|
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 Operator Logos. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "OperatorLogoBioControl.h" // COperatorLogoBioControl |
|
23 #include "OperatorLogoOTAConv.h" // converter |
|
24 |
|
25 #include <centralrepository.h> |
|
26 #include <settingsinternalcrkeys.h> |
|
27 #include <StringLoader.h> // StringLoader (iCoeEnv) |
|
28 #include <msgbiocontrolObserver.h> // MMsgBioControlObserver |
|
29 #include <OpLogoBC.rsg> // resouce identifiers |
|
30 #include <MsgBioUtils.h> // MsgBioUtils |
|
31 #include <bldvariant.hrh> |
|
32 #include <featmgr.h> // Feature manager |
|
33 #include <csxhelp/smart.hlp.hrh> |
|
34 #include <mmtsy_names.h> |
|
35 #include <AknUtils.h> |
|
36 #include <msvapi.h> // CMsvEntry |
|
37 #include <aknlayoutscalable_apps.cdl.h> |
|
38 #include <MIHLScaler.h> // MIHLScaler |
|
39 |
|
40 #ifdef RD_PHONE_CLIENT_EXT |
|
41 #include <CPhCltImageHandler.h> |
|
42 #include <CPhCltImageParams.h> |
|
43 #include <CPhCltBaseImageParams.h> |
|
44 #else |
|
45 #include <CPhCltExtImageHandler.h> // CPhCltExtImageHandler |
|
46 #include <CPhCltExtImageParams.h> // CPhCltExtImageParams |
|
47 #include <CPhCltExtBaseImageParams.h> |
|
48 #include <PhCltExt.h> // CPhCltExtFactory |
|
49 #endif |
|
50 |
|
51 #include <mmsvattachmentmanager.h> |
|
52 #include <mmsvattachmentmanagersync.h> |
|
53 |
|
54 |
|
55 |
|
56 // CONSTANTS |
|
57 |
|
58 const TInt KLogoMaxWidthPixels = 97; |
|
59 const TInt KLogoMaxHeightPixels = 25; |
|
60 const TInt KUseLogo = 0; |
|
61 const TInt KFirstMenuItem = 1; |
|
62 const TInt KLineFeed = 0x0a; |
|
63 const TInt KOtaBitmapInfoField = 0x00; |
|
64 // for infofield containing number of animated icons one: |
|
65 const TInt KOtaBitmapInfoFieldAnim = 0x01; |
|
66 const TInt KOtaBitmapColorDepth = 0x01; |
|
67 const TInt KVersionNumberZero = 48; // ASCII value for '0' |
|
68 const TInt KNumOfBytesMccMnc = 3; |
|
69 const TInt KNumOfBytesExpDay = 19; |
|
70 const TInt KPixelsInByte = 8; |
|
71 |
|
72 _LIT(KOpLogoCResourceFileName, "oplogoBC.rsc"); |
|
73 |
|
74 _LIT(KTempOtaFileName,"oltmp.ota"); |
|
75 |
|
76 _LIT(KPanicOplogoBC, "OpLogo"); |
|
77 |
|
78 #ifndef RD_PHONE_CLIENT_EXT |
|
79 // PhoneClient Extension library |
|
80 _LIT( KDllPhoneClientExt, "PhoneClientExt.dll" ); |
|
81 #endif |
|
82 |
|
83 enum TOpLogoPanics |
|
84 { |
|
85 EPanicBadImageContent = 1, |
|
86 EPanicNullFileName, |
|
87 EPanicScalingError, |
|
88 EPanicOnlyOneLibraryAllowed, |
|
89 EPanicNullPtr |
|
90 }; |
|
91 |
|
92 // ========================================================== |
|
93 |
|
94 /** |
|
95 * Helper class which allows COperatorLogoBioControl to receive a callback |
|
96 * to it's callback method when an asynchronous operation has finished. |
|
97 * CAsyncCallBack needed tweaking since it is ment for callback only, and |
|
98 * it completes the task immediately. |
|
99 */ |
|
100 class COpLogoAOCallBack: public CAsyncCallBack |
|
101 { |
|
102 public: |
|
103 |
|
104 COpLogoAOCallBack( const TCallBack &aCallBack, TInt aPriority ) |
|
105 : CAsyncCallBack( aCallBack, aPriority ) |
|
106 { |
|
107 } |
|
108 |
|
109 ~COpLogoAOCallBack() |
|
110 { |
|
111 // Empty |
|
112 } |
|
113 |
|
114 void SetItActive() |
|
115 { |
|
116 SetActive(); |
|
117 StartWait(); |
|
118 } |
|
119 |
|
120 protected: |
|
121 |
|
122 void RunL() |
|
123 { |
|
124 StopWait(); |
|
125 iCallBack.CallBack(); |
|
126 } |
|
127 |
|
128 void StartWait() |
|
129 { |
|
130 if( !iWait.IsStarted() ) |
|
131 { |
|
132 iWait.Start(); |
|
133 } |
|
134 } |
|
135 |
|
136 void StopWait() |
|
137 { |
|
138 if( iWait.IsStarted() ) |
|
139 { |
|
140 iWait.AsyncStop(); |
|
141 } |
|
142 } |
|
143 |
|
144 void DoCancel() |
|
145 { |
|
146 } |
|
147 |
|
148 private: |
|
149 |
|
150 CActiveSchedulerWait iWait; |
|
151 }; |
|
152 |
|
153 // ================= MEMBER FUNCTIONS ======================= |
|
154 |
|
155 // C++ default constructor. |
|
156 COperatorLogoBioControl::COperatorLogoBioControl( |
|
157 MMsgBioControlObserver& aObserver, |
|
158 CMsvSession* aSession, |
|
159 TMsvId aId, |
|
160 TMsgBioMode aEditorOrViewerMode ): |
|
161 CMsgBioControl( aObserver, |
|
162 aSession, |
|
163 aId, |
|
164 aEditorOrViewerMode, |
|
165 NULL /* file handle */ ) |
|
166 { |
|
167 } |
|
168 |
|
169 // Symbian OS default constructor can leave. |
|
170 void COperatorLogoBioControl::ConstructL() |
|
171 { |
|
172 |
|
173 //we take the file server session to own variable in order |
|
174 //to avoid constant use of CCoeEnv::Static() and to reduce the usage |
|
175 //of TLS |
|
176 iFs = CCoeEnv::Static()->FsSession(); |
|
177 if ( !CheckMsgValidityL() ) |
|
178 { |
|
179 User::Leave( KErrMsgBioMessageNotValid ); |
|
180 } |
|
181 |
|
182 FeatureManager::InitializeLibL(); |
|
183 |
|
184 if( IsEditor() ) //This control doesnt support editing mode. |
|
185 { |
|
186 User::Leave( KErrNotSupported ); |
|
187 } |
|
188 |
|
189 User::LeaveIfError( iPhoneServer.Connect() ); |
|
190 |
|
191 |
|
192 LoadStandardBioResourceL(); |
|
193 LoadResourceL( KOpLogoCResourceFileName ); |
|
194 |
|
195 iScaler = IHLScaler::CreateL(); |
|
196 iScalingAO = new ( ELeave ) COpLogoAOCallBack( |
|
197 TCallBack( ScalingReady, this ), CActive::EPriorityStandard ); |
|
198 |
|
199 CreateBitmapL(); |
|
200 |
|
201 // We want to scale the image now: |
|
202 SetRect( Rect() ); |
|
203 |
|
204 // logo will be shown after asynch. scaling, |
|
205 // see COperatorLogoBioControl::DoScalingReady() |
|
206 } |
|
207 |
|
208 // Two-phased constructor. |
|
209 EXPORT_C CMsgBioControl* COperatorLogoBioControl::NewL( |
|
210 MMsgBioControlObserver& aObserver, |
|
211 CMsvSession* aSession, |
|
212 TMsvId aId, |
|
213 TMsgBioMode aEditorOrViewerMode, |
|
214 const RFile* /* aFile */ ) |
|
215 { |
|
216 COperatorLogoBioControl* self = |
|
217 new( ELeave ) COperatorLogoBioControl( aObserver, |
|
218 aSession, |
|
219 aId, |
|
220 aEditorOrViewerMode ); |
|
221 CleanupStack::PushL( self ); |
|
222 self->ConstructL(); |
|
223 CleanupStack::Pop(self); |
|
224 return self; |
|
225 } |
|
226 |
|
227 // Destructor |
|
228 COperatorLogoBioControl::~COperatorLogoBioControl() |
|
229 { |
|
230 FeatureManager::UnInitializeLib(); |
|
231 |
|
232 iPhoneServer.Close(); |
|
233 |
|
234 if( iTempFileExists ) |
|
235 { |
|
236 //delete tempfile if exists |
|
237 iFs.Delete(iTempPathAndName); |
|
238 } |
|
239 |
|
240 delete iBitmap; |
|
241 delete iScaledBitmap; |
|
242 |
|
243 delete iScaler; |
|
244 delete iScalingAO; |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------- |
|
248 // COperatorLogoBioControl::SetAndGetSizeL |
|
249 // --------------------------------------------------------- |
|
250 // |
|
251 void COperatorLogoBioControl::SetAndGetSizeL( TSize& aSize ) |
|
252 { |
|
253 // Size proposed in aSize parameter is used, only height is |
|
254 // proposed by this control. |
|
255 |
|
256 if (AknLayoutUtils::ScalableLayoutInterfaceAvailable()) |
|
257 { |
|
258 TAknWindowComponentLayout layout = |
|
259 AknLayoutScalable_Apps::mce_image_pane_g2(); |
|
260 TAknLayoutRect layoutRect; |
|
261 layoutRect.LayoutRect( Rect(), layout.LayoutLine() ); |
|
262 aSize.iHeight = layoutRect.Rect().Height(); |
|
263 } |
|
264 |
|
265 else |
|
266 { // use old sizing functionality if scalable IF isn't available: |
|
267 aSize.iHeight /= 2; // get in to the middle of pane |
|
268 } |
|
269 |
|
270 SetSizeWithoutNotification( aSize ); |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------- |
|
274 // COperatorLogoBioControl::SetMenuCommandSetL |
|
275 // --------------------------------------------------------- |
|
276 // |
|
277 void COperatorLogoBioControl::SetMenuCommandSetL( CEikMenuPane& aMenuPane ) |
|
278 { |
|
279 AddMenuItemL( aMenuPane, R_USE_LOGO, KUseLogo, KFirstMenuItem ); |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------- |
|
283 // COperatorLogoBioControl::CurrentLineRect |
|
284 // --------------------------------------------------------- |
|
285 // |
|
286 TRect COperatorLogoBioControl::CurrentLineRect() const |
|
287 { |
|
288 return Rect(); |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------- |
|
292 // COperatorLogoBioControl::IsFocusChangePossible |
|
293 // --------------------------------------------------------- |
|
294 // |
|
295 TBool COperatorLogoBioControl::IsFocusChangePossible( |
|
296 TMsgFocusDirection /*aDirection*/ ) const |
|
297 { |
|
298 return EFalse; |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------- |
|
302 // COperatorLogoBioControl::HeaderTextL |
|
303 // --------------------------------------------------------- |
|
304 // |
|
305 HBufC* COperatorLogoBioControl::HeaderTextL() const |
|
306 { |
|
307 HBufC* titleText = StringLoader::LoadL( R_TITLE_OPERATOR_LOGO ); |
|
308 return titleText; |
|
309 } |
|
310 |
|
311 // --------------------------------------------------------- |
|
312 // COperatorLogoBioControl::HandleBioCommandL |
|
313 // --------------------------------------------------------- |
|
314 // |
|
315 TBool COperatorLogoBioControl::HandleBioCommandL(TInt aCommand) |
|
316 { |
|
317 aCommand -= iBioControlObserver.FirstFreeCommand(); |
|
318 |
|
319 TBool retVal( EFalse ); |
|
320 switch ( aCommand ) |
|
321 { |
|
322 case KUseLogo: |
|
323 { |
|
324 TrySaveBitmapL(); |
|
325 retVal = ETrue; |
|
326 break; |
|
327 } |
|
328 default: |
|
329 { |
|
330 retVal = EFalse; |
|
331 break; |
|
332 } |
|
333 } |
|
334 return retVal; |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------- |
|
338 // COperatorLogoBioControl::OptionMenuPermissionsL |
|
339 // --------------------------------------------------------- |
|
340 // |
|
341 TUint32 COperatorLogoBioControl::OptionMenuPermissionsL() const |
|
342 { |
|
343 return EMsgBioDelete |
|
344 | EMsgBioMessInfo |
|
345 | EMsgBioMove |
|
346 | EMsgBioHelp |
|
347 | EMsgBioExit; |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------- |
|
351 // COperatorLogoBioControl::OfferKeyEventL |
|
352 // --------------------------------------------------------- |
|
353 // |
|
354 TKeyResponse COperatorLogoBioControl::OfferKeyEventL( |
|
355 const TKeyEvent& /*aKeyEvent*/, |
|
356 TEventCode /*aType*/ ) |
|
357 { |
|
358 return EKeyWasConsumed; |
|
359 } |
|
360 |
|
361 // --------------------------------------------------------- |
|
362 // COperatorLogoBioControl::GetHelpContext |
|
363 // --------------------------------------------------------- |
|
364 // |
|
365 void COperatorLogoBioControl::GetHelpContext( |
|
366 TCoeHelpContext& aHelpContext ) const |
|
367 { |
|
368 if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
369 { |
|
370 const TUid KUidSmart = {0x101F4CDA}; |
|
371 |
|
372 aHelpContext.iContext = KSMART_HLP_OPLOGOVIEWER(); |
|
373 aHelpContext.iMajor = KUidSmart; |
|
374 } |
|
375 } |
|
376 |
|
377 // --------------------------------------------------------- |
|
378 // COperatorLogoBioControl::CountComponentControls |
|
379 // --------------------------------------------------------- |
|
380 // |
|
381 TInt COperatorLogoBioControl::CountComponentControls() const |
|
382 { |
|
383 return 0; |
|
384 } |
|
385 |
|
386 // --------------------------------------------------------- |
|
387 // COperatorLogoBioControl::ComponentControl |
|
388 // --------------------------------------------------------- |
|
389 // |
|
390 CCoeControl* COperatorLogoBioControl::ComponentControl( |
|
391 TInt /*aIndex*/ ) const |
|
392 { |
|
393 return NULL; |
|
394 } |
|
395 |
|
396 // --------------------------------------------------------- |
|
397 // COperatorLogoBioControl::SizeChanged |
|
398 // --------------------------------------------------------- |
|
399 // |
|
400 void COperatorLogoBioControl::SizeChanged() |
|
401 { |
|
402 TRect imageRect( Rect() ); |
|
403 |
|
404 if (AknLayoutUtils::ScalableLayoutInterfaceAvailable()) |
|
405 { |
|
406 TAknWindowComponentLayout layout = |
|
407 AknLayoutScalable_Apps::mce_image_pane_g2(); |
|
408 TAknLayoutRect layoutRect; |
|
409 layoutRect.LayoutRect( Rect(), layout.LayoutLine() ); |
|
410 imageRect = layoutRect.Rect(); |
|
411 |
|
412 // If leave occurs then scaling is not performed |
|
413 TRAP_IGNORE( ScaleIfPossibleL( imageRect.Size() ) ); |
|
414 } |
|
415 |
|
416 else |
|
417 { |
|
418 TSize imageSize( KLogoMaxWidthPixels, KLogoMaxHeightPixels ); |
|
419 if ( imageRect.Width() < KLogoMaxWidthPixels || |
|
420 imageRect.Height() < KLogoMaxHeightPixels ) |
|
421 { // size of the control is smaller than the maximum size we |
|
422 // would use otherwise. |
|
423 imageSize = imageRect.Size(); |
|
424 } |
|
425 |
|
426 // If leave occurs then scaling is not performed |
|
427 TRAP_IGNORE( ScaleIfPossibleL( imageSize ) ); |
|
428 } |
|
429 } |
|
430 |
|
431 // --------------------------------------------------------- |
|
432 // COperatorLogoBioControl::FocusChanged |
|
433 // --------------------------------------------------------- |
|
434 // |
|
435 void COperatorLogoBioControl::FocusChanged( TDrawNow /*aDrawNow*/ ) |
|
436 { |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------- |
|
440 // COperatorLogoBioControl::SetContainerWindowL |
|
441 // --------------------------------------------------------- |
|
442 // |
|
443 void COperatorLogoBioControl::SetContainerWindowL( |
|
444 const CCoeControl& aContainer ) |
|
445 { |
|
446 CCoeControl::SetContainerWindowL( aContainer ); |
|
447 } |
|
448 |
|
449 // --------------------------------------------------------- |
|
450 // COperatorLogoBioControl::CheckMsgValidityL |
|
451 // --------------------------------------------------------- |
|
452 // |
|
453 TBool COperatorLogoBioControl::CheckMsgValidityL() |
|
454 { |
|
455 RFile file; |
|
456 TFileName fileName; |
|
457 TInt fileSize(0); |
|
458 HBufC8* fileBuffer; |
|
459 |
|
460 CMsvEntry* entry = this->MsvSession(). GetEntryL(iId); |
|
461 CleanupStack::PushL( entry ); |
|
462 CMsvStore* store = entry->ReadStoreL(); |
|
463 CleanupStack::PushL(store); |
|
464 |
|
465 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
466 file = manager.GetAttachmentFileL(0); |
|
467 |
|
468 CleanupClosePushL(file); |
|
469 |
|
470 // get the size of file for descriptor |
|
471 User::LeaveIfError(file.Size(fileSize)); |
|
472 |
|
473 fileBuffer = HBufC8::NewLC(fileSize); |
|
474 TPtr8 filePtr = fileBuffer->Des(); |
|
475 |
|
476 User::LeaveIfError(file.Read(filePtr)); |
|
477 |
|
478 TInt ret(CheckMsgFormatL(file, filePtr)); |
|
479 |
|
480 CleanupStack::PopAndDestroy(fileBuffer); |
|
481 CleanupStack::PopAndDestroy( &file ); |
|
482 CleanupStack::PopAndDestroy( store ); |
|
483 CleanupStack::PopAndDestroy( entry ); |
|
484 |
|
485 return ret; |
|
486 } |
|
487 |
|
488 // --------------------------------------------------------- |
|
489 // COperatorLogoBioControl::CheckMsgFormatL |
|
490 // --------------------------------------------------------- |
|
491 // |
|
492 TBool COperatorLogoBioControl::CheckMsgFormatL( RFile aFile, TPtr8 aPtr ) |
|
493 { |
|
494 TInt len = aPtr.Length(); |
|
495 TInt descPosition( 0 ); |
|
496 TUint8 byte; |
|
497 |
|
498 // first byte |
|
499 if (len > descPosition) |
|
500 { |
|
501 byte = aPtr[descPosition]; |
|
502 } |
|
503 else |
|
504 { |
|
505 return EFalse; |
|
506 } |
|
507 |
|
508 if (byte == KVersionNumberZero) |
|
509 { |
|
510 descPosition++; |
|
511 if (len > descPosition) |
|
512 { |
|
513 byte = aPtr[descPosition]; |
|
514 } |
|
515 else |
|
516 { |
|
517 return EFalse; |
|
518 } |
|
519 |
|
520 TInt count( 1 ); |
|
521 |
|
522 while (byte != KLineFeed && count <= KNumOfBytesExpDay ) |
|
523 { |
|
524 // loop Mcc, Mnc and expiration date bytes off. |
|
525 descPosition++; |
|
526 if (len > descPosition) |
|
527 { |
|
528 byte = aPtr[descPosition]; |
|
529 } |
|
530 else |
|
531 { |
|
532 return EFalse; |
|
533 } |
|
534 count ++; |
|
535 } |
|
536 |
|
537 if (count <= KNumOfBytesMccMnc || count > KNumOfBytesExpDay ) |
|
538 { |
|
539 // there has to be at least 3 bytes for Mcc and Mnc between Version |
|
540 // number and linefeed. if there was an expiration date, the length |
|
541 // can't exceed 15 bytes. |
|
542 return EFalse; |
|
543 } |
|
544 } |
|
545 |
|
546 else |
|
547 { |
|
548 // first byte of message was first byte of Mcc |
|
549 descPosition++; // second byte for Mcc |
|
550 descPosition++; // byte for Mnc |
|
551 } |
|
552 |
|
553 descPosition++; |
|
554 if (len > descPosition) |
|
555 { |
|
556 byte = aPtr[descPosition]; // Ota bitmap Infofield |
|
557 } |
|
558 else |
|
559 { |
|
560 return EFalse; |
|
561 } |
|
562 |
|
563 if ( byte == KLineFeed ) |
|
564 { |
|
565 // there was linefeed before ota bitmap |
|
566 descPosition++; |
|
567 if (len > descPosition) |
|
568 { |
|
569 byte = aPtr[descPosition]; // Ota bitmap Infofield |
|
570 } |
|
571 else |
|
572 { |
|
573 return EFalse; |
|
574 } |
|
575 |
|
576 iLineFeedExists = ETrue; |
|
577 } |
|
578 |
|
579 if ( byte != KOtaBitmapInfoField) |
|
580 { |
|
581 if ( byte == KOtaBitmapInfoFieldAnim) |
|
582 { |
|
583 // The byte descripting ota bitmap's infofield should be 0x00, but |
|
584 // there is existing formats where this byte is 0x01, meaning that |
|
585 // number of animated icons is one. There should not to be any |
|
586 // animated icons in operator logo. But if there is one animated |
|
587 // icon, that could be interpretted as static bitmap. There has |
|
588 // been misunderstandings with smart messaging spec. |
|
589 TBuf8<1> temp; |
|
590 temp.Append(0x00); |
|
591 User::LeaveIfError(aFile.Write(descPosition ,temp)); |
|
592 } |
|
593 else |
|
594 { |
|
595 return EFalse; |
|
596 } |
|
597 } |
|
598 |
|
599 descPosition++; |
|
600 TInt imageWidth; |
|
601 if (len > descPosition) |
|
602 { |
|
603 imageWidth = aPtr[descPosition]; // Ota bitmap width |
|
604 } |
|
605 else |
|
606 { |
|
607 return EFalse; |
|
608 } |
|
609 |
|
610 descPosition++; |
|
611 TInt imageHeight; |
|
612 if (len > descPosition) |
|
613 { |
|
614 imageHeight = aPtr[descPosition]; // Ota bitmap height |
|
615 } |
|
616 else |
|
617 { |
|
618 return EFalse; |
|
619 } |
|
620 |
|
621 if (imageWidth <= 0 || imageHeight <= 0) |
|
622 { |
|
623 return EFalse; |
|
624 } |
|
625 |
|
626 // number of bytes in Bitmap's data |
|
627 TInt numOfImageBytes = (imageWidth * imageHeight) / KPixelsInByte; |
|
628 descPosition++; |
|
629 if (len > descPosition) |
|
630 { |
|
631 byte = aPtr[descPosition]; // Ota bitmap color depth |
|
632 } |
|
633 else |
|
634 { |
|
635 return EFalse; |
|
636 } |
|
637 |
|
638 if (byte != KOtaBitmapColorDepth) // color depth must be black and white |
|
639 { |
|
640 return EFalse; |
|
641 } |
|
642 |
|
643 descPosition++; // position to the first byte of otabitmap's data |
|
644 if ( (len - descPosition) < numOfImageBytes ) |
|
645 { |
|
646 return EFalse; |
|
647 } |
|
648 |
|
649 return ETrue; |
|
650 } |
|
651 |
|
652 // --------------------------------------------------------- |
|
653 // COperatorLogoBioControl ::CreateBitmapL() |
|
654 // --------------------------------------------------------- |
|
655 // |
|
656 void COperatorLogoBioControl::CreateBitmapL() |
|
657 { |
|
658 // Create a temporary ota-bitmap file... |
|
659 |
|
660 RFileReadStream readStream; |
|
661 OpenOperatorLogoL( readStream ); |
|
662 CleanupClosePushL(readStream); |
|
663 WriteBitmapToTempFileL( readStream ); |
|
664 CleanupStack::PopAndDestroy( &readStream ); |
|
665 |
|
666 // ... Then convert it to a bitmap |
|
667 if( iBitmap ) |
|
668 { |
|
669 iBitmap->Reset(); |
|
670 delete iBitmap; |
|
671 iBitmap = NULL; |
|
672 } |
|
673 iBitmap = new ( ELeave ) CFbsBitmap(); |
|
674 |
|
675 __ASSERT_DEBUG( iTempPathAndName.Length() > 0, Panic( EPanicNullFileName ) ); |
|
676 COperatorLogoOTAConv* conv = COperatorLogoOTAConv::NewLC(); |
|
677 conv->ConvertImageL( iTempPathAndName, *iBitmap ); |
|
678 CleanupStack::PopAndDestroy( conv ); |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------- |
|
682 // COperatorLogoBioControl::OpenOperatorLogoL() |
|
683 // --------------------------------------------------------- |
|
684 // |
|
685 void COperatorLogoBioControl::OpenOperatorLogoL( |
|
686 RFileReadStream& aReadStream ) |
|
687 { |
|
688 RFile file; |
|
689 CMsvEntry* entry = this->MsvSession(). GetEntryL(iId); |
|
690 CleanupStack::PushL( entry ); |
|
691 |
|
692 CMsvStore* store = entry->ReadStoreL(); |
|
693 CleanupStack::PushL(store); |
|
694 |
|
695 MMsvAttachmentManager& manager = store->AttachmentManagerL(); |
|
696 |
|
697 file = manager.GetAttachmentFileL(0); |
|
698 CleanupClosePushL( file ); |
|
699 aReadStream.Attach(file,0); |
|
700 CleanupStack::PopAndDestroy( &file ); |
|
701 CleanupStack::PopAndDestroy( store ); |
|
702 CleanupStack::PopAndDestroy( entry ); |
|
703 } |
|
704 |
|
705 // --------------------------------------------------------- |
|
706 // COperatorLogoBioControl::WriteBitmapToTempFileL() |
|
707 // Creates OTA bitmap file |
|
708 // --------------------------------------------------------- |
|
709 // |
|
710 void COperatorLogoBioControl::WriteBitmapToTempFileL( |
|
711 RFileReadStream& aReadStream ) |
|
712 { |
|
713 iTempFileExists = EFalse; |
|
714 //Takes header information away: readStream includes pure OTA-bitmap |
|
715 //after that. |
|
716 DetachHeadersFromOpLogoL( aReadStream ); |
|
717 |
|
718 |
|
719 User::LeaveIfError(iFs.CreatePrivatePath(EDriveC)); |
|
720 |
|
721 TChar driveChar; |
|
722 iFs.DriveToChar( EDriveC,driveChar); |
|
723 TDriveName driveName; |
|
724 driveName.Append(driveChar); |
|
725 driveName.Append(KDriveDelimiter); |
|
726 |
|
727 iFs.PrivatePath(iTempPathAndName); |
|
728 iTempPathAndName.Insert(0,driveName); |
|
729 iTempPathAndName.Append(KTempOtaFileName); |
|
730 |
|
731 |
|
732 RFileWriteStream writeStream; |
|
733 |
|
734 TInt err = writeStream.Replace( iFs, |
|
735 iTempPathAndName, |
|
736 EFileStream ); |
|
737 User::LeaveIfError( err ); |
|
738 |
|
739 writeStream.PushL(); |
|
740 writeStream.WriteL( aReadStream ); |
|
741 writeStream.CommitL(); |
|
742 writeStream.Pop(); |
|
743 writeStream.Release(); |
|
744 |
|
745 iTempFileExists = ETrue; |
|
746 } |
|
747 |
|
748 // --------------------------------------------------------- |
|
749 // COperatorLogoBioControl ::DetachHeadersFromOpLogoL |
|
750 // --------------------------------------------------------- |
|
751 // |
|
752 void COperatorLogoBioControl::DetachHeadersFromOpLogoL( |
|
753 RFileReadStream& aReadStream ) |
|
754 { |
|
755 TBool isVersion = EFalse; |
|
756 //Check if there is version number, which is always |
|
757 //zero in first octet. If not, the Mobile country code is first one. |
|
758 //It describes first part of Mobile country code, which is |
|
759 //encoded in little-endian BCD format. |
|
760 TUint8 firstMcc = aReadStream.ReadUint8L(); |
|
761 if( firstMcc == KVersionNumberZero ) //version number found, |
|
762 //so the file is according to Smart Messaging specification (2.0.0 or 3.0.0) |
|
763 { |
|
764 //Mcc is the next octet after version number. |
|
765 firstMcc = aReadStream.ReadUint8L(); |
|
766 isVersion = ETrue; |
|
767 } |
|
768 |
|
769 //Next one describes second part of Mobile country code |
|
770 TUint8 secondMcc = aReadStream.ReadUint8L(); |
|
771 |
|
772 //Next one describes Mobile network code, which is |
|
773 //encoded in little-endian BCD format. |
|
774 TUint8 mnc = aReadStream.ReadUint8L(); |
|
775 |
|
776 if( isVersion ) //Take all the rubbish away before OTA-bitmap |
|
777 { |
|
778 TInt next = aReadStream.ReadUint8L(); |
|
779 |
|
780 while (next != KLineFeed) |
|
781 { |
|
782 next = aReadStream.ReadUint8L(); |
|
783 } |
|
784 } |
|
785 |
|
786 if( iLineFeedExists ) |
|
787 { |
|
788 // remove the linefeed before ota bitmap data |
|
789 aReadStream.ReadUint8L(); |
|
790 } |
|
791 |
|
792 SetMccAndMnc( firstMcc, secondMcc, mnc ); |
|
793 } |
|
794 |
|
795 // --------------------------------------------------------- |
|
796 // COperatorLogoBioControl ::SetMccAndMnc |
|
797 // --------------------------------------------------------- |
|
798 // |
|
799 void COperatorLogoBioControl::SetMccAndMnc( |
|
800 TUint8 aFmcc, |
|
801 TUint8 aSmcc, |
|
802 TUint8 aMnc ) |
|
803 { |
|
804 // First BCD coded mcc decimal |
|
805 TUint mask = 0x0F; // This is for first byte |
|
806 TUint num = aFmcc & mask; |
|
807 |
|
808 iMcc = num * 100; // first num is hundreds. |
|
809 |
|
810 // Second BCD coded mcc desimal |
|
811 mask = 0xF0; // This is for second byte |
|
812 num = aFmcc & mask; |
|
813 num = num >> 4; |
|
814 if (num != 0x0F) |
|
815 { |
|
816 iMcc += 10 * num; // second num is tens. |
|
817 } |
|
818 |
|
819 // Third BCD coded mcc desimal |
|
820 mask = 0x0F; // This is for first byte |
|
821 num = aSmcc & mask; |
|
822 if (num != 0x0F) |
|
823 { |
|
824 iMcc += num; // third num is ones. |
|
825 } |
|
826 |
|
827 // Fourth BCD coded mcc desimal |
|
828 mask = 0x000000F0; // This is for second byte |
|
829 num = aSmcc & mask; |
|
830 num = num >> 4; |
|
831 // First BCD coded mnc desimal |
|
832 mask = 0x0000000F; // This is for first byte |
|
833 num = aMnc & mask; |
|
834 if (num != 0x00000000) |
|
835 { |
|
836 iMnc = num * 10; // first of mnc is tens. |
|
837 } |
|
838 |
|
839 // Second BCD coded mnc desimal |
|
840 mask = 0x000000F0; // This is for second byte |
|
841 num = aMnc & mask; |
|
842 num = num >> 4; |
|
843 if (num != 0x0000000F) |
|
844 { |
|
845 iMnc += num; // second of mnc is ones. |
|
846 } |
|
847 } |
|
848 |
|
849 // --------------------------------------------------------- |
|
850 // COperatorLogoBioControl :: DetachSizeFromTempBitmapL |
|
851 // --------------------------------------------------------- |
|
852 // |
|
853 TSize COperatorLogoBioControl::DetachSizeFromTempBitmapL() |
|
854 { |
|
855 RFileReadStream readStream; |
|
856 |
|
857 TInt err = readStream.Open( iFs, |
|
858 iTempPathAndName, EFileStream ); |
|
859 |
|
860 User::LeaveIfError( err ); |
|
861 |
|
862 CleanupClosePushL( readStream ); |
|
863 |
|
864 TSize tempSize; |
|
865 |
|
866 readStream.ReadUint8L(); // infofield |
|
867 tempSize.iWidth = readStream.ReadUint8L(); // width |
|
868 tempSize.iHeight = readStream.ReadUint8L(); // height |
|
869 |
|
870 CleanupStack::PopAndDestroy(&readStream); |
|
871 |
|
872 return tempSize; |
|
873 } |
|
874 |
|
875 #ifdef RD_PHONE_CLIENT_EXT |
|
876 // --------------------------------------------------------- |
|
877 // COperatorLogoBioControl ::TrySaveBitmapL |
|
878 // --------------------------------------------------------- |
|
879 // |
|
880 void COperatorLogoBioControl::TrySaveBitmapL() |
|
881 { |
|
882 // Scaling not ready yet bitmaps unexistent for some other reason: |
|
883 User::LeaveIfNull( iBitmap ); |
|
884 |
|
885 // Create image handler, factory will be deleted even in leave case: |
|
886 CPhCltImageHandler* imageHandler = CPhCltImageHandler::NewL(); |
|
887 CleanupStack::PushL( imageHandler ); |
|
888 |
|
889 CPhCltImageParams* logoParams = |
|
890 imageHandler->CPhCltBaseImageParamsL( EPhCltTypeOperatorLogo ); |
|
891 CleanupStack::PushL( logoParams ); |
|
892 |
|
893 CPhCltExtOperatorLogoParams* opLogoParams = |
|
894 static_cast<CPhCltExtOperatorLogoParams*>( logoParams ); |
|
895 |
|
896 TBool clearingMsg( IsClearingMessageL() ); |
|
897 if ( clearingMsg ) |
|
898 { |
|
899 if ( ConfirmationQueryL( R_SM_DELETE_ALL_LOGOS ) ) |
|
900 { |
|
901 // Deletion happens by saving empty params |
|
902 opLogoParams->SetCodesL( KPhCltDeleteOperatorLogo, KPhCltDeleteOperatorLogo, EPhCltLogoTypeOTA ); |
|
903 imageHandler->SaveImages( *logoParams ); |
|
904 |
|
905 // Set oplogo setting to not show active in user's settings: |
|
906 CRepository* repository; |
|
907 repository = CRepository::NewLC( KCRUidPersonalizationSettings ); |
|
908 TInt keyVal = 0; |
|
909 TInt err = repository->Get( KSettingsShowOperatorLogoSetting, keyVal ); |
|
910 if ( err == KErrNone ) |
|
911 { |
|
912 keyVal = 0; |
|
913 User::LeaveIfError( repository->Set( KSettingsShowOperatorLogoSetting, keyVal )); |
|
914 } |
|
915 else if ( err != KErrNotFound ) |
|
916 { |
|
917 User::Leave( KErrCorrupt ); // Bad value in key |
|
918 } |
|
919 CleanupStack::PopAndDestroy(repository); |
|
920 } |
|
921 |
|
922 } |
|
923 else |
|
924 { |
|
925 opLogoParams->SetCodesL( iMcc, iMnc, EPhCltLogoTypeOTA ); |
|
926 TBool replace( EFalse ); |
|
927 TBool exists( LogoExistsL( *imageHandler, opLogoParams ) ); |
|
928 |
|
929 if ( exists ) |
|
930 { |
|
931 replace = ConfirmationQueryL( R_SM_REPLACE_LOGO ); |
|
932 } |
|
933 |
|
934 if ( replace || !exists ) |
|
935 { |
|
936 logoParams->AddImageL( iBitmap->Handle() ); |
|
937 User::LeaveIfError( imageHandler->SaveImages( *logoParams ) ); |
|
938 |
|
939 MsgBioUtils::ConfirmationNoteL( R_SM_NOTE_LOGO_COPIED ); |
|
940 |
|
941 // Set oplogo showing active in user's settings: |
|
942 CRepository* repository; |
|
943 repository = CRepository::NewLC( KCRUidPersonalizationSettings ); |
|
944 TInt keyVal = 0; |
|
945 TInt err = repository->Get( KSettingsShowOperatorLogoSetting, keyVal ); |
|
946 if ( err == KErrNone ) |
|
947 { |
|
948 keyVal = 1; |
|
949 User::LeaveIfError( repository->Set( KSettingsShowOperatorLogoSetting, keyVal )); |
|
950 } |
|
951 else if ( err != KErrNotFound ) |
|
952 { |
|
953 User::Leave( KErrCorrupt ); // Bad value in key |
|
954 } |
|
955 CleanupStack::PopAndDestroy(repository); |
|
956 } |
|
957 } |
|
958 |
|
959 CleanupStack::PopAndDestroy( 2 ,imageHandler); // logoParams, imageHandler |
|
960 } |
|
961 #else |
|
962 // --------------------------------------------------------- |
|
963 // COperatorLogoBioControl ::TrySaveBitmapL |
|
964 // --------------------------------------------------------- |
|
965 // |
|
966 void COperatorLogoBioControl::TrySaveBitmapL() |
|
967 { |
|
968 // Scaling not ready yet bitmaps unexistent for some other reason: |
|
969 User::LeaveIfNull( iBitmap ); |
|
970 |
|
971 // Load Phone Client Extension library |
|
972 // iControlDllLibrary is pushed to cleanup stack if leave should happen. |
|
973 LoadLibraryLC(); |
|
974 |
|
975 TLibraryFunction entry = iControlDllLibrary.Lookup( 1 ); |
|
976 CPhCltExtFactory* factory = reinterpret_cast< CPhCltExtFactory* >( entry() ); |
|
977 // Factory cannot be pushed to cleanupstack because next method is LD. |
|
978 |
|
979 // Create image handler, factory will be deleted even in leave case: |
|
980 CPhCltExtImageHandler* imageHandler = factory->CPhCltExtImageHandlerLD(); |
|
981 CleanupStack::PushL( imageHandler ); |
|
982 |
|
983 User::LeaveIfError( imageHandler->Open( iPhoneServer ) ); |
|
984 |
|
985 CPhCltExtImageParams* logoParams = |
|
986 imageHandler->CPhCltExtBaseImageParamsL( EPhCltTypeOperatorLogo ); |
|
987 CleanupStack::PushL( logoParams ); |
|
988 |
|
989 CPhCltExtOperatorLogoParams* opLogoParams = |
|
990 static_cast<CPhCltExtOperatorLogoParams*>( logoParams ); |
|
991 |
|
992 |
|
993 TBool clearingMsg( IsClearingMessageL() ); |
|
994 if ( clearingMsg ) |
|
995 { |
|
996 if ( ConfirmationQueryL( R_SM_DELETE_ALL_LOGOS ) ) |
|
997 { |
|
998 // Deletion happens by saving empty params |
|
999 opLogoParams->SetCodesL( KPhCltDeleteOperatorLogo, KPhCltDeleteOperatorLogo, EPhCltLogoTypeOTA ); |
|
1000 imageHandler->SaveImages( *logoParams ); |
|
1001 |
|
1002 // Set oplogo setting to not show active in user's settings: |
|
1003 CRepository* repository; |
|
1004 repository = CRepository::NewLC( KCRUidPersonalizationSettings ); |
|
1005 TInt keyVal = 0; |
|
1006 TInt err = repository->Get( KSettingsShowOperatorLogoSetting, keyVal ); |
|
1007 if ( err == KErrNone ) |
|
1008 { |
|
1009 keyVal = 0; |
|
1010 User::LeaveIfError( repository->Set( KSettingsShowOperatorLogoSetting, keyVal )); |
|
1011 } |
|
1012 else if ( err != KErrNotFound ) |
|
1013 { |
|
1014 User::Leave( KErrCorrupt ); // Bad value in key |
|
1015 } |
|
1016 CleanupStack::PopAndDestroy(repository); |
|
1017 } |
|
1018 |
|
1019 } |
|
1020 else |
|
1021 { |
|
1022 opLogoParams->SetCodesL( iMcc, iMnc, EPhCltLogoTypeOTA ); |
|
1023 TBool replace( EFalse ); |
|
1024 TBool exists( LogoExistsL( *imageHandler, opLogoParams ) ); |
|
1025 |
|
1026 if ( exists ) |
|
1027 { |
|
1028 replace = ConfirmationQueryL( R_SM_REPLACE_LOGO ); |
|
1029 } |
|
1030 |
|
1031 if ( replace || !exists ) |
|
1032 { |
|
1033 logoParams->AddImageL( iBitmap->Handle() ); |
|
1034 User::LeaveIfError( imageHandler->SaveImages( *logoParams ) ); |
|
1035 |
|
1036 MsgBioUtils::ConfirmationNoteL( R_SM_NOTE_LOGO_COPIED ); |
|
1037 |
|
1038 // Set oplogo showing active in user's settings: |
|
1039 CRepository* repository; |
|
1040 repository = CRepository::NewLC( KCRUidPersonalizationSettings ); |
|
1041 TInt keyVal = 0; |
|
1042 TInt err = repository->Get( KSettingsShowOperatorLogoSetting, keyVal ); |
|
1043 if ( err == KErrNone ) |
|
1044 { |
|
1045 keyVal = 1; |
|
1046 User::LeaveIfError( repository->Set( KSettingsShowOperatorLogoSetting, keyVal )); |
|
1047 } |
|
1048 else if ( err != KErrNotFound ) |
|
1049 { |
|
1050 User::Leave( KErrCorrupt ); // Bad value in key |
|
1051 } |
|
1052 CleanupStack::PopAndDestroy(repository); |
|
1053 } |
|
1054 } |
|
1055 |
|
1056 CleanupStack::PopAndDestroy( 3 ,&iControlDllLibrary); // logoParams, imageHandler, iControlDllLibrary |
|
1057 } |
|
1058 |
|
1059 void COperatorLogoBioControl::LoadLibraryLC() |
|
1060 { |
|
1061 // If iControlDllLibrary has a handle value (!=0) then library |
|
1062 // is already loaded. BioControlFactory supports only one loaded library |
|
1063 // at a time. |
|
1064 __ASSERT_ALWAYS( iControlDllLibrary.Handle() == 0, |
|
1065 Panic( EPanicOnlyOneLibraryAllowed ) ); |
|
1066 |
|
1067 TFileName fullname(NULL); |
|
1068 fullname.Append( KDllPhoneClientExt ); |
|
1069 User::LeaveIfError( iControlDllLibrary.Load( fullname ) ); |
|
1070 CleanupClosePushL( iControlDllLibrary ); |
|
1071 } |
|
1072 #endif |
|
1073 |
|
1074 |
|
1075 // --------------------------------------------------------- |
|
1076 // COperatorLogoBioControl::LogoExistsL |
|
1077 // --------------------------------------------------------- |
|
1078 // |
|
1079 #ifdef RD_PHONE_CLIENT_EXT |
|
1080 TBool COperatorLogoBioControl::LogoExistsL( |
|
1081 CPhCltImageHandler& aImageHandler, |
|
1082 CPhCltImageParams* aLogoParams ) |
|
1083 #else |
|
1084 TBool COperatorLogoBioControl::LogoExistsL( |
|
1085 CPhCltExtImageHandler& aImageHandler, |
|
1086 CPhCltExtImageParams* aLogoParams ) |
|
1087 #endif |
|
1088 { |
|
1089 |
|
1090 TInt err = aImageHandler.LoadImages( aLogoParams ); |
|
1091 if( err != KErrNone && err != KErrNotFound ) |
|
1092 { |
|
1093 User::Leave( err ); |
|
1094 } |
|
1095 |
|
1096 TBool retVal; |
|
1097 if( err == KErrNone && aLogoParams->Count() > 0 ) |
|
1098 { |
|
1099 retVal = ETrue; |
|
1100 } |
|
1101 else // KErrNotFound || oldLogoParams->Count() == 0 |
|
1102 { |
|
1103 retVal = EFalse; |
|
1104 } |
|
1105 return retVal; |
|
1106 } |
|
1107 |
|
1108 // --------------------------------------------------------- |
|
1109 // COperatorLogoBioControl::CalculateCropRect |
|
1110 // --------------------------------------------------------- |
|
1111 // |
|
1112 TRect COperatorLogoBioControl::CalculateCropRect( TSize aSize ) |
|
1113 { |
|
1114 // crops from right and bottom |
|
1115 |
|
1116 TRect cropperRect( 0, 0, aSize.iWidth, aSize.iHeight ); |
|
1117 |
|
1118 if ( aSize.iHeight > KLogoMaxHeightPixels ) |
|
1119 { |
|
1120 TInt heightDiff( aSize.iHeight - KLogoMaxHeightPixels ); |
|
1121 cropperRect.iBr.iY = aSize.iHeight - heightDiff; |
|
1122 } |
|
1123 if ( aSize.iWidth > KLogoMaxWidthPixels ) |
|
1124 { |
|
1125 TInt widthDiff( aSize.iWidth - KLogoMaxWidthPixels ); |
|
1126 cropperRect.iBr.iX = aSize.iWidth - widthDiff; |
|
1127 } |
|
1128 |
|
1129 return cropperRect; |
|
1130 } |
|
1131 |
|
1132 |
|
1133 // --------------------------------------------------------- |
|
1134 // COperatorLogoBioControl ::VirtualHeight |
|
1135 // --------------------------------------------------------- |
|
1136 // |
|
1137 TInt COperatorLogoBioControl::VirtualHeight() |
|
1138 { |
|
1139 return 0; |
|
1140 } |
|
1141 |
|
1142 // --------------------------------------------------------- |
|
1143 // COperatorLogoBioControl ::VirtualVisibleTop |
|
1144 // --------------------------------------------------------- |
|
1145 // |
|
1146 TInt COperatorLogoBioControl::VirtualVisibleTop() |
|
1147 { |
|
1148 return 0; |
|
1149 } |
|
1150 |
|
1151 // --------------------------------------------------------- |
|
1152 // COperatorLogoBioControl::IsClearingMessageL |
|
1153 // --------------------------------------------------------- |
|
1154 // |
|
1155 TBool COperatorLogoBioControl::IsClearingMessageL() |
|
1156 { |
|
1157 TBool ret( EFalse ); |
|
1158 RTelServer server; |
|
1159 |
|
1160 // connect to server |
|
1161 TInt res = server.Connect(); |
|
1162 if ( res != KErrNone ) |
|
1163 { // cannot continue |
|
1164 return ret; |
|
1165 } |
|
1166 |
|
1167 // load phone module |
|
1168 res=server.LoadPhoneModule( KMmTsyModuleName ); |
|
1169 if ( res != KErrNone ) |
|
1170 { // cannot continue, close the server |
|
1171 server.Close(); |
|
1172 return ret; |
|
1173 } |
|
1174 |
|
1175 // get phone info for phone name. |
|
1176 RTelServer::TPhoneInfo phoneInfo; |
|
1177 res = server.GetPhoneInfo( 0, phoneInfo ); |
|
1178 |
|
1179 // open mobilephone subsession |
|
1180 RMobilePhone mobilePhone; |
|
1181 res = mobilePhone.Open( server, phoneInfo.iName ); |
|
1182 if (res != KErrNone ) |
|
1183 { // cannot continue, unload the phone module and close the server. |
|
1184 server.UnloadPhoneModule( KMmTsyModuleName ); |
|
1185 server.Close(); |
|
1186 return ret; |
|
1187 } |
|
1188 |
|
1189 // Get the current network MCC & MNC codes |
|
1190 TRequestStatus status; |
|
1191 RMobilePhone::TMobilePhoneLocationAreaV1 area; |
|
1192 RMobilePhone::TMobilePhoneNetworkInfoV1 networkInfo; |
|
1193 RMobilePhone::TMobilePhoneNetworkInfoV1Pckg networkInfoPckg( networkInfo ); |
|
1194 |
|
1195 mobilePhone.GetCurrentNetwork( status, |
|
1196 networkInfoPckg, |
|
1197 area); |
|
1198 User::WaitForRequest( status ); |
|
1199 |
|
1200 // Parse the codes. Notice, this does not give correct results in WINS !!! |
|
1201 TLex lexMcc( networkInfo.iCountryCode ); |
|
1202 TLex lexMnc( networkInfo.iNetworkId ); |
|
1203 TInt mcc; |
|
1204 TInt mnc; |
|
1205 if ( lexMcc.Val( mcc ) != KErrNone ) |
|
1206 { |
|
1207 // cannot continue, unload the phone module and close the server. |
|
1208 mobilePhone.Close(); |
|
1209 server.UnloadPhoneModule( KMmTsyModuleName ); |
|
1210 server.Close(); |
|
1211 return ret; |
|
1212 } |
|
1213 |
|
1214 if ( lexMnc.Val( mnc ) != KErrNone ) |
|
1215 { |
|
1216 // cannot continue, unload the phone module and close the server. |
|
1217 mobilePhone.Close(); |
|
1218 server.UnloadPhoneModule( KMmTsyModuleName ); |
|
1219 server.Close(); |
|
1220 return ret; |
|
1221 } |
|
1222 |
|
1223 // check are MCC and MNC same with codes came with message. |
|
1224 ret = !( iMcc == mcc && iMnc == mnc ); |
|
1225 |
|
1226 // close mobile phone |
|
1227 mobilePhone.Close(); |
|
1228 |
|
1229 // unload phone module |
|
1230 server.UnloadPhoneModule( KMmTsyModuleName ); |
|
1231 |
|
1232 // close server. |
|
1233 server.Close(); |
|
1234 |
|
1235 return ret; |
|
1236 } |
|
1237 |
|
1238 void COperatorLogoBioControl::Reset() |
|
1239 { |
|
1240 __ASSERT_DEBUG( iScalingAO, Panic( KErrArgument ) ); |
|
1241 |
|
1242 if ( iScalingAO->IsActive() ) |
|
1243 { |
|
1244 iScalingAO->Cancel(); |
|
1245 } |
|
1246 |
|
1247 if(iBitmap) |
|
1248 { |
|
1249 iBitmap->Reset(); |
|
1250 delete iBitmap; |
|
1251 iBitmap = NULL; |
|
1252 } |
|
1253 |
|
1254 if(iScaledBitmap) |
|
1255 { |
|
1256 iScaledBitmap->Reset(); |
|
1257 delete iScaledBitmap; |
|
1258 iScaledBitmap = NULL; |
|
1259 } |
|
1260 } |
|
1261 |
|
1262 TInt COperatorLogoBioControl::ScalingReady( TAny* aPtr ) |
|
1263 { |
|
1264 __ASSERT_DEBUG(aPtr,User::Panic( KPanicOplogoBC, EPanicNullPtr)); |
|
1265 static_cast<COperatorLogoBioControl*>( aPtr )->DoScalingReady(); |
|
1266 return 0; |
|
1267 } |
|
1268 |
|
1269 void COperatorLogoBioControl::DoScalingReady() |
|
1270 { |
|
1271 __ASSERT_DEBUG( iScalingAO->iStatus == KErrNone, |
|
1272 Panic( EPanicScalingError ) ); |
|
1273 |
|
1274 if ( iScalingAO->iStatus == KErrNone ) |
|
1275 { |
|
1276 // We want to draw the image now: |
|
1277 DrawNow(); |
|
1278 } |
|
1279 } |
|
1280 |
|
1281 void COperatorLogoBioControl::Panic( TInt aCode ) |
|
1282 { |
|
1283 User::Panic( KPanicOplogoBC, aCode ); |
|
1284 } |
|
1285 |
|
1286 void COperatorLogoBioControl::Draw( const TRect& aRect ) const |
|
1287 { |
|
1288 // Ensure that scaled bitmap exists and that no scaling is |
|
1289 // currently ongoing. |
|
1290 if ( iScaledBitmap && |
|
1291 iScaledBitmap->Handle() && |
|
1292 ! iScalingAO->IsActive() ) |
|
1293 { |
|
1294 CWindowGc& gc = SystemGc(); |
|
1295 |
|
1296 TRect bitmapRect; |
|
1297 TAknWindowComponentLayout layout = |
|
1298 AknLayoutScalable_Apps::mce_image_pane_g2(); |
|
1299 TAknLayoutRect LayoutRect; |
|
1300 LayoutRect.LayoutRect( aRect, layout.LayoutLine() ); |
|
1301 bitmapRect = LayoutRect.Rect(); |
|
1302 |
|
1303 TInt yAxisOffset = aRect.iTl.iY - bitmapRect.iTl.iY; |
|
1304 bitmapRect.Move(0,yAxisOffset); |
|
1305 gc.DrawBitmap(bitmapRect,iScaledBitmap); |
|
1306 } |
|
1307 } |
|
1308 |
|
1309 TBool COperatorLogoBioControl::ScaleIfPossibleL( TSize aSize ) |
|
1310 { |
|
1311 if ( !iBitmap ) |
|
1312 { |
|
1313 // Image hasn't been loaded, cannot scale |
|
1314 return EFalse; |
|
1315 } |
|
1316 |
|
1317 else |
|
1318 { |
|
1319 // Scaling is possible, it is done asynchronously |
|
1320 |
|
1321 if ( iScalingAO->IsActive() ) |
|
1322 { // In this case scaling was already ongoing, but it is cancelled |
|
1323 // due to overriding request. |
|
1324 iScalingAO->Cancel(); |
|
1325 } |
|
1326 |
|
1327 delete iScaledBitmap; |
|
1328 iScaledBitmap = NULL; |
|
1329 iScaledBitmap = new( ELeave ) CFbsBitmap; |
|
1330 |
|
1331 // Bitmap is scaled (cropped first if it exceeds 97*25 pixels). |
|
1332 |
|
1333 //get the current size of operator logo |
|
1334 TSize logoSize = DetachSizeFromTempBitmapL(); |
|
1335 User::LeaveIfError( iScaler->Scale( iScalingAO->iStatus, |
|
1336 *iBitmap, |
|
1337 CalculateCropRect( logoSize ), |
|
1338 *iScaledBitmap, |
|
1339 TRect(aSize) ) ); |
|
1340 iScalingAO->SetItActive(); |
|
1341 return ETrue; |
|
1342 } |
|
1343 } |
|
1344 |
|
1345 // End of File |