|
1 /* |
|
2 * Copyright (c) 2002 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 * Bio control for Provisioning documents. |
|
16 * |
|
17 */ |
|
18 |
|
19 #include <hbapplication.h> |
|
20 #include <hbtoolbar.h> |
|
21 #include <hbaction.h> |
|
22 #include <HbMenu.h> |
|
23 #include <HbTextItem> |
|
24 #include <HbFontSpec> |
|
25 #include <HbMessageBox> |
|
26 #include <QGraphicsLinearLayout> |
|
27 #include <xqserviceprovider.h> |
|
28 #include <xqservicerequest.h> |
|
29 #include <xqserviceutil.h> |
|
30 #include <e32base.h> |
|
31 #include <flogger.h> |
|
32 #include <CWPNameValue.h> |
|
33 #include <CWPEngine.h> |
|
34 #include <CpQtSpView.h> |
|
35 #include <CpQtSpMainWindow.h> |
|
36 #include <HbGroupBox> |
|
37 #include <HbListWidget> |
|
38 #include <HbListWidgetItem> |
|
39 #include <HbLabel> |
|
40 #include <MSVSTD.H> |
|
41 #include <SMSCLNT.H> |
|
42 #include <MTCLREG.H> |
|
43 #include <SMUTHDR.H> |
|
44 #include <QDateTime> |
|
45 #include "ProvisioningDebug.h" |
|
46 #include "ProvisioningUIDs.h" |
|
47 #include <CWPBioControl.h> |
|
48 const QString DATE_TIME_FORMAT("dd.MM.yy hh:mm"); |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // CpQtSpView::CpQtSpView |
|
52 // Description: Construtor |
|
53 // ---------------------------------------------------------------------------- |
|
54 |
|
55 |
|
56 CpQtSpView::CpQtSpView(CpQtSp* service,CpQtSpMainWindow* ptr, QGraphicsItem *parent) |
|
57 : HbView(parent), iServiceProvider(service), window(ptr) |
|
58 { |
|
59 setTitle(hbTrId("txt_device_update_title_messaging")); |
|
60 iViewStatus = true; |
|
61 iOrientationFlag = false; |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------------------------- |
|
65 // CpQtSpView::~CpQtSpView |
|
66 // Description: Destructor |
|
67 // ---------------------------------------------------------------------------- |
|
68 |
|
69 |
|
70 CpQtSpView::~CpQtSpView() |
|
71 { |
|
72 } |
|
73 |
|
74 // ---------------------------------------------------------------------------- |
|
75 // CpQtSpView::corruptMessageDialog |
|
76 // Description: Construction of view for provisioning message |
|
77 // ---------------------------------------------------------------------------- |
|
78 |
|
79 void CpQtSpView::corruptMessageDialog(HbAction *action) |
|
80 { |
|
81 HbMessageBox *dlg = static_cast<HbMessageBox*>(sender()); |
|
82 if(action == dlg->primaryAction()) |
|
83 { |
|
84 window->closeWindow(); |
|
85 } |
|
86 } |
|
87 // ---------------------------------------------------------------------------- |
|
88 // CpQtSpView::constructView |
|
89 // Description: Construction of view for provisioning message |
|
90 // ---------------------------------------------------------------------------- |
|
91 |
|
92 void CpQtSpView::constructView() |
|
93 { |
|
94 iBio = iServiceProvider->returnBio(); |
|
95 TInt err( KErrNone ); |
|
96 TRAP(err, array = iBio->CollectItemsLC(); CleanupStack::Pop()); |
|
97 |
|
98 if(err != KErrNone) |
|
99 { |
|
100 array->ResetAndDestroy(); |
|
101 HbMessageBox *box = new HbMessageBox(hbTrId("txt_device_update_info_unable_to_open_message_f")); |
|
102 box->setAttribute(Qt::WA_DeleteOnClose); |
|
103 box->setTimeout(HbPopup::NoTimeout); |
|
104 box->open(this,SLOT(corruptMessageDialog(HbAction*))); |
|
105 } |
|
106 else |
|
107 { |
|
108 window->buildView(); |
|
109 } |
|
110 } |
|
111 // ---------------------------------------------------------------------------- |
|
112 // CpQtSpView::buildView |
|
113 // Description: Construction of view for provisioning message |
|
114 // ---------------------------------------------------------------------------- |
|
115 |
|
116 bool CpQtSpView::buildView(QGraphicsLinearLayout* layout) |
|
117 { |
|
118 //Gather information about provisioning message |
|
119 TMsvId tmsvid = iServiceProvider->returnId(); |
|
120 CMsvSession* session = iServiceProvider->returnSession(); |
|
121 CMsvEntry* entry = session->GetEntryL(tmsvid); |
|
122 entry->SetEntryL(tmsvid); |
|
123 TMsvEntry index = entry->Entry(); |
|
124 |
|
125 // Details about message sender |
|
126 TBufC<KLENGTH> details = index.iDetails; |
|
127 QString fromStringName((QChar*)details.Ptr(),details.Length()); |
|
128 QString fromString = "From: "; |
|
129 QString from; |
|
130 from.append(fromString); |
|
131 from.append(fromStringName); |
|
132 |
|
133 |
|
134 |
|
135 //Construction of group box |
|
136 group = new HbGroupBox(); |
|
137 connect(group,SIGNAL(toggled(bool)),this,SLOT(expand())); |
|
138 group->setHeading(fromStringName); |
|
139 HbLabel* label = new HbLabel(from); |
|
140 group->setContentWidget(label); |
|
141 group->setCollapsed(true); |
|
142 orientationChanges(); |
|
143 layout->addItem(group); |
|
144 iOrientationFlag = true; |
|
145 //Message recieved time |
|
146 _LIT(KUnixEpoch, "19700000:000000.000000"); |
|
147 QDateTime retTimeStamp; |
|
148 TTime timeStamp = index.iDate; |
|
149 TTime unixEpoch(KUnixEpoch); |
|
150 TTimeIntervalSeconds seconds; |
|
151 timeStamp.SecondsFrom(unixEpoch, seconds); |
|
152 timeStamp.DaysFrom(unixEpoch); |
|
153 retTimeStamp.setTime_t(seconds.Int()); |
|
154 QString qtime = retTimeStamp.toString(DATE_TIME_FORMAT); |
|
155 HbTextItem* time = new HbTextItem(qtime,this); |
|
156 layout->addItem(time); |
|
157 |
|
158 //Blank Line |
|
159 HbTextItem* blankLine = new HbTextItem("", this); |
|
160 layout->addItem(blankLine); |
|
161 |
|
162 //Details about save message |
|
163 QString cfgMsg = hbTrId("txt_device_update_dblist_configuration_message"); |
|
164 QString saveMsg = hbTrId("txt_device_update_dblist_product_code_val_save_to"); |
|
165 HbTextItem* mPrimaryItem1 = new HbTextItem(cfgMsg, this); |
|
166 HbTextItem* mSecondaryItem2 = new HbTextItem(saveMsg, this); |
|
167 |
|
168 //Provisioning setting details |
|
169 iPrimaryFont = new HbFontSpec(HbFontSpec::Primary); |
|
170 iSecondaryFont = new HbFontSpec(HbFontSpec::Secondary); |
|
171 |
|
172 QFont font = iPrimaryFont->font(); |
|
173 mPrimaryItem1->setFont(font); |
|
174 |
|
175 font = iSecondaryFont->font(); |
|
176 mSecondaryItem2->setFont(font); |
|
177 |
|
178 layout->addItem(mPrimaryItem1); |
|
179 layout->addItem(mSecondaryItem2); |
|
180 |
|
181 |
|
182 TBufC<KLENGTH> Name; |
|
183 TBufC<KLENGTH> Value; |
|
184 HbTextItem* mPrimaryItem[100]; |
|
185 HbTextItem* mSecondaryItem[KLENGTH]; |
|
186 HbTextItem* mBlank[KLENGTH]; |
|
187 |
|
188 QFont pfont = iPrimaryFont->font(); |
|
189 QFont sfont = iSecondaryFont->font(); |
|
190 |
|
191 |
|
192 TBuf<KLENGTH> currentTitle(KNullDesC); |
|
193 |
|
194 for( TInt item = 0; item < array->Count(); item++ ) |
|
195 { |
|
196 CWPNameValue* pair = ((*array)[item]); |
|
197 Name = pair->Name(); |
|
198 if(Name.Compare(currentTitle) !=0 ) |
|
199 { |
|
200 QString qname((QChar*)Name.Ptr(),Name.Length()); |
|
201 mPrimaryItem[item] = new HbTextItem(qname); |
|
202 mPrimaryItem[item]->setFont(pfont); |
|
203 mBlank[item] = new HbTextItem("", this); |
|
204 mBlank[item]->setFont(pfont); |
|
205 layout->addItem(mBlank[item]); |
|
206 layout->addItem(mPrimaryItem[item]); |
|
207 currentTitle.Copy(Name); |
|
208 } |
|
209 |
|
210 Value = pair->Value(); |
|
211 QString qvalue((QChar*)Value.Ptr(),Value.Length()); |
|
212 mSecondaryItem[item] = new HbTextItem(qvalue); |
|
213 mSecondaryItem[item]->setFont(sfont); |
|
214 layout->addItem(mSecondaryItem[item]); |
|
215 } |
|
216 |
|
217 array->ResetAndDestroy(); |
|
218 return true; |
|
219 } |
|
220 |
|
221 // ---------------------------------------------------------------------------- |
|
222 // CpQtSpView::saveProvisoningMessage |
|
223 // Description: Saves the provisioning message |
|
224 // ---------------------------------------------------------------------------- |
|
225 |
|
226 |
|
227 void CpQtSpView::saveProvisoningMessage() |
|
228 { |
|
229 iBio->SaveSettingsL(); |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------------------------------- |
|
233 // CpQtSpView::expand |
|
234 // Description: Alignement of groupbox according to orientation |
|
235 // ---------------------------------------------------------------------------- |
|
236 |
|
237 |
|
238 void CpQtSpView::expand() |
|
239 { |
|
240 this->orientationChanges(); |
|
241 } |
|
242 |
|
243 // ---------------------------------------------------------------------------- |
|
244 // CpQtSpView::orientationChanges |
|
245 // Description: Group box orientation changes |
|
246 // ---------------------------------------------------------------------------- |
|
247 |
|
248 void CpQtSpView::orientationChanges() |
|
249 { |
|
250 if(window->orientation() == Qt::Horizontal) |
|
251 { |
|
252 if(!group->isCollapsed()) |
|
253 { |
|
254 group->setMinimumSize(KLANDSCAPE,KEXPANDED); |
|
255 group->setMaximumSize(KLANDSCAPE,KEXPANDED); |
|
256 } |
|
257 else |
|
258 { |
|
259 group->setMinimumSize(KLANDSCAPE,KCOLLAPSED); |
|
260 group->setMaximumSize(KLANDSCAPE,KCOLLAPSED); |
|
261 } |
|
262 } |
|
263 else |
|
264 { |
|
265 if(!group->isCollapsed()) |
|
266 { |
|
267 group->setMinimumSize(KPORTRAIT,KEXPANDED); |
|
268 group->setMaximumSize(KPORTRAIT,KEXPANDED); |
|
269 } |
|
270 else |
|
271 { |
|
272 group->setMinimumSize(KPORTRAIT,KCOLLAPSED); |
|
273 group->setMaximumSize(KPORTRAIT,KCOLLAPSED); |
|
274 } |
|
275 } |
|
276 } |
|
277 |
|
278 // ---------------------------------------------------------------------------- |
|
279 // CpQtSpView::getOrientationFlag |
|
280 // Description: Get the Orientation status |
|
281 // ---------------------------------------------------------------------------- |
|
282 bool CpQtSpView::getOrientationFlag() |
|
283 { |
|
284 return iOrientationFlag; |
|
285 } |
|
286 // ---------------------------------------------------------------------------- |
|
287 // CpQtSpView::setHorizontal |
|
288 // Description: Landscape alignment |
|
289 // ---------------------------------------------------------------------------- |
|
290 |
|
291 |
|
292 void CpQtSpView::setHorizontal() |
|
293 { |
|
294 if(!group->isCollapsed()) |
|
295 { |
|
296 group->setMinimumSize(KPORTRAIT,KEXPANDED); |
|
297 group->setMaximumSize(KPORTRAIT,KEXPANDED); |
|
298 } |
|
299 else |
|
300 { |
|
301 group->setMinimumSize(KPORTRAIT,KCOLLAPSED); |
|
302 group->setMaximumSize(KPORTRAIT,KCOLLAPSED); |
|
303 } |
|
304 |
|
305 } |
|
306 |
|
307 // ---------------------------------------------------------------------------- |
|
308 // CpQtSpView::setVertical |
|
309 // Description: Portrait alignment |
|
310 // ---------------------------------------------------------------------------- |
|
311 |
|
312 |
|
313 void CpQtSpView::setVertical() |
|
314 { |
|
315 if(!group->isCollapsed()) |
|
316 { |
|
317 group->setMinimumSize(KLANDSCAPE,KEXPANDED); |
|
318 group->setMaximumSize(KLANDSCAPE,KEXPANDED); |
|
319 } |
|
320 else |
|
321 { |
|
322 group->setMinimumSize(KLANDSCAPE,KCOLLAPSED); |
|
323 group->setMaximumSize(KLANDSCAPE,KCOLLAPSED); |
|
324 } |
|
325 } |
|
326 |
|
327 // ---------------------------------------------------------------------------- |
|
328 // CpQtSpView::deleteMessage |
|
329 // Description: Deletion of provisioning message |
|
330 // ---------------------------------------------------------------------------- |
|
331 |
|
332 |
|
333 void CpQtSpView::deleteMessage() |
|
334 { |
|
335 TMsvId entryID = iServiceProvider->returnId(); |
|
336 CMsvSession* session = iServiceProvider->returnSession(); |
|
337 CMsvEntry* entry = session->GetEntryL(entryID); |
|
338 CleanupStack::PushL(entry); |
|
339 entry->DeleteL(entryID); |
|
340 CleanupStack::PopAndDestroy(entry); |
|
341 window->close(); |
|
342 } |
|
343 |
|
344 |
|
345 |
|
346 // ---------------------------------------------------------------------------- |
|
347 // CpQtSpView::requestCompleted |
|
348 // Description: Framework call |
|
349 // ---------------------------------------------------------------------------- |
|
350 |
|
351 void CpQtSpView::requestCompleted(const QVariant& /*value*/) |
|
352 { |
|
353 } |
|
354 |
|
355 // ---------------------------------------------------------------------------- |
|
356 // CpQtSp::CpQtSp |
|
357 // Description: constructor |
|
358 // ---------------------------------------------------------------------------- |
|
359 |
|
360 |
|
361 CpQtSp::CpQtSp(CpQtSpMainWindow *ptr, QObject* parent) |
|
362 : XQServiceProvider("com.nokia.services.MDM.Provisioning",parent) |
|
363 { |
|
364 window = ptr; |
|
365 publishAll(); |
|
366 } |
|
367 |
|
368 // ---------------------------------------------------------------------------- |
|
369 // CpQtSp::~CpQtSp |
|
370 // Description: destructor |
|
371 // ---------------------------------------------------------------------------- |
|
372 |
|
373 CpQtSp::~CpQtSp() |
|
374 { |
|
375 delete iObserver; |
|
376 delete iSession; |
|
377 delete iBioCtrl; |
|
378 } |
|
379 |
|
380 // ---------------------------------------------------------------------------- |
|
381 // CpQtSp::complete |
|
382 // Description: Framework call |
|
383 // ---------------------------------------------------------------------------- |
|
384 |
|
385 void CpQtSp::complete() |
|
386 { |
|
387 QString retvalue =""; |
|
388 completeRequest(1,retvalue); |
|
389 } |
|
390 |
|
391 // ---------------------------------------------------------------------------- |
|
392 // CpQtSp::ProcessMessage |
|
393 // Description: Messaging application calls this function via QTHighway |
|
394 // ---------------------------------------------------------------------------- |
|
395 |
|
396 QString CpQtSp::ProcessMessage(const QString& tmsvid) |
|
397 { |
|
398 iId = tmsvid.toInt(); |
|
399 TMsvSelectionOrdering sort; |
|
400 sort.SetShowInvisibleEntries(ETrue); |
|
401 iObserver = new(ELeave) CObserver; |
|
402 iSession = CMsvSession::OpenSyncL(*iObserver); |
|
403 iBioCtrl = CWPBioControl::NewL(iSession,iId,this); |
|
404 iBioCtrl->RestoreMsgL(); |
|
405 return ""; |
|
406 } |
|
407 |
|
408 void CpQtSp::authenticationStatus() |
|
409 { |
|
410 TInt ret = iBioCtrl->getAuth(); |
|
411 switch(ret) |
|
412 { |
|
413 case KAUTENTICATIONCANCEL: |
|
414 { |
|
415 window->close(); |
|
416 } |
|
417 break; |
|
418 |
|
419 case KAUTENTICATIONFAILURE: |
|
420 { |
|
421 CMsvEntry* entry = iSession->GetEntryL(iId); |
|
422 CleanupStack::PushL(entry); |
|
423 entry->DeleteL(iId); |
|
424 CleanupStack::PopAndDestroy(entry); |
|
425 window->close(); |
|
426 } |
|
427 break; |
|
428 |
|
429 case KAUTENTICATIONSUCCESS: |
|
430 { |
|
431 iBioCtrl->updateAuthetication(); |
|
432 emit showView(); |
|
433 setCurrentRequestAsync(); |
|
434 } |
|
435 break; |
|
436 } |
|
437 } |
|
438 |
|
439 // ---------------------------------------------------------------------------- |
|
440 // CpQtSp::returnId |
|
441 // Description: used by CpQtSpView |
|
442 // ---------------------------------------------------------------------------- |
|
443 |
|
444 TMsvId CpQtSp::returnId() |
|
445 { |
|
446 return iId; |
|
447 } |
|
448 |
|
449 // ---------------------------------------------------------------------------- |
|
450 // CpQtSp::returnSession |
|
451 // Description: used by CpQtSpView |
|
452 // ---------------------------------------------------------------------------- |
|
453 |
|
454 CMsvSession* CpQtSp::returnSession() |
|
455 { |
|
456 return iSession; |
|
457 } |
|
458 |
|
459 // ---------------------------------------------------------------------------- |
|
460 // CpQtSp::returnBio |
|
461 // Description: used by CpQtSpView |
|
462 // ---------------------------------------------------------------------------- |
|
463 |
|
464 CWPBioControl* CpQtSp::returnBio() |
|
465 { |
|
466 return iBioCtrl; |
|
467 } |