aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2017-12-01 23:55:00 +0100
committerMontel Laurent <[email protected]>2017-12-01 23:55:00 +0100
commitcd2c07972dbd4f822f96e2b8eeeb51841bc7340c (patch)
tree03442402d6b815c9647bab5864219ebd4c1b0ed1
parentdc314b5e1f89d422c040c6fa64a15f5ef58b0f04 (diff)
Use QVector
-rw-r--r--CMakeLists.txt4
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Messages.sh2
-rw-r--r--src/common/davcollectionmodifyjob.cpp1
-rw-r--r--src/common/davcollectionsfetchjob.cpp2
-rw-r--r--src/common/daverror.cpp55
-rw-r--r--src/common/davjobbase.cpp8
-rw-r--r--src/common/davprincipalsearchjob.cpp2
-rw-r--r--src/common/davprincipalsearchjob.h5
9 files changed, 41 insertions, 40 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e72e420..8ea4aed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.0)
-set(PIM_VERSION "5.7.40")
+set(PIM_VERSION "5.7.41")
project(libkdav VERSION ${PIM_VERSION})
@@ -30,7 +30,7 @@ set(QT_REQUIRED_VERSION "5.8.0")
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Core Gui XmlPatterns Test)
-find_package(KF5 ${KF5_VERSION} REQUIRED CoreAddons KIO)
+find_package(KF5 ${KF5_VERSION} REQUIRED CoreAddons KIO I18n)
# setup lib
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 79ccc93..8ad0760 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,3 +1,4 @@
+add_definitions(-DTRANSLATION_DOMAIN=\"libkdav\")
include_directories(
common/
protocols/
@@ -111,6 +112,7 @@ PRIVATE
Qt5::Gui
Qt5::XmlPatterns
KF5::KIOCore
+ KF5::I18n
)
set_target_properties(KPimKDAV PROPERTIES
diff --git a/src/Messages.sh b/src/Messages.sh
new file mode 100644
index 0000000..ee93862
--- /dev/null
+++ b/src/Messages.sh
@@ -0,0 +1,2 @@
+#! /bin/sh
+$XGETTEXT `find . -name "*.cpp" -o -name "*.h" | grep -v '/tests/'` -o $podir/libkdav.pot
diff --git a/src/common/davcollectionmodifyjob.cpp b/src/common/davcollectionmodifyjob.cpp
index b23d1b9..3f3c9eb 100644
--- a/src/common/davcollectionmodifyjob.cpp
+++ b/src/common/davcollectionmodifyjob.cpp
@@ -125,7 +125,6 @@ void DavCollectionModifyJob::davJobFinished(KJob *job)
QDomElement responseElement = Utils::firstChildElementNS(response.documentElement(), QStringLiteral("DAV:"), QStringLiteral("response"));
bool hasError = false;
- QString errorText;
// parse all propstats answers to get the eventual errors
const QDomNodeList propstats = responseElement.elementsByTagNameNS(QStringLiteral("DAV:"), QStringLiteral("propstat"));
diff --git a/src/common/davcollectionsfetchjob.cpp b/src/common/davcollectionsfetchjob.cpp
index a8f18e0..d142f19 100644
--- a/src/common/davcollectionsfetchjob.cpp
+++ b/src/common/davcollectionsfetchjob.cpp
@@ -101,7 +101,7 @@ void DavCollectionsFetchJob::principalFetchFinished(KJob *job)
return;
}
- foreach (const QString &homeSet, homeSets) {
+ for (const QString &homeSet : homeSets) {
QUrl url = mUrl.url();
if (homeSet.startsWith(QLatin1Char('/'))) {
diff --git a/src/common/daverror.cpp b/src/common/daverror.cpp
index cfce548..2e5591a 100644
--- a/src/common/daverror.cpp
+++ b/src/common/daverror.cpp
@@ -17,6 +17,7 @@
*/
#include "daverror.h"
+#include <KLocalizedString>
#include <KIO/Global>
#include <KIO/Job>
@@ -49,13 +50,11 @@ QString Error::internalErrorText() const
return mErrorText;
}
-
int Error::jobErrorCode() const
{
return mJobErrorCode;
}
-
int Error::responseCode() const
{
return mResponseCode;
@@ -82,80 +81,80 @@ QString Error::errorText() const
case ERR_PROBLEM_WITH_REQUEST: {
// User-side error
if (mResponseCode == 401) {
- err = QStringLiteral("Invalid username/password");
+ err = i18n("Invalid username/password");
} else if (mResponseCode == 403) {
- err = QStringLiteral("Access forbidden");
+ err = i18n("Access forbidden");
} else if (mResponseCode == 404) {
- err = QStringLiteral("Resource not found");
+ err = i18n("Resource not found");
} else {
- err = QStringLiteral("HTTP error");
+ err = i18n("HTTP error");
}
- result = QStringLiteral("There was a problem with the request.\n"
- "%1 (%2).").arg(err).arg(mResponseCode);
+ result = i18n("There was a problem with the request.\n"
+ "%1 (%2).", err, mResponseCode);
break;
}
case ERR_NO_MULTIGET: {
- result = QStringLiteral("Protocol for the collection does not support MULTIGET");
+ result = i18n("Protocol for the collection does not support MULTIGET");
break;
}
case ERR_SERVER_UNRECOVERABLE: {
- result = QStringLiteral("The server encountered an error that prevented it from completing your request: %1 (%2)").arg(err).arg(mResponseCode);
+ result = i18n("The server encountered an error that prevented it from completing your request: %1 (%2)", err, mResponseCode);
break;
}
case ERR_COLLECTIONDELETE: {
- result = QStringLiteral("There was a problem with the request. The collection has not been deleted from the server.\n"
- "%1 (%2).").arg(err).arg(mResponseCode);
+ result = i18n("There was a problem with the request. The collection has not been deleted from the server.\n"
+ "%1 (%2).", err, mResponseCode);
break;
}
case ERR_COLLECTIONFETCH: {
- result = QStringLiteral("Invalid responses from backend");
+ result = i18n("Invalid responses from backend");
break;
}
case ERR_COLLECTIONFETCH_XQUERY_SETFOCUS: {
- result = QStringLiteral("Error setting focus for XQuery");
+ result = i18n("Error setting focus for XQuery");
break;
}
case ERR_COLLECTIONFETCH_XQUERY_INVALID: {
- result = QStringLiteral("Invalid XQuery submitted by DAV implementation");
+ result = i18n("Invalid XQuery submitted by DAV implementation");
break;
}
case ERR_COLLECTIONMODIFY: {
- result = QStringLiteral("There was a problem with the request. The collection has not been modified on the server.\n"
- "%1 (%2).").arg(err).arg(mResponseCode);
+ result = i18n("There was a problem with the request. The collection has not been modified on the server.\n"
+ "%1 (%2).", err, mResponseCode);
break;
}
case ERR_COLLECTIONMODIFY_NO_PROPERITES: {
- result = QStringLiteral("No properties to change or remove");
+ result = i18n("No properties to change or remove");
break;
}
case ERR_COLLECTIONMODIFY_RESPONSE: {
- result = QStringLiteral("There was an error when modifying the properties");
+ result = i18n("There was an error when modifying the properties");
if (!mErrorText.isEmpty()) {
- result.append(QStringLiteral("\nThe server returned more information:\n%1").arg(mErrorText));
+ result.append(i18n("\nThe server returned more information:\n%1", mErrorText));
}
break;
}
case ERR_ITEMCREATE: {
- result = QStringLiteral("There was a problem with the request. The item has not been created on the server.\n"
- "%1 (%2).").arg(err).arg(mResponseCode);
+ result = i18n("There was a problem with the request. The item has not been created on the server.\n"
+ "%1 (%2).", err, mResponseCode);
break;
}
case ERR_ITEMDELETE: {
- result = QStringLiteral("There was a problem with the request. The item has not been deleted from the server.\n"
- "%1 (%2).").arg(err).arg(mResponseCode);
+ result = i18n("There was a problem with the request. The item has not been deleted from the server.\n"
+ "%1 (%2).", err, mResponseCode);
break;
}
case ERR_ITEMMODIFY: {
- result = QStringLiteral("There was a problem with the request. The item was not modified on the server.\n"
- "%1 (%2).").arg(err).arg(mResponseCode);
+ result = i18n("There was a problem with the request. The item was not modified on the server.\n"
+ "%1 (%2).", err, mResponseCode);
break;
}
case ERR_ITEMLIST: {
- result = QStringLiteral("There was a problem with the request.");
+ result = i18n("There was a problem with the request.");
break;
};
case ERR_ITEMLIST_NOMIMETYPE: {
- result = QStringLiteral("There was a problem with the request. The requested mimetypes are not supported.");
+ result = i18n("There was a problem with the request. The requested mimetypes are not supported.");
break;
}
case NO_ERR:
diff --git a/src/common/davjobbase.cpp b/src/common/davjobbase.cpp
index 3dcca7f..bffc789 100644
--- a/src/common/davjobbase.cpp
+++ b/src/common/davjobbase.cpp
@@ -26,14 +26,12 @@ class DavJobBasePrivate {
public:
DavJobBasePrivate();
- int mLatestResponseCode;
- int mJobErrorCode;
+ int mLatestResponseCode = 0;
+ int mJobErrorCode = 0;
QString mInternalErrorText;
};
DavJobBasePrivate::DavJobBasePrivate()
- : mLatestResponseCode(0)
- , mJobErrorCode(0)
{
}
@@ -68,7 +66,7 @@ bool DavJobBase::canRetryLater() const
// Payment required
ret = true;
} else if (latestResponseCode() == 407) {
- // Proxy authentication required
+ // Proxy authentication required
ret = true;
} else if (latestResponseCode() == 408) {
// Request timeout
diff --git a/src/common/davprincipalsearchjob.cpp b/src/common/davprincipalsearchjob.cpp
index e4895ee..2432f9d 100644
--- a/src/common/davprincipalsearchjob.cpp
+++ b/src/common/davprincipalsearchjob.cpp
@@ -312,7 +312,7 @@ void DavPrincipalSearchJob::principalPropertySearchFinished(KJob *job)
}
}
-QList< DavPrincipalSearchJob::Result > DavPrincipalSearchJob::results() const
+QVector< DavPrincipalSearchJob::Result > DavPrincipalSearchJob::results() const
{
return mResults;
}
diff --git a/src/common/davprincipalsearchjob.h b/src/common/davprincipalsearchjob.h
index b0260b6..ed5cb10 100644
--- a/src/common/davprincipalsearchjob.h
+++ b/src/common/davprincipalsearchjob.h
@@ -98,7 +98,7 @@ public:
/**
* Get the job results.
*/
- QList<Result> results() const;
+ QVector<Result> results() const;
private:
void principalCollectionSetSearchFinished(KJob *job);
@@ -112,9 +112,10 @@ private:
int mPrincipalPropertySearchSubJobCount;
bool mPrincipalPropertySearchSubJobSuccessful;
QList< QPair<QString, QString> > mFetchProperties;
- QList<Result> mResults;
+ QVector<Result> mResults;
};
}
+Q_DECLARE_TYPEINFO(KDAV::DavPrincipalSearchJob::Result, Q_MOVABLE_TYPE);
#endif