Commit 2cf8a6d3 authored by Pekka Vuorela's avatar Pekka Vuorela

Read settings only once

parent 11c3fe71
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <QDBusMessage> #include <QDBusMessage>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QTimer> #include <QTimer>
#include <QSettings>
#include <notification.h> #include <notification.h>
...@@ -66,7 +67,7 @@ TransferEngineSignalHandler * TransferEngineSignalHandler::instance() ...@@ -66,7 +67,7 @@ TransferEngineSignalHandler * TransferEngineSignalHandler::instance()
void TransferEngineSignalHandler::signalHandler(int signal) void TransferEngineSignalHandler::signalHandler(int signal)
{ {
if(signal == SIGUSR1) { if (signal == SIGUSR1) {
QMetaObject::invokeMethod(TransferEngineSignalHandler::instance(), QMetaObject::invokeMethod(TransferEngineSignalHandler::instance(),
"exitSafely", "exitSafely",
Qt::AutoConnection); Qt::AutoConnection);
...@@ -145,7 +146,6 @@ void ClientActivityMonitor::checkActivity() ...@@ -145,7 +146,6 @@ void ClientActivityMonitor::checkActivity()
TransferEnginePrivate::TransferEnginePrivate(TransferEngine *parent): TransferEnginePrivate::TransferEnginePrivate(TransferEngine *parent):
m_notificationsEnabled(true), m_notificationsEnabled(true),
m_settings(CONFIG_PATH, QSettings::IniFormat),
q_ptr(parent) q_ptr(parent)
{ {
m_fileWatcherTimer = new QTimer(this); m_fileWatcherTimer = new QTimer(this);
...@@ -175,6 +175,24 @@ TransferEnginePrivate::TransferEnginePrivate(TransferEngine *parent): ...@@ -175,6 +175,24 @@ TransferEnginePrivate::TransferEnginePrivate(TransferEngine *parent):
// Monitor expired transfers and cleanup them if required // Monitor expired transfers and cleanup them if required
m_activityMonitor = new ClientActivityMonitor(this); m_activityMonitor = new ClientActivityMonitor(this);
connect(m_activityMonitor, SIGNAL(transfersExpired(QList<int>)), this, SLOT(cleanupExpiredTransfers(QList<int>))); connect(m_activityMonitor, SIGNAL(transfersExpired(QList<int>)), this, SLOT(cleanupExpiredTransfers(QList<int>)));
QSettings settings(CONFIG_PATH, QSettings::IniFormat);
if (settings.status() != QSettings::NoError) {
qWarning() << Q_FUNC_INFO << "Failed to read settings!" << settings.status();
} else {
settings.beginGroup("transfers");
const QString service = settings.value("service").toString();
const QString path = settings.value("path").toString();
const QString iface = settings.value("interface").toString();
const QString method = settings.value("method").toString();
settings.endGroup();
if (!service.isEmpty() && !path.isEmpty() && !iface.isEmpty() && !method.isEmpty()) {
m_defaultActions << Notification::remoteAction("default", "", service, path, iface, method)
<< Notification::remoteAction("app", "", service, path, iface, method);
}
}
} }
void TransferEnginePrivate::pluginDirChanged() void TransferEnginePrivate::pluginDirChanged()
...@@ -429,20 +447,8 @@ void TransferEnginePrivate::sendNotification(TransferEngineData::TransferType ty ...@@ -429,20 +447,8 @@ void TransferEnginePrivate::sendNotification(TransferEngineData::TransferType ty
notification.setReplacesId(notificationId); notification.setReplacesId(notificationId);
} }
if (m_settings.status() != QSettings::NoError) { if (!m_defaultActions.isEmpty()) {
qWarning() << Q_FUNC_INFO << "Failed to read settings!" << m_settings.status(); notification.setRemoteActions(m_defaultActions);
} else {
m_settings.beginGroup("transfers");
const QString service = m_settings.value("service").toString();
const QString path = m_settings.value("path").toString();
const QString iface = m_settings.value("interface").toString();
const QString method = m_settings.value("method").toString();
m_settings.endGroup();
if (!service.isEmpty() && !path.isEmpty() && !iface.isEmpty() && !method.isEmpty()) {
notification.setRemoteActions(QVariantList() << Notification::remoteAction("default", "", service, path, iface, method)
<< Notification::remoteAction("app", "", service, path, iface, method));
}
} }
//: Group name for notifications of successful transfers //: Group name for notifications of successful transfers
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <QObject> #include <QObject>
#include <QMap> #include <QMap>
#include <QSettings> #include <QVariantList>
#include "mediatransferinterface.h" #include "mediatransferinterface.h"
#include "transfermethodinfo.h" #include "transfermethodinfo.h"
...@@ -141,9 +141,9 @@ private: ...@@ -141,9 +141,9 @@ private:
QFileSystemWatcher *m_fileWatcher; QFileSystemWatcher *m_fileWatcher;
QTimer *m_fileWatcherTimer; QTimer *m_fileWatcherTimer;
QTimer *m_delayedExitTimer; QTimer *m_delayedExitTimer;
QSettings m_settings;
ClientActivityMonitor *m_activityMonitor; ClientActivityMonitor *m_activityMonitor;
TransferEngine *q_ptr; TransferEngine *q_ptr;
QVariantList m_defaultActions;
Q_DECLARE_PUBLIC(TransferEngine) Q_DECLARE_PUBLIC(TransferEngine)
}; };
......
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