|
1 /* |
|
2 * Copyright (c) 2006 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <coemain.h> |
|
22 |
|
23 #include "IptvDebug.h" |
|
24 |
|
25 #include <aknViewAppUi.h> |
|
26 #include <AknWaitDialog.h> |
|
27 #include <StringLoader.h> |
|
28 #include <apgwgnam.h> |
|
29 #include <aknnotewrappers.h> |
|
30 #include <e32property.h> |
|
31 #include "CIptvResourceLoader.h" |
|
32 #include <vcxnotifier.rsg> |
|
33 #include "vcxnotifier.h" |
|
34 |
|
35 // CONSTANTS |
|
36 _LIT( KvcNotifierResFile, "\\Resource\\Plugins\\vcxnotifier."); |
|
37 |
|
38 // |
|
39 // ---------------------------------------------------------- |
|
40 // CVcXNotifier::NewL() |
|
41 // ---------------------------------------------------------- |
|
42 // |
|
43 MEikSrvNotifierBase2* CVcXNotifier::NewL() |
|
44 { |
|
45 IPTVLOGSTRING_LOW_LEVEL("CIptvVodNotifier::NewL"); |
|
46 |
|
47 CVcXNotifier* self = new(ELeave) CVcXNotifier(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 |
|
52 |
|
53 // |
|
54 // ---------------------------------------------------------- |
|
55 // CVcXNotifier::CVcXNotifier() |
|
56 // ---------------------------------------------------------- |
|
57 // |
|
58 CVcXNotifier::CVcXNotifier() |
|
59 { |
|
60 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::CVcXNotifier"); |
|
61 } |
|
62 |
|
63 // |
|
64 // ---------------------------------------------------------- |
|
65 // CVcXNotifier::~CVcXNotifier() |
|
66 // ---------------------------------------------------------- |
|
67 // |
|
68 CVcXNotifier::~CVcXNotifier() |
|
69 { |
|
70 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::~CVcXNotifier"); |
|
71 |
|
72 if ( iWaitDialog ) |
|
73 { |
|
74 iWaitDialog->SetCallback( NULL ); |
|
75 TRAPD( err, iWaitDialog->ProcessFinishedL() ); |
|
76 if( err != KErrNone ) |
|
77 { |
|
78 delete iWaitDialog; |
|
79 } |
|
80 iWaitDialog = NULL; |
|
81 } |
|
82 |
|
83 delete iResourceLoader; |
|
84 |
|
85 } |
|
86 |
|
87 // |
|
88 // ---------------------------------------------------------- |
|
89 // CVcXNotifier::Release() |
|
90 // ---------------------------------------------------------- |
|
91 // |
|
92 void CVcXNotifier::Release() |
|
93 { |
|
94 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::Release"); |
|
95 delete this; |
|
96 } |
|
97 |
|
98 // |
|
99 // ---------------------------------------------------------- |
|
100 // CVcXNotifier::RegisterL() |
|
101 // ---------------------------------------------------------- |
|
102 // |
|
103 MEikSrvNotifierBase2::TNotifierInfo CVcXNotifier::RegisterL() |
|
104 { |
|
105 IPTVLOGSTRING_LOW_LEVEL("CIptvVodNotifier::RegisterL"); |
|
106 |
|
107 iInfo.iUid = KVcxNotifierImplUid; |
|
108 iInfo.iChannel = KVcxNotifierImplUid; |
|
109 iInfo.iPriority = MEikSrvNotifierBase2::ENotifierPriorityHigh; |
|
110 return iInfo; |
|
111 } |
|
112 |
|
113 // |
|
114 // ---------------------------------------------------------- |
|
115 // CVcXNotifier::Info() |
|
116 // ---------------------------------------------------------- |
|
117 // |
|
118 MEikSrvNotifierBase2::TNotifierInfo CVcXNotifier::Info() const |
|
119 { |
|
120 return iInfo; |
|
121 } |
|
122 |
|
123 // |
|
124 // ---------------------------------------------------------- |
|
125 // CVcXNotifier::StartL() |
|
126 // ---------------------------------------------------------- |
|
127 // |
|
128 TPtrC8 CVcXNotifier::StartL(const TDesC8& /*aBuffer*/ ) |
|
129 { |
|
130 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::StartL"); |
|
131 // Synch usage not allowde |
|
132 TPtrC8 ret(KNullDesC8); |
|
133 return (ret); |
|
134 } |
|
135 |
|
136 // |
|
137 // ---------------------------------------------------------- |
|
138 // CVcXNotifier::StartL() |
|
139 // ---------------------------------------------------------- |
|
140 // |
|
141 void CVcXNotifier::StartL(const TDesC8& aBuffer, |
|
142 TInt /*aReturnVal*/, |
|
143 const RMessagePtr2& aMessage ) |
|
144 { |
|
145 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::StartL"); |
|
146 TPckg<TVcxNotifierParams> params( iParams ); |
|
147 params.Copy( aBuffer ); |
|
148 if( !iAsyncResp.IsNull() ) |
|
149 { |
|
150 // "gracefully" close waiting active objects |
|
151 iAsyncResp.Complete( KErrNone ); |
|
152 } |
|
153 |
|
154 if( !iResourceLoader ) |
|
155 { |
|
156 LoadResourcesL(); |
|
157 } |
|
158 |
|
159 switch (iParams.iEvent) |
|
160 { |
|
161 case TVcxNotifierParams::EConnecting: |
|
162 // New completed download, get new counter value |
|
163 iAsyncResp = aMessage; |
|
164 DisplayWaitNoteL(); |
|
165 // message will be completed after |
|
166 // dialog have been dismissed or |
|
167 // when close request is received from client |
|
168 break; |
|
169 |
|
170 case TVcxNotifierParams::EConnected: |
|
171 CloseWaitNote( ); |
|
172 aMessage.Complete( KErrNone ); |
|
173 break; |
|
174 default: |
|
175 break; |
|
176 } |
|
177 } |
|
178 |
|
179 // |
|
180 // ---------------------------------------------------------- |
|
181 // CVcXNotifier::Cancel() |
|
182 // ---------------------------------------------------------- |
|
183 // |
|
184 void CVcXNotifier::Cancel() |
|
185 { |
|
186 if( !iAsyncResp.IsNull() ) |
|
187 { |
|
188 iAsyncResp.Complete( KErrCancel ); |
|
189 } |
|
190 CloseWaitNote(); |
|
191 |
|
192 delete iResourceLoader; |
|
193 iResourceLoader = NULL; |
|
194 } |
|
195 |
|
196 // |
|
197 // ---------------------------------------------------------- |
|
198 // CVcXNotifier::UpdateL() |
|
199 // ---------------------------------------------------------- |
|
200 // |
|
201 TPtrC8 CVcXNotifier::UpdateL(const TDesC8& /*aBuffer*/) |
|
202 { |
|
203 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::UpdateL"); |
|
204 |
|
205 return TPtrC8(); |
|
206 } |
|
207 |
|
208 // |
|
209 // ---------------------------------------------------------- |
|
210 // CVcXNotifier::NotifierCapabilites() |
|
211 // ---------------------------------------------------------- |
|
212 // |
|
213 TInt CVcXNotifier::NotifierCapabilites() |
|
214 { |
|
215 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::NotifierCapabilites"); |
|
216 |
|
217 return EScreenDeviceChangeSupported; |
|
218 } |
|
219 |
|
220 // |
|
221 // ---------------------------------------------------------- |
|
222 // CVcXNotifier::DialogDismissedL( |
|
223 // ---------------------------------------------------------- |
|
224 // |
|
225 void CVcXNotifier::DialogDismissedL( TInt /* aButtonId */ ) |
|
226 { |
|
227 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::DialogDismissedL"); |
|
228 if( !iAsyncResp.IsNull() ) |
|
229 { |
|
230 iAsyncResp.Complete( KErrCancel ); |
|
231 } |
|
232 } |
|
233 |
|
234 // |
|
235 // ---------------------------------------------------------- |
|
236 // CVcXNotifier::DisplayWaitNoteL |
|
237 // ---------------------------------------------------------- |
|
238 // |
|
239 void CVcXNotifier::DisplayWaitNoteL() |
|
240 { |
|
241 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::DisplayWaitNoteL"); |
|
242 |
|
243 CloseWaitNote(); |
|
244 |
|
245 if( iResourceLoader ) |
|
246 { |
|
247 iWaitDialog = new (ELeave) CAknWaitDialog( |
|
248 (REINTERPRET_CAST( CEikDialog**, &iWaitDialog )), |
|
249 ETrue ); |
|
250 HBufC* text(NULL); |
|
251 if( iParams.iMsg.Length() ) |
|
252 { |
|
253 text = StringLoader::LoadLC( R_IPTV_CON_UTIL_CONNECTING_VIA_NOTE, iParams.iMsg ); |
|
254 } |
|
255 else |
|
256 { |
|
257 text = StringLoader::LoadLC( R_IPTV_CON_UTIL_CONNECTING_NOTE ); |
|
258 } |
|
259 iWaitDialog->SetCallback( this ); |
|
260 iWaitDialog->SetTextL( *text ); |
|
261 CleanupStack::PopAndDestroy( text ); |
|
262 iWaitDialog->ExecuteLD( R_IPTV_CON_UTIL_COMMON_WAIT_NOTE ); |
|
263 } |
|
264 } |
|
265 |
|
266 // |
|
267 // ---------------------------------------------------------- |
|
268 // CVcXNotifier::CloseWaitNote |
|
269 // ---------------------------------------------------------- |
|
270 // |
|
271 void CVcXNotifier::CloseWaitNote() |
|
272 { |
|
273 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::CloseWaitNote"); |
|
274 if ( iWaitDialog ) |
|
275 { |
|
276 TRAPD(error, iWaitDialog->ProcessFinishedL()); |
|
277 if ( error != KErrNone ) |
|
278 { |
|
279 delete iWaitDialog; |
|
280 } |
|
281 iWaitDialog = NULL; |
|
282 } |
|
283 } |
|
284 |
|
285 // |
|
286 // ---------------------------------------------------------- |
|
287 // CVcXNotifier::LoadResourcesL |
|
288 // ---------------------------------------------------------- |
|
289 // |
|
290 void CVcXNotifier::LoadResourcesL() |
|
291 { |
|
292 IPTVLOGSTRING_LOW_LEVEL("CVcXNotifier::LoadResourcesL"); |
|
293 |
|
294 CCoeEnv* env = CCoeEnv::Static(); |
|
295 if( env ) |
|
296 { |
|
297 iResourceLoader = CIptvResourceLoader::NewL( *env ); |
|
298 if (iResourceLoader) |
|
299 { |
|
300 iResourceLoader->AddResourceL( KvcNotifierResFile ); |
|
301 } |
|
302 else |
|
303 { |
|
304 User::Leave( KErrGeneral ); |
|
305 } |
|
306 } |
|
307 } |
|
308 // end of file |