Skip to content

Commit

Permalink
[libqofono] Eliminate dependency on QtXmlPatterns. MER#1963
Browse files Browse the repository at this point in the history
libqofono provisioning is broken and doesn't seem to be used anywhere,
disable it and get rid of unnecessary dependency on QtXmlPatterns.
  • Loading branch information
monich committed Jul 9, 2019
1 parent b5a1423 commit c474fef
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
3 changes: 0 additions & 3 deletions rpm/libqofono-qt5.spec
Expand Up @@ -7,15 +7,12 @@ Group: System/Libraries
License: LGPLv2.1
URL: https://git.sailfishos.org/mer-core/libqofono
Source0: %{name}-%{version}.tar.bz2
Requires: qt5-qtcore
Requires: mobile-broadband-provider-info
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5DBus)
BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: pkgconfig(Qt5Test)
BuildRequires: pkgconfig(Qt5XmlPatterns)

%description
This package contains Qt bindings for ofono cellular service
Expand Down
17 changes: 14 additions & 3 deletions src/qofonoconnectioncontext.cpp
Expand Up @@ -13,7 +13,9 @@
**
****************************************************************************/

#ifdef QOFONO_PROVISIONING
#include <QtXmlPatterns/QXmlQuery>
#endif

#include "qofonoconnectioncontext.h"
#include "qofonoconnectionmanager.h"
Expand Down Expand Up @@ -317,9 +319,9 @@ void QOfonoConnectionContext::onProvisionContextFinished(QDBusPendingCallWatcher
/*
* Tries to validate the context against the current registered network
**/
//check provision against mbpi
bool QOfonoConnectionContext::validateProvisioning()
{
#ifdef QOFONO_PROVISIONING
QString modem(modemPath());
qDebug() << modem;
if (modem.isEmpty())
Expand All @@ -330,15 +332,16 @@ bool QOfonoConnectionContext::validateProvisioning()
// This won't work because ofono queries are asynchronous:
if (netReg.status() == "registered")
return validateProvisioning(netReg.networkOperators().at(0),netReg.mcc(),netReg.mnc());
#endif // QOFONO_PROVISIONING
return false;
}

/*
* Tries to validate the context using the provider, mcc and mnc arguments
**/
//check provision against mbpi
bool QOfonoConnectionContext::validateProvisioning(const QString &providerString, const QString &mcc, const QString &mnc)
{
#ifdef QOFONO_PROVISIONING
qDebug() << providerString;
QXmlQuery query;
QString provider = providerString;
Expand Down Expand Up @@ -421,10 +424,14 @@ bool QOfonoConnectionContext::validateProvisioning(const QString &providerString

//we got here, must be ok
return true;
#else // QOFONO_PROVISIONING
return false;
#endif
}

void QOfonoConnectionContext::provisionForCurrentNetwork(const QString &type)
{
#ifdef QOFONO_PROVISIONING
QString modem(modemPath());
if (modem.isEmpty())
return;
Expand All @@ -434,6 +441,7 @@ void QOfonoConnectionContext::provisionForCurrentNetwork(const QString &type)

if (netReg.status() == "registered")
provision(netReg.name(), netReg.mcc(),netReg.mnc(), type);
#endif // QOFONO_PROVISIONING
}

/*
Expand All @@ -445,9 +453,9 @@ void QOfonoConnectionContext::provisionForCurrentNetwork(const QString &type)
* The only way to see if this is a working context is to try to activate the context.
*
**/
// provision context against mbpi
void QOfonoConnectionContext::provision(const QString &provider, const QString &mcc, const QString &mnc, const QString &type)
{
#ifdef QOFONO_PROVISIONING
QXmlQuery query;
query.setFocus(QUrl("/usr/share/mobile-broadband-provider-info/serviceproviders.xml"));

Expand Down Expand Up @@ -543,4 +551,7 @@ void QOfonoConnectionContext::provision(const QString &provider, const QString &
}
break;
}
Q_EMIT setPropertyFinished();
Q_EMIT provisioningFinished();
#endif // QOFONO_PROVISIONING
}
8 changes: 4 additions & 4 deletions src/qofonoconnectioncontext.h
Expand Up @@ -89,10 +89,10 @@ class QOFONOSHARED_EXPORT QOfonoConnectionContext : public QOfonoObject
bool isValid() const;
QString modemPath() const;

bool validateProvisioning(); //check provision against mbpi
bool validateProvisioning(const QString &provider, const QString &mcc, const QString &mnc); //check provision against mbpi
void provision(const QString &provider, const QString &mcc, const QString &mnc, const QString &type=QStringLiteral("internet")); // provision context against mbpi
void provisionForCurrentNetwork(const QString &type);
QT_DEPRECATED bool validateProvisioning(); //check provision against mbpi
QT_DEPRECATED bool validateProvisioning(const QString &provider, const QString &mcc, const QString &mnc); //check provision against mbpi
QT_DEPRECATED void provision(const QString &provider, const QString &mcc, const QString &mnc, const QString &type=QStringLiteral("internet")); // provision context against mbpi
QT_DEPRECATED void provisionForCurrentNetwork(const QString &type);

Q_INVOKABLE void disconnect();
Q_INVOKABLE bool provision();
Expand Down
9 changes: 6 additions & 3 deletions src/src.pro
Expand Up @@ -4,9 +4,12 @@
#
#-------------------------------------------------

QT += dbus xmlpatterns
QT -= gui
QMAKE_CXXFLAGS += -Wno-unused-parameter -Wno-psabi
QT += dbus

# QT += xmlpatterns
# DEFINES += QOFONO_PROVISIONING

QMAKE_CXXFLAGS += -Wno-unused-parameter

include(version.pri)

Expand Down
2 changes: 2 additions & 0 deletions test/auto/tests/tst_qofonoconnmancontext.cpp
Expand Up @@ -126,6 +126,7 @@ private slots:

}

#ifdef QOFONO_PROVISIONING
void tst_provisioning()
{
QSignalSpy conadd(m, SIGNAL(contextAdded(QString)));
Expand Down Expand Up @@ -175,6 +176,7 @@ private slots:
QCOMPARE(apn.takeFirst().at(0).toString(), QString("test"));
QCOMPARE(context->validateProvisioning(operatorString, mcc, mnc),false);
}
#endif // QOFONO_PROVISIONING

private:
QOfonoConnectionManager *m;
Expand Down
15 changes: 4 additions & 11 deletions test/auto/tst_qofono/tst_qofono.pro
Expand Up @@ -4,19 +4,12 @@
#
#-------------------------------------------------

QT += testlib dbus xmlpatterns
QT += testlib dbus # xmlpatterns
QT -= gui

equals(QT_MAJOR_VERSION, 4): {
LIBS += -lqofono
TARGET = tst_qofonotest
target.path = $$[QT_INSTALL_LIBS]/libqofono/tests
}
equals(QT_MAJOR_VERSION, 5): {
LIBS += -lqofono-qt5
TARGET = tst_qofonotest-qt5
target.path = $$[QT_INSTALL_LIBS]/libqofono-qt5/tests
}
LIBS += -lqofono-qt5
TARGET = tst_qofonotest-qt5
target.path = $$[QT_INSTALL_LIBS]/libqofono-qt5/tests

CONFIG += console
CONFIG -= app_bundle
Expand Down

0 comments on commit c474fef

Please sign in to comment.