1 /* |
|
2 * Copyright (c) 2008 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: Task list entry |
|
15 * |
|
16 */ |
|
17 |
|
18 #define __E32SVR_H__ |
|
19 #include <s32strm.h> |
|
20 #include <fbs.h> |
|
21 #include "tsentry.h" |
|
22 #include "tsdataobserver.h" |
|
23 |
|
24 |
|
25 // -------------------------------------------------------------------------- |
|
26 // CTsFswEntry::NewL |
|
27 // -------------------------------------------------------------------------- |
|
28 // |
|
29 CTsEntry* CTsEntry::NewL() |
|
30 { |
|
31 CTsEntry* self = NewLC(); |
|
32 CleanupStack::Pop(self); |
|
33 return self; |
|
34 } |
|
35 |
|
36 // -------------------------------------------------------------------------- |
|
37 // CTsFswEntry::NewLC |
|
38 // -------------------------------------------------------------------------- |
|
39 // |
|
40 CTsEntry* CTsEntry::NewLC() |
|
41 { |
|
42 CTsEntry* self = new (ELeave) CTsEntry; |
|
43 CleanupStack::PushL(self); |
|
44 return self; |
|
45 } |
|
46 |
|
47 // -------------------------------------------------------------------------- |
|
48 // CTsFswEntry::NewL |
|
49 // -------------------------------------------------------------------------- |
|
50 // |
|
51 CTsEntry* CTsEntry::NewL(const TTsEntryKey& key, MHsDataObserver *observer) |
|
52 { |
|
53 CTsEntry* self = NewLC(key, observer); |
|
54 CleanupStack::Pop(self); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // -------------------------------------------------------------------------- |
|
59 // CTsFswEntry::NewLC |
|
60 // -------------------------------------------------------------------------- |
|
61 // |
|
62 CTsEntry* CTsEntry::NewLC(const TTsEntryKey& key, MHsDataObserver* observer) |
|
63 { |
|
64 CTsEntry* self = new (ELeave) CTsEntry(key, observer); |
|
65 CleanupStack::PushL(self); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // -------------------------------------------------------------------------- |
|
70 // CTsFswEntry::~CTsFswEntry |
|
71 // -------------------------------------------------------------------------- |
|
72 // |
|
73 CTsEntry::~CTsEntry() |
|
74 { |
|
75 delete mAppName; |
|
76 delete mAppIconBitmap; |
|
77 delete mAppIconMask; |
|
78 delete mScreenshot; |
|
79 delete mImgTool; |
|
80 } |
|
81 |
|
82 // -------------------------------------------------------------------------- |
|
83 // CTsFswEntry::CTsFswEntry |
|
84 // -------------------------------------------------------------------------- |
|
85 // |
|
86 CTsEntry::CTsEntry() : |
|
87 mVisibility(Visible), |
|
88 mPriority(Low) |
|
89 { |
|
90 mKey = TTsEntryKey(); |
|
91 } |
|
92 |
|
93 // -------------------------------------------------------------------------- |
|
94 // CTsFswEntry::CTsFswEntry |
|
95 // -------------------------------------------------------------------------- |
|
96 // |
|
97 CTsEntry::CTsEntry(const TTsEntryKey& key, MHsDataObserver *observer) |
|
98 : |
|
99 mVisibility(Visible), |
|
100 mKey(key), |
|
101 mPriority(Low), |
|
102 mObserver(observer) |
|
103 { |
|
104 } |
|
105 |
|
106 // -------------------------------------------------------------------------- |
|
107 // CTsFswEntry::SetAppUid |
|
108 // -------------------------------------------------------------------------- |
|
109 // |
|
110 void CTsEntry::SetAppUid(const TUid& uid) |
|
111 { |
|
112 mAppUid = uid; |
|
113 } |
|
114 |
|
115 // -------------------------------------------------------------------------- |
|
116 // CTsFswEntry::SetAppNameL |
|
117 // -------------------------------------------------------------------------- |
|
118 // |
|
119 void CTsEntry::SetAppNameL(const TDesC& appName) |
|
120 { |
|
121 delete mAppName; |
|
122 mAppName = 0; |
|
123 mAppName = appName.AllocL(); |
|
124 } |
|
125 |
|
126 // -------------------------------------------------------------------------- |
|
127 // CTsFswEntry::SetSystemApp |
|
128 // -------------------------------------------------------------------------- |
|
129 // |
|
130 void CTsEntry::SetCloseableApp(TBool value) |
|
131 { |
|
132 mCloseableApp = value; |
|
133 } |
|
134 |
|
135 // -------------------------------------------------------------------------- |
|
136 // CTsFswEntry::SetAppIconHandles |
|
137 // -------------------------------------------------------------------------- |
|
138 // |
|
139 void CTsEntry::SetAppIcon(CFbsBitmap* bitmap, CFbsBitmap* mask) |
|
140 { |
|
141 mAppIconBitmap = bitmap; |
|
142 mAppIconMask = mask; |
|
143 } |
|
144 |
|
145 // -------------------------------------------------------------------------- |
|
146 /** |
|
147 * Application uid. |
|
148 */ |
|
149 TUid CTsEntry::AppUid() const |
|
150 { |
|
151 return mAppUid; |
|
152 } |
|
153 |
|
154 // -------------------------------------------------------------------------- |
|
155 /** |
|
156 * Application name. |
|
157 */ |
|
158 const TDesC& CTsEntry::AppName() const |
|
159 { |
|
160 return mAppName ? *mAppName : KNullDesC(); |
|
161 } |
|
162 |
|
163 // -------------------------------------------------------------------------- |
|
164 /** |
|
165 * Retrieve entry visibilit status |
|
166 */ |
|
167 Visibility CTsEntry::GetVisibility() const |
|
168 { |
|
169 return mVisibility; |
|
170 } |
|
171 |
|
172 // -------------------------------------------------------------------------- |
|
173 /** |
|
174 * Change entry visibility status |
|
175 * @param visibility - new visibility status |
|
176 */ |
|
177 void CTsEntry::SetVisibility(Visibility visibility) |
|
178 { |
|
179 mVisibility = visibility; |
|
180 } |
|
181 |
|
182 // -------------------------------------------------------------------------- |
|
183 /** |
|
184 * ETrue if the application is closeable |
|
185 */ |
|
186 TBool CTsEntry::CloseableApp() const |
|
187 { |
|
188 return mCloseableApp; |
|
189 } |
|
190 |
|
191 // -------------------------------------------------------------------------- |
|
192 /** |
|
193 * Application icon bitmap |
|
194 */ |
|
195 CFbsBitmap* CTsEntry::AppIconBitmap() const |
|
196 { |
|
197 return mAppIconBitmap; |
|
198 } |
|
199 |
|
200 // -------------------------------------------------------------------------- |
|
201 /** |
|
202 * Application icon mask. |
|
203 */ |
|
204 CFbsBitmap* CTsEntry::AppIconMask() const |
|
205 { |
|
206 return mAppIconMask; |
|
207 } |
|
208 |
|
209 // -------------------------------------------------------------------------- |
|
210 /** |
|
211 * Entry's key |
|
212 */ |
|
213 const TTsEntryKey& CTsEntry::Key() const |
|
214 { |
|
215 return mKey; |
|
216 } |
|
217 // -------------------------------------------------------------------------- |
|
218 // CTsFswEntry::ExternalizeL |
|
219 // -------------------------------------------------------------------------- |
|
220 // |
|
221 void CTsEntry::ExternalizeL(RWriteStream& stream) const |
|
222 { |
|
223 stream.WriteInt32L(mAppUid.iUid); |
|
224 stream << AppName(); |
|
225 stream.WriteInt32L(mCloseableApp); |
|
226 if (mAppIconBitmap) { |
|
227 stream.WriteInt32L(mAppIconBitmap->Handle()); |
|
228 } |
|
229 else { |
|
230 stream.WriteInt32L(KErrNotFound); |
|
231 } |
|
232 |
|
233 if (mAppIconMask) { |
|
234 stream.WriteInt32L(mAppIconMask->Handle()); |
|
235 } |
|
236 else { |
|
237 stream.WriteInt32L(KErrNotFound); |
|
238 } |
|
239 |
|
240 if (mScreenshot) { |
|
241 stream.WriteInt32L(mScreenshot->Handle()); |
|
242 } |
|
243 else { |
|
244 stream.WriteInt32L(KErrNotFound); |
|
245 } |
|
246 |
|
247 mKey.ExternalizeL(stream); |
|
248 TInt currentPriority = static_cast<TInt> (mPriority); |
|
249 stream.WriteInt32L(currentPriority); |
|
250 } |
|
251 |
|
252 // -------------------------------------------------------------------------- |
|
253 // CTsFswEntry::InternalizeL |
|
254 // -------------------------------------------------------------------------- |
|
255 // |
|
256 void CTsEntry::InternalizeL(RReadStream& stream) |
|
257 { |
|
258 |
|
259 mAppUid = TUid::Uid(stream.ReadInt32L()); |
|
260 delete mAppName; |
|
261 mAppName = NULL; |
|
262 mAppName = HBufC::NewL(stream, KMaxTInt); |
|
263 mCloseableApp = stream.ReadInt32L(); |
|
264 TInt appIconBitmapHandle = stream.ReadInt32L(); |
|
265 TInt appIconMaskHandle = stream.ReadInt32L(); |
|
266 TInt screenshotHandle = stream.ReadInt32L(); |
|
267 if (appIconBitmapHandle != KErrNotFound) { |
|
268 mAppIconBitmap = new (ELeave) CFbsBitmap; |
|
269 mAppIconBitmap->Duplicate(appIconBitmapHandle); |
|
270 } |
|
271 if (appIconMaskHandle != KErrNotFound) { |
|
272 mAppIconMask = new (ELeave) CFbsBitmap; |
|
273 mAppIconMask->Duplicate(appIconMaskHandle); |
|
274 } |
|
275 if (screenshotHandle != KErrNotFound) { |
|
276 mScreenshot = new (ELeave) CFbsBitmap; |
|
277 mScreenshot->Duplicate(screenshotHandle); |
|
278 } |
|
279 mKey.InternalizeL(stream); |
|
280 TInt currentPriority = stream.ReadInt32L(); |
|
281 mPriority = static_cast<UpdatePriority> (currentPriority); |
|
282 } |
|
283 |
|
284 // -------------------------------------------------------------------------- |
|
285 // CTsFswEntry::ExternalizeArrayL |
|
286 // -------------------------------------------------------------------------- |
|
287 // |
|
288 void CTsEntry::ExternalizeArrayL(RWriteStream& stream, const RTsFswArray& array) |
|
289 { |
|
290 TInt iter(0); |
|
291 RArray<TInt> visibleItems(array.Count() ? array.Count() : 1); |
|
292 CleanupClosePushL(visibleItems); |
|
293 for (iter = 0; iter < array.Count(); ++iter) { |
|
294 if (Visible == array[iter]->GetVisibility()) { |
|
295 visibleItems.AppendL(iter); |
|
296 } |
|
297 } |
|
298 stream.WriteInt32L(visibleItems.Count()); |
|
299 for (iter = 0; iter < visibleItems.Count(); ++iter) { |
|
300 array[visibleItems[iter]]->ExternalizeL(stream); |
|
301 } |
|
302 CleanupStack::PopAndDestroy(&visibleItems); |
|
303 } |
|
304 |
|
305 // -------------------------------------------------------------------------- |
|
306 // CTsFswEntry::InternalizeArrayL |
|
307 // -------------------------------------------------------------------------- |
|
308 // |
|
309 void CTsEntry::InternalizeArrayL(RReadStream& stream, RTsFswArray& array) |
|
310 { |
|
311 array.ResetAndDestroy(); |
|
312 TInt count = stream.ReadInt32L(); |
|
313 for (TInt i = 0; i < count; ++i) { |
|
314 CTsEntry* entry = CTsEntry::NewLC(); |
|
315 entry->InternalizeL(stream); |
|
316 array.AppendL(entry); |
|
317 CleanupStack::Pop(entry); |
|
318 } |
|
319 } |
|
320 |
|
321 // -------------------------------------------------------------------------- |
|
322 /** |
|
323 * Application type. |
|
324 */ |
|
325 TAppType CTsEntry::Type() const |
|
326 { |
|
327 return EApp; |
|
328 } |
|
329 |
|
330 // -------------------------------------------------------------------------- |
|
331 // CTsFswEntry::SetScreenshot |
|
332 // -------------------------------------------------------------------------- |
|
333 // |
|
334 void CTsEntry::SetScreenshotL(const CFbsBitmap& bitmapArg, UpdatePriority priority) |
|
335 { |
|
336 TInt currentPriority = static_cast<TInt> (mPriority); |
|
337 TInt newPriority = static_cast<TInt> (priority); |
|
338 if(newPriority <currentPriority) { |
|
339 User::Leave(KErrAccessDenied); |
|
340 } |
|
341 |
|
342 CFbsBitmap* bitmap = new (ELeave) CFbsBitmap; |
|
343 CleanupStack::PushL(bitmap); |
|
344 User::LeaveIfError(bitmap->Duplicate(bitmapArg.Handle())); |
|
345 CleanupStack::Pop(bitmap); |
|
346 |
|
347 mPriority = priority; |
|
348 delete mScreenshot; |
|
349 mScreenshot = bitmap; |
|
350 |
|
351 delete mImgTool; |
|
352 mImgTool = 0; |
|
353 |
|
354 mImgTool = CTsGraphicFileScalingHandler::NewL(*this, *mScreenshot, TSize(128, 128), |
|
355 CTsGraphicFileScalingHandler::EKeepAspectRatioByExpanding); |
|
356 } |
|
357 |
|
358 // -------------------------------------------------------------------------- |
|
359 // CTsFswEntry::RemoveScreenshot |
|
360 // -------------------------------------------------------------------------- |
|
361 // |
|
362 void CTsEntry::RemoveScreenshotL() |
|
363 { |
|
364 if (!mScreenshot) { |
|
365 User::Leave(KErrNotFound); |
|
366 } |
|
367 delete mScreenshot; |
|
368 mScreenshot = NULL; |
|
369 mPriority = Low; |
|
370 if (mObserver) { |
|
371 mObserver->DataChanged(); |
|
372 } |
|
373 } |
|
374 |
|
375 // -------------------------------------------------------------------------- |
|
376 /** |
|
377 * Application screenshot. |
|
378 */ |
|
379 CFbsBitmap* CTsEntry::Screenshot() const |
|
380 { |
|
381 return mScreenshot; |
|
382 } |
|
383 |
|
384 // -------------------------------------------------------------------------- |
|
385 /** |
|
386 * Priority. |
|
387 */ |
|
388 UpdatePriority CTsEntry::Priority() const |
|
389 { |
|
390 return mPriority; |
|
391 } |
|
392 |
|
393 // -------------------------------------------------------------------------- |
|
394 // CTsFswEntry::Priority |
|
395 // -------------------------------------------------------------------------- |
|
396 // |
|
397 void CTsEntry::ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap) |
|
398 { |
|
399 if (KErrNone == error && 0 != bitmap) { |
|
400 mScreenshot->Reset(); |
|
401 mScreenshot->Duplicate(bitmap->Handle()); |
|
402 |
|
403 if (mObserver) { |
|
404 mObserver->DataChanged(); |
|
405 } |
|
406 } |
|
407 } |
|
408 |
|
409 // end of file |
|