1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/*=========================================================================
| 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";
res = pushObjects(mAdded, caldav_add_object, OK, RT);
if (OK == res) {
#ifdef USE_CALDAV_MODIFY
kdDebug() << "pushing changed objects";
res = pushObjects(mChanged, caldav_modify_object, OK, RT);
if (OK == res) {
kdDebug() << "pushing deleted objects";
res = pushObjects(mDeleted, caldav_delete_object, OK, RT);
}
#else // if USE_CALDAV_MODIFY
kdDebug() << "pushing changed objects (delete)";
res = pushObjects(mChanged, caldav_delete_object, OK, RT);
if (OK == res) {
kdDebug() << "pushing changed objects (add)";
res = pushObjects(mChanged, caldav_add_object, OK, RT);
if (OK == res) {
kdDebug() << "pushing deleted objects";
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";
tasksres = pushTasksObjects(mTasksAdded, caldav_add_object, OK, RT);
if (OK == tasksres) {
#ifdef USE_CALDAV_TASKS_MODIFY
kdDebug() << "pushing changed objects";
tasksres = pushTasksObjects(mTasksChanged, caldav_tasks_modify_object, OK, RT);
if (OK == tasksres) {
kdDebug() << "pushing deleted objects";
tasksres = pushTasksObjects(mTasksDeleted, caldav_tasks_delete_object, OK, RT);
}
#else // if USE_CALDAV_TASKS_MODIFY
kdDebug() << "pushing changed objects (delete)";
tasksres = pushTasksObjects(mTasksChanged, caldav_tasks_delete_object, OK, RT);
if (OK == tasksres) {
kdDebug() << "pushing changed objects (add)";
tasksres = pushTasksObjects(mTasksChanged, caldav_add_object, OK, RT);
if (OK == tasksres) {
kdDebug() << "pushing deleted objects";
tasksres = pushTasksObjects(mTasksDeleted, 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;
}
// EOF ========================================================================
|