diff options
-rw-r--r-- | HISTORY | 11 | ||||
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | activity.c | 37 | ||||
-rw-r--r-- | activity.h | 3 | ||||
-rw-r--r-- | useractivity.c | 2 |
6 files changed, 45 insertions, 14 deletions
@@ -1,6 +1,17 @@ VDR Plugin 'useractivity' Revision History ------------------------------------------ +2007-11-26: Version 0.0.4 + +- Fixed X activity detection for Ubuntu 7.10. +- Fixed compilation without XSS. +- Added host to LSTU printout. +- Fixed SVDRP command SETI for VDR 1.5.1 and later. + +2007-09-11: Version 0.0.3 + +- New SVDRP command SETA. + 2007-08-19: Version 0.0.2 - Updated for VDR 1.5.8. @@ -69,7 +69,9 @@ OBJS = $(PLUGIN).o activity.o i18n.o ### Libraries -LIBS = -lX11 -lXss +ifeq ($(USERACTIVITY_XSS), 1) + LIBS = -lX11 -lXss +endif ### Implicit rules: @@ -18,6 +18,8 @@ GETI Display minimum user inactivity in minutes. LSTU Display a list of users. +SETA + Set VDR user activity. SETI <minutes> Set minimum user inactivity in minutes. @@ -67,6 +67,22 @@ int cUserActivity::DeviceIdleTime(char *device) { return idle; } +int cUserActivity::IdleTime(struct utmp *uptr) { + int idle = -1; +#ifdef USE_XSS + /* Detecting display idle time for ut_hosts * + * without screen. This is based on Ubuntu 7.10 * + * where X has valid device in ut_line. */ + char *cptr = strchr(uptr->ut_host, ':'); + if(cptr != NULL ) { + if(strchr(cptr+1,'.') == NULL) + idle = DisplayIdleTime(uptr->ut_host); + } +#endif + if(idle < 0) + idle = DeviceIdleTime(uptr->ut_line); + return idle; +} bool cUserActivity::ActiveUsers(void) { struct utmp *uptr; @@ -76,11 +92,7 @@ bool cUserActivity::ActiveUsers(void) { setutent(); while((uptr = getutent())!=NULL) { if(uptr->ut_type == USER_PROCESS) { - idle = DeviceIdleTime(uptr->ut_line); -#ifdef USE_XSS - if(idle < 0 && strchr(uptr->ut_line, ':') != NULL) - idle = DisplayIdleTime(uptr->ut_line); -#endif + idle = IdleTime(uptr); if(idle >= 0 && idle < Setup.MinUserInactivity) { result = true; break; @@ -93,6 +105,9 @@ bool cUserActivity::ActiveUsers(void) { void cUserActivity::SetMinUserInactivity(int minutes) { Setup.MinUserInactivity = minutes; +#if VDRVERSNUM >= 10501 + ShutdownHandler.SetUserInactiveTimeout(); +#endif } int cUserActivity::GetMinUserInactivity(void) { @@ -108,21 +123,19 @@ char *cUserActivity::GetUsers(void) { #if VDRVERSNUM >= 10501 stream << "VDR user has been inactive " << GetUserInactivity() << " minutes." << endl; #endif - stream << "USER DEVICE IDLE" << endl; + stream << "USER DEVICE IDLE HOST" << endl; setutent(); while((uptr = getutent())!=NULL) { if(uptr->ut_type == USER_PROCESS) { - idle = DeviceIdleTime(uptr->ut_line); -#ifdef USE_XSS - if(idle < 0 && strchr(uptr->ut_line, ':') != NULL) - idle = DisplayIdleTime(uptr->ut_line); -#endif + idle = IdleTime(uptr); stream.width(15); stream << left << uptr->ut_user; stream.width(15); stream << left << uptr->ut_line; + stream.width(10); + stream << left << idle; stream.width(0); - stream << idle << endl; + stream << uptr->ut_host << endl; } } endutent(); @@ -9,12 +9,15 @@ #ifndef _USERACTILITY_ACTIVITY_H #define _USERACTILITY_ACTIVITY_H +#include <utmp.h> + class cUserActivity { private: #ifdef USE_XSS static int DisplayIdleTime(char *display); #endif static int DeviceIdleTime(char *device); + static int IdleTime(struct utmp *uptr); public: static bool ActiveUsers(void); static void SetMinUserInactivity(int minutes); diff --git a/useractivity.c b/useractivity.c index c94a18f..86f42f9 100644 --- a/useractivity.c +++ b/useractivity.c @@ -10,7 +10,7 @@ #include "i18n.h" #include "activity.h" -static const char *VERSION = "0.0.3"; +static const char *VERSION = "0.0.4"; static const char *DESCRIPTION = trNOOP("Prevents shutdown if there are active users"); #if 0 static const char *MAINMENUENTRY = trNOOP("Active users"); |