Buteo Synchronization Framework
TransportTracker.h
1/*
2 * This file is part of buteo-syncfw package
3 *
4 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
5 * 2019 Updated to use bluez5 by deloptes@gmail.com
6 *
7 * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * version 2.1 as published by the Free Software Foundation.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 *
23 */
24
25#ifndef TRANSPORTTRACKER_H_
26#define TRANSPORTTRACKER_H_
27
28#include "SyncCommonDefs.h"
29#include <QObject>
30#include <QMap>
31#include <QMutex>
32#include <QDBusVariant>
33#include <QDBusConnection>
34#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
35#include <QNetworkInformation>
36#endif
37#ifdef HAVE_BLUEZ_5
38#include <BtCommon.h>
39#endif
40
41namespace Buteo {
42
43class USBModedProxy;
44class NetworkManager;
45
46
51class TransportTracker : public QObject
52{
53 Q_OBJECT
54
55public:
56
61 TransportTracker(QObject *aParent = 0);
62
64 virtual ~TransportTracker();
65
71 bool isConnectivityAvailable(Sync::ConnectivityType aType) const;
72
73signals:
74
80#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
81 void connectivityStateChanged(QNetworkInformation::TransportMedium aType, bool aState);
82#else
83 void connectivityStateChanged(Sync::ConnectivityType aType, bool aState);
84#endif
90#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
91 void networkStateChanged(bool aConnected, QNetworkInformation::TransportMedium aType);
92#else
93 void networkStateChanged(bool aState, Sync::InternetConnectionType aType);
94#endif
97 void sessionConnected();
98
101 void sessionError();
102
103private slots:
104
105 void onUsbStateChanged(bool aConnected);
106
107#ifdef HAVE_BLUEZ_5
108 void onBtStateChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated);
109
110 void onBtInterfacesAdded(const QDBusObjectPath &path, const InterfacesMap &interfaces);
111
112 void onBtInterfacesRemoved(const QDBusObjectPath &path, const QStringList &interfaces);
113#endif
114#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
115 void onReachabilityChanged(QNetworkInformation::Reachability newReachability);
116 void onInternetStateChanged(QNetworkInformation::TransportMedium aType);
117#else
118 void onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType);
119#endif
120private:
121
122 QMap<Sync::ConnectivityType, bool> iTransportStates;
123
124 USBModedProxy *iUSBProxy;
125#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
126 QNetworkInformation *iInternet;
127 bool m_connected;
128 QNetworkInformation::TransportMedium m_aType;
129#else
130 NetworkManager *iInternet;
131#endif
132 QDBusConnection iSystemBus;
133 QString iDefaultBtAdapter;
134
135 mutable QMutex iMutex;
136
142#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
143 void updateState();
144#else
145 void updateState(Sync::ConnectivityType aType, bool aState);
146#endif
147#ifdef SYNCFW_UNIT_TESTS
148 friend class TransportTrackerTest;
149 friend class SynchronizerTest;
150#endif
151
152#ifdef HAVE_BLUEZ_5
153 bool btConnectivityStatus();
154#endif
155
156};
157
158} // namespace Buteo
159
160#endif /* TRANSPORTTRACKER_H_ */
Class for managing network sessions.
Definition NetworkManager.h:43
Class for tracking transport states.
Definition TransportTracker.h:52
void networkStateChanged(bool aConnected, QNetworkInformation::TransportMedium aType)
Signal emitted when a n/w state changes.
Definition moc_TransportTracker.cpp:274
bool isConnectivityAvailable(Sync::ConnectivityType aType) const
Checks the state of the given connectivity type.
Definition TransportTracker.cpp:130
void sessionError()
Signal emitted when opening a network session fails.
Definition moc_TransportTracker.cpp:287
virtual ~TransportTracker()
Destructor.
Definition TransportTracker.cpp:125
void sessionConnected()
Signal emitted when a network session is successfully opened.
Definition moc_TransportTracker.cpp:281
void connectivityStateChanged(QNetworkInformation::TransportMedium aType, bool aState)
Signal emitted when a connectivity state changes.
Definition moc_TransportTracker.cpp:267
TransportTracker(QObject *aParent=0)
Constructor.
Definition TransportTracker.cpp:43
Proxy class for interface com.meego.usb_moded
Definition USBModedProxy.h:50
Definition SyncBackupAdaptor.h:41