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

List:       kde-commits
Subject:    kdelibs/kabc
From:       Bo Thorsen <bo () sonofthor ! dk>
Date:       2004-01-07 10:01:07
Message-ID: 20040107100107.886C293B8 () office ! kde ! org
[Download RAW message or body]

CVS commit by thorsen: 

Fix a couple of issues in the ab resource class.

THIS IS BINARY INCOMPATIBLE!

Note to translators: It also adds two new i18n strings (sorry). The strings
are identical to the strings in kdelibs/kabc/plugins/ldap/resourceldap.cpp,
so you can just copy the translation from that file.

Not included in this patch: Remove the abc resource plugin methods that
implement exactly the same asyncLoad and asyncSave as these default
implementations.

Reviewed by several people.


  M +24 -0     resource.cpp   1.25
  M +6 -12     resource.h   1.28


--- kdelibs/kabc/resource.cpp  #1.24:1.25
@@ -20,4 +20,5 @@
 
 #include <kdebug.h>
+#include <klocale.h>
 
 #include "resource.h"
@@ -336,3 +337,26 @@ void Resource::clear()
 }
 
+bool Resource::asyncLoad()
+{
+  bool ok = load();
+  if ( !ok )
+    emit loadingError( this, i18n( "Loading resource '%1' failed!" )
+                       .arg( resourceName() ) );
+  else
+    emit loadingFinished( this );
+
+  return ok;
+}
+
+bool Resource::asyncSave( Ticket *ticket ) {
+  bool ok = save( ticket );
+  if ( !ok )
+    emit savingError( this, i18n( "Saving resource '%1' failed!" )
+                      .arg( resourceName() ) );
+  else
+    emit savingFinished( this );
+
+  return ok;
+}
+
 #include "resource.moc"

--- kdelibs/kabc/resource.h  #1.27:1.28
@@ -161,14 +161,4 @@ class Resource : public KRES::Resource
 
     /**
-      Opens the resource and returns if it was successfully
-     */
-    virtual bool doOpen() = 0;
-
-    /**
-      Closes the resource and returns if it was successfully
-     */
-    virtual void doClose() = 0;
-
-    /**
       Request a ticket, you have to pass through save() to
       allow locking. The resource has to create its locks
@@ -195,7 +185,9 @@ class Resource : public KRES::Resource
       this function.
 
+      The default implementation simply calls the synchronous load.
+
       @return Whether the synchronous part of loading was successfully.
      */
-    virtual bool asyncLoad() = 0;
+    virtual bool asyncLoad();
 
     /**
@@ -223,9 +215,11 @@ class Resource : public KRES::Resource
       this function.
 
+      The default implementation simply calls the synchronous save.
+
       @param ticket You have to release the ticket later with
                     releaseSaveTicket() explicitely.
       @return Whether the saving was successfully.
      */
-    virtual bool asyncSave( Ticket *ticket ) = 0;
+    virtual bool asyncSave( Ticket *ticket );
 
     /**


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

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