summaryrefslogtreecommitdiffstats
path: root/tderesources/carddav/writer.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:50 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-26 13:17:50 -0600
commitb363d2579af0a11b77e698aed2e1021c2233b644 (patch)
treef4a47b87354b7a6a3b266c8121bd8ddaeb7accaa /tderesources/carddav/writer.cpp
parent61bddfe3a7226b18c68a76124b727c736f431688 (diff)
downloadtdepim-b363d2579af0a11b77e698aed2e1021c2233b644.tar.gz
tdepim-b363d2579af0a11b77e698aed2e1021c2233b644.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tderesources/carddav/writer.cpp')
-rw-r--r--tderesources/carddav/writer.cpp106
1 files changed, 106 insertions, 0 deletions
diff --git a/tderesources/carddav/writer.cpp b/tderesources/carddav/writer.cpp
new file mode 100644
index 000000000..68bf126d5
--- /dev/null
+++ b/tderesources/carddav/writer.cpp
@@ -0,0 +1,106 @@
+/*=========================================================================
+| KABCDAV
+|--------------------------------------------------------------------------
+| (c) 2010 Timothy Pearson
+|
+| This project is released under the GNU General Public License.
+| Please see the file COPYING for more details.
+|--------------------------------------------------------------------------
+| Remote address book writing class.
+ ========================================================================*/
+
+/*=========================================================================
+| INCLUDES
+ ========================================================================*/
+
+#include "writer.h"
+#include <kdebug.h>
+#include <string>
+
+/*=========================================================================
+| DEFINES
+ ========================================================================*/
+
+// Use carddav_modify_object() function.
+// If it's not set, a pair of carddav_delete_object/carddav_add_object
+// is used for modifying objects.
+// It's done, because, for some reason, Zimbra returns an error
+// on carddav_modify_object.
+//#define USE_CARDDAV_MODIFY
+
+/*=========================================================================
+| NAMESPACE
+ ========================================================================*/
+
+using namespace KABC;
+
+/*=========================================================================
+| METHODS
+ ========================================================================*/
+
+void CardDavWriter::cleanJob() {
+ CardDavJob::cleanJob();
+}
+
+int CardDavWriter::runJob(runtime_info* RT) {
+ kdDebug() << "writer::run, url: " << url() << "\n";
+
+ int res = OK;
+
+ kdDebug() << "pushing added objects" << '\n';
+ res = pushObjects(mAdded, carddav_add_object, OK, RT);
+ if (OK == res) {
+#ifdef USE_CARDDAV_MODIFY
+ kdDebug() << "pushing changed objects" << '\n';
+ if (getUseURI() == false)
+ res = pushObjects(mChanged, carddav_modify_object, OK, RT);
+ else
+ res = pushObjects(mChanged, carddav_modify_object_by_uri, OK, RT);
+ if (OK == res) {
+ kdDebug() << "pushing deleted objects" << '\n';
+ while (mDeleted.contains("BEGIN:VCARD", TRUE) > 0) {
+ int endLocation = mDeleted.find("END:VCARD", 0, TRUE);
+ TQString deletedCurSeq = mDeleted.mid(0, endLocation+9);
+ mDeleted = mDeleted.remove(0, endLocation+9);
+ if (getUseURI() == false)
+ res = pushObjects(deletedCurSeq, carddav_delete_object, OK, RT);
+ else
+ res = pushObjects(deletedCurSeq, carddav_delete_object_by_uri, OK, RT);
+ }
+ }
+#else // if USE_CARDDAV_MODIFY
+ kdDebug() << "pushing changed objects (delete)" << '\n';
+ if (getUseURI() == false)
+ res = pushObjects(mChanged, carddav_delete_object, OK, RT);
+ else
+ res = pushObjects(mChanged, carddav_delete_object_by_uri, OK, RT);
+ if (OK == res) {
+ kdDebug() << "pushing changed objects (add)" << '\n';
+ if (getUseURI() == false)
+ res = pushObjects(mChanged, carddav_add_object, OK, RT);
+ else
+ res = pushObjects(mChanged, carddav_add_object, OK, RT);
+ if (OK == res) {
+ kdDebug() << "pushing deleted objects" << '\n';
+ while (mDeleted.contains("BEGIN:VCARD", TRUE) > 0) {
+ int endLocation = mDeleted.find("END:VCARD", 0, TRUE);
+ TQString deletedCurSeq = mDeleted.mid(0, endLocation+9);
+ mDeleted = mDeleted.remove(0, endLocation+9);
+ if (getUseURI() == false)
+ res = pushObjects(deletedCurSeq, carddav_delete_object, OK, RT);
+ else
+ res = pushObjects(deletedCurSeq, carddav_delete_object_by_uri, OK, RT);
+ }
+ }
+ }
+#endif // if USE_CARDDAV_MODIFY
+ }
+
+ if (OK != res) {
+ clearObjects();
+ }
+
+ return res;
+}
+
+// EOF ========================================================================