|
1 /* |
|
2 * Copyright (c) 2009 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 #include <qgraphicswidget> |
|
19 #include <hbmenu.h> |
|
20 #include <hbaction.h> |
|
21 #include <hbpushbutton.h> |
|
22 #include <hbdocumentloader.h> |
|
23 #include <hbinstance.h> |
|
24 #include <hbinputdialog.h> |
|
25 |
|
26 #include <hbindicator.h> |
|
27 #include <hbindicatorplugininterface.h> |
|
28 #include <hbindicatorinterface.h> |
|
29 |
|
30 #include "wlanindicatortest.h" |
|
31 #include "wlanindicatortestview.h" |
|
32 |
|
33 WlanIndicatorTestView::WlanIndicatorTestView(WlanIndicatorTest *appRef) : |
|
34 mAppRef(appRef) |
|
35 { |
|
36 bool ok = false; |
|
37 mWlanIap = "Access Point"; |
|
38 HbDocumentLoader loader; |
|
39 if (HbInstance::instance()->allMainWindows().value(0)->orientation() == Qt::Horizontal) { |
|
40 loader.load(":/docml/wlanindicatortestview.docml", &ok); |
|
41 } |
|
42 else { |
|
43 loader.load(":/docml/wlanindicatortestview_portrait.docml", &ok); |
|
44 } |
|
45 Q_ASSERT_X(ok, "Wlan Indicator Test", "Invalid docml file"); |
|
46 |
|
47 // Load the view by name from the xml file |
|
48 QGraphicsWidget *widget = loader.findWidget("view"); |
|
49 Q_ASSERT_X(widget != 0, "Wlan Indicator Test", "View not found"); |
|
50 |
|
51 setWidget(widget); |
|
52 |
|
53 HbMenu *viewMenu = qobject_cast<HbMenu *>(loader.findWidget("viewMenu")); |
|
54 Q_ASSERT_X(viewMenu != 0, "Wlan Indicator Test", "Menu not found"); |
|
55 setMenu(viewMenu); |
|
56 |
|
57 mTestButton2 = qobject_cast<HbPushButton *>(loader.findWidget("pushButton_2")); |
|
58 Q_ASSERT_X(mTestButton2 != 0, "Wlan Indicator Test", "Button2 not found"); |
|
59 |
|
60 mTestButton3 = qobject_cast<HbPushButton *>(loader.findWidget("pushButton_3")); |
|
61 Q_ASSERT_X(mTestButton3 != 0, "Wlan Indicator Test", "Button3 not found"); |
|
62 |
|
63 mTestButton4 = qobject_cast<HbPushButton *>(loader.findWidget("pushButton_4")); |
|
64 Q_ASSERT_X(mTestButton4 != 0, "Wlan Indicator Test", "Button4 not found"); |
|
65 |
|
66 mTestButton5 = qobject_cast<HbPushButton *>(loader.findWidget("pushButton_5")); |
|
67 Q_ASSERT_X(mTestButton5 != 0, "Wlan Indicator Test", "Button5 not found"); |
|
68 |
|
69 mTestButton6 = qobject_cast<HbPushButton *>(loader.findWidget("pushButton_6")); |
|
70 Q_ASSERT_X(mTestButton6 != 0, "Wlan Indicator Test", "Button6 not found"); |
|
71 |
|
72 mTestButton7 = qobject_cast<HbPushButton *>(loader.findWidget("pushButton_7")); |
|
73 Q_ASSERT_X(mTestButton7 != 0, "Wlan Indicator Test", "Button7 not found"); |
|
74 |
|
75 mTestButton8 = qobject_cast<HbPushButton *>(loader.findWidget("pushButton_8")); |
|
76 Q_ASSERT_X(mTestButton8 != 0, "Wlan Indicator Test", "Button8 not found"); |
|
77 |
|
78 HbAction *exitAction = qobject_cast<HbAction *>(loader.findObject("exitAction")); |
|
79 Q_ASSERT_X(exitAction != 0, "Wlan Indicator Test", "Exit action not found"); |
|
80 |
|
81 |
|
82 bool connectStatus = connect( |
|
83 mTestButton2, |
|
84 SIGNAL(clicked()), |
|
85 this, |
|
86 SLOT(handleWlanPushButtonPressed())); |
|
87 Q_ASSERT(connectStatus == true); |
|
88 connectStatus = connect( |
|
89 mTestButton3, |
|
90 SIGNAL(clicked()), |
|
91 this, |
|
92 SLOT(handleWlanPushButtonPressed())); |
|
93 Q_ASSERT(connectStatus == true); |
|
94 connectStatus = connect( |
|
95 mTestButton4, |
|
96 SIGNAL(clicked()), |
|
97 this, |
|
98 SLOT(handleWlanPushButtonPressed())); |
|
99 Q_ASSERT(connectStatus == true); |
|
100 connectStatus = connect( |
|
101 mTestButton5, |
|
102 SIGNAL(clicked()), |
|
103 this, |
|
104 SLOT(handleWlanPushButtonPressed())); |
|
105 Q_ASSERT(connectStatus == true); |
|
106 connectStatus = connect( |
|
107 mTestButton6, |
|
108 SIGNAL(clicked()), |
|
109 this, |
|
110 SLOT(handleGprsPushButtonPressed())); |
|
111 Q_ASSERT(connectStatus == true); |
|
112 connectStatus = connect( |
|
113 mTestButton7, |
|
114 SIGNAL(clicked()), |
|
115 this, |
|
116 SLOT(handleGprsPushButtonPressed())); |
|
117 Q_ASSERT(connectStatus == true); |
|
118 connectStatus = connect( |
|
119 mTestButton8, |
|
120 SIGNAL(clicked()), |
|
121 this, |
|
122 SLOT(handleWlanPushButtonPressed())); |
|
123 Q_ASSERT(connectStatus == true); |
|
124 connectStatus = connect( |
|
125 exitAction, |
|
126 SIGNAL(triggered(bool)), |
|
127 this, |
|
128 SIGNAL(exitTriggered())); |
|
129 Q_ASSERT(connectStatus == true); |
|
130 |
|
131 |
|
132 // Set correct orientation when drawing view first time. Orientation change |
|
133 // on the fly is not yet implemented |
|
134 if (HbInstance::instance()->allMainWindows().value(0)->orientation() == Qt::Horizontal) { |
|
135 bool loaded = false; |
|
136 loader.load( ":/docml/wlanindicatortestview.docml", "landscape", &loaded ); |
|
137 } |
|
138 else { |
|
139 bool loaded = false; |
|
140 loader.load( ":/docml/wlanindicatortestview_portrait.docml", "portrait", &loaded ); |
|
141 } |
|
142 } |
|
143 |
|
144 WlanIndicatorTestView::~WlanIndicatorTestView() |
|
145 { |
|
146 } |
|
147 |
|
148 |
|
149 |
|
150 void WlanIndicatorTestView::handleWlanPushButtonPressed() |
|
151 { |
|
152 HbPushButton *item = (HbPushButton *)sender(); |
|
153 |
|
154 QList<QVariant> list; |
|
155 QString test = item->text(); |
|
156 |
|
157 if (test == "No Wlan Networks") { |
|
158 list.insert(0,0); |
|
159 |
|
160 } else if (test == "Wlan Connected") { |
|
161 list.insert(0,1); |
|
162 list.insert(1,"lahna"); |
|
163 // list.insert(2,"lahna"); |
|
164 /* |
|
165 } else if (test == "Unknown Wlan Found") { |
|
166 list.insert(0,4); |
|
167 list.insert(1,12); |
|
168 } else if (test == "WLAN connected") { |
|
169 list.insert(0,5); |
|
170 list.insert(1,0); //no. of networks not used but must be there |
|
171 QString label("Connected to"); |
|
172 bool ok = false; |
|
173 mWlanIap = HbInputDialog::getText(label, mWlanIap, &ok, scene(), this); |
|
174 list.insert(2,mWlanIap); |
|
175 */ |
|
176 } |
|
177 |
|
178 HbIndicator indicator; |
|
179 if (test == "WLAN disconnected") { |
|
180 indicator.deactivate("com.nokia.hb.indicator.connectivity.wlanindicatorplugin/1.0"); |
|
181 } |
|
182 else { |
|
183 indicator.activate("com.nokia.hb.indicator.connectivity.wlanindicatorplugin/1.0", list); |
|
184 } |
|
185 |
|
186 int error = indicator.error(); |
|
187 |
|
188 } |
|
189 |
|
190 void WlanIndicatorTestView::handleGprsPushButtonPressed() |
|
191 { |
|
192 HbPushButton *item = (HbPushButton *)sender(); |
|
193 |
|
194 QList<QVariant> list; |
|
195 QString test = item->text(); |
|
196 |
|
197 HbIndicator indicator; |
|
198 |
|
199 if (test == "GPRS connected") { |
|
200 |
|
201 list.insert(0,"Sonera"); //dummy IAP name |
|
202 list.insert(1,"12345678"); //dummy connection id |
|
203 |
|
204 indicator.activate("com.nokia.hb.indicator.connectivity.cellularindicatorplugin/1.0", list); |
|
205 |
|
206 } else if (test == "GPRS disconnected") { |
|
207 |
|
208 indicator.deactivate("com.nokia.hb.indicator.connectivity.cellularindicatorplugin/1.0"); |
|
209 |
|
210 } |
|
211 |
|
212 int error = indicator.error(); |
|
213 |
|
214 } |
|
215 |