|
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: The AppUi file for screensaver application. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <eikenv.h> |
|
21 |
|
22 #include "screensavershareddatai.h" |
|
23 #include "screensaverappui.h" |
|
24 #include "screensaverengine.h" |
|
25 |
|
26 // |
|
27 // CScreensaverAppUi |
|
28 // |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CScreensaverAppUi::ConstructL |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 void CScreensaverAppUi::ConstructL() |
|
34 { |
|
35 SCRLOGGER_WRITEF(_L("SCR:CScreensaverAppUi::ConstructL start") ); |
|
36 SCRLOGGER_CREATE; |
|
37 |
|
38 // Choose orientation based on screensaverconfig |
|
39 #if defined(SS_ALWAYSPORTRAIT) |
|
40 BaseConstructL(EAppOrientationPortrait); |
|
41 |
|
42 #elif defined(SS_ALWAYSLANDSCAPE) |
|
43 BaseConstructL(EAppOrientationLandscape); |
|
44 |
|
45 #else |
|
46 |
|
47 // Not specified - follows device setting |
|
48 BaseConstructL(); |
|
49 #endif |
|
50 |
|
51 SetKeyEventFlags( CAknAppUiBase::EDisableSendKeyShort | CAknAppUiBase::EDisableSendKeyLong ); |
|
52 |
|
53 iModel = CScreensaverEngine::NewL(); |
|
54 |
|
55 CreateViewL(); |
|
56 |
|
57 iEikonEnv->SetSystem( ETrue ); |
|
58 HideApplicationFromFSW(); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CScreensaverAppUi::~CScreensaverAppUi |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CScreensaverAppUi::~CScreensaverAppUi() |
|
66 { |
|
67 |
|
68 delete iModel; |
|
69 iModel = NULL; |
|
70 |
|
71 SCRLOGGER_DELETE; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CScreensaverAppUi::Model |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CScreensaverEngine& CScreensaverAppUi::Model() const |
|
79 { |
|
80 return *iModel; |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CScreensaverAppUi::HandleCommandL |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 void CScreensaverAppUi::HandleCommandL( TInt aCommand ) |
|
88 { |
|
89 switch ( aCommand ) |
|
90 { |
|
91 case EEikCmdExit: |
|
92 Exit(); |
|
93 break; |
|
94 default: |
|
95 break; |
|
96 } |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CScreensaverAppUi::GetView |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 CScreensaverView* CScreensaverAppUi::ScreensaverView() |
|
104 { |
|
105 return iView; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CScreensaverAppUi::CreateViewL |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 void CScreensaverAppUi::CreateViewL() |
|
113 { |
|
114 SCRLOGGER_WRITEF(_L("SCR:CScreensaverAppUi::CreateViewL start") ); |
|
115 iView = CScreensaverView::NewL(); |
|
116 |
|
117 AddViewL( iView ); // transfer ownership to CAknViewAppUi |
|
118 |
|
119 SetDefaultViewL( *iView ); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CScreensaverAppUi::HandleKeyEventL |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 TKeyResponse CScreensaverAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent, |
|
127 TEventCode aType ) |
|
128 { |
|
129 SCRLOGGER_WRITEF(_L("SCR:CScreensaverAppUi::HandleKeyEventL start") ); |
|
130 // Stop on keyup instead of keydown, otherwise the underlying |
|
131 // app might get orphaned key up events and soil its pants. EXCEPT |
|
132 // in preview mode stop on keydown, because the keup from starting |
|
133 // the preview might be received here, and preview stopped before |
|
134 // it even properly started |
|
135 TBool stop = EFalse; |
|
136 |
|
137 if ( !iView ) |
|
138 { |
|
139 return EKeyWasConsumed; |
|
140 } |
|
141 |
|
142 if ( aType == EEventKey && aKeyEvent.iCode == EKeyNo ) |
|
143 { |
|
144 stop = ETrue; |
|
145 } |
|
146 else |
|
147 { |
|
148 if ( iModel->ScreenSaverIsPreviewing() ) |
|
149 { |
|
150 if ( aType == EEventKeyDown ) |
|
151 { |
|
152 stop = ETrue; |
|
153 } |
|
154 } |
|
155 else |
|
156 { |
|
157 if ( aType == EEventKeyUp ) |
|
158 { |
|
159 stop = ETrue; |
|
160 } |
|
161 } |
|
162 } |
|
163 |
|
164 if ( stop ) |
|
165 { |
|
166 iModel->StopScreenSaver(); |
|
167 } |
|
168 |
|
169 return EKeyWasConsumed; |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CScreensaverAppUi::HandleScreenDeviceChangedL |
|
174 // Stops screensaver as soon as screen device changes. Resourcechange |
|
175 // about e.g. resulting layout change comes annoyingly late |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CScreensaverAppUi::HandleScreenDeviceChangedL() |
|
179 { |
|
180 #if defined(SS_FASTSTOPONSCREENDEVICECHANGE) |
|
181 // Slightly faster stop when screendevice changes. Instead of |
|
182 // letting the created user activity stop, do it here. |
|
183 // NOTE that if forced orientation is not used and there is an |
|
184 // application that changes screen orientation for itself (e.g. |
|
185 // viewfinder), screensaver will die here when activated if fast |
|
186 // stop is used. |
|
187 #if !defined(SS_ALWAYSPORTRAIT) && !defined(SS_ALWAYSLANDSCAPE) |
|
188 // Do not stop, if forced orientation is used! |
|
189 // Screensaver may cause a screen device change when activated, |
|
190 // and will promptly commit suicide here |
|
191 iModel->StopScreenSaver(); |
|
192 #endif |
|
193 #endif |
|
194 |
|
195 CAknViewAppUi::HandleScreenDeviceChangedL(); |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CScreensaverAppUi::HandleWsEventL |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 void CScreensaverAppUi::HandleWsEventL( const TWsEvent& aEvent, |
|
203 CCoeControl* aDestination ) |
|
204 { |
|
205 SCRLOGGER_WRITEF(_L("SCR:CScreensaverAppUi::HandleWsEventL start") ); |
|
206 // First, let parent class handle the event |
|
207 CAknViewAppUi::HandleWsEventL( aEvent, aDestination ); |
|
208 |
|
209 // In case of a pointer event, also stop screensaver |
|
210 if ( aEvent.Type() == EEventPointer ) |
|
211 { |
|
212 iModel->StopScreenSaver(); |
|
213 } |
|
214 } |
|
215 |
|
216 //End of file |