summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2015-04-30 16:33:09 +0200
committerTomasz Sterna <tomek@xiaoka.com>2015-04-30 16:33:09 +0200
commit3f64297af4e7a070b4f62ebf3f17105ee6b0a3a8 (patch)
tree0a98d79065fa0bed488583306302beb574910b3b /daemon
parentf212fcc536aab7d51c21857ba80431af4b1ed6cc (diff)
Implemented profile changes on watch (dis)connection3f64297
Diffstat (limited to 'daemon')
-rw-r--r--daemon/manager.cpp36
-rw-r--r--daemon/manager.h3
-rw-r--r--daemon/settings.h9
3 files changed, 9 insertions, 39 deletions
diff --git a/daemon/manager.cpp b/daemon/manager.cpp
index 567316e..262fb4b 100644
--- a/daemon/manager.cpp
+++ b/daemon/manager.cpp
@@ -24,7 +24,6 @@ Manager::Manager(Settings *settings, QObject *parent) :
{
connect(settings, SIGNAL(valueChanged(QString)), SLOT(onSettingChanged(const QString&)));
connect(settings, SIGNAL(valuesChanged()), SLOT(onSettingsChanged()));
- //connect(settings, SIGNAL(silentWhenConnectedChanged(bool)), SLOT(onSilentWhenConnectedChanged(bool)));
// We don't need to handle presence changes, so report them separately and ignore them
QMap<QString, QString> parameters;
@@ -75,8 +74,6 @@ Manager::Manager(Settings *settings, QObject *parent) :
connect(bank, &BankManager::slotsChanged, proxy, &PebbledProxy::AppSlotsChanged);
connect(apps, &AppManager::appsChanged, proxy, &PebbledProxy::AllAppsChanged);
- QString currentProfile = getCurrentProfile();
- defaultProfile = currentProfile.isEmpty() ? "ambience" : currentProfile;
connect(watch, SIGNAL(connectedChanged()), SLOT(applyProfile()));
// Set BT icon for notification
@@ -259,38 +256,11 @@ void Manager::onEmailNotify(const QString &sender, const QString &data,const QSt
watch->sendEmailNotification(sender, data, subject);
}
-QString Manager::getCurrentProfile() const
-{
- QDBusReply<QString> profile = QDBusConnection::sessionBus().call(
- QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "get_profile"));
- if (profile.isValid()) {
- QString currentProfile = profile.value();
- qCDebug(l) << "Got profile" << currentProfile;
- return currentProfile;
- }
-
- qCCritical(l) << profile.error().message();
- return QString();
-}
-
void Manager::applyProfile()
{
- QString currentProfile = getCurrentProfile();
- QString newProfile;
-
- if (settings->property("silentWhenConnected").toBool()) {
- if (watch->isConnected() && currentProfile != "silent") {
- newProfile = "silent";
- defaultProfile = currentProfile;
- }
- if (!watch->isConnected() && currentProfile == "silent" && defaultProfile != "silent") {
- newProfile = defaultProfile;
- }
- }
- else if (currentProfile != defaultProfile) {
- newProfile = defaultProfile;
- }
-
+ QString newProfile = settings->property(
+ watch->isConnected() ? "profileWhenConnected"
+ : "profileWhenDisconnected").toString();
if (!newProfile.isEmpty()) {
QDBusReply<bool> res = QDBusConnection::sessionBus().call(
QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "set_profile")
diff --git a/daemon/manager.h b/daemon/manager.h
index de01dbb..2079de0 100644
--- a/daemon/manager.h
+++ b/daemon/manager.h
@@ -58,8 +58,6 @@ class Manager : public QObject, protected QDBusContext
QContactManager *contacts;
QContactDetailFilter numberFilter;
- QString defaultProfile;
-
QUuid currentAppUuid;
QScopedPointer<icu::Transliterator> transliterator;
@@ -69,7 +67,6 @@ public:
~Manager();
QString findPersonByNumber(QString number);
- QString getCurrentProfile() const;
bool uploadFirmware(bool recovery, const QString &file);
diff --git a/daemon/settings.h b/daemon/settings.h
index 688b211..3c38473 100644
--- a/daemon/settings.h
+++ b/daemon/settings.h
@@ -7,7 +7,8 @@ class Settings : public MDConfGroup
{
Q_OBJECT
- Q_PROPERTY(bool silentWhenConnected MEMBER silentWhenConnected NOTIFY silentWhenConnectedChanged)
+ Q_PROPERTY(QString profileWhenConnected MEMBER profileWhenConnected NOTIFY profileWhenConnectedChanged)
+ Q_PROPERTY(QString profileWhenDisconnected MEMBER profileWhenDisconnected NOTIFY profileWhenDisconnectedChanged)
Q_PROPERTY(bool transliterateMessage MEMBER transliterateMessage NOTIFY transliterateMessageChanged)
Q_PROPERTY(bool useSystemVolume MEMBER useSystemVolume NOTIFY useSystemVolumeChanged)
Q_PROPERTY(bool incomingCallNotification MEMBER incomingCallNotification NOTIFY incomingCallNotificationChanged)
@@ -21,7 +22,8 @@ class Settings : public MDConfGroup
Q_PROPERTY(bool notificationsAll MEMBER notificationsAll NOTIFY notificationsAllChanged)
Q_PROPERTY(QString accountToken MEMBER accountToken NOTIFY accountTokenChanged)
- bool silentWhenConnected;
+ QString profileWhenConnected;
+ QString profileWhenDisconnected;
bool transliterateMessage;
bool useSystemVolume;
bool incomingCallNotification;
@@ -41,7 +43,8 @@ public:
{ resolveMetaObject(); }
signals:
- void silentWhenConnectedChanged();
+ void profileWhenConnectedChanged();
+ void profileWhenDisconnectedChanged();
void transliterateMessageChanged();
void useSystemVolumeChanged();
void incomingCallNotificationChanged();