summaryrefslogtreecommitdiffstats
path: root/tderesources/caldav/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/caldav/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/caldav/writer.cpp')
-rw-r--r--tderesources/caldav/writer.cpp162
1 files changed, 162 insertions, 0 deletions
diff --git a/tderesources/caldav/writer.cpp b/tderesources/caldav/writer.cpp
new file mode 100644
index 000000000..d9a6b2f0e
--- /dev/null
+++ b/tderesources/caldav/writer.cpp
@@ -0,0 +1,162 @@
+/*=========================================================================
+| KCalDAV
+|--------------------------------------------------------------------------
+| (c) 2010 Timothy Pearson
+| (c) 2009 Kumaran Santhanam (initial KDE4 version)
+|
+| This project is released under the GNU General Public License.
+| Please see the file COPYING for more details.
+|--------------------------------------------------------------------------
+| Remote calendar writing class.
+ ========================================================================*/
+
+/*=========================================================================
+| INCLUDES
+ ========================================================================*/
+
+#include "writer.h"
+#include <kdebug.h>
+#include <string>
+
+/*=========================================================================
+| DEFINES
+ ========================================================================*/
+
+// Use caldav_modify_object() function.
+// If it's not set, a pair of caldav_delete_object/caldav_add_object
+// is used for modifying objects.
+// It's done, because, for some reason, SOGo server returns an error
+// on caldav_modify_object. DAViCAL works fine both ways.
+#define USE_CALDAV_MODIFY
+#define USE_CALDAV_TASKS_MODIFY
+
+/*=========================================================================
+| NAMESPACE
+ ========================================================================*/
+
+using namespace KCal;
+
+/*=========================================================================
+| METHODS
+ ========================================================================*/
+
+void CalDavWriter::cleanJob() {
+ CalDavJob::cleanJob();
+}
+
+int CalDavWriter::runJob(runtime_info* RT) {
+ kdDebug() << "writer::run, url: " << url() << "\n";
+
+ int res = OK;
+
+ if ((OK == res) && (url() != "")) {
+ kdDebug() << "pushing added objects" << '\n';
+ res = pushObjects(mAdded, caldav_add_object, OK, RT);
+ if (OK == res) {
+#ifdef USE_CALDAV_MODIFY
+ kdDebug() << "pushing changed objects" << '\n';
+ res = pushObjects(mChanged, caldav_modify_object, OK, RT);
+ if (OK == res) {
+ kdDebug() << "pushing deleted objects" << '\n';
+ res = pushObjects(mDeleted, caldav_delete_object, OK, RT);
+ }
+#else // if USE_CALDAV_MODIFY
+ kdDebug() << "pushing changed objects (delete)" << '\n';
+ res = pushObjects(mChanged, caldav_delete_object, OK, RT);
+ if (OK == res) {
+ kdDebug() << "pushing changed objects (add)" << '\n';
+ res = pushObjects(mChanged, caldav_add_object, OK, RT);
+ if (OK == res) {
+ kdDebug() << "pushing deleted objects" << '\n';
+ res = pushObjects(mDeleted, caldav_delete_object, OK, RT);
+ }
+ }
+#endif // if USE_CALDAV_MODIFY
+ }
+ }
+
+ int tasksres = OK;
+
+ if ((OK == tasksres) && (tasksUrl() != "")) {
+ kdDebug() << "pushing added tasks objects" << '\n';
+ tasksres = pushTasksObjects(mTasksAdded, caldav_add_object, OK, RT);
+ if (OK == tasksres) {
+#ifdef USE_CALDAV_TASKS_MODIFY
+ kdDebug() << "pushing changed objects" << '\n';
+ tasksres = pushTasksObjects(mTasksChanged, caldav_tasks_modify_object, OK, RT);
+ if (OK == tasksres) {
+ kdDebug() << "pushing deleted objects" << '\n';
+ tasksres = pushTasksObjects(mTasksDeleted, caldav_tasks_delete_object, OK, RT);
+ }
+#else // if USE_CALDAV_TASKS_MODIFY
+ kdDebug() << "pushing changed objects (delete)" << '\n';
+ tasksres = pushTasksObjects(mTasksChanged, caldav_tasks_delete_object, OK, RT);
+ if (OK == tasksres) {
+ kdDebug() << "pushing changed objects (add)" << '\n';
+ tasksres = pushTasksObjects(mTasksChanged, caldav_add_object, OK, RT);
+ if (OK == tasksres) {
+ kdDebug() << "pushing deleted objects" << '\n';
+ tasksres = pushTasksObjects(mTasksDeleted, caldav_tasks_delete_object, OK, RT);
+ }
+ }
+#endif // if USE_CALDAV_TASKS_MODIFY
+ }
+ }
+
+ int journalsres = OK;
+
+ if ((OK == journalsres) && (tasksUrl() != "")) {
+ kdDebug() << "pushing added tasks objects" << '\n';
+ journalsres = pushJournalsObjects(mJournalsAdded, caldav_add_object, OK, RT);
+ if (OK == journalsres) {
+#ifdef USE_CALDAV_TASKS_MODIFY
+ kdDebug() << "pushing changed objects" << '\n';
+ journalsres = pushJournalsObjects(mJournalsChanged, caldav_tasks_modify_object, OK, RT);
+ if (OK == journalsres) {
+ kdDebug() << "pushing deleted objects" << '\n';
+ journalsres = pushJournalsObjects(mJournalsDeleted, caldav_tasks_delete_object, OK, RT);
+ }
+#else // if USE_CALDAV_TASKS_MODIFY
+ kdDebug() << "pushing changed objects (delete)" << '\n';
+ journalsres = pushJournalsObjects(mJournalsChanged, caldav_tasks_delete_object, OK, RT);
+ if (OK == journalsres) {
+ kdDebug() << "pushing changed objects (add)" << '\n';
+ journalsres = pushJournalsObjects(mJournalsChanged, caldav_add_object, OK, RT);
+ if (OK == journalsres) {
+ kdDebug() << "pushing deleted objects" << '\n';
+ journalsres = pushJournalsObjects(mJournalsDeleted, caldav_tasks_delete_object, OK, RT);
+ }
+ }
+#endif // if USE_CALDAV_TASKS_MODIFY
+ }
+ }
+
+ if ((OK != res) || (OK != tasksres)) {
+ clearObjects();
+ }
+
+ if (tasksres == OK)
+ return res;
+ else
+ return tasksres;
+}
+
+int CalDavWriter::runTasksJob(runtime_info* RT) {
+ // Stub function as there is no reason to split the writing jobs like the reading jobs
+ return OK;
+}
+
+void CalDavWriter::cleanTasksJob() {
+ // Stub function as there is no reason to split the writing jobs like the reading jobs
+}
+
+int CalDavWriter::runJournalsJob(runtime_info* RT) {
+ // Stub function as there is no reason to split the writing jobs like the reading jobs
+ return OK;
+}
+
+void CalDavWriter::cleanJournalsJob() {
+ // Stub function as there is no reason to split the writing jobs like the reading jobs
+}
+
+// EOF ========================================================================