@@ -1,9 +1,6 @@
11/*
22 * Copyright (C) 2013 Canonical, Ltd.
33 *
4− * Authors:
5− * Michał Sawicz <michal.sawicz@canonical.com>
6− *
74 * This program is free software; you can redistribute it and/or modify
85 * it under the terms of the GNU General Public License as published by
96 * the Free Software Foundation; version 3.
@@ -15,6 +12,8 @@
1512 *
1613 * You should have received a copy of the GNU General Public License
1714 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ *
16+ * Author: Nick Dedekind <nick.dedekind@canonical.com>
1817 */
1918
2019#include "indicatorsmanager.h"
@@ -29,9 +28,9 @@ class IndicatorsManager::IndicatorData
2928{
3029public:
3130 IndicatorData(const QString& name, const QFileInfo& fileInfo)
32− : m_name(name)
33− , m_fileInfo(fileInfo)
34− , m_verified (true)
31+ : m_name(name)
32+ , m_fileInfo(fileInfo)
33+ , m_verified (true)
3534 {}
3635
3736 QString m_name;
@@ -42,8 +41,8 @@ public:
4241};
4342
4443IndicatorsManager::IndicatorsManager(QObject* parent)
45−: QObject(parent)
46−, m_loaded(false)
44+ : QObject(parent)
45+ , m_loaded(false)
4746{
4847}
4948
@@ -68,7 +67,7 @@ void IndicatorsManager::load()
6867 // watch folder for changes.
6968 m_fsWatcher->addPath(indicator_path);
7069
71− load(indicator_dir);
70+ loadDir(indicator_dir);
7271 }
7372 }
7473
@@ -77,9 +76,9 @@ void IndicatorsManager::load()
7776 setLoaded(true);
7877}
7978
80−void IndicatorsManager::onDirectoryChanged(const QString& direcory)
79+void IndicatorsManager::onDirectoryChanged(const QString& directory)
8180{
82− load(QDir(direcory));
81+ loadDir(QDir(directory));
8382}
8483
8584void IndicatorsManager::onFileChanged(const QString& file)
@@ -87,29 +86,29 @@ void IndicatorsManager::onFileChanged(const QString& file)
8786 QFileInfo file_info(file);
8887 if (!file_info.exists())
8988 {
90− unload(file_info);
89+ unloadFile(file_info);
9190 return;
9291 }
9392 else
9493 {
95− load(QFileInfo(file));
94+ loadFile(QFileInfo(file));
9695 }
9796}
9897
99−void IndicatorsManager::load(const QDir& dir)
98+void IndicatorsManager::loadDir(const QDir& dir)
10099{
101100 startVerify(dir.canonicalPath());
102101
103102 QFileInfoList indicator_files = dir.entryInfoList(QStringList(), QDir::Files|QDir::NoDotAndDotDot);
104103 Q_FOREACH(const QFileInfo& indicator_file, indicator_files)
105104 {
106− load(indicator_file);
105+ loadFile(indicator_file);
107106 }
108107
109108 endVerify(dir.canonicalPath());
110109}
111110
112−void IndicatorsManager::load(const QFileInfo& file_info)
111+void IndicatorsManager::loadFile(const QFileInfo& file_info)
113112{
114113 QSettings indicator_settings(file_info.absoluteFilePath(), QSettings::IniFormat, this);
115114 QString name = indicator_settings.value("Indicator Service/Name").toString();
@@ -128,18 +127,24 @@ void IndicatorsManager::load(const QFileInfo& file_info)
128127
129128 // if we've already got this indicator, we need to make sure we're not overwriting data which is
130129 // from a lower priority standard path
131− QStringList xdgLocations = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
130+ QStringList xdgLocations = shellDataDirs();
132131 for (int i = 0; i < xdgLocations.size(); i++)
133132 {
134133 QString indicatorDir = QDir::cleanPath(xdgLocations[i] + "/unity/indicators");
135134
136135 if (newFileInfoDir == indicatorDir)
137− file_info_location = i;
136+ {
137+ file_info_location = i;
138+ }
138139 if (currentDataDir == indicatorDir)
140+ {
139141 current_data_location = i;
142+ }
140143
141144 if (file_info_location != -1 && current_data_location != -1)
145+ {
142146 break;
147+ }
143148 }
144149
145150 // file location is higher (or of equal) priority. overwrite.
@@ -174,7 +179,7 @@ void IndicatorsManager::unload()
174179 setLoaded(false);
175180}
176181
177−void IndicatorsManager::unload(const QFileInfo& file)
182+void IndicatorsManager::unloadFile(const QFileInfo& file)
178183{
179184 QMutableHashIterator<QString, IndicatorData*> iter(m_indicatorsData);
180185 while(iter.hasNext())
@@ -214,7 +219,9 @@ void IndicatorsManager::startVerify(const QString& path)
214219 iter.next();
215220 IndicatorData* data = iter.value();
216221 if (data->m_fileInfo.canonicalPath() == path)
222+ {
217223 data->m_verified = false;
224+ }
218225 }
219226}
220227
@@ -249,7 +256,9 @@ Indicator::Ptr IndicatorsManager::indicator(const QString& indicator)
249256
250257 IndicatorData *data = m_indicatorsData[indicator];
251258 if (data->m_indicator)
259+ {
252260 return data->m_indicator;
261+ }
253262
254263 Indicator::Ptr plugin(new Indicator(this));
255264 data->m_indicator = plugin;