summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-03-29 06:04:09 +0200
committerJavier <dev.git@javispedro.com>2015-03-29 06:04:09 +0200
commit2ded0dbcf63ae7203f64a8f788cc74528eb79416 (patch)
treebbd3a986515cf37f5e180ebb456208fe96905ad5
parent88a96091042c63d9b2d62dedb3a7b9be0f53bf49 (diff)
downloadsaltoq-2ded0dbcf63ae7203f64a8f788cc74528eb79416.tar.gz
saltoq-2ded0dbcf63ae7203f64a8f788cc74528eb79416.zip
fix profile change detection
-rw-r--r--saltoqd/com.nokia.profiled.xml3
-rw-r--r--saltoqd/commmanager.cpp2
-rw-r--r--saltoqd/contactsmanager.cpp2
-rw-r--r--saltoqd/saltoqd.pro1
-rw-r--r--saltoqd/toqconnection.cpp1
-rw-r--r--saltoqd/voicecallmanager.cpp49
-rw-r--r--saltoqd/voicecallmanager.h16
7 files changed, 61 insertions, 13 deletions
diff --git a/saltoqd/com.nokia.profiled.xml b/saltoqd/com.nokia.profiled.xml
index d90247e..45578d7 100644
--- a/saltoqd/com.nokia.profiled.xml
+++ b/saltoqd/com.nokia.profiled.xml
@@ -6,7 +6,8 @@
<arg name="changed" type="b" direction="out"/>
<arg name="active" type="b" direction="out"/>
<arg name="profile" type="s" direction="out"/>
- <!-- TODO <arg type="a(sss)" direction="out"/> -->
+ <arg name="values" type="a(sss)" direction="out"/>
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In3" value="QList&lt;ProfileValue&gt;" />
</signal>
<method name="get_profile">
<arg name="profile" type="s" direction="out"/>
diff --git a/saltoqd/commmanager.cpp b/saltoqd/commmanager.cpp
index 878fba2..b078c0c 100644
--- a/saltoqd/commmanager.cpp
+++ b/saltoqd/commmanager.cpp
@@ -220,5 +220,7 @@ void CommManager::refresh()
QJsonObject root;
root.insert("DataStore", store);
+ qDebug() << "Got" << records.size() << "records";
+
_storage->updateStore(storeName, root);
}
diff --git a/saltoqd/contactsmanager.cpp b/saltoqd/contactsmanager.cpp
index 4e17e0f..19e3c84 100644
--- a/saltoqd/contactsmanager.cpp
+++ b/saltoqd/contactsmanager.cpp
@@ -102,6 +102,8 @@ void ContactsManager::refresh()
QJsonObject root;
root.insert("DataStore", store);
+ qDebug() << "Got" << records.size() << "records";
+
_storage->updateStore(storeName, root);
emit changed();
diff --git a/saltoqd/saltoqd.pro b/saltoqd/saltoqd.pro
index e261b36..332dcb8 100644
--- a/saltoqd/saltoqd.pro
+++ b/saltoqd/saltoqd.pro
@@ -41,6 +41,7 @@ HEADERS += \
DBUS_ADAPTORS += org.freedesktop.Notifications.xml
DBUS_INTERFACES += com.nokia.profiled.xml org.nemomobile.voicecall.VoiceCallManager.xml
+QDBUSXML2CPP_INTERFACE_HEADER_FLAGS = -i voicecallmanager.h
target.path = /usr/bin
INSTALLS += target
diff --git a/saltoqd/toqconnection.cpp b/saltoqd/toqconnection.cpp
index 92d3353..4cc1d3e 100644
--- a/saltoqd/toqconnection.cpp
+++ b/saltoqd/toqconnection.cpp
@@ -52,7 +52,6 @@ quint32 ToqConnection::checksum(QIODevice *dev)
void ToqConnection::setAddress(const QBluetoothAddress &address)
{
- qDebug() << address.toString() << _address.toString();
if (address != _address) {
_address = address;
if (isConnected()) {
diff --git a/saltoqd/voicecallmanager.cpp b/saltoqd/voicecallmanager.cpp
index 8820dd6..d2c5c52 100644
--- a/saltoqd/voicecallmanager.cpp
+++ b/saltoqd/voicecallmanager.cpp
@@ -10,6 +10,9 @@ VoiceCallManager::VoiceCallManager(ToqManager *toq) :
QObject(toq), _toq(toq)
{
if (!profiled) {
+ qDBusRegisterMetaType<ProfileValue>();
+ qDBusRegisterMetaType< QList<ProfileValue> >();
+
profiled = new ComNokiaProfiledInterface("com.nokia.profiled",
"/com/nokia/profiled",
QDBusConnection::sessionBus());
@@ -20,9 +23,8 @@ VoiceCallManager::VoiceCallManager(ToqManager *toq) :
QDBusConnection::sessionBus());
}
- // TODO Fix .xml to catch this signal
- connect(profiled, SIGNAL(profile_changed(bool,bool,QString)),
- this, SLOT(handleProfileChanged(bool,bool,QString)));
+ connect(profiled, &ComNokiaProfiledInterface::profile_changed,
+ this, &VoiceCallManager::handleProfileChanged);
_toq->setEndpointListener(ToqConnection::VoiceCallEndpoint, this);
}
@@ -47,13 +49,7 @@ void VoiceCallManager::setSilentMode(bool silent)
void VoiceCallManager::handleGetPhoneStatusMessage(const ToqConnection::Message &msg)
{
- QJsonObject obj;
- obj.insert("service", int(1));
- obj.insert("call_status", int(0));
- obj.insert("call_setup_status", int(0));
- obj.insert("silence_mode", getCurrentProfile() == "silent" ? 1 : 0);
-
- _toq->sendReply(msg, 0x400F, obj);
+ _toq->sendReply(msg, 0x400F, buildPhoneStatus());
}
QString VoiceCallManager::getCurrentProfile()
@@ -77,11 +73,42 @@ void VoiceCallManager::setProfile(const QString &name)
}
}
+void VoiceCallManager::sendPhoneStatusMessage()
+{
+ _toq->sendMessage(ToqConnection::VoiceCallEndpoint, ToqConnection::VoiceCallEndpoint + 1,
+ 0x8000, buildPhoneStatus());
+}
+
+QJsonObject VoiceCallManager::buildPhoneStatus()
+{
+ QJsonObject obj;
+ obj.insert("service", int(1));
+ obj.insert("call_status", int(0));
+ obj.insert("call_setup_status", int(0));
+ obj.insert("silence_mode", getCurrentProfile() == "silent" ? 1 : 0);
+ return obj;
+}
+
void VoiceCallManager::handleProfileChanged(bool changed, bool active, const QString &profile)
{
Q_UNUSED(changed);
Q_UNUSED(active);
qDebug() << "Profile changed to" << profile;
- // TODO
+ sendPhoneStatusMessage();
}
+QDBusArgument &operator<<(QDBusArgument &argument, const ProfileValue &value)
+{
+ argument.beginStructure();
+ argument << value.key << value.val << value.type;
+ argument.endStructure();
+ return argument;
+}
+
+const QDBusArgument &operator>>(const QDBusArgument &argument, ProfileValue &value)
+{
+ argument.beginStructure();
+ argument >> value.key >> value.val >> value.type;
+ argument.endStructure();
+ return argument;
+}
diff --git a/saltoqd/voicecallmanager.h b/saltoqd/voicecallmanager.h
index 8a7bd85..2e6275a 100644
--- a/saltoqd/voicecallmanager.h
+++ b/saltoqd/voicecallmanager.h
@@ -3,6 +3,12 @@
#include "toqmanager.h"
+struct ProfileValue {
+ QString key;
+ QString val;
+ QString type;
+};
+
class VoiceCallManager : public QObject, public ToqManager::EndpointHandler
{
Q_OBJECT
@@ -19,6 +25,9 @@ private:
static QString getCurrentProfile();
static void setProfile(const QString &name);
+ void sendPhoneStatusMessage();
+ QJsonObject buildPhoneStatus();
+
private slots:
void handleProfileChanged(bool changed, bool active, const QString &profile);
@@ -26,4 +35,11 @@ private:
ToqManager *_toq;
};
+class QDBusArgument;
+QDBusArgument &operator<<(QDBusArgument &argument, const ProfileValue &value);
+const QDBusArgument &operator>>(const QDBusArgument &argument, ProfileValue &value);
+
+Q_DECLARE_METATYPE(ProfileValue)
+Q_DECLARE_METATYPE(QList<ProfileValue>)
+
#endif // VOICECALLMANAGER_H