|
1 /* |
|
2 * Copyright (c) 2002-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: factory settings for active space |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <centralrepository.h> |
|
20 #include <menudebug.h> |
|
21 #include <apadef.h> |
|
22 #include <AknDef.hrh> |
|
23 #include "hnrepositoryobserver.h" |
|
24 #include "hnglobals.h" |
|
25 #include "hnsuitemodelcontainer.h" |
|
26 #include "hnsuitemodel.h" |
|
27 #include "hnmdsuite.h" |
|
28 #include "hnitemsorder.h" |
|
29 #include "hnliwutils.h" |
|
30 #include "hnmdbasekey.h" |
|
31 #include "hnmdkeyfactory.h" |
|
32 #include "hnconvutils.h" |
|
33 #include "hnsuiteobserver.h" |
|
34 #include "hnmdmodel.h" |
|
35 |
|
36 class CHnServiceHandler; |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 void CHnRepositoryObserver::ConstructL( const TUid aRepositoryUid ) |
|
42 { |
|
43 iRepository = CRepository::NewL( aRepositoryUid ); |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CHnRepositoryObserver::CHnRepositoryObserver( THnMdCommonPointers* aCmnPtrs ) |
|
51 : iCmnPtrs(aCmnPtrs) |
|
52 { |
|
53 |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CHnRepositoryObserver::CHnRepositoryObserver( THnMdCommonPointers* aCmnPtrs, TUint32 aId ) |
|
61 : iId( aId ), iCmnPtrs(aCmnPtrs) |
|
62 { |
|
63 |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CHnRepositoryObserver::~CHnRepositoryObserver() |
|
71 { |
|
72 if (iNotifyHandler) |
|
73 iNotifyHandler->StopListening(); |
|
74 delete iNotifyHandler; |
|
75 delete iRepository; |
|
76 } |
|
77 |
|
78 |
|
79 // class CHnRepositoryWidgetTypeObserver |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CHnRepositoryWidgetTypeObserver * CHnRepositoryWidgetTypeObserver::NewL( |
|
85 THnMdCommonPointers* aCmnPtrs, const TUid aRepositoryUid ) |
|
86 { |
|
87 CHnRepositoryWidgetTypeObserver * self = CHnRepositoryWidgetTypeObserver::NewLC( aCmnPtrs, aRepositoryUid ); |
|
88 CleanupStack::Pop(self); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CHnRepositoryWidgetTypeObserver * CHnRepositoryWidgetTypeObserver::NewLC( |
|
97 THnMdCommonPointers* aCmnPtrs, const TUid aRepositoryUid ) |
|
98 { |
|
99 CHnRepositoryWidgetTypeObserver * self = new (ELeave) CHnRepositoryWidgetTypeObserver( aCmnPtrs ); |
|
100 CleanupStack::PushL(self); |
|
101 self->ConstructL( aRepositoryUid ); |
|
102 return self; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 // --------------------------------------------------------------------------- |
|
108 // |
|
109 void CHnRepositoryWidgetTypeObserver::ConstructL( const TUid aRepositoryUid ) |
|
110 { |
|
111 CHnRepositoryObserver::ConstructL( aRepositoryUid ); |
|
112 iNotifyHandler = CCenRepNotifyHandler::NewL(*this, *iRepository ); |
|
113 iNotifyHandler->StartListeningL(); |
|
114 } |
|
115 |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CHnRepositoryWidgetTypeObserver::CHnRepositoryWidgetTypeObserver( THnMdCommonPointers* aCmnPtrs ) |
|
122 : CHnRepositoryObserver( aCmnPtrs ) |
|
123 { |
|
124 |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 CHnRepositoryWidgetTypeObserver::~CHnRepositoryWidgetTypeObserver() |
|
132 { |
|
133 iWidgetSwitches.Close(); |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 // --------------------------------------------------------------------------- |
|
139 // |
|
140 void CHnRepositoryWidgetTypeObserver::HandleNotifyGeneric(TUint32 aId) |
|
141 { |
|
142 TRAP_IGNORE( HandleNotifyGenericL(aId) ); |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 void CHnRepositoryWidgetTypeObserver::HandleNotifyGenericL(TUint32 aId) |
|
150 { |
|
151 DEBUG(("_MM_:CHnRepositoryObserver::HandleNotifyGeneric IN")); |
|
152 DEBUG(("\tID: %d",aId)); |
|
153 THnSuiteWidgetType suiteState( EUnspecified ); |
|
154 |
|
155 iRepository->Get( aId, (int &) suiteState); |
|
156 TInt id = iWidgetSwitches.Find(aId); |
|
157 |
|
158 if ( suiteState == EChangeWidget ) |
|
159 { |
|
160 iWidgetSwitches.AppendL(aId); |
|
161 } |
|
162 else if ( id != KErrNotFound ) |
|
163 { |
|
164 iWidgetSwitches.Remove(id); |
|
165 return; |
|
166 } |
|
167 |
|
168 CHnSuiteModel* lastSuiteModel = iCmnPtrs->iContainer->GetLastSuiteModel(); |
|
169 TBuf <NCentralRepositoryConstants::KMaxUnicodeStringLength> suiteName; |
|
170 if ( iRepository->Get( aId - 1, suiteName ) == KErrNone && lastSuiteModel |
|
171 && lastSuiteModel->WidgetType() != suiteState ) |
|
172 { |
|
173 DEBUG16(("\t\tSuite Name: %S",&suiteName)); |
|
174 lastSuiteModel->GetItemsOrder()->MarkSuiteUninitialized(); |
|
175 |
|
176 TInt32 suiteId = lastSuiteModel->CustomId(); |
|
177 |
|
178 CLiwGenericParamList* inParam = CLiwGenericParamList::NewL(); |
|
179 CleanupStack::PushL( inParam ); |
|
180 |
|
181 CLiwDefaultMap* map = CLiwDefaultMap::NewLC(); |
|
182 |
|
183 map->InsertL( KGenreName8, TLiwVariant(suiteName) ); |
|
184 map->InsertL( KId8, TLiwVariant(suiteId) ); |
|
185 inParam->AppendL(TLiwGenericParam( KFilterElementItem8, TLiwVariant(map) )); |
|
186 CleanupStack::PopAndDestroy( map ); |
|
187 |
|
188 iCmnPtrs->iModelEventObserver->HandleModelEventL( KReevaluateMdEvent, *inParam ); |
|
189 |
|
190 CleanupStack::PopAndDestroy( inParam ); |
|
191 } |
|
192 DEBUG(("_MM_:CHnRepositoryObserver::HandleNotifyGeneric OUT")); |
|
193 } |
|
194 |
|
195 |
|
196 // class CHnRepositoryShowFolderObserver |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 CHnRepositoryShowFolderObserver * CHnRepositoryShowFolderObserver::NewL( |
|
202 THnMdCommonPointers* aCmnPtrs, const TUid aRepositoryUid, const TUint32 aId ) |
|
203 { |
|
204 CHnRepositoryShowFolderObserver * self = CHnRepositoryShowFolderObserver::NewLC( aCmnPtrs, aRepositoryUid, aId ); |
|
205 CleanupStack::Pop(self); |
|
206 return self; |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 CHnRepositoryShowFolderObserver * CHnRepositoryShowFolderObserver::NewLC( |
|
214 THnMdCommonPointers* aCmnPtrs, const TUid aRepositoryUid, const TUint32 aId ) |
|
215 { |
|
216 CHnRepositoryShowFolderObserver * self = new (ELeave) CHnRepositoryShowFolderObserver( aCmnPtrs, aId ); |
|
217 CleanupStack::PushL(self); |
|
218 self->ConstructL( aRepositoryUid ); |
|
219 return self; |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 void CHnRepositoryShowFolderObserver::ConstructL( const TUid aRepositoryUid ) |
|
227 { |
|
228 CHnRepositoryObserver::ConstructL( aRepositoryUid ); |
|
229 TInt ret = iRepository->Create( iId, KBlank ); |
|
230 iNotifyHandler = CCenRepNotifyHandler::NewL( |
|
231 *this, *iRepository, |
|
232 CCenRepNotifyHandler::EStringKey, iId ); |
|
233 iNotifyHandler->StartListeningL(); |
|
234 } |
|
235 |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 CHnRepositoryShowFolderObserver::CHnRepositoryShowFolderObserver( THnMdCommonPointers* aCmnPtrs, TUint32 aId ) |
|
242 : CHnRepositoryObserver( aCmnPtrs, aId ) |
|
243 { |
|
244 |
|
245 } |
|
246 |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 CHnRepositoryShowFolderObserver::~CHnRepositoryShowFolderObserver() |
|
252 { |
|
253 delete iServiceHandler; |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 void CHnRepositoryShowFolderObserver::HandleNotifyString(TUint32 aId, const TDesC16& aNewValue ) |
|
261 { |
|
262 TRAP_IGNORE( HandleNotifyStringL(aId, aNewValue) ); |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void CHnRepositoryShowFolderObserver::HandleNotifyStringL(TUint32 aId, const TDesC16& aNewValue) |
|
270 { |
|
271 DEBUG(("_MM_:CHnRepositoryShowFolderObserver::HandleNotifyStringL IN")); |
|
272 DEBUG(("\tID: %d : %S", aId, &aNewValue)); |
|
273 |
|
274 //++Show Folder |
|
275 if( aId == iId && aNewValue.Length()) |
|
276 { |
|
277 iNotifyType = 0; |
|
278 ExtractCRKeyShowFolderName( aNewValue ); |
|
279 |
|
280 // iCRKeyFolderItemUid can contain mcs id or uid |
|
281 // in case of uid it will be replaced whith id in HandleNotifyL callback |
|
282 if( iCRKeyFolderItemUid.Length()>0 ) |
|
283 { |
|
284 if( iCRKeyFolderItemUid.FindF( KHexPrefix8 )==0 ) |
|
285 { |
|
286 iNotifyType |= EAPP_UID; |
|
287 } |
|
288 else |
|
289 { |
|
290 iNotifyType |= EAPP_ID; |
|
291 } |
|
292 } |
|
293 |
|
294 CHnMdBaseKey* inDataKey = HnMdKeyFactory::CreateL( |
|
295 KInData8, KKeyTypeMap, KDefaultParentId8 ); |
|
296 CleanupStack::PushL( inDataKey ); |
|
297 |
|
298 CHnMdBaseKey* filter( NULL ); |
|
299 HBufC8* id( NULL ); |
|
300 if ( iCRKeyFolderName.Length()>0 && !( iNotifyType & EAPP_UID ) ) |
|
301 { |
|
302 // app group name is known |
|
303 // id is optional |
|
304 id = HnConvUtils::NumToStr8LC( KRootId ); |
|
305 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KType8, KKeyTypeString, KMenuFolder8 ) ); |
|
306 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KIdParam, KKeyTypeInteger, *id ) ); |
|
307 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KRecursiveSearch8, KKeyTypeBoolean, KStringTrue8 ) ); |
|
308 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KFlatResult8, KKeyTypeBoolean, KStringTrue8 ) ); |
|
309 |
|
310 filter = HnMdKeyFactory::CreateL( |
|
311 KFilter8, KKeyTypeMap, KStringTrue8 ); |
|
312 CleanupStack::PushL( filter ); |
|
313 filter->AddSubKeyL( HnMdKeyFactory::CreateL( KMcsAppGroupName8, KKeyTypeString, iCRKeyFolderName ) ); |
|
314 filter->AddSubKeyL( HnMdKeyFactory::CreateL( KType8, KKeyTypeString, KMenuFolder8 ) ); |
|
315 filter->AddSubKeyL( HnMdKeyFactory::CreateL( KHidden8, KKeyTypeBoolean, KStringFalse8 ) ); |
|
316 } |
|
317 else if( iNotifyType & EAPP_ID ) |
|
318 { |
|
319 // no app group name, id is known |
|
320 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KType8, KKeyTypeString, KMenuApplication8 ) ); |
|
321 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KIdParam, KKeyTypeInteger, iCRKeyFolderItemUid ) ); |
|
322 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KParentOnly8, KKeyTypeBoolean, KStringTrue8 ) ); |
|
323 } |
|
324 else if( iNotifyType & EAPP_UID ) |
|
325 { |
|
326 // uid is known |
|
327 // app group name is optional |
|
328 id = HnConvUtils::NumToStr8LC( KRootId ); |
|
329 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KType8, KKeyTypeString, KMenuFolder8 ) ); |
|
330 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KIdParam, KKeyTypeInteger, *id ) ); |
|
331 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KRecursiveSearch8, KKeyTypeBoolean, KStringTrue8 ) ); |
|
332 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KFlatResult8, KKeyTypeBoolean, KStringTrue8 ) ); |
|
333 |
|
334 filter = HnMdKeyFactory::CreateL( |
|
335 KFilter8, KKeyTypeMap, KStringTrue8 ); |
|
336 CleanupStack::PushL( filter ); |
|
337 filter->AddSubKeyL( HnMdKeyFactory::CreateL( KUid8, KKeyTypeInteger, iCRKeyFolderItemUid ) ); |
|
338 filter->AddSubKeyL( HnMdKeyFactory::CreateL( KType8, KKeyTypeString, KMenuApplication8 ) ); |
|
339 filter->AddSubKeyL( HnMdKeyFactory::CreateL( KHidden8, KKeyTypeBoolean, KStringFalse8 ) ); |
|
340 } |
|
341 else |
|
342 { |
|
343 // No app group name, no uid. Search for root. |
|
344 id = HnConvUtils::NumToStr8LC( KRootId ); |
|
345 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KType8, KKeyTypeString, KMenuFolder8 ) ); |
|
346 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KIdParam, KKeyTypeInteger, *id ) ); |
|
347 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KParentOnly8, KKeyTypeBoolean, KStringTrue8 ) ); |
|
348 } |
|
349 |
|
350 RPointerArray< CHnMdBaseKey > data; |
|
351 CleanupClosePushL( data ); |
|
352 data.AppendL( inDataKey ); |
|
353 if ( filter ) |
|
354 { |
|
355 data.AppendL( filter ); |
|
356 } |
|
357 |
|
358 CHnMdBaseKey* serviceData = HnMdKeyFactory::CreateL( |
|
359 KServiceContentName, KKeyTypeString, KMatrixMenuData ); |
|
360 CleanupStack::PushL( serviceData ); |
|
361 |
|
362 RPointerArray< CHnMdBaseKey> constructor; |
|
363 CleanupClosePushL( constructor ); |
|
364 constructor.AppendL( serviceData ); |
|
365 CLiwGenericParamList* constructorLiw = CLiwGenericParamList::NewLC(); |
|
366 CLiwGenericParamList* commandLiw = CLiwGenericParamList::NewLC(); |
|
367 HnLiwUtils::SetGenericParamListL( constructor, *constructorLiw ); |
|
368 HnLiwUtils::SetGenericParamListL( data, *commandLiw ); |
|
369 |
|
370 TBuf8< KMaxLength > interface( KMCSDataSourceInterface8 ); |
|
371 |
|
372 delete iServiceHandler; |
|
373 iServiceHandler = NULL; |
|
374 iServiceHandler = CHnServiceHandler::NewL( |
|
375 KMCSService8, interface, KCmdGetList8, |
|
376 EServiceModeAsynchronous, constructorLiw, commandLiw ); |
|
377 |
|
378 CleanupStack::Pop( commandLiw ); |
|
379 CleanupStack::Pop( constructorLiw ); |
|
380 |
|
381 iServiceHandler->ExecuteL( this ); |
|
382 |
|
383 CleanupStack::PopAndDestroy( &constructor ); |
|
384 CleanupStack::PopAndDestroy( serviceData ); |
|
385 CleanupStack::PopAndDestroy( &data ); |
|
386 if( filter ) |
|
387 { |
|
388 CleanupStack::PopAndDestroy( filter ); |
|
389 } |
|
390 if( id ) |
|
391 { |
|
392 CleanupStack::PopAndDestroy( id ); |
|
393 } |
|
394 CleanupStack::PopAndDestroy( inDataKey ); |
|
395 } |
|
396 |
|
397 DEBUG(("_MM_:CHnRepositoryShowFolderObserver::HandleNotifyStringL OUT")); |
|
398 |
|
399 } |
|
400 |
|
401 // --------------------------------------------------------------------------- |
|
402 // |
|
403 // --------------------------------------------------------------------------- |
|
404 // |
|
405 void CHnRepositoryShowFolderObserver::ExtractCRKeyShowFolderName( const TDesC& aNewValue ) |
|
406 { |
|
407 DEBUG(( "_MM_:CHnRepositoryShowFolderObserver::ExtractCRKeyShowFolderName IN" )); |
|
408 iCRKeyFolderName.Copy( KBlank ); |
|
409 iCRKeyFolderItemUid.Copy( KBlank ); |
|
410 |
|
411 int keyValueLength = aNewValue.Length(); |
|
412 if( keyValueLength ) |
|
413 { |
|
414 TApaAppGroupName folder; |
|
415 TBuf<KTimeStampBufferLength + KUidStringLength + 1> tempBuf; |
|
416 TBuf<KTimeStampBufferLength> timeStamp; |
|
417 |
|
418 TInt ret = aNewValue.Find( KComma ); |
|
419 if( (ret == KErrNotFound )|| ( ret == ( keyValueLength-1 ) ) ) |
|
420 { |
|
421 DEBUG(( "_MM_:CHnRepositoryShowFolderObserver::ExtractCRKeyShowFolderName (bad CR key value input) OUT" )); |
|
422 return; //bad CR key value input |
|
423 } |
|
424 if( ret>KApaMaxAppGroupName ) |
|
425 { |
|
426 return; |
|
427 } |
|
428 folder.Copy(aNewValue.Left(ret)); |
|
429 if( aNewValue.Length()-ret > tempBuf.MaxLength() ) |
|
430 { |
|
431 return; |
|
432 } |
|
433 tempBuf.Copy(aNewValue.Mid( ret + 1 ) ); |
|
434 |
|
435 TInt posUid = tempBuf.Find( KComma ); |
|
436 if ( KErrNotFound != posUid ) |
|
437 { |
|
438 if( posUid>KTimeStampBufferLength ) |
|
439 { |
|
440 return; |
|
441 } |
|
442 timeStamp.Copy( tempBuf.Left(posUid) ); |
|
443 if( tempBuf.Length()-(posUid+1) > KUidStringLength ) |
|
444 { |
|
445 return; |
|
446 } |
|
447 iCRKeyFolderItemUid.Copy( tempBuf.Mid( posUid + 1 ) ); |
|
448 } |
|
449 else |
|
450 { |
|
451 if( tempBuf.Length()>KTimeStampBufferLength ) |
|
452 { |
|
453 return; |
|
454 } |
|
455 timeStamp.Copy( tempBuf ); |
|
456 } |
|
457 |
|
458 TTime currentTime; |
|
459 currentTime.HomeTime(); |
|
460 TTimeIntervalSeconds interval; |
|
461 |
|
462 TTime timeStampTime; |
|
463 ret = timeStampTime.Set(timeStamp); |
|
464 |
|
465 if(ret == KErrGeneral ) |
|
466 { |
|
467 DEBUG(( "_MM_:CHnRepositoryShowFolderObserver::ExtractCRKeyShowFolderName (bad timestamp) OUT" )); |
|
468 return; // bad time stamp value |
|
469 } |
|
470 |
|
471 ret = currentTime.SecondsFrom( timeStampTime, interval ); |
|
472 |
|
473 if( interval.Int() < 0 ) |
|
474 {//negative timestamp is set ahead of current time...! |
|
475 DEBUG(( "_MM_:CHnRepositoryShowFolderObserver::ExtractCRKeyShowFolderName (negative interval) OUT" )); |
|
476 return; |
|
477 } |
|
478 |
|
479 if(( interval.Int()) > KTimeStampCutOff ) |
|
480 {//positive timestamp but more than 5 seconds |
|
481 DEBUG(( "_MM_:CHnRepositoryShowFolderObserver::ExtractCRKeyShowFolderName (more than 5 seconds) OUT" )); |
|
482 return; |
|
483 } |
|
484 else |
|
485 { |
|
486 iCRKeyFolderName.Copy(folder); |
|
487 } |
|
488 } |
|
489 DEBUG(( "_MM_:CHnRepositoryShowFolderObserver::ExtractCRKeyShowFolderName OUT" )); |
|
490 } |
|
491 |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 // --------------------------------------------------------------------------- |
|
495 // |
|
496 void CHnRepositoryShowFolderObserver::GetShowFolderL( TUint32 aFolderId ) |
|
497 { |
|
498 |
|
499 CHnMdBaseKey* inDataKey = HnMdKeyFactory::CreateL( |
|
500 KInData8, KKeyTypeMap, KDefaultParentId8 ); |
|
501 CleanupStack::PushL( inDataKey ); |
|
502 HBufC8* id = HnConvUtils::NumToStr8LC( aFolderId ); |
|
503 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KType8, KKeyTypeString, KMenuFolder8 ) ); |
|
504 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KIdParam, KKeyTypeInteger, *id ) ); |
|
505 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KParentOnly8, KKeyTypeBoolean, KStringTrue8 ) ); |
|
506 |
|
507 RPointerArray< CHnMdBaseKey > data; |
|
508 CleanupClosePushL( data ); |
|
509 data.Append( inDataKey ); |
|
510 |
|
511 CHnMdBaseKey* serviceData = HnMdKeyFactory::CreateL( |
|
512 KServiceContentName, KKeyTypeString, KMatrixMenuData ); |
|
513 CleanupStack::PushL( serviceData ); |
|
514 |
|
515 RPointerArray< CHnMdBaseKey> constructor; |
|
516 CleanupClosePushL( constructor ); |
|
517 constructor.Append( serviceData ); |
|
518 CLiwGenericParamList* constructorLiw = CLiwGenericParamList::NewLC(); |
|
519 CLiwGenericParamList* commandLiw = CLiwGenericParamList::NewLC(); |
|
520 HnLiwUtils::SetGenericParamListL( constructor, *constructorLiw ); |
|
521 HnLiwUtils::SetGenericParamListL( data, *commandLiw ); |
|
522 |
|
523 TBuf8< KMaxLength > interface( KMCSDataSourceInterface8 ); |
|
524 |
|
525 delete iServiceHandler; |
|
526 iServiceHandler = NULL; |
|
527 iServiceHandler = CHnServiceHandler::NewL( |
|
528 KMCSService8, interface, KCmdGetList8, |
|
529 EServiceModeAsynchronous, constructorLiw, commandLiw ); |
|
530 |
|
531 CleanupStack::Pop( commandLiw ); |
|
532 CleanupStack::Pop( constructorLiw ); |
|
533 |
|
534 iServiceHandler->ExecuteL( this ); |
|
535 |
|
536 CleanupStack::PopAndDestroy( &constructor ); |
|
537 CleanupStack::PopAndDestroy( serviceData ); |
|
538 CleanupStack::PopAndDestroy( &data ); |
|
539 CleanupStack::PopAndDestroy( id ); |
|
540 CleanupStack::PopAndDestroy( inDataKey ); |
|
541 |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------------------------- |
|
545 // |
|
546 // --------------------------------------------------------------------------- |
|
547 // |
|
548 void CHnRepositoryShowFolderObserver::GetShowFolderGroupNameL() |
|
549 { |
|
550 |
|
551 CHnMdBaseKey* inDataKey = HnMdKeyFactory::CreateL( |
|
552 KInData8, KKeyTypeMap, KDefaultParentId8 ); |
|
553 CleanupStack::PushL( inDataKey ); |
|
554 HBufC8* id = HnConvUtils::NumToStr8LC( KRootId ); |
|
555 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KType8, KKeyTypeString, KMenuFolder8 ) ); |
|
556 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KIdParam, KKeyTypeInteger, *id ) ); |
|
557 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KRecursiveSearch8, KKeyTypeBoolean, KStringTrue8 ) ); |
|
558 inDataKey->AddSubKeyL( HnMdKeyFactory::CreateL( KFlatResult8, KKeyTypeBoolean, KStringTrue8 ) ); |
|
559 |
|
560 CHnMdBaseKey* filter = HnMdKeyFactory::CreateL( |
|
561 KFilter8, KKeyTypeMap, KStringTrue8 ); |
|
562 CleanupStack::PushL( filter ); |
|
563 filter->AddSubKeyL( HnMdKeyFactory::CreateL( KMcsAppGroupName8, KKeyTypeString, iCRKeyFolderName ) ); |
|
564 filter->AddSubKeyL( HnMdKeyFactory::CreateL( KType8, KKeyTypeString, KMenuFolder8 ) ); |
|
565 filter->AddSubKeyL( HnMdKeyFactory::CreateL( KHidden8, KKeyTypeBoolean, KStringFalse8 ) ); |
|
566 |
|
567 RPointerArray< CHnMdBaseKey > data; |
|
568 CleanupClosePushL( data ); |
|
569 data.AppendL( inDataKey ); |
|
570 if ( filter ) |
|
571 { |
|
572 data.AppendL( filter ); |
|
573 } |
|
574 |
|
575 CHnMdBaseKey* serviceData = HnMdKeyFactory::CreateL( |
|
576 KServiceContentName, KKeyTypeString, KMatrixMenuData ); |
|
577 CleanupStack::PushL( serviceData ); |
|
578 |
|
579 RPointerArray< CHnMdBaseKey> constructor; |
|
580 CleanupClosePushL( constructor ); |
|
581 constructor.Append( serviceData ); |
|
582 CLiwGenericParamList* constructorLiw = CLiwGenericParamList::NewLC(); |
|
583 CLiwGenericParamList* commandLiw = CLiwGenericParamList::NewLC(); |
|
584 HnLiwUtils::SetGenericParamListL( constructor, *constructorLiw ); |
|
585 HnLiwUtils::SetGenericParamListL( data, *commandLiw ); |
|
586 |
|
587 TBuf8< KMaxLength > interface( KMCSDataSourceInterface8 ); |
|
588 |
|
589 delete iServiceHandler; |
|
590 iServiceHandler = NULL; |
|
591 iServiceHandler = CHnServiceHandler::NewL( |
|
592 KMCSService8, interface, KCmdGetList8, |
|
593 EServiceModeAsynchronous, constructorLiw, commandLiw ); |
|
594 |
|
595 CleanupStack::Pop( commandLiw ); |
|
596 CleanupStack::Pop( constructorLiw ); |
|
597 |
|
598 iServiceHandler->ExecuteL( this ); |
|
599 |
|
600 CleanupStack::PopAndDestroy( &constructor ); |
|
601 CleanupStack::PopAndDestroy( serviceData ); |
|
602 CleanupStack::PopAndDestroy( &data ); |
|
603 CleanupStack::PopAndDestroy( filter ); |
|
604 CleanupStack::PopAndDestroy( id ); |
|
605 CleanupStack::PopAndDestroy( inDataKey ); |
|
606 |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------------------------- |
|
610 // |
|
611 // --------------------------------------------------------------------------- |
|
612 // |
|
613 TInt CHnRepositoryShowFolderObserver::HandleNotifyL( |
|
614 TInt /*aCmdId*/, |
|
615 TInt aEventId, |
|
616 CLiwGenericParamList& aEventParamList, |
|
617 const CLiwGenericParamList& /*aInParamList*/) |
|
618 { |
|
619 DEBUG(("_MM_:CHnRepositoryShowFolderObserver::HandleNotifyL IN")); |
|
620 if( aEventId == KLiwEventCanceled ) |
|
621 { |
|
622 return KErrNotFound; |
|
623 } |
|
624 else |
|
625 { |
|
626 TInt pos( 0 ); |
|
627 const TLiwGenericParam* first = aEventParamList.FindFirst( pos, KReturnValue8() ); |
|
628 if( pos==KErrNotFound ) |
|
629 { |
|
630 return KErrNotFound; |
|
631 } |
|
632 |
|
633 TInt count = first->Value().AsList()->Count(); |
|
634 if( !( iNotifyType & ESECOND_NOTIFY ) ) //first notify |
|
635 { |
|
636 if( iCRKeyFolderName.Length()==0 ) |
|
637 { |
|
638 // no app group name |
|
639 // it must be found using parent id |
|
640 if ( count == 0 ) |
|
641 { |
|
642 return KErrNotFound; |
|
643 } |
|
644 iNotifyType |= ESECOND_NOTIFY; |
|
645 TLiwVariant varId; varId.PushL(); |
|
646 TLiwVariant varParentId; varParentId.PushL(); |
|
647 |
|
648 HnLiwUtils::GetVariantL( aEventParamList, KIdPath8, 0, varId ); |
|
649 HnLiwUtils::GetVariantL( aEventParamList, KParentIdPath8, 0, varParentId ); |
|
650 |
|
651 TInt32 id( 0 ); |
|
652 TInt32 parentId( 0 ); |
|
653 varId.Get( id ); |
|
654 iCRKeyFolderItemUid.Num( id ); |
|
655 varParentId.Get( parentId ); |
|
656 |
|
657 CleanupStack::PopAndDestroy( &varParentId ); |
|
658 CleanupStack::PopAndDestroy( &varId ); |
|
659 |
|
660 GetShowFolderL( parentId ); |
|
661 return KErrNone; |
|
662 } |
|
663 else |
|
664 { |
|
665 // app group name is known |
|
666 if( iNotifyType & EAPP_UID ) |
|
667 { |
|
668 // first get list was used to found id for app item |
|
669 iNotifyType |= ESECOND_NOTIFY; |
|
670 if ( count ) |
|
671 { |
|
672 // uid was given, id is found |
|
673 // and replaces uid |
|
674 TLiwVariant varId; varId.PushL(); |
|
675 HnLiwUtils::GetVariantL( aEventParamList, KIdPath8, 0, varId ); |
|
676 TInt32 id( 0 ); |
|
677 varId.Get( id ); |
|
678 iCRKeyFolderItemUid.Num( id ); |
|
679 CleanupStack::PopAndDestroy( &varId ); |
|
680 } |
|
681 GetShowFolderGroupNameL(); |
|
682 return KErrNone; |
|
683 } |
|
684 else |
|
685 { |
|
686 // intentionally empty |
|
687 // no uid was given so only one get list is needed |
|
688 } |
|
689 } |
|
690 } |
|
691 if ( count == 0 ) |
|
692 { |
|
693 return KErrNotFound; |
|
694 } |
|
695 |
|
696 TLiwVariant varId; varId.PushL(); |
|
697 TLiwVariant varAppGroupName; varAppGroupName.PushL(); |
|
698 TLiwVariant varSuiteName; varSuiteName.PushL(); |
|
699 TLiwVariant varChildrenCount; varChildrenCount.PushL(); |
|
700 |
|
701 HnLiwUtils::GetVariantL( aEventParamList, KIdPath8, 0, varId ); |
|
702 HnLiwUtils::GetVariantL( aEventParamList, KAppGroupNamePath8, 0, varAppGroupName ); |
|
703 HnLiwUtils::GetVariantL( aEventParamList, KTitleNamePath8, 0, varSuiteName ); |
|
704 HnLiwUtils::GetVariantL( aEventParamList, KChildrenCountPath8, 0, varChildrenCount ); |
|
705 |
|
706 CLiwGenericParamList* paramList = CLiwGenericParamList::NewL(); |
|
707 CleanupStack::PushL( paramList ); |
|
708 |
|
709 CLiwDefaultMap* map = CLiwDefaultMap::NewLC(); |
|
710 |
|
711 paramList->AppendL( TLiwGenericParam( KSuiteName8, |
|
712 TLiwVariant( KFolderSuite ) ) ); |
|
713 |
|
714 map->InsertL( KSuiteName8, varSuiteName ); |
|
715 map->InsertL( KFolderId8, varId ); |
|
716 map->InsertL( KRemoveLocked8, TLiwVariant( KStringFalse8 ) ); |
|
717 map->InsertL( KParentFolderId8, varId ); |
|
718 map->InsertL( KTmpParentFolderId8, varId ); |
|
719 map->InsertL( KMcsAppGroupName8, varAppGroupName ); |
|
720 |
|
721 paramList->AppendL( TLiwGenericParam( KParams8, TLiwVariant( map ) ) ); |
|
722 |
|
723 CleanupStack::PopAndDestroy( map ); |
|
724 |
|
725 while ( iCmnPtrs->iModel->LoadedSuitesCount() > 1 ) |
|
726 { |
|
727 CHnMdSuite* suite = iCmnPtrs->iModel->GetLastSuite(); |
|
728 iCmnPtrs->iContainer->PopSuiteModelL( suite->SuiteName() ); |
|
729 iCmnPtrs->iModel->DeleteLastSuite(); |
|
730 } |
|
731 |
|
732 if ( iCmnPtrs->iContainer->GetLastSuiteModel()->CustomId() != varId.AsTInt64() ) |
|
733 { |
|
734 iCmnPtrs->iModelEventObserver->HandleModelEventL( KNewSuiteLoadedMdEvent, *paramList ); |
|
735 iCmnPtrs->iContainer->GetLastSuiteModel()->RegisterSuiteObserverL( this ); |
|
736 iCmnPtrs->iModel->QueueForeground( CHnMdModel::EWhenCurrentTopSuiteIsEvaluated ); |
|
737 } |
|
738 else |
|
739 { |
|
740 iCmnPtrs->iContainer->GetLastSuiteModel()->NotifyObserversL( ESuiteModelInitialized ); |
|
741 TLex8 lex( iCRKeyFolderItemUid ); |
|
742 TInt64 id (0); |
|
743 TInt err = lex.Val( id ); |
|
744 TLiwVariant varItemCustomId; varItemCustomId.PushL(); |
|
745 varItemCustomId.Set( id ); |
|
746 TLiwVariant varId; varId.PushL(); |
|
747 varId.Set( iCmnPtrs->iContainer->GetLastSuiteModel()->CustomId() ); |
|
748 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
|
749 CleanupStack::PushL( pl ); |
|
750 pl->AppendL( TLiwGenericParam( KSuiteCustomId8, varId ) ); |
|
751 pl->AppendL( TLiwGenericParam( KItemCustomId8, varItemCustomId ) ); |
|
752 iCmnPtrs->iModelEventObserver->HandleModelEventL( KSetFocusEvent, *pl ); |
|
753 iCmnPtrs->iModelEventObserver->HandleModelEventL( KAppGainForeground, *pl ); |
|
754 CleanupStack::PopAndDestroy( pl ); |
|
755 CleanupStack::PopAndDestroy( &varId ); |
|
756 CleanupStack::PopAndDestroy( &varItemCustomId ); |
|
757 |
|
758 iCRKeyFolderItemUid.Copy( KBlank ); |
|
759 } |
|
760 |
|
761 iNotifyType = 0; |
|
762 iCRKeyFolderName.Copy( KBlank ); |
|
763 iRepository->Set( iId, KBlank ); |
|
764 |
|
765 CleanupStack::PopAndDestroy( paramList ); |
|
766 CleanupStack::PopAndDestroy( &varChildrenCount ); |
|
767 CleanupStack::PopAndDestroy( &varSuiteName ); |
|
768 CleanupStack::PopAndDestroy( &varAppGroupName ); |
|
769 CleanupStack::PopAndDestroy( &varId ); |
|
770 } |
|
771 |
|
772 DEBUG(("_MM_:CHnRepositoryShowFolderObserver::HandleNotifyL OUT")); |
|
773 return KErrNone; |
|
774 } |
|
775 |
|
776 // --------------------------------------------------------------------------- |
|
777 // |
|
778 // --------------------------------------------------------------------------- |
|
779 // |
|
780 void CHnRepositoryShowFolderObserver::HandleSuiteEventL ( THnCustomSuiteEvent aCustomSuiteEvent, |
|
781 CHnSuiteModel *aModel ) |
|
782 { |
|
783 |
|
784 if ( aCustomSuiteEvent == ESuiteModelInitialized && iCRKeyFolderItemUid.Length() > 0 ) |
|
785 { |
|
786 if (iCRKeyFolderItemUid.Length() > 0 ) |
|
787 { |
|
788 TLex8 lex( iCRKeyFolderItemUid ); |
|
789 TInt64 id (0); |
|
790 TInt err = lex.Val( id ); |
|
791 TInt focus( KErrNotFound ); |
|
792 // If suite is not null, then find matching item model. |
|
793 CHnItemModel* itemModel = aModel->GetMatchingItemModelL( id, focus ); |
|
794 aModel->SetSuiteHighlightL( focus ); |
|
795 } |
|
796 iCRKeyFolderItemUid.Copy( KBlank ); |
|
797 aModel->UnregisterSuiteObserver( this ); |
|
798 CLiwGenericParamList* pl = CLiwGenericParamList::NewL(); |
|
799 CleanupStack::PushL( pl ); |
|
800 iCmnPtrs->iModelEventObserver->HandleModelEventL( KAppGainForeground, *pl ); |
|
801 CleanupStack::PopAndDestroy( pl ); |
|
802 } |
|
803 } |
|
804 |
|
805 // End of File |