|
1 /* |
|
2 * Copyright (c) 2008 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: Used for receive SIM Application name, icon or visibility information. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 #include <e32property.h> |
|
21 #include <bitdev.h> |
|
22 |
|
23 #include "ca2internalCRkeys.h" |
|
24 #include "casathandler.h" |
|
25 |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CCaSatHandler::NewL |
|
30 // Two-phased constructor. |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 EXPORT_C CCaSatHandler* CCaSatHandler::NewL() |
|
34 { |
|
35 CCaSatHandler* self = new ( ELeave ) CCaSatHandler(); |
|
36 CleanupStack::PushL( self ); |
|
37 self->ConstructL(); |
|
38 CleanupStack::Pop( self ); |
|
39 return self; |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // Destructor |
|
44 // ----------------------------------------------------------------------------- |
|
45 CCaSatHandler::~CCaSatHandler() |
|
46 { |
|
47 iSatIcon.Close(); |
|
48 iSatSession.Close(); |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // LoadIconL |
|
53 // ----------------------------------------------------------------------------- |
|
54 EXPORT_C CAknIcon* CCaSatHandler::LoadIconL() |
|
55 { |
|
56 TInt iconId( KErrNone ); |
|
57 User::LeaveIfError( RProperty::Get( KCRUidCa, KCaSatUIIconId, iconId ) ); |
|
58 CAknIcon* icon = CAknIcon::NewL(); |
|
59 CleanupStack::PushL( icon ); |
|
60 if( iconId != KErrNone ) |
|
61 { |
|
62 RIconEf iIconEf; |
|
63 iSatIcon.GetIconInfoL( TUint8( iconId ), iIconEf ); |
|
64 CleanupClosePushL( iIconEf ); |
|
65 CFbsBitmap* bitmap = GetBitmapL( iIconEf ); |
|
66 if( bitmap ) |
|
67 { |
|
68 CFbsBitmap* mask( new (ELeave) CFbsBitmap ); |
|
69 CleanupStack::PushL( mask ); |
|
70 |
|
71 icon->SetBitmap( bitmap ); |
|
72 // create and set mask |
|
73 User::LeaveIfError( mask->Create( bitmap->SizeInPixels(), |
|
74 EGray256 ) ); |
|
75 |
|
76 CFbsBitmapDevice* maskDevice = CFbsBitmapDevice::NewL( mask ); |
|
77 CleanupStack::PushL( maskDevice ); |
|
78 CFbsBitGc* maskGc; |
|
79 User::LeaveIfError( maskDevice->CreateContext( maskGc ) ); |
|
80 CleanupStack::PushL( maskGc ); |
|
81 maskGc->SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
82 maskGc->SetDrawMode( CGraphicsContext::EDrawModePEN ); |
|
83 maskGc->SetBrushColor( KRgbBlack ); |
|
84 maskGc->Clear(); |
|
85 maskGc->SetBrushColor( KRgbWhite ); |
|
86 maskGc->DrawRect( TRect( TPoint(), bitmap->SizeInPixels() ) ); |
|
87 icon->SetMask( mask ); |
|
88 |
|
89 CleanupStack::PopAndDestroy( maskGc ); |
|
90 CleanupStack::PopAndDestroy( maskDevice ); |
|
91 CleanupStack::Pop( mask ); |
|
92 } |
|
93 CleanupStack::PopAndDestroy( &iIconEf ); // iIconEf |
|
94 CleanupStack::Pop( icon ); |
|
95 } |
|
96 else |
|
97 { |
|
98 CleanupStack::PopAndDestroy( icon ); |
|
99 icon = NULL; |
|
100 } |
|
101 return icon; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CCaSatHandler::GetName |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 EXPORT_C TInt CCaSatHandler::GetName( TDes& aName ) |
|
109 { |
|
110 return RProperty::Get( KCRUidCa, KCaSatUIName, aName ); |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // CCaSatHandler::GetVisibility |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C TBool CCaSatHandler::CheckVisibility() |
|
118 { |
|
119 TInt visibility( KErrNone ); |
|
120 TInt err = RProperty::Get( KCRUidCa, KCaShowSatUI, visibility ); |
|
121 if( err == KErrNone && visibility ) |
|
122 return ETrue; |
|
123 else |
|
124 return EFalse; |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CCaSatHandler::CMcsSatHandler |
|
129 // C++ default constructor can NOT contain any code, that |
|
130 // might leave. |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 CCaSatHandler::CCaSatHandler() |
|
134 { |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CCaSatHandler::ConstructL |
|
139 // Symbian 2nd phase constructor can leave. |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CCaSatHandler::ConstructL() |
|
143 { |
|
144 iSatSession.ConnectL(); |
|
145 iSatIcon.OpenL( iSatSession ); |
|
146 } |
|
147 |
|
148 #ifdef COVERAGE_MEASUREMENT |
|
149 #pragma CTC SKIP |
|
150 #endif //COVERAGE_MEASUREMENT (Icon can be created only from SIM) |
|
151 // --------------------------------------------------------------------------- |
|
152 // CCaSatHandler::GetVisibility |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 CFbsBitmap* CCaSatHandler::GetBitmapL( const RIconEf& aIconEF ) |
|
156 { |
|
157 TInt selectedIconIndex( KErrNotFound ); |
|
158 TSize selectedIconSize( 0, 0 ); |
|
159 CFbsBitmap* bitmap( NULL ); |
|
160 for( TInt i = 0; i < aIconEF.Count(); ++i ) |
|
161 { |
|
162 if( ( aIconEF[i].IconSize().iHeight * aIconEF[i].IconSize().iWidth ) |
|
163 >= ( selectedIconSize.iHeight * selectedIconSize.iWidth ) ) |
|
164 if( bitmap ) |
|
165 { |
|
166 delete bitmap; |
|
167 bitmap = NULL; |
|
168 } |
|
169 // test and select index of iIcon which is not too big |
|
170 TRAPD( bitmapErr, bitmap = iSatIcon.GetIconL( aIconEF[ i ] ) ); |
|
171 if( !bitmapErr && bitmap ) //!iBitmap if iIcon is too big |
|
172 { |
|
173 selectedIconSize = aIconEF[i].IconSize(); |
|
174 selectedIconIndex = i; |
|
175 } |
|
176 else if( bitmapErr ) |
|
177 { |
|
178 User::Leave( bitmapErr ); |
|
179 } |
|
180 } |
|
181 if( selectedIconIndex != KErrNotFound ) |
|
182 { |
|
183 if( bitmap ) |
|
184 { |
|
185 delete bitmap; |
|
186 bitmap = NULL; |
|
187 } |
|
188 TRAPD( bitmapErr, bitmap = |
|
189 iSatIcon.GetIconL( aIconEF[ selectedIconIndex ] ) ); |
|
190 User::LeaveIfError( bitmapErr ); |
|
191 return bitmap; |
|
192 } |
|
193 else |
|
194 { |
|
195 return NULL; |
|
196 } |
|
197 } |
|
198 #ifdef COVERAGE_MEASUREMENT |
|
199 #pragma CTC ENDSKIP |
|
200 #endif //COVERAGE_MEASUREMENT |
|
201 |
|
202 // End of File |