cPlainKeys::Register(this,Super);
}
+// -- cLastKey -----------------------------------------------------------------
+
+cLastKey::cLastKey(void)
+{
+ lastType=lastId=lastKeynr=-1;
+}
+
+bool cLastKey::NotLast(int Type, int Id, int Keynr)
+{
+ if(lastType!=Type || lastId!=Id || lastKeynr!=Keynr) {
+ lastType=Type; lastId=Id; lastKeynr=Keynr;
+ return true;
+ }
+ return false;
+}
+
// -- cPlainKeys ---------------------------------------------------------------
const char *externalAU=0;
first=pkt;
}
+void cPlainKeys::Trigger(int Type, int Id, int Keynr)
+{
+ if(lastkey.NotLast(Type,Id,Keynr))
+ PRINTF(L_CORE_AUEXTERN,"triggered from findkey (%s)",*KeyString(Type,Id,Keynr));
+ ExternalUpdate();
+}
+
cPlainKey *cPlainKeys::FindKey(int Type, int Id, int Keynr, int Size, cPlainKey *key)
{
key=FindKeyNoTrig(Type,Id,Keynr,Size,key);
- if(!key) {
- static int lastType=-1, lastId=-1, lastKeynr=-1;
- if(externalAU && (lastType!=Type || lastId!=Id || lastKeynr!=Keynr)) {
- PRINTF(L_CORE_AUEXTERN,"triggered from findkey (type=%X id=%X keynr=%X)",Type,Id,Keynr);
- lastType=Type; lastId=Id; lastKeynr=Keynr;
- }
- ExternalUpdate();
- }
+ if(!key) Trigger(Type,Id,Keynr);
return key;
}
return pkt->Create();
}
+cString cPlainKeys::KeyString(int Type, int Id, int Keynr)
+{
+ cPlainKey *pk=NewFromType(Type);
+ if(pk) {
+ pk->type=Type; pk->id=Id; pk->keynr=Keynr;
+ return cString::sprintf("%c %.*X %s",Type,pk->IdSize(),Id,*pk->PrintKeyNr());
+ }
+ return "unknown";
+}
+
bool cPlainKeys::ParseLine(const char *line, bool fromCache)
{
char *s=skipspace(line);
// ----------------------------------------------------------------
+class cLastKey {
+private:
+ int lastType, lastId, lastKeynr;
+public:
+ cLastKey(void);
+ bool NotLast(int Type, int Id, int Keynr);
+ };
+
+// ----------------------------------------------------------------
+
extern const char *externalAU;
class cPlainKeys : public cLoader, private cConfRead, private cThread, public cSimpleList<cPlainKey> {
static cPlainKeyType *first;
cPlainKey *mark;
cTimeMs trigger, last;
+ cLastKey lastkey;
//
static void Register(cPlainKeyType *pkt, bool Super);
cPlainKey *NewFromType(int type);
virtual bool ParseLine(const char *line, bool Au);
cPlainKey *FindKey(int Type, int Id, int Keynr, int Size, cPlainKey *key=0);
cPlainKey *FindKeyNoTrig(int Type, int Id, int Keynr, int Size, cPlainKey *key=0);
+ void Trigger(int Type, int Id, int Keynr);
+ cString KeyString(int Type, int Id, int Keynr);
bool NewKey(int Type, int Id, int Keynr, void *Key, int Keylen);
bool NewKeyParse(const char *line);
void HouseKeeping(void);
cSystem::cSystem(const char *Name, int Pri)
{
name=Name; pri=Pri;
- lastType=0; currentKeyStr[0]=0; doLog=true; cardNum=-1; logecm=0;
+ currentKeyStr[0]=0; doLog=true; cardNum=-1; logecm=0;
check=new struct EcmCheck;
memset(check,0,sizeof(struct EcmCheck));
// default config
void cSystem::KeyOK(cPlainKey *pk)
{
- if(pk->type!=lastType || pk->id!=lastId || pk->keynr!=lastKeynr) {
- lastType=pk->type; lastId=pk->id; lastKeynr=pk->keynr;
+ if(lastkey.NotLast(pk->type,pk->id,pk->keynr)) {
strn0cpy(currentKeyStr,pk->ToString(),sizeof(currentKeyStr));
PRINTF(L_CORE_ECM,"system: using key %s",*pk->ToString(true));
doLog=true;
void cSystem::KeyFail(int type, int id, int keynr)
{
- if(type!=lastType || id!=lastId || keynr!=lastKeynr) {
- lastType=type; lastId=id; lastKeynr=keynr;
- if(doLog)
- PRINTF(L_CORE_ECM,"system: no key found for %c %.2x %.2x",lastType,lastId,lastKeynr);
- }
+ keys.Trigger(type,id,keynr);
+ if(lastkey.NotLast(type,id,keynr) && doLog)
+ PRINTF(L_CORE_ECM,"system: no key found for %s",*keys.KeyString(type,id,keynr));
}
// -- cSystemLink --------------------------------------------------------------
private:
static int foundKeys, newKeys;
int pri, cardNum;
- int lastType, lastId, lastKeynr;
+ cLastKey lastkey;
char *lastTxt;
char currentKeyStr[48];
struct EcmCheck *check;