~ci-train-bot/ubuntu-system-settings/ubuntu-system-settings-ubuntu-zesty-2066

« back to all changes in this revision

Viewing changes to src/utils.cpp

  • Committer: Bileto Bot
  • Author(s): Jonas G. Drange
  • Date: 2016-09-30 13:48:06 UTC
  • mfrom: (1720.3.7 path-fixes)
  • Revision ID: ci-train-bot@canonical.com-20160930134806-tir714ireb8xzaau
uses XDG_DATA_DIRS where applicable to enable USS to find files and folders on snappy-based systems (LP: #1629009)

Approved by: Alberto Mardegan, Ken VanDine, Lukáš Tinkl, system-apps-ci-bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include "debug.h"
23
23
 
24
24
#include <glib.h>
25
 
#include <QUrl>
 
25
#include <QStandardPaths>
 
26
#include <QUrlQuery>
26
27
#include <QUrlQuery>
27
28
 
28
29
 
94
95
 */
95
96
QString Utilities::getDestinationUrl(const QString &source)
96
97
{
 
98
    QString mapFile = QStandardPaths::locate(
 
99
        QStandardPaths::GenericDataLocation,
 
100
        QString("%1/%2").arg(PLUGIN_MANIFEST_DIR).arg("url-map.ini")
 
101
    );
 
102
    if (Q_UNLIKELY(mapFile.isEmpty())) {
 
103
        qWarning() << "could not locate map file";
 
104
        return source;
 
105
    }
 
106
 
97
107
    // This method will be called from multiple threads, and QSettings
98
108
    // is reentrant, meaning each call to this function require its own
99
109
    // settings instance.
100
 
    QSettings map(
101
 
        QString("%1/%2").arg(PLUGIN_MANIFEST_DIR).arg("url-map.ini"),
102
 
        QSettings::IniFormat
103
 
    );
 
110
    QSettings map(mapFile, QSettings::IniFormat);
104
111
    map.sync();
105
112
 
106
113
    // If reading the map failed, return the source unchanged.