|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation of the SyncML Appserver starter notifier |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <centralrepository.h> |
|
22 #include <CoreApplicationUIsSDKCRKeys.h> |
|
23 #include <settingsinternalcrkeys.h> |
|
24 #include <e32property.h> |
|
25 #include <coreapplicationuisdomainpskeys.h> |
|
26 #include <eikenv.h> // Eikon environment |
|
27 #include <uikon/eiksrvui.h> // Eikon server ui (for suppressing app -key) |
|
28 #include <bautils.h> // BAFL utils (for language file) |
|
29 #include <data_caging_path_literals.hrh> |
|
30 #include <AknNotiferAppServerApplication.h> |
|
31 |
|
32 #include "SyncMLNotifierBase.h" |
|
33 #include "SyncMLNotifDebug.h" |
|
34 |
|
35 // CONSTANTS |
|
36 // Literals for resource and bitmap files ( drive, directory, filename(s) ) |
|
37 _LIT(KFileDrive,"z:"); |
|
38 _LIT(KResourceFileName, "SyncMLNotifier.rsc"); |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CSyncMLNotifierBase::CSyncMLNotifierBase |
|
44 // C++ default constructor can NOT contain any code, that |
|
45 // might leave. Sets the AOs priority and puts |
|
46 // itself to the active scheduler stack. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CSyncMLNotifierBase::CSyncMLNotifierBase() : CActive(EPriorityStandard) |
|
50 { |
|
51 CActiveScheduler::Add(this); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CSyncMLNotifierBase::ConstructL |
|
56 // Symbian 2nd phase constructor can leave. |
|
57 // Create registry object and open resource file. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CSyncMLNotifierBase::ConstructL() |
|
61 { |
|
62 FLOG(_L("[SmlNotif]\t CSyncMLNotifierBase::ConstructL()")); |
|
63 |
|
64 iEikEnv = CEikonEnv::Static(); |
|
65 |
|
66 TFileName filename; |
|
67 filename += KFileDrive; |
|
68 filename += KDC_RESOURCE_FILES_DIR; |
|
69 filename += KResourceFileName; |
|
70 BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename ); |
|
71 iResourceFileFlag = iEikEnv->AddResourceFileL( filename ); |
|
72 FLOG(_L("[SmlNotif]\t CSyncMLNotifierBase::ConstructL() completed")); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // Destructor. |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 CSyncMLNotifierBase::~CSyncMLNotifierBase() |
|
80 { |
|
81 Cancel(); |
|
82 iEikEnv->DeleteResourceFile( iResourceFileFlag ); |
|
83 |
|
84 // Complete the RMessage2 if needed |
|
85 // |
|
86 if ( iNeedToCompleteMessage ) |
|
87 { |
|
88 iMessage.Complete( KErrDied ); |
|
89 } |
|
90 |
|
91 // Activate apps -key again (if not previously activated yet) |
|
92 SuppressAppSwitching( EFalse ); |
|
93 |
|
94 iReplySlot = NULL; |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CSyncMLNotifierBase::Release |
|
99 // Release itself. Call to destructor. |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CSyncMLNotifierBase::Release() |
|
103 { |
|
104 delete this; |
|
105 } |
|
106 |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CSyncMLNotifierBase::Info |
|
110 // Return registered information. |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 CSyncMLNotifierBase::TNotifierInfo CSyncMLNotifierBase::Info() const |
|
114 { |
|
115 return iInfo; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CSyncMLNotifierBase::StartL |
|
120 // Synchronic notifier launch. Does nothing here. |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 TPtrC8 CSyncMLNotifierBase::StartL( const TDesC8& /*aBuffer*/ ) |
|
124 { |
|
125 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::StartL(sync)") ); |
|
126 TPtrC8 ret( KNullDesC8 ); |
|
127 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::StartL(sync) completed") ); |
|
128 return ( ret ); |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CSyncMLNotifierBase::StartL |
|
133 // Asynchronic notifier launch. |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CSyncMLNotifierBase::StartL( const TDesC8& aBuffer, |
|
137 TInt aReplySlot, |
|
138 const RMessagePtr2& aMessage ) |
|
139 { |
|
140 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::StartL(async)") ); |
|
141 TRAPD( err, GetParamsL( aBuffer, aReplySlot, aMessage ) ); |
|
142 if ( err ) |
|
143 { |
|
144 aMessage.Complete( err ); |
|
145 iNeedToCompleteMessage = EFalse; |
|
146 User::Leave( err ); |
|
147 } |
|
148 FLOG(_L("[SmlNotif]\t CSyncMLNotifierBase::StartL(async) completed")); |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CSyncMLNotifierBase::Cancel |
|
153 // Cancelling method. |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CSyncMLNotifierBase::Cancel() |
|
157 { |
|
158 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::Cancel()") ); |
|
159 if (iNeedToCompleteMessage) |
|
160 { |
|
161 iMessage.Complete(KErrCancel); |
|
162 iNeedToCompleteMessage = EFalse; |
|
163 } |
|
164 iNeedToCompleteMessage = EFalse; |
|
165 iReplySlot = NULL; |
|
166 |
|
167 // Activate apps -key again (if not previously activated yet) |
|
168 SuppressAppSwitching( EFalse ); |
|
169 |
|
170 CActive::Cancel(); |
|
171 |
|
172 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::Cancel() completed") ); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CSyncMLNotifierBase::UpdateL |
|
177 // Notifier update. Not supported. |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 TPtrC8 CSyncMLNotifierBase::UpdateL(const TDesC8& /*aBuffer*/) |
|
181 { |
|
182 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::UpdateL()") ); |
|
183 TPtrC8 ret(KNullDesC8); |
|
184 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::UpdateL() completed") ); |
|
185 return ret; |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CSyncMLNotifierBase::DoCancel |
|
190 // This method will be called by framework (CActive) |
|
191 // if active object is still active. |
|
192 // Does nothing here. |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void CSyncMLNotifierBase::DoCancel() |
|
196 { |
|
197 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::DoCancel()") ); |
|
198 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::DoCancel()--End") ); |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CSyncMLNotifierBase::RunError |
|
203 // This method is called if any leaving has been occured |
|
204 // during RunL. Optional method for CActive derived objects. |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 TInt CSyncMLNotifierBase::RunError( TInt aError ) |
|
208 { |
|
209 FTRACE( FPrint( _L("[SmlNotif]\t CSyncMLNotifierBase::RunError() Error = %d"), aError ) ); |
|
210 // Activate apps -key again (if not previously activated yet) |
|
211 SuppressAppSwitching( EFalse ); |
|
212 |
|
213 // Complete message if needed and return the error code. |
|
214 if( iNeedToCompleteMessage ) |
|
215 { |
|
216 iMessage.Complete( aError ); |
|
217 } |
|
218 iNeedToCompleteMessage = EFalse; |
|
219 iReplySlot = NULL; |
|
220 |
|
221 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::RunError() completed") ); |
|
222 |
|
223 return KErrNone; |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CSyncMLNotifierBase::TurnLightsOn |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 void CSyncMLNotifierBase::TurnLightsOn() |
|
231 { |
|
232 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::TurnLightsOn()") ); |
|
233 |
|
234 RProperty::Set( KPSUidCoreApplicationUIs, KLightsControl, ELightsOn ); |
|
235 RProperty::Set( KPSUidCoreApplicationUIs, KLightsControl, ELightsOff ); |
|
236 |
|
237 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::TurnLightsOn() completed") ); |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CSyncMLNotifierBase::AutoLockOnL |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 TBool CSyncMLNotifierBase::AutoLockOnL() |
|
245 { |
|
246 FLOG( _L("[SmlNotif]\t CSyncMLNotifierBase::AutoLockOnL()") ); |
|
247 |
|
248 TBool result = EFalse; |
|
249 TInt status = 1; |
|
250 |
|
251 // Connecting and initialization: |
|
252 CRepository* repository = CRepository::NewL( KCRUidSecuritySettings ); |
|
253 |
|
254 repository->Get( KSettingsAutolockStatus, status ); |
|
255 |
|
256 // Closing connection: |
|
257 delete repository; |
|
258 |
|
259 if ( status == 1 ) |
|
260 { |
|
261 result = ETrue; |
|
262 } |
|
263 |
|
264 FTRACE( FPrint( |
|
265 _L("[SmlNotif]\t CSyncMLNotifierBase::AutoLockOnL() completed with %d"), |
|
266 result ) ); |
|
267 |
|
268 return result; |
|
269 } |
|
270 |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CSyncMLNotifierBase::SuppressAppSwitchching |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 void CSyncMLNotifierBase::SuppressAppSwitching( TBool aEnable ) |
|
277 { |
|
278 if ( iAppsKeyBlocked != aEnable ) |
|
279 { |
|
280 TInt err = ( ( CAknNotifierAppServerAppUi* ) |
|
281 ( CEikonEnv::Static() )->EikAppUi() )-> |
|
282 SuppressAppSwitching( aEnable ); |
|
283 iAppsKeyBlocked = aEnable; |
|
284 } |
|
285 } |
|
286 |
|
287 // End of File |