diff --git a/.travis.yml b/.travis.yml index 773871f..1945fc9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,17 +22,13 @@ addons: - sqlite3 - telepathy-mission-control-5 - doxygen + - libqofono-dev before_install: - sudo apt-get update - - sudo apt-get install -y qtbase5-dev libtelepathy-qt5-dev libphonenumber-dev dbus-test-runner dconf-cli gnome-keyring libmission-control-plugins-dev libqt5sql5-sqlite libsqlite3-dev qt5-default sqlite3 telepathy-mission-control-5 doxygen + - sudo apt-get install -y qtbase5-dev libtelepathy-qt5-dev libphonenumber-dev dbus-test-runner dconf-cli gnome-keyring libmission-control-plugins-dev libqt5sql5-sqlite libsqlite3-dev qt5-default sqlite3 telepathy-mission-control-5 doxygen libqofono-dev script: - - git clone https://github.com/Kaffeine/libofono-qt.git - - cd libofono-qt - - qmake && make -j4 - - sudo make install - - cd .. - mkdir build && cd build - cmake ../ - make -j4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 47c22f2..b4850a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,10 @@ project(telepathy-ofono) -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) set(TELEPATHY_OFONO telepathy-ofono) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) # Find includes in corresponding build directories set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -31,28 +33,23 @@ IF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) ENDIF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) find_package(LibPhoneNumber REQUIRED) -find_package(Qt5Core) -find_package(Qt5DBus) -find_package(Qt5Network) -add_definitions(-DQT_NO_KEYWORDS) +find_package(Qt5 REQUIRED COMPONENTS Core DBus Network) find_package(PkgConfig REQUIRED) pkg_check_modules(TP_QT5 REQUIRED TelepathyQt5) pkg_check_modules(SQLITE3 REQUIRED sqlite3) pkg_check_modules(MC_PLUGINS REQUIRED mission-control-plugins) -pkg_check_modules(OFONO_QT REQUIRED ofono-qt) +pkg_check_modules(QOFONO REQUIRED qofono-qt5) find_program(DBUS_RUNNER dbus-test-runner) set(CMAKE_AUTOMOC ON) include_directories(${TP_QT5_INCLUDE_DIRS}) -include_directories(${Qt5Core_INCLUDE_DIRS}) -include_directories(${Qt5DBus_INCLUDE_DIRS}) include_directories(${SQLITE3_INCLUDE_DIRS}) include_directories(${LibPhoneNumber_INCLUDE_DIRS}) include_directories(/usr/include/telepathy-qt5/) -include_directories(${OFONO_QT_INCLUDE_DIRS}) +include_directories(${QOFONO_INCLUDE_DIRS}) find_library(TELEPATHY_QT5_LIBRARIES telepathy-qt5) find_library(TELEPATHY_QT5_SERVICE_LIBRARIES telepathy-qt5-service) @@ -95,7 +92,7 @@ add_dependencies(${TELEPATHY_OFONO} schema_update qrc_update) enable_testing() -target_link_libraries(${TELEPATHY_OFONO} ${Qt5Core_LIBRARIES} ${Qt5DBus_LIBRARIES} -ltelepathy-qt5 ${TELEPATHY_QT5_SERVICE_LIBRARIES} ${Qt5Network_LIBRARIES} ${OFONO_QT_LIBRARIES} ${SQLITE3_LIBRARIES} ${LibPhoneNumber_LIBRARIES}) +target_link_libraries(${TELEPATHY_OFONO} Qt5::Core Qt5::DBus -ltelepathy-qt5 ${TELEPATHY_QT5_SERVICE_LIBRARIES} Qt5::Network ${SQLITE3_LIBRARIES} ${LibPhoneNumber_LIBRARIES} ${QOFONO_LIBRARIES}) install(TARGETS ${TELEPATHY_OFONO} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}) configure_file(ofono.service.in org.freedesktop.Telepathy.ConnectionManager.ofono.service) diff --git a/connection.cpp b/connection.cpp index faefd70..5d695d4 100644 --- a/connection.cpp +++ b/connection.cpp @@ -43,25 +43,38 @@ oFonoConnection::oFonoConnection(const QDBusConnection &dbusConnection, const QString &protocolName, const QVariantMap ¶meters) : Tp::BaseConnection(dbusConnection, cmName, protocolName, parameters), - mOfonoModemManager(new OfonoModemManager(this)), + mOfonoManager(new QOfonoManager(this)), mHandleCount(0), mGroupHandleCount(0), mMmsdManager(new MMSDManager(this)), mConferenceCall(nullptr) { - OfonoModem::SelectionSetting setting = OfonoModem::AutomaticSelect; + // TODO porting + // OfonoModem::SelectionSetting setting = OfonoModem::AutomaticSelect; mModemPath = parameters["modem-objpath"].toString(); - if (!mModemPath.isEmpty()) { - setting = OfonoModem::ManualSelect; - } - mOfonoMessageManager = new OfonoMessageManager(setting, mModemPath); - mOfonoVoiceCallManager = new OfonoVoiceCallManager(setting, mModemPath); - mOfonoCallVolume = new OfonoCallVolume(setting, mModemPath); - mOfonoNetworkRegistration = new OfonoNetworkRegistration(setting, mModemPath); - mOfonoMessageWaiting = new OfonoMessageWaiting(setting, mModemPath); - mOfonoSupplementaryServices = new OfonoSupplementaryServices(setting, mModemPath); - mOfonoSimManager = new OfonoSimManager(setting, mModemPath); - mOfonoModem = mOfonoSimManager->modem(); +// if (!mModemPath.isEmpty()) { +// setting = OfonoModem::ManualSelect; +// } + + //TODO porting 'setting'?? was getting passed to ModemInterface + mOfonoMessageManager = new QOfonoMessageManager(this); + mOfonoMessageManager->setModemPath(mModemPath); + /// TODO porting setting? + mOfonoVoiceCallManager = new QOfonoVoiceCallManager(this); + mOfonoVoiceCallManager->setModemPath(mModemPath); + mOfonoCallVolume = new QOfonoCallVolume(this); + mOfonoCallVolume->setModemPath(mModemPath); + mOfonoNetworkRegistration = new QOfonoNetworkRegistration(this); + mOfonoNetworkRegistration->setModemPath(mModemPath); + /// TODO porting setting? + mOfonoMessageWaiting = new QOfonoMessageWaiting(this); + mOfonoMessageWaiting->setModemPath(mModemPath); + mOfonoSupplementaryServices = new QOfonoSupplementaryServices(this); + mOfonoSupplementaryServices->setModemPath(mModemPath); + mOfonoSimManager = new QOfonoSimManager(this); + mOfonoSimManager->setModemPath(mModemPath); + mOfonoModem = new QOfonoModem(this); + mOfonoModem->setModemPath(mModemPath); if (mOfonoSimManager->subscriberNumbers().size() > 0) { setSelfHandle(newHandle(mOfonoSimManager->subscriberNumbers()[0])); @@ -126,8 +139,8 @@ oFonoConnection::oFonoConnection(const QDBusConnection &dbusConnection, // init custom emergency mode interface (not provided by telepathy emergencyModeIface = BaseConnectionEmergencyModeInterface::create(); emergencyModeIface->setEmergencyNumbersCallback(Tp::memFun(this,&oFonoConnection::emergencyNumbers)); - QObject::connect(mOfonoVoiceCallManager, SIGNAL(emergencyNumbersChanged(QStringList)), - emergencyModeIface.data(), SLOT(setEmergencyNumbers(QStringList))); + QObject::connect(mOfonoVoiceCallManager, &QOfonoVoiceCallManager::emergencyNumbersChanged, + emergencyModeIface.data(), &BaseConnectionEmergencyModeInterface::setEmergencyNumbers); plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(emergencyModeIface)); emergencyModeIface->setEmergencyNumbers(mOfonoVoiceCallManager->emergencyNumbers()); emergencyModeIface->setFakeEmergencyNumber(parameters["fakeEmergencyNumber"].toString()); @@ -190,65 +203,52 @@ oFonoConnection::oFonoConnection(const QDBusConnection &dbusConnection, << TP_QT_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE); plugInterface(Tp::AbstractConnectionInterfacePtr::dynamicCast(contactsIface)); - QObject::connect(mOfonoModem, SIGNAL(onlineChanged(bool)), SLOT(updateOnlineStatus())); - QObject::connect(mOfonoModem, SIGNAL(serialChanged(QString)), supplementaryServicesIface.data(), SLOT(setSerial(QString))); - QObject::connect(mOfonoModem, SIGNAL(interfacesChanged(QStringList)), SLOT(updateOnlineStatus())); - QObject::connect(mOfonoMessageManager, SIGNAL(incomingMessage(QString,QVariantMap)), this, SLOT(onOfonoIncomingMessage(QString,QVariantMap))); - QObject::connect(mOfonoMessageManager, SIGNAL(immediateMessage(QString,QVariantMap)), this, SLOT(onOfonoImmediateMessage(QString,QVariantMap))); - QObject::connect(mOfonoMessageManager, SIGNAL(statusReport(QString,QVariantMap)), this, SLOT(onDeliveryReportReceived(QString,QVariantMap))); - QObject::connect(mOfonoVoiceCallManager, SIGNAL(callAdded(QString,QVariantMap)), SLOT(onOfonoCallAdded(QString, QVariantMap))); + QObject::connect(mOfonoModem, &QOfonoModem::onlineChanged, this, &oFonoConnection::updateOnlineStatus); + QObject::connect(mOfonoModem, &QOfonoModem::serialChanged, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::setSerial); + QObject::connect(mOfonoModem, &QOfonoModem::interfacesChanged, this, &oFonoConnection::updateOnlineStatus); + QObject::connect(mOfonoMessageManager, &QOfonoMessageManager::incomingMessage, this, &oFonoConnection::onOfonoIncomingMessage); + QObject::connect(mOfonoMessageManager, &QOfonoMessageManager::immediateMessage, this, &oFonoConnection::onOfonoImmediateMessage); + //TODO porting: is that equivalent to receiving a status report? + //QObject::connect(mOfonoMessageManager, &QOfonoMessageManager::sendMessageComplete, this, &oFonoConnection::onDeliveryReportReceived); + QObject::connect(mOfonoVoiceCallManager, &QOfonoVoiceCallManager::callAdded, this, &oFonoConnection::onOfonoCallAdded); + /// \TODO: this is actually a misnamed slot in ofono-qt/OfonoVoiceCallManager QObject::connect(mOfonoVoiceCallManager, SIGNAL(validityChanged(bool)), SLOT(onValidityChanged(bool))); - QObject::connect(mOfonoSimManager, SIGNAL(validityChanged(bool)), SLOT(onValidityChanged(bool))); - QObject::connect(mOfonoSimManager, SIGNAL(presenceChanged(bool)), SLOT(updateOnlineStatus())); - QObject::connect(mOfonoSimManager, SIGNAL(pinRequiredChanged(QString)), SLOT(updateOnlineStatus())); - QObject::connect(mOfonoSimManager, SIGNAL(subscriberNumbersChanged(QStringList)), SLOT(updateOnlineStatus())); - QObject::connect(mOfonoNetworkRegistration, SIGNAL(statusChanged(QString)), SLOT(updateOnlineStatus())); - QObject::connect(mOfonoNetworkRegistration, SIGNAL(nameChanged(QString)), SLOT(updateOnlineStatus())); - QObject::connect(mOfonoNetworkRegistration, SIGNAL(mccChanged(QString)), SLOT(updateOnlineStatus(QString))); - QObject::connect(mOfonoNetworkRegistration, SIGNAL(validityChanged(bool)), SLOT(onValidityChanged(bool))); - QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailMessageCountChanged(int)), voicemailIface.data(), SLOT(setVoicemailCount(int))); - QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailWaitingChanged(bool)), voicemailIface.data(), SLOT(setVoicemailIndicator(bool))); - QObject::connect(mOfonoMessageWaiting, SIGNAL(voicemailMailboxNumberChanged(QString)), voicemailIface.data(), SLOT(setVoicemailNumber(QString))); - - QObject::connect(mMmsdManager, SIGNAL(serviceAdded(const QString&)), SLOT(onMMSDServiceAdded(const QString&))); - QObject::connect(mMmsdManager, SIGNAL(serviceRemoved(const QString&)), SLOT(onMMSDServiceRemoved(const QString&))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(notificationReceived(const QString &)), supplementaryServicesIface.data(), SLOT(NotificationReceived(const QString &))); - QObject::connect(mOfonoSupplementaryServices, SIGNAL(requestReceived(const QString &)), supplementaryServicesIface.data(), SLOT(RequestReceived(const QString &))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(initiateUSSDComplete(const QString &)), supplementaryServicesIface.data(), SLOT(InitiateUSSDComplete(const QString &))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(barringComplete(const QString &, const QString &, const QVariantMap &)), - supplementaryServicesIface.data(), SLOT(BarringComplete(const QString &, const QString &, const QVariantMap &))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(forwardingComplete(const QString &, const QString &, const QVariantMap &)), - supplementaryServicesIface.data(), SLOT(ForwardingComplete(const QString &, const QString &, const QVariantMap &))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(waitingComplete(const QString &, const QVariantMap &)), - supplementaryServicesIface.data(), SLOT(WaitingComplete(const QString &, const QVariantMap &))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(callingLinePresentationComplete(const QString &, const QString &)), - supplementaryServicesIface.data(), SLOT(CallingLinePresentationComplete(const QString &, const QString &))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(connectedLinePresentationComplete(const QString &, const QString &)), - supplementaryServicesIface.data(), SLOT(ConnectedLinePresentationComplete(const QString &, const QString &))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(callingLineRestrictionComplete(const QString &, const QString &)), - supplementaryServicesIface.data(), SLOT(CallingLineRestrictionComplete(const QString &, const QString &))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(connectedLineRestrictionComplete(const QString &, const QString &)), - supplementaryServicesIface.data(), SLOT(ConnectedLineRestrictionComplete(const QString &, const QString &))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(initiateFailed()), supplementaryServicesIface.data(), SLOT(InitiateFailed())); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(stateChanged(const QString&)), supplementaryServicesIface.data(), SLOT(StateChanged(const QString&))); - - QObject::connect(mOfonoSupplementaryServices, SIGNAL(respondComplete(bool, const QString &)), supplementaryServicesIface.data(), SLOT(RespondComplete(bool, const QString &))); - - QObject::connect(this, SIGNAL(disconnected()), this, SLOT(onDisconnected())); + // todo porting can this be gone? + //QObject::connect(mOfonoSimManager, &QOfonoSimManager::validityChanged, this, &oFonoConnection::onValidityChanged); + QObject::connect(mOfonoSimManager, &QOfonoSimManager::presenceChanged, this, &oFonoConnection::updateOnlineStatus); + QObject::connect(mOfonoSimManager, &QOfonoSimManager::pinRequiredChanged, this, &oFonoConnection::updateOnlineStatus); + QObject::connect(mOfonoSimManager, &QOfonoSimManager::subscriberNumbersChanged, this, &oFonoConnection::updateOnlineStatus); + QObject::connect(mOfonoNetworkRegistration, &QOfonoNetworkRegistration::statusChanged, this, &oFonoConnection::updateOnlineStatus); + QObject::connect(mOfonoNetworkRegistration, &QOfonoNetworkRegistration::nameChanged, this, &oFonoConnection::updateOnlineStatus); + QObject::connect(mOfonoNetworkRegistration, &QOfonoNetworkRegistration::mccChanged, this, &oFonoConnection::updateOnlineStatus); + // TODO porting can this be gone + //QObject::connect(mOfonoNetworkRegistration, &QOfonoNetworkRegistration::validityChanged, this, &oFonoConnection::onValidityChanged); + QObject::connect(mOfonoMessageWaiting, &QOfonoMessageWaiting::voicemailMessageCountChanged, voicemailIface.data(), &BaseConnectionVoicemailInterface::setVoicemailCount); + QObject::connect(mOfonoMessageWaiting, &QOfonoMessageWaiting::voicemailWaitingChanged, voicemailIface.data(), &BaseConnectionVoicemailInterface::setVoicemailIndicator); + QObject::connect(mOfonoMessageWaiting, &QOfonoMessageWaiting::voicemailMailboxNumberChanged, voicemailIface.data(), &BaseConnectionVoicemailInterface::setVoicemailNumber); + + QObject::connect(mMmsdManager, &MMSDManager::serviceAdded, this, &oFonoConnection::onMMSDServiceAdded); + QObject::connect(mMmsdManager, &MMSDManager::serviceRemoved, this, &oFonoConnection::onMMSDServiceRemoved); + + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::notificationReceived, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::NotificationReceived); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::requestReceived, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::RequestReceived); + // todo porting + //QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::initiateUSSDComplete, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::InitiateUSSDComplete); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::callBarringResponse, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::BarringComplete); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::callForwardingResponse, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::ForwardingComplete); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::callWaitingResponse, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::WaitingComplete); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::callingLinePresentationResponse, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::CallingLinePresentationComplete); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::connectedLinePresentationResponse, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::ConnectedLinePresentationComplete); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::callingLineRestrictionResponse, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::CallingLineRestrictionComplete); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::connectedLineRestrictionResponse, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::ConnectedLineRestrictionComplete); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::initiateFailed, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::InitiateFailed); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::stateChanged, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::StateChanged); + QObject::connect(mOfonoSupplementaryServices, &QOfonoSupplementaryServices::respondComplete, supplementaryServicesIface.data(), &BaseConnectionUSSDInterface::RespondComplete); + + QObject::connect(this, &oFonoConnection::disconnected, this, &oFonoConnection::onDisconnected); // workaround: we can't add services here as tp-ofono interfaces are not exposed on dbus // todo: use QDBusServiceWatcher - QTimer::singleShot(1000, this, SLOT(onCheckMMSServices())); + QTimer::singleShot(1000, this, &oFonoConnection::onCheckMMSServices); } void oFonoConnection::onDisconnected() @@ -290,8 +290,8 @@ void oFonoConnection::onMMSDServiceAdded(const QString &path) } qDebug() << "oFonoConnection::onMMSServiceAdded" << path; mMmsdServices[path] = service; - QObject::connect(service, SIGNAL(messageAdded(const QString&, const QVariantMap&)), SLOT(onMMSAdded(const QString&, const QVariantMap&))); - QObject::connect(service, SIGNAL(messageRemoved(const QString&)), SLOT(onMMSRemoved(const QString&))); + QObject::connect(service, &MMSDService::messageAdded, this, &oFonoConnection::onMMSAdded); + QObject::connect(service, &MMSDService::messageRemoved, this, &oFonoConnection::onMMSRemoved); Q_FOREACH(MessageStruct message, service->messages()) { addMMSToService(message.path.path(), message.properties, service->path()); } @@ -493,7 +493,7 @@ oFonoConnection::~oFonoConnection() { dbusConnection().unregisterObject(objectPath(), QDBusConnection::UnregisterTree); dbusConnection().unregisterService(busName()); - mOfonoModemManager->deleteLater(); + mOfonoManager->deleteLater(); mOfonoMessageManager->deleteLater(); mOfonoVoiceCallManager->deleteLater(); mOfonoCallVolume->deleteLater(); @@ -556,11 +556,12 @@ void oFonoConnection::onValidityChanged(bool valid) // WORKAROUND: ofono-qt does not refresh the properties once the interface // becomes available, so it contains old values. if (sender() == mOfonoSimManager) { - Q_EMIT mOfonoSimManager->modem()->pathChanged(mOfonoModem->path()); + //Q_EMIT mOfonoSimManager->modem()->pathChanged(mOfonoModem->path()); } else if (sender() == mOfonoNetworkRegistration) { - Q_EMIT mOfonoNetworkRegistration->modem()->pathChanged(mOfonoModem->path()); + //Q_EMIT mOfonoNetworkRegistration->modem()->pathChanged(mOfonoModem->path()); } else if (sender() == mOfonoVoiceCallManager) { - Q_EMIT mOfonoVoiceCallManager->modem()->pathChanged(mOfonoModem->path()); + /// todo porting can this safely be removed? + //Q_EMIT mOfonoVoiceCallManager->modem()->pathChanged(mOfonoModem->path()); } QString modemSerial; if (valid) { @@ -587,7 +588,7 @@ void oFonoConnection::updateOnlineStatus() !mOfonoSimManager->isValid()) { mSelfPresence.status = "nosim"; } else if (mOfonoSimManager->isValid() && mOfonoSimManager->present() && - mOfonoSimManager->pinRequired() != "none" && !mOfonoSimManager->pinRequired().isEmpty()) { + mOfonoSimManager->pinRequired() != QOfonoSimManager::NoPin) { mSelfPresence.status = "simlocked"; mSelfPresence.type = Tp::ConnectionPresenceTypeAway; } else if (isNetworkRegistered()) { @@ -784,8 +785,8 @@ Tp::BaseChannelPtr oFonoConnection::createTextChannel(const QVariantMap &request channel = new oFonoTextChannel(this, QString(), phoneNumbers, flash); } mTextChannels << channel; - QObject::connect(channel, SIGNAL(messageRead(QString)), SLOT(onMessageRead(QString))); - QObject::connect(channel, SIGNAL(destroyed()), SLOT(onTextChannelClosed())); + QObject::connect(channel, &oFonoTextChannel::messageRead, this, &oFonoConnection::onMessageRead); + QObject::connect(channel, &oFonoTextChannel::destroyed, this, &oFonoConnection::onTextChannelClosed); return channel->baseChannel(); } @@ -843,21 +844,23 @@ Tp::BaseChannelPtr oFonoConnection::createCallChannel(const QVariantMap &request return Tp::BaseChannelPtr(); } - QList channels = mOfonoVoiceCallManager->createMultiparty(); - if (!channels.isEmpty()) { + // todo porting error handling + /*QList channels =*/ mOfonoVoiceCallManager->createMultiparty(); + //if (!channels.isEmpty()) { mConferenceCall = new oFonoConferenceCallChannel(this); - QObject::connect(mConferenceCall, SIGNAL(destroyed()), SLOT(onConferenceCallChannelClosed())); + QObject::connect(mConferenceCall, &oFonoConferenceCallChannel::destroyed, this, &oFonoConnection::onConferenceCallChannelClosed); mConferenceCall->baseChannel()->setInitiatorHandle(initiatorHandle); return mConferenceCall->baseChannel(); - } - error->set(TP_QT_ERROR_NOT_AVAILABLE, "Impossible to merge calls"); - return Tp::BaseChannelPtr(); + //} + //error->set(TP_QT_ERROR_NOT_AVAILABLE, "Impossible to merge calls"); + //return Tp::BaseChannelPtr(); } QDBusObjectPath objpath(request["ofonoObjPath"].toString()); if (objpath.path().isEmpty()) { - objpath = mOfonoVoiceCallManager->dial(newPhoneNumber, "", success); + /// todo porting error handling + /*objpath =*/ mOfonoVoiceCallManager->dial(newPhoneNumber, "");//, success); } qDebug() << "success " << success; @@ -873,12 +876,12 @@ Tp::BaseChannelPtr oFonoConnection::createCallChannel(const QVariantMap &request oFonoCallChannel *channel = new oFonoCallChannel(this, newPhoneNumber, targetHandle, objpath.path()); channel->baseChannel()->setInitiatorHandle(initiatorHandle); mCallChannels[objpath.path()] = channel; - QObject::connect(channel, SIGNAL(destroyed()), SLOT(onCallChannelDestroyed())); - QObject::connect(channel, SIGNAL(closed()), SLOT(onCallChannelClosed())); - QObject::connect(channel, SIGNAL(merged()), SLOT(onCallChannelMerged())); - QObject::connect(channel, SIGNAL(splitted()), SLOT(onCallChannelSplitted())); - QObject::connect(channel, SIGNAL(multipartyCallHeld()), SLOT(onMultipartyCallHeld())); - QObject::connect(channel, SIGNAL(multipartyCallActive()), SLOT(onMultipartyCallActive())); + QObject::connect(channel, &oFonoCallChannel::destroyed, this, &oFonoConnection::onCallChannelDestroyed); + QObject::connect(channel, &oFonoCallChannel::closed, this, &oFonoConnection::onCallChannelClosed); + QObject::connect(channel, &oFonoCallChannel::merged, this, &oFonoConnection::onCallChannelMerged); + QObject::connect(channel, &oFonoCallChannel::splitted, this, &oFonoConnection::onCallChannelSplitted); + QObject::connect(channel, &oFonoCallChannel::multipartyCallHeld, this, &oFonoConnection::onMultipartyCallHeld); + QObject::connect(channel, &oFonoCallChannel::multipartyCallActive, this, &oFonoConnection::onMultipartyCallActive); qDebug() << channel; return channel->baseChannel(); } @@ -935,17 +938,17 @@ Tp::BaseChannelPtr oFonoConnection::createChannel(const QVariantMap &request, Tp return Tp::BaseChannelPtr(); } -OfonoMessageManager *oFonoConnection::messageManager() +QOfonoMessageManager *oFonoConnection::messageManager() { return mOfonoMessageManager; } -OfonoVoiceCallManager *oFonoConnection::voiceCallManager() +QOfonoVoiceCallManager *oFonoConnection::voiceCallManager() { return mOfonoVoiceCallManager; } -OfonoCallVolume *oFonoConnection::callVolume() +QOfonoCallVolume *oFonoConnection::callVolume() { return mOfonoCallVolume; } @@ -1106,13 +1109,13 @@ bool oFonoConnection::matchChannel(const Tp::BaseChannelPtr &channel, const QVar return (channelType == TP_QT_IFACE_CHANNEL_TYPE_TEXT) && BaseConnection::matchChannel(channel, request, error); } -void oFonoConnection::onOfonoCallAdded(const QString &call, const QVariantMap &properties) +void oFonoConnection::onOfonoCallAdded(const QString &call/*, const QVariantMap &properties*/) { - qDebug() << "new call" << call << properties; + qDebug() << "new call" << call;// << properties; bool yours; Tp::DBusError error; - QString lineIdentification = properties["LineIdentification"].toString(); + QString lineIdentification;// = properties["LineIdentification"].toString(); // check if there is an open channel for this call, if so, ignore it if (mCallChannels.keys().contains(call)) { @@ -1136,11 +1139,11 @@ void oFonoConnection::onOfonoCallAdded(const QString &call, const QVariantMap &p uint handle = ensureHandle(normalizedNumber); uint initiatorHandle = 0; - if (properties["State"] == "incoming" || properties["State"] == "waiting") { + //if (properties["State"] == "incoming" || properties["State"] == "waiting") { initiatorHandle = handle; - } else { - initiatorHandle = selfHandle(); - } + //} else { + // initiatorHandle = selfHandle(); + //} qDebug() << "initiatorHandle " < #include -// ofono-qt -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// telepathy-ofono +// qofono +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// telepathy-ofono + #include "ofonotextchannel.h" #include "ofonocallchannel.h" #include "emergencymodeiface.h" @@ -50,7 +51,7 @@ #include "ussdiface.h" -class oFonoConnection; +//class oFonoConnection; class oFonoTextChannel; class oFonoCallChannel; class oFonoConferenceCallChannel; @@ -90,9 +91,9 @@ class oFonoConnection : public Tp::BaseConnection uint newHandle(const QString &identifier); uint newGroupHandle(const QString &identifier); - OfonoMessageManager *messageManager(); - OfonoVoiceCallManager *voiceCallManager(); - OfonoCallVolume *callVolume(); + QOfonoMessageManager *messageManager(); + QOfonoVoiceCallManager *voiceCallManager(); + QOfonoCallVolume *callVolume(); QMap callChannels(); uint ensureHandle(const QString &phoneNumber); @@ -119,7 +120,7 @@ class oFonoConnection : public Tp::BaseConnection private Q_SLOTS: void onOfonoIncomingMessage(const QString &message, const QVariantMap &info); void onOfonoImmediateMessage(const QString &message, const QVariantMap &info); - void onOfonoCallAdded(const QString &call, const QVariantMap &properties); + void onOfonoCallAdded(const QString &call);//, const QVariantMap &properties); void onTextChannelClosed(); void onCallChannelClosed(); void onCallChannelDestroyed(); @@ -153,15 +154,15 @@ private Q_SLOTS: QMap mCallChannels; QStringList mModems; - OfonoModemManager *mOfonoModemManager; - OfonoMessageManager *mOfonoMessageManager; - OfonoVoiceCallManager *mOfonoVoiceCallManager; - OfonoCallVolume *mOfonoCallVolume; - OfonoNetworkRegistration *mOfonoNetworkRegistration; - OfonoMessageWaiting *mOfonoMessageWaiting; - OfonoSupplementaryServices *mOfonoSupplementaryServices; - OfonoSimManager *mOfonoSimManager; - OfonoModem *mOfonoModem; + QOfonoManager *mOfonoManager; + QOfonoMessageManager *mOfonoMessageManager; + QOfonoVoiceCallManager *mOfonoVoiceCallManager; + QOfonoCallVolume *mOfonoCallVolume; + QOfonoNetworkRegistration *mOfonoNetworkRegistration; + QOfonoMessageWaiting *mOfonoMessageWaiting; + QOfonoSupplementaryServices *mOfonoSupplementaryServices; + QOfonoSimManager *mOfonoSimManager; + QOfonoModem *mOfonoModem; Tp::SimplePresence mSelfPresence; MMSDManager *mMmsdManager; QMap mMmsdServices; diff --git a/debian/control b/debian/control index 022c05f..78520a5 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Build-Depends: cmake, dconf-cli, gnome-keyring, libmission-control-plugins-dev (>= 1:5.14.0), - libofono-qt-dev (>= 1.5), + libqofono-dev (>= 0.90), libphonenumber-dev, libqt5sql5-sqlite, libtelepathy-qt5-dev (>= 0.9.3), diff --git a/emergencymodeiface.cpp b/emergencymodeiface.cpp index 788746a..f5ad85d 100644 --- a/emergencymodeiface.cpp +++ b/emergencymodeiface.cpp @@ -136,7 +136,7 @@ ConnectionInterfaceEmergencyModeAdaptor::~ConnectionInterfaceEmergencyModeAdapto QStringList ConnectionInterfaceEmergencyModeAdaptor::EmergencyNumbers(const QDBusMessage& dbusMessage) { - if (!adaptee()->metaObject()->indexOfMethod("emergencyNumbers(ConnectionInterfaceEmergencyModeAdaptor::EmergencyNumbersContextPtr)") == -1) { + if (adaptee()->metaObject()->indexOfMethod("emergencyNumbers(ConnectionInterfaceEmergencyModeAdaptor::EmergencyNumbersContextPtr)") == -1) { dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"))); return QStringList(); } @@ -150,7 +150,7 @@ QStringList ConnectionInterfaceEmergencyModeAdaptor::EmergencyNumbers(const QDBu QString ConnectionInterfaceEmergencyModeAdaptor::CountryCode(const QDBusMessage& dbusMessage) { - if (!adaptee()->metaObject()->indexOfMethod("countryCode(ConnectionInterfaceEmergencyModeAdaptor::CountryCodeContextPtr)") == -1) { + if (adaptee()->metaObject()->indexOfMethod("countryCode(ConnectionInterfaceEmergencyModeAdaptor::CountryCodeContextPtr)") == -1) { dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"))); return QString(); } diff --git a/ofonocallchannel.cpp b/ofonocallchannel.cpp index 10402a6..678435f 100644 --- a/ofonocallchannel.cpp +++ b/ofonocallchannel.cpp @@ -20,7 +20,7 @@ oFonoCallChannel::oFonoCallChannel(oFonoConnection *conn, QString phoneNumber, uint targetHandle, QString voiceObj, QObject *parent): - OfonoVoiceCall(voiceObj), + QOfonoVoiceCall(parent), mIncoming(false), mRequestedHangup(false), mConnection(conn), @@ -30,6 +30,8 @@ oFonoCallChannel::oFonoCallChannel(oFonoConnection *conn, QString phoneNumber, u mMultiparty(false) { + setVoiceCallPath(voiceObj); + Tp::BaseChannelPtr baseChannel = Tp::BaseChannel::create(mConnection, TP_QT_IFACE_CHANNEL_TYPE_CALL, Tp::HandleTypeContact, targetHandle); Tp::BaseChannelCallTypePtr callType = Tp::BaseChannelCallType::create(baseChannel.data(), true, @@ -57,10 +59,10 @@ oFonoCallChannel::oFonoCallChannel(oFonoConnection *conn, QString phoneNumber, u mCallChannel->setHangupCallback(Tp::memFun(this,&oFonoCallChannel::onHangup)); mCallChannel->setAcceptCallback(Tp::memFun(this,&oFonoCallChannel::onAccept)); - QObject::connect(this, SIGNAL(hangupComplete(bool)), this, SLOT(onHangupComplete(bool))); - QObject::connect(this, SIGNAL(answerComplete(bool)), this, SLOT(onAnswerComplete(bool))); + QObject::connect(this, &oFonoCallChannel::hangupComplete, this, &oFonoCallChannel::onHangupComplete); + QObject::connect(this, &oFonoCallChannel::answerComplete, this, &oFonoCallChannel::onAnswerComplete); // init must be called after initialization, otherwise we will have no object path registered. - QTimer::singleShot(0, this, SLOT(init())); + QTimer::singleShot(0, this, &oFonoCallChannel::init); } Tp::CallState oFonoCallChannel::callState() @@ -70,20 +72,20 @@ Tp::CallState oFonoCallChannel::callState() void oFonoCallChannel::onSplit(Tp::DBusError *error) { - mConnection->voiceCallManager()->privateChat(path()); + mConnection->voiceCallManager()->privateChat(voiceCallPath()); } void oFonoCallChannel::onHangupComplete(bool status) { if (!status) { - QTimer::singleShot(2000, this, SLOT(hangup())); + QTimer::singleShot(2000, this, &oFonoCallChannel::hangup); } } void oFonoCallChannel::onAnswerComplete(bool status) { if (!status) { - QTimer::singleShot(1000, this, SLOT(answer())); + QTimer::singleShot(1000, this, &oFonoCallChannel::answer); } } @@ -148,13 +150,13 @@ void oFonoCallChannel::init() mCallChannel->setMembersFlags(memberFlags, identifiers, Tp::UIntList(), reason); mCallChannel->setCallState(Tp::CallStateInitialised, 0, reason, stateDetails); - QObject::connect(mBaseChannel.data(), SIGNAL(closed()), this, SLOT(deleteLater())); - QObject::connect(mConnection->callVolume(), SIGNAL(mutedChanged(bool)), SLOT(onOfonoMuteChanged(bool))); - QObject::connect(this, SIGNAL(stateChanged(QString)), SLOT(onOfonoCallStateChanged(QString))); - QObject::connect(mConnection->voiceCallManager(), SIGNAL(sendTonesComplete(bool)), SLOT(onDtmfComplete(bool))); - QObject::connect(this, SIGNAL(multipartyChanged(bool)), this, SLOT(onMultipartyChanged(bool))); + QObject::connect(mBaseChannel.data(), &Tp::BaseChannel::closed, this, &oFonoCallChannel::deleteLater); + QObject::connect(mConnection->callVolume(), &QOfonoCallVolume::mutedChanged, this, &oFonoCallChannel::onOfonoMuteChanged); + QObject::connect(this, &oFonoCallChannel::stateChanged, this, &oFonoCallChannel::onOfonoCallStateChanged); + QObject::connect(mConnection->voiceCallManager(), &QOfonoVoiceCallManager::sendTonesComplete, this, &oFonoCallChannel::onDtmfComplete); + QObject::connect(this, &oFonoCallChannel::multipartyChanged, this, &oFonoCallChannel::onMultipartyChanged); - QObject::connect(this, SIGNAL(disconnectReason(const QString &)), this, SLOT(onDisconnectReason(const QString &))); + QObject::connect(this, &oFonoCallChannel::disconnectReason, this, &oFonoCallChannel::onDisconnectReason); } void oFonoCallChannel::onDisconnectReason(const QString &reason) { @@ -181,11 +183,11 @@ void oFonoCallChannel::onOfonoMuteChanged(bool mute) void oFonoCallChannel::onHoldStateChanged(const Tp::LocalHoldState &state, const Tp::LocalHoldStateReason &reason, Tp::DBusError *error) { if (state == Tp::LocalHoldStateHeld && this->state() == "active") { - QObject::connect(mConnection->voiceCallManager(), SIGNAL(swapCallsComplete(bool)), this, SLOT(onSwapCallsComplete(bool))); + QObject::connect(mConnection->voiceCallManager(), &QOfonoVoiceCallManager::swapCallsComplete, this, &oFonoCallChannel::onSwapCallsComplete); mConnection->voiceCallManager()->swapCalls(); mHoldIface->setHoldState(Tp::LocalHoldStatePendingHold, Tp::LocalHoldStateReasonRequested); } else if (state == Tp::LocalHoldStateUnheld && this->state() == "held") { - QObject::connect(mConnection->voiceCallManager(), SIGNAL(swapCallsComplete(bool)), this, SLOT(onSwapCallsComplete(bool))); + QObject::connect(mConnection->voiceCallManager(), &QOfonoVoiceCallManager::swapCallsComplete, this, &oFonoCallChannel::onSwapCallsComplete); mConnection->voiceCallManager()->swapCalls(); mHoldIface->setHoldState(Tp::LocalHoldStatePendingUnhold, Tp::LocalHoldStateReasonRequested); } @@ -193,13 +195,13 @@ void oFonoCallChannel::onHoldStateChanged(const Tp::LocalHoldState &state, const void oFonoCallChannel::onSwapCallsComplete(bool success) { - if (!success && errorName() == "org.ofono.Error.InProgress") { - QTimer::singleShot(2000, mConnection->voiceCallManager(), SLOT(swapCalls())); + if (!success /*&& errorName() == "org.ofono.Error.InProgress" TODO: PORTING */) { + QTimer::singleShot(2000, mConnection->voiceCallManager(), &QOfonoVoiceCallManager::swapCalls); return; } Tp::LocalHoldState holdState = this->state() == "active" ? Tp::LocalHoldStateUnheld : Tp::LocalHoldStateHeld; Tp::LocalHoldStateReason reason = success ? Tp::LocalHoldStateReasonRequested : Tp::LocalHoldStateReasonResourceNotAvailable; - QObject::disconnect(mConnection->voiceCallManager(), SIGNAL(swapCallsComplete(bool)), this, SLOT(onSwapCallsComplete(bool))); + QObject::disconnect(mConnection->voiceCallManager(), &QOfonoVoiceCallManager::swapCallsComplete, this, &oFonoCallChannel::onSwapCallsComplete); mHoldIface->setHoldState(holdState, reason); } diff --git a/ofonocallchannel.h b/ofonocallchannel.h index 7361c00..364aa7d 100644 --- a/ofonocallchannel.h +++ b/ofonocallchannel.h @@ -26,13 +26,14 @@ #include #include -#include +// qofono +#include #include "connection.h" class oFonoConnection; -class oFonoCallChannel : public OfonoVoiceCall +class oFonoCallChannel : public QOfonoVoiceCall { Q_OBJECT public: diff --git a/ofonoconferencecallchannel.cpp b/ofonoconferencecallchannel.cpp index 07a08b3..f560622 100644 --- a/ofonoconferencecallchannel.cpp +++ b/ofonoconferencecallchannel.cpp @@ -151,13 +151,13 @@ void oFonoConferenceCallChannel::init() mDTMFIface->setStartToneCallback(Tp::memFun(this,&oFonoConferenceCallChannel::onDTMFStartTone)); mDTMFIface->setStopToneCallback(Tp::memFun(this,&oFonoConferenceCallChannel::onDTMFStopTone)); - QObject::connect(mBaseChannel.data(), SIGNAL(closed()), this, SLOT(deleteLater())); - QObject::connect(mConnection->callVolume(), SIGNAL(mutedChanged(bool)), SLOT(onOfonoMuteChanged(bool))); - QObject::connect(mConnection->voiceCallManager(), SIGNAL(sendTonesComplete(bool)), SLOT(onDtmfComplete(bool))); + QObject::connect(mBaseChannel.data(), &Tp::BaseChannel::closed, this, &oFonoConferenceCallChannel::deleteLater); + QObject::connect(mConnection->callVolume(), &QOfonoCallVolume::mutedChanged, this, &oFonoConferenceCallChannel::onOfonoMuteChanged); + QObject::connect(mConnection->voiceCallManager(), &QOfonoVoiceCallManager::sendTonesComplete, this, &oFonoConferenceCallChannel::onDtmfComplete); - QObject::connect(mConnection, SIGNAL(channelMerged(const QDBusObjectPath&)), this, SLOT(onChannelMerged(const QDBusObjectPath&))); - QObject::connect(mConnection, SIGNAL(channelSplitted(const QDBusObjectPath&)), this, SLOT(onChannelSplitted(const QDBusObjectPath&))); - QObject::connect(mConnection, SIGNAL(channelHangup(const QDBusObjectPath&)), this, SLOT(onChannelSplitted(const QDBusObjectPath&))); + QObject::connect(mConnection, &oFonoConnection::channelMerged, this, &oFonoConferenceCallChannel::onChannelMerged); + QObject::connect(mConnection, &oFonoConnection::channelSplitted, this, &oFonoConferenceCallChannel::onChannelSplitted); + QObject::connect(mConnection, &oFonoConnection::channelHangup, this, &oFonoConferenceCallChannel::onChannelSplitted); } void oFonoConferenceCallChannel::onOfonoMuteChanged(bool mute) @@ -178,11 +178,11 @@ void oFonoConferenceCallChannel::setConferenceActive(bool active) void oFonoConferenceCallChannel::onHoldStateChanged(const Tp::LocalHoldState &state, const Tp::LocalHoldStateReason &reason, Tp::DBusError *error) { if (state == Tp::LocalHoldStateHeld && mHoldIface->getHoldState() == Tp::LocalHoldStateUnheld) { - QObject::connect(mConnection->voiceCallManager(), SIGNAL(swapCallsComplete(bool)), this, SLOT(onSwapCallsComplete(bool))); + QObject::connect(mConnection->voiceCallManager(), &QOfonoVoiceCallManager::swapCallsComplete, this, &oFonoConferenceCallChannel::onSwapCallsComplete); mHoldIface->setHoldState(Tp::LocalHoldStatePendingHold, Tp::LocalHoldStateReasonRequested); mConnection->voiceCallManager()->swapCalls(); } else if (state == Tp::LocalHoldStateUnheld && mHoldIface->getHoldState() == Tp::LocalHoldStateHeld) { - QObject::connect(mConnection->voiceCallManager(), SIGNAL(swapCallsComplete(bool)), this, SLOT(onSwapCallsComplete(bool))); + QObject::connect(mConnection->voiceCallManager(), &QOfonoVoiceCallManager::swapCallsComplete, this, &oFonoConferenceCallChannel::onSwapCallsComplete); mHoldIface->setHoldState(Tp::LocalHoldStatePendingUnhold, Tp::LocalHoldStateReasonRequested); mConnection->voiceCallManager()->swapCalls(); } @@ -190,7 +190,7 @@ void oFonoConferenceCallChannel::onHoldStateChanged(const Tp::LocalHoldState &st void oFonoConferenceCallChannel::onSwapCallsComplete(bool success) { - QObject::disconnect(mConnection->voiceCallManager(), SIGNAL(swapCallsComplete(bool)), this, SLOT(onSwapCallsComplete(bool))); + QObject::disconnect(mConnection->voiceCallManager(), &QOfonoVoiceCallManager::swapCallsComplete, this, &oFonoConferenceCallChannel::onSwapCallsComplete); if (!success) { // only change hold state in case of failure. Successful action will happen through setConferenceActive() Tp::LocalHoldState holdState = mHoldIface->getHoldState() == Tp::LocalHoldStatePendingHold ? Tp::LocalHoldStateUnheld : Tp::LocalHoldStateHeld; diff --git a/ofonoconferencecallchannel.h b/ofonoconferencecallchannel.h index c66ba4d..da15d5d 100644 --- a/ofonoconferencecallchannel.h +++ b/ofonoconferencecallchannel.h @@ -26,8 +26,6 @@ #include #include -#include - #include "connection.h" class oFonoConnection; diff --git a/ofonotextchannel.cpp b/ofonotextchannel.cpp index c0c72f8..5071742 100644 --- a/ofonotextchannel.cpp +++ b/ofonotextchannel.cpp @@ -17,8 +17,8 @@ * Gustavo Pichorim Boiko */ -// ofono-qt -#include +// qofono +#include // telepathy-ofono #include "ofonotextchannel.h" @@ -117,7 +117,7 @@ oFonoTextChannel::oFonoTextChannel(oFonoConnection *conn, const QString &targetI mBaseChannel = baseChannel; mTextChannel = Tp::BaseChannelTextTypePtr::dynamicCast(mBaseChannel->interface(TP_QT_IFACE_CHANNEL_TYPE_TEXT)); mTextChannel->setMessageAcknowledgedCallback(Tp::memFun(this,&oFonoTextChannel::messageAcknowledged)); - QObject::connect(mBaseChannel.data(), SIGNAL(closed()), this, SLOT(deleteLater())); + QObject::connect(mBaseChannel.data(), &Tp::BaseChannel::closed, this, &oFonoTextChannel::deleteLater); } Tp::UIntList oFonoTextChannel::members() @@ -232,7 +232,7 @@ QString oFonoTextChannel::sendMessage(Tp::MessagePartList message, uint flags, T Q_FOREACH(const QString &phoneNumber, mPhoneNumbers) { QString realObjpath = mConnection->sendMMS(QStringList() << phoneNumber, attachments).path(); MMSDMessage *msg = new MMSDMessage(realObjpath, QVariantMap(), this); - QObject::connect(msg, SIGNAL(propertyChanged(QString,QVariant)), SLOT(onMMSPropertyChanged(QString,QVariant))); + QObject::connect(msg, &MMSDMessage::propertyChanged, this, &oFonoTextChannel::onMMSPropertyChanged); mPendingBroadcastMMS[realObjpath] = objpath; mPendingDeliveryReportUnknown[objpath] = handle; QTimer::singleShot(0, this, SLOT(onProcessPendingDeliveryReport())); @@ -256,7 +256,7 @@ QString oFonoTextChannel::sendMessage(Tp::MessagePartList message, uint flags, T return objpath; } MMSDMessage *msg = new MMSDMessage(objpath, QVariantMap(), this); - QObject::connect(msg, SIGNAL(propertyChanged(QString,QVariant)), SLOT(onMMSPropertyChanged(QString,QVariant))); + QObject::connect(msg, &MMSDMessage::propertyChanged, this, &oFonoTextChannel::onMMSPropertyChanged); mPendingDeliveryReportUnknown[objpath] = handle; QTimer::singleShot(0, this, SLOT(onProcessPendingDeliveryReport())); if (temporaryFiles.size() > 0) { @@ -269,8 +269,9 @@ QString oFonoTextChannel::sendMessage(Tp::MessagePartList message, uint flags, T if (mPhoneNumbers.size() == 1) { QString phoneNumber = mPhoneNumbers[0]; uint handle = mConnection->ensureHandle(phoneNumber); - objpath = mConnection->messageManager()->sendMessage(phoneNumber, body["content"].variant().toString(), success).path(); - if (objpath.isEmpty() || !success) { + /// TODO porting how does error handling work with qofono? + /*objpath = */ mConnection->messageManager()->sendMessage(phoneNumber, body["content"].variant().toString());//, success).path(); + /*if (objpath.isEmpty() || !success) { if (!success) { qWarning() << mConnection->messageManager()->errorName() << mConnection->messageManager()->errorMessage(); } else { @@ -282,7 +283,8 @@ QString oFonoTextChannel::sendMessage(Tp::MessagePartList message, uint flags, T QTimer::singleShot(0, this, SLOT(onProcessPendingDeliveryReport())); return objpath; } - OfonoMessage *msg = new OfonoMessage(objpath); + QOfonoMessage *msg = new QOfonoMessage(this); + msg->setMessagePath(objpath); if (msg->state() == "") { // message was already sent or failed too fast (this case is only reproducible with the emulator) msg->deleteLater(); @@ -292,24 +294,25 @@ QString oFonoTextChannel::sendMessage(Tp::MessagePartList message, uint flags, T } // FIXME: track pending messages only if delivery reports are enabled. We need a system config option for it. PendingMessagesManager::instance()->addPendingMessage(objpath, mPhoneNumbers[0]); - QObject::connect(msg, SIGNAL(stateChanged(QString)), SLOT(onOfonoMessageStateChanged(QString))); + QObject::connect(msg, &QOfonoMessage::stateChanged, this, &oFonoTextChannel::onOfonoMessageStateChanged);*/ return objpath; } else { // Broadcast sms bool someMessageSent = false; QString lastPhoneNumber; Q_FOREACH(const QString &phoneNumber, mPhoneNumbers) { - objpath = mConnection->messageManager()->sendMessage(phoneNumber, body["content"].variant().toString(), success).path(); + /*objpath =*/ mConnection->messageManager()->sendMessage(phoneNumber, body["content"].variant().toString());//, success).path(); lastPhoneNumber = phoneNumber; // dont fail if this is a broadcast chat as we cannot track individual messages - if (objpath.isEmpty() || !success) { + // TODo PORTING reenable error handling + /*if (objpath.isEmpty() || !success) { if (!success) { qWarning() << mConnection->messageManager()->errorName() << mConnection->messageManager()->errorMessage(); } else { error->set(TP_QT_ERROR_INVALID_ARGUMENT, mConnection->messageManager()->errorMessage()); } continue; - } + }*/ someMessageSent = true; } if (!someMessageSent) { @@ -320,7 +323,8 @@ QString oFonoTextChannel::sendMessage(Tp::MessagePartList message, uint flags, T QTimer::singleShot(0, this, SLOT(onProcessPendingDeliveryReport())); return objpath; } - OfonoMessage *msg = new OfonoMessage(objpath); + QOfonoMessage *msg = new QOfonoMessage(this); + msg->setMessagePath(objpath); if (msg->state() == "") { // message was already sent or failed too fast (this case is only reproducible with the emulator) msg->deleteLater(); @@ -330,7 +334,7 @@ QString oFonoTextChannel::sendMessage(Tp::MessagePartList message, uint flags, T // return only the last one in case of group chat for history purposes return objpath; } - QObject::connect(msg, SIGNAL(stateChanged(QString)), SLOT(onOfonoMessageStateChanged(QString))); + QObject::connect(msg, &QOfonoMessage::stateChanged, this, &oFonoTextChannel::onOfonoMessageStateChanged); return objpath; } } @@ -430,7 +434,7 @@ void oFonoTextChannel::onProcessPendingDeliveryReport() void oFonoTextChannel::onOfonoMessageStateChanged(QString status) { - OfonoMessage *msg = static_cast(sender()); + QOfonoMessage *msg = static_cast(sender()); if(msg) { Tp::DeliveryStatus delivery_status; if (status == "sent") { @@ -438,7 +442,7 @@ void oFonoTextChannel::onOfonoMessageStateChanged(QString status) msg->deleteLater(); } else if(status == "failed") { delivery_status = Tp::DeliveryStatusPermanentlyFailed; - PendingMessagesManager::instance()->removePendingMessage(msg->path()); + PendingMessagesManager::instance()->removePendingMessage(msg->messagePath()); msg->deleteLater(); } else if(status == "pending") { delivery_status = Tp::DeliveryStatusTemporarilyFailed; @@ -446,7 +450,7 @@ void oFonoTextChannel::onOfonoMessageStateChanged(QString status) delivery_status = Tp::DeliveryStatusUnknown; } - sendDeliveryReport(msg->path(), mConnection->ensureHandle(mPhoneNumbers[0]), delivery_status); + sendDeliveryReport(msg->messagePath(), mConnection->ensureHandle(mPhoneNumbers[0]), delivery_status); } } diff --git a/sqlitedatabase.cpp b/sqlitedatabase.cpp index 09bddbc..11fe8df 100644 --- a/sqlitedatabase.cpp +++ b/sqlitedatabase.cpp @@ -33,6 +33,12 @@ Q_DECLARE_METATYPE(sqlite3*) // custom sqlite function "comparePhoneNumbers" used to compare IDs if necessary void comparePhoneNumbers(sqlite3_context *context, int argc, sqlite3_value **argv) { + if (argc != 2) { + qCritical() << "comparePhoneNumbers called with " << argc << "arguments but requires two."; + sqlite3_result_error(context, "Number of arguments needs to be two", 0); + return; + } + QString arg1((const char*)sqlite3_value_text(argv[0])); QString arg2((const char*)sqlite3_value_text(argv[1])); sqlite3_result_int(context, (int)PhoneUtils::comparePhoneNumbers(arg1, arg2)); @@ -108,7 +114,7 @@ bool SQLiteDatabase::reopen() // make sure the database is up-to-date after reopening. // this is mainly required for the memory backend used for testing - createOrUpdateDatabase(); + return createOrUpdateDatabase(); } bool SQLiteDatabase::createOrUpdateDatabase() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 599916e..65670cf 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,9 +3,10 @@ include_directories( ${CMAKE_SOURCE_DIR} ) +find_package(Qt5 REQUIRED COMPONENTS Test) + macro(generate_test TESTNAME USE_DBUS) add_executable(${TESTNAME} ${ARGN} ${TESTNAME}.cpp) - qt5_use_modules(${TESTNAME} Core DBus Test) set(TEST_COMMAND ) if (${USE_DBUS}) set(TEST_COMMAND -p ${CMAKE_CURRENT_BINARY_DIR}/${TESTNAME} -p -xunitxml -p -o -p ${CMAKE_BINARY_DIR}/test_${TESTNAME}.xml) @@ -34,6 +35,7 @@ macro(generate_test TESTNAME USE_DBUS) target_link_libraries(${TESTNAME} ${TP_QT5_LIBRARIES} ${LibPhoneNumber_LIBRARIES} + Qt5::Core Qt5::DBus Qt5::Test ) endmacro(generate_test) diff --git a/tests/dbus-test-wrapper.sh.in b/tests/dbus-test-wrapper.sh.in index ac5f813..73af1ed 100755 --- a/tests/dbus-test-wrapper.sh.in +++ b/tests/dbus-test-wrapper.sh.in @@ -17,7 +17,7 @@ dconf write /org/gnome/empathy/use-conn false export PA_DISABLED=1 # start telepathy-ofono with the ofono-qt mock library -LD_PRELOAD=@CMAKE_CURRENT_BINARY_DIR@/mock/libofono-qt.so ${CMAKE_BINARY_DIR}/telepathy-ofono & +LD_PRELOAD=@CMAKE_CURRENT_BINARY_DIR@/mock/libqofono-qt5.so.0 ${CMAKE_BINARY_DIR}/telepathy-ofono & TP_OFONO_PID=$! sleep 2 diff --git a/tests/mock/CMakeLists.txt b/tests/mock/CMakeLists.txt index 948daec..09e9525 100644 --- a/tests/mock/CMakeLists.txt +++ b/tests/mock/CMakeLists.txt @@ -34,9 +34,10 @@ qt5_add_dbus_adaptor(library_SRCS VoiceCallManagerPrivate.xml voicecallmanagerpr qt5_add_dbus_adaptor(library_SRCS VoiceCallPrivate.xml voicecallprivate.h VoiceCallPrivate) qt5_add_dbus_adaptor(library_SRCS SimManagerPrivate.xml simmanagerprivate.h SimManagerPrivate) -add_library(ofono-qt-mock SHARED ${library_SRCS}) -set_target_properties(ofono-qt-mock PROPERTIES - OUTPUT_NAME "ofono-qt" +add_library(qofono-mock SHARED ${library_SRCS}) +set_target_properties(qofono-mock PROPERTIES + OUTPUT_NAME "qofono-qt5" + SOVERSION 0 ) # Set the library version and the SOVERSION @@ -44,4 +45,4 @@ set_target_properties(ofono-qt-mock PROPERTIES # SOVERSION ${HISTORY_VERSION_MAJOR} # VERSION ${HISTORY_VERSION_MAJOR}.${HISTORY_VERSION_MINOR}.${HISTORY_VERSION_PATCH}) -qt5_use_modules(ofono-qt-mock Core DBus) +qt5_use_modules(qofono-mock Core DBus) diff --git a/ussdiface.cpp b/ussdiface.cpp index 3887243..5dc9e9f 100644 --- a/ussdiface.cpp +++ b/ussdiface.cpp @@ -256,7 +256,7 @@ ConnectionInterfaceUSSDAdaptor::~ConnectionInterfaceUSSDAdaptor() void ConnectionInterfaceUSSDAdaptor::Initiate(const QString &command, const QDBusMessage& dbusMessage) { - if (!adaptee()->metaObject()->indexOfMethod("initiate(const QString &,ConnectionInterfaceUSSDAdaptor::InitiateContextPtr)") == -1) { + if (adaptee()->metaObject()->indexOfMethod("initiate(const QString &,ConnectionInterfaceUSSDAdaptor::InitiateContextPtr)") == -1) { dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"))); return; } @@ -271,7 +271,7 @@ void ConnectionInterfaceUSSDAdaptor::Initiate(const QString &command, const QDBu void ConnectionInterfaceUSSDAdaptor::Respond(const QString &reply, const QDBusMessage& dbusMessage) { - if (!adaptee()->metaObject()->indexOfMethod("respond(QConnectionInterfaceUSSDAdaptor::RespondContextPtr)") == -1) { + if (adaptee()->metaObject()->indexOfMethod("respond(QConnectionInterfaceUSSDAdaptor::RespondContextPtr)") == -1) { dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"))); return; } @@ -286,7 +286,7 @@ void ConnectionInterfaceUSSDAdaptor::Respond(const QString &reply, const QDBusMe void ConnectionInterfaceUSSDAdaptor::Cancel(const QDBusMessage& dbusMessage) { - if (!adaptee()->metaObject()->indexOfMethod("cancel(ConnectionInterfaceUSSDAdaptor::CancelContextPtr)") == -1) { + if (adaptee()->metaObject()->indexOfMethod("cancel(ConnectionInterfaceUSSDAdaptor::CancelContextPtr)") == -1) { dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"))); return; } diff --git a/voicemailiface.cpp b/voicemailiface.cpp index f152a5a..20d1c42 100644 --- a/voicemailiface.cpp +++ b/voicemailiface.cpp @@ -159,7 +159,7 @@ ConnectionInterfaceVoicemailAdaptor::~ConnectionInterfaceVoicemailAdaptor() bool ConnectionInterfaceVoicemailAdaptor::VoicemailIndicator(const QDBusMessage& dbusMessage) { - if (!adaptee()->metaObject()->indexOfMethod("voicemailIndicator(ConnectionInterfaceVoicemailAdaptor::VoicemailIndicatorContextPtr)") == -1) { + if (adaptee()->metaObject()->indexOfMethod("voicemailIndicator(ConnectionInterfaceVoicemailAdaptor::VoicemailIndicatorContextPtr)") == -1) { dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"))); return bool(); } @@ -173,7 +173,7 @@ bool ConnectionInterfaceVoicemailAdaptor::VoicemailIndicator(const QDBusMessage& QString ConnectionInterfaceVoicemailAdaptor::VoicemailNumber(const QDBusMessage& dbusMessage) { - if (!adaptee()->metaObject()->indexOfMethod("voicemailNumber(ConnectionInterfaceVoicemailAdaptor::VoicemailNumberContextPtr)") == -1) { + if (adaptee()->metaObject()->indexOfMethod("voicemailNumber(ConnectionInterfaceVoicemailAdaptor::VoicemailNumberContextPtr)") == -1) { dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"))); return QString(); } @@ -187,7 +187,7 @@ QString ConnectionInterfaceVoicemailAdaptor::VoicemailNumber(const QDBusMessage& uint ConnectionInterfaceVoicemailAdaptor::VoicemailCount(const QDBusMessage& dbusMessage) { - if (!adaptee()->metaObject()->indexOfMethod("voicemailCount(ConnectionInterfaceVoicemailAdaptor::VoicemailCountContextPtr)") == -1) { + if (adaptee()->metaObject()->indexOfMethod("voicemailCount(ConnectionInterfaceVoicemailAdaptor::VoicemailCountContextPtr)") == -1) { dbusConnection().send(dbusMessage.createErrorReply(TP_QT_ERROR_NOT_IMPLEMENTED, QLatin1String("Not implemented"))); return uint(); }