From d5ec7490e249d51081d0e516aee0fc6fb2088072 Mon Sep 17 00:00:00 2001
From: leslie <unknown>
Date: Mon, 7 Jan 2008 22:17:06 +0100
Subject: [PATCH] add user message display to OSD

---
 data.c      |  5 ++++-
 log.c       | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 log.h       | 29 ++++++++++++++++++++++++++++-
 po/de_DE.po |  8 +++++++-
 po/fi_FI.po |  8 +++++++-
 po/fr_FR.po |  8 +++++++-
 po/hu_HU.po |  8 +++++++-
 po/it_IT.po | 10 ++++++++--
 po/nl_NL.po |  8 +++++++-
 po/pl_PL.po |  8 +++++++-
 po/ru_RU.po |  8 +++++++-
 po/sv_SE.po |  8 +++++++-
 sc.c        | 14 +++++++++++++-
 13 files changed, 159 insertions(+), 14 deletions(-)

diff --git a/data.c b/data.c
index ad4925e..42e9c73 100644
--- a/data.c
+++ b/data.c
@@ -29,6 +29,7 @@
 #include "misc.h"
 #include "scsetup.h"
 #include "log-core.h"
+#include "i18n.h"
 
 #define KEY_FILE     "SoftCam.Key"
 #define EXT_AU_INT   (15*60*1000) // ms interval for external AU
@@ -883,7 +884,9 @@ bool cPlainKeys::AddNewKey(cPlainKey *nk, const char *reason)
     if(k->Cmp(nk)) return false;
 
   cPlainKey *ref=0;
-  PRINTF(L_GEN_INFO,"key update for ID %s",*nk->ToString(true));
+  cString ks=nk->ToString(true);
+  PRINTF(L_GEN_INFO,"key update for ID %s",*ks);
+  ums.Queue("%s %s",tr("Key update"),*ks);
   for(k=0; (k=FindKeyNoTrig(nk->type,nk->id,nk->keynr,nk->Size(),k)); ) {
     if(nk->CanSupersede()) {
       PRINTF(L_GEN_INFO,"supersedes key: %s",*k->ToString(true));
diff --git a/log.c b/log.c
index 170d4da..b8c4c07 100644
--- a/log.c
+++ b/log.c
@@ -38,7 +38,7 @@ struct LogHeader {
   };
 
 struct LogConfig logcfg = {
-  1,0,0,
+  1,0,0,0,
   0,
   "/var/log/vdr-sc"
   };
@@ -396,6 +396,55 @@ int cLogging::GetClassByName(const char *name)
   return -1;  
 }
 
+// -- cUserMsg -----------------------------------------------------------------
+
+cUserMsg::cUserMsg(const char *m)
+{
+  msg=strdup(m);
+}
+
+cUserMsg::~cUserMsg()
+{
+  free(msg);
+}
+
+// -- cUserMsgs ----------------------------------------------------------------
+
+cUserMsgs ums;
+
+cUserMsgs::cUserMsgs(void)
+{
+  mutex=new cMutex;
+}
+
+cUserMsgs::~cUserMsgs()
+{
+  delete mutex;
+}
+
+void cUserMsgs::Queue(const char *fmt, ...)
+{
+  if(logcfg.logUser) {
+    char buff[1024];
+    va_list ap;
+    va_start(ap,fmt);
+    vsnprintf(buff,sizeof(buff),fmt,ap);
+    va_end(ap);
+    mutex->Lock();
+    Add(new cUserMsg(buff));
+    mutex->Unlock();
+    }
+}
+
+cUserMsg *cUserMsgs::GetQueuedMsg(void)
+{
+  mutex->Lock();
+  cUserMsg *um=First();
+  if(um) Del(um,false);
+  mutex->Unlock();
+  return um;
+}
+
 // -- cLogLineBuff -------------------------------------------------------------
 
 cLogLineBuff::cLogLineBuff(int C)
diff --git a/log.h b/log.h
index 38fa86b..e523f34 100644
--- a/log.h
+++ b/log.h
@@ -22,6 +22,8 @@
 
 #include "misc.h"
 
+class cMutex;
+
 // ----------------------------------------------------------------
 
 #define LOPT_NUM    24
@@ -68,7 +70,7 @@
 // ----------------------------------------------------------------
 
 struct LogConfig {
-  int logCon, logFile, logSys;
+  int logCon, logFile, logSys, logUser;
   int maxFilesize;
   char logFilename[128];
   };
@@ -112,6 +114,31 @@ public:
 
 // ----------------------------------------------------------------
 
+class cUserMsg : public cSimpleItem {
+private:
+  char *msg;
+public:
+  cUserMsg(const char *m);
+  ~cUserMsg();
+  const char *Message(void) { return msg; };
+  };
+
+// ----------------------------------------------------------------
+
+class cUserMsgs : public cSimpleList<cUserMsg> {
+private:
+  cMutex *mutex;
+public:
+  cUserMsgs(void);
+  ~cUserMsgs();
+  void Queue(const char *fmt, ...) __attribute__ ((format (printf,2,3)));
+  cUserMsg *GetQueuedMsg(void);
+  };
+
+extern cUserMsgs ums;
+
+// ----------------------------------------------------------------
+
 class cLogLineBuff : public cLineBuff {
 private:
   int c;
diff --git a/po/de_DE.po b/po/de_DE.po
index 6b231b9..76e4e14 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: VDR 1.5.9\n"
 "Report-Msgid-Bugs-To: <noone@nowhere.org>\n"
-"POT-Creation-Date: 2007-12-19 18:49+0100\n"
+"POT-Creation-Date: 2008-01-07 22:10+0100\n"
 "PO-Revision-Date: 2007-08-27 12:45+0200\n"
 "Last-Translator: somebody\n"
 "Language-Team: somebody\n"
@@ -14,6 +14,9 @@ msgstr ""
 "Content-Type: text/plain; charset=ISO-8859-15\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+msgid "Key update"
+msgstr "Key Update"
+
 msgid "off"
 msgstr "aus"
 
@@ -148,6 +151,9 @@ msgstr "Dateigr
 msgid "Log to syslog"
 msgstr "Meldungen in Syslog"
 
+msgid "Show user messages"
+msgstr "Benutzer Meldungen zeigen"
+
 msgid "A software emulated CAM"
 msgstr "Ein Software emuliertes CAM"
 
diff --git a/po/fi_FI.po b/po/fi_FI.po
index 2447c7d..3482afc 100644
--- a/po/fi_FI.po
+++ b/po/fi_FI.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: VDR 1.5.9\n"
 "Report-Msgid-Bugs-To: <noone@nowhere.org>\n"
-"POT-Creation-Date: 2007-12-19 18:52+0100\n"
+"POT-Creation-Date: 2008-01-07 22:10+0100\n"
 "PO-Revision-Date: 2007-08-27 12:45+0200\n"
 "Last-Translator: somebody\n"
 "Language-Team: somebody\n"
@@ -14,6 +14,9 @@ msgstr ""
 "Content-Type: text/plain; charset=ISO-8859-15\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+msgid "Key update"
+msgstr ""
+
 msgid "off"
 msgstr "pois"
 
@@ -148,6 +151,9 @@ msgstr "Tiedoston maksimikoko (KB)"
 msgid "Log to syslog"
 msgstr "Tulosta systeemilokiin"
 
+msgid "Show user messages"
+msgstr ""
+
 msgid "A software emulated CAM"
 msgstr "Ohjelmistopohjainen salauksenpurku"
 
diff --git a/po/fr_FR.po b/po/fr_FR.po
index 6fd88fe..4e31102 100644
--- a/po/fr_FR.po
+++ b/po/fr_FR.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: VDR 1.5.9\n"
 "Report-Msgid-Bugs-To: <noone@nowhere.org>\n"
-"POT-Creation-Date: 2007-12-19 18:52+0100\n"
+"POT-Creation-Date: 2008-01-07 22:10+0100\n"
 "PO-Revision-Date: 2007-08-27 12:45+0200\n"
 "Last-Translator: somebody\n"
 "Language-Team: somebody\n"
@@ -14,6 +14,9 @@ msgstr ""
 "Content-Type: text/plain; charset=ISO-8859-1\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+msgid "Key update"
+msgstr ""
+
 msgid "off"
 msgstr "off"
 
@@ -148,6 +151,9 @@ msgstr ""
 msgid "Log to syslog"
 msgstr ""
 
+msgid "Show user messages"
+msgstr ""
+
 msgid "A software emulated CAM"
 msgstr "Un logiciel emulateur de CAM"
 
diff --git a/po/hu_HU.po b/po/hu_HU.po
index 9744b77..7b76ea3 100644
--- a/po/hu_HU.po
+++ b/po/hu_HU.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: VDR 1.5.11\n"
 "Report-Msgid-Bugs-To: <noone@nowhere.org>\n"
-"POT-Creation-Date: 2007-12-19 18:52+0100\n"
+"POT-Creation-Date: 2008-01-07 22:10+0100\n"
 "PO-Revision-Date: 2007-11-01 16:45+0200\n"
 "Last-Translator: jv\n"
 "Language-Team: somebody\n"
@@ -14,6 +14,9 @@ msgstr ""
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+msgid "Key update"
+msgstr ""
+
 msgid "off"
 msgstr "ki"
 
@@ -148,6 +151,9 @@ msgstr "Fileméret limit (KB)"
 msgid "Log to syslog"
 msgstr "Naplózás a rendszelogba"
 
+msgid "Show user messages"
+msgstr ""
+
 msgid "A software emulated CAM"
 msgstr "Szoftveresen emulált CAM"
 
diff --git a/po/it_IT.po b/po/it_IT.po
index df9c34d..1b75611 100644
--- a/po/it_IT.po
+++ b/po/it_IT.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: VDR 1.5.9\n"
 "Report-Msgid-Bugs-To: <noone@nowhere.org>\n"
-"POT-Creation-Date: 2007-12-19 18:52+0100\n"
+"POT-Creation-Date: 2008-01-07 22:10+0100\n"
 "PO-Revision-Date: 2007-08-27 12:45+0200\n"
 "Last-Translator: somebody\n"
 "Language-Team: somebody\n"
@@ -14,6 +14,9 @@ msgstr ""
 "Content-Type: text/plain; charset=ISO-8859-15\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+msgid "Key update"
+msgstr ""
+
 msgid "off"
 msgstr "spento"
 
@@ -148,6 +151,9 @@ msgstr "Limite dimensione file (KB)"
 msgid "Log to syslog"
 msgstr "Log in Syslog"
 
+msgid "Show user messages"
+msgstr ""
+
 msgid "A software emulated CAM"
 msgstr "Un software di emulazione CAM"
 
@@ -200,4 +206,4 @@ msgid "SC-Seca: EMM updates"
 msgstr "SC-Seca: aggiornamenti EMM"
 
 msgid "SC-Seca: activate PPV"
-msgstr "SC-Seca: attiva PPV" 
+msgstr "SC-Seca: attiva PPV"
diff --git a/po/nl_NL.po b/po/nl_NL.po
index 5cc85db..eb9e6b8 100644
--- a/po/nl_NL.po
+++ b/po/nl_NL.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: VDR 1.5.9\n"
 "Report-Msgid-Bugs-To: <noone@nowhere.org>\n"
-"POT-Creation-Date: 2007-12-19 18:52+0100\n"
+"POT-Creation-Date: 2008-01-07 22:10+0100\n"
 "PO-Revision-Date: 2007-08-27 12:45+0200\n"
 "Last-Translator: somebody\n"
 "Language-Team: somebody\n"
@@ -14,6 +14,9 @@ msgstr ""
 "Content-Type: text/plain; charset=ISO-8859-15\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+msgid "Key update"
+msgstr ""
+
 msgid "off"
 msgstr "uit"
 
@@ -148,6 +151,9 @@ msgstr ""
 msgid "Log to syslog"
 msgstr ""
 
+msgid "Show user messages"
+msgstr ""
+
 msgid "A software emulated CAM"
 msgstr "In software geëmuleerde CAM"
 
diff --git a/po/pl_PL.po b/po/pl_PL.po
index 184cb32..709c728 100644
--- a/po/pl_PL.po
+++ b/po/pl_PL.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: VDR 1.5.9\n"
 "Report-Msgid-Bugs-To: <noone@nowhere.org>\n"
-"POT-Creation-Date: 2007-12-19 18:52+0100\n"
+"POT-Creation-Date: 2008-01-07 22:10+0100\n"
 "PO-Revision-Date: 2007-08-27 12:45+0200\n"
 "Last-Translator: somebody\n"
 "Language-Team: somebody\n"
@@ -14,6 +14,9 @@ msgstr ""
 "Content-Type: text/plain; charset=ISO-8859-2\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+msgid "Key update"
+msgstr ""
+
 msgid "off"
 msgstr "wy³±cz"
 
@@ -148,6 +151,9 @@ msgstr ""
 msgid "Log to syslog"
 msgstr ""
 
+msgid "Show user messages"
+msgstr ""
+
 msgid "A software emulated CAM"
 msgstr "Programowo emulowany CAM"
 
diff --git a/po/ru_RU.po b/po/ru_RU.po
index c1d6a19..f370e5f 100644
--- a/po/ru_RU.po
+++ b/po/ru_RU.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: VDR 1.5.9\n"
 "Report-Msgid-Bugs-To: <noone@nowhere.org>\n"
-"POT-Creation-Date: 2007-12-19 18:52+0100\n"
+"POT-Creation-Date: 2008-01-07 22:10+0100\n"
 "PO-Revision-Date: 2008-01-03 14:21+0100\n"
 "Last-Translator: somebody\n"
 "Language-Team: ru\n"
@@ -15,6 +15,9 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "X-Generator: KBabel 1.11.4\n"
 
+msgid "Key update"
+msgstr ""
+
 msgid "off"
 msgstr "ÒëÚÛ"
 
@@ -149,6 +152,9 @@ msgstr "
 msgid "Log to syslog"
 msgstr "ÁÞÞÑéÕÝØï Ò Syslog"
 
+msgid "Show user messages"
+msgstr ""
+
 msgid "A software emulated CAM"
 msgstr "¿àÞÓàÐÜÝëÙ íÜãÛïâÞà CAM"
 
diff --git a/po/sv_SE.po b/po/sv_SE.po
index 04fcf04..e424901 100644
--- a/po/sv_SE.po
+++ b/po/sv_SE.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: VDR 1.5.9\n"
 "Report-Msgid-Bugs-To: <noone@nowhere.org>\n"
-"POT-Creation-Date: 2007-12-19 18:52+0100\n"
+"POT-Creation-Date: 2008-01-07 22:10+0100\n"
 "PO-Revision-Date: 2007-08-27 12:45+0200\n"
 "Last-Translator: somebody\n"
 "Language-Team: somebody\n"
@@ -14,6 +14,9 @@ msgstr ""
 "Content-Type: text/plain; charset=ISO-8859-1\n"
 "Content-Transfer-Encoding: 8bit\n"
 
+msgid "Key update"
+msgstr ""
+
 msgid "off"
 msgstr "av"
 
@@ -148,6 +151,9 @@ msgstr ""
 msgid "Log to syslog"
 msgstr ""
 
+msgid "Show user messages"
+msgstr ""
+
 msgid "A software emulated CAM"
 msgstr "En mjukvaruemulerad CAM"
 
diff --git a/sc.c b/sc.c
index 50f2860..33b64df 100644
--- a/sc.c
+++ b/sc.c
@@ -1192,6 +1192,7 @@ public:
   virtual bool Start(void);
   virtual void Stop(void);
   virtual void Housekeeping(void);
+  virtual void MainThreadHook(void);
   virtual cMenuSetupPage *SetupMenu(void);
   virtual bool SetupParse(const char *Name, const char *Value);
   virtual const char **SVDRPHelpPages(void);
@@ -1209,12 +1210,13 @@ cScPlugin::cScPlugin(void)
   ScOpts->Add(new cOptBool ("LocalPriority",trNOOP("Prefer local systems") ,&ScSetup.LocalPriority));
   ScOpts->Add(new cOptMInt ("ScCaps"       ,trNOOP("Active on DVB card")   , ScSetup.ScCaps,MAXSCCAPS,0));
   ScOpts->Add(new cOptMInt ("CaIgnore"     ,trNOOP("Ignore CAID")          , ScSetup.CaIgnore,MAXCAIGN,2));
-  LogOpts=new cOpts(0,5);
+  LogOpts=new cOpts(0,6);
   LogOpts->Add(new cOptBool ("LogConsole"  ,trNOOP("Log to console")      ,&logcfg.logCon));
   LogOpts->Add(new cOptBool ("LogFile"     ,trNOOP("Log to file")         ,&logcfg.logFile));
   LogOpts->Add(new cOptStr  ("LogFileName" ,trNOOP("Filename")            ,logcfg.logFilename,sizeof(logcfg.logFilename),FileNameChars));
   LogOpts->Add(new cOptInt  ("LogFileLimit",trNOOP("Filesize limit (KB)") ,&logcfg.maxFilesize,0,2000000));
   LogOpts->Add(new cOptBool ("LogSyslog"   ,trNOOP("Log to syslog")       ,&logcfg.logSys));
+  LogOpts->Add(new cOptBool ("LogUserMsg"  ,trNOOP("Show user messages")  ,&logcfg.logUser));
 #ifndef STATICBUILD
   dlls.Load();
 #endif
@@ -1366,6 +1368,16 @@ void cScPlugin::Housekeeping(void)
   cSoftCAM::HouseKeeping();
 }
 
+void cScPlugin::MainThreadHook(void)
+{
+  int n=0;
+  cUserMsg *um;
+  while(++n<=10 && (um=ums.GetQueuedMsg())) {
+    Skins.QueueMessage(mtInfo,um->Message());
+    delete um;
+    }
+}
+
 const char **cScPlugin::SVDRPHelpPages(void)
 {
   static const char *HelpPages[] = {
-- 
2.39.5