Commit 3f16d9d7 authored by Bhushan Shah's avatar Bhushan Shah 📱

Use qofono to retrieve modem name and use that

instead of depending on the hardcoded account0
parent fc640f98
......@@ -38,6 +38,8 @@ find_package(GStreamer 1.1.90 REQUIRED)
find_package(GLIB2 REQUIRED)
find_package(GObject REQUIRED)
find_package(Qofono REQUIRED)
include(CheckIncludeFiles)
plasma_install_package(look-and-feel org.kde.plasma.phone look-and-feel)
......
#=============================================================================
# Copyright (c) 2019 Bhushan Shah <bshah@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
find_package(PkgConfig)
pkg_check_modules(PC_Qofono QUIET qofono-qt5)
find_path(Qofono_INCLUDE_DIR
NAMES qofono.h
PATHS ${PC_Qofono_INCLUDE_DIRS}
PATH_SUFFIXES qofono-qt5
)
find_library(Qofono_LIBRARY
NAMES qofono-qt5
PATHS ${PC_Qofono_LIBRARY_DIRS}
)
set(Qofono_VERSION ${PC_Qofono_VERSION})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Qofono
FOUND_VAR Qofono_FOUND
REQUIRED_VARS
Qofono_LIBRARY
Qofono_INCLUDE_DIR
VERSION_VAR Qofono_VERSION
)
if(Qofono_FOUND)
set(Qofono_LIBRARIES ${Qofono_LIBRARY})
set(Qofono_INCLUDE_DIRS ${Qofono_INCLUDE_DIR})
set(Qofono_DEFINITIONS ${PC_Qofono_CFLAGS_OTHER})
endif()
mark_as_advanced(
Qofono_INCLUDE_DIR
Qofono_LIBRARY
)
install(FILES metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.dialer.desktop)
include_directories(${TELEPATHY_QT5_INCLUDE_DIR})
#
include_directories(${Qofono_INCLUDE_DIRS})
add_subdirectory(src)
......@@ -21,6 +21,7 @@ target_link_libraries(plasmaphonedialer
KF5::DBusAddons
KF5::Notifications
${TELEPATHY_QT5_LIBRARIES}
${Qofono_LIBRARIES}
)
install(TARGETS plasmaphonedialer ${INSTALL_TARGETS_DEFAULT_ARGS})
......
......@@ -42,6 +42,7 @@
#include <KAboutData>
#include <KDBusService>
#include <qofonomanager.h>
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
......@@ -137,9 +138,12 @@ int main(int argc, char **argv)
Tp::ClientRegistrarPtr registrar = Tp::ClientRegistrar::create(accountFactory, connectionFactory,
channelFactory, contactFactory);
Tp::AccountPtr simAccount = Tp::Account::create(TP_QT_ACCOUNT_MANAGER_BUS_NAME, QStringLiteral("/org/freedesktop/Telepathy/Account/ofono/ofono/account0"),
connectionFactory, channelFactory);
// we ask the ofono for the default modem, which is generally first modem
QOfonoManager *ofonoManager = new QOfonoManager;
const QString accountName = ofonoManager->modems().first();
Tp::AccountPtr simAccount = Tp::Account::create(TP_QT_ACCOUNT_MANAGER_BUS_NAME, QStringLiteral("/org/freedesktop/Telepathy/Account/ofono/ofono/") + accountName,
connection::Factory, channelFactory);
const QString packagePath("org.kde.phone.dialer");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment