58
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 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: DM Idle SoftKey Adapter
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// s60
|
|
20 |
#include <favouritesitemlist.h>
|
|
21 |
#include <msvuids.h>
|
|
22 |
#include <SenduiMtmUids.h>
|
|
23 |
#include <javaregistryentrytype.h>
|
|
24 |
#include <featmgr.h>
|
|
25 |
#include <aiscutplugindomaincrkeys.h>
|
|
26 |
|
|
27 |
#include "UiSettingsUtil.h"
|
|
28 |
#include "IsAdapterLiterals.h"
|
|
29 |
|
|
30 |
#include "debug.h"
|
|
31 |
|
|
32 |
|
|
33 |
// ------------------------------------------------------------------------------------------------
|
|
34 |
// CUiSettingsUtil* CUiSettingsUtil::NewL( )
|
|
35 |
// ------------------------------------------------------------------------------------------------
|
|
36 |
CUiSettingsUtil* CUiSettingsUtil::NewL( )
|
|
37 |
{
|
|
38 |
RDEBUG( "CUiSettingsUtil::NewL() >" );
|
|
39 |
CUiSettingsUtil* self = NewLC( );
|
|
40 |
CleanupStack::Pop();
|
|
41 |
RDEBUG( "CUiSettingsUtil::NewL() <" );
|
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ------------------------------------------------------------------------------------------------
|
|
46 |
// CUiSettingsUtil* CUiSettingsUtil::NewLC( )
|
|
47 |
// ------------------------------------------------------------------------------------------------
|
|
48 |
CUiSettingsUtil* CUiSettingsUtil::NewLC( )
|
|
49 |
{
|
|
50 |
RDEBUG( "CUiSettingsUtil::NewLC() >" );
|
|
51 |
CUiSettingsUtil* self = new (ELeave) CUiSettingsUtil();
|
|
52 |
CleanupStack::PushL(self);
|
|
53 |
self->ConstructL();
|
|
54 |
RDEBUG( "CUiSettingsUtil::NewLC() <" );
|
|
55 |
return self;
|
|
56 |
}
|
|
57 |
|
|
58 |
// ------------------------------------------------------------------------------------------------
|
|
59 |
// CUiSettingsUtil::CUiSettingsUtil()
|
|
60 |
// ------------------------------------------------------------------------------------------------
|
|
61 |
CUiSettingsUtil::CUiSettingsUtil()
|
|
62 |
{
|
|
63 |
RDEBUG( "CUiSettingsUtil::CUiSettingsUtil()" );
|
|
64 |
}
|
|
65 |
|
|
66 |
// ------------------------------------------------------------------------------------------------
|
|
67 |
// CUiSettingsUtil::ConstructL
|
|
68 |
// ------------------------------------------------------------------------------------------------
|
|
69 |
void CUiSettingsUtil::ConstructL()
|
|
70 |
{
|
|
71 |
RDEBUG( "CUiSettingsUtil::ConstructL() >" );
|
|
72 |
|
|
73 |
FeatureManager::InitializeLibL();
|
|
74 |
|
|
75 |
/* ReadAppTargetsL();
|
|
76 |
ReadJavaTargetsL();
|
|
77 |
ReadMailBoxesL();
|
|
78 |
ReadBookmarksL();
|
|
79 |
ReadStaticAppTargetsL();*/
|
|
80 |
|
|
81 |
|
|
82 |
RDEBUG( "CIsAdapter::ConstructL() <" );
|
|
83 |
}
|
|
84 |
|
|
85 |
// ------------------------------------------------------------------------------------------------
|
|
86 |
// CUiSettingsUtil::~CUiSettingsUtil()
|
|
87 |
// ------------------------------------------------------------------------------------------------
|
|
88 |
CUiSettingsUtil::~CUiSettingsUtil()
|
|
89 |
{
|
|
90 |
RDEBUG( "CUiSettingsUtil::~CUiSettingsUtil() >" );
|
|
91 |
|
|
92 |
if(iListItems.Count())
|
|
93 |
iListItems.ResetAndDestroy();
|
|
94 |
|
|
95 |
if(iJaveUids.Count())
|
|
96 |
iJaveUids.Reset();
|
|
97 |
|
|
98 |
if(iMailBoxes)
|
|
99 |
{
|
|
100 |
iMailBoxes->Reset();
|
|
101 |
delete iMailBoxes;
|
|
102 |
}
|
|
103 |
|
|
104 |
if(iStaticAppParam)
|
|
105 |
{
|
|
106 |
iStaticAppParam->Reset();
|
|
107 |
delete iStaticAppParam;
|
|
108 |
}
|
|
109 |
|
|
110 |
if(iStaticAppCaption)
|
|
111 |
{
|
|
112 |
iStaticAppCaption->Reset();
|
|
113 |
delete iStaticAppCaption;
|
|
114 |
}
|
|
115 |
|
|
116 |
if(iFavList)
|
|
117 |
{
|
|
118 |
delete iFavList;
|
|
119 |
}
|
|
120 |
|
|
121 |
FeatureManager::UnInitializeLib();
|
|
122 |
|
|
123 |
RDEBUG( "CUiSettingsUtil::~CUiSettingsUtil() <" );
|
|
124 |
}
|
|
125 |
|
|
126 |
// ------------------------------------------------------------------------------------------------
|
|
127 |
// CUiSettingsUtil::GetShortcutRtType
|
|
128 |
// ------------------------------------------------------------------------------------------------
|
|
129 |
|
|
130 |
void CUiSettingsUtil::GetShortcutRtTypeL(TInt aUid, TInt &aRtType)
|
|
131 |
{
|
|
132 |
RDEBUG( "CUiSettingsUtil::GetShortcutRtTypeL() >" );
|
|
133 |
aRtType = 1;
|
|
134 |
TBuf16<256> KeyValue;
|
|
135 |
GetKeyValueL(aUid, KeyValue);
|
|
136 |
TInt temp = KeyValue.FindF(KBookmarkText);
|
|
137 |
if(temp==KErrNotFound)
|
|
138 |
aRtType = 0;
|
|
139 |
RDEBUG( "CUiSettingsUtil::GetShortcutRtTypeL() <" );
|
|
140 |
}
|
|
141 |
|
|
142 |
// ------------------------------------------------------------------------------------------------
|
|
143 |
// CUiSettingsUtil* CUiSettingsUtil::GetSoftkeyCountL( )
|
|
144 |
// ------------------------------------------------------------------------------------------------
|
|
145 |
|
|
146 |
TInt CUiSettingsUtil::GetSoftkeyCountL()
|
|
147 |
{
|
|
148 |
RDEBUG( "CUiSettingsUtil::GetSoftkeyCountL() >" );
|
|
149 |
TInt count;
|
|
150 |
CRepository *cenRep = CRepository::NewL(KCRUidShortcutItems);
|
|
151 |
RArray<TUint32> defaultThemeKeys;
|
|
152 |
CleanupClosePushL(defaultThemeKeys);
|
|
153 |
cenRep->FindL(KScutCenRepKeyThemeDefault, KScutCenRepKeyMask, defaultThemeKeys);
|
|
154 |
count = defaultThemeKeys.Count();
|
|
155 |
//default SoftKeys always return Active Idle softkeys
|
|
156 |
//total number of Softkeys = defalult + scroll (left,right,up,down,selection)
|
|
157 |
count = count + 5;
|
|
158 |
CleanupStack::PopAndDestroy(&defaultThemeKeys);
|
|
159 |
delete cenRep;
|
|
160 |
RDEBUG( "CUiSettingsUtil::GetSoftkeyCountL() <" );
|
|
161 |
return count;
|
|
162 |
}
|
|
163 |
|
|
164 |
// ------------------------------------------------------------------------------------------------
|
|
165 |
// CUiSettingsUtil* CUiSettingsUtil::GetKeyValueL( )
|
|
166 |
// ------------------------------------------------------------------------------------------------
|
|
167 |
|
|
168 |
void CUiSettingsUtil::GetKeyValueL(TInt aUid, TDes16 &aKeyValue)
|
|
169 |
{
|
|
170 |
RDEBUG( "CUiSettingsUtil::GetKeyValueL() >" );
|
|
171 |
CRepository *cenRep = CRepository::NewL(KCRUidShortcutItems);
|
|
172 |
|
|
173 |
RArray<TUint32> defaultThemeKeys;
|
|
174 |
CleanupClosePushL(defaultThemeKeys);
|
|
175 |
|
|
176 |
RArray<TUint32> userDefinedKeys;
|
|
177 |
CleanupClosePushL(userDefinedKeys);
|
|
178 |
|
|
179 |
cenRep->FindL(KScutCenRepKeyThemeDefault, KScutCenRepKeyMask, defaultThemeKeys);
|
|
180 |
cenRep->FindL(KScutCenRepKeyUserDefined, KScutCenRepKeyMask, userDefinedKeys);
|
|
181 |
|
|
182 |
TUint keyUid = aUid;
|
|
183 |
keyUid = keyUid | 0x80000000 ;
|
|
184 |
TUint defaultThemeKey;
|
|
185 |
TUint userDefinedKey;
|
|
186 |
TInt countThemeKey;
|
|
187 |
TInt countUserKey;
|
|
188 |
TBool isUserDefinedKey = EFalse;
|
|
189 |
|
|
190 |
countThemeKey = defaultThemeKeys.Count();
|
|
191 |
countUserKey = userDefinedKeys.Count();
|
|
192 |
TBuf16<256> KeyValue;
|
|
193 |
|
|
194 |
//First retrive the UID of the softkey's application
|
|
195 |
for (TInt i = 0; i < countUserKey; i++)
|
|
196 |
{
|
|
197 |
userDefinedKey = userDefinedKeys[i];
|
|
198 |
userDefinedKey = userDefinedKey | 0x80000000;
|
|
199 |
if (keyUid == userDefinedKey)
|
|
200 |
{
|
|
201 |
isUserDefinedKey = ETrue;
|
|
202 |
cenRep->Get(userDefinedKeys[i],KeyValue);
|
|
203 |
break;
|
|
204 |
}
|
|
205 |
}
|
|
206 |
|
|
207 |
if (!isUserDefinedKey)
|
|
208 |
{
|
|
209 |
for (TInt i = 0; i < countThemeKey; i++)
|
|
210 |
{
|
|
211 |
defaultThemeKey = defaultThemeKeys[i];
|
|
212 |
if (keyUid == defaultThemeKey)
|
|
213 |
{
|
|
214 |
cenRep->Get(defaultThemeKey,KeyValue);
|
|
215 |
break;
|
|
216 |
}
|
|
217 |
}
|
|
218 |
}
|
|
219 |
aKeyValue = KeyValue;
|
|
220 |
delete cenRep;
|
|
221 |
CleanupStack::PopAndDestroy(&userDefinedKeys);
|
|
222 |
CleanupStack::PopAndDestroy(&defaultThemeKeys);
|
|
223 |
RDEBUG( "CUiSettingsUtil::GetKeyValueL() <" );
|
|
224 |
}
|
|
225 |
|
|
226 |
// ------------------------------------------------------------------------------------------------
|
|
227 |
// CUiSettingsUtil::GetShortcutTargetIndex()
|
|
228 |
// ------------------------------------------------------------------------------------------------
|
|
229 |
|
|
230 |
TInt CUiSettingsUtil::GetShortcutTargetIndexL(TInt aUid, TInt& aIndex)
|
|
231 |
{
|
|
232 |
RDEBUG( "CUiSettingsUtil::GetShortcutTargetIndexL() >" );
|
|
233 |
TInt index;
|
|
234 |
TBuf16<256> KeyValue;
|
|
235 |
GetKeyValueL(aUid, KeyValue);
|
|
236 |
if(GetStaticAppIndex(KeyValue, index))
|
|
237 |
{
|
|
238 |
aIndex=index + iListItems.Count() + iJaveUids.Count() + iMailBoxes->Count();
|
|
239 |
return KErrNone;
|
|
240 |
}
|
|
241 |
TInt FindBm = KeyValue.FindF(KBookmarkText);
|
|
242 |
if (FindBm==KErrNotFound)
|
|
243 |
{
|
|
244 |
TInt FindMB = KeyValue.FindF(KMailBoxText);
|
|
245 |
if (FindMB==KErrNotFound)
|
|
246 |
{
|
|
247 |
TInt FindApp = KeyValue.FindF(KAppText);
|
|
248 |
KeyValue.Delete(0, KAppText().Length());
|
|
249 |
|
|
250 |
TLex16 lex(KeyValue);
|
|
251 |
TInt64 value;
|
|
252 |
lex.Val(value, EHex);
|
|
253 |
|
|
254 |
TUid ApplicationUid = { value };
|
|
255 |
|
|
256 |
if(GetAppIndexToUID(ApplicationUid, index))
|
|
257 |
{
|
|
258 |
aIndex = index;
|
|
259 |
}
|
|
260 |
else
|
|
261 |
{
|
|
262 |
aIndex = -1;
|
|
263 |
return KErrArgument;
|
|
264 |
}
|
|
265 |
}
|
|
266 |
else
|
|
267 |
{
|
|
268 |
KeyValue.Delete(0, KMailBoxText().Length());
|
|
269 |
if( GetMailBoxTargetIndex(KeyValue, index))
|
|
270 |
{
|
|
271 |
aIndex = index + iListItems.Count() + iJaveUids.Count();
|
|
272 |
}
|
|
273 |
else
|
|
274 |
{
|
|
275 |
aIndex = -1;
|
|
276 |
return KErrArgument;
|
|
277 |
}
|
|
278 |
}
|
|
279 |
}
|
|
280 |
else
|
|
281 |
{
|
|
282 |
KeyValue.Delete(0, KBookmarkText().Length());
|
|
283 |
|
|
284 |
TLex16 lex(KeyValue);
|
|
285 |
TInt64 value;
|
|
286 |
lex.Val(value, EHex);
|
|
287 |
|
|
288 |
TInt WebUid = value ;
|
|
289 |
|
|
290 |
if (GetWebTargetIndex( WebUid, index) == KErrNotFound)
|
|
291 |
{
|
|
292 |
aIndex = -1;
|
|
293 |
return KErrArgument;
|
|
294 |
}
|
|
295 |
else
|
|
296 |
aIndex = index;
|
|
297 |
}
|
|
298 |
RDEBUG( "CUiSettingsUtil::GetShortcutTargetIndexL() <" );
|
|
299 |
return KErrNone;
|
|
300 |
}
|
|
301 |
|
|
302 |
// ------------------------------------------------------------------------------------------------
|
|
303 |
// CUiSettingsUtil::GetAppTargetCaptionL()
|
|
304 |
// ------------------------------------------------------------------------------------------------
|
|
305 |
|
|
306 |
// Caption and description are the same. They are obtained from
|
|
307 |
// RApaLsSession API by passing the application UID
|
|
308 |
// ApplicationUID is obtained from the CentRep
|
|
309 |
|
|
310 |
TInt CUiSettingsUtil::GetAppTargetCaptionL(TInt aIndex, TDes& aBufferCaption)
|
|
311 |
{
|
|
312 |
RDEBUG( "CUiSettingsUtil::GetShortcutTargetCaptionL() >" );
|
|
313 |
TInt NoOfTargetApps = iListItems.Count();
|
|
314 |
TInt NoOfJavaApps = iJaveUids.Count();
|
|
315 |
TInt NoOfMailBoxes = iMailBoxes->Count();
|
|
316 |
TInt NoOfStaticApps = iStaticAppParam->Count();
|
|
317 |
|
|
318 |
if(aIndex < NoOfTargetApps)
|
|
319 |
{
|
|
320 |
TApaAppInfo appInfo;
|
|
321 |
GetAppInfoAtIndex(aIndex, appInfo);
|
|
322 |
aBufferCaption.Copy(appInfo.iCaption);
|
|
323 |
}
|
|
324 |
else if ((aIndex - NoOfTargetApps) < NoOfJavaApps )
|
|
325 |
{
|
|
326 |
CJavaRegistry* registry = CJavaRegistry::NewLC();
|
|
327 |
CJavaRegistryEntry* entry =
|
|
328 |
registry->RegistryEntryL( iJaveUids[aIndex - NoOfTargetApps] );
|
|
329 |
CleanupStack::PushL(entry);
|
|
330 |
const TDesC& name = entry->Name();
|
|
331 |
aBufferCaption.Copy(name);
|
|
332 |
CleanupStack::PopAndDestroy(entry);
|
|
333 |
CleanupStack::PopAndDestroy(registry);
|
|
334 |
}
|
|
335 |
else if((aIndex - NoOfTargetApps - NoOfJavaApps ) < NoOfMailBoxes)
|
|
336 |
{
|
|
337 |
TInt index = aIndex - NoOfTargetApps - NoOfJavaApps;
|
|
338 |
aBufferCaption = iMailBoxes->MdcaPoint(index);
|
|
339 |
}
|
|
340 |
else if((aIndex - NoOfTargetApps - NoOfJavaApps - NoOfMailBoxes) < NoOfStaticApps)
|
|
341 |
{
|
|
342 |
TInt index = aIndex - NoOfTargetApps - NoOfJavaApps - NoOfMailBoxes;
|
|
343 |
aBufferCaption = iStaticAppCaption->MdcaPoint(index);
|
|
344 |
}
|
|
345 |
else
|
|
346 |
{
|
|
347 |
return KErrArgument;
|
|
348 |
}
|
|
349 |
RDEBUG( "CUiSettingsUtil::GetShortcutTargetCaptionL() <" );
|
|
350 |
return KErrNone;
|
|
351 |
}
|
|
352 |
|
|
353 |
// ------------------------------------------------------------------------------------------------
|
|
354 |
// CUiSettingsUtil::SetShortcutTargetAppIndex()
|
|
355 |
// ------------------------------------------------------------------------------------------------
|
|
356 |
|
|
357 |
TInt CUiSettingsUtil::SetShortcutTargetAppIndexL( TInt aUid, TInt aIndex )
|
|
358 |
{
|
|
359 |
RDEBUG( "CUiSettingsUtil::SetShortcutTargetAppIndexL() >" );
|
|
360 |
TUint softkeyID = aUid;
|
|
361 |
|
|
362 |
TBuf16<256> SetKeyValue;
|
|
363 |
TBuf16<10> appUid ;
|
|
364 |
|
|
365 |
TInt NoOfTargetApps = iListItems.Count();
|
|
366 |
TInt NoOfJavaApps = iJaveUids.Count();
|
|
367 |
TInt NoOfMailBoxes = iMailBoxes->Count();
|
|
368 |
TInt NoOfStaticApps = iStaticAppParam->Count();
|
|
369 |
|
|
370 |
CRepository *cenRep = CRepository::NewL(KCRUidShortcutItems);
|
|
371 |
TBool found = EFalse;
|
|
372 |
if (aIndex < NoOfTargetApps)
|
|
373 |
{
|
|
374 |
TApaAppInfo appInfo;
|
|
375 |
found = GetAppInfoAtIndex(aIndex, appInfo);
|
|
376 |
appUid.Format(KFormat,appInfo.iUid);
|
|
377 |
SetKeyValue = KAppText;
|
|
378 |
SetKeyValue.Insert (SetKeyValue.Length(),appUid);
|
|
379 |
}
|
|
380 |
else if ((aIndex - NoOfTargetApps) < NoOfJavaApps)
|
|
381 |
{
|
|
382 |
CJavaRegistry* registry = CJavaRegistry::NewLC();
|
|
383 |
CJavaRegistryEntry* entry = registry->RegistryEntryL( iJaveUids[aIndex - NoOfTargetApps] );
|
|
384 |
CleanupStack::PushL(entry);
|
|
385 |
const TDesC& name = entry->Name();
|
|
386 |
found = ETrue;
|
|
387 |
appUid.Format(KFormat,entry->Uid());
|
|
388 |
CleanupStack::PopAndDestroy(entry);
|
|
389 |
CleanupStack::PopAndDestroy(registry);
|
|
390 |
SetKeyValue = KAppText;
|
|
391 |
SetKeyValue.Insert (SetKeyValue.Length(),appUid);
|
|
392 |
}
|
|
393 |
else if((aIndex - NoOfTargetApps - NoOfJavaApps) < NoOfMailBoxes)
|
|
394 |
{
|
|
395 |
TInt index = aIndex - NoOfTargetApps - NoOfJavaApps;
|
|
396 |
SetKeyValue = KMailBoxText;
|
|
397 |
SetKeyValue.Insert (SetKeyValue.Length(),iMailBoxes->MdcaPoint(index));
|
|
398 |
found = ETrue;
|
|
399 |
}
|
|
400 |
else if((aIndex - NoOfTargetApps - NoOfJavaApps - NoOfMailBoxes) < NoOfStaticApps)
|
|
401 |
{
|
|
402 |
TInt index = aIndex - NoOfTargetApps - NoOfJavaApps - NoOfMailBoxes;
|
|
403 |
SetKeyValue.Insert (SetKeyValue.Length(),iStaticAppParam->MdcaPoint(index));
|
|
404 |
found = ETrue;
|
|
405 |
}
|
|
406 |
else
|
|
407 |
{
|
|
408 |
delete cenRep;
|
|
409 |
return KErrArgument;
|
|
410 |
}
|
|
411 |
|
|
412 |
if (found)
|
|
413 |
{
|
|
414 |
cenRep->Set(softkeyID,SetKeyValue);
|
|
415 |
}
|
|
416 |
delete cenRep;
|
|
417 |
RDEBUG( "CUiSettingsUtil::SetShortcutTargetAppIndexL() <" );
|
|
418 |
return KErrNone;
|
|
419 |
}
|
|
420 |
|
|
421 |
// ------------------------------------------------------------------------------------------------
|
|
422 |
// CUiSettingsUtil* CUiSettingsUtil::GetAppInfoAtIndex( )
|
|
423 |
// ------------------------------------------------------------------------------------------------
|
|
424 |
|
|
425 |
TBool CUiSettingsUtil::GetAppInfoAtIndex(TInt aIndex, TApaAppInfo& aAppInfo )
|
|
426 |
{
|
|
427 |
RDEBUG( "CUiSettingsUtil::GetAppInfoAtIndex() >" );
|
|
428 |
aAppInfo = *iListItems[aIndex];
|
|
429 |
if(aIndex < iListItems.Count() )
|
|
430 |
return ETrue;
|
|
431 |
else
|
|
432 |
return EFalse;
|
|
433 |
}
|
|
434 |
|
|
435 |
// ------------------------------------------------------------------------------------------------
|
|
436 |
// CUiSettingsUtil* CUiSettingsUtil::GetAppIndexToUID( )
|
|
437 |
// ------------------------------------------------------------------------------------------------
|
|
438 |
|
|
439 |
TBool CUiSettingsUtil::GetAppIndexToUID(TUid aUID, TInt& aIndex )
|
|
440 |
{
|
|
441 |
RDEBUG( "CUiSettingsUtil::GetAppIndexToUID() >" );
|
|
442 |
TBool found = EFalse;
|
|
443 |
for (TInt i=0; i < iListItems.Count() ; i++)
|
|
444 |
{
|
|
445 |
if(iListItems[i]->iUid == aUID)
|
|
446 |
{
|
|
447 |
found = ETrue;
|
|
448 |
aIndex = i;
|
|
449 |
break;
|
|
450 |
}
|
|
451 |
}
|
|
452 |
if(!found)
|
|
453 |
{
|
|
454 |
for (TInt i=0; i < iJaveUids.Count() ; i++)
|
|
455 |
{
|
|
456 |
if(iJaveUids[i] == aUID)
|
|
457 |
{
|
|
458 |
found = ETrue;
|
|
459 |
aIndex = i + iListItems.Count();
|
|
460 |
break;
|
|
461 |
}
|
|
462 |
}
|
|
463 |
}
|
|
464 |
RDEBUG( "CUiSettingsUtil::GetAppIndexToUID() <" );
|
|
465 |
return found;
|
|
466 |
}
|
|
467 |
|
|
468 |
// ------------------------------------------------------------------------------------------------
|
|
469 |
// CUiSettingsUtil* CUiSettingsUtil::GetMailBoxTargetIndex( )
|
|
470 |
// ------------------------------------------------------------------------------------------------
|
|
471 |
|
|
472 |
TBool CUiSettingsUtil::GetMailBoxTargetIndex(const TDesC& aName, TInt& aIndex )
|
|
473 |
{
|
|
474 |
RDEBUG( "CUiSettingsUtil::GetMailBoxTargetIndex() >" );
|
|
475 |
TBool found = EFalse;
|
|
476 |
for (TInt i=0; i < iMailBoxes->Count() ; i++)
|
|
477 |
{
|
|
478 |
if(aName.CompareF(iMailBoxes->MdcaPoint(i)) == 0 )
|
|
479 |
{
|
|
480 |
found = ETrue;
|
|
481 |
aIndex = i;
|
|
482 |
break;
|
|
483 |
}
|
|
484 |
}
|
|
485 |
RDEBUG( "CUiSettingsUtil::GetMailBoxTargetIndex() <" );
|
|
486 |
return found;
|
|
487 |
}
|
|
488 |
|
|
489 |
// ------------------------------------------------------------------------------------------------
|
|
490 |
// CUiSettingsUtil* CUiSettingsUtil::GetStaticAppIndex( )
|
|
491 |
// ------------------------------------------------------------------------------------------------
|
|
492 |
|
|
493 |
TBool CUiSettingsUtil::GetStaticAppIndex(const TDesC& aKeyValue, TInt& aIndex)
|
|
494 |
{
|
|
495 |
RDEBUG( "CUiSettingsUtil::GetStaticAppIndex() >" );
|
|
496 |
TBool found = EFalse;
|
|
497 |
for (TInt i=0; i < iStaticAppParam->Count() ; i++)
|
|
498 |
{
|
|
499 |
if(aKeyValue.CompareF(iStaticAppParam->MdcaPoint(i)) == 0 )
|
|
500 |
{
|
|
501 |
found = ETrue;
|
|
502 |
aIndex = i;
|
|
503 |
break;
|
|
504 |
}
|
|
505 |
}
|
|
506 |
RDEBUG( "CUiSettingsUtil::GetStaticAppIndex() <" );
|
|
507 |
return found;
|
|
508 |
}
|
|
509 |
|
|
510 |
// ------------------------------------------------------------------------------------------------
|
|
511 |
// CUiSettingsUtil* CUiSettingsUtil::ReadTargetsL( )
|
|
512 |
// ------------------------------------------------------------------------------------------------
|
|
513 |
|
|
514 |
void CUiSettingsUtil::ReadTargetsL()
|
|
515 |
{
|
|
516 |
RDEBUG( "CUiSettingsUtil::ReadTargetsL() >" );
|
|
517 |
ReadAppTargetsL();
|
|
518 |
ReadJavaTargetsL();
|
|
519 |
ReadMailBoxesL();
|
|
520 |
ReadStaticAppTargetsL();
|
|
521 |
RDEBUG( "CUiSettingsUtil::ReadTargetsL() <" );
|
|
522 |
}
|
|
523 |
|
|
524 |
// ------------------------------------------------------------------------------------------------
|
|
525 |
// CUiSettingsUtil* CUiSettingsUtil::ReadAppTargetsL( )
|
|
526 |
// ------------------------------------------------------------------------------------------------
|
|
527 |
|
|
528 |
void CUiSettingsUtil::ReadAppTargetsL()
|
|
529 |
{
|
|
530 |
RDEBUG( "CUiSettingsUtil::ReadAppTargetsL() >" );
|
|
531 |
RApaLsSession apaSession;
|
|
532 |
if ( apaSession.Handle() == KNullHandle )
|
|
533 |
{
|
|
534 |
User::LeaveIfError( apaSession.Connect() );
|
|
535 |
}
|
|
536 |
|
|
537 |
TInt count_app =0 ;
|
|
538 |
if (apaSession.GetAllApps() == KErrNone)
|
|
539 |
{
|
|
540 |
TInt err = apaSession.AppCount(count_app);
|
|
541 |
}
|
|
542 |
iListItems.ReserveL(150);
|
|
543 |
for (TInt i=0; i < count_app ; i++)
|
|
544 |
{
|
|
545 |
TApaAppInfo* appInfo = new (ELeave) TApaAppInfo;
|
|
546 |
TInt err = apaSession.GetNextApp(*appInfo);
|
|
547 |
if (err == KErrNone)
|
|
548 |
{
|
|
549 |
TApaAppCapabilityBuf buf;
|
|
550 |
if (apaSession.GetAppCapability(buf, appInfo->iUid) == KErrNone &&
|
|
551 |
!buf().iAppIsHidden && !IsNonNativeL(appInfo->iUid) )
|
|
552 |
{
|
|
553 |
iListItems.Append(appInfo);
|
|
554 |
}
|
|
555 |
else
|
|
556 |
{
|
|
557 |
delete appInfo;
|
|
558 |
}
|
|
559 |
}
|
|
560 |
else
|
|
561 |
{
|
|
562 |
delete appInfo;
|
|
563 |
}
|
|
564 |
}
|
|
565 |
apaSession.Close();
|
|
566 |
RDEBUG( "CUiSettingsUtil::ReadAppTargetsL() <" );
|
|
567 |
}
|
|
568 |
|
|
569 |
// ------------------------------------------------------------------------------------------------
|
|
570 |
// CUiSettingsUtil* CUiSettingsUtil::ReadJavaTargetsL( )
|
|
571 |
// ------------------------------------------------------------------------------------------------
|
|
572 |
|
|
573 |
void CUiSettingsUtil::ReadJavaTargetsL()
|
|
574 |
{
|
|
575 |
RDEBUG( "CUiSettingsUtil::ReadJavaTargetsL() >" );
|
|
576 |
CJavaRegistry* registry = CJavaRegistry::NewLC();
|
|
577 |
|
|
578 |
// get all uids stored in registry
|
|
579 |
RArray<TUid> uids;
|
|
580 |
CleanupClosePushL(uids);
|
|
581 |
registry->GetRegistryEntryUidsL( uids );
|
|
582 |
//TBool duplicate = EFalse ;
|
|
583 |
for(TInt i =0; i <uids.Count();i++)
|
|
584 |
{
|
|
585 |
CJavaRegistryEntry* entry = registry->RegistryEntryL( uids[i] );
|
|
586 |
CleanupStack::PushL(entry);
|
|
587 |
if(entry->Type() >= EGeneralApplication)
|
|
588 |
{
|
|
589 |
iJaveUids.Append(uids[i]);
|
|
590 |
}
|
|
591 |
CleanupStack::PopAndDestroy(entry);
|
|
592 |
}
|
|
593 |
CleanupStack::PopAndDestroy(&uids);
|
|
594 |
CleanupStack::PopAndDestroy(registry);
|
|
595 |
RDEBUG( "CUiSettingsUtil::ReadJavaTargetsL() <" );
|
|
596 |
}
|
|
597 |
|
|
598 |
// ------------------------------------------------------------------------------------------------
|
|
599 |
// CUiSettingsUtil* CUiSettingsUtil::ReadMailBoxesL( )
|
|
600 |
// ------------------------------------------------------------------------------------------------
|
|
601 |
|
|
602 |
void CUiSettingsUtil::ReadMailBoxesL()
|
|
603 |
{
|
|
604 |
RDEBUG( "CUiSettingsUtil::ReadMailBoxesL() >" );
|
|
605 |
CMsvSession* msvSession = CMsvSession::OpenAsObserverL(*this);
|
|
606 |
iMailBoxes = new (ELeave) CDesCArrayFlat(1);
|
|
607 |
|
|
608 |
CMsvEntry* rootEntry = msvSession->GetEntryL(KMsvRootIndexEntryIdValue);
|
|
609 |
CleanupStack::PushL(rootEntry);
|
|
610 |
|
|
611 |
for (TInt i = rootEntry->Count() - 1; i >= 0; --i)
|
|
612 |
{
|
|
613 |
const TMsvEntry& tentry = (*rootEntry)[i];
|
|
614 |
|
|
615 |
if (tentry.iMtm == KSenduiMtmImap4Uid || tentry.iMtm == KSenduiMtmPop3Uid)
|
|
616 |
{
|
|
617 |
iMailBoxes->AppendL(tentry.iDetails);
|
|
618 |
}
|
|
619 |
}
|
|
620 |
CleanupStack::PopAndDestroy(rootEntry);
|
|
621 |
delete msvSession;
|
|
622 |
RDEBUG( "CUiSettingsUtil::ReadMailBoxesL() <" );
|
|
623 |
}
|
|
624 |
|
|
625 |
// ------------------------------------------------------------------------------------------------
|
|
626 |
// CUiSettingsUtil* CUiSettingsUtil::ReadStaticAppTargetsL( )
|
|
627 |
// ------------------------------------------------------------------------------------------------
|
|
628 |
|
|
629 |
void CUiSettingsUtil::ReadStaticAppTargetsL()
|
|
630 |
{
|
|
631 |
RDEBUG( "CUiSettingsUtil::ReadStaticAppTargetsL() >" );
|
|
632 |
//add the code to read the static applications here
|
|
633 |
|
|
634 |
iStaticAppParam = new (ELeave) CDesCArrayFlat(1);
|
|
635 |
iStaticAppCaption = new (ELeave) CDesCArrayFlat(1);
|
|
636 |
|
|
637 |
iStaticAppParam->AppendL(KNewMsg());
|
|
638 |
iStaticAppCaption->AppendL(KNewMsgCaption());
|
|
639 |
|
|
640 |
iStaticAppParam->AppendL(KNewEmail());
|
|
641 |
iStaticAppCaption->AppendL(KNewEmailCaption());
|
|
642 |
|
|
643 |
#ifdef __SYNCML_DS_EMAIL
|
|
644 |
iStaticAppParam->AppendL(KNewSyncMLMail());
|
|
645 |
iStaticAppCaption->AppendL(KNewSyncMLMailCaption());
|
|
646 |
#endif
|
|
647 |
|
|
648 |
if (FeatureManager::FeatureSupported(KFeatureIdMmsPostcard))
|
|
649 |
{
|
|
650 |
// New Postcard item.
|
|
651 |
iStaticAppParam->AppendL(KNewMMS());
|
|
652 |
iStaticAppCaption->AppendL(KNewMMSCaption());
|
|
653 |
}
|
|
654 |
|
|
655 |
if (FeatureManager::FeatureSupported(KFeatureIdAudioMessaging))
|
|
656 |
{
|
|
657 |
// New Audio Messaging
|
|
658 |
iStaticAppParam->AppendL(KNewAudioMsg());
|
|
659 |
iStaticAppCaption->AppendL(KNewAudioMsgCaption());
|
|
660 |
}
|
|
661 |
|
|
662 |
iStaticAppParam->AppendL(KNewMsgType());
|
|
663 |
iStaticAppCaption->AppendL(KNewMsgTypeCaption());
|
|
664 |
|
|
665 |
iStaticAppParam->AppendL(KChangeTheme());
|
|
666 |
iStaticAppCaption->AppendL(KChangeThemeCaption());
|
|
667 |
RDEBUG( "CUiSettingsUtil::ReadStaticAppTargetsL() <" );
|
|
668 |
}
|
|
669 |
|
|
670 |
// ------------------------------------------------------------------------------------------------
|
|
671 |
// CUiSettingsUtil* CUiSettingsUtil::IsNonNativeL( )
|
|
672 |
// ------------------------------------------------------------------------------------------------
|
|
673 |
|
|
674 |
TBool CUiSettingsUtil::IsNonNativeL(const TUid& aUid) const
|
|
675 |
{
|
|
676 |
RDEBUG( "CUiSettingsUtil::IsNonNativeL() >" );
|
|
677 |
TBool ret = EFalse;
|
|
678 |
|
|
679 |
const TUid KMidletAppType = { 0x10210E26 };
|
|
680 |
TUid typeuid = KNullUid;
|
|
681 |
RApaLsSession apaSession;
|
|
682 |
if ( apaSession.Handle() == KNullHandle )
|
|
683 |
{
|
|
684 |
User::LeaveIfError( apaSession.Connect() );
|
|
685 |
}
|
|
686 |
if (KErrNone == apaSession.GetAppType(typeuid, aUid))
|
|
687 |
{
|
|
688 |
if (typeuid == KMidletAppType)
|
|
689 |
{
|
|
690 |
ret = ETrue;
|
|
691 |
}
|
|
692 |
}
|
|
693 |
apaSession.Close();
|
|
694 |
RDEBUG( "CUiSettingsUtil::IsNonNativeL() <" );
|
|
695 |
return ret;
|
|
696 |
}
|
|
697 |
|
|
698 |
// ------------------------------------------------------------------------------------------------
|
|
699 |
// CUiSettingsUtil* CUiSettingsUtil::GetNoOfTargetApps( )
|
|
700 |
// ------------------------------------------------------------------------------------------------
|
|
701 |
|
|
702 |
TInt CUiSettingsUtil::GetNoOfTargetApps()
|
|
703 |
{
|
|
704 |
RDEBUG( "CUiSettingsUtil::GetNoOfTargetApps() >" );
|
|
705 |
return iListItems.Count() + iJaveUids.Count() + iMailBoxes->Count() + iStaticAppParam->Count();
|
|
706 |
}
|
|
707 |
|
|
708 |
// ------------------------------------------------------------------------------------------------
|
|
709 |
// CUiSettingsUtil* CUiSettingsUtil::ReadBookmarksL( )
|
|
710 |
// ------------------------------------------------------------------------------------------------
|
|
711 |
|
|
712 |
void CUiSettingsUtil::ReadBookmarksL()
|
|
713 |
{
|
|
714 |
RDEBUG( "CUiSettingsUtil::ReadBookmarksL() >" );
|
|
715 |
RFavouritesSession bmSess;
|
|
716 |
RFavouritesDb bmDb;
|
|
717 |
User::LeaveIfError(bmSess.Connect());
|
|
718 |
User::LeaveIfError(bmDb.Open(bmSess, KBrowserBookmarks));
|
|
719 |
if(iFavList)
|
|
720 |
{
|
|
721 |
delete iFavList;
|
|
722 |
iFavList = NULL;
|
|
723 |
}
|
|
724 |
iFavList = new (ELeave) CFavouritesItemList();
|
|
725 |
TInt err = bmDb.GetAll(*iFavList, KFavouritesNullUid, CFavouritesItem::EItem);
|
|
726 |
bmDb.Close();
|
|
727 |
bmSess.Close();
|
|
728 |
RDEBUG( "CUiSettingsUtil::ReadBookmarksL() <" );
|
|
729 |
}
|
|
730 |
|
|
731 |
// ------------------------------------------------------------------------------------------------
|
|
732 |
// CUiSettingsUtil* CUiSettingsUtil::GetWebTargetsCount( )
|
|
733 |
// ------------------------------------------------------------------------------------------------
|
|
734 |
|
|
735 |
TInt CUiSettingsUtil::GetWebTargetsCount( TInt &aCount )
|
|
736 |
{
|
|
737 |
RDEBUG( "CUiSettingsUtil::GetWebTargetAppUid() >" );
|
|
738 |
aCount = iFavList->Count();
|
|
739 |
RDEBUG( "CUiSettingsUtil::GetWebTargetAppUid() <" );
|
|
740 |
return KErrNone;
|
|
741 |
}
|
|
742 |
|
|
743 |
// ------------------------------------------------------------------------------------------------
|
|
744 |
// CUiSettingsUtil* CUiSettingsUtil::GetWebTargetAppUid( )
|
|
745 |
// ------------------------------------------------------------------------------------------------
|
|
746 |
|
|
747 |
TInt CUiSettingsUtil::GetWebTargetAppUid( TInt aIndex, TInt& aUid )
|
|
748 |
{
|
|
749 |
RDEBUG( "CUiSettingsUtil::GetWebTargetAppUid() >" );
|
|
750 |
CFavouritesItem* item;
|
|
751 |
if(aIndex>=0 && aIndex<iFavList->Count())
|
|
752 |
item = iFavList->At(aIndex);
|
|
753 |
else
|
|
754 |
return KErrArgument;
|
|
755 |
aUid = item->Uid();
|
|
756 |
RDEBUG( "CUiSettingsUtil::GetWebTargetAppUid() <" );
|
|
757 |
return KErrNone;
|
|
758 |
}
|
|
759 |
|
|
760 |
// ------------------------------------------------------------------------------------------------
|
|
761 |
// CUiSettingsUtil* CUiSettingsUtil::GetWebTargetCaption( )
|
|
762 |
// ------------------------------------------------------------------------------------------------
|
|
763 |
|
|
764 |
TInt CUiSettingsUtil::GetWebTargetCaption( TInt aIndex, TDes& aCaption )
|
|
765 |
{
|
|
766 |
RDEBUG( "CUiSettingsUtil::GetWebTargetCaption() >" );
|
|
767 |
CFavouritesItem* item;
|
|
768 |
if(aIndex>=0 && aIndex<iFavList->Count())
|
|
769 |
item = iFavList->At(aIndex);
|
|
770 |
else
|
|
771 |
return KErrArgument;
|
|
772 |
aCaption = item->Name();
|
|
773 |
RDEBUG( "CUiSettingsUtil::GetWebTargetCaption() <" );
|
|
774 |
return KErrNone;
|
|
775 |
}
|
|
776 |
|
|
777 |
// ------------------------------------------------------------------------------------------------
|
|
778 |
// CUiSettingsUtil* CUiSettingsUtil::GetWebTargetIndex( )
|
|
779 |
// ------------------------------------------------------------------------------------------------
|
|
780 |
|
|
781 |
TInt CUiSettingsUtil::GetWebTargetIndex( TInt& aUid, TInt& aIndex)
|
|
782 |
{
|
|
783 |
RDEBUG( "CUiSettingsUtil::GetWebTargetIndex() >" );
|
|
784 |
TBool found = EFalse;
|
|
785 |
TInt i;
|
|
786 |
for (i=0; i < iFavList->Count() ; i++)
|
|
787 |
{
|
|
788 |
CFavouritesItem* item = iFavList->At(i);
|
|
789 |
if(item->Uid() == aUid)
|
|
790 |
{
|
|
791 |
found = ETrue;
|
|
792 |
break;
|
|
793 |
}
|
|
794 |
}
|
|
795 |
if (found)
|
|
796 |
{
|
|
797 |
aIndex = i;
|
|
798 |
return KErrNone;
|
|
799 |
}
|
|
800 |
else
|
|
801 |
{
|
|
802 |
aIndex = -1;
|
|
803 |
return KErrNotFound;
|
|
804 |
}
|
|
805 |
}
|
|
806 |
|
|
807 |
// ------------------------------------------------------------------------------------------------
|
|
808 |
// CUiSettingsUtil* CUiSettingsUtil::SetShortcutTargetWebIndexL( )
|
|
809 |
// ------------------------------------------------------------------------------------------------
|
|
810 |
|
|
811 |
TInt CUiSettingsUtil::SetShortcutTargetWebIndexL( TInt aUid, TInt aIndex )
|
|
812 |
{
|
|
813 |
RDEBUG( "CUiSettingsUtil::SetShortcutTargetWebIndexL() >" );
|
|
814 |
TUint webTargetID = aUid;
|
|
815 |
CFavouritesItem* item;
|
|
816 |
CRepository *cenRep = CRepository::NewL(KCRUidShortcutItems);
|
|
817 |
if(aIndex>=0 && aIndex<iFavList->Count())
|
|
818 |
item = iFavList->At(aIndex);
|
|
819 |
else
|
|
820 |
{
|
|
821 |
delete cenRep;
|
|
822 |
return KErrArgument;
|
|
823 |
}
|
|
824 |
|
|
825 |
TBuf16<256> SetKeyValue;
|
|
826 |
TBuf16<10> appUid ;
|
|
827 |
appUid.Format(KFormat,item->Uid());
|
|
828 |
SetKeyValue = KBookmarkText;
|
|
829 |
SetKeyValue.Insert (SetKeyValue.Length(),appUid);
|
|
830 |
cenRep->Set(webTargetID, SetKeyValue);
|
|
831 |
|
|
832 |
delete cenRep;
|
|
833 |
RDEBUG( "CUiSettingsUtil::SetShortcutTargetWebIndexL() <" );
|
|
834 |
return KErrNone;
|
|
835 |
}
|
|
836 |
|
|
837 |
// ------------------------------------------------------------------------------------------------
|
|
838 |
// CUiSettingsUtil* CUiSettingsUtil::HandleSessionEventL( )
|
|
839 |
// ------------------------------------------------------------------------------------------------
|
|
840 |
|
|
841 |
void CUiSettingsUtil::HandleSessionEventL(TMsvSessionEvent /*aEvent*/, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
|
|
842 |
{
|
|
843 |
// A null function
|
|
844 |
// since we are not registering for any observer
|
|
845 |
// but required since its a pure virtual function in
|
|
846 |
// the parent class
|
|
847 |
}
|