Commit b98d8f2a authored by kende's avatar kende

[buteo-sync-plugins-social] Support for multiple users. Fixes JB#47618.

Removes hardcoded user home directory.
parent a90e5c55
This diff is collapsed.
......@@ -22,7 +22,6 @@ QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
HEADERS += $$PWD/common/socialdnetworkaccessmanager_p.h
!contains(DEFINES, 'SOCIALD_TEST_DEFINE') {
SOURCES += $$PWD/common/socialdnetworkaccessmanager_p.cpp
DEFINES += 'PRIVILEGED_DATA_DIR=\'\"/home/nemo/.local/share/system/privileged/\"\''
}
DEFINES += 'SYNC_DATABASE_DIR=\'\"Sync\"\''
......
......@@ -37,4 +37,8 @@
#include <PluginCbInterface.h>
#include <LogMacros.h>
#ifndef SOCIALD_TEST_DEFINE
#define PRIVILEGED_DATA_DIR QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QLatin1String("/.local/share/system/privileged")
#endif
#endif // SOCIALD_BUTEOSYNCFW_P_H
......@@ -92,7 +92,7 @@ void DropboxBackupSyncAdaptor::beginSync(int accountId, const QString &accessTok
}
if (backupRestoreOptions.localDirPath.isEmpty()) {
backupRestoreOptions.localDirPath = QString::fromLatin1("%1/Backups/").arg(QString::fromLatin1(PRIVILEGED_DATA_DIR));
backupRestoreOptions.localDirPath = QString::fromLatin1("%1/Backups/").arg(PRIVILEGED_DATA_DIR);
}
// create local directory if it doesn't exist
QDir localDir;
......
......@@ -62,7 +62,7 @@ namespace {
bool ghostEventCleanupPerformed()
{
QString settingsFileName = QString::fromLatin1("%1/%2/fbcal.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
return settingsFile.value(QString::fromLatin1("cleaned"), QVariant::fromValue<bool>(false)).toBool();
......@@ -71,7 +71,7 @@ namespace {
void setGhostEventCleanupPerformed()
{
QString settingsFileName = QString::fromLatin1("%1/%2/fbcal.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
settingsFile.setValue(QString::fromLatin1("cleaned"), QVariant::fromValue<bool>(true));
......
......@@ -58,7 +58,7 @@
#define SOCIALD_FACEBOOK_CONTACTS_ID_PREFIX QLatin1String("facebook-contacts-")
#define SOCIALD_FACEBOOK_CONTACTS_GROUPNAME QLatin1String("sociald-sync-facebook-contacts")
#define SOCIALD_FACEBOOK_CONTACTS_SYNCTARGET QLatin1String("facebook")
#define SOCIALD_FACEBOOK_CONTACTS_AVATAR_FILENAME(fbFriendId, avatarType) QString("%1/%2/%3-%4.jpg").arg(QLatin1String(PRIVILEGED_DATA_DIR)).arg(SocialNetworkSyncAdaptor::dataTypeName(m_dataType)).arg(fbFriendId).arg(avatarType)
#define SOCIALD_FACEBOOK_CONTACTS_AVATAR_FILENAME(fbFriendId, avatarType) QString("%1/%2/%3-%4.jpg").arg(PRIVILEGED_DATA_DIR).arg(SocialNetworkSyncAdaptor::dataTypeName(m_dataType)).arg(fbFriendId).arg(avatarType)
#define SOCIALD_FACEBOOK_CONTACTS_AVATAR_BATCHSIZE 20
static const char *WHICH_FIELDS = "name,first_name,middle_name,last_name,link,website,"\
......
......@@ -90,7 +90,7 @@ void traceDumpStr(const QString &str)
bool ghostEventCleanupPerformed()
{
QString settingsFileName = QString::fromLatin1("%1/%2/gcal.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
return settingsFile.value(QString::fromLatin1("cleaned"), QVariant::fromValue<bool>(false)).toBool();
......@@ -98,7 +98,7 @@ bool ghostEventCleanupPerformed()
void setGhostEventCleanupPerformed()
{
QString settingsFileName = QString::fromLatin1("%1/%2/gcal.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
settingsFile.setValue(QString::fromLatin1("cleaned"), QVariant::fromValue<bool>(true));
......@@ -899,7 +899,7 @@ bool localModificationIsReal(const QJsonObject &local, const QJsonObject &remote
bool wasLastSyncSuccessful(int accountId, bool *needCleanSync)
{
QString settingsFileName = QString::fromLatin1("%1/%2/gcal.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
if (!QFile::exists(settingsFileName)) {
SOCIALD_LOG_DEBUG("gcal.ini settings file does not exist, triggering clean sync");
......@@ -925,7 +925,7 @@ bool wasLastSyncSuccessful(int accountId, bool *needCleanSync)
void setLastSyncSuccessful(QList<int> accountIds)
{
QString settingsFileName = QString::fromLatin1("%1/%2/gcal.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
Q_FOREACH(int accountId, accountIds) {
......@@ -938,7 +938,7 @@ void setLastSyncSuccessful(QList<int> accountIds)
void setLastSyncRequiresCleanSync(QList<int> accountIds)
{
QString settingsFileName = QString::fromLatin1("%1/%2/gcal.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
Q_FOREACH(int accountId, accountIds) {
......
......@@ -92,7 +92,7 @@ void GoogleTwoWayContactSyncAdaptor::sync(const QString &dataTypeString, int acc
{
// check if we need to perform a complete clean sync
QString settingsFileName = QString::fromLatin1("%1/%2/gcontacts.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
bool doneCleanSync = settingsFile.value(QString::fromLatin1("%1-cleansync").arg(accountId), QVariant::fromValue<bool>(false)).toBool();
......
......@@ -127,7 +127,7 @@ void OneDriveBackupSyncAdaptor::beginSync(int accountId, const QString &accessTo
}
if (backupRestoreOptions.localDirPath.isEmpty()) {
backupRestoreOptions.localDirPath = QString::fromLatin1("%1/Backups/").arg(QString::fromLatin1(PRIVILEGED_DATA_DIR));
backupRestoreOptions.localDirPath = QString::fromLatin1("%1/Backups/").arg(PRIVILEGED_DATA_DIR);
}
// create local directory if it doesn't exist
QDir localDir;
......
......@@ -484,7 +484,7 @@ QDateTime VKPostSyncAdaptor::lastSuccessfulSyncTime(int accountId)
{
QDateTime result;
QString settingsFileName = QString::fromLatin1("%1/%2/vkposts.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
uint timestamp = settingsFile.value(QString::fromLatin1("%1-last-successful-sync-time").arg(accountId)).toUInt();
......@@ -498,7 +498,7 @@ void VKPostSyncAdaptor::setLastSuccessfulSyncTime(int accountId)
{
QDateTime currentTime = QDateTime::currentDateTime().toUTC();
QString settingsFileName = QString::fromLatin1("%1/%2/vkposts.ini")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QSettings settingsFile(settingsFileName, QSettings::IniFormat);
settingsFile.setValue(QString::fromLatin1("%1-last-successful-sync-time").arg(accountId),
......
......@@ -38,7 +38,7 @@ namespace {
bool touchTimestampFile()
{
static const QString timestampFileName = QString::fromLatin1("%1/%2/vktimestamp")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QByteArray tsfnba = timestampFileName.toUtf8();
......@@ -59,7 +59,7 @@ namespace {
qint64 readTimestampFile()
{
static const QString timestampFileName = QString::fromLatin1("%1/%2/vktimestamp")
.arg(QString::fromLatin1(PRIVILEGED_DATA_DIR))
.arg(PRIVILEGED_DATA_DIR)
.arg(QString::fromLatin1(SYNC_DATABASE_DIR));
QByteArray tsfnba = timestampFileName.toUtf8();
......
DEFINES += SOCIALD_TEST_DEFINE
DEFINES += 'PRIVILEGED_DATA_DIR=\'\"/tmp/\"\''
DEFINES += 'PRIVILEGED_DATA_DIR=\'\"/tmp\"\''
DEFINES += SOCIALD_USE_QTPIM
include($$PWD/../src/common.pri)
......
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