From a71c4476a79950040c9007f84af25cef4e28b351 Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 24 May 2010 17:21:58 +0000 Subject: Initial CalDAV support git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1130194 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kresources/caldav/writer.h | 110 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 kresources/caldav/writer.h (limited to 'kresources/caldav/writer.h') diff --git a/kresources/caldav/writer.h b/kresources/caldav/writer.h new file mode 100644 index 000000000..841fc4477 --- /dev/null +++ b/kresources/caldav/writer.h @@ -0,0 +1,110 @@ +/*========================================================================= +| 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 + ========================================================================*/ + +#ifndef KCALDAV_WRITER_H +#define KCALDAV_WRITER_H + +#include "job.h" + +#include +#include +#include + +namespace KCal { + +/*========================================================================= +| CLASS + ========================================================================*/ + +/** + * Calendar writer. + */ +class CalDavWriter : public CalDavJob { + +public: + + /** + * @param url URL to load. + */ + CalDavWriter(const QString& url = QString()) : + CalDavJob(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 + 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 KCal + +#endif // KCALDAV_WRITER_H + -- cgit v1.2.1