blob: c35e185a822b9a227896357dc4c162025ceb2e24 (
plain)
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
|
/*=========================================================================
| KCardDAV
|--------------------------------------------------------------------------
| (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
========================================================================*/
#ifndef KCARDDAV_WRITER_H
#define KCARDDAV_WRITER_H
#include "job.h"
#include <string>
#include <qstring.h>
#include <qdatetime.h>
namespace KABC {
/*=========================================================================
| CLASS
========================================================================*/
/**
* Calendar writer.
*/
class CardDavWriter : public CardDavJob {
public:
/**
* @param url URL to load.
*/
CardDavWriter(const QString& url = QString()) :
CardDavJob(url)
{
clearObjects();
}
/**
* Sets the information about added incidences writer should send to server.
* @param s icalendar-formatted string consists of all added incidences plus necessary calendar info.
* May be an empty string, which means there is no added incidences to send.
*/
void setAddedObjects(const QString& s) {
mAdded = s;
}
/**
* Sets the information about changed incidences writer should send to server.
* @param s icalendar-formatted string consists of all changed incidences plus necessary calendar info.
* May be an empty string, which means there is no changed incidences to send.
*/
void setChangedObjects(const QString& s) {
mChanged = s;
}
/**
* Sets the information about deleted incidences writer should send to server.
* @param s icalendar-formatted string consists of all deleted incidences plus necessary calendar info.
* May be an empty string, which means there is no deleted incidences to send.
*/
void setDeletedObjects(const QString& s) {
mDeleted = s;
}
/**
* Clear all the information previously set.
*/
void clearObjects() {
setAddedObjects("");
setChangedObjects("");
setDeletedObjects("");
}
protected:
virtual int runJob(runtime_info* caldavRuntime);
virtual void cleanJob();
/// Just a wrapper above libcaldav functions.
template<typename Operation>
int pushObjects(const QString& data, Operation op, int okCode, runtime_info* RT) {
int r = okCode;
if (!data.isNull() && !data.isEmpty()) {
r = op(std::string(data.ascii()).c_str(), std::string(url().ascii()).c_str(), RT);
}
return r;
}
private:
QString mAdded;
QString mChanged;
QString mDeleted;
};
} // namespace KABC
#endif // KCARDDAV_WRITER_H
|