summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--HISTORY11
-rw-r--r--Makefile4
-rw-r--r--README2
-rw-r--r--activity.c37
-rw-r--r--activity.h3
-rw-r--r--useractivity.c2
6 files changed, 45 insertions, 14 deletions
diff --git a/HISTORY b/HISTORY
index 8e4cfa6..fc32bd5 100644
--- a/HISTORY
+++ b/HISTORY
@@ -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.
diff --git a/Makefile b/Makefile
index 8f0d512..f95dd8f 100644
--- a/Makefile
+++ b/Makefile
@@ -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:
diff --git a/README b/README
index 71962bd..37ebade 100644
--- a/README
+++ b/README
@@ -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.
diff --git a/activity.c b/activity.c
index 1ab8f04..36b3ee2 100644
--- a/activity.c
+++ b/activity.c
@@ -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();
diff --git a/activity.h b/activity.h
index 051a193..707b9b2 100644
--- a/activity.h
+++ b/activity.h
@@ -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");