You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
6.2 KiB
163 lines
6.2 KiB
15 years ago
|
/*=========================================================================
|
||
|
| 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>
|
||
15 years ago
|
#include <string>
|
||
15 years ago
|
|
||
|
/*=========================================================================
|
||
|
| 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.
|
||
15 years ago
|
#define USE_CALDAV_MODIFY
|
||
15 years ago
|
#define USE_CALDAV_TASKS_MODIFY
|
||
15 years ago
|
|
||
|
/*=========================================================================
|
||
|
| 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;
|
||
|
|
||
15 years ago
|
if ((OK == res) && (url() != "")) {
|
||
13 years ago
|
kdDebug() << "pushing added objects" << '\n';
|
||
15 years ago
|
res = pushObjects(mAdded, caldav_add_object, OK, RT);
|
||
|
if (OK == res) {
|
||
15 years ago
|
#ifdef USE_CALDAV_MODIFY
|
||
13 years ago
|
kdDebug() << "pushing changed objects" << '\n';
|
||
15 years ago
|
res = pushObjects(mChanged, caldav_modify_object, OK, RT);
|
||
|
if (OK == res) {
|
||
13 years ago
|
kdDebug() << "pushing deleted objects" << '\n';
|
||
15 years ago
|
res = pushObjects(mDeleted, caldav_delete_object, OK, RT);
|
||
|
}
|
||
15 years ago
|
#else // if USE_CALDAV_MODIFY
|
||
13 years ago
|
kdDebug() << "pushing changed objects (delete)" << '\n';
|
||
15 years ago
|
res = pushObjects(mChanged, caldav_delete_object, OK, RT);
|
||
|
if (OK == res) {
|
||
13 years ago
|
kdDebug() << "pushing changed objects (add)" << '\n';
|
||
15 years ago
|
res = pushObjects(mChanged, caldav_add_object, OK, RT);
|
||
|
if (OK == res) {
|
||
13 years ago
|
kdDebug() << "pushing deleted objects" << '\n';
|
||
15 years ago
|
res = pushObjects(mDeleted, caldav_delete_object, OK, RT);
|
||
|
}
|
||
|
}
|
||
15 years ago
|
#endif // if USE_CALDAV_MODIFY
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
int tasksres = OK;
|
||
|
|
||
|
if ((OK == tasksres) && (tasksUrl() != "")) {
|
||
13 years ago
|
kdDebug() << "pushing added tasks objects" << '\n';
|
||
15 years ago
|
tasksres = pushTasksObjects(mTasksAdded, caldav_add_object, OK, RT);
|
||
|
if (OK == tasksres) {
|
||
15 years ago
|
#ifdef USE_CALDAV_TASKS_MODIFY
|
||
13 years ago
|
kdDebug() << "pushing changed objects" << '\n';
|
||
15 years ago
|
tasksres = pushTasksObjects(mTasksChanged, caldav_tasks_modify_object, OK, RT);
|
||
|
if (OK == tasksres) {
|
||
13 years ago
|
kdDebug() << "pushing deleted objects" << '\n';
|
||
15 years ago
|
tasksres = pushTasksObjects(mTasksDeleted, caldav_tasks_delete_object, OK, RT);
|
||
15 years ago
|
}
|
||
15 years ago
|
#else // if USE_CALDAV_TASKS_MODIFY
|
||
13 years ago
|
kdDebug() << "pushing changed objects (delete)" << '\n';
|
||
15 years ago
|
tasksres = pushTasksObjects(mTasksChanged, caldav_tasks_delete_object, OK, RT);
|
||
|
if (OK == tasksres) {
|
||
13 years ago
|
kdDebug() << "pushing changed objects (add)" << '\n';
|
||
15 years ago
|
tasksres = pushTasksObjects(mTasksChanged, caldav_add_object, OK, RT);
|
||
|
if (OK == tasksres) {
|
||
13 years ago
|
kdDebug() << "pushing deleted objects" << '\n';
|
||
15 years ago
|
tasksres = pushTasksObjects(mTasksDeleted, caldav_tasks_delete_object, OK, RT);
|
||
15 years ago
|
}
|
||
|
}
|
||
15 years ago
|
#endif // if USE_CALDAV_TASKS_MODIFY
|
||
15 years ago
|
}
|
||
15 years ago
|
}
|
||
|
|
||
14 years ago
|
int journalsres = OK;
|
||
|
|
||
|
if ((OK == journalsres) && (tasksUrl() != "")) {
|
||
13 years ago
|
kdDebug() << "pushing added tasks objects" << '\n';
|
||
14 years ago
|
journalsres = pushJournalsObjects(mJournalsAdded, caldav_add_object, OK, RT);
|
||
|
if (OK == journalsres) {
|
||
|
#ifdef USE_CALDAV_TASKS_MODIFY
|
||
13 years ago
|
kdDebug() << "pushing changed objects" << '\n';
|
||
14 years ago
|
journalsres = pushJournalsObjects(mJournalsChanged, caldav_tasks_modify_object, OK, RT);
|
||
|
if (OK == journalsres) {
|
||
13 years ago
|
kdDebug() << "pushing deleted objects" << '\n';
|
||
14 years ago
|
journalsres = pushJournalsObjects(mJournalsDeleted, caldav_tasks_delete_object, OK, RT);
|
||
|
}
|
||
|
#else // if USE_CALDAV_TASKS_MODIFY
|
||
13 years ago
|
kdDebug() << "pushing changed objects (delete)" << '\n';
|
||
14 years ago
|
journalsres = pushJournalsObjects(mJournalsChanged, caldav_tasks_delete_object, OK, RT);
|
||
|
if (OK == journalsres) {
|
||
13 years ago
|
kdDebug() << "pushing changed objects (add)" << '\n';
|
||
14 years ago
|
journalsres = pushJournalsObjects(mJournalsChanged, caldav_add_object, OK, RT);
|
||
|
if (OK == journalsres) {
|
||
13 years ago
|
kdDebug() << "pushing deleted objects" << '\n';
|
||
14 years ago
|
journalsres = pushJournalsObjects(mJournalsDeleted, caldav_tasks_delete_object, OK, RT);
|
||
|
}
|
||
|
}
|
||
|
#endif // if USE_CALDAV_TASKS_MODIFY
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
if ((OK != res) || (OK != tasksres)) {
|
||
15 years ago
|
clearObjects();
|
||
|
}
|
||
|
|
||
15 years ago
|
if (tasksres == OK)
|
||
|
return res;
|
||
|
else
|
||
|
return tasksres;
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
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
|
||
|
}
|
||
|
|
||
14 years ago
|
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
|
||
|
}
|
||
|
|
||
15 years ago
|
// EOF ========================================================================
|