eOSState cMenuLogSys::ProcessKey(eKeys Key) { eOSState state=cOsdMenu::ProcessKey(Key); switch(state) { case osUser9: if(Interface->Confirm(tr("Really disable ALL modules?"))) { for(int m=1; m<LMOD_MAX; m++) cLogging::SetModuleOption(LCLASS(m,LMOD_ENABLE),false); Store(); state=osBack; } break; case osUser8: if(Interface->Confirm(tr("Really reset ALL modules to default?"))) { for(int m=1; m<LMOD_MAX; m++) cLogging::SetModuleDefault(LCLASS(m,0)); Store(); state=osBack; } break; case osUnknown: if(Key==kOk) { cLogModItem *item=dynamic_cast<cLogModItem *>(Get(Current())); if(item) state=AddSubMenu(new cMenuLogMod(item->Module())); else { Store(); state=osBack; } } break; default: break; } return state; }
eOSState cMenuLogMod::ProcessKey(eKeys Key) { eOSState state=cOsdMenu::ProcessKey(Key); switch(state) { case osUser9: if(Interface->Confirm(tr("Really reset module to default?"))) { cLogging::SetModuleDefault(LCLASS(m,0)); ScSetup.Store(false); state=osBack; } break; case osContinue: if(NORMALKEY(Key)==kLeft || NORMALKEY(Key)==kRight) { cLogOptItem *item=dynamic_cast<cLogOptItem *>(Get(Current())); if(item) { int o=item->Option(); cLogging::SetModuleOption(LCLASS(m,1<<o),cfg[o]); } } break; case osUnknown: if(Key==kOk) { Store(); state=osBack; } break; default: break; } return state; }
void cMenuLogMod::Store(void) { int o=0; for(int i=0; i<LOPT_NUM; i++) if(v[i] && cfg[i]) o|=(1<<i); cLogging::SetModuleOptions(LCLASS(m,o)); ScSetup.Store(false); }
cMenuLogSys::cMenuLogSys(void) :cOsdMenu(tr("Message logging"),33) { LogOpts->Backup(); LogOpts->Create(this); Add(new cOsdItem(tr("Disable ALL modules"),osUser9)); Add(new cOsdItem(tr("Reset ALL modules to default"),osUser8)); for(int m=1; m<LMOD_MAX; m++) { const char *name=cLogging::GetModuleName(LCLASS(m,0)); if(name) Add(new cLogModItem(name,m)); } Display(); }
cMenuLogMod::cMenuLogMod(int M) :cOsdMenu(tr("Module config"),33) { m=M; Add(new cOsdItem(tr("Reset module to default"),osUser9)); const char *name=cLogging::GetModuleName(LCLASS(m,0)); int o=cLogging::GetModuleOptions(LCLASS(m,0)); if(o>=0) { for(int i=0; i<LOPT_NUM; i++) { const char *opt; if(i==0) opt="enable"; else opt=cLogging::GetOptionName(LCLASS(m,1<<i)); if(opt) { char buff[64]; snprintf(buff,sizeof(buff),"%s.%s",name,opt); cfg[i]=(o&(1<<i)) ? 1:0; v[i]=1; Add(new cLogOptItem(buff,i,&cfg[i])); } else v[i]=0; } } Display(); }
cString cScPlugin::SVDRPCommand(const char *Command, const char *Option, int &ReplyCode) { if(!strcasecmp(Command,"RELOAD")) { if(cGlobal::Active(true)) { ReplyCode=550; return "Softcam active. Can't reload files now"; } else { if(cSoftCAM::Load(ConfigDirectory(cfgsub))) return "Files reloaded successfully"; else { ReplyCode=901; return "Reloading files not entirely successfull"; } } } else if(!strcasecmp(Command,"KEY")) { if(Option && *Option) { if(keys.NewKeyParse(skipspace(Option),"from SVDR")) return "Key update successfull"; else { ReplyCode=901; return "Key already known or invalid key format"; } } else { ReplyCode=501; return "Missing args"; } } else if(!strcasecmp(Command,"LOG")) { if(Option && *Option) { char tmp[1024]; strn0cpy(tmp,Option,sizeof(tmp)); char *opt=tmp; opt=skipspace(opt); bool mode; if(!strncasecmp(opt,"ON ",3)) { mode=true; opt+=3; } else if(!strncasecmp(opt,"OFF ",4)) { mode=false; opt+=4; } else { ReplyCode=501; return "Bad mode, valid: on off"; } do { char *s=index(opt,','); if(s) *s++=0; int c=cLogging::GetClassByName(opt); if(c>=0) cLogging::SetModuleOption(c,mode); else { ReplyCode=501; return "Unknown message class"; } opt=s; } while(opt); ScSetup.Store(true); Setup.Save(); return "Done"; } else { ReplyCode=501; return "Missing args"; } } else if(!strcasecmp(Command,"LOGCFG")) { cLineBuff lb(256); for(int m=1; m<LMOD_MAX; m++) { const char *name=cLogging::GetModuleName(LCLASS(m,0)); if(name) { int o=cLogging::GetModuleOptions(LCLASS(m,0)); if(o>=0) { for(int i=0; i<LOPT_NUM; i++) { const char *opt; if(i==0) opt="enable"; else opt=cLogging::GetOptionName(LCLASS(m,1<<i)); if(opt) lb.Printf("%s.%s %s\n",name,opt,(o&(1<<i))?"on":"off"); } } } } if(lb.Length()>0) return lb.Line(); ReplyCode=901; return "No config available"; } else if(!strcasecmp(Command,"LOGFILE")){ if(Option && *Option) { char tmp[1024]; strn0cpy(tmp,Option,sizeof(tmp)); char *opt=tmp; opt=skipspace(opt); bool mode; if(!strncasecmp(opt,"ON",2)) { mode=true; opt+=2; } else if(!strncasecmp(opt,"OFF",3)) { mode=false; opt+=3; } else { ReplyCode=501; return "Bad mode, valid: on off"; } cLineBuff lb(256); if(mode) { logcfg.logFile=true; if(*opt==' ' || *opt=='\t') { opt=stripspace(skipspace(opt)); strn0cpy(logcfg.logFilename,opt,sizeof(logcfg.logFilename)); } lb.Printf("logging to file enabled, file %s",logcfg.logFilename); } else { logcfg.logFile=false; lb.Printf("logging to file disabled"); } ScSetup.Store(true); Setup.Save(); return lb.Line(); } else { ReplyCode=501; return "Missing args"; } } return NULL; }
void LogNone(void) { for(int i=0; i<32; i++) cLogging::SetModuleOptions(LCLASS(i,0)); }
void LogAll(void) { for(int i=0; i<32; i++) cLogging::SetModuleOptions(LCLASS(i,0xFFFFFFFF)); }