diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-05-31 07:49:08 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-05-31 07:49:08 +0000 |
commit | 7ef3b0e2a5e5bc9bf928e989e4f66932be096824 (patch) | |
tree | d1b924b843f78b9d9de26becb36bb8e12f7fef44 /kresources/carddav/writer.cpp | |
parent | f4a40d0495ff26b8767cf321fa8039e5ac633c12 (diff) | |
download | tdepim-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.cpp')
-rw-r--r-- | kresources/carddav/writer.cpp | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/kresources/carddav/writer.cpp b/kresources/carddav/writer.cpp new file mode 100644 index 000000000..479120d44 --- /dev/null +++ b/kresources/carddav/writer.cpp @@ -0,0 +1,81 @@ +/*========================================================================= +| KABCDAV +|-------------------------------------------------------------------------- +| (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 + ========================================================================*/ + +#include "writer.h" +#include <kdebug.h> +#include <string> + +/*========================================================================= +| DEFINES + ========================================================================*/ + +// Use carddav_modify_object() function. +// If it's not set, a pair of carddav_delete_object/carddav_add_object +// is used for modifying objects. +// It's done, because, for some reason, SOGo server returns an error +// on carddav_modify_object. DAViCAL works fine both ways. +#define USE_CARDDAV_MODIFY + +/*========================================================================= +| NAMESPACE + ========================================================================*/ + +using namespace KABC; + +/*========================================================================= +| METHODS + ========================================================================*/ + +void CardDavWriter::cleanJob() { + CardDavJob::cleanJob(); +} + +int CardDavWriter::runJob(runtime_info* RT) { + kdDebug() << "writer::run, url: " << url() << "\n"; + + int res = OK; + + kdDebug() << "pushing added objects"; + res = pushObjects(mAdded, carddav_add_object, OK, RT); + if (OK == res) { +#ifdef USE_CARDDAV_MODIFY + kdDebug() << "pushing changed objects"; + res = pushObjects(mChanged, carddav_modify_object, OK, RT); + if (OK == res) { + kdDebug() << "pushing deleted objects"; + res = pushObjects(mDeleted, carddav_delete_object, OK, RT); + } +#else // if USE_CARDDAV_MODIFY + kdDebug() << "pushing changed objects (delete)"; + res = pushObjects(mChanged, carddav_delete_object, OK, RT); + if (OK == res) { + kdDebug() << "pushing changed objects (add)"; + res = pushObjects(mChanged, carddav_add_object, OK, RT); + if (OK == res) { + kdDebug() << "pushing deleted objects"; + res = pushObjects(mDeleted, carddav_delete_object, OK, RT); + } + } +#endif // if USE_CARDDAV_MODIFY + } + + if (OK != res) { + clearObjects(); + } + + return res; +} + +// EOF ======================================================================== |