85
|
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 |
// Destructor
|
|
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( NULL );
|
|
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 |
// ---------------------------------------------------------------------------
|
|
149 |
// CCaSatHandler::GetVisibility
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
CFbsBitmap* CCaSatHandler::GetBitmapL( const RIconEf& aIconEF )
|
|
153 |
{
|
|
154 |
TInt selectedIconIndex( KErrNotFound );
|
|
155 |
TSize selectedIconSize( 0, 0 );
|
|
156 |
CFbsBitmap* bitmap( NULL );
|
|
157 |
for( TInt i = 0; i < aIconEF.Count(); ++i )
|
|
158 |
{
|
|
159 |
if( ( aIconEF[i].IconSize().iHeight * aIconEF[i].IconSize().iWidth )
|
|
160 |
>= ( selectedIconSize.iHeight * selectedIconSize.iWidth ) )
|
|
161 |
if( bitmap )
|
|
162 |
{
|
|
163 |
delete bitmap;
|
|
164 |
bitmap = NULL;
|
|
165 |
}
|
|
166 |
// test and select index of iIcon which is not too big
|
|
167 |
TRAPD( bitmapErr, bitmap = iSatIcon.GetIconL( aIconEF[ i ] ) );
|
|
168 |
if( !bitmapErr && bitmap ) //!iBitmap if iIcon is too big
|
|
169 |
{
|
|
170 |
selectedIconSize = aIconEF[i].IconSize();
|
|
171 |
selectedIconIndex = i;
|
|
172 |
}
|
|
173 |
else if( bitmapErr )
|
|
174 |
{
|
|
175 |
User::Leave( bitmapErr );
|
|
176 |
}
|
|
177 |
}
|
|
178 |
if( selectedIconIndex != KErrNotFound )
|
|
179 |
{
|
|
180 |
if( bitmap )
|
|
181 |
{
|
|
182 |
delete bitmap;
|
|
183 |
bitmap = NULL;
|
|
184 |
}
|
|
185 |
TRAPD( bitmapErr, bitmap =
|
|
186 |
iSatIcon.GetIconL( aIconEF[ selectedIconIndex ] ) );
|
|
187 |
User::LeaveIfError( bitmapErr );
|
|
188 |
return bitmap;
|
|
189 |
}
|
|
190 |
else
|
|
191 |
{
|
|
192 |
return NULL;
|
|
193 |
}
|
|
194 |
}
|
|
195 |
|
|
196 |
// End of File
|