#include #include "voicecallmanager.h" #include "voicecallmanager_interface.h" #include "profiled_interface.h" static ComNokiaProfiledInterface *profiled = NULL; static OrgNemomobileVoicecallVoiceCallManagerInterface *vcm = NULL; VoiceCallManager::VoiceCallManager(ToqManager *toq) : QObject(toq), _toq(toq) { if (!profiled) { profiled = new ComNokiaProfiledInterface("com.nokia.profiled", "/com/nokia/profiled", QDBusConnection::sessionBus()); } if (!vcm) { vcm = new OrgNemomobileVoicecallVoiceCallManagerInterface("org.nemomobile.voicecall", "/", QDBusConnection::sessionBus()); } // TODO Fix .xml to catch this signal connect(profiled, SIGNAL(profile_changed(bool,bool,QString)), this, SLOT(handleProfileChanged(bool,bool,QString))); _toq->setEndpointListener(ToqConnection::VoiceCallEndpoint, this); } void VoiceCallManager::handleMessage(const ToqConnection::Message &msg) { Q_ASSERT(msg.destination == ToqConnection::VoiceCallEndpoint); switch (msg.type) { case 15: handleGetPhoneStatusMessage(msg); break; default: qWarning() << "Unknown message" << msg.type; break; } } void VoiceCallManager::setSilentMode(bool silent) { setProfile(silent ? "silent" : "ambience"); } 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); } QString VoiceCallManager::getCurrentProfile() { QDBusReply resp = profiled->get_profile(); if (resp.isValid()) { return resp.value(); } else { qWarning() << resp.error().message(); return QString(); } } void VoiceCallManager::setProfile(const QString &name) { QDBusReply resp = profiled->set_profile(name); if (!resp.isValid()) { qWarning() << resp.error().message(); } } void VoiceCallManager::handleProfileChanged(bool changed, bool active, const QString &profile) { Q_UNUSED(changed); Q_UNUSED(active); qDebug() << "Profile changed to" << profile; // TODO }