23
|
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 |
!iModel->SharedDataInterface()->IsKeyguardOn() )
|
|
159 |
{
|
|
160 |
stop = ETrue;
|
|
161 |
}
|
|
162 |
}
|
|
163 |
}
|
|
164 |
|
|
165 |
if ( stop )
|
|
166 |
{
|
|
167 |
iModel->StopScreenSaver();
|
|
168 |
}
|
|
169 |
|
|
170 |
return EKeyWasConsumed;
|
|
171 |
}
|
|
172 |
|
|
173 |
// -----------------------------------------------------------------------------
|
|
174 |
// CScreensaverAppUi::HandleScreenDeviceChangedL
|
|
175 |
// Stops screensaver as soon as screen device changes. Resourcechange
|
|
176 |
// about e.g. resulting layout change comes annoyingly late
|
|
177 |
// -----------------------------------------------------------------------------
|
|
178 |
//
|
|
179 |
void CScreensaverAppUi::HandleScreenDeviceChangedL()
|
|
180 |
{
|
|
181 |
#if defined(SS_FASTSTOPONSCREENDEVICECHANGE)
|
|
182 |
// Slightly faster stop when screendevice changes. Instead of
|
|
183 |
// letting the created user activity stop, do it here.
|
|
184 |
// NOTE that if forced orientation is not used and there is an
|
|
185 |
// application that changes screen orientation for itself (e.g.
|
|
186 |
// viewfinder), screensaver will die here when activated if fast
|
|
187 |
// stop is used.
|
|
188 |
#if !defined(SS_ALWAYSPORTRAIT) && !defined(SS_ALWAYSLANDSCAPE)
|
|
189 |
// Do not stop, if forced orientation is used!
|
|
190 |
// Screensaver may cause a screen device change when activated,
|
|
191 |
// and will promptly commit suicide here
|
|
192 |
iModel->StopScreenSaver();
|
|
193 |
#endif
|
|
194 |
#endif
|
|
195 |
|
|
196 |
CAknViewAppUi::HandleScreenDeviceChangedL();
|
|
197 |
}
|
|
198 |
|
|
199 |
// -----------------------------------------------------------------------------
|
|
200 |
// CScreensaverAppUi::HandleWsEventL
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
//
|
|
203 |
void CScreensaverAppUi::HandleWsEventL( const TWsEvent& aEvent,
|
|
204 |
CCoeControl* aDestination )
|
|
205 |
{
|
|
206 |
SCRLOGGER_WRITEF(_L("SCR:CScreensaverAppUi::HandleWsEventL start") );
|
|
207 |
// First, let parent class handle the event
|
|
208 |
CAknViewAppUi::HandleWsEventL( aEvent, aDestination );
|
|
209 |
|
|
210 |
// In case of a pointer event, also stop screensaver
|
|
211 |
if ( aEvent.Type() == EEventPointer )
|
|
212 |
{
|
|
213 |
iModel->StopScreenSaver();
|
|
214 |
}
|
|
215 |
}
|
|
216 |
|
|
217 |
//End of file
|