|
1 /* |
|
2 * CookieClientDataArray.cpp |
|
3 * |
|
4 * Created on: Dec 18, 2009 |
|
5 * Author: mohanti |
|
6 */ |
|
7 |
|
8 //System Includes |
|
9 #include <e32cmn.h> |
|
10 #include <e32base.h> |
|
11 #include <e32std.h> |
|
12 |
|
13 //User Includes |
|
14 #include "CookieClientDataArray.h" |
|
15 #include "cookiemanagerclient.h" |
|
16 #include "CookieArray.h" |
|
17 #include "CookieLogger.h" |
|
18 #include "CookieClientData.h" |
|
19 |
|
20 //Constatnts |
|
21 const TInt KCookieArrayGranularity = 10; |
|
22 |
|
23 |
|
24 // --------------------------------------------------------- |
|
25 // CCookieClientDataArray::New |
|
26 // --------------------------------------------------------- |
|
27 // |
|
28 |
|
29 CCookieClientDataArray* CCookieClientDataArray::New() |
|
30 { |
|
31 CCookieClientDataArray* arrayInstance = new CCookieClientDataArray(); |
|
32 if (arrayInstance) |
|
33 { |
|
34 arrayInstance->Init(); |
|
35 } |
|
36 return arrayInstance ; |
|
37 } |
|
38 |
|
39 CCookieClientDataArray::CCookieClientDataArray() |
|
40 { |
|
41 } |
|
42 |
|
43 void CCookieClientDataArray::Init() |
|
44 { |
|
45 iCookieClientData = new RPointerArray<CCookieClientData>(KCookieArrayGranularity); |
|
46 } |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // CCookieClientDataArray::~CCookieClientDataArray |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 CCookieClientDataArray::~CCookieClientDataArray() |
|
53 { |
|
54 CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::~CCookieClientDataArray" ) ) ); |
|
55 if(iCookieClientData && iCookieClientData->Count()) |
|
56 { |
|
57 iCookieClientData->ResetAndDestroy(); |
|
58 iCookieClientData->Close(); |
|
59 //delete iCookieClientData; |
|
60 iCookieClientData = NULL; |
|
61 } |
|
62 CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::~CCookieClientDataArray" ) ) ); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // CCookieClientDataArray::Count |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 TInt CCookieClientDataArray::Count()const |
|
70 { |
|
71 if (iCookieClientData) |
|
72 return iCookieClientData->Count(); |
|
73 else |
|
74 return 0; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------- |
|
78 // CCookieClientDataArray::Compress |
|
79 // --------------------------------------------------------- |
|
80 // |
|
81 void CCookieClientDataArray::AddClientGroupDataL(CCookieClientData* aCookieClientData) |
|
82 { |
|
83 CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::AddGroupDataL" ) ) ); |
|
84 iCookieClientData->AppendL(aCookieClientData); |
|
85 CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::AddGroupDataL" ) ) ); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // CCookieClientDataArray::Compress |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 void CCookieClientDataArray::Compress() |
|
93 { |
|
94 CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::Compress" ) ) ); |
|
95 iCookieClientData->Compress(); |
|
96 CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Compress" ) ) ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // CCookieClientDataArray::operator[] |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 CCookieClientData* CCookieClientDataArray::operator[](TInt aIndex) const |
|
104 { |
|
105 return (*iCookieClientData)[aIndex]; |
|
106 } |
|
107 |
|
108 // --------------------------------------------------------- |
|
109 // CCookieClientDataArray::At |
|
110 // --------------------------------------------------------- |
|
111 // |
|
112 CCookieClientData* CCookieClientDataArray::At(TInt aIndex) const |
|
113 { |
|
114 return (*iCookieClientData)[ aIndex ]; |
|
115 } |
|
116 // --------------------------------------------------------- |
|
117 // CCookieClientDataArray::Find |
|
118 // --------------------------------------------------------- |
|
119 // |
|
120 CCookieClientData* CCookieClientDataArray::Find(const TUint32& aGroupId, const TUint32& aWidgetUid ) |
|
121 { |
|
122 CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::Find GroupId = %x, WidgetUid = %x" ),aGroupId,aWidgetUid ) ); |
|
123 TInt total = Count(); |
|
124 TBool WidgetUidFound = EFalse; |
|
125 TInt index = 0; |
|
126 for ( TInt i = 0;i<total;i++ ) |
|
127 { |
|
128 if (At(i)->GetGroupId()== aGroupId && (At(i)->GetCookieSharableFlag())) |
|
129 { |
|
130 WidgetUidFound = ETrue; |
|
131 index = i; |
|
132 break; |
|
133 } |
|
134 else if (At(i)->GetGroupId()== aGroupId && !(At(i)->GetCookieSharableFlag()) |
|
135 && (At(i)->GetWidgetUid()== aWidgetUid)) |
|
136 { |
|
137 WidgetUidFound = ETrue; |
|
138 index = i; |
|
139 break; |
|
140 } |
|
141 } |
|
142 if ( WidgetUidFound ) |
|
143 { |
|
144 CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Find found with index = %d" ),index ) ); |
|
145 return At(index); |
|
146 } |
|
147 else |
|
148 { |
|
149 CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Find not found " ) ) ); |
|
150 return NULL; |
|
151 } |
|
152 } |
|
153 // --------------------------------------------------------- |
|
154 // CCookieClientDataArray::FindIndex |
|
155 // --------------------------------------------------------- |
|
156 // |
|
157 TInt CCookieClientDataArray::FindIndex(const TUint32& aGroupId, const TUint32& aWidgetUid,TInt& aIndex ) |
|
158 { |
|
159 CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::FindIndex GroupId = %x,WidgetUid = %x" ) |
|
160 ,aGroupId,aWidgetUid ) ); |
|
161 TInt total = Count(); |
|
162 TBool WidgetUidFound = EFalse; |
|
163 TInt index = 0; |
|
164 for ( TInt i = 0;i<total;i++ ) |
|
165 { |
|
166 if (At(i)->GetGroupId()== aGroupId && (At(i)->GetCookieSharableFlag())) |
|
167 { |
|
168 WidgetUidFound = ETrue; |
|
169 index = i; |
|
170 break; |
|
171 } |
|
172 else if (At(i)->GetGroupId()== aGroupId && !(At(i)->GetCookieSharableFlag()) |
|
173 && (At(i)->GetWidgetUid()== aWidgetUid)) |
|
174 { |
|
175 WidgetUidFound = ETrue; |
|
176 index = i; |
|
177 break; |
|
178 } |
|
179 } |
|
180 if ( WidgetUidFound ) |
|
181 { |
|
182 aIndex = index; |
|
183 CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::FindIndex found with index = %d" ),index ) ); |
|
184 return KErrNone; |
|
185 } |
|
186 else |
|
187 { |
|
188 CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::FindIndex not found " ) ) ); |
|
189 return KErrNotFound; |
|
190 } |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------- |
|
194 // CCookieClientDataArray::CookieArray |
|
195 // --------------------------------------------------------- |
|
196 // |
|
197 CCookieArray* CCookieClientDataArray::CookieArray(TInt aIndex) |
|
198 { |
|
199 CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::CookieArray Index =%d" ),aIndex ) ); |
|
200 CCookieClientData* cookieclientdata = At(aIndex); |
|
201 return cookieclientdata->CookieArray(); |
|
202 } |
|
203 |
|
204 |
|
205 // --------------------------------------------------------- |
|
206 // CCookieClientDataArray::Remove |
|
207 // --------------------------------------------------------- |
|
208 // |
|
209 void CCookieClientDataArray::Remove(TInt aIndex) |
|
210 { |
|
211 CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::Remove %d" ), aIndex ) ); |
|
212 delete (*iCookieClientData)[ aIndex ]; |
|
213 iCookieClientData->Remove(aIndex); |
|
214 iCookieClientData->Compress(); |
|
215 CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::Remove " )) ); |
|
216 } |
|
217 |
|
218 |
|
219 // --------------------------------------------------------- |
|
220 // CCookieClientDataArray::DestroyGroupData |
|
221 // --------------------------------------------------------- |
|
222 // |
|
223 TInt CCookieClientDataArray::DestroyClientData(const TUint32 aAppUid) |
|
224 { |
|
225 CLOG( ( EClient, 0, _L( "-> CCookieClientDataArray::DestroyClientData" ) ) ); |
|
226 TUint32 groupid = RProcess().SecureId().iId; |
|
227 TInt index = -1; |
|
228 TInt err = FindIndex(groupid,aAppUid,index); |
|
229 if ( err == KErrNone ) |
|
230 { |
|
231 Remove(index); |
|
232 } |
|
233 CLOG( ( EClient, 0, _L( "<- CCookieClientDataArray::DestroyClientData removed index = %d" ),index ) ); |
|
234 return err; |
|
235 } |
|
236 //EOF |