85
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Base class for all screensavers.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "screensaver_p.h"
|
|
19 |
|
|
20 |
/*!
|
|
21 |
\class Screensaver
|
|
22 |
\brief The private implementation of the Screensaver.
|
|
23 |
*/
|
|
24 |
|
|
25 |
/*!
|
|
26 |
Constructs a new ScreensaverPrivate with \a screensaverPublic.
|
|
27 |
*/
|
|
28 |
ScreensaverPrivate::ScreensaverPrivate(Screensaver * const screensaverPublic) :
|
|
29 |
m_q(screensaverPublic), mState(ScreensaverStateConstructed)
|
|
30 |
{
|
|
31 |
}
|
|
32 |
|
|
33 |
/*!
|
|
34 |
Destructs the class.
|
|
35 |
*/
|
|
36 |
ScreensaverPrivate::~ScreensaverPrivate()
|
|
37 |
{
|
|
38 |
}
|
|
39 |
|
|
40 |
/*!
|
|
41 |
Return current state.
|
|
42 |
\return Current state.
|
|
43 |
*/
|
|
44 |
ScreensaverState ScreensaverPrivate::currentState()
|
|
45 |
{
|
|
46 |
return mState;
|
|
47 |
}
|
|
48 |
|
|
49 |
/*!
|
|
50 |
Change state on Initialized.
|
|
51 |
*/
|
|
52 |
void ScreensaverPrivate::initialize()
|
|
53 |
{
|
|
54 |
switch (mState)
|
|
55 |
{
|
|
56 |
case ScreensaverStateConstructed:
|
|
57 |
case ScreensaverStateClosed:
|
|
58 |
break;
|
|
59 |
default:
|
|
60 |
return;
|
|
61 |
}
|
|
62 |
|
|
63 |
mState = ScreensaverStateInitialized;
|
|
64 |
if (!m_q->onInitialize()) {
|
|
65 |
emit m_q->faulted();
|
|
66 |
}
|
|
67 |
}
|
|
68 |
|
|
69 |
/*!
|
|
70 |
Change state on Foreground.
|
|
71 |
*/
|
|
72 |
void ScreensaverPrivate::foreground()
|
|
73 |
{
|
|
74 |
switch (mState)
|
|
75 |
{
|
|
76 |
case ScreensaverStateInitialized:
|
|
77 |
case ScreensaverStateBackground:
|
|
78 |
case ScreensaverStatePowerSave:
|
|
79 |
case ScreensaverStatePartialForeground:
|
|
80 |
break;
|
|
81 |
default:
|
|
82 |
return;
|
|
83 |
}
|
|
84 |
|
|
85 |
mState = ScreensaverStateForeground;
|
|
86 |
if (!m_q->onForeground()) {
|
|
87 |
emit m_q->faulted();
|
|
88 |
}
|
|
89 |
}
|
|
90 |
|
|
91 |
/*!
|
|
92 |
Change state on PartialForeground.
|
|
93 |
*/
|
|
94 |
void ScreensaverPrivate::partialForeground()
|
|
95 |
{
|
|
96 |
switch (mState)
|
|
97 |
{
|
|
98 |
case ScreensaverStateInitialized:
|
|
99 |
case ScreensaverStateForeground:
|
|
100 |
case ScreensaverStateBackground:
|
|
101 |
break;
|
|
102 |
default:
|
|
103 |
return;
|
|
104 |
}
|
|
105 |
|
|
106 |
mState = ScreensaverStatePartialForeground;
|
|
107 |
if (!m_q->onPartialForeground()) {
|
|
108 |
emit m_q->faulted();
|
|
109 |
}
|
|
110 |
}
|
|
111 |
|
|
112 |
/*!
|
|
113 |
Change state on Background.
|
|
114 |
*/
|
|
115 |
void ScreensaverPrivate::background()
|
|
116 |
{
|
|
117 |
switch (mState)
|
|
118 |
{
|
|
119 |
case ScreensaverStateInitialized:
|
|
120 |
case ScreensaverStateForeground:
|
|
121 |
case ScreensaverStatePartialForeground:
|
|
122 |
case ScreensaverStatePowerSave:
|
|
123 |
break;
|
|
124 |
default:
|
|
125 |
return;
|
|
126 |
}
|
|
127 |
|
|
128 |
mState = ScreensaverStateBackground;
|
|
129 |
if (!m_q->onBackground()) {
|
|
130 |
emit m_q->faulted();
|
|
131 |
}
|
|
132 |
}
|
|
133 |
|
|
134 |
/*!
|
|
135 |
Change state on Disabled.
|
|
136 |
*/
|
|
137 |
void ScreensaverPrivate::powerSave()
|
|
138 |
{
|
|
139 |
switch (mState)
|
|
140 |
{
|
|
141 |
case ScreensaverStateBackground:
|
|
142 |
break;
|
|
143 |
default:
|
|
144 |
return;
|
|
145 |
}
|
|
146 |
|
|
147 |
mState = ScreensaverStatePowerSave;
|
|
148 |
if (!m_q->onPowerSave()) {
|
|
149 |
emit m_q->faulted();
|
|
150 |
}
|
|
151 |
}
|
|
152 |
|
|
153 |
/*!
|
|
154 |
Change state on Closed.
|
|
155 |
*/
|
|
156 |
void ScreensaverPrivate::close()
|
|
157 |
{
|
|
158 |
switch (mState)
|
|
159 |
{
|
|
160 |
case ScreensaverStateInitialized:
|
|
161 |
case ScreensaverStateBackground:
|
|
162 |
case ScreensaverStateForeground:
|
|
163 |
case ScreensaverStatePartialForeground:
|
|
164 |
case ScreensaverStatePowerSave:
|
|
165 |
break;
|
|
166 |
default:
|
|
167 |
return;
|
|
168 |
}
|
|
169 |
|
|
170 |
mState = ScreensaverStateClosed;
|
|
171 |
if (!m_q->onClose()) {
|
|
172 |
emit m_q->faulted();
|
|
173 |
}
|
|
174 |
}
|