diff options
Diffstat (limited to 'saltoqd/voicecallmanager.cpp')
-rw-r--r-- | saltoqd/voicecallmanager.cpp | 49 |
1 files changed, 38 insertions, 11 deletions
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; +} |