⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sc.c

📁 VDR softcam plugin 0.9.1
💻 C
📖 第 1 页 / 共 3 页
字号:
}void cOpts::Backup(void){  if(opts) {    for(int i=0; i<numAdd; i++)      if(opts[i]) opts[i]->Backup();    }}void cOpts::Create(cOsdMenu *menu){  if(opts) {    for(int i=0; i<numAdd; i++)      if(opts[i]) opts[i]->Create(menu);    }}// --- cMenuInfoSc -------------------------------------------------------------class cMenuInfoSc : public cOsdMenu {public:  cMenuInfoSc(void);  virtual eOSState ProcessKey(eKeys Key);  };cMenuInfoSc::cMenuInfoSc(void):cOsdMenu(tr("SoftCAM"),25){  Add(new cScInfoItem(tr("Current keys:")));  for(int d=0; d<MAXDVBDEVICES; d++) {    int n=0;    char *ks;    do {      if((ks=cSoftCAM::CurrKeyStr(d,n))) {        char buffer[32];        snprintf(buffer,sizeof(buffer),"  [%s %d:%d]","DVB",d+1,n+1);        Add(new cScInfoItem(buffer,ks));        free(ks);        }      n++;      } while(ks);    }  if(Feature.KeyFile()) {    Add(new cScInfoItem(tr("Key update status:")));    int fk, nk;    cSystem::KeyStats(fk,nk);    // TRANSLATORS: 2 leading spaces!    Add(new cScInfoItem(tr("  [Seen keys]"),fk));    // TRANSLATORS: 2 leading spaces!    Add(new cScInfoItem(tr("  [New keys]"), nk));    }  Display();}eOSState cMenuInfoSc::ProcessKey(eKeys Key){  eOSState state=cOsdMenu::ProcessKey(Key);  if(state==osUnknown && Key==kOk) state=osBack;  return state;}// --- cMenuInfoCard -----------------------------------------------------------class cMenuInfoCard : public cMenuText {private:  int port;  char infoStr[4096];public:  cMenuInfoCard(int Port);  virtual eOSState ProcessKey(eKeys Key);  };cMenuInfoCard::cMenuInfoCard(int Port):cMenuText(tr("Smartcard"),0,fontFix){  port=Port;  smartcards.CardInfo(port,infoStr,sizeof(infoStr));  SetText(infoStr);  SetHelp(tr("Reset card"));  Display();}eOSState cMenuInfoCard::ProcessKey(eKeys Key){  if(Key==kRed && Interface->Confirm(tr("Really reset card?"))) {    smartcards.CardReset(port);    return osEnd;    }  eOSState state=cMenuText::ProcessKey(Key);  if(state==osUnknown) state=osContinue;  return state;}// --- cLogOptItem -------------------------------------------------------------class cLogOptItem : public cMenuEditBoolItem {private:  int o;public:  cLogOptItem(const char *Name, int O, int *val);  int Option(void) { return o; }  };cLogOptItem::cLogOptItem(const char *Name, int O, int *val):cMenuEditBoolItem(Name,val){  o=O;}// --- cMenuLogMod -------------------------------------------------------------class cMenuLogMod : public cOsdMenu {private:  int m;  int v[LOPT_NUM], cfg[LOPT_NUM];  //  void Store(void);public:  cMenuLogMod(int M);  virtual eOSState ProcessKey(eKeys Key);  };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();}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);}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;}// --- cLogModItem -------------------------------------------------------------class cLogModItem : public cOsdItem {private:  int m;public:  cLogModItem(const char *Name, int M);  int Module(void) { return m; }  };cLogModItem::cLogModItem(const char *Name, int M):cOsdItem(osUnknown){  m=M;  char buf[64];  snprintf(buf,sizeof(buf),"%s '%s'...",tr("Module"),Name);  SetText(buf,true);}// --- cMenuLogSys -------------------------------------------------------------class cMenuLogSys : public cOsdMenu {private:  void Store(void);public:  cMenuLogSys(void);  virtual eOSState ProcessKey(eKeys Key);  };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();}void cMenuLogSys::Store(void){  char *lf=strdup(logcfg.logFilename);  ScSetup.Store(false);  if(!lf || strcmp(lf,logcfg.logFilename))    cLogging::ReopenLogfile();  free(lf);}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;}// --- cMenuSysOpts -------------------------------------------------------------class cMenuSysOpts : public cOsdMenu {public:  cMenuSysOpts(void);  virtual eOSState ProcessKey(eKeys Key);  };cMenuSysOpts::cMenuSysOpts(void):cOsdMenu(tr("Cryptsystem options"),33){  for(cOpts *opts=0; (opts=cSystems::GetSystemOpts(opts==0));) {    opts->Backup();    opts->Create(this);    }  Display();}eOSState cMenuSysOpts::ProcessKey(eKeys Key){  eOSState state=cOsdMenu::ProcessKey(Key);  switch(state) {    case osContinue:      if(NORMALKEY(Key)==kUp || NORMALKEY(Key)==kDown) {        cOsdItem *item=Get(Current());        if(item) item->ProcessKey(kNone);        }      break;    case osUnknown:      if(Key==kOk) { ScSetup.Store(false); state=osBack; }      break;    default:      break;    }  return state;}// --- cMenuSetupSc ------------------------------------------------------------class cMenuSetupSc : public cMenuSetupPage {private:  char *cfgdir;protected:  virtual void Store(void);public:  cMenuSetupSc(const char *CfgDir);  virtual ~cMenuSetupSc();  virtual eOSState ProcessKey(eKeys Key);  };static eOSState portStates[] = { osUser1,osUser2,osUser3,osUser4 };#if MAX_PORTS!=4#error Update portStates[]#endifcMenuSetupSc::cMenuSetupSc(const char *CfgDir){  cfgdir=strdup(CfgDir);  SetSection(tr("SoftCAM"));  ScOpts->Backup(); LogOpts->Backup();  for(cOpts *opts=0; (opts=cSystems::GetSystemOpts(opts==0));) opts->Backup();  ScOpts->Create(this);  Add(new cOsdItem(tr("Cryptsystem options..."),osUser5));  Add(new cOsdItem(tr("Message logging..."),osUser6));  if(Feature.SmartCard()) {    char id[IDSTR_LEN];    for(int i=0; smartcards.ListCard(i,id,sizeof(id)); i++) {      char buff[32];      snprintf(buff,sizeof(buff),"%s %d",tr("Smartcard interface"),i);      if(id[0]) Add(new cScInfoItem(buff,id,portStates[i]));      else      Add(new cScInfoItem(buff,tr("(empty)")));      }    }  Add(new cOsdItem(tr("Status information..."),osUser8));  Add(new cOsdItem(tr("Flush ECM cache"),osUser7));  Add(new cOsdItem(tr("Reload files"),osUser9));}cMenuSetupSc::~cMenuSetupSc(){  free(cfgdir);}void cMenuSetupSc::Store(void){  ScSetup.Store(false);}eOSState cMenuSetupSc::ProcessKey(eKeys Key){  eOSState state = cOsdMenu::ProcessKey(Key);  switch(state) {    case osUser1...osUser4:      if(Feature.SmartCard()) {        for(unsigned int i=0; i<sizeof(portStates)/sizeof(eOSState); i++)          if(portStates[i]==state) return(AddSubMenu(new cMenuInfoCard(i)));        }      state=osContinue;      break;    case osUser7:      state=osContinue;      if(Interface->Confirm(tr("Really flush ECM cache?"))) {        ecmcache.Flush();        state=osEnd;        }      break;    case osUser8:      return AddSubMenu(new cMenuInfoSc);    case osUser6:      return AddSubMenu(new cMenuLogSys);    case osUser5:      return AddSubMenu(new cMenuSysOpts);    case osUser9:      state=osContinue;      if(!cSoftCAM::Active(true)) {        if(Interface->Confirm(tr("Really reload files?"))) {          Store();          cSoftCAM::Load(cfgdir);          state=osEnd;          }        }      else         Skins.Message(mtError,tr("Active! Can't reload files now"));      break;    case osContinue:      if(NORMALKEY(Key)==kUp || NORMALKEY(Key)==kDown) {        cOsdItem *item=Get(Current());        if(item) item->ProcessKey(kNone);        }      break;    case osUnknown:      if(Key==kOk) { Store(); state=osBack; }      break;    default:      break;    }  return state;}// --- cScSetup ---------------------------------------------------------------cScSetup ScSetup;cScSetup::cScSetup(void){  AutoUpdate=1;  memset(ScCaps,0,sizeof(ScCaps));  ScCaps[0]=1;  ScCaps[1]=2;  ConcurrentFF=0;  memset(CaIgnore,0,sizeof(CaIgnore));  LocalPriority=0;  ForceTransfer=1;  PrestartAU=0;  SuperKeys=0;  EcmCache=0;}void cScSetup::Check(void){  if(AutoUpdate==0)    PRINTF(L_GEN_WARN,"Keys updates (AU) are disabled.");  for(int i=0; i<MAXSCCAPS; i++)    if(ScCaps[i]>=16) {      PRINTF(L_GEN_WARN,"ScCaps contains unusual value. Check your config! (You can ignore this message if you have more than 16 dvb cards in your system ;)");      break;      }  PRINTF(L_CORE_LOAD,"** Plugin config:");  PRINTF(L_CORE_LOAD,"** Key updates (AU) are %s (%sprestart)",AutoUpdate?(AutoUpdate==1?"enabled (active CAIDs)":"enabled (all CAIDs)"):"DISABLED",PrestartAU?"":"no ");  PRINTF(L_CORE_LOAD,"** Local systems %stake priority over cached remote",LocalPriority?"":"DON'T ");  PRINTF(L_CORE_LOAD,"** Concurrent FF recordings are %sallowed",ConcurrentFF?"":"NOT ");  PRINTF(L_CORE_LOAD,"** %sorce transfermode with digital audio",ForceTransfer?"F":"DON'T f");  LBSTART(L_CORE_LOAD);  LBPUT("** ScCaps are"); for(int i=0; i<MAXSCCAPS ; i++) LBPUT(" %d",ScCaps[i]);  LBFLUSH();  LBPUT("** Ignored CAIDs"); for(int i=0; i<MAXCAIGN ; i++) LBPUT(" %04X",CaIgnore[i]);  LBEND();}void cScSetup::Store(bool AsIs){  if(ScOpts) ScOpts->Store(AsIs);  cSystems::ConfigStore(AsIs);  if(LogOpts) LogOpts->Store(AsIs);  cLineBuff lb(128);  if(cLogging::GetConfig(&lb))    ScPlugin->SetupStore("LogConfig",lb.Line());}bool cScSetup::CapCheck(int n){  for(int j=0; j<MAXSCCAPS; j++)    if(ScCaps[j] && ScCaps[j]==n+1) return true;  return false;}bool cScSetup::Ignore(unsigned short caid){  for(int i=0; i<MAXCAIGN; i++)    if(CaIgnore[i]==caid) return true;  return false;}// --- cSoftCAM ---------------------------------------------------------------bool cSoftCAM::Load(const char *cfgdir){  if(!Feature.KeyFile()) keys.Disable();  if(!Feature.SmartCard()) smartcards.Disable();  cStructLoaders::Load(false);  if(Feature.KeyFile() && keys.Count()<1)    PRINTF(L_GEN_ERROR,"no keys loaded for softcam!");  if(!cSystems::Init(cfgdir)) return false;  srand(time(0));  return true;}void cSoftCAM::Shutdown(void){  cStructLoaders::Save(true);  cSystems::Clean();  smartcards.Shutdown();  keys.Clear();}char *cSoftCAM::CurrKeyStr(int CardNum, int num){  cScDvbDevice *dev=dynamic_cast<cScDvbDevice *>(cDevice::GetDevice(CardNum));  char *str=0;  if(dev) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -