ButeoSynchronizationFramework
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  *
6  * Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * version 2.1 as published by the Free Software Foundation.
11  *
12  * This library is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA
21  *
22  */
23 
24 #ifndef TRANSPORTTRACKER_H_
25 #define TRANSPORTTRACKER_H_
26 
27 #include "SyncCommonDefs.h"
28 #include <QObject>
29 #include <QMap>
30 #include <QMutex>
31 #include <QDBusVariant>
32 #include <QDBusConnection>
33 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
34 #include <QtSystemInfo/QSystemDeviceInfo>
35 #endif
36 
37 namespace Buteo {
38 
39 class USBModedProxy;
40 class NetworkManager;
41 
42 
47 class TransportTracker : public QObject
48 {
49  Q_OBJECT
50 
51 public:
52 
57  TransportTracker(QObject *aParent = 0);
58 
60  virtual ~TransportTracker();
61 
67  bool isConnectivityAvailable(Sync::ConnectivityType aType) const;
68 
69 signals:
70 
76  void connectivityStateChanged(Sync::ConnectivityType aType, bool aState);
77 
83  void networkStateChanged(bool aState, Sync::InternetConnectionType aType);
84 
87  void sessionConnected();
88 
91  void sessionError();
92 
93 private slots:
94 
95  void onUsbStateChanged(bool aConnected);
96 
97 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
98  void onBtStateChanged(bool aState);
99 #else
100  void onBtStateChanged(QString aKey, QDBusVariant aValue);
101 #endif
102 
103  void onInternetStateChanged(bool aConnected, Sync::InternetConnectionType aType);
104 
105 private:
106 
107  QMap<Sync::ConnectivityType, bool> iTransportStates;
108 
109  USBModedProxy *iUSBProxy;
110 
111 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
112  QtMobility::QSystemDeviceInfo iDeviceInfo;
113 #endif
114 
115  NetworkManager *iInternet;
116  QDBusConnection *iSystemBus;
117 
118  mutable QMutex iMutex;
119 
125  void updateState(Sync::ConnectivityType aType, bool aState);
126 
127 #ifdef SYNCFW_UNIT_TESTS
128  friend class TransportTrackerTest;
129  friend class SynchronizerTest;
130 #endif
131 
132  bool btConnectivityStatus();
133 
134 };
135 
136 }
137 
138 #endif /* TRANSPORTTRACKER_H_ */
virtual ~TransportTracker()
Destructor.
Definition: TransportTracker.cpp:110
Definition: AccountsHelper.h:31
void sessionConnected()
Signal emitted when a network session is successfully opened.
Definition: moc_TransportTracker.cpp:218
void sessionError()
Signal emitted when opening a network session fails.
Definition: moc_TransportTracker.cpp:224
TransportTracker(QObject *aParent=0)
Constructor.
Definition: TransportTracker.cpp:37
void connectivityStateChanged(Sync::ConnectivityType aType, bool aState)
Signal emitted when a connectivity state changes.
Definition: moc_TransportTracker.cpp:204
void networkStateChanged(bool aState, Sync::InternetConnectionType aType)
Signal emitted when a n/w state changes.
Definition: moc_TransportTracker.cpp:211
Class for managing network sessions.
Definition: NetworkManager.h:43
Class for tracking transport states.
Definition: TransportTracker.h:47
Proxy class for interface com.meego.usb_moded
Definition: USBModedProxy.h:50
bool isConnectivityAvailable(Sync::ConnectivityType aType) const
Checks the state of the given connectivity type.
Definition: TransportTracker.cpp:116