PPD Class Reference

#include <PPDdb.h>

List of all members.

Public Types

typedef string VendorKey
typedef string ModelKey
typedef string DriverFile
typedef map< DriverFile,
DriverInfo
Drivers
typedef map< ModelKey, ModelInfoModels
typedef map< VendorKey,
VendorInfo
Vendors
typedef map< string, PpdFileInfoPpdFiles
typedef map< VendorKey, set
< string > > 
ModelLabels
typedef set< string > VendorLabels

Public Member Functions

 PPD (const char *ppddir=PPD_DIR, const char *ppddb=PPD_DB)
 ~PPD ()
bool createdb ()
void * createdbThread (const char *filename)
int creationStatus ()
bool changed (int *count)
string getVendorId (string vendor)
string getModelId (string vendor, string model)
string removeVendorFromModel (string vendor, string model)
bool fileinfo (const char *file, PPDInfo *info)
bool setCheckMethod (YCPSymbol method)
YCPList sortItems (const YCPMap &items)

Static Public Member Functions

static void * startCreatedbThread (void *instance)

Protected Member Functions

string strupper (const string s)
string killchars (const string s, const string chr)
string killspaces (const string s)
string killbraces (const string s)
string addbrace (const string s)
string first (const string s, const string sep=" -/")
string clean (const char *s)
string filternotchars (const string s, const string chr)
string regexpsub (const string input, const string pattern, const string result)
bool validateModel (const string vendor, const string printer)

Private Types

typedef map< string, string > VendorsMap
typedef map< string, vector
< pair< string, string > > > 
ModelsMap

Private Member Functions

bool mtimes (const char *dirname, time_t mtime, int *count)
int countFiles (const char *dirname)
bool process_dir (const char *dirname)
bool process_file (const char *filename, PPDInfo *newinfo=NULL)
void preprocess (PPDInfo info, PPDInfo *newinfo)
void addAdditionalInfo ()
void debugdb () const
bool loadPrebuiltDatabase ()
bool createFileList (const char *dirname, time_t mtime)
bool cleanupLists ()
bool processNewFiles ()
bool cleanupEmptyEntries ()
string fileChecksum (const string &filename)
off_t fileSize (const string &filename)
string updateLabel (const string &label)

Private Attributes

Vendors db
PpdFiles ppdfiles
ModelLabels modellabels
VendorLabels vendorlabels
string datadir
string var_datadir
char ppd_dir [MAX]
char ppd_db [MAX]
time_t mtime
VendorsMap vendors_map
ModelsMap models_map
volatile int creation_status
volatile int total_files
volatile int done_files
bool fast_check

Friends

class PPDfile

Classes

class  DriverInfo
class  ModelInfo
class  PpdFileInfo
class  PPDInfo
class  VendorInfo


Member Typedef Documentation

typedef string PPD::VendorKey

typedef string PPD::ModelKey

typedef string PPD::DriverFile

typedef map<string, PpdFileInfo> PPD::PpdFiles

typedef map<VendorKey, set<string> > PPD::ModelLabels

typedef set<string> PPD::VendorLabels

typedef map<string, string> PPD::VendorsMap [private]

typedef map<string, vector<pair <string, string> > > PPD::ModelsMap [private]


Constructor & Destructor Documentation

PPD::PPD ( const char *  ppddir = PPD_DIR,
const char *  ppddb = PPD_DB 
)

Constructor

Array of all known vendors

Array of all known string->vendor mappings

References array_all, array_map, datadir, fast_check, models_map, mtime, ppd_db, ppd_dir, val, var_datadir, vendors_map, and y2error.

PPD::~PPD (  ) 

Destructor


Member Function Documentation

bool PPD::createdb (  ) 

Create database of printers Just start a thread and return immediately

References creation_status, and startCreatedbThread().

Referenced by PPDAgent::Write().

void * PPD::startCreatedbThread ( void *  instance  )  [static]

References createdbThread().

Referenced by createdb().

void * PPD::createdbThread ( const char *  filename  ) 

Create a database of all ppd files in the /var/lib/YaST2/ppd_db.ycp

Returns:
operation succeeded

References addAdditionalInfo(), cleanupEmptyEntries(), cleanupLists(), countFiles(), createFileList(), creation_status, db, done_files, F, loadPrebuiltDatabase(), mtime, ppd_db, ppd_dir, process_dir(), processNewFiles(), str, total_files, y2debug, y2error, and y2milestone.

Referenced by startCreatedbThread(), and PPDAgent::Write().

int PPD::creationStatus (  ) 

References creation_status.

Referenced by PPDAgent::Read(), and PPDAgent::Write().

bool PPD::changed ( int *  count  ) 

Check if any ppd file has changed

References mtime, mtimes(), ppd_db, and ppd_dir.

Referenced by PPDAgent::Read().

string PPD::getVendorId ( string  vendor  ) 

Transform vendor name from PPD file/detection to key in database

References filternotchars(), strupper(), and vendors_map.

Referenced by addAdditionalInfo(), getModelId(), preprocess(), process_file(), PPDAgent::Read(), and removeVendorFromModel().

string PPD::getModelId ( string  vendor,
string  model 
)

Transform model name from PPD file/detection to key in database

References filternotchars(), getVendorId(), models_map, regexpsub(), removeVendorFromModel(), and strupper().

Referenced by addAdditionalInfo(), preprocess(), PPDAgent::Read(), and validateModel().

string PPD::removeVendorFromModel ( string  vendor,
string  model 
)

Remove the vendor name from the beginning of the model if present

Parameters:
vendor string vendor id
model string model label/id
Returns:
string model label/id with removed vendor from the begining

References getVendorId(), strupper(), and vendors_map.

Referenced by getModelId(), and process_file().

bool PPD::fileinfo ( const char *  file,
PPDInfo info 
)

Return info from the given file

References process_file(), and y2error.

bool PPD::setCheckMethod ( YCPSymbol  method  ) 

References fast_check, and y2milestone.

Referenced by PPDAgent::Write().

YCPList PPD::sortItems ( const YCPMap items  ) 

bool PPD::mtimes ( const char *  dirname,
time_t  mtime,
int *  count 
) [private]

Check modification times in the given directory

References MAX, and y2error.

Referenced by changed().

int PPD::countFiles ( const char *  dirname  )  [private]

Count files to process

References MAX, and y2error.

Referenced by createdbThread().

bool PPD::process_dir ( const char *  dirname  )  [private]

Search given directory for ppd files and update the ppd database

Parameters:
dirname directory to be processed
Returns:
operation succeeded

References MAX, process_file(), y2debug, and y2error.

Referenced by createdbThread().

bool PPD::process_file ( const char *  filename,
PPDInfo newinfo = NULL 
) [private]

void PPD::preprocess ( PPD::PPDInfo  info,
PPDInfo newinfo 
) [private]

void PPD::addAdditionalInfo (  )  [private]

void PPD::debugdb (  )  const [private]

Return the whole DB / PPD::Vendors PPD::getDB() const { return db; } Debug whole ppd db to the y2log

References db, and y2debug.

bool PPD::loadPrebuiltDatabase (  )  [private]

bool PPD::createFileList ( const char *  dirname,
time_t  mtime 
) [private]

Creates a list of files with attrubutes about modification dates

References PPD::PpdFileInfo::dir_newer, PPD::PpdFileInfo::file_newer, MAX, ppdfiles, and y2error.

Referenced by createdbThread().

bool PPD::cleanupLists (  )  [private]

bool PPD::processNewFiles (  )  [private]

bool PPD::cleanupEmptyEntries (  )  [private]

References db.

Referenced by createdbThread().

string PPD::fileChecksum ( const string &  filename  )  [private]

References md5_stream().

Referenced by cleanupLists(), and process_file().

off_t PPD::fileSize ( const string &  filename  )  [private]

Referenced by cleanupLists(), and process_file().

string PPD::updateLabel ( const string &  label  )  [private]

References strupper().

Referenced by preprocess().

string PPD::strupper ( const string  s  )  [protected]

Convert string to upper characters

Referenced by addAdditionalInfo(), getModelId(), getVendorId(), preprocess(), removeVendorFromModel(), and updateLabel().

string PPD::killchars ( const string  s,
const string  chr 
) [protected]

Kill the given chars from the start and end of the string

References killspaces().

Referenced by killbraces().

string PPD::killspaces ( const string  s  )  [protected]

Kill all spaces from the start and end of the string

Referenced by addbrace(), and killchars().

string PPD::killbraces ( const string  s  )  [protected]

Kill braces (and other bad characters) from the start and end of the string

References killchars().

Referenced by addbrace(), clean(), first(), and preprocess().

string PPD::addbrace ( const string  s  )  [protected]

Add a right brace if there is one left brace alone.

References killbraces(), and killspaces().

Referenced by preprocess().

string PPD::first ( const string  s,
const string  sep = " -/" 
) [protected]

Return the first word from the string

References killbraces().

Referenced by preprocess().

string PPD::clean ( const char *  s  )  [protected]

Make s string from the char* and clean it from spaces and braces

References killbraces().

Referenced by process_file().

string PPD::filternotchars ( const string  s,
const string  chr 
) [protected]

Filter characters, leavo only listed ones

Referenced by getModelId(), and getVendorId().

string PPD::regexpsub ( const string  input,
const string  pattern,
const string  result 
) [protected]

the same as YCP regexpsub builtin

References ERR_MAX, and SUB_MAX.

Referenced by getModelId().

bool PPD::validateModel ( const string  vendor,
const string  printer 
) [protected]

References getModelId().

Referenced by preprocess().


Friends And Related Function Documentation

friend class PPDfile [friend]


Member Data Documentation

Vendors PPD::db [private]

string PPD::datadir [private]

Referenced by addAdditionalInfo(), and PPD().

string PPD::var_datadir [private]

Referenced by PPD().

char PPD::ppd_dir[MAX] [private]

Referenced by changed(), createdbThread(), and PPD().

char PPD::ppd_db[MAX] [private]

time_t PPD::mtime [private]

Referenced by changed(), createdbThread(), and PPD().

Referenced by getModelId(), and PPD().

volatile int PPD::creation_status [private]

volatile int PPD::total_files [private]

Referenced by createdbThread(), and process_file().

volatile int PPD::done_files [private]

bool PPD::fast_check [private]

Referenced by cleanupLists(), PPD(), and setCheckMethod().


The documentation for this class was generated from the following files:

Generated on Sat Jun 7 05:16:31 2008 for yast2-printer by  doxygen 1.5.5