[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdepim/kpilot
From:       Adriaan de Groot <groot () kde ! org>
Date:       2005-04-18 22:52:10
Message-ID: 20050418225210.634893C8 () office ! kde ! org
[Download RAW message or body]

CVS commit by adridg: 

Move appinfo constant to class where it makes sense; add uninterpreted form of \
PilotAppInfoBase.


  M +3 -3      conduits/memofileconduit/memofile-conduit.cc   1.15
  M +16 -0     lib/pilotDatabase.cc   1.16
  M +30 -6     lib/pilotDatabase.h   1.30


--- kdepim/kpilot/conduits/memofileconduit/memofile-conduit.cc  #1.14:1.15
@@ -235,6 +235,6 @@ bool MemofileConduit::getAppInfo()
 
 
-        unsigned char buffer[PilotDatabase::MAX_APPINFO_SIZE];
-        int appInfoSize = \
fDatabase->readAppBlock(buffer,PilotDatabase::MAX_APPINFO_SIZE); +        unsigned \
char buffer[PilotAppInfoBase::MAX_APPINFO_SIZE]; +        int appInfoSize = \
fDatabase->readAppBlock(buffer,PilotAppInfoBase::MAX_APPINFO_SIZE);  
         if (appInfoSize<0) {

--- kdepim/kpilot/lib/pilotDatabase.cc  #1.15:1.16
@@ -110,4 +110,20 @@ PilotDatabase::PilotDatabase(const QStri
 }
 
+PilotAppInfoBase::PilotAppInfoBase(PilotDatabase *d) : fC(new struct \
CategoryAppInfo), fLen(0), fOwn(true) +{
+        FUNCTIONSETUP;
+        int appLen = MAX_APPINFO_SIZE;
+        unsigned char buffer[MAX_APPINFO_SIZE];
+
+        fLen = appLen = d->readAppBlock(buffer,appLen);
+        unpack_CategoryAppInfo(fC, buffer, appLen);
+} ;
+
+PilotAppInfoBase::~PilotAppInfoBase()
+{
+        if (fOwn) delete fC;
+} ;
+
+
 int PilotAppInfoBase::findCategory(const QString &selectedCategory, 
         bool unknownIsUnfiled, struct CategoryAppInfo *info)

--- kdepim/kpilot/lib/pilotDatabase.h  #1.29:1.30
@@ -69,6 +69,4 @@ public:
         virtual ~PilotDatabase();
 
-        static const int MAX_APPINFO_SIZE=8192;
-
 
         QString name() const { return fName; } ;
@@ -188,8 +186,16 @@ private:
 };
 
+/** Base class for all specific kinds of AppInfo. */
 class KDE_EXPORT PilotAppInfoBase
 {
 protected:
-        PilotAppInfoBase() { } ;
+        /** Constructor. This is for use by derived classes (using the template \
below +        * only, and says that the category info in the base class aliases data \
in +        * the derived class. Remember to call init()!
+        */
+        PilotAppInfoBase() : fC(0L), fLen(-1), fOwn(false) { } ;
+        /** Initialize class members after reading header, to alias data elsewhere.
+        * Only for use by the (derived) template classes below.
+        */
         void init(struct CategoryAppInfo *c, int len)
         {
@@ -199,6 +205,23 @@ protected:
 
 public:
+        /** Maximum size of an AppInfo block, taken roughly from the pilot-link \
source. */ +        static const int MAX_APPINFO_SIZE=8192;
+
+        /** Constructor, intended for untyped access to the AppInfo only. This \
throws +        * away everything but the category information. In this variety, the 
+        * CategoryAppInfo structure is owned by the PilotAppInfoBase object. 
+        */
+        PilotAppInfoBase(PilotDatabase *d);
+        /** Destructor. */
+        virtual ~PilotAppInfoBase();
+
+        /** Retrieve the most basic part of the AppInfo block -- the category
+        * information which is guaranteed to be the first 240-odd bytes of
+        * a database.
+        */
         struct CategoryAppInfo *categoryInfo() { return fC; } ;
+        /** Const version of the above function. */
         const struct CategoryAppInfo *categoryInfo() const { return fC; } ;
+        /** Returns the length of the (whole) AppInfo block. */
         int length() const { return fLen; } ;
 
@@ -227,4 +250,5 @@ private:
         struct CategoryAppInfo *fC;
         int fLen;
+        bool fOwn;
 } ;
 
@@ -233,9 +257,9 @@ class PilotAppInfo : public PilotAppInfo
 {
 public:
-        PilotAppInfo(PilotDatabase *d)
+        PilotAppInfo(PilotDatabase *d) : PilotAppInfoBase()
         {
                 FUNCTIONSETUP;
-                int appLen = 8192;
-                unsigned char buffer[8192];
+                int appLen = MAX_APPINFO_SIZE;
+                unsigned char buffer[MAX_APPINFO_SIZE];
 
                 appLen = d->readAppBlock(buffer,appLen);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic