|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Methods for DmFotaView. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <hbmainwindow.h> |
|
19 #include <hbpushbutton.h> |
|
20 #include <hbaction.h> |
|
21 #include <hbdialog.h> |
|
22 #include <sysutil.h> |
|
23 #include <hbscrollarea.h> |
|
24 #include <etel.h> |
|
25 #include <featmgr.h> |
|
26 #include <etelmm.h> |
|
27 #include <centralrepository.h> |
|
28 #include <sysversioninfo.h> |
|
29 #include "nsmldmsyncprivatecrkeys.h" |
|
30 #include "dmadvancedview.h" |
|
31 #include "dmfotaview.h" |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // DMFotaView::DMFotaView |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 DMFotaView::DMFotaView(HbMainWindow *mainWindow): |
|
39 mMainWindow(mainWindow),profilesView(NULL) |
|
40 { |
|
41 fotaPortraitView=0; |
|
42 fotaLandscapeView=0; |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // DMFotaView::~DMFotaView |
|
47 // |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 DMFotaView::~DMFotaView() |
|
51 { |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // DMFotaView::addFotaView |
|
56 // Creates and adds the Fota Portrait and Landscape View |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 bool DMFotaView::addFotaView() |
|
60 { |
|
61 connect( mMainWindow, SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( readSection(Qt::Orientation) ) ); |
|
62 |
|
63 bool ok = false; |
|
64 QString val,val2; |
|
65 loader.load(":/xml/devman.docml", &ok); |
|
66 ok = false; |
|
67 loader2.load(":/xml/devman.docml", &ok); |
|
68 // Exit if the file format is invalid |
|
69 Q_ASSERT_X(ok, "Device Manager", "Invalid docml file"); |
|
70 |
|
71 ok=false; |
|
72 loader.load(":/xml/devman.docml","Portrait", &ok); |
|
73 ok=false; |
|
74 loader2.load(":/xml/devman.docml","Landscape", &ok); |
|
75 |
|
76 // Load the view by name from the xml file |
|
77 fotaPortraitView = qobject_cast<HbView*>(loader.findWidget("p:view")); |
|
78 fotaLandscapeView = qobject_cast<HbView*>(loader2.findWidget("l:view")); |
|
79 |
|
80 |
|
81 HbAction *help = qobject_cast<HbAction*> (loader.findObject("help")); |
|
82 help->setText(QString("txt_common_menu_help")); |
|
83 QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp())); |
|
84 HbAction *exit = qobject_cast<HbAction*> (loader.findObject("exit")); |
|
85 exit->setText(QString("txt_common_menu_exit")); |
|
86 QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit())); |
|
87 |
|
88 help = qobject_cast<HbAction*>(loader2.findObject("help")); |
|
89 help->setText(QString("txt_common_menu_help")); |
|
90 QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp())); |
|
91 exit = qobject_cast<HbAction*>( loader2.findObject("exit")); |
|
92 exit->setText(QString("txt_common_menu_exit")); |
|
93 QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit())); |
|
94 |
|
95 mSoftKeyBackAction = new HbAction(Hb::BackAction ,this); |
|
96 mSoftKeyBackAction->setText("Back"); |
|
97 connect(mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(backtoMainWindow())); |
|
98 |
|
99 |
|
100 i=0; |
|
101 QString str; |
|
102 //Setting title text |
|
103 label = qobject_cast<HbLabel*> (loader.findWidget("p:title")); |
|
104 label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:title")); |
|
105 val = hbTrId("txt_device_update_subhead_device_updates"); |
|
106 label->setPlainText(val); |
|
107 label2->setPlainText(val); |
|
108 |
|
109 //Setting help text for update button |
|
110 label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel")); |
|
111 label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel")); |
|
112 val = hbTrId("txt_device_update_setlabel_to_update_your_device_s"); |
|
113 label->setPlainText(val); |
|
114 label2->setPlainText(val); |
|
115 |
|
116 HbScrollArea* area = qobject_cast<HbScrollArea*> (loader.findWidget("scrollArea")); |
|
117 area->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn); |
|
118 |
|
119 |
|
120 list1 << "label" << "label_1" << "label_2" << "label_3" << "label_4" << "label_5" << "label_6"<<"label_7"<<"label_8"<<"label_9"<<"label_10"<<"label_11"; |
|
121 list2 << "label_13" << "label_14" << "label_15" << "label_16" << "label_17" << "label_18" << "label_19"<<"label_20"<<"label_21"<<"label_22"<<"label_23"<<"label_24"; |
|
122 |
|
123 |
|
124 //Product Release |
|
125 TBuf< 1024 > prodrelease; |
|
126 prodrelease.Zero(); |
|
127 if(SysUtil::GetPRInformation(prodrelease)==KErrNone) |
|
128 { |
|
129 val = hbTrId("txt_device_update_dblist_product_release"); |
|
130 str = QString::fromUtf16(prodrelease.Ptr(), prodrelease.Length()); |
|
131 FormatList(val,str); |
|
132 } |
|
133 |
|
134 //Software version |
|
135 |
|
136 TBuf< KSysUtilVersionTextLength > swversion; |
|
137 TBuf< KSysUtilVersionTextLength > swversiondate; |
|
138 TBuf< KSysUtilVersionTextLength > typedesignator; |
|
139 TBuf< KSysUtilVersionTextLength > version; |
|
140 swversion.Zero(); |
|
141 version.Zero(); |
|
142 typedesignator.Zero(); |
|
143 swversiondate.Zero(); |
|
144 if( SysUtil::GetSWVersion(version)==KErrNone) |
|
145 { |
|
146 TInt len= version.Length(); |
|
147 TInt pos1 = version.Find(KSmlEOL); |
|
148 if( pos1 != KErrNotFound && len > pos1 ) |
|
149 { |
|
150 TBuf<KSysUtilVersionTextLength> version1; |
|
151 version1.Zero(); |
|
152 swversion.Append( version.Left(pos1)); |
|
153 version1.Append( version.Right( len-pos1-1 )); |
|
154 len= version1.Length(); |
|
155 pos1 = version1.Find(KSmlEOL); |
|
156 if( pos1 != KErrNotFound && len > pos1 ) |
|
157 { |
|
158 swversiondate.Append(version1.Left( pos1 )); |
|
159 version.Zero(); |
|
160 version.Append( version1.Right( len-pos1-1 )); |
|
161 len= version.Length(); |
|
162 pos1 = version.Find(KSmlEOL); |
|
163 if( pos1 != KErrNotFound && len > pos1 ) |
|
164 { |
|
165 typedesignator.Append(version.Left(pos1)); |
|
166 } |
|
167 } |
|
168 } |
|
169 val = hbTrId("txt_device_update_dblist_software_version"); |
|
170 str = QString::fromUtf16(swversion.Ptr(), swversion.Length()); |
|
171 FormatList(val,str); |
|
172 } |
|
173 |
|
174 //Model |
|
175 RTelServer telServer; |
|
176 User::LeaveIfError( telServer.Connect() ); |
|
177 RTelServer::TPhoneInfo teleinfo; |
|
178 User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) ); |
|
179 RMobilePhone phone; |
|
180 User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) ); |
|
181 User::LeaveIfError(phone.Initialise()); |
|
182 TUint32 teleidentityCaps; |
|
183 phone.GetIdentityCaps( teleidentityCaps ); |
|
184 RMobilePhone::TMobilePhoneIdentityV1 telid; |
|
185 TRequestStatus status; |
|
186 phone.GetPhoneId( status, telid ); |
|
187 User::WaitForRequest( status ); |
|
188 TBuf <50> imei; |
|
189 if (status==KErrNone) |
|
190 { |
|
191 TBuf<100> phoneName; |
|
192 phoneName.Copy( telid.iModel ); |
|
193 imei.Copy(telid.iSerialNumber); |
|
194 if( phoneName.Length()>0 ) |
|
195 { |
|
196 val = hbTrId("txt_device_update_dblist_model"); |
|
197 str = QString::fromUtf16(phoneName.Ptr(), phoneName.Length()); |
|
198 FormatList(val,str); |
|
199 } |
|
200 } |
|
201 phone.Close(); |
|
202 telServer.Close(); |
|
203 |
|
204 //type |
|
205 if(typedesignator.Length()>0) |
|
206 { |
|
207 val = hbTrId("txt_device_update_dblist_type"); |
|
208 str = QString::fromUtf16(typedesignator.Ptr(), typedesignator.Length()); |
|
209 FormatList(val,str); |
|
210 } |
|
211 |
|
212 //Product Code |
|
213 /* TInt runtimesupport(0); |
|
214 CRepository* cenrep = NULL; |
|
215 TRAPD( error, cenrep = CRepository::NewL( KCRUidNSmlDMSyncApp ) ); |
|
216 if(error) |
|
217 { |
|
218 runtimesupport=1; |
|
219 } |
|
220 if ( cenrep ) |
|
221 { |
|
222 cenrep->Get( KNsmlDmRuntimeVerSupport, runtimesupport ); |
|
223 delete cenrep; cenrep = NULL; |
|
224 } |
|
225 if(runtimesupport) |
|
226 { */ |
|
227 TBuf<KSysUtilVersionTextLength> productcode; |
|
228 productcode.Zero(); |
|
229 TInt error = SysVersionInfo::GetVersionInfo(SysVersionInfo::EProductCode, productcode); |
|
230 if(error ==KErrNone ) |
|
231 { |
|
232 if( productcode.Length()>0 ) |
|
233 { |
|
234 val = hbTrId("txt_device_update_dblist_product_code"); |
|
235 str = QString::fromUtf16(productcode.Ptr(), productcode.Length()); |
|
236 FormatList(val,str); |
|
237 } |
|
238 } |
|
239 |
|
240 //IMEI |
|
241 if(imei.Length()>0) |
|
242 { |
|
243 val = hbTrId("txt_device_update_dblist_imei"); |
|
244 str = QString::fromUtf16(imei.Ptr(), imei.Length()); |
|
245 FormatList(val,str); |
|
246 } |
|
247 |
|
248 |
|
249 val = hbTrId("txt_device_update_button_update"); |
|
250 HbPushButton *updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update")); |
|
251 updateButton->setText(val); |
|
252 QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate())); |
|
253 updateButton = qobject_cast<HbPushButton*>(loader2.findWidget("l:update")); |
|
254 updateButton->setText(val); |
|
255 QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate())); |
|
256 |
|
257 val = hbTrId("txt_device_update_button_advanced"); |
|
258 HbPushButton *advancedButton = qobject_cast<HbPushButton*>(loader.findWidget("p:advanced")); |
|
259 advancedButton->setText(val); |
|
260 QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager())); |
|
261 advancedButton = qobject_cast<HbPushButton*>(loader2.findWidget("l:advanced")); |
|
262 advancedButton->setText(val); |
|
263 QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager())); |
|
264 |
|
265 |
|
266 mMainWindow->addView(fotaPortraitView); |
|
267 mMainWindow->addView(fotaLandscapeView); |
|
268 |
|
269 if(mMainWindow->orientation()==Qt::Vertical) |
|
270 mMainWindow->setCurrentView(fotaPortraitView); |
|
271 else |
|
272 mMainWindow->setCurrentView(fotaLandscapeView); |
|
273 return ETrue; |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // DMFotaView::CheckforUpdate |
|
278 // Checks for updates from the default server |
|
279 // ----------------------------------------------------------------------------- |
|
280 // |
|
281 void DMFotaView::CheckforUpdate() |
|
282 { |
|
283 // if(no default profile defined) |
|
284 HbDocumentLoader loader; |
|
285 bool ok = false; |
|
286 loader.load(":/xml/updatedialog.docml", &ok); |
|
287 QString val; |
|
288 // Exit if the file format is invalid |
|
289 Q_ASSERT_X(ok, "Device Manager", "Invalid docml file"); |
|
290 HbDialog* dialog = qobject_cast<HbDialog*>(loader.findWidget("UpdateDialog")); |
|
291 |
|
292 label=qobject_cast<HbLabel*>(loader.findWidget("DialogText")); |
|
293 val = hbTrId("txt_device_update_info_no_server_configured_to_get"); |
|
294 label->setPlainText(val); |
|
295 dialog->setDismissPolicy(HbPopup::TapAnywhere); |
|
296 dialog->setTimeout(HbPopup::StandardTimeout); |
|
297 dialog->setAttribute(Qt::WA_DeleteOnClose, true); |
|
298 dialog->exec(); |
|
299 //Else connect |
|
300 /*TInt iProfileId= 1000000; |
|
301 iSession.OpenL(); |
|
302 profile.OpenL(iSession,iProfileId); |
|
303 //openconnection |
|
304 iSyncJob.CreateL( iSession, iProfileId );*/ |
|
305 } |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // DMFotaView::AdvancedDeviceManager |
|
309 // Displays the Profiles view |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 void DMFotaView::AdvancedDeviceManager() |
|
313 { |
|
314 |
|
315 qDebug("omadm DeviceManagerUi::AdvancedDeviceManager"); |
|
316 if(!profilesView) |
|
317 { |
|
318 qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 1"); |
|
319 profilesView = new DmAdvancedView(mMainWindow,this); |
|
320 qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 2"); |
|
321 bool loadingok = profilesView->displayItems(); |
|
322 if(loadingok) |
|
323 {qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 3"); |
|
324 mMainWindow->addView(profilesView); |
|
325 qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 4"); |
|
326 profilesView->setBackBehavior(); |
|
327 qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 5"); |
|
328 mMainWindow->setCurrentView(profilesView); |
|
329 qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 6"); |
|
330 } |
|
331 else |
|
332 { |
|
333 qFatal("omadm Unable to read groupbox.docml"); |
|
334 |
|
335 } |
|
336 } |
|
337 else |
|
338 { |
|
339 profilesView->setBackBehavior(); |
|
340 mMainWindow->setCurrentView(profilesView); |
|
341 } |
|
342 } |
|
343 |
|
344 // ----------------------------------------------------------------------------- |
|
345 // DMFotaView::FormatList |
|
346 // Adds data to the details list |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 void DMFotaView::FormatList(QString val,QString str) |
|
350 { |
|
351 label = qobject_cast<HbLabel*> (loader.findWidget(list1[i])); |
|
352 label2 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++])); |
|
353 label3 = qobject_cast<HbLabel*> (loader.findWidget(list1[i])); |
|
354 label4 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++])); |
|
355 label->setPlainText(val); |
|
356 label2->setPlainText(val); |
|
357 label3->setPlainText(str); |
|
358 label4->setPlainText(str); |
|
359 label->setVisible(ETrue); |
|
360 label2->setVisible(ETrue); |
|
361 label3->setVisible(ETrue); |
|
362 label4->setVisible(ETrue); |
|
363 } |
|
364 // ----------------------------------------------------------------------------- |
|
365 // DMFotaView::backtoMainWindow |
|
366 // Enables switching between views |
|
367 // ----------------------------------------------------------------------------- |
|
368 // |
|
369 void DMFotaView::backtoMainWindow() |
|
370 { |
|
371 qApp->quit(); |
|
372 } |
|
373 |
|
374 // ----------------------------------------------------------------------------- |
|
375 // DMFotaView::OnHelp |
|
376 // Displays Help contents |
|
377 // ----------------------------------------------------------------------------- |
|
378 // |
|
379 void DMFotaView::OnHelp() |
|
380 { |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // DMFotaView::OnExit |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 void DMFotaView::OnExit() |
|
388 { |
|
389 qApp->quit(); |
|
390 } |
|
391 |
|
392 void DMFotaView::readSection( Qt::Orientation orientation ) |
|
393 { |
|
394 if(mMainWindow->currentView() == fotaPortraitView || mMainWindow->currentView() == fotaLandscapeView) |
|
395 { |
|
396 if( orientation == Qt::Vertical ) { |
|
397 // reading "portrait" section |
|
398 mMainWindow->setCurrentView(fotaPortraitView); |
|
399 } |
|
400 else { |
|
401 // reading "landscape" section |
|
402 mMainWindow->setCurrentView(fotaLandscapeView); |
|
403 } |
|
404 } |
|
405 else if(mMainWindow->currentView()==profilesView) |
|
406 { |
|
407 profilesView->reLayout(orientation); |
|
408 } |
|
409 |
|
410 } |
|
411 |
|
412 |
|
413 |