22
|
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 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include "AutolockContainer.h"
|
|
21 |
#include <eikenv.h>
|
|
22 |
#include <autolock.mbg>
|
|
23 |
#include <avkon.hrh>
|
|
24 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
25 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
26 |
#include <layoutmetadata.cdl.h>
|
|
27 |
#include <data_caging_path_literals.hrh>
|
|
28 |
#include "AutolockAppUiPS.h"
|
|
29 |
#include <Autolock.rsg>
|
|
30 |
#include "autolock.hrh"
|
|
31 |
#include <eikdef.h>
|
|
32 |
#include <aknnotedialog.h>
|
|
33 |
#include <aknkeylock.h>
|
|
34 |
#include <AknSoftNotifier.h>
|
|
35 |
|
|
36 |
#include <coreapplicationuisdomainpskeys.h>
|
|
37 |
|
|
38 |
#include <AknsLayeredBackgroundControlContext.h>
|
|
39 |
#include <AknsDrawUtils.h>
|
|
40 |
#include <AknBitmapAnimation.h>
|
|
41 |
#include <AknsUtils.h>
|
|
42 |
#include <AknUtils.h>
|
|
43 |
|
|
44 |
#include <e32property.h>
|
|
45 |
#include <PSVariables.h> // Property values
|
|
46 |
#include <coreapplicationuisdomainpskeys.h>
|
|
47 |
#include <startupdomainpskeys.h>
|
|
48 |
#include <ctsydomainpskeys.h>
|
|
49 |
_LIT(BitmapName,"AutoLock.mbm");
|
|
50 |
|
|
51 |
// CONSTANTS
|
|
52 |
|
|
53 |
#ifdef RD_FULLSCREEN_WALLPAPER
|
|
54 |
enum TAutolockBgLayers
|
|
55 |
{
|
|
56 |
EAutolockBgLayerWallpaper = 0,
|
|
57 |
EAutolockBgLayerBackground = 1,
|
|
58 |
EAutolockBgLayersN = 2
|
|
59 |
};
|
|
60 |
#else
|
|
61 |
enum TAutolockBgLayers
|
|
62 |
{
|
|
63 |
EAutolockBgLayerBackground = 0,
|
|
64 |
EAutolockBgLayerWallpaper = 1,
|
|
65 |
EAutolockBgLayersN = 2
|
|
66 |
};
|
|
67 |
#endif //RD_FULLSCREEN_WALLPAPER
|
|
68 |
|
|
69 |
TInt aCallRect_x;
|
|
70 |
TInt aCallRect_y;
|
|
71 |
TInt aCallRect_width;
|
|
72 |
TInt aCallRect_height;
|
|
73 |
// ================= MEMBER FUNCTIONS =======================
|
|
74 |
|
|
75 |
// ---------------------------------------------------------
|
|
76 |
// CAutolockContainer::ConstructL(const TRect& aRect)
|
|
77 |
// Symbian OS two phased constructor
|
|
78 |
// ---------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CAutolockContainer::ConstructL(const TRect& aRect)
|
|
81 |
{
|
|
82 |
#if defined(_DEBUG)
|
|
83 |
RDebug::Print(_L("(AUTOLOCK)CAutolockContainer::ConstructL"));
|
|
84 |
#endif
|
|
85 |
CreateWindowL();
|
|
86 |
|
|
87 |
HBufC* bitMapPath = HBufC::NewLC(KMaxPath);
|
|
88 |
TPtr BitmapFile(bitMapPath->Des());
|
|
89 |
BitmapFile.Append(_L("Z:"));
|
|
90 |
BitmapFile.Append(KDC_APP_BITMAP_DIR);
|
|
91 |
BitmapFile.Append(BitmapName);
|
|
92 |
|
|
93 |
iEikBitmap = 0;
|
|
94 |
iEikBitmapCall = 0;
|
|
95 |
AknsUtils::CreateIconL(
|
|
96 |
AknsUtils::SkinInstance(),
|
|
97 |
KAknsIIDQgnGrafPhoneLocked,
|
|
98 |
iBitmap,
|
|
99 |
iMask,
|
|
100 |
BitmapFile,
|
|
101 |
EMbmAutolockQgn_graf_phone_locked,
|
|
102 |
EMbmAutolockQgn_graf_phone_locked_mask );
|
|
103 |
AknsUtils::CreateIconL(
|
|
104 |
AknsUtils::SkinInstance(),
|
|
105 |
KAknsIIDQgnGrafPhoneLocked,
|
|
106 |
iBitmapCall,
|
|
107 |
iMaskCall,
|
|
108 |
BitmapFile,
|
|
109 |
EMbmAutolockQgn_indi_button_end_call,
|
|
110 |
EMbmAutolockQgn_indi_button_end_call_mask );
|
|
111 |
|
|
112 |
#ifdef RD_FULLSCREEN_WALLPAPER
|
|
113 |
TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels();
|
|
114 |
TRect wallpaperRect( TPoint(0,0), screenSize );
|
|
115 |
iBgContext = CAknsLayeredBackgroundControlContext::NewL(
|
|
116 |
KAknsIIDWallpaper, wallpaperRect, ETrue, EAutolockBgLayersN );
|
|
117 |
SetRect(aRect);
|
|
118 |
#else
|
|
119 |
// Create background control context for skins. Use parent absolute mode,
|
|
120 |
// as this is window owning control
|
|
121 |
iBgContext = CAknsLayeredBackgroundControlContext::NewL(
|
|
122 |
KAknsIIDQsnBgAreaMainIdle, aRect, ETrue, EAutolockBgLayersN );
|
|
123 |
iBgContext->SetLayerImage( EAutolockBgLayerWallpaper, KAknsIIDWallpaper );
|
|
124 |
iBgContext->SetLayerRect( EAutolockBgLayerWallpaper, aRect );
|
|
125 |
SetRect(aRect);
|
|
126 |
#endif // RD_FULLSCREEN_WALLPAPER
|
|
127 |
ActivateL();
|
|
128 |
|
|
129 |
CleanupStack::PopAndDestroy(bitMapPath); //bitMapPath
|
|
130 |
#if defined(_DEBUG)
|
|
131 |
RDebug::Print(_L("(AUTOLOCK)CAutolockContainer::ConstructL END"));
|
|
132 |
#endif
|
|
133 |
}
|
|
134 |
|
|
135 |
|
|
136 |
// ---------------------------------------------------------
|
|
137 |
// CAutolockContainer::~CAutolockContainer()
|
|
138 |
// Destructor
|
|
139 |
// ---------------------------------------------------------
|
|
140 |
//
|
|
141 |
CAutolockContainer::~CAutolockContainer()
|
|
142 |
{
|
|
143 |
delete iBgContext;
|
|
144 |
delete iBitmap;
|
|
145 |
delete iMask;
|
|
146 |
delete iBitmapCall;
|
|
147 |
delete iMaskCall;
|
|
148 |
|
|
149 |
}
|
|
150 |
// ---------------------------------------------------------
|
|
151 |
// CAutolockContainer::SizeChanged()
|
|
152 |
// Called by framework when the view size is changed
|
|
153 |
// ---------------------------------------------------------
|
|
154 |
//
|
|
155 |
void CAutolockContainer::SizeChanged()
|
|
156 |
{
|
|
157 |
#if defined(_DEBUG)
|
|
158 |
RDebug::Print(_L("(AUTOLOCK)CAutolockContainer::SizeChanged()"));
|
|
159 |
#endif
|
|
160 |
|
|
161 |
TRect mainPaneRect(Rect());
|
|
162 |
TAknLayoutRect idleTradPane;
|
|
163 |
idleTradPane.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::main_idle_trad_pane());
|
|
164 |
|
|
165 |
TInt variety = 3;
|
|
166 |
if (Layout_Meta_Data::IsLandscapeOrientation())
|
|
167 |
{
|
|
168 |
variety = 2;
|
|
169 |
}
|
|
170 |
|
|
171 |
|
|
172 |
TAknLayoutRect idlePaneG2;
|
|
173 |
idlePaneG2.LayoutRect(idleTradPane.Rect(), AknLayoutScalable_Avkon::main_idle_pane_g2(variety));
|
|
174 |
|
|
175 |
TInt callState = 0;
|
|
176 |
RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState );
|
|
177 |
if ( callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized )
|
|
178 |
{
|
|
179 |
AknIconUtils::SetSize( iBitmap, idlePaneG2.Rect().Size() );
|
|
180 |
}
|
|
181 |
else
|
|
182 |
{
|
|
183 |
TSize lockSize = TSize(0.8 * idlePaneG2.Rect().Size().iWidth, 0.8 * idlePaneG2.Rect().Size().iHeight);
|
|
184 |
AknIconUtils::SetSize( iBitmap, lockSize );
|
|
185 |
}
|
|
186 |
TSize callSize = TSize(60,60);
|
|
187 |
AknIconUtils::SetSize( iBitmapCall, callSize );
|
|
188 |
|
|
189 |
#ifdef RD_FULLSCREEN_WALLPAPER
|
|
190 |
TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels();
|
|
191 |
TRect wallpaperRect( TPoint(0,0), screenSize );
|
|
192 |
iBgContext->SetLayerRect( EAutolockBgLayerBackground, Rect() ) ;
|
|
193 |
iBgContext->SetLayerRect( EAutolockBgLayerWallpaper, wallpaperRect ) ;
|
|
194 |
|
|
195 |
TPoint origo( 0, 0);
|
|
196 |
iBgContext->SetParentPos(origo);
|
|
197 |
#else
|
|
198 |
|
|
199 |
iBgContext->SetLayerRect( EAutolockBgLayerBackground, Rect() ) ;
|
|
200 |
iBgContext->SetLayerRect( EAutolockBgLayerWallpaper, Rect() ) ;
|
|
201 |
|
|
202 |
TPoint positionRelativeToScreen = PositionRelativeToScreen();
|
|
203 |
//parent must be set when using parent absolute mode.
|
|
204 |
iBgContext->SetParentPos(positionRelativeToScreen);
|
|
205 |
#endif //RD_FULLSCREEN_WALLPAPER
|
|
206 |
|
|
207 |
RRegion autolockRegion;
|
|
208 |
#ifdef RD_FULLSCREEN_WALLPAPER
|
|
209 |
autolockRegion.AddRect( wallpaperRect);
|
|
210 |
#else
|
|
211 |
autolockRegion.AddRect(Rect());
|
|
212 |
#endif //RD_FULLSCREEN_WALLPAPER
|
|
213 |
Window().SetShape(autolockRegion);
|
|
214 |
autolockRegion.Close();
|
|
215 |
|
|
216 |
#if defined(_DEBUG)
|
|
217 |
RDebug::Print(_L("(AUTOLOCK)CAutolockContainer::SizeChanged() END"));
|
|
218 |
#endif
|
|
219 |
}
|
|
220 |
// ---------------------------------------------------------
|
|
221 |
// CAutolockContainer::CountComponentControls() const
|
|
222 |
// ---------------------------------------------------------
|
|
223 |
//
|
|
224 |
TInt CAutolockContainer::CountComponentControls() const
|
|
225 |
{
|
|
226 |
TInt controlCount = 0;
|
|
227 |
|
|
228 |
return controlCount;
|
|
229 |
}
|
|
230 |
|
|
231 |
// ---------------------------------------------------------
|
|
232 |
// CAutolockContainer::ComponentControl(TInt aIndex) const
|
|
233 |
// ---------------------------------------------------------
|
|
234 |
//
|
|
235 |
CCoeControl* CAutolockContainer::ComponentControl(TInt /*aIndex*/) const
|
|
236 |
{
|
|
237 |
return NULL;
|
|
238 |
}
|
|
239 |
// ---------------------------------------------------------
|
|
240 |
// CAutolockContainer::Draw(const TRect& aRect) const
|
|
241 |
// ---------------------------------------------------------
|
|
242 |
//
|
|
243 |
void CAutolockContainer::Draw(const TRect& aRect) const
|
|
244 |
{
|
|
245 |
#if defined(_DEBUG)
|
|
246 |
RDebug::Print(_L("(AUTOLOCK)CAutolockContainer::Draw"));
|
|
247 |
#endif
|
|
248 |
if (AknLayoutUtils::PenEnabled() )
|
|
249 |
{
|
|
250 |
TInt value = 0;
|
|
251 |
RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, value);
|
|
252 |
if(value <= EAutolockOff)
|
|
253 |
{ // Avoid displaying the icon
|
|
254 |
#if defined(_DEBUG)
|
|
255 |
RDebug::Printf( "%s %s (%u) no Draw value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, value );
|
|
256 |
#endif
|
|
257 |
// If it returns, it will not handle orientation changes.
|
|
258 |
// However it will not really draw because the view is hidden
|
|
259 |
// return;
|
|
260 |
}
|
|
261 |
}
|
|
262 |
|
|
263 |
CWindowGc& gc = SystemGc();
|
|
264 |
gc.SetPenStyle(CGraphicsContext::ENullPen);
|
|
265 |
gc.SetBrushColor(KRgbWhite);
|
|
266 |
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
|
|
267 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
268 |
MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
|
|
269 |
AknsDrawUtils::Background( skin, cc, this, gc, aRect );
|
|
270 |
|
|
271 |
// Draw "lock" icon centered to this control
|
|
272 |
// fist calculate the correct x coordinate based on this
|
|
273 |
// controls rect and bitmap width
|
|
274 |
TInt x = Rect().Width()/2 - iBitmap->SizeInPixels().iWidth /2;
|
|
275 |
// and do same with y
|
|
276 |
TInt y = Rect().Height()/2 - iBitmap->SizeInPixels().iHeight/2;
|
|
277 |
TInt width =iBitmap->SizeInPixels().iWidth;
|
|
278 |
TInt height =iBitmap->SizeInPixels().iHeight;
|
|
279 |
|
|
280 |
TInt gripStatus = EPSHWRMGripClosed;
|
|
281 |
RProperty::Get( KPSUidHWRM, KHWRMGripStatus, gripStatus );
|
|
282 |
#if defined(_DEBUG)
|
|
283 |
RDebug::Printf( "%s %s (%u) gripStatus=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, gripStatus );
|
|
284 |
#endif
|
|
285 |
|
|
286 |
TInt callState = 0;
|
|
287 |
RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState );
|
|
288 |
if ( callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized )
|
|
289 |
{
|
|
290 |
}
|
|
291 |
else
|
|
292 |
{
|
|
293 |
if (gripStatus != EPSHWRMGripOpen)
|
|
294 |
y-=100;
|
|
295 |
}
|
|
296 |
|
|
297 |
if (iBitmap && iMask)
|
|
298 |
{
|
|
299 |
// gc.BitBltMasked(TPoint(x,y),iBitmap,TRect(TPoint(0,0),iBitmap->SizeInPixels()), iMask, ETrue);
|
|
300 |
gc.BitBltMasked(TPoint(x,y),iBitmap,TRect(TPoint(0,0),TPoint(width,height)), iMask, ETrue);
|
|
301 |
if ( callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized )
|
|
302 |
{
|
|
303 |
}
|
|
304 |
else
|
|
305 |
{
|
|
306 |
if (gripStatus != EPSHWRMGripOpen)
|
|
307 |
{
|
|
308 |
aCallRect_x=Rect().Width()/2 - iBitmapCall->SizeInPixels().iWidth/2;
|
|
309 |
aCallRect_y=Rect().Height() * 0.75;
|
|
310 |
}
|
|
311 |
else
|
|
312 |
{
|
|
313 |
aCallRect_x=Rect().Width()* 0.75 - iBitmapCall->SizeInPixels().iWidth/2;
|
|
314 |
aCallRect_y = Rect().Height()/2-3*10;
|
|
315 |
}
|
|
316 |
aCallRect_width=iBitmapCall->SizeInPixels().iWidth;
|
|
317 |
aCallRect_height=iBitmapCall->SizeInPixels().iHeight;
|
|
318 |
TSize cornerSize(20,20);
|
|
319 |
TSize cornerEllipseSize(cornerSize.iHeight*2,cornerSize.iWidth*2);
|
|
320 |
TRect box(aCallRect_x-3*10 , aCallRect_y-3*10, aCallRect_x+aCallRect_width+3*10, aCallRect_y+aCallRect_height+3*10);
|
|
321 |
TRect cornerRectTl(box.iTl,cornerEllipseSize);
|
|
322 |
gc.SetBrushColor(KRgbRed);
|
|
323 |
gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
|
|
324 |
gc.SetPenStyle(CGraphicsContext::EDottedPen);
|
|
325 |
gc.DrawRoundRect(box,cornerSize);
|
|
326 |
gc.BitBltMasked(TPoint(aCallRect_x,aCallRect_y),iBitmapCall,TRect(TPoint(0,0),TPoint(aCallRect_width,aCallRect_height)), iMaskCall, ETrue);
|
|
327 |
if (gripStatus != EPSHWRMGripOpen)
|
|
328 |
aCallRect_y+=100; // coordinates are relative to TRect, not to Screen
|
|
329 |
|
|
330 |
// if active call, dismiss all pending notes. This avoids them on top of the BigRedButton
|
|
331 |
CAknSoftNotifier *softNotifier = NULL;
|
|
332 |
TRAPD (err, {
|
|
333 |
softNotifier = CAknSoftNotifier::NewL();
|
|
334 |
softNotifier->AddNotificationL(ESetIdleState, 0);
|
|
335 |
// softNotifier->SetIdleStateL(EFalse);
|
|
336 |
};)
|
|
337 |
delete softNotifier;
|
|
338 |
// during any call ,the touch need to be enabled, so that BigRedButton is available
|
|
339 |
// It will be re-enabled when the call ends
|
|
340 |
RAknKeyLock keylock;
|
|
341 |
if ( keylock.Connect() == KErrNone )
|
|
342 |
{
|
|
343 |
keylock.DisableWithoutNote();
|
|
344 |
keylock.Close();
|
|
345 |
}
|
|
346 |
}
|
|
347 |
}
|
|
348 |
else if (iBitmap && !iMask)
|
|
349 |
{
|
|
350 |
gc.BitBlt(TPoint(x,y),iBitmap);
|
|
351 |
if ( callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized )
|
|
352 |
{
|
|
353 |
}
|
|
354 |
else
|
|
355 |
{
|
|
356 |
gc.BitBlt(TPoint(x,y+iBitmap->SizeInPixels().iHeight),iBitmapCall);
|
|
357 |
}
|
|
358 |
}
|
|
359 |
#if defined(_DEBUG)
|
|
360 |
RDebug::Print(_L("(AUTOLOCK)CAutolockContainer::Draw END"));
|
|
361 |
#endif
|
|
362 |
}
|
|
363 |
|
|
364 |
// ---------------------------------------------------------
|
|
365 |
// CAutolockContainer::HandleControlEventL(
|
|
366 |
// CCoeControl* aControl,TCoeEvent aEventType)
|
|
367 |
// ---------------------------------------------------------
|
|
368 |
//
|
|
369 |
void CAutolockContainer::HandleControlEventL(
|
|
370 |
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
|
|
371 |
{
|
|
372 |
}
|
|
373 |
|
|
374 |
// ---------------------------------------------------------
|
|
375 |
// CAutolockContainer::MopSupplyObject
|
|
376 |
//
|
|
377 |
// ---------------------------------------------------------
|
|
378 |
//
|
|
379 |
TTypeUid::Ptr CAutolockContainer::MopSupplyObject( TTypeUid aId )
|
|
380 |
{
|
|
381 |
if (aId.iUid == MAknsControlContext::ETypeId)
|
|
382 |
{
|
|
383 |
return MAknsControlContext::SupplyMopObject( aId, iBgContext );
|
|
384 |
}
|
|
385 |
return CCoeControl::MopSupplyObject( aId );
|
|
386 |
}
|
|
387 |
void CAutolockContainer::GiveCoords( TRect& aRect )
|
|
388 |
{
|
|
389 |
aRect.iBr.iX=aCallRect_x;
|
|
390 |
aRect.iBr.iY=aCallRect_y;
|
|
391 |
aRect.iTl.iX=aCallRect_width+2*3*10;
|
|
392 |
aRect.iTl.iY=aCallRect_height+2*3*10;
|
|
393 |
}
|
|
394 |
// End of File
|