exception.h

00001 /**************
00002 FILE          : exception.h
00003 ***************
00004 PROJECT       : SaX2 - library interface [header]
00005               :
00006 AUTHOR        : Marcus Schäfer <ms@suse.de>
00007               :
00008 BELONGS TO    : SaX2 - SuSE advanced X11 configuration 
00009               : 
00010               :
00011 DESCRIPTION   : native C++ class library to access SaX2
00012               : functionality. Easy to use interface for
00013               : //.../
00014               : - importing/exporting X11 configurations
00015               : - modifying/creating X11 configurations 
00016               : ---
00017               :
00018               :
00019 STATUS        : Status: Development
00020 **************/
00021 #ifndef SAX_EXCEPTION_H
00022 #define SAX_EXCEPTION_H 1
00023 
00024 //====================================
00025 // Main Includes...
00026 //------------------------------------
00027 #include <qobject.h>
00028 #include <errno.h>
00029 #include <sys/types.h>
00030 #include <sys/stat.h>
00031 #include <fcntl.h>
00032 #include <sys/file.h>
00033 
00034 //====================================
00035 // namespace SaX
00036 //------------------------------------
00044 namespace SaX {
00045 //====================================
00046 // Defines (macros)...
00047 //------------------------------------
00048 #define qError(msg,exc)  handle_error(__FILE__, __LINE__, msg,exc)
00049 
00050 //====================================
00051 // Defines (exception names)...
00052 //------------------------------------
00053 #define EXC_PROCESSFAILED               "saxProcessFailed"
00054 #define EXC_IMPORTSECTIONFAILED         "saxImportSectionFailed"
00055 #define EXC_EXPORTSECTIONFAILED         "saxExportSectionFailed"
00056 #define EXC_FILEOPENFAILED              "saxFileOpenFailed"
00057 #define EXC_NOSTORAGE                   "saxNoStorage"
00058 #define EXC_CDBFILEFAILED               "saxCDBFileFailed"
00059 #define EXC_PERMISSIONDENIED            "saxPermissionDenied"
00060 #define EXC_PROFILENOTFOUND             "saxProfileNotFound"
00061 #define EXC_PROFILEUNDEFINED            "saxProfileUndefined"
00062 #define EXC_IMPORTALREADYADDED          "saxImportAlreadyAdded"
00063 #define EXC_UNKNOWNIMPORT               "saxUnknownImport"
00064 #define EXC_NOAPIFILEFOUND              "saxNoAPIFileFound"
00065 #define EXC_NULLPOINTERARGUMENT         "saxNullPointerArgument"
00066 #define EXC_DESKTOPIMPORTBINDFAILED     "saxDesktopImportBindFailed"
00067 #define EXC_CARDIMPORTBINDFAILED        "saxCardImportBindFailed"
00068 #define EXC_POINTERIMPORTBINDFAILED     "saxPointerImportBindFailed"
00069 #define EXC_KEYBOARDIMPORTBINDFAILED    "saxKeyboardImportBindFailed"
00070 #define EXC_PATHIMPORTBINDFAILED        "saxPathImportBindFailed"
00071 #define EXC_EXTENSIONSIMPORTBINDFAILED  "saxExtensionsImportBindFailed"
00072 #define EXC_LAYOUTIMPORTBINDFAILED      "saxLayoutImportBindFailed"
00073 #define EXC_XKBLOADRULESFAILED          "saxXKBLoadRulesFailed"
00074 #define EXC_CDBRECORDNOTFOUND           "saxCDBRecordNotFound"
00075 #define EXC_WRONGINPUTFASHION           "saxWrongInputFashion"
00076 #define EXC_POINTERFASHIONTYPEFAILED    "saxPointerFashionTypeFailed"
00077 #define EXC_SETSTORAGEIDFAILED          "saxSetStorageIDFailed"
00078 #define EXC_INVALIDARGUMENT             "saxInvalidArgument"
00079 #define EXC_INVALIDARGUMENT             "saxInvalidArgument"
00080 #define EXC_LOCKSETFAILED               "saxLockSetFailed"
00081 #define EXC_LOCKUNSETFAILED             "saxLockUnsetFailed"
00082 #define EXC_GETSCREENLAYOUTFAILED       "saxGetScreenLayoutFailed"
00083 #define EXC_GETINPUTLAYOUTFAILED        "saxGetInputLayoutFailed"
00084 #define EXC_EMPTYCDBGROUP               "saxEmptyCDBGroup"
00085 #define EXC_NVIDIADRIVERMISSING         "saxNvidiaDriverMissing"
00086 #define EXC_NVIDIADRIVERINSTALLED       "saxNvidiaDriverInstalled"
00087 #define EXC_XKBLAYOUTUNDEFINED          "saxXKBLayoutUndefined"
00088 #define EXC_DRIVERMISMATCH              "saxCDBDriverMismatch"
00089 
00090 //====================================
00091 // Defines (error texts)...
00092 //------------------------------------
00093 #define EISAXIMPORT      "No such ISaX section to import"
00094 #define EISAXEXPORT      "No such ISaX file to export"
00095 #define EPROFILE         "No such profile ID"
00096 #define EFASHION         "Bad InputFashion type"
00097 #define ECDBGROUP        "No such CDB group found"
00098 #define ERECORD          "No such record"
00099 #define ESCREEN          "No layout defined for screen"
00100 #define ECDBDATA         "No CDB record found"
00101 #define ENVIDIAMIS       "NVIDIA binary driver missing"
00102 #define ENVIDIAINS       "NVIDIA binary driver installed"
00103 #define EXKBLAYOUT       "Undefined XKB layout"
00104 #define ECDBMISMATCH     "2D/3D driver from CDB doesn't match current driver"
00105 
00106 //====================================
00107 // Defines (error codes)...
00108 //------------------------------------
00109 #define EISAXIMPORTID    256
00110 #define EISAXEXPORTID    257
00111 #define EPROFILEID       258
00112 #define ECDBGROUPID      259
00113 #define EFASHIONID       260
00114 #define ERECORDID        261
00115 #define ESCREENID        262
00116 #define ECDBDATAID       263
00117 #define ENVIDIAMISID     264
00118 #define ENVIDIAINSID     265
00119 #define EXKBLAYOUTID     266
00120 #define ECDBMISMATCHID   267
00121 
00122 //====================================
00123 // Defines (locking)...
00124 //------------------------------------
00125 #define ZERO_DEV        "/dev/zero"
00126 
00127 //====================================
00128 // Functions...
00129 //------------------------------------
00130 void handle_error (const char*, int , const char*, const char*);
00131 
00132 //====================================
00133 // pre Class definitions...
00134 //------------------------------------
00135 class SaXImport;
00136 
00137 //====================================
00138 // Interface class for dlopen ability
00139 //------------------------------------
00147 class SaXExceptionIF : public QObject {
00148         public:
00149         virtual void setDebug ( bool=true ) = 0;
00150 
00151         public:
00152         virtual int   errorCode      ( void ) = 0;
00153         virtual void  errorReset     ( void ) = 0;
00154         virtual bool  havePrivileges ( void ) = 0;
00155 
00156         public:
00157         virtual QString errorString ( void ) = 0;
00158     virtual QString errorValue  ( void ) = 0;
00159 
00160         public:
00161         virtual void excProcessFailed              ( void ) = 0;
00162         virtual void excImportSectionFailed        ( void ) = 0;
00163         virtual void excExportSectionFailed        ( void ) = 0;
00164         virtual void excFileOpenFailed             ( int  ) = 0;
00165         virtual void excNoStorage                  ( int  ) = 0;
00166         virtual void excCDBFileFailed              ( void ) = 0;
00167         virtual void excPermissionDenied           ( void ) = 0;
00168         virtual void excProfileNotFound            ( void ) = 0;
00169         virtual void excProfileUndefined           ( int  ) = 0;
00170         virtual void excImportAlreadyAdded         ( int  ) = 0;
00171         virtual void excUnknownImport              ( SaXImport* ) = 0;
00172         virtual void excNoAPIFileFound             ( void ) = 0;
00173         virtual void excNullPointerArgument        ( void ) = 0;
00174         virtual void excXKBLoadRulesFailed         ( void ) = 0;
00175     virtual void excCDBRecordNotFound          ( const char* ) = 0;
00176     virtual void excWrongInputFashion          ( const char* ) = 0;
00177     virtual void excSetStorageIDFailed         ( int ) = 0;
00178     virtual void excInvalidArgument            ( int ) = 0;
00179         virtual void excInvalidArgument            ( const char* ) = 0;
00180         virtual void excDesktopImportBindFailed    ( int ) = 0;
00181         virtual void excCardImportBindFailed       ( int ) = 0;
00182         virtual void excPointerImportBindFailed    ( int ) = 0;
00183         virtual void excKeyboardImportBindFailed   ( int ) = 0;
00184         virtual void excPathImportBindFailed       ( int ) = 0;
00185         virtual void excLayoutImportBindFailed     ( int ) = 0;
00186         virtual void excExtensionsImportBindFailed ( int ) = 0;
00187         virtual void excPointerFashionTypeFailed   ( const char* ) = 0;
00188         virtual void excLockSetFailed              ( int ) = 0;
00189         virtual void excLockUnsetFailed            ( int ) = 0;
00190         virtual void excGetScreenLayoutFailed      ( int ) = 0;
00191         virtual void excEmptyCDBGroup              ( const char* ) = 0;
00192         virtual void excGetInputLayoutFailed       ( void ) = 0;
00193         virtual void excNvidiaDriverMissing        ( void ) = 0;
00194         virtual void excNvidiaDriverInstalled      ( void ) = 0;
00195         virtual void excXKBLayoutUndefined         ( const char* ) = 0;
00196         virtual void excDriverMismatch             ( const char*,const char* ) = 0;
00197 
00198         public:
00199         virtual ~SaXExceptionIF ( void ) { }
00200 };
00201 //====================================
00202 // Class SaXException
00203 //------------------------------------
00269 class SaXException : public SaXExceptionIF {
00270         Q_OBJECT
00271 
00272         private:
00273         QString* mErrorString;
00274         QString* mErrorValue;
00275         int      mErrorCode;
00276         int      mLFD;
00277 
00278         private:
00279         void setErrorCode    ( int );
00280         void setErrorCode    ( const char*,int );
00281         void setErrorValue   ( int );
00282         void setErrorValue   ( const char* );
00283         void setErrorValue   ( void* );
00284 
00285         public:
00286         void setDebug ( bool=true );
00287 
00288         public:
00289         int   errorCode      ( void );
00290         void  errorReset     ( void );
00291         bool  havePrivileges ( void );
00292 
00293         public:
00294         QString errorString ( void );
00295         QString errorValue  ( void );
00296 
00297         public:
00298         void excProcessFailed              ( void );
00299         void excImportSectionFailed        ( void );
00300         void excExportSectionFailed        ( void );
00301         void excFileOpenFailed             ( int  );
00302         void excNoStorage                  ( int  );
00303         void excCDBFileFailed              ( void );
00304         void excPermissionDenied           ( void );
00305         void excProfileNotFound            ( void );
00306         void excProfileUndefined           ( int  );
00307         void excImportAlreadyAdded         ( int  );
00308         void excUnknownImport              ( SaXImport* );
00309         void excNoAPIFileFound             ( void );
00310         void excNullPointerArgument        ( void );
00311         void excXKBLoadRulesFailed         ( void );
00312     void excCDBRecordNotFound          ( const char* );
00313     void excWrongInputFashion          ( const char* );
00314     void excSetStorageIDFailed         ( int );
00315     void excInvalidArgument            ( int );
00316         void excInvalidArgument            ( const char* );
00317         void excDesktopImportBindFailed    ( int );
00318         void excCardImportBindFailed       ( int );
00319         void excPointerImportBindFailed    ( int );
00320         void excKeyboardImportBindFailed   ( int );
00321         void excPathImportBindFailed       ( int );
00322         void excLayoutImportBindFailed     ( int );
00323         void excExtensionsImportBindFailed ( int );
00324         void excPointerFashionTypeFailed   ( const char* );
00325         void excLockSetFailed              ( int );
00326         void excLockUnsetFailed            ( int );
00327         void excGetScreenLayoutFailed      ( int );
00328         void excEmptyCDBGroup              ( const char* );
00329         void excGetInputLayoutFailed       ( void );
00330         void excNvidiaDriverMissing        ( void );
00331         void excNvidiaDriverInstalled      ( void );
00332         void excXKBLayoutUndefined         ( const char* );
00333         void excDriverMismatch             ( const char*,const char* );
00334 
00335         signals:
00336         void saxProcessFailed              ( void );
00337         void saxImportSectionFailed        ( void );
00338         void saxExportSectionFailed        ( void );
00339         void saxFileOpenFailed             ( int  );
00340         void saxNoStorage                  ( int  );
00341         void saxCDBFileFailed              ( void );
00342         void saxPermissionDenied           ( void );
00343         void saxProfileNotFound            ( void );
00344         void saxProfileUndefined           ( int  );
00345         void saxImportAlreadyAdded         ( int  );
00346         void saxUnknownImport              ( SaXImport* );
00347         void saxNoAPIFileFound             ( void );
00348         void saxNullPointerArgument        ( void );
00349         void saxDesktopImportBindFailed    ( int  );
00350         void saxCardImportBindFailed       ( int  );
00351     void saxPointerImportBindFailed    ( int  );
00352     void saxKeyboardImportBindFailed   ( int  );
00353     void saxPathImportBindFailed       ( int  );
00354     void saxExtensionsImportBindFailed ( int  );
00355         void saxLayoutImportBindFailed     ( int  );
00356         void saxXKBLoadRulesFailed         ( void );
00357         void saxCDBRecordNotFound          ( const char* );
00358         void saxWrongInputFashion          ( const char* );
00359         void saxPointerFashionTypeFailed   ( const char* );
00360         void saxSetStorageIDFailed         ( int  );
00361         void saxInvalidArgument            ( int  );
00362         void saxInvalidArgument            ( const char* );
00363         void saxLockSetFailed              ( int  );
00364         void saxLockUnsetFailed            ( int  );
00365         void saxGetScreenLayoutFailed      ( int  );
00366         void saxEmptyCDBGroup              ( const char* );
00367         void saxGetInputLayoutFailed       ( void );
00368         void saxNvidiaDriverMissing        ( void );
00369         void saxNvidiaDriverInstalled      ( void );
00370         void saxXKBLayoutUndefined         ( const char* );
00371         void saxDriverMismatch             ( const char*,const char* );
00372 
00373         signals:
00374         void saxGlobalException            ( const char* );
00375 
00376         protected:
00377         bool setLock   ( void );
00378         bool unsetLock ( void );
00379 
00380         public:
00381         SaXException ( void );
00382 };
00383 } // end namespace
00384 #endif

Generated on Mon Jun 19 12:42:49 2006 for libsax by  doxygen 1.4.6