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

List:       kde-commits
Subject:    kdepim/libkdenetwork/gpgmepp
From:       Marc Mutz <Marc.Mutz () uni-bielefeld ! de>
Date:       2004-04-26 8:08:46
Message-ID: 20040426080846.968C79A6E () office ! kde ! org
[Download RAW message or body]

CVS commit by mutz: 

Add KeyListResult::mergeWith( KeyListResult )


  M +25 -1     keylistresult.cpp   1.6
  M +8 -0      keylistresult.h   1.6


--- kdepim/libkdenetwork/gpgmepp/keylistresult.cpp  #1.5:1.6
@@ -34,4 +34,5 @@ class GpgME::KeyListResult::Private : pu
 public:
   Private( const _gpgme_op_keylist_result & r ) : Shared(), res( r ) {}
+  Private( const Private & other ) : Shared(), res( other.res ) {}
 
   _gpgme_op_keylist_result res;
@@ -57,5 +58,28 @@ GpgME::KeyListResult::KeyListResult( con
 }
 
-make_standard_stuff(KeyListResult)
+make_standard_stuff(KeyListResult);
+
+void GpgME::KeyListResult::detach() {
+  if ( isNull() || d->refCount() <= 1 )
+    return;
+  d->unref();
+  d = new Private( *d );
+}
+
+void GpgME::KeyListResult::mergeWith( const KeyListResult & other ) {
+  if ( other.isNull() )
+    return;
+  if ( isNull() ) { // just assign
+    operator=( other );
+    return;
+  }
+  // merge the truncated flag (try to keep detaching to a minimum):
+  if ( other.d->res.truncated && !d->res.truncated ) {
+    detach();
+    d->res.truncated = true;
+  }
+  if ( !error() ) // only merge the error when there was none yet.
+    Result::operator=( other );
+}
 
 bool GpgME::KeyListResult::isTruncated() const {

--- kdepim/libkdenetwork/gpgmepp/keylistresult.h  #1.5:1.6
@@ -40,4 +40,11 @@ namespace GpgME {
     const KeyListResult & operator=( const KeyListResult & other );
 
+    const KeyListResult & operator+=( const KeyListResult & other ) {
+      mergeWith( other );
+      return *this;
+    }
+
+    void mergeWith( const KeyListResult & other );
+
     bool isNull() const;
 
@@ -45,4 +52,5 @@ namespace GpgME {
 
   private:
+    void detach();
     class Private;
     Private * d;


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

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