5
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-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 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: This Class provides information of Application installed on phone.
|
|
15 |
*
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
#include "appinfo.h"
|
|
21 |
|
|
22 |
// Length of heap descriptor holding keyvalue.
|
|
23 |
|
|
24 |
//(8*8) + (2 * 8) = 64 + 16 = 80 , 10 bytes + 1 = 11 bytes
|
|
25 |
const TInt KUidLength = 20;
|
|
26 |
|
|
27 |
_LIT(KHEXAdd,"0x");
|
|
28 |
// -----------------------------------------------------------------------------
|
|
29 |
// CAppInfo::NewL
|
|
30 |
// Returns the instance of CAppInfo class.
|
|
31 |
// -----------------------------------------------------------------------------
|
|
32 |
CAppInfo* CAppInfo::NewL(TApaAppInfo& aAppInfo)
|
|
33 |
{
|
|
34 |
CAppInfo* self = new(ELeave) CAppInfo(aAppInfo);
|
|
35 |
CleanupStack::PushL(self);
|
|
36 |
self->ConstructL();
|
|
37 |
CleanupStack::Pop(self);
|
|
38 |
return self;
|
|
39 |
}
|
|
40 |
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
// CAppInfo::ConstructL
|
|
43 |
// Two-phased constructor
|
|
44 |
// -----------------------------------------------------------------------------
|
|
45 |
void CAppInfo::ConstructL()
|
|
46 |
{
|
|
47 |
iKeyArray = new(ELeave) CDesC8ArraySeg( KArrayGranularity );
|
|
48 |
|
|
49 |
iKeyArray->AppendL(KName);
|
|
50 |
iKeyArray->AppendL(KUid);
|
|
51 |
iKeyArray->AppendL(KCaption);
|
|
52 |
iKeyArray->AppendL(KShortCaption);
|
|
53 |
TInt count = iKeyArray->Count();
|
|
54 |
for(TInt index = 0 ; index < count ;index++)
|
|
55 |
{
|
|
56 |
//Intializing the Array
|
|
57 |
iKeyValArray.AppendL(NULL);
|
|
58 |
}
|
|
59 |
|
|
60 |
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
// -----------------------------------------------------------------------------
|
|
65 |
// CAppInfo::CAppInfo
|
|
66 |
// C++ constructor
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
CAppInfo::CAppInfo(TApaAppInfo& aAppInfo):iAppInfo(aAppInfo)
|
|
69 |
{
|
|
70 |
|
|
71 |
}
|
|
72 |
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
// CAppInfo::~CAppInfo
|
|
75 |
// destructor
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
CAppInfo::~CAppInfo()
|
|
78 |
{
|
|
79 |
|
|
80 |
|
|
81 |
iKeyValArray.ResetAndDestroy();
|
|
82 |
|
|
83 |
if(iKeyArray)
|
|
84 |
{
|
|
85 |
|
|
86 |
iKeyArray->Reset();
|
|
87 |
delete iKeyArray;
|
|
88 |
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
// -----------------------------------------------------------------------------
|
|
93 |
// CAppInfo::FindL
|
|
94 |
// This function finds the value as per key given in argument
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
TBool CAppInfo::FindL(const TDesC8& aKey, TPtrC& aVal)
|
|
97 |
{
|
|
98 |
TBool flgret = ETrue;
|
|
99 |
TInt index = -1;
|
|
100 |
|
|
101 |
//For each key fetching the Value from underlying S60 classes
|
|
102 |
if(aKey.CompareF(KName) == KErrNone)
|
|
103 |
{
|
|
104 |
|
|
105 |
iKeyArray->Find(KName,index);
|
|
106 |
|
|
107 |
if(index >= 0)
|
|
108 |
{
|
|
109 |
if( NULL == iKeyValArray[index])
|
|
110 |
{
|
|
111 |
HBufC* keyval = HBufC::NewL(iAppInfo.iFullName.Length());
|
|
112 |
|
|
113 |
TPtr val(keyval->Des());
|
|
114 |
|
|
115 |
val.Append(iAppInfo.iFullName);
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
iKeyValArray[index] = keyval;
|
|
120 |
}
|
|
121 |
|
|
122 |
aVal.Set(*iKeyValArray[index]);
|
|
123 |
|
|
124 |
}
|
|
125 |
|
|
126 |
}
|
|
127 |
else if(aKey.CompareF(KUid) == KErrNone)
|
|
128 |
{
|
|
129 |
|
|
130 |
iKeyArray->Find(KUid,index);
|
|
131 |
|
|
132 |
if(index >= 0)
|
|
133 |
{
|
|
134 |
if(NULL == iKeyValArray[index])
|
|
135 |
{
|
|
136 |
|
|
137 |
HBufC* keyval = HBufC::NewL(KUidLength);
|
|
138 |
|
|
139 |
TPtr val(keyval->Des());
|
|
140 |
val.Append(KHEXAdd);
|
|
141 |
val.AppendNum(iAppInfo.iUid.iUid,EHex);
|
|
142 |
|
|
143 |
|
|
144 |
iKeyValArray[index] = keyval;
|
|
145 |
}
|
|
146 |
|
|
147 |
aVal.Set(*iKeyValArray[index]);
|
|
148 |
|
|
149 |
}
|
|
150 |
|
|
151 |
}
|
|
152 |
else if(aKey.CompareF(KShortCaption) == KErrNone)
|
|
153 |
{
|
|
154 |
|
|
155 |
iKeyArray->Find(KShortCaption,index);
|
|
156 |
|
|
157 |
if(index >= 0)
|
|
158 |
{
|
|
159 |
if(NULL == iKeyValArray[index])
|
|
160 |
{
|
|
161 |
|
|
162 |
HBufC* keyval = HBufC::NewL(iAppInfo.iShortCaption.Length());
|
|
163 |
|
|
164 |
TPtr val(keyval->Des());
|
|
165 |
|
|
166 |
val.Append(iAppInfo.iShortCaption);
|
|
167 |
|
|
168 |
|
|
169 |
iKeyValArray[index] = keyval;
|
|
170 |
}
|
|
171 |
|
|
172 |
aVal.Set(*iKeyValArray[index]);
|
|
173 |
|
|
174 |
}
|
|
175 |
|
|
176 |
}
|
|
177 |
else if(aKey.CompareF(KCaption) == KErrNone)
|
|
178 |
{
|
|
179 |
|
|
180 |
iKeyArray->Find(KCaption,index);
|
|
181 |
|
|
182 |
if(index >= 0)
|
|
183 |
{
|
|
184 |
if(NULL == iKeyValArray[index])
|
|
185 |
{
|
|
186 |
|
|
187 |
HBufC* keyval = HBufC::NewL(iAppInfo.iCaption.Length());
|
|
188 |
|
|
189 |
TPtr val(keyval->Des());
|
|
190 |
|
|
191 |
val.Append(iAppInfo.iCaption);
|
|
192 |
|
|
193 |
|
|
194 |
iKeyValArray[index] = keyval;
|
|
195 |
}
|
|
196 |
|
|
197 |
aVal.Set(*iKeyValArray[index]);
|
|
198 |
|
|
199 |
}
|
|
200 |
}
|
|
201 |
else
|
|
202 |
{
|
|
203 |
flgret = EFalse;
|
|
204 |
}
|
|
205 |
|
|
206 |
return flgret;
|
|
207 |
}
|
|
208 |
|
|
209 |
|
|
210 |
// -----------------------------------------------------------------------------
|
|
211 |
// CAppInfo::AtL
|
|
212 |
// This function gives the key value at a given index
|
|
213 |
// -----------------------------------------------------------------------------
|
|
214 |
TBool CAppInfo::AtL(TInt aIndex, TDes8& aKeyVal)
|
|
215 |
{
|
|
216 |
TBool flgret= EFalse;
|
|
217 |
|
|
218 |
if((-1 < aIndex)&& (aIndex< iKeyArray->Count()))
|
|
219 |
{
|
|
220 |
aKeyVal.Copy((*iKeyArray)[aIndex]);
|
|
221 |
flgret = ETrue;
|
|
222 |
}
|
|
223 |
else
|
|
224 |
{
|
|
225 |
flgret = EFalse;
|
|
226 |
}
|
|
227 |
|
|
228 |
return flgret;
|
|
229 |
|
|
230 |
}
|
|
231 |
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
// CAppInfo::Count
|
|
234 |
// This function gives the number of keys
|
|
235 |
// -----------------------------------------------------------------------------
|
|
236 |
TInt CAppInfo::Count() const
|
|
237 |
{
|
|
238 |
|
|
239 |
return iKeyArray->Length();
|
|
240 |
}
|