Skip to content

Commit

Permalink
Merge pull request #6 from neochapay/qt6
Browse files Browse the repository at this point in the history
Allow build with qt6
  • Loading branch information
rainemak authored Aug 31, 2023
2 parents 65508b4 + f698ed1 commit c20e4fd
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
16 changes: 13 additions & 3 deletions src/nemo-connectivity/connectionhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@
#include <QtDBus/QDBusPendingReply>
#include <QtDBus/QDBusPendingCall>
#include <QtDBus/QDBusPendingCallWatcher>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <connman-qt6/networkmanager.h>
#include <connman-qt6/networktechnology.h>
#else
#include <connman-qt5/networkmanager.h>
#include <connman-qt5/networktechnology.h>

#endif
namespace Nemo {

ConnectionHelper::ConnectionHelper(QObject *parent)
Expand Down Expand Up @@ -252,11 +255,18 @@ void ConnectionHelper::performRequest()
// for a Captive Portal redirect, in which case we should consider network
// connectivity to be unavailable (as it requires user intervention).
connect(reply, &QNetworkReply::finished, this, &ConnectionHelper::handleCanaryRequestFinished);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
connect(reply, &QNetworkReply::error, this, &ConnectionHelper::handleCanaryRequestError);
#else
connect(reply, static_cast<void (QNetworkReply::*)(QNetworkReply::NetworkError)>(&QNetworkReply::error),
this, &ConnectionHelper::handleCanaryRequestError);
#endif
}

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void ConnectionHelper::handleCanaryRequestError()
#else
void ConnectionHelper::handleCanaryRequestError(const QNetworkReply::NetworkError &)
#endif
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
reply->setProperty("isError", QVariant::fromValue<bool>(true));
Expand Down
15 changes: 12 additions & 3 deletions src/nemo-connectivity/connectionhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@
#define NEMO_CONNECTION_HELPER_H

#include <QObject>

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QNetworkConfigurationManager>
#include <QNetworkSession>
#endif
#include <QNetworkAccessManager>
#include <QNetworkReply>

#include <nemo-connectivity/global.h>

#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <connman-qt6/networkmanager.h>
#include <connman-qt6/networktechnology.h>
#include <connman-qt6/networkservice.h>
#else
#include <connman-qt5/networkmanager.h>
#include <connman-qt5/networktechnology.h>
#include <connman-qt5/networkservice.h>

#endif
#include <QTimer>

QT_BEGIN_NAMESPACE
Expand Down Expand Up @@ -88,7 +93,11 @@ class NEMO_CONNECTIVITY_EXPORT ConnectionHelper : public QObject

private Q_SLOTS:
void performRequest();
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
void handleCanaryRequestError();
#else
void handleCanaryRequestError(const QNetworkReply::NetworkError &error);
#endif
void handleCanaryRequestFinished();
void emitFailureIfNeeded(); // due to timeout.

Expand Down
5 changes: 4 additions & 1 deletion src/nemo-connectivity/mobiledataconnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@

#include <QObject>
#include <QLoggingCategory>
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <connman-qt6/networkservice.h>
#else
#include <connman-qt5/networkservice.h>

#endif
Q_DECLARE_LOGGING_CATEGORY(CONNECTIVITY)

namespace Nemo {
Expand Down
4 changes: 2 additions & 2 deletions src/nemo-connectivity/nemo-connectivity.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ INCLUDEPATH += ..

DEFINES += NEMO_BUILD_CONNECTIVITY_LIBRARY

PKGCONFIG += connman-qt5 \
PKGCONFIG += connman-qt$${QT_MAJOR_VERSION} \
qofonoext \
qofono-qt5
qofono-qt$${QT_MAJOR_VERSION}

SOURCES += \
connectionhelper.cpp \
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/plugin.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PLUGIN_IMPORT_PATH = Nemo/Connectivity
TEMPLATE = lib
CONFIG += qt plugin hide_symbols
QT = qml dbus
LIBS += -lconnman-qt5 -L../nemo-connectivity -lnemoconnectivity
LIBS += -lconnman-qt$${QT_MAJOR_VERSION} -L../nemo-connectivity -lnemoconnectivity
target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
INSTALLS += target

Expand Down

0 comments on commit c20e4fd

Please sign in to comment.