Commit 1fc4b614 authored by Sergio Martins's avatar Sergio Martins

Build with QT_NO_CAST_FROM_ASCII, to prevent temporary QStrings

parent c84ccdc8
......@@ -132,6 +132,8 @@ find_package(KF5AkonadiSocialUtils ${AKONADISOCIALUTIL_LIB_VERSION} CONFIG REQUI
option(KDEPIM_RUN_ISOLATED_TESTS "Run the isolated tests." FALSE)
add_definitions( -DQT_NO_CAST_FROM_ASCII )
add_definitions( -DQT_NO_CAST_TO_ASCII )
add_subdirectory(resources)
add_subdirectory(agents)
......
......@@ -55,9 +55,6 @@ endmacro( akonadi_add_resourcetest )
#add_definitions( -DQT_NO_CAST_FROM_ASCII )
#add_definitions( -DQT_NO_CAST_TO_ASCII )
add_subdirectory( akonotes )
add_subdirectory( kalarm )
add_subdirectory( contacts )
......
......@@ -102,7 +102,7 @@ void DavCollectionsFetchJob::principalFetchFinished(KJob *job)
if (homeSet.startsWith(QLatin1Char('/'))) {
// homeSet is only a path, use request url to complete
url.setPath(homeSet.toLatin1(), QUrl::TolerantMode);
url.setPath(homeSet, QUrl::TolerantMode);
} else {
// homeSet is a complete url
QUrl tmpUrl(homeSet);
......@@ -266,7 +266,7 @@ void DavCollectionsFetchJob::collectionsFetchFinished(KJob *job)
url.setUserInfo(QString());
if (href.startsWith(QLatin1Char('/'))) {
// href is only a path, use request url to complete
url.setPath(href.toLatin1(), QUrl::TolerantMode);
url.setPath(href, QUrl::TolerantMode);
} else {
// href is a complete url
url = QUrl::fromUserInput(href);
......
......@@ -92,7 +92,7 @@ void DavItemCreateJob::davJobFinished(KJob *job)
url = storedJob->url();
} else if (location.startsWith(QLatin1Char('/'))) {
url = storedJob->url();
url.setPath(location.toLatin1(), QUrl::TolerantMode);
url.setPath(location, QUrl::TolerantMode);
} else {
url = QUrl::fromUserInput(location);
}
......
......@@ -106,7 +106,7 @@ void DavItemModifyJob::davJobFinished(KJob *job)
url = storedJob->url();
} else if (location.startsWith(QLatin1Char('/'))) {
url = storedJob->url();
url.setPath(location.toLatin1(), QUrl::TolerantMode);
url.setPath(location, QUrl::TolerantMode);
} else {
url = QUrl::fromUserInput(location);
}
......
......@@ -116,7 +116,7 @@ void DavItemsFetchJob::davJobFinished(KJob *job)
url.setUserInfo(QString());
if (href.startsWith(QLatin1Char('/'))) {
// href is only a path, use request url to complete
url.setPath(href.toLatin1(), QUrl::TolerantMode);
url.setPath(href, QUrl::TolerantMode);
} else {
// href is a complete url
url = QUrl::fromUserInput(href);
......
......@@ -179,7 +179,7 @@ void DavItemsListJob::davJobFinished(KJob *job)
url.setUserInfo(QString());
if (href.startsWith(QLatin1Char('/'))) {
// href is only a path, use request url to complete
url.setPath(href.toLatin1(), QUrl::TolerantMode);
url.setPath(href, QUrl::TolerantMode);
} else {
// href is a complete url
url = QUrl::fromUserInput(href);
......
......@@ -208,7 +208,7 @@ void DavPrincipalHomeSetsFetchJob::davJobFinished(KJob *job)
if (nextRoundHref.startsWith(QLatin1Char('/'))) {
// nextRoundHref is only a path, use request url to complete
nextRoundUrl.setPath(nextRoundHref.toLatin1(), QUrl::TolerantMode);
nextRoundUrl.setPath(nextRoundHref, QUrl::TolerantMode);
} else {
// href is a complete url
nextRoundUrl = QUrl::fromUserInput(nextRoundHref);
......
......@@ -175,7 +175,7 @@ void DavPrincipalSearchJob::principalCollectionSetSearchFinished(KJob *job)
QUrl url = mUrl.url();
if (href.startsWith(QLatin1Char('/'))) {
// href is only a path, use request url to complete
url.setPath(href.toLatin1(), QUrl::TolerantMode);
url.setPath(href, QUrl::TolerantMode);
} else {
// href is a complete url
QUrl tmpUrl(href);
......
......@@ -109,7 +109,7 @@ void DavFreeBusyHandler::onPrincipalSearchJobFinished(KJob *job)
QUrl url(davJob->property("url").toString());
if (result.value.startsWith(QLatin1Char('/'))) {
// href is only a path, use request url to complete
url.setPath(result.value.toLatin1(), QUrl::TolerantMode);
url.setPath(result.value, QUrl::TolerantMode);
} else {
// href is a complete url
url = QUrl::fromUserInput(result.value);
......
......@@ -381,8 +381,8 @@ void DavGroupwareResource::itemChanged(const Akonadi::Item &item, const QSet<QBy
}
QString ridBase = item.remoteId();
if (ridBase.contains(QChar('#'))) {
ridBase.truncate(ridBase.indexOf(QChar('#')));
if (ridBase.contains(QLatin1Char('#'))) {
ridBase.truncate(ridBase.indexOf(QLatin1Char('#')));
}
EtagCache *cache = mEtagCaches.value(collection.remoteId());
......@@ -423,8 +423,8 @@ void DavGroupwareResource::doItemChange(const Akonadi::Item &item, const Akonadi
}
QString url = item.remoteId();
if (url.contains(QChar('#'))) {
url.truncate(url.indexOf(QChar('#')));
if (url.contains(QLatin1Char('#'))) {
url.truncate(url.indexOf(QLatin1Char('#')));
}
const DavUtils::DavUrl davUrl = Settings::self()->davUrlFromCollectionUrl(item.parentCollection().remoteId(), url);
......@@ -454,10 +454,10 @@ void DavGroupwareResource::itemRemoved(const Akonadi::Item &item)
}
QString ridBase = item.remoteId();
if (ridBase.contains(QChar('#'))) {
if (ridBase.contains(QLatin1Char('#'))) {
// A bit tricky: we must remove an incidence contained in a resource
// containing multiple ones.
ridBase.truncate(ridBase.indexOf(QChar('#')));
ridBase.truncate(ridBase.indexOf(QLatin1Char('#')));
EtagCache *cache = mEtagCaches.value(collection.remoteId());
Akonadi::Item::List extraItems;
......@@ -499,7 +499,7 @@ void DavGroupwareResource::onItemRemovalPrepared(KJob *job)
Akonadi::Item mainItem;
Akonadi::Item::List extraItems;
QString ridBase = item.remoteId();
ridBase.truncate(ridBase.indexOf(QChar('#')));
ridBase.truncate(ridBase.indexOf(QLatin1Char('#')));
foreach (const Akonadi::Item &kept, keptItems) {
if (kept.remoteId() == ridBase && extraItems.isEmpty()) {
......@@ -1144,8 +1144,8 @@ void DavGroupwareResource::handleConflict(const Item &lI, const Item::List &loca
DavItem davItem = DavUtils::createDavItem(localItem, collection, localDependentItems);
QString urlStr = localItem.remoteId();
if (urlStr.contains(QChar('#'))) {
urlStr.truncate(urlStr.indexOf(QChar('#')));
if (urlStr.contains(QLatin1Char('#'))) {
urlStr.truncate(urlStr.indexOf(QLatin1Char('#')));
}
davItem.setUrl(urlStr);
const DavUtils::DavUrl davUrl = Settings::self()->davUrlFromCollectionUrl(collection.remoteId(), urlStr);
......
......@@ -156,7 +156,7 @@ void SearchDialog::onSearchJobFinished(KJob *job)
foreach (const DavPrincipalSearchJob::Result &result, results) {
if (result.value.startsWith(QLatin1Char('/'))) {
url.setPath(result.value.toLatin1(), QUrl::TolerantMode);
url.setPath(result.value, QUrl::TolerantMode);
} else {
QUrl tmp(result.value);
tmp.setUserInfo(QString());
......
......@@ -74,7 +74,7 @@ static bool writeToFile(const QString &fileName, Incidence::Ptr &incidence)
const bool success = fileStorage->save();
if (!success) {
qCritical() << "Failed to save calendar to file " + fileName;
qCritical() << QStringLiteral("Failed to save calendar to file ") + fileName;
}
return success;
......@@ -301,7 +301,7 @@ void ICalDirResource::initializeICalDirectory() const
}
// check whether warning file is in place...
QFile file(dir.absolutePath() + QDir::separator() + "WARNING_README.txt");
QFile file(dir.absolutePath() + QDir::separator() + QStringLiteral("WARNING_README.txt"));
if (!file.exists()) {
// ... if not, create it
file.open(QIODevice::WriteOnly);
......
......@@ -13,6 +13,8 @@ find_library(KIMAPTEST_LIBRARY NAMES kimaptest)
MESSAGE( STATUS "KIMAPTEST_INCLUDE_DIR :${KIMAPTEST_INCLUDE_DIR}")
MESSAGE( STATUS "KIMAPTEST_LIBRARY :${KIMAPTEST_LIBRARY}")
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
if(KIMAPTEST_INCLUDE_DIR AND KIMAPTEST_LIBRARY)
MACRO(IMAP_RESOURCE_UNIT_TESTS)
FOREACH(_testname ${ARGN})
......
......@@ -55,7 +55,7 @@ QDebug debugStream(int line, const char *file, const char *function)
}
}
debug << QStringLiteral("Trace:%1(%2) %3:").arg(QString::fromLatin1(programName)).arg(unsigned(getpid())).arg(function) /* << file << ":" << line */;
debug << QStringLiteral("Trace:%1(%2) %3:").arg(QString::fromLatin1(programName)).arg(unsigned(getpid())).arg(QLatin1String(function)) /* << file << ":" << line */;
return debug;
}
......@@ -1036,7 +1036,7 @@ void KAlarmDirResource::initializeDirectory() const
}
// Check whether warning file is in place...
QFile file(dirPath + QDir::separator() + warningFile);
QFile file(dirPath + QDir::separator() + QLatin1String(warningFile));
if (!file.exists()) {
// ... if not, create it
file.open(QIODevice::WriteOnly);
......
......@@ -43,13 +43,13 @@ void SyncTest::initTestCase()
void SyncTest::testSync()
{
AgentInstance instance = AgentManager::self()->instance("akonadi_maildir_resource_0");
AgentInstance instance = AgentManager::self()->instance(QStringLiteral("akonadi_maildir_resource_0"));
QVERIFY(instance.isValid());
for (int i = 0; i < 100; i++) {
QDBusInterface *interface = new QDBusInterface(
QString::fromLatin1("org.freedesktop.Akonadi.Resource.%1").arg(instance.identifier()),
"/", "org.freedesktop.Akonadi.Resource", QDBusConnection::sessionBus(), this);
QStringLiteral("/"), QStringLiteral("org.freedesktop.Akonadi.Resource"), QDBusConnection::sessionBus(), this);
QVERIFY(interface->isValid());
QTime t;
t.start();
......
......@@ -336,16 +336,16 @@ void MaildirTest::testMaildirMoveTo()
void MaildirTest::testMaildirFlagsReading()
{
QFile file;
const QStringList markers = QStringList() << "P" << "R" << "S" << "F" << "FPRS";
QDir::setCurrent(m_temp->path() + QLatin1Char('/') + "cur");
const QStringList markers = QStringList() << QStringLiteral("P") << QStringLiteral("R") << QStringLiteral("S") << QStringLiteral("F") << QStringLiteral("FPRS");
QDir::setCurrent(m_temp->path() + QLatin1Char('/') + QStringLiteral("cur"));
for (int i = 0; i < 6 ; i++) {
QString fileName = QLatin1String("testmail-") + QString::number(i);
if (i < 5) {
fileName +=
#ifdef Q_OS_WIN
"!2,"
QLatin1String("!2,")
#else
":2,"
QLatin1String(":2,")
#endif
+ markers[i];
}
......@@ -423,7 +423,7 @@ void MaildirTest::testMaildirFlagsWriting()
const QString newKey = d.changeEntryFlags(entries[0], Akonadi::Item::Flags() << Akonadi::MessageFlags::Seen);
// make sure the new key exists
QCOMPARE(newKey, d.entryList()[0]);
QVERIFY(QFile::exists("cur/" + newKey));
QVERIFY(QFile::exists(QStringLiteral("cur/") + newKey));
// and it's the right file
QCOMPARE(d.readEntry(newKey), QByteArray(testString));
// now check the file name
......@@ -432,5 +432,5 @@ void MaildirTest::testMaildirFlagsWriting()
const QString newKey2 = d.changeEntryFlags(newKey, Akonadi::Item::Flags() << Akonadi::MessageFlags::Seen << Akonadi::MessageFlags::Replied);
// check the file name, and the sorting of markers
QVERIFY(newKey2.endsWith(QLatin1String("2,RS")));
QVERIFY(QFile::exists("cur/" + newKey2));
QVERIFY(QFile::exists(QStringLiteral("cur/") + newKey2));
}
......@@ -105,7 +105,7 @@ MaildirResource::MaildirResource(const QString &id)
// we cannot be sure that a config file is existing
// the MaildirResource will always be build
// look for a resource of this name
QString configFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, id + "rc");
QString configFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, id + QLatin1String("rc"));
// if not present, create it
if (configFile.isEmpty()) {
// check if the resource was used before
......@@ -156,7 +156,7 @@ void MaildirResource::attemptConfigRestoring(KJob *job)
}
// we cannot be sure that a config file is existing
const QString id = identifier();
const QString configFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, id + "rc");
const QString configFile = QStandardPaths::locate(QStandardPaths::ConfigLocation, id + QLatin1String("rc"));
// we test it again, to be sure
if (configFile.isEmpty()) {
// it is still empty, create it
......@@ -526,7 +526,7 @@ void MaildirResource::retrieveCollections()
CachePolicy policy;
policy.setInheritFromParent(false);
policy.setSyncOnDemand(true);
policy.setLocalParts(QStringList() << MessagePart::Envelope);
policy.setLocalParts(QStringList() << QLatin1String(MessagePart::Envelope));
policy.setCacheTimeout(1);
policy.setIntervalCheckTime(-1);
root.setCachePolicy(policy);
......
......@@ -26,6 +26,7 @@ set( testdata_SRCS
../mixedmaildir_debug.cpp
)
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
add_executable(testdatatest testdatatest.cpp ${testdata_SRCS})
add_test(testdatatest testdatatest)
......
......@@ -7,6 +7,7 @@ include_directories(
set( testidxreader_SRCS
testidxreader.cpp
)
remove_definitions(-DQT_NO_CAST_FROM_ASCII)
add_executable( testidxreader ${testidxreader_SRCS} )
add_test( testidxreader testidxreader )
ecm_mark_as_test(testidxreader)
......
......@@ -155,7 +155,7 @@ MessageStatus &KMIndexData::status()
QStringList KMIndexData::tagList() const
{
return mCachedStringParts[KMIndexReader::MsgTagPart].split(',', QString::SkipEmptyParts);
return mCachedStringParts[KMIndexReader::MsgTagPart].split(QLatin1Char(','), QString::SkipEmptyParts);
}
quint64 KMIndexData::uid() const
......@@ -452,7 +452,7 @@ bool KMIndexReader::fromOldIndexString(KMIndexData *msg, const QByteArray &str,
// }
// msg->replyToIdMD5 = str.mid(240, 22).trimmed();
// msg->msgIdMD5 = str.mid(263, 22).trimmed();
msg->mStatus.setStatusFromStr(str);
msg->mStatus.setStatusFromStr(QString::fromUtf8(str));
return true;
}
......
......@@ -894,7 +894,7 @@ static Collection folderToCollection(const OXA::Folder &folder, const Collection
remoteInformation.store(collection);
// set a unique name to make Akonadi happy
collection.setName(folder.title() + '_' + QUuid::createUuid().toString());
collection.setName(folder.title() + QLatin1Char('_') + QUuid::createUuid().toString());
EntityDisplayAttribute *attribute = collection.attribute<EntityDisplayAttribute>(Collection::AddIfMissing);
attribute->setDisplayName(folder.title());
......
......@@ -56,7 +56,7 @@ static void parseMembersAttribute(const QDomElement &element,
}
name = uid;
email = uid + '@' + DavManager::self()->baseUrl().host();
email = uid + QLatin1Char('@') + DavManager::self()->baseUrl().host();
} else {
name = user.name();
email = user.email();
......
......@@ -25,8 +25,8 @@ using namespace OXA;
OXErrors::EditErrorID OXErrors::getEditErrorID(const QString &errorText)
{
int b1Pos = errorText.indexOf('[');
int b2Pos = errorText.indexOf(']');
int b1Pos = errorText.indexOf(QLatin1Char('['));
int b2Pos = errorText.indexOf(QLatin1Char(']'));
QString errorID = errorText.mid(b1Pos + 1, b2Pos - b1Pos - 1);
bool ok;
......
......@@ -37,11 +37,11 @@ QString OXUtils::writeNumber(qlonglong value)
QString OXUtils::writeString(const QString &value)
{
QStringList lines = value.split('\n');
QStringList lines = value.split(QLatin1Char('\n'));
for (int i = 0; i < lines.count(); ++i) {
lines[i].replace('\\', QStringLiteral("\\\\"));
lines[i].replace('"', QStringLiteral("\\\""));
lines[i].replace(QLatin1Char('\\'), QStringLiteral("\\\\"));
lines[i].replace(QLatin1Char('"'), QStringLiteral("\\\""));
}
return lines.join(QStringLiteral("\n"));
......
......@@ -80,7 +80,7 @@ User Users::lookupEmail(const QString &email) const
QString Users::cacheFilePath() const
{
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + "openxchangeresource_" + mIdentifier ;
return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QLatin1Char('/') + QLatin1String("openxchangeresource_") + mIdentifier;
}
void Users::setCurrentUserId(qlonglong id)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment