author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:13:53 +0300 | |
branch | RCL_3 |
changeset 29 | 65be1d84df1f |
parent 26 | e8d784ac1a4b |
child 31 | 8f536f98e1f8 |
permissions | -rw-r--r-- |
26 | 1 |
/* |
2 |
* Copyright (c) 2004 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: Defines screensaver utility tools. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
||
20 |
#include <coecntrl.h> |
|
21 |
#include <akntranseffect.h> |
|
22 |
#include <data_caging_path_literals.hrh> |
|
23 |
#include <gulicon.h> |
|
24 |
||
25 |
#ifdef RD_UI_TRANSITION_EFFECTS_PHASE2 |
|
26 |
#include <akntransitionutils.h> |
|
27 |
#endif |
|
28 |
||
29 |
#include "screensaverutility.h" |
|
30 |
#include "screensaverappui.h" |
|
31 |
#include "ScreensaverUtils.h" |
|
32 |
||
33 |
||
34 |
// Screensaver window group priority boost (to ensure it's on top) |
|
35 |
const TInt KSSWinPriorityBoost = 2; |
|
36 |
||
37 |
_LIT(KSsBitmapName, "\\ssbackground.mbm"); |
|
38 |
_LIT(KSsBitmapUserDrive, "c:"); |
|
39 |
_LIT(KSsBitmapSystemDrive, "z:"); |
|
40 |
||
41 |
// ----------------------------------------------------------------------------- |
|
42 |
// CScreensaverUtility::Panic( TInt aPanic ) |
|
43 |
// ----------------------------------------------------------------------------- |
|
44 |
// |
|
45 |
void ScreensaverUtility::Panic( TInt aPanic ) |
|
46 |
{ |
|
47 |
User::Panic( _L("Screensaver"),aPanic ); |
|
48 |
} |
|
49 |
||
50 |
||
51 |
// ----------------------------------------------------------------------------- |
|
52 |
// CScreensaverUtility::FlushDrawBuffer( TInt aPanic ) |
|
53 |
// Flushes pending draw commands. A "must" before activating power save |
|
54 |
// mode, so that the image can be copied to power save memory |
|
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// |
|
57 |
void ScreensaverUtility::FlushDrawBuffer() |
|
58 |
{ |
|
59 |
CCoeEnv::Static()->WsSession().Flush(); |
|
60 |
} |
|
61 |
||
62 |
// ----------------------------------------------------------------------------- |
|
63 |
// CScreensaverUtility::ScreenRotated( TInt aPanic ) |
|
64 |
// Checks if screen has been rotated |
|
65 |
// ----------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
TBool ScreensaverUtility::ScreenRotated() |
|
68 |
{ |
|
69 |
TPixelsAndRotation pxRot; |
|
70 |
CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(pxRot); |
|
71 |
||
72 |
// Rotated, if 90 or 270 degrees |
|
73 |
return ((pxRot.iRotation == CFbsBitGc::EGraphicsOrientationRotated90) |
|
74 |
|| (pxRot.iRotation == CFbsBitGc::EGraphicsOrientationRotated270)); |
|
75 |
} |
|
76 |
||
77 |
// ----------------------------------------------------------------------------- |
|
78 |
// ScreensaverUtility::Query12HourClock |
|
79 |
// Query whether 12-hour clock is displayed |
|
80 |
// ----------------------------------------------------------------------------- |
|
81 |
// |
|
82 |
TBool ScreensaverUtility::Query12HourClock( ) |
|
83 |
{ |
|
84 |
TLocale locale; |
|
85 |
return (locale.TimeFormat() == ETime12); |
|
86 |
} |
|
87 |
||
88 |
||
89 |
// ----------------------------------------------------------------------------- |
|
90 |
// ScreensaverUtility::BringToForeground |
|
91 |
// ----------------------------------------------------------------------------- |
|
92 |
// |
|
93 |
void ScreensaverUtility::BringToForeground() |
|
94 |
{ |
|
95 |
#ifdef RD_UI_TRANSITION_EFFECTS_PHASE2 |
|
96 |
const TInt KSsaCustomActivateContextNum = 1002; |
|
97 |
||
98 |
GfxTransEffect::BeginFullScreen( KSsaCustomActivateContextNum, TRect( ), |
|
99 |
AknTransEffect::EParameterType, AknTransEffect::GfxTransParam( |
|
100 |
KUidScreensaverApp, |
|
101 |
AknTransEffect::TParameter::EActivateExplicitContinue ) ); |
|
102 |
#endif |
|
103 |
CEikonEnv::Static()->SetAutoForwarding( ETrue ); |
|
104 |
CEikonEnv::Static()->BringForwards( ETrue, ECoeWinPriorityAlwaysAtFront |
|
105 |
+ KSSWinPriorityBoost ); |
|
106 |
} |
|
107 |
||
108 |
// ----------------------------------------------------------------------------- |
|
109 |
// ScreensaverUtility::SendToBackground |
|
110 |
// ----------------------------------------------------------------------------- |
|
111 |
// |
|
112 |
void ScreensaverUtility::SendToBackground() |
|
113 |
{ |
|
114 |
#ifdef RD_UI_TRANSITION_EFFECTS_PHASE2 |
|
115 |
||
116 |
// Start the exit effect context even if this is actually application switch. The exit context |
|
117 |
// makes possible to map effect by using the *previous* application uid (=Screen Saver). |
|
118 |
// Note: Not allowed to call GfxTransEffect::EndFullScreen() as AVKON takes care of that when |
|
119 |
// EApplicationExit context is used! |
|
120 |
const TInt KSsaCustomDeactivateContextNum = 1001; |
|
121 |
||
122 |
//condition takes care of special case of incomeing call (should not have effect then) |
|
123 |
if ( CAknTransitionUtils::GetData( KScreensaverCallStateChange ) == NULL ) |
|
124 |
{ |
|
125 |
if ( static_cast<CScreensaverAppUi*>(CCoeEnv::Static()->AppUi())->IsForeground() ) |
|
126 |
{ |
|
127 |
GfxTransEffect::BeginFullScreen( KSsaCustomDeactivateContextNum, |
|
128 |
TRect( ), AknTransEffect::EParameterType, |
|
129 |
AknTransEffect::GfxTransParam( KUidScreensaverApp, |
|
130 |
AknTransEffect::TParameter::EActivateExplicitContinue ) ); |
|
131 |
} |
|
132 |
} |
|
133 |
CAknTransitionUtils::RemoveData( KScreensaverCallStateChange ); |
|
134 |
#endif |
|
29
65be1d84df1f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
135 |
CEikonEnv::Static()->RootWin().SetOrdinalPosition( |
65be1d84df1f
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
136 |
0, ECoeWinPriorityNeverAtFront ); |
26 | 137 |
CEikonEnv::Static()->BringForwards( EFalse ); |
138 |
} |
|
139 |
||
140 |
// ----------------------------------------------------------------------------- |
|
141 |
// ScreensaverUtility::IsDrivePresent |
|
142 |
// ----------------------------------------------------------------------------- |
|
143 |
// |
|
144 |
TBool ScreensaverUtility::IsDrivePresent(TInt aDrive) |
|
145 |
{ |
|
146 |
RFs& fs = CCoeEnv::Static()->FsSession(); |
|
147 |
||
148 |
TInt error = KErrNone; |
|
149 |
TDriveInfo driveInfo; |
|
150 |
error = fs.Drive(driveInfo, aDrive ); |
|
151 |
||
152 |
// Not present, locked or unknown is bad |
|
153 |
if ((error != KErrNone) || |
|
154 |
(driveInfo.iMediaAtt & KMediaAttLocked) || |
|
155 |
(driveInfo.iType == EMediaNotPresent) || |
|
156 |
(driveInfo.iType == EMediaUnknown)) |
|
157 |
{ |
|
158 |
return EFalse; |
|
159 |
} |
|
160 |
||
161 |
// Read-only is fine |
|
162 |
return ETrue; |
|
163 |
} |
|
164 |
||
165 |
// ----------------------------------------------------------------------------- |
|
166 |
// ScreensaverUtility::LoadBitmapL |
|
167 |
// ----------------------------------------------------------------------------- |
|
168 |
// |
|
169 |
CGulIcon* ScreensaverUtility::LoadBitmapL() |
|
170 |
{ |
|
171 |
CGulIcon *icon = CGulIcon::NewL(); |
|
172 |
CleanupStack::PushL( icon ); |
|
173 |
icon->SetBitmap(new (ELeave) CFbsBitmap()); |
|
174 |
CFbsBitmap* mask = new (ELeave) CFbsBitmap(); |
|
175 |
||
176 |
// First try user path and then system path. |
|
177 |
TInt error; |
|
178 |
TFileName path; |
|
179 |
path.Copy(KSsBitmapUserDrive); |
|
180 |
path.Append(KDC_APP_BITMAP_DIR); |
|
181 |
path.Append(KSsBitmapName); |
|
182 |
||
183 |
for (TInt i = 0; i < 2; i++) |
|
184 |
{ |
|
185 |
error = icon->Bitmap()->Load(path, 0); |
|
186 |
if (error == KErrNone) |
|
187 |
{ |
|
188 |
error = mask->Load(path, 1); |
|
189 |
if (error != KErrNone) |
|
190 |
{ |
|
191 |
delete mask; |
|
192 |
} |
|
193 |
else |
|
194 |
{ |
|
195 |
icon->SetMask( mask ); |
|
196 |
} |
|
197 |
CleanupStack::Pop(); // icon |
|
198 |
return icon; |
|
199 |
} |
|
200 |
path.Copy(KSsBitmapSystemDrive); |
|
201 |
path.Append(KDC_APP_BITMAP_DIR); |
|
202 |
path.Append(KSsBitmapName); |
|
203 |
} |
|
204 |
||
205 |
CleanupStack::PopAndDestroy(); // icon |
|
206 |
return NULL; |
|
207 |
} |
|
208 |
||
209 |
||
210 |
// ----------------------------------------------------------------------------- |
|
211 |
// ScreensaverUtility::StopWServHeartBeat |
|
212 |
// ----------------------------------------------------------------------------- |
|
213 |
// |
|
214 |
void ScreensaverUtility::StopWServHeartBeat() |
|
215 |
{ |
|
216 |
SCRLOGGER_WRITE("Model: Stopping WServ HB, snoozing..."); |
|
217 |
RWsSession ws; |
|
218 |
TInt err = ws.Connect( ); |
|
219 |
if ( !err ) |
|
220 |
{ |
|
221 |
ws.PrepareForSwitchOff( ); |
|
222 |
ws.Close( ); |
|
223 |
} |
|
224 |
} |
|
225 |
||
226 |
// End of file |