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
35#ifdef HAVE_BLUEZ_5
36#include <BtCommon.h>
37#endif
38
39namespace Buteo {
40
41class USBModedProxy;
42class NetworkManager;
43
48class TransportTracker : public QObject
49{
50 Q_OBJECT
51
52public:
57 TransportTracker(QObject *aParent = 0);
58
60 virtual ~TransportTracker();
61
67 bool isConnectivityAvailable(Sync::ConnectivityType aType) const;
68
69signals:
75 void connectivityStateChanged(Sync::ConnectivityType aType, bool aState);
76
82 void networkStateChanged(bool aState, Sync::InternetConnectionType aType);
83
87
91
92private slots:
93 void onUsbStateChanged(bool aConnected);
94
95#ifdef HAVE_BLUEZ_5
96 void onBtStateChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalidated);
97 void onBtInterfacesAdded(const QDBusObjectPath &path, const InterfacesMap &interfaces);
98 void onBtInterfacesRemoved(const QDBusObjectPath &path, const QStringList &interfaces);
99#endif
100
101 void onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType);
102
103private:
104 QMap<Sync::ConnectivityType, bool> iTransportStates;
105
106 USBModedProxy *iUSBProxy;
107
108 NetworkManager *iInternet;
109 QDBusConnection iSystemBus;
110 QString iDefaultBtAdapter;
111
112 mutable QMutex iMutex;
113
119 void updateState(Sync::ConnectivityType aType, bool aState);
120
121#ifdef SYNCFW_UNIT_TESTS
122 friend class TransportTrackerTest;
123 friend class SynchronizerTest;
124#endif
125
126#ifdef HAVE_BLUEZ_5
127 bool btConnectivityStatus();
128#endif
129};
130
131} // namespace Buteo
132
133#endif /* TRANSPORTTRACKER_H_ */
Class for managing network sessions.
Definition NetworkManager.h:44
void connectivityStateChanged(Sync::ConnectivityType aType, bool aState)
Signal emitted when a connectivity state changes.
bool isConnectivityAvailable(Sync::ConnectivityType aType) const
Checks the state of the given connectivity type.
Definition TransportTracker.cpp:121
void sessionError()
Signal emitted when opening a network session fails.
virtual ~TransportTracker()
Destructor.
Definition TransportTracker.cpp:116
void sessionConnected()
Signal emitted when a network session is successfully opened.
void networkStateChanged(bool aState, Sync::InternetConnectionType aType)
Signal emitted when a n/w state changes.
TransportTracker(QObject *aParent=0)
Constructor.
Definition TransportTracker.cpp:38
Proxy class for interface com.meego.usb_moded
Definition USBModedProxy.h:50
Definition SyncBackupAdaptor.h:41