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

List:       kde-commits
Subject:    KDE/kdepim/akonadi/server/src/handler
From:       Volker Krause <volker.krause () rwth-aachen ! de>
Date:       2006-09-20 16:44:25
Message-ID: 1158770665.004529.12421.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 586805 by vkrause:

Add error handling.


 M  +23 -20    store.cpp  
 M  +3 -3      store.h  


--- trunk/KDE/kdepim/akonadi/server/src/handler/store.cpp #586804:586805
@@ -89,14 +89,18 @@
   for ( int i = 0; i < pimItems.count(); ++i ) {
     if ( mStoreQuery.dataType() == StoreQuery::Flags ) {
       if ( mStoreQuery.operation() & StoreQuery::Replace ) {
-        replaceFlags( pimItems[ i ], mStoreQuery.flags() );
+        if ( !replaceFlags( pimItems[ i ], mStoreQuery.flags() ) )
+          return failureResponse( "Unable to replace item flags." );
       } else if ( mStoreQuery.operation() & StoreQuery::Add ) {
-        addFlags( pimItems[ i ], mStoreQuery.flags() );
+        if ( !addFlags( pimItems[ i ], mStoreQuery.flags() ) )
+          return failureResponse( "Unable to add item flags." );
       } else if ( mStoreQuery.operation() & StoreQuery::Delete ) {
-        deleteFlags( pimItems[ i ], mStoreQuery.flags() );
+        if ( !deleteFlags( pimItems[ i ], mStoreQuery.flags() ) )
+          return failureResponse( "Unable to remove item flags." );
       }
     } else if ( mStoreQuery.dataType() == StoreQuery::Data ) {
-      store->updatePimItem( pimItems[ i ], mData );
+      if ( !store->updatePimItem( pimItems[ i ], mData ) )
+        return failureResponse( "Unable to change item data." );
     }
 
     if ( !( mStoreQuery.operation() & StoreQuery::Silent ) ) {
@@ -126,7 +130,7 @@
 }
 
 
-void Store::replaceFlags( const PimItem &item, const QList<QByteArray> &flags )
+bool Store::replaceFlags( const PimItem &item, const QList<QByteArray> &flags )
 {
   DataStore *store = connection()->storageBackend();
 
@@ -134,16 +138,14 @@
   for ( int i = 0; i < flags.count(); ++i ) {
     Flag flag = store->flagByName( flags[ i ] );
     if ( !flag.isValid() ) {
-      /**
-       * If the flag does not exist we'll create it now.
-       */
+       // If the flag does not exist we'll create it now.
       if ( !store->appendFlag( flags[ i ] ) ) {
         qDebug( "Store::replaceFlags: Unable to add new flag '%s'", flags[ i ].data() );
-        return;
+        return false;
       } else {
         flag = store->flagByName( flags[ i ] );
         if ( !flag.isValid() )
-          return;
+          return false;
         else
           flagList.append( flag );
       }
@@ -154,11 +156,12 @@
 
   if ( !store->setItemFlags( item, flagList ) ) {
     qDebug( "Store::replaceFlags: Unable to set new item flags" );
-    return;
+    return false;
   }
+  return true;
 }
 
-void Store::addFlags( const PimItem &item, const QList<QByteArray> &flags )
+bool Store::addFlags( const PimItem &item, const QList<QByteArray> &flags )
 {
   DataStore *store = connection()->storageBackend();
 
@@ -166,16 +169,14 @@
   for ( int i = 0; i < flags.count(); ++i ) {
     Flag flag = store->flagByName( flags[ i ] );
     if ( !flag.isValid() ) {
-      /**
-       * If the flag does not exist we'll create it now.
-       */
+       // If the flag does not exist we'll create it now.
       if ( !store->appendFlag( flags[ i ] ) ) {
         qDebug( "Store::addFlags: Unable to add new flag '%s'", flags[ i ].data() );
-        return;
+        return false;
       } else {
         flag = store->flagByName( flags[ i ] );
         if ( !flag.isValid() )
-          return;
+          return false;
         else
           flagList.append( flag );
       }
@@ -186,11 +187,12 @@
 
   if ( !store->appendItemFlags( item, flagList ) ) {
     qDebug( "Store::addFlags: Unable to add new item flags" );
-    return;
+    return false;
   }
+  return true;
 }
 
-void Store::deleteFlags( const PimItem &item, const QList<QByteArray> &flags )
+bool Store::deleteFlags( const PimItem &item, const QList<QByteArray> &flags )
 {
   DataStore *store = connection()->storageBackend();
 
@@ -205,8 +207,9 @@
 
   if ( !store->removeItemFlags( item, flagList ) ) {
     qDebug( "Store::deleteFlags: Unable to add new item flags" );
-    return;
+    return false;
   }
+  return true;
 }
 
 bool Akonadi::Store::inContinuation() const
--- trunk/KDE/kdepim/akonadi/server/src/handler/store.h #586804:586805
@@ -44,9 +44,9 @@
     bool allDataRead() const;
     bool handleContinuation( const QByteArray& line );
 
-    void replaceFlags( const PimItem &item, const QList<QByteArray> &flags );
-    void addFlags( const PimItem &item, const QList<QByteArray> &flags );
-    void deleteFlags( const PimItem &item, const QList<QByteArray> &flags );
+    bool replaceFlags( const PimItem &item, const QList<QByteArray> &flags );
+    bool addFlags( const PimItem &item, const QList<QByteArray> &flags );
+    bool deleteFlags( const PimItem &item, const QList<QByteArray> &flags );
 
     StoreQuery mStoreQuery;
     int mSize;
[prev in list] [next in list] [prev in thread] [next in thread] 

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