|
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 the packages installed on |
|
15 * the phone by user. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "pkginfo.h" |
|
21 #include "installpkgiterator.h" |
|
22 |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CInstallPkgIterator::NewL |
|
26 // Returns the instance of CInstallPkgIterator class. |
|
27 // ----------------------------------------------------------------------------- |
|
28 CInstallPkgIterator* CInstallPkgIterator::NewL() |
|
29 { |
|
30 CInstallPkgIterator* self = new(ELeave)CInstallPkgIterator(); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CInstallPkgIterator::CInstallPkgIterator |
|
39 // C++ Constructor |
|
40 // ----------------------------------------------------------------------------- |
|
41 CInstallPkgIterator::CInstallPkgIterator():iJavaReg(NULL),iCurrent(0) |
|
42 { |
|
43 |
|
44 |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CInstallPkgIterator::ConstructL |
|
49 // Two-phase constructor |
|
50 // ----------------------------------------------------------------------------- |
|
51 |
|
52 void CInstallPkgIterator::ConstructL() |
|
53 { |
|
54 |
|
55 User::LeaveIfError( iSisRegSession.Connect() ); |
|
56 |
|
57 iJavaReg = Java::CJavaRegistry::NewL(); |
|
58 |
|
59 //Getting the uids of all native application |
|
60 iSisRegSession.InstalledUidsL(iSisxUids); |
|
61 |
|
62 |
|
63 //Getting the uids of non-native means java application |
|
64 iJavaReg->GetRegistryEntryUidsL( Java::EMidp2MidletSuite ,iJavaUids ); |
|
65 |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CInstallPkgIterator::~CInstallPkgIterator |
|
70 // Destructor |
|
71 // ----------------------------------------------------------------------------- |
|
72 |
|
73 CInstallPkgIterator::~CInstallPkgIterator() |
|
74 { |
|
75 |
|
76 iSisxUids.Reset(); |
|
77 |
|
78 iJavaUids.Reset(); |
|
79 |
|
80 iSisRegSession.Close(); |
|
81 |
|
82 delete iJavaReg; |
|
83 |
|
84 } |
|
85 |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CInstallPkgIterator::NextL |
|
89 // It gives the instance of MInfoMap which contains the information about next package |
|
90 // iterator list. |
|
91 // ----------------------------------------------------------------------------- |
|
92 |
|
93 TBool CInstallPkgIterator::NextL( MInfoMap*& aInfo ) |
|
94 { |
|
95 |
|
96 TBool flg = EFalse; |
|
97 |
|
98 //First it will return all native application |
|
99 if( iSisxUids.Count() > iCurrent ) |
|
100 { |
|
101 CPkgInfo* pkg = CPkgInfo::NewL(&iSisRegSession); |
|
102 |
|
103 CleanupStack::PushL(pkg); |
|
104 |
|
105 while(flg == EFalse) |
|
106 { |
|
107 pkg->SetEntryL( iSisxUids[iCurrent], flg ); |
|
108 iCurrent++; |
|
109 |
|
110 if(iCurrent >= iSisxUids.Count() ) |
|
111 break; |
|
112 } |
|
113 CleanupStack::Pop(pkg); |
|
114 |
|
115 if(flg == EFalse) |
|
116 { |
|
117 delete pkg; |
|
118 pkg = NULL; |
|
119 } |
|
120 else |
|
121 { |
|
122 aInfo = pkg; |
|
123 } |
|
124 |
|
125 } |
|
126 |
|
127 |
|
128 //After finishing native application it will return non-native application |
|
129 if( ( ( iJavaUids.Count() + iSisxUids.Count()-1 )>= iCurrent) && (flg ==EFalse)) |
|
130 { |
|
131 |
|
132 CPkgInfo* pkg = CPkgInfo::NewL(iJavaReg); |
|
133 |
|
134 CleanupStack::PushL(pkg); |
|
135 |
|
136 |
|
137 |
|
138 while(flg == EFalse) |
|
139 { |
|
140 |
|
141 pkg->SetEntryL( iJavaUids[iCurrent-iSisxUids.Count()], flg ); |
|
142 iCurrent++; |
|
143 |
|
144 if(iCurrent >= ( iJavaUids.Count() + iSisxUids.Count()-1 ) ) |
|
145 break; |
|
146 |
|
147 } |
|
148 |
|
149 |
|
150 CleanupStack::Pop(pkg); |
|
151 if(flg == EFalse) |
|
152 { |
|
153 delete pkg; |
|
154 |
|
155 } |
|
156 else |
|
157 { |
|
158 aInfo = pkg; |
|
159 } |
|
160 } |
|
161 |
|
162 |
|
163 return flg; |
|
164 } |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CInstallPkgIterator::Reset |
|
167 // It resets the iterator |
|
168 // ----------------------------------------------------------------------------- |
|
169 |
|
170 void CInstallPkgIterator::Reset() |
|
171 { |
|
172 |
|
173 iCurrent = 0; |
|
174 |
|
175 } |
|
176 |
|
177 |