public:
cEcmData(void):cEcmInfo() {}
cEcmData(cEcmInfo *e):cEcmInfo(e) {}
- virtual cString ToString(bool hide=false);
+ virtual cString ToString(bool hide);
bool Parse(const char *buf);
};
class cCommentItem : public cStructItem {
public:
cCommentItem(void);
- virtual cString ToString(bool hide=false) { return ""; }
};
cCommentItem::cCommentItem(void)
public:
cStructItem(void);
virtual ~cStructItem();
- virtual cString ToString(bool hide=false)=0;
+ virtual cString ToString(bool hide) { return ""; }
bool Save(FILE *f);
//
void SetComment(const char *com);
//
cPlainKey(bool CanSupersede);
virtual bool Parse(const char *line)=0;
- virtual cString ToString(bool hide=false);
+ virtual cString ToString(bool hide);
virtual bool Cmp(void *Key, int Keylen)=0;
virtual bool Cmp(cPlainKey *k)=0;
virtual void Get(void *mem)=0;
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;
- if(Feature.SmartCard()) smartcards.LoadData(cfgdir);
return true;
}
cSmartCards::cSmartCards(void)
:cThread("SmartcardWatcher")
+,cStructList<cSmartCardData>("smartcard data",DATAFILE,SL_MISSINGOK|SL_WATCH)
{
for(int i=0 ; i<MAX_PORTS ; i++) ports[i].Serial=0;
firstRun=true;
ports[i].Serial=0;
}
}
- dataList.Clear();
mutex.Unlock();
+ ListLock(true); Clear(); ListUnlock();
}
bool cSmartCards::AddPort(const char *devName, bool invCD, bool invRST, int clock)
return false;
}
-void cSmartCards::LoadData(const char *cfgdir)
-{
- mutex.Lock();
- dataList.Clear();
- ConfRead("smartcard data",AddDirectory(cfgdir,DATAFILE),true);
- mutex.Unlock();
-}
-
-bool cSmartCards::ParseLine(const char *line, bool fromCache)
+cStructItem *cSmartCards::ParseLine(char *line)
{
char *r=index(line,':');
- if(!r) return false;
- for(cSmartCardLink *scl=first; scl; scl=scl->next) {
- if(!strncasecmp(scl->name,line,r-line)) {
- cSmartCardData *scd=scl->CreateData();
- if(scd && scd->Parse(r+1)) {
- dataList.Add(scd);
- break;
- }
- else {
+ if(r)
+ for(cSmartCardLink *scl=first; scl; scl=scl->next)
+ if(!strncasecmp(scl->name,line,r-line)) {
+ cSmartCardData *scd=scl->CreateData();
+ if(scd && scd->Parse(r+1)) return scd;
delete scd;
- return false;
+ break;
}
- }
- }
- return true;
+ return 0;
}
cSmartCardData *cSmartCards::FindCardData(cSmartCardData *param)
{
- cMutexLock lock(&mutex);
- for(cSmartCardData *cd=dataList.First(); cd; cd=dataList.Next(cd))
- if(cd->ident==param->ident && cd->Matches(param))
- return cd;
- return 0;
+ ListLock(false);
+ cSmartCardData *cd;
+ for(cd=First(); cd; cd=Next(cd))
+ if(cd->ident==param->ident && cd->Matches(param)) break;
+ ListUnlock();
+ return cd;
}
bool cSmartCards::HaveCard(int id)
// ----------------------------------------------------------------
-class cSmartCardData : public cSimpleItem {
+class cSmartCardData : public cStructItem {
friend class cSmartCards;
protected:
int ident;
struct Atr Atr;
};
-class cSmartCards : private cThread, private cConfRead {
+class cSmartCards : private cThread, public cStructList<cSmartCardData> {
friend class cSmartCardLink;
private:
static cSmartCardLink *first;
cCondVar cond;
struct Port ports[MAX_PORTS];
bool firstRun;
- cSimpleList<cSmartCardData> dataList;
//
static void Register(cSmartCardLink *scl);
bool CardInserted(cSerial *ser);
void SetPort(struct Port *port, cSmartCard *sc, int id, bool dead);
protected:
virtual void Action(void);
- virtual bool ParseLine(const char *line, bool fromCache);
+ virtual cStructItem *ParseLine(char *line);
public:
cSmartCards(void);
void Shutdown(void);
// to be called ONLY from frontend thread!
bool AddPort(const char *devName, bool invCD, bool invRST, int clock);
void LaunchWatcher(void);
- void LoadData(const char *cfgdir);
bool ListCard(int num, char *str, int len);
bool CardInfo(int num, char *str, int len);
void CardReset(int num);
void cSystem::KeyOK(cPlainKey *pk)
{
if(lastkey.NotLast(pk->type,pk->id,pk->keynr)) {
- strn0cpy(currentKeyStr,pk->ToString(),sizeof(currentKeyStr));
+ strn0cpy(currentKeyStr,pk->ToString(false),sizeof(currentKeyStr));
PRINTF(L_CORE_ECM,"system: using key %s",*pk->ToString(true));
doLog=true;
}
bool haveHMK;
//
bool Parse(const char *line);
- virtual cString ToString(bool hide=false);
+ virtual cString ToString(bool hide);
};
bool cIrdCardInfo::Parse(const char *line)
unsigned char key[16];
//
bool Parse(const char *line);
- virtual cString ToString(bool hide=false) { return ""; }
int KeySize(void) { return len; }
};
unsigned char keyno, key[8];
//
bool Parse(const char *line);
- virtual cString ToString(bool hide=false) { return ""; }
};
bool cViaccessCardInfo::Parse(const char *line)