SASC-NG
DVBSoftCAM

cScPlugin Class Reference

Inheritance diagram for cScPlugin:

List of all members.

Public Member Functions

 cScPlugin (void)
virtual ~cScPlugin ()
virtual const char * Version (void)
virtual const char * Description (void)
virtual const char * CommandLineHelp (void)
virtual bool ProcessArgs (int argc, char *argv[])
virtual bool Initialize (void)
virtual bool Start (void)
virtual void Stop (void)
virtual void MainThreadHook (void)
virtual cMenuSetupPage * SetupMenu (void)
virtual bool SetupParse (const char *Name, const char *Value)
virtual const char ** SVDRPHelpPages (void)
virtual cString SVDRPCommand (const char *Command, const char *Option, int &ReplyCode)

Detailed Description

Definition at line 1202 of file sc.c.


Constructor & Destructor Documentation

cScPlugin::cScPlugin ( void  )

Definition at line 1228 of file sc.c.

References cOpts::Add(), cScSetup::AutoUpdate, cScSetup::ConcurrentFF, cScSetup::DeCsaTsBuffSize, cScSetup::EcmCache, FileNameChars, cScSetup::ForceTransfer, cScDlls::Load(), cScSetup::LocalPriority, logcfg, MAXSCCAPS, cScDevices::OnPluginLoad(), cScSetup::PrestartAU, cScSetup::ScCaps, cScSetup::SuperKeys, and trNOOP.

{
  static const char *logg[] = { trNOOP("off"),trNOOP("active CAIDs"),trNOOP("all CAIDs") };
  static const char *skey[] = { trNOOP("comment out"),trNOOP("remove") };
  static const char *ecache[] = { trNOOP("enabled"),trNOOP("read-only"),trNOOP("off") };
  ScOpts=new cOpts(0,10);
  ScOpts->Add(new cOptSel  ("AutoUpdate"   ,trNOOP("Update keys (AU)")     ,&ScSetup.AutoUpdate,3,logg));
  ScOpts->Add(new cOptBool ("PrestartAU"   ,trNOOP("Start AU on EPG scan") ,&ScSetup.PrestartAU));
  ScOpts->Add(new cOptSel  ("SuperKeys"    ,trNOOP("Superseded keys")      ,&ScSetup.SuperKeys,2,skey));
  ScOpts->Add(new cOptBool ("ConcurrentFF" ,trNOOP("Concurrent FF streams"),&ScSetup.ConcurrentFF));
  ScOpts->Add(new cOptBool ("ForceTranfer" ,trNOOP("Force TransferMode")   ,&ScSetup.ForceTransfer));
  ScOpts->Add(new cOptBool ("LocalPriority",trNOOP("Prefer local systems") ,&ScSetup.LocalPriority));
  ScOpts->Add(new cOptSel  ("EcmCache"     ,trNOOP("ECM cache")            ,&ScSetup.EcmCache,3,ecache));
  ScOpts->Add(new cOptInt  ("DeCsaTsBuffSize",trNOOP("TS buffer size MB")  ,&ScSetup.DeCsaTsBuffSize,4,15));
  ScOpts->Add(new cOptMInt ("ScCaps"       ,trNOOP("Active on DVB card")   , ScSetup.ScCaps,MAXSCCAPS,0));
  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
  dllSuccess=dlls.Load();
#else
  dllSuccess=true;
#endif
  if(dllSuccess) cScDevices::OnPluginLoad();
  keeper=0;
}
cScPlugin::~cScPlugin ( ) [virtual]

Definition at line 1259 of file sc.c.

References LogOpts, cScDevices::OnPluginUnload(), and ScOpts.

{
  delete keeper;
  delete ScOpts;
  delete LogOpts;
  cScDevices::OnPluginUnload();
}

Member Function Documentation

const char * cScPlugin::CommandLineHelp ( void  ) [virtual]

Reimplemented from cPlugin.

Definition at line 1319 of file sc.c.

References bprintf(), and free.

{
  static char *help_str=0;
  
  free(help_str);    //                                     for easier orientation, this is column 80|
  help_str=bprintf(  "  -B N    --budget=N        forces DVB device N to budget mode (using FFdecsa)\n"
                     "  -E CMD  --external-au=CMD script for external key updates\n"
                     );
  return help_str;
}
const char * cScPlugin::Description ( void  ) [virtual]

Implements cPlugin.

Definition at line 1314 of file sc.c.

References tr.

{
  return tr("A software emulated CAM");
}
bool cScPlugin::Initialize ( void  ) [virtual]

Reimplemented from cPlugin.

Definition at line 1267 of file sc.c.

References L_GEN_INFO, PRINTF, ScVersion, and VDRVERSION.

{
  PRINTF(L_GEN_INFO,"SC version %s initializing (VDR %s)",ScVersion,VDRVERSION);
  return dllSuccess && cScDevices::Initialize();
}
void cScPlugin::MainThreadHook ( void  ) [virtual]

Reimplemented from cPlugin.

Definition at line 1366 of file sc.c.

References cUserMsgs::GetQueuedMsg(), cUserMsg::Message(), mtInfo, cSkins::QueueMessage(), Skins, and ums.

{
  int n=0;
  cUserMsg *um;
  while(++n<=10 && (um=ums.GetQueuedMsg())) {
    Skins.QueueMessage(mtInfo,um->Message());
    delete um;
    }
}
bool cPlugin::ProcessArgs ( int  argc,
char *  argv[] 
) [virtual]

Reimplemented from cPlugin.

Definition at line 1330 of file sc.c.

References externalAU, NULL, and cScDevices::SetForceBudget().

{
  static struct option long_options[] = {
      { "external-au", required_argument, NULL, 'E' },
      { "budget",      required_argument, NULL, 'B' },
      { NULL }
    };

  int c, option_index=0;
  while((c=getopt_long(argc,argv,"B:E:",long_options,&option_index))!=-1) {
    switch (c) {
      case 'E': externalAU=optarg; break;
      case 'B': cScDevices::SetForceBudget(atoi(optarg)); break;
      default:  return false;
      }
    }
  return true;
}
cMenuSetupPage * cScPlugin::SetupMenu ( void  ) [virtual]

Reimplemented from cPlugin.

Definition at line 1349 of file sc.c.

References cfgsub, and cPlugin::ConfigDirectory().

bool cScPlugin::SetupParse ( const char *  Name,
const char *  Value 
) [virtual]

Reimplemented from cPlugin.

Definition at line 1354 of file sc.c.

References cSystems::ConfigParse(), cOpts::Parse(), and cLogging::ParseConfig().

{
  if((ScOpts && ScOpts->Parse(Name,Value)) ||
     (LogOpts && LogOpts->Parse(Name,Value)) ||
     cSystems::ConfigParse(Name,Value)) ;
  else if(!strcasecmp(Name,"LogConfig")) cLogging::ParseConfig(Value);
  else return false;
  return true;
}
bool cScPlugin::Start ( void  ) [virtual]

Reimplemented from cPlugin.

Definition at line 1273 of file sc.c.

References APIVERSNUM, cfgsub, cScSetup::Check(), cPlugin::ConfigDirectory(), filemaps, L_GEN_ERROR, L_GEN_INFO, cSoftCAM::Load(), MIN_MAJOR, MIN_MINOR, MIN_VERS, MINAPIVERSNUM, PRINTF, ScVersion, cStructLoaders::SetCfgDir(), cFileMaps::SetCfgDir(), cScDevices::Startup(), and VDRVERSION.

{
  PRINTF(L_GEN_INFO,"SC version %s starting (VDR %s)",ScVersion,VDRVERSION);
  if(APIVERSNUM<MINAPIVERSNUM) {
    PRINTF(L_GEN_ERROR,"SC plugin needs at least VDR API version %d.%d.%d",MIN_VERS,MIN_MAJOR,MIN_MINOR);
    return false;
    }
  if(sizeof(int)!=4) {
    PRINTF(L_GEN_ERROR,"compiled with 'int' as %d bit. Only supporting 32 bit.",(int)sizeof(int)*8);
    return false;
    }
  if(sizeof(long long)!=8) {
    PRINTF(L_GEN_ERROR,"compiled with 'long long' as %d bit. Only supporting 64 bit.",(int)sizeof(long long)*8);
    return false;
    }
    
  ScPlugin=this;
  const char *cfgdir=ConfigDirectory(cfgsub);
  filemaps.SetCfgDir(cfgdir);
  cStructLoaders::SetCfgDir(cfgdir);
  ScSetup.Check();
  if(!cSoftCAM::Load(cfgdir)) return false;
  cScDevices::Startup();
  keeper=new cScHousekeeper;
  return true;
}
void cScPlugin::Stop ( void  ) [virtual]

Reimplemented from cPlugin.

Definition at line 1300 of file sc.c.

References L_GEN_DEBUG, LogStatsDown(), PRINTF, cSoftCAM::Shutdown(), and cScDevices::Shutdown().

{
  delete keeper; keeper=0;
  cScDevices::Shutdown();
  LogStatsDown();
  cSoftCAM::Shutdown();
  PRINTF(L_GEN_DEBUG,"SC cleanup done");
}
cString cScPlugin::SVDRPCommand ( const char *  Command,
const char *  Option,
int &  ReplyCode 
) [virtual]

Reimplemented from cPlugin.

Definition at line 1396 of file sc.c.

References cGlobal::Active(), cfgsub, cPlugin::ConfigDirectory(), cLogging::GetClassByName(), cLogging::GetModuleName(), cLogging::GetModuleOptions(), cLogging::GetOptionName(), keys, LCLASS, cLineBuff::Length(), cLineBuff::Line(), LMOD_MAX, cSoftCAM::Load(), logcfg, LOPT_NUM, cPlainKeys::NewKeyParse(), NULL, cLineBuff::Printf(), cSetup::Save(), cLogging::SetModuleOption(), Setup, skipspace(), cScSetup::Store(), stripspace(), and strn0cpy().

{
  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;
}
const char ** cScPlugin::SVDRPHelpPages ( void  ) [virtual]

Reimplemented from cPlugin.

Definition at line 1378 of file sc.c.

References NULL.

{
  static const char *HelpPages[] = {
    "RELOAD\n"
    "    Reload all configuration files.",
    "KEY <string>\n",
    "    Add key to the key database (as if it was received from EMM stream).",
    "LOG <on|off> <class>[,<class>...]\n"
    "    Turn the given message class(es) on or off.",
    "LOGCFG\n"
    "    Display available message classes and their status.",
    "LOGFILE <on|off> [<filename>]\n"
    "    Enables/disables logging to file and optionaly sets the filename.",
    NULL
    };
  return HelpPages;
}
const char * cScPlugin::Version ( void  ) [virtual]

Implements cPlugin.

Definition at line 1309 of file sc.c.

References ScVersion.

{
  return ScVersion;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines