summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--run.c34
-rw-r--r--run.h7
-rw-r--r--script/vdr-uactivity18
-rw-r--r--uactivity.c10
4 files changed, 45 insertions, 24 deletions
diff --git a/run.c b/run.c
index a7a698c..f1a5d65 100644
--- a/run.c
+++ b/run.c
@@ -11,6 +11,16 @@ cRun::~cRun()
if (myResourceDirectory) free(myResourceDirectory);
}
+const char *cRun::OrginToString(eOrgin Orgin)
+{
+ const char *OrginStr = "";
+ if (Orgin == oStartUp) OrginStr = "startup";
+ else if (Orgin == oShutDown) OrginStr = "shutdown";
+ else if (Orgin == oRunning) OrginStr = "running";
+
+ return OrginStr;
+}
+
void cRun::SetConfigDirectory(const char *Directory)
{
myConfigDirectory = strdup(Directory);
@@ -28,38 +38,30 @@ void cRun::SetResourceDirectory(const char *Directory)
void cRun::Call(eOrgin Orgin, bool Active)
{
- char *OrginStr = NULL;
- if (Orgin == oStartUp) OrginStr = strdup("startup");
- else if (Orgin == oShutDown) OrginStr = strdup("shutdown");
- else if (Orgin == oRunning) OrginStr = strdup("running");
-
- char *ActivityStatusStr = NULL;
+ const char *ActivityStatusStr = "";
if (Active)
- ActivityStatusStr = strdup("true");
+ ActivityStatusStr = "true";
else
- ActivityStatusStr = strdup("false");
+ ActivityStatusStr = "false";
char *buffer;
- asprintf(&buffer, UACTIVITY_COMMAND, "activity", OrginStr, ActivityStatusStr, myConfigDirectory, myCacheDirectory, myResourceDirectory);
+ asprintf(&buffer, UACTIVITY_COMMAND, "activity", OrginToString(Orgin), ActivityStatusStr, myConfigDirectory, myCacheDirectory, myResourceDirectory);
SystemExec(buffer, true);
free(buffer);
-
- if (ActivityStatusStr) free(ActivityStatusStr);
- if (OrginStr) free(OrginStr);
}
-void cRun::Call(eKeys Key)
+void cRun::Call(eOrgin Orgin, eKeys Key)
{
char *buffer;
- asprintf(&buffer, UACTIVITY_COMMAND, "key", "none", myKey.ToString(Key), myConfigDirectory, myCacheDirectory, myResourceDirectory);
+ asprintf(&buffer, UACTIVITY_COMMAND, "key", OrginToString(Orgin), myKey.ToString(Key), myConfigDirectory, myCacheDirectory, myResourceDirectory);
SystemExec(buffer, true);
free(buffer);
}
-void cRun::Call()
+void cRun::Call(eOrgin Orgin)
{
char *buffer;
- asprintf(&buffer, UACTIVITY_COMMAND, "watchdog", "none", "none", myConfigDirectory, myCacheDirectory, myResourceDirectory);
+ asprintf(&buffer, UACTIVITY_COMMAND, "watchdog", OrginToString(Orgin), "none", myConfigDirectory, myCacheDirectory, myResourceDirectory);
SystemExec(buffer, true);
free(buffer);
}
diff --git a/run.h b/run.h
index e6c035e..9366e65 100644
--- a/run.h
+++ b/run.h
@@ -11,15 +11,16 @@ private:
char *myCacheDirectory;
char *myResourceDirectory;
cKey myKey;
+ static const char *OrginToString(eOrgin Orgin);
public:
cRun() { };
~cRun();
void SetConfigDirectory(const char *Directory);
void SetCacheDirectory(const char *Directory);
void SetResourceDirectory(const char *Directory);
- void Call(eOrgin Orgin, bool Active=false);
- void Call(eKeys Key);
- void Call();
+ void Call(eOrgin Orgin, bool Active);
+ void Call(eOrgin Orgin, eKeys Key);
+ void Call(eOrgin Orgin);
};
extern cRun Run;
diff --git a/script/vdr-uactivity b/script/vdr-uactivity
index b1504bf..ee3b3c8 100644
--- a/script/vdr-uactivity
+++ b/script/vdr-uactivity
@@ -33,12 +33,26 @@ done
[ -d "${PARAM_CONFIGDIRECTORY}/${PARAM_REASON}" ] || exit 0
+case "${PARAM_REASON}" in
+ activity)
+ commandline="${PARAM_ORGIN} ${PARAM_VALUE}"
+ ;;
+ key)
+ [ "${PARAM_VALUE}" != "_Setup" ] \
+ && commandline="${PARAM_ORGIN} ${PARAM_VALUE}" \
+ || commandline="${PARAM_ORGIN} ''"
+ ;;
+ watchdog)
+ commandline="${PARAM_ORGIN} ''"
+ ;;
+esac
+
hooks="$(find "${PARAM_CONFIGDIRECTORY}/${PARAM_REASON}" -maxdepth 1 -xtype f -name '[0-9][0-9]*' | sort)"
for hook in ${hooks}; do
if [ -x $hook ]; then
- $hook $PARAM_ORGIN $PARAM_VALUE "$PARAM_CONFIGDIRECTORY" "$PARAM_CACHEDIRECTORY" "$PARAM_RESOURCEDIRECTORY"
+ eval $hook $commandline "$PARAM_CONFIGDIRECTORY" "$PARAM_CACHEDIRECTORY" "$PARAM_RESOURCEDIRECTORY"
else
- /bin/sh $hook $PARAM_ORGIN $PARAM_VALUE "$PARAM_CONFIGDIRECTORY" "$PARAM_CACHEDIRECTORY" "$PARAM_RESOURCEDIRECTORY"
+ eval /bin/sh $hook $commandline "$PARAM_CONFIGDIRECTORY" "$PARAM_CACHEDIRECTORY" "$PARAM_RESOURCEDIRECTORY"
fi
[ $? -ne 0 ] && ${LOG} "error when executing ${hook}"
done
diff --git a/uactivity.c b/uactivity.c
index 44b7323..ed6ab97 100644
--- a/uactivity.c
+++ b/uactivity.c
@@ -55,7 +55,7 @@ protected:
eOSState state = cOsdMenu::ProcessKey(Key);
if (state == osUnknown)
if ((Key >= kUp) && (Key < kNone)) {
- Run.Call(Key);
+ Run.Call(oRunning, Key);
return osEnd;
}
return state;
@@ -116,12 +116,14 @@ bool cPluginUactivity::Start(void)
Run.SetResourceDirectory(ConfigDirectory(PLUGIN_NAME_I18N));
#endif
+ Run.Call(oStartUp, k_Setup);
+
bool ActivityStatus = !ShutdownHandler.IsUserInactive();
LastActivity = ActivityStatus;
Run.Call(oStartUp, ActivityStatus);
time(&LastTime);
- if (WatchdogTimer > 0) Run.Call();
+ if (WatchdogTimer > 0) Run.Call(oStartUp);
return true;
}
@@ -129,6 +131,8 @@ bool cPluginUactivity::Start(void)
void cPluginUactivity::Stop(void)
{
// Stop any background activities the plugin is performing.
+ Run.Call(oShutDown, k_Setup);
+ Run.Call(oShutDown, false);
Run.Call(oShutDown);
}
@@ -147,7 +151,7 @@ void cPluginUactivity::MainThreadHook(void)
time(&Seconds);
if (difftime(Seconds, LastTime) >= WatchdogTimer) {
time(&LastTime);
- Run.Call();
+ Run.Call(oRunning);
}
}
}