1 /* |
|
2 * Copyright (c) 2010 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: Controller for managing the camera startup logo state |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "camstartuplogocontroller.h" |
|
19 #include "camlogging.h" |
|
20 |
|
21 // Maximum time the logo can be shown |
|
22 const TInt KCamFailSafeTimeout = 5000000; // 5 seconds |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // C++ constructor |
|
26 // --------------------------------------------------------------------------- |
|
27 // |
|
28 CCamStartupLogoController::CCamStartupLogoController(TStartupLogoState aInitialState) |
|
29 : iState(aInitialState) |
|
30 { |
|
31 // No implementation required |
|
32 PRINT( _L("Camera <> CCamStartupLogoController::CCamStartupLogoController") ); |
|
33 } |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // Destructor |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 CCamStartupLogoController::~CCamStartupLogoController() |
|
40 { |
|
41 PRINT( _L("Camera <> CCamStartupLogoController::~CCamStartupLogoController") ); |
|
42 delete iFailSafeTimer; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Two-phased constructor |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CCamStartupLogoController* CCamStartupLogoController::NewLC(TStartupLogoState aInitialState) |
|
50 { |
|
51 CCamStartupLogoController* self = |
|
52 new (ELeave) CCamStartupLogoController(aInitialState); |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // Two-phased constructor |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 CCamStartupLogoController* CCamStartupLogoController::NewL( |
|
63 TStartupLogoState aInitialState) |
|
64 { |
|
65 CCamStartupLogoController* self = CCamStartupLogoController::NewLC(aInitialState); |
|
66 CleanupStack::Pop(self); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // 2nd phase constructor |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 void CCamStartupLogoController::ConstructL() |
|
75 { |
|
76 iFailSafeTimer = CPeriodic::NewL(0); |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CCamStartupLogoController::AddObserver |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 TInt CCamStartupLogoController::AddObserver( |
|
84 MCamStartupLogoControllerObserver* aObserver) |
|
85 { |
|
86 return iObservers.Append(aObserver); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CCamStartupLogoController::RemoveObserver |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CCamStartupLogoController::RemoveObserver( |
|
94 MCamStartupLogoControllerObserver* aObserver) |
|
95 { |
|
96 TInt index = iObservers.Find(aObserver); |
|
97 if (index >= 0) |
|
98 { |
|
99 iObservers.Remove(index); |
|
100 } |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CCamStartupLogoController::State |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 TStartupLogoState CCamStartupLogoController::State() const |
|
108 { |
|
109 return iState; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CCamStartupLogoController::ShowLogo |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 void CCamStartupLogoController::ShowLogo() |
|
117 { |
|
118 PRINT(_L("Camera <> CCamStartupLogoController::ShowLogo")); |
|
119 |
|
120 if (iFailSafeTimer) |
|
121 { |
|
122 iFailSafeTimer->Cancel(); |
|
123 iFailSafeTimer->Start(TTimeIntervalMicroSeconds32(KCamFailSafeTimeout), |
|
124 TTimeIntervalMicroSeconds32(KCamFailSafeTimeout), |
|
125 TCallBack(FailSafeCallback, this)); |
|
126 } |
|
127 |
|
128 SetState(EStartupLogoVisible); |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CCamStartupLogoController::HideLogo |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CCamStartupLogoController::HideLogo() |
|
136 { |
|
137 PRINT(_L("Camera <> CCamStartupLogoController::HideLogo")); |
|
138 |
|
139 // Hide immediately |
|
140 SetState(EStartupLogoNotVisible); |
|
141 if (iFailSafeTimer) |
|
142 { |
|
143 iFailSafeTimer->Cancel(); |
|
144 } |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // CCamStartupLogoController::SetState |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CCamStartupLogoController::SetState(TStartupLogoState aNewState) |
|
152 { |
|
153 PRINT1(_L("Camera => CCamStartupLogoController::SetState %d"), aNewState); |
|
154 |
|
155 if (iState != aNewState) |
|
156 { |
|
157 iState = aNewState; |
|
158 for (TInt i=0; i<iObservers.Count(); i++) |
|
159 { |
|
160 iObservers[i]->StartupLogoControllerStateChanged(aNewState); |
|
161 } |
|
162 } |
|
163 PRINT1(_L("Camera <= CCamStartupLogoController::SetState %d"), aNewState); |
|
164 } |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // CCamStartupLogoController::FailSafeCallback |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 TInt CCamStartupLogoController::FailSafeCallback(TAny* ptr) |
|
171 { |
|
172 PRINT(_L("Camera <> CCamStartupLogoController::FailSafeCallback")); |
|
173 |
|
174 CCamStartupLogoController* self = static_cast<CCamStartupLogoController*>(ptr); |
|
175 if (self) |
|
176 { |
|
177 self->HideLogo(); |
|
178 if (self->iFailSafeTimer) |
|
179 { |
|
180 self->iFailSafeTimer->Cancel(); |
|
181 } |
|
182 } |
|
183 return 0; |
|
184 } |
|