SASC-NG
DVBSoftCAM

cPlainKeys Class Reference

#include <data.h>

Inheritance diagram for cPlainKeys:

List of all members.

Public Member Functions

 cPlainKeys (void)
virtual cPlainKey * ParseLine (char *line)
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 (char *line, const char *reason)
void HouseKeeping (void)

Protected Member Functions

virtual void Action (void)
virtual void PostLoad (void)

Friends

class cPlainKeyType

Detailed Description

Definition at line 346 of file data.h.


Constructor & Destructor Documentation

cPlainKeys::cPlainKeys ( void  )

Member Function Documentation

void cPlainKeys::Action ( void  ) [protected, virtual]

A derived cThread class must implement the code it wants to execute as a separate thread in this function. If this is a loop, it must check Running() repeatedly to see whether it's time to stop.

Implements cThread.

Definition at line 1027 of file data.c.

References cPipe::Close(), cTimeMs::Elapsed(), EXT_AU_MIN, L_CORE_AUEXTERN, NewKeyParse(), cPipe::Open(), PRINTF, cTimeMs::Set(), skipspace(), start(), and stripspace().

{
  last.Set(EXT_AU_MIN);
  PRINTF(L_CORE_AUEXTERN,"starting...");
  cTimeMs start;
  cPipe pipe;
  if(pipe.Open(externalAU,"r")) {
    char buff[1024];
    while(fgets(buff,sizeof(buff),pipe)) {
      char *line=skipspace(stripspace(buff));
      if(line[0]==0 || line[0]==';' || line[0]=='#') continue;
      NewKeyParse(line,"from ExtAU");
      }
    }
  pipe.Close();
  PRINTF(L_CORE_AUEXTERN,"done (elapsed %d)",(int)start.Elapsed());
}
cPlainKey * cPlainKeys::FindKeyNoTrig ( int  Type,
int  Id,
int  Keynr,
int  Size,
cPlainKey *  key = 0 
)

Definition at line 910 of file data.c.

References cStructList< cPlainKey >::First(), cPlainKey::id, cPlainKey::keynr, cStructLoader::ListLock(), cStructLoader::ListUnlock(), cStructList< cPlainKey >::Next(), and cPlainKey::type.

Referenced by cSystemLinkConstCw::CanHandle(), FindKey(), cN2Prov4101::PostProcAU(), cSystemNagra2::ProcessECM(), cSystemSeca::ProcessEMM(), and cSystemNagra2::ProcessEMM().

{
  ListLock(false);
  for(key=key?Next(key):First(); key; key=Next(key))
    if(key->type==Type && key->id==Id && key->keynr==Keynr && (Size<0 || key->Size()==Size))
      break;
  ListUnlock();
  return key;
}
void cPlainKeys::HouseKeeping ( void  )

Definition at line 1004 of file data.c.

References EXT_AU_INT, L_CORE_AUEXTERN, PRINTF, cTimeMs::Set(), and cTimeMs::TimedOut().

Referenced by cScHousekeeper::Action().

{
  if(trigger.TimedOut()) {
    trigger.Set(EXT_AU_INT);
    if(externalAU) PRINTF(L_CORE_AUEXTERN,"triggered from housekeeping");
    ExternalUpdate();
    }
}
cString cPlainKeys::KeyString ( int  Type,
int  Id,
int  Keynr 
)

Definition at line 981 of file data.c.

References bprintf(), cPlainKey::id, cPlainKey::IdSize(), cPlainKey::keynr, cPlainKey::PrintKeyNr(), and cPlainKey::type.

Referenced by cSystem::KeyFail(), and Trigger().

{
  cPlainKey *pk=NewFromType(Type);
  char *s;
  if(pk) {
    pk->type=Type; pk->id=Id; pk->keynr=Keynr;
    s=bprintf("%c %.*X %s",Type,pk->IdSize(),Id,*pk->PrintKeyNr());
    delete pk;
    }
  else s=strdup("unknown");
  return cString(s,true);
}
bool cPlainKeys::NewKey ( int  Type,
int  Id,
int  Keynr,
void *  Key,
int  Keylen 
)

Definition at line 957 of file data.c.

References cPlainKey::Set().

Referenced by cSystemViaccess::ProcessEMM(), cSystemSeca::ProcessEMM(), cSystemNagra2::ProcessEMM(), cSystemNagra::ProcessEMM(), cSystemIrd2::ProcessEMM(), and cSystemIrd::ProcessEMM().

{
  cPlainKey *nk=NewFromType(Type);
  if(nk) {
    nk->Set(Type,Id,Keynr,Key,Keylen);
    return AddNewKey(nk,"from AU");
    }
  return false;
}
bool cPlainKeys::NewKeyParse ( char *  line,
const char *  reason 
)

Definition at line 967 of file data.c.

References ParseLine().

Referenced by Action(), and cScPlugin::SVDRPCommand().

{
  cPlainKey *nk=ParseLine(line);
  return nk && AddNewKey(nk,reason);
}
cPlainKey * cPlainKeys::ParseLine ( char *  line) [virtual]

Implements cStructLoader.

Definition at line 973 of file data.c.

References k, cPlainKey::Parse(), and skipspace().

Referenced by NewKeyParse().

{
  char *s=skipspace(line);
  cPlainKey *k=NewFromType(toupper(*s));
  if(k && !k->Parse(line)) { delete k; k=0; }
  return k;
}
void cPlainKeys::PostLoad ( void  ) [protected, virtual]

Reimplemented from cStructLoader.

Definition at line 994 of file data.c.

References cSimpleListBase::Count(), cStructList< cPlainKey >::First(), L_CORE_KEYS, cStructLoader::ListLock(), cStructLoader::ListUnlock(), LOG, cStructList< cPlainKey >::Next(), and PRINTF.

{
  ListLock(false);
  if(Count() && LOG(L_CORE_KEYS)) {
    for(cPlainKey *dat=First(); dat; dat=Next(dat))
      PRINTF(L_CORE_KEYS,"keys %s",*dat->ToString(false));
    }
  ListUnlock();
}
void cPlainKeys::Trigger ( int  Type,
int  Id,
int  Keynr 
)

Definition at line 896 of file data.c.

References KeyString(), L_CORE_AUEXTERN, cLastKey::NotLast(), and PRINTF.

Referenced by FindKey(), and cSystem::KeyFail().

{
  if(lastkey.NotLast(Type,Id,Keynr))
    PRINTF(L_CORE_AUEXTERN,"triggered from findkey (%s)",*KeyString(Type,Id,Keynr));
  ExternalUpdate();
}

Friends And Related Function Documentation

friend class cPlainKeyType [friend]

Definition at line 347 of file data.h.


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