summaryrefslogtreecommitdiffstats
path: root/kresources/carddav/writer.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-05-31 07:49:08 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-05-31 07:49:08 +0000
commit7ef3b0e2a5e5bc9bf928e989e4f66932be096824 (patch)
treed1b924b843f78b9d9de26becb36bb8e12f7fef44 /kresources/carddav/writer.h
parentf4a40d0495ff26b8767cf321fa8039e5ac633c12 (diff)
downloadtdepim-7ef3b0e2a5e5bc9bf928e989e4f66932be096824.tar.gz
tdepim-7ef3b0e2a5e5bc9bf928e989e4f66932be096824.zip
Added new carddav resource for kaddressbook
Lots of bugfixes for korganizer caldav resource git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1132701 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kresources/carddav/writer.h')
-rw-r--r--kresources/carddav/writer.h109
1 files changed, 109 insertions, 0 deletions
diff --git a/kresources/carddav/writer.h b/kresources/carddav/writer.h
new file mode 100644
index 000000000..c35e185a8
--- /dev/null
+++ b/kresources/carddav/writer.h
@@ -0,0 +1,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
+