diff options
author | Timo Eskola <timo@tolleri.net> | 2015-09-08 13:45:38 +0300 |
---|---|---|
committer | Timo Eskola <timo@tolleri.net> | 2015-09-08 13:45:38 +0300 |
commit | 5803854e175a911011abc760b3cda23dae05b50a (patch) | |
tree | 33864afc0db289d1de30296d5d580098165d0604 | |
parent | 9d91a147e9be5fa93af2d5e8753464546566174e (diff) | |
download | vdr-plugin-useractivity-5803854e175a911011abc760b3cda23dae05b50a.tar.gz vdr-plugin-useractivity-5803854e175a911011abc760b3cda23dae05b50a.tar.bz2 |
Version 0.0.3
-rw-r--r-- | activity.c | 21 | ||||
-rw-r--r-- | activity.h | 4 | ||||
-rw-r--r-- | useractivity.c | 18 |
3 files changed, 42 insertions, 1 deletions
@@ -9,14 +9,19 @@ #include <stdlib.h> #include <stdio.h> #include <syslog.h> +#ifdef USE_XSS #include <X11/Xlib.h> #include <X11/extensions/scrnsaver.h> +#endif #include <utmp.h> #include <string.h> #include <sstream> #include <sys/stat.h> #include <time.h> #include <vdr/config.h> +#if VDRVERSNUM >= 10501 +#include <vdr/shutdown.h> +#endif #include "activity.h" #ifdef USE_XSS @@ -100,6 +105,9 @@ char *cUserActivity::GetUsers(void) { using namespace std; stringstream stream; +#if VDRVERSNUM >= 10501 + stream << "VDR user has been inactive " << GetUserInactivity() << " minutes." << endl; +#endif stream << "USER DEVICE IDLE" << endl; setutent(); while((uptr = getutent())!=NULL) { @@ -124,3 +132,16 @@ char *cUserActivity::GetUsers(void) { strcpy(result, resultString.c_str()); return result; } + +#if VDRVERSNUM >= 10501 +int cUserActivity::GetUserInactivity(void) { + return GetMinUserInactivity() ? + GetMinUserInactivity() - 1 - + (ShutdownHandler.GetUserInactiveTime() - time(NULL))/60 : -1; +} + +void cUserActivity::UserActivity(void) { + ShutdownHandler.SetUserInactiveTimeout(); +} +#endif + @@ -20,6 +20,10 @@ class cUserActivity { static void SetMinUserInactivity(int minutes); static int GetMinUserInactivity(void); static char *GetUsers(void); +#if VDRVERSNUM >= 10501 + static int GetUserInactivity(void); + static void UserActivity(void); +#endif }; #endif diff --git a/useractivity.c b/useractivity.c index 6f510e5..c94a18f 100644 --- a/useractivity.c +++ b/useractivity.c @@ -10,7 +10,7 @@ #include "i18n.h" #include "activity.h" -static const char *VERSION = "0.0.2"; +static const char *VERSION = "0.0.3"; static const char *DESCRIPTION = trNOOP("Prevents shutdown if there are active users"); #if 0 static const char *MAINMENUENTRY = trNOOP("Active users"); @@ -137,6 +137,10 @@ const char **cPluginUseractivity::SVDRPHelpPages(void) " Display minimum user inactivity in minutes.", "LSTU\n" " Display a list of users.", +#if VDRVERSNUM >= 10501 + "SETA\n" + " Set VDR user activity.", +#endif "SETI <minutes>\n" " Set minimum user inactivity in minutes.", NULL @@ -149,12 +153,24 @@ cString cPluginUseractivity::SVDRPCommand(const char *Command, const char *Optio // Process SVDRP commands this plugin implements if (strcasecmp(Command, "GETI") == 0) { // we use the default reply code here +#if VDRVERSNUM >= 10501 + return cString::sprintf("Minimum user inactivity is %d minutes.\nVDR user has been inactive %d minutes.", + cUserActivity::GetMinUserInactivity(), cUserActivity::GetUserInactivity()); +#else return cString::sprintf("Minimum user inactivity is %d minutes.", cUserActivity::GetMinUserInactivity()); +#endif } else if (strcasecmp(Command, "LSTU") == 0) { // we use the default reply code here return cString(cUserActivity::GetUsers()); } +#if VDRVERSNUM >= 10501 + else if (strcasecmp(Command, "SETA") == 0) { + // we use the default reply code here + cUserActivity::UserActivity(); + return cString::sprintf("VDR user set active."); +} +#endif else if (strcasecmp(Command, "SETI") == 0) { ReplyCode = 501; if (*Option) { |