|
1 /* |
|
2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CONNECTIONVIEW_H__ |
|
19 #define __CONNECTIONVIEW_H__ |
|
20 |
|
21 #include <QObject> |
|
22 #include <HbMainWindow> |
|
23 #include <HbDialog> |
|
24 #include <QStringList> |
|
25 #include <HbWidget> |
|
26 #include <QtNetwork> |
|
27 #include <QGraphicsLinearLayout> |
|
28 #include <HbGroupBox> |
|
29 #include <HbScrollArea> |
|
30 #include <HbToolBar> |
|
31 #include <HbLabel> |
|
32 #include <qnetworksession.h> |
|
33 #include <qnetworkconfigmanager.h> |
|
34 |
|
35 QTM_USE_NAMESPACE |
|
36 |
|
37 class QSignalMapper; |
|
38 |
|
39 const QString bearer2G = "2G"; |
|
40 const QString bearerWCDMA = "WCDMA"; |
|
41 const QString bearerHSPA = "HSPA"; |
|
42 const QString bearerCDMA2000 = "CDMA2000"; |
|
43 const int timerValue = 3000; |
|
44 |
|
45 class ConnectionView: public HbMainWindow |
|
46 { |
|
47 Q_OBJECT |
|
48 |
|
49 public: |
|
50 /* Constructor */ |
|
51 ConnectionView(); |
|
52 |
|
53 /* Destructor */ |
|
54 ~ConnectionView(); |
|
55 |
|
56 /** |
|
57 * This is the re-implemented timerEvent function used to trigger |
|
58 * closing of the application. It is received every time the set timer expires. |
|
59 */ |
|
60 void timerEvent(QTimerEvent * /*event*/); |
|
61 |
|
62 private slots: |
|
63 /* Handles the changes in the cellular data connections */ |
|
64 void handleConfigurationChanged(const QNetworkConfiguration& config); |
|
65 |
|
66 /* Disonnects the iap given as a parameter */ |
|
67 void disconnectSelectedIap(int iapId); |
|
68 |
|
69 /* Disconnects all the cellular iaps */ |
|
70 void disconnectAll(); |
|
71 |
|
72 /* |
|
73 * Does the actual stopping of the sessions, once the session's |
|
74 * opened-signal is received |
|
75 */ |
|
76 void stopSessions(); |
|
77 |
|
78 /* Deletes the sender when the session opening fails */ |
|
79 void errorSessions(QNetworkSession::SessionError); |
|
80 |
|
81 private: |
|
82 |
|
83 /* Constructs the view */ |
|
84 void createView(); |
|
85 |
|
86 /* |
|
87 * Creates group boxes into the view for all the active cellular |
|
88 * connections. |
|
89 */ |
|
90 void createGroupBoxesForConnections(); |
|
91 |
|
92 /* |
|
93 * Updates the list of active cellular connections into the |
|
94 * list received as a reference parameter. |
|
95 */ |
|
96 void getActiveCellularConnections(QList<QNetworkConfiguration> &activeConfigurations); |
|
97 |
|
98 /* |
|
99 * Creates a single groupbox for the iap given as a paremeters. Attaches the |
|
100 * group boxes disconnect button to the disconnectSelectedIap slot |
|
101 */ |
|
102 void addGroupBox(int iapId, QString iapName); |
|
103 |
|
104 /* Clears the groupboxes from the view */ |
|
105 void clearGroupBoxView(); |
|
106 |
|
107 private: |
|
108 /* Pointer to network configuration manager */ |
|
109 QNetworkConfigurationManager* mNetConfigurationManager; |
|
110 |
|
111 /* Pointer to the main view of the window */ |
|
112 HbView *mMainView; |
|
113 |
|
114 /* The main vertical layout which contains the group box container */ |
|
115 QGraphicsLinearLayout* mMainLayout; |
|
116 |
|
117 /* The scroll area of the view */ |
|
118 HbScrollArea *mScrollArea; |
|
119 |
|
120 /* The layout into which the groupboxes are inserted */ |
|
121 QGraphicsLinearLayout *mBoxLayout; |
|
122 |
|
123 /* |
|
124 * Pointer to the signalmapper used in mapping the disconnect buttons clicks |
|
125 * to the disconnectSelectedIap function |
|
126 */ |
|
127 QSignalMapper *mSignalMapper; |
|
128 |
|
129 /* The amount of active cellular data connections */ |
|
130 int mConnectionCount; |
|
131 |
|
132 /* The toolbar on the view */ |
|
133 HbToolBar *mToolBar; |
|
134 |
|
135 /* The toolbar action which can be used to disconnect all the connections */ |
|
136 HbAction *mDisconnectAction; |
|
137 |
|
138 /* The label used to inform if there are no active connections */ |
|
139 HbLabel *mInfoLabel; |
|
140 |
|
141 /* The id of the timer used to close the application */ |
|
142 int mClosingTimer; |
|
143 |
|
144 /* definition for unit test purposes */ |
|
145 friend class TestConnectionView; |
|
146 |
|
147 }; |
|
148 |
|
149 |
|
150 #endif // __CONNECTIONVIEW_H__ |