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