summaryrefslogtreecommitdiffstats
path: root/kresources/carddav
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-06-23 02:32:10 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-06-23 02:32:10 +0000
commit672beaaffcce643b8ab17a191327caa771641a7e (patch)
tree4b4850b93992ba065767768c7f5ff2de2e3e6421 /kresources/carddav
parent23f5d4229caea32af49c007de85563158630b5d4 (diff)
downloadtdepim-672beaaffcce643b8ab17a191327caa771641a7e.tar.gz
tdepim-672beaaffcce643b8ab17a191327caa771641a7e.zip
Major KAddressbook carddav fixes and improvements (should now work with Zimbra once Zimbra fixes a standards compliance issue with contact creation mimetypes)
Fixed handling of close events and save interaction with Kontact and Korganizer git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1141613 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kresources/carddav')
-rw-r--r--kresources/carddav/config.cpp5
-rw-r--r--kresources/carddav/config.h1
-rw-r--r--kresources/carddav/job.cpp2
-rw-r--r--kresources/carddav/job.h15
-rw-r--r--kresources/carddav/preferences.cpp4
-rw-r--r--kresources/carddav/preferences.h2
-rw-r--r--kresources/carddav/prefsskel.kcfg4
-rw-r--r--kresources/carddav/reader.cpp12
-rw-r--r--kresources/carddav/resource.cpp13
-rw-r--r--kresources/carddav/writer.cpp31
10 files changed, 67 insertions, 22 deletions
diff --git a/kresources/carddav/config.cpp b/kresources/carddav/config.cpp
index 8408184cc..2fd583837 100644
--- a/kresources/carddav/config.cpp
+++ b/kresources/carddav/config.cpp
@@ -87,6 +87,7 @@ void ResourceCardDavConfig::loadSettings( KRES::Resource *resource ) {
mUsername->setText(p->username());
mRememberPassword->setChecked(p->rememberPassword());
mPassword->setText(p->password());
+ mUseUriNotUID->setChecked(p->useURI());
mReloadConfig->loadSettings(res);
mSaveConfig->loadSettings(res);
@@ -105,6 +106,7 @@ void ResourceCardDavConfig::saveSettings( KRES::Resource *resource ) {
p->setUsername(mUsername->text());
p->setRememberPassword(mRememberPassword->isChecked());
p->setPassword(mPassword->text());
+ p->setUseURI(mUseUriNotUID->isChecked());
}
}
}
@@ -137,6 +139,9 @@ void ResourceCardDavConfig::setupUI() {
mRememberPassword = new QCheckBox( i18n("Remember password"), this );
mainLayout->addWidget(mRememberPassword, 4, 1);
+ mUseUriNotUID = new QCheckBox( i18n( "Use URI instead of UID when modifying existing contacts" ), this );
+ mainLayout->addWidget( mUseUriNotUID, 5, 1 );
+
// configs
QHBoxLayout* horizontal = new QHBoxLayout(this);
diff --git a/kresources/carddav/config.h b/kresources/carddav/config.h
index c71d55a55..f74cb07f9 100644
--- a/kresources/carddav/config.h
+++ b/kresources/carddav/config.h
@@ -59,6 +59,7 @@ private:
QLineEdit *mUsername;
QLineEdit *mPassword;
QCheckBox *mRememberPassword;
+ QCheckBox *mUseUriNotUID;
CardDavReloadConfig* mReloadConfig;
CardDavSaveConfig* mSaveConfig;
diff --git a/kresources/carddav/job.cpp b/kresources/carddav/job.cpp
index e82645f27..ce5141f06 100644
--- a/kresources/carddav/job.cpp
+++ b/kresources/carddav/job.cpp
@@ -35,7 +35,7 @@ using namespace KABC;
| CONSTRUCTOR AND DESTRUCTOR
========================================================================*/
-CardDavJob::CardDavJob(const QString& url) {
+CardDavJob::CardDavJob(const QString& url) : mUseURI(false) {
cleanJob();
setUrl(url);
}
diff --git a/kresources/carddav/job.h b/kresources/carddav/job.h
index 6d6f8a8ae..79e12f828 100644
--- a/kresources/carddav/job.h
+++ b/kresources/carddav/job.h
@@ -53,6 +53,13 @@ public:
}
/**
+ * Sets whether to use UID (false) or URI (true) as an object's unique identifier
+ */
+ virtual void setUseURI(bool b) {
+ mUseURI = b;
+ }
+
+ /**
* Sets the parent qobject.
*/
virtual void setParent(QObject *s) {
@@ -74,6 +81,13 @@ public:
}
/**
+ * @return whether to use UID (false) or URI (true) as an object's unique identifier
+ */
+ virtual bool getUseURI() {
+ return mUseURI;
+ }
+
+ /**
* @return parent object
*/
virtual QObject *parent() {
@@ -151,6 +165,7 @@ private:
long mErrorNumber;
QObject *mParent;
int mType;
+ bool mUseURI;
void enableCarddavDebug(runtime_info*);
};
diff --git a/kresources/carddav/preferences.cpp b/kresources/carddav/preferences.cpp
index 69c0db9cc..e95041195 100644
--- a/kresources/carddav/preferences.cpp
+++ b/kresources/carddav/preferences.cpp
@@ -206,6 +206,10 @@ void CardDavPrefs::readConfig() {
}*/
}
+bool CardDavPrefs::getUseURI() {
+ return useURI();
+}
+
QString CardDavPrefs::getFullUrl() {
QUrl t(url());
diff --git a/kresources/carddav/preferences.h b/kresources/carddav/preferences.h
index c3f31ed2c..6035efe2d 100644
--- a/kresources/carddav/preferences.h
+++ b/kresources/carddav/preferences.h
@@ -86,6 +86,8 @@ public:
*/
QString getFullUrl();
+ bool getUseURI();
+
protected:
/**
diff --git a/kresources/carddav/prefsskel.kcfg b/kresources/carddav/prefsskel.kcfg
index 39b79b85f..9012e9bab 100644
--- a/kresources/carddav/prefsskel.kcfg
+++ b/kresources/carddav/prefsskel.kcfg
@@ -22,5 +22,9 @@
<label>Remember password</label>
</entry>
+ <entry key="UseURI" type="Bool" >
+ <label>Use URI instead of UID</label>
+ </entry>
+
</group>
</kcfg>
diff --git a/kresources/carddav/reader.cpp b/kresources/carddav/reader.cpp
index 57375e9f9..d71d5236a 100644
--- a/kresources/carddav/reader.cpp
+++ b/kresources/carddav/reader.cpp
@@ -38,13 +38,11 @@ int CardDavReader::runJob(runtime_info* RT) {
response* result = carddav_get_response();
CARDDAV_RESPONSE res = OK;
- if (mGetAll) {
- kdDebug() << "getting all objects";
- res = carddav_getall_object(result, std::string(url().ascii()).c_str(), RT);
- } else {
- kdDebug() << "getting object from the specified time range";
- res = carddav_get_object(result, mTimeStart.toTime_t(), mTimeEnd.toTime_t(), std::string(url().ascii()).c_str(), RT);
- }
+ kdDebug() << "getting all objects";
+ if (getUseURI() == false)
+ res = carddav_getall_object(result, std::string(url().ascii()).c_str(), RT);
+ else
+ res = carddav_getall_object_by_uri(result, std::string(url().ascii()).c_str(), RT);
if (OK == res) {
kdDebug() << "success";
diff --git a/kresources/carddav/resource.cpp b/kresources/carddav/resource.cpp
index 77a0e6889..d8d4508d0 100644
--- a/kresources/carddav/resource.cpp
+++ b/kresources/carddav/resource.cpp
@@ -333,6 +333,7 @@ void ResourceCardDav::loadingQueuePop() {
mLoader->setUrl(t->url);
mLoader->setParent(this);
mLoader->setType(0);
+ mLoader->setUseURI(mPrefs->getUseURI());
//QDateTime dt(QDate::currentDate());
//mLoader->setRange(dt.addDays(-CACHE_DAYS), dt.addDays(CACHE_DAYS));
@@ -394,17 +395,11 @@ void ResourceCardDav::loadFinished() {
QString data = loader->data();
if (!data.isNull() && !data.isEmpty()) {
- // TODO: I don't know why, but some schedules on http://carddav-test.ioda.net/ (I used it for testing)
- // have some lines separated by single \r rather than \n or \r\n.
- // ICalFormat fails to parse that.
data.replace("\r\n", "\n"); // to avoid \r\n becomes \n\n after the next line
data.replace('\r', '\n');
log("trying to parse...");
- //printf("PARSING:\n\r%s\n\r", data.ascii());
if (parseData(data)) {
- // FIXME: The agenda view can crash when a change is
- // made on a remote server and a reload is requested!
log("... parsing is ok");
log("clearing changes");
//enableChangeNotification();
@@ -550,6 +545,7 @@ void ResourceCardDav::writingQueuePop() {
mWriter->setUrl(t->url);
mWriter->setParent(this);
mWriter->setType(1);
+ mWriter->setUseURI(mPrefs->getUseURI());
#ifdef KCARDDAV_DEBUG
const QString fout_path = "/tmp/kcarddav_upload_" + identifier() + ".tmp";
@@ -673,6 +669,11 @@ void ResourceCardDav::writingFinished() {
mWritingQueueReady = true;
updateProgressBar(1);
writingQueuePop();
+
+ // If a URI is required we will need to retrieve it from the server after the new record is committed...
+ if (mPrefs->getUseURI() == true) {
+ startLoading(mPrefs->getFullUrl());
+ }
}
// EOF ========================================================================
diff --git a/kresources/carddav/writer.cpp b/kresources/carddav/writer.cpp
index 479120d44..2216fb065 100644
--- a/kresources/carddav/writer.cpp
+++ b/kresources/carddav/writer.cpp
@@ -24,9 +24,9 @@
// 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
+// It's done, because, for some reason, Zimbra returns an error
+// on carddav_modify_object.
+//#define USE_CARDDAV_MODIFY
/*=========================================================================
| NAMESPACE
@@ -52,20 +52,35 @@ int CardDavWriter::runJob(runtime_info* RT) {
if (OK == res) {
#ifdef USE_CARDDAV_MODIFY
kdDebug() << "pushing changed objects";
- res = pushObjects(mChanged, carddav_modify_object, OK, RT);
+ if (getUseURI() == false)
+ res = pushObjects(mChanged, carddav_modify_object, OK, RT);
+ else
+ res = pushObjects(mChanged, carddav_modify_object_by_uri, OK, RT);
if (OK == res) {
kdDebug() << "pushing deleted objects";
- res = pushObjects(mDeleted, carddav_delete_object, OK, RT);
+ if (getUseURI() == false)
+ res = pushObjects(mDeleted, carddav_delete_object, OK, RT);
+ else
+ res = pushObjects(mDeleted, carddav_delete_object_by_uri, OK, RT);
}
#else // if USE_CARDDAV_MODIFY
kdDebug() << "pushing changed objects (delete)";
- res = pushObjects(mChanged, carddav_delete_object, OK, RT);
+ if (getUseURI() == false)
+ res = pushObjects(mChanged, carddav_delete_object, OK, RT);
+ else
+ res = pushObjects(mChanged, carddav_delete_object_by_uri, OK, RT);
if (OK == res) {
kdDebug() << "pushing changed objects (add)";
- res = pushObjects(mChanged, carddav_add_object, OK, RT);
+ if (getUseURI() == false)
+ res = pushObjects(mChanged, carddav_add_object, OK, RT);
+ else
+ res = pushObjects(mChanged, carddav_add_object, OK, RT);
if (OK == res) {
kdDebug() << "pushing deleted objects";
- res = pushObjects(mDeleted, carddav_delete_object, OK, RT);
+ if (getUseURI() == false)
+ res = pushObjects(mDeleted, carddav_delete_object, OK, RT);
+ else
+ res = pushObjects(mDeleted, carddav_delete_object_by_uri, OK, RT);
}
}
#endif // if USE_CARDDAV_MODIFY