summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorPhilipp Andreas <github@smurfy.de>2014-07-22 19:17:53 +0200
committerPhilipp Andreas <github@smurfy.de>2014-07-22 19:49:07 +0200
commitc2c141ed1e13e6f0fbc740d0ff37caba0b2a7c08 (patch)
treea7892e105c85c7d4a32d3b3202e60ec2131e42c8 /daemon
parentc9c1ed9faee07c0067827872ffe465d465c81470 (diff)
parent9f8db04d6059e0b220e36a064d694a1b0649f5f0 (diff)
Merge branch 'master' into notifications
Conflicts: daemon/daemon.cpp daemon/manager.cpp daemon/manager.h
Diffstat (limited to 'daemon')
-rw-r--r--daemon/daemon.cpp4
-rw-r--r--daemon/daemon.pro2
-rw-r--r--daemon/manager.cpp53
-rw-r--r--daemon/manager.h4
4 files changed, 60 insertions, 3 deletions
diff --git a/daemon/daemon.cpp b/daemon/daemon.cpp
index 1ab7b8c..e075c0c 100644
--- a/daemon/daemon.cpp
+++ b/daemon/daemon.cpp
@@ -70,8 +70,6 @@ void initLogging()
Log4Qt::LogManager::setHandleQtMessages(true);
qDebug() << "Using following log config file: " << usedConfigFile;
-
- Log4Qt::Logger::logger(QLatin1String("Main Logger"))->info("Logging started");
}
int main(int argc, char *argv[])
@@ -82,6 +80,8 @@ int main(int argc, char *argv[])
// QCoreApplication for determining the .conf files locations
initLogging();
+ Log4Qt::Logger::logger(QLatin1String("Main Logger"))->info() << argv[0] << APP_VERSION;
+
watch::WatchConnector watch;
DBusConnector dbus;
VoiceCallManager voice;
diff --git a/daemon/daemon.pro b/daemon/daemon.pro
index fb10771..df7b887 100644
--- a/daemon/daemon.pro
+++ b/daemon/daemon.pro
@@ -12,6 +12,8 @@ LIBS += -L$$OUT_PWD/../ext/Log4Qt/ -llog4qt
QMAKE_RPATHDIR += /usr/share/pebble/lib
INCLUDEPATH += ../ext/Log4Qt/src ../ext/Log4Qt/deploy/include
+DEFINES += APP_VERSION=\\\"$$VERSION\\\"
+
SOURCES += \
daemon.cpp \
manager.cpp \
diff --git a/daemon/manager.cpp b/daemon/manager.cpp
index efa5a28..41617e4 100644
--- a/daemon/manager.cpp
+++ b/daemon/manager.cpp
@@ -11,7 +11,7 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan
{
connect(settings, SIGNAL(valueChanged(QString)), SLOT(onSettingChanged(const QString&)));
connect(settings, SIGNAL(valuesChanged()), SLOT(onSettingsChanged()));
- connect(settings, SIGNAL(silentWhenConnectedChanged()), 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;
@@ -50,6 +50,10 @@ Manager::Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallMan
connect(dbus, SIGNAL(pebbleChanged()), adaptor, SIGNAL(pebbleChanged()));
connect(watch, SIGNAL(connectedChanged()), adaptor, SIGNAL(connectedChanged()));
+ QString currentProfile = getCurrentProfile();
+ defaultProfile = currentProfile.isEmpty() ? "ambience" : currentProfile;
+ connect(watch, SIGNAL(connectedChanged()), SLOT(applyProfile()));
+
// Music Control interface
session.connect("", "/org/mpris/MediaPlayer2",
"org.freedesktop.DBus.Properties", "PropertiesChanged",
@@ -257,3 +261,50 @@ void Manager::setMprisMetadata(QVariantMap metadata)
mprisMetadata = metadata;
emit mprisMetadataChanged(mprisMetadata);
}
+
+QString Manager::getCurrentProfile()
+{
+ 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();
+ logger()->debug() << "Got profile" << currentProfile;
+ return currentProfile;
+ }
+
+ logger()->error() << 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;
+ }
+
+ if (!newProfile.isEmpty()) {
+ QDBusReply<bool> res = QDBusConnection::sessionBus().call(
+ QDBusMessage::createMethodCall("com.nokia.profiled", "/com/nokia/profiled", "com.nokia.profiled", "set_profile")
+ << newProfile);
+ if (res.isValid()) {
+ if (!res.value()) {
+ logger()->error() << "Unable to set profile" << newProfile;
+ }
+ }
+ else {
+ logger()->error() << res.error().message();
+ }
+ }
+}
diff --git a/daemon/manager.h b/daemon/manager.h
index 16e3cbf..9a82603 100644
--- a/daemon/manager.h
+++ b/daemon/manager.h
@@ -46,12 +46,15 @@ class Manager :
QContactManager *contacts;
QContactDetailFilter numberFilter;
+ QString defaultProfile;
+
QString lastSeenMpris;
public:
explicit Manager(watch::WatchConnector *watch, DBusConnector *dbus, VoiceCallManager *voice, NotificationManager *notifications, Settings *settings);
Q_INVOKABLE QString findPersonByNumber(QString number);
+ Q_INVOKABLE QString getCurrentProfile();
Q_INVOKABLE QString mpris();
QVariantMap mprisMetadata;
QVariantMap getMprisMetadata() { return mprisMetadata; }
@@ -61,6 +64,7 @@ signals:
public slots:
void hangupAll();
+ void applyProfile();
protected slots:
void onSettingChanged(const QString &key);