From d9f246e8cac67eb938d1091d106132ab532c95c6 Mon Sep 17 00:00:00 2001 From: Herman van Hazendonk Date: Mon, 27 May 2019 13:53:10 +0200 Subject: [PATCH] VoiceCall: Make it work without Mer specific bits Other distros such as LuneOS uses VoiceCall as well. To date LuneOS was always maintaining patches to make sure that the Mer specific bits not available in LuneOS were disabled. Made the code more flexible so Voicecall can be used by simply enabling or disabling some flags in the build and in this way a single codebase can be shared between Mer and LuneOS for Voicecall. Signed-off-by: Herman van Hazendonk github.com@herrie.org --- lib/src/src.pro | 4 ++++ plugins/declarative/src/src.pro | 9 ++++++++- plugins/declarative/src/voicecallmanager.cpp | 14 ++++++++++++++ plugins/playback-manager/src/src.pro | 4 ++++ plugins/plugins.pro | 6 +++++- plugins/providers/ofono/src/src.pro | 4 ++++ plugins/providers/providers.pro | 6 +++++- rpm/voicecall-qt5.spec | 1 + src/src.pro | 20 +++++++++++++------- src/voicecallmanager.cpp | 13 +++++++++++++ 10 files changed, 71 insertions(+), 10 deletions(-) diff --git a/lib/src/src.pro b/lib/src/src.pro index 3b64d50..946f76b 100644 --- a/lib/src/src.pro +++ b/lib/src/src.pro @@ -5,6 +5,10 @@ QT = core dbus CONFIG += c++11 +enable-debug { + DEFINES += WANT_TRACE +} + HEADERS += \ common.h \ voicecallmanagerinterface.h \ diff --git a/plugins/declarative/src/src.pro b/plugins/declarative/src/src.pro index 548d31e..d4f1b6e 100644 --- a/plugins/declarative/src/src.pro +++ b/plugins/declarative/src/src.pro @@ -5,7 +5,14 @@ QT = core dbus qml multimedia TARGET = voicecall uri = org.nemomobile.voicecall -PKGCONFIG += ngf-qt5 +enable-debug { + DEFINES += WANT_TRACE +} + +enable-ngf { + PKGCONFIG += ngf-qt5 + DEFINES += WITH_NGF +} HEADERS += \ voicecallaudiorecorder.h \ diff --git a/plugins/declarative/src/voicecallmanager.cpp b/plugins/declarative/src/voicecallmanager.cpp index 6c987a6..ad22b8d 100644 --- a/plugins/declarative/src/voicecallmanager.cpp +++ b/plugins/declarative/src/voicecallmanager.cpp @@ -1,7 +1,9 @@ #include "common.h" #include "voicecallmanager.h" +#ifdef WITH_NGF #include +#endif #include #include @@ -22,7 +24,9 @@ class VoiceCallManagerPrivate voicecalls(NULL), providers(NULL), activeVoiceCall(NULL), +#ifdef WITH_NGF ngf(0), +#endif eventId(0), connected(false) { /*...*/ } @@ -36,7 +40,10 @@ class VoiceCallManagerPrivate VoiceCallHandler* activeVoiceCall; +#ifdef WITH_NGF Ngf::Client *ngf; +#endif + quint32 eventId; bool connected; @@ -74,8 +81,10 @@ void VoiceCallManager::initialize(bool notifyError) Q_D(VoiceCallManager); bool success = false; +#ifdef WITH_NGF d->ngf = new Ngf::Client(this); d->ngf->connect(); +#endif if(d->interface->isValid()) { @@ -287,11 +296,14 @@ bool VoiceCallManager::startDtmfTone(const QString &tone) QMap properties; properties.insert("tonegen.value", toneId); + +#ifdef WITH_NGF if (d->eventId > 0) { d->ngf->stop(d->eventId); } d->eventId = d->ngf->play("dtmf", properties); +#endif return true; } @@ -303,7 +315,9 @@ bool VoiceCallManager::stopDtmfTone() if (d->eventId > 0) { +#ifdef WITH_NGF d->ngf->stop(d->eventId); +#endif d->eventId = 0; } diff --git a/plugins/playback-manager/src/src.pro b/plugins/playback-manager/src/src.pro index 11a6e3d..601ac5d 100644 --- a/plugins/playback-manager/src/src.pro +++ b/plugins/playback-manager/src/src.pro @@ -4,6 +4,10 @@ QT += dbus DEFINES += PLUGIN_NAME=\\\"voicecall-playback-manager-plugin\\\" +enable-debug { + DEFINES += WANT_TRACE +} + HEADERS += \ playbackmanagerplugin.h diff --git a/plugins/plugins.pro b/plugins/plugins.pro index 07bbfbe..13561e6 100644 --- a/plugins/plugins.pro +++ b/plugins/plugins.pro @@ -1,2 +1,6 @@ TEMPLATE = subdirs -SUBDIRS = declarative providers ngf playback-manager mce +SUBDIRS = declarative providers playback-manager mce + +enable-ngf { + SUBDIRS += ngf +} diff --git a/plugins/providers/ofono/src/src.pro b/plugins/providers/ofono/src/src.pro index a38a209..e320bab 100644 --- a/plugins/providers/ofono/src/src.pro +++ b/plugins/providers/ofono/src/src.pro @@ -4,6 +4,10 @@ QT += dbus PKGCONFIG += qofono-qt5 +enable-debug { + DEFINES += WANT_TRACE +} + HEADERS += \ ofonovoicecallhandler.h \ ofonovoicecallprovider.h \ diff --git a/plugins/providers/providers.pro b/plugins/providers/providers.pro index dfe8016..9ca172b 100644 --- a/plugins/providers/providers.pro +++ b/plugins/providers/providers.pro @@ -1,2 +1,6 @@ TEMPLATE = subdirs -SUBDIRS = ofono telepathy +SUBDIRS = ofono + +enable-telepathy { + SUBDIRS += telepathy +} diff --git a/rpm/voicecall-qt5.spec b/rpm/voicecall-qt5.spec index 872f244..989e65b 100644 --- a/rpm/voicecall-qt5.spec +++ b/rpm/voicecall-qt5.spec @@ -76,6 +76,7 @@ BuildRequires: pkgconfig(qofono-qt5) %qmake5 +qmake -qt=5 CONFIG+=enable-ngf CONFIG+=enable-audiopolicy CONFIG+=enable-telepathy CONFIG+=enable-nemo-devicelock CONFIG+=install-servicefiles make %{?_smp_mflags} %install diff --git a/src/src.pro b/src/src.pro index 7e8f40f..cf26c32 100644 --- a/src/src.pro +++ b/src/src.pro @@ -5,7 +5,10 @@ CONFIG += link_pkgconfig INCLUDEPATH += ../lib/src -PKGCONFIG += libresourceqt5 nemodevicelock +enable-nemo-devicelock { + PKGCONFIG += libresourceqt5 nemodevicelock + DEFINES += WITH_NEMO_DEVICELOCK +} packagesExist(qt5-boostable) { DEFINES += HAS_BOOSTER @@ -14,26 +17,28 @@ packagesExist(qt5-boostable) { warning("qt5-boostable not available; startup times will be slower") } - - QT += multimedia # for basic ringtone plugin. LIBS += -L../lib/src -lvoicecall HEADERS += \ dbus/voicecallmanagerdbusservice.h \ basicvoicecallconfigurator.h \ - audiocallpolicyproxy.h \ voicecallmanager.h \ basicringtonenotificationprovider.h SOURCES += \ dbus/voicecallmanagerdbusservice.cpp \ basicvoicecallconfigurator.cpp \ - audiocallpolicyproxy.cpp \ voicecallmanager.cpp \ main.cpp \ basicringtonenotificationprovider.cpp +enable-audiopolicy { + HEADERS += audiocallpolicyproxy.h + SOURCES += audiocallpolicyproxy.cpp + DEFINES += WITH_AUDIOPOLICY +} + target.path = /usr/bin INSTALLS += target @@ -43,5 +48,6 @@ OTHER_FILES += voicecall-manager.desktop voicecall-manager.service systemd_service_entry.files = voicecall-manager.service systemd_service_entry.path = /usr/lib/systemd/user -INSTALLS += autostart_entry systemd_service_entry - +install-servicefiles { + INSTALLS += systemd_service_entry +} diff --git a/src/voicecallmanager.cpp b/src/voicecallmanager.cpp index abe9573..305d257 100644 --- a/src/voicecallmanager.cpp +++ b/src/voicecallmanager.cpp @@ -23,9 +23,15 @@ #include #include +#include + +#ifdef WITH_NEMO_DEVICELOCK #include +#endif +#ifdef WITH_AUDIOPOLICY #include "audiocallpolicyproxy.h" +#endif class VoiceCallManagerPrivate { @@ -45,7 +51,10 @@ class VoiceCallManagerPrivate AbstractVoiceCallHandler *activeVoiceCall; +#ifdef WITH_NEMO_DEVICELOCK NemoDeviceLock::DeviceLock deviceLock; +#endif + QString audioMode; bool isAudioRouted; bool isMicrophoneMuted; @@ -327,8 +336,12 @@ void VoiceCallManager::onVoiceCallAdded(AbstractVoiceCallHandler *handler) TRACE Q_D(VoiceCallManager); +#ifdef WITH_NEMO_DEVICELOCK if (!handler->isEmergency() && d->deviceLock.state() == NemoDeviceLock::DeviceLock::ManagerLockout) { +#else + if (!handler->isEmergency()) { +#endif handler->hangup(); return;