1 /* |
1 /* |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
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 * |
8 * |
16 */ |
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Task list entry |
|
15 * |
|
16 */ |
17 |
17 |
18 #define __E32SVR_H__ |
18 #define __E32SVR_H__ |
19 #include "tsfswentry.h" |
19 #include "tsfswentry.h" |
|
20 #include "tsdataobserver.h" |
20 #include <s32strm.h> |
21 #include <s32strm.h> |
21 #include <fbs.h> |
22 #include <fbs.h> |
22 |
23 |
23 // -------------------------------------------------------------------------- |
24 // -------------------------------------------------------------------------- |
24 // CTsFswEntry::NewL |
25 // CTsFswEntry::NewL |
25 // -------------------------------------------------------------------------- |
26 // -------------------------------------------------------------------------- |
26 // |
27 // |
27 CTsFswEntry* CTsFswEntry::NewL() |
28 CTsFswEntry* CTsFswEntry::NewL() |
28 { |
29 { |
29 CTsFswEntry* self = NewLC(); |
30 CTsFswEntry* self = NewLC(); |
30 CleanupStack::Pop( self ); |
31 CleanupStack::Pop(self); |
31 return self; |
32 return self; |
32 } |
33 } |
33 |
34 |
34 // -------------------------------------------------------------------------- |
35 // -------------------------------------------------------------------------- |
35 // CTsFswEntry::NewLC |
36 // CTsFswEntry::NewLC |
36 // -------------------------------------------------------------------------- |
37 // -------------------------------------------------------------------------- |
37 // |
38 // |
38 CTsFswEntry* CTsFswEntry::NewLC() |
39 CTsFswEntry* CTsFswEntry::NewLC() |
39 { |
40 { |
40 CTsFswEntry* self = new ( ELeave ) CTsFswEntry; |
41 CTsFswEntry* self = new (ELeave) CTsFswEntry; |
41 CleanupStack::PushL( self ); |
42 CleanupStack::PushL(self); |
42 return self; |
43 return self; |
43 } |
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 } |
44 |
67 |
45 // -------------------------------------------------------------------------- |
68 // -------------------------------------------------------------------------- |
46 // CTsFswEntry::~CTsFswEntry |
69 // CTsFswEntry::~CTsFswEntry |
47 // -------------------------------------------------------------------------- |
70 // -------------------------------------------------------------------------- |
48 // |
71 // |
49 CTsFswEntry::~CTsFswEntry() |
72 CTsFswEntry::~CTsFswEntry() |
50 { |
73 { |
51 delete iAppName; |
74 delete mAppName; |
52 delete iAppIconBitmap; |
75 delete mAppIconBitmap; |
53 delete iAppIconMask; |
76 delete mAppIconMask; |
54 } |
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 } |
55 |
100 |
56 // -------------------------------------------------------------------------- |
101 // -------------------------------------------------------------------------- |
57 // CTsFswEntry::SetWgId |
102 // CTsFswEntry::SetWgId |
58 // -------------------------------------------------------------------------- |
103 // -------------------------------------------------------------------------- |
59 // |
104 // |
60 void CTsFswEntry::SetWgId( TInt aWgId ) |
105 void CTsFswEntry::SetWgId(TInt wgId) |
61 { |
106 { |
62 iWgId = aWgId; |
107 mWgId = wgId; |
63 } |
108 mKey = TTsEntryKey(mWgId); |
|
109 } |
64 |
110 |
65 // -------------------------------------------------------------------------- |
111 // -------------------------------------------------------------------------- |
66 // CTsFswEntry::SetAppUid |
112 // CTsFswEntry::SetAppUid |
67 // -------------------------------------------------------------------------- |
113 // -------------------------------------------------------------------------- |
68 // |
114 // |
69 void CTsFswEntry::SetAppUid( const TUid& aUid ) |
115 void CTsFswEntry::SetAppUid(const TUid& uid) |
70 { |
116 { |
71 iAppUid = aUid; |
117 mAppUid = uid; |
72 } |
118 } |
73 |
119 |
74 // -------------------------------------------------------------------------- |
120 // -------------------------------------------------------------------------- |
75 // CTsFswEntry::SetAppNameL |
121 // CTsFswEntry::SetAppNameL |
76 // -------------------------------------------------------------------------- |
122 // -------------------------------------------------------------------------- |
77 // |
123 // |
78 void CTsFswEntry::SetAppNameL( const TDesC& aAppName ) |
124 void CTsFswEntry::SetAppNameL(const TDesC& appName) |
79 { |
125 { |
80 delete iAppName; iAppName = 0; |
126 delete mAppName; |
81 iAppName = aAppName.AllocL(); |
127 mAppName = 0; |
82 } |
128 mAppName = appName.AllocL(); |
|
129 } |
83 |
130 |
84 // -------------------------------------------------------------------------- |
131 // -------------------------------------------------------------------------- |
85 // CTsFswEntry::SetSystemApp |
132 // CTsFswEntry::SetSystemApp |
86 // -------------------------------------------------------------------------- |
133 // -------------------------------------------------------------------------- |
87 // |
134 // |
88 void CTsFswEntry::SetCloseableApp( TBool aValue ) |
135 void CTsFswEntry::SetCloseableApp(TBool value) |
89 { |
136 { |
90 iCloseableApp = aValue; |
137 mCloseableApp = value; |
91 } |
138 } |
92 |
139 |
93 // -------------------------------------------------------------------------- |
140 // -------------------------------------------------------------------------- |
94 // CTsFswEntry::SetAppIconHandles |
141 // CTsFswEntry::SetAppIconHandles |
95 // -------------------------------------------------------------------------- |
142 // -------------------------------------------------------------------------- |
96 // |
143 // |
97 void CTsFswEntry::SetAppIcon( CFbsBitmap* aBitmap, CFbsBitmap* aMask ) |
144 void CTsFswEntry::SetAppIcon(CFbsBitmap* bitmap, CFbsBitmap* mask) |
98 { |
145 { |
99 iAppIconBitmap = aBitmap; |
146 mAppIconBitmap = bitmap; |
100 iAppIconMask = aMask; |
147 mAppIconMask = mask; |
101 } |
148 } |
102 |
149 |
103 // -------------------------------------------------------------------------- |
150 // -------------------------------------------------------------------------- |
104 // CTsFswEntry::WgId |
151 // CTsFswEntry::WgId |
105 // -------------------------------------------------------------------------- |
152 // -------------------------------------------------------------------------- |
106 // |
153 // |
107 TInt CTsFswEntry::WgId() const |
154 TInt CTsFswEntry::WgId() const |
108 { |
155 { |
109 return iWgId; |
156 return mWgId; |
110 } |
157 } |
111 |
158 |
112 // -------------------------------------------------------------------------- |
159 // -------------------------------------------------------------------------- |
113 // CTsFswEntry::AppUid |
160 // CTsFswEntry::AppUid |
114 // -------------------------------------------------------------------------- |
161 // -------------------------------------------------------------------------- |
115 // |
162 // |
116 TUid CTsFswEntry::AppUid() const |
163 TUid CTsFswEntry::AppUid() const |
117 { |
164 { |
118 return iAppUid; |
165 return mAppUid; |
119 } |
166 } |
120 |
167 |
121 // -------------------------------------------------------------------------- |
168 // -------------------------------------------------------------------------- |
122 // CTsFswEntry::AppName |
169 // CTsFswEntry::AppName |
123 // -------------------------------------------------------------------------- |
170 // -------------------------------------------------------------------------- |
124 // |
171 // |
125 const TDesC& CTsFswEntry::AppName() const |
172 const TDesC& CTsFswEntry::AppName() const |
126 { |
173 { |
127 return iAppName ? *iAppName : KNullDesC(); |
174 return mAppName ? *mAppName : KNullDesC(); |
128 } |
175 } |
129 |
176 |
130 // -------------------------------------------------------------------------- |
177 // -------------------------------------------------------------------------- |
131 // CTsFswEntry::SystemApp |
178 // CTsFswEntry::SystemApp |
132 // -------------------------------------------------------------------------- |
179 // -------------------------------------------------------------------------- |
133 // |
180 // |
134 TBool CTsFswEntry::CloseableApp() const |
181 TBool CTsFswEntry::CloseableApp() const |
135 { |
182 { |
136 return iCloseableApp; |
183 return mCloseableApp; |
137 } |
184 } |
138 |
185 |
139 // -------------------------------------------------------------------------- |
186 // -------------------------------------------------------------------------- |
140 // CTsFswEntry::AppIconBitmapHandle |
187 // CTsFswEntry::AppIconBitmapHandle |
141 // -------------------------------------------------------------------------- |
188 // -------------------------------------------------------------------------- |
142 // |
189 // |
143 CFbsBitmap* CTsFswEntry::AppIconBitmap() const |
190 CFbsBitmap* CTsFswEntry::AppIconBitmap() const |
144 { |
191 { |
145 return iAppIconBitmap; |
192 return mAppIconBitmap; |
146 } |
193 } |
147 |
194 |
148 // -------------------------------------------------------------------------- |
195 // -------------------------------------------------------------------------- |
149 // CTsFswEntry::AppIconMaskHandle |
196 // CTsFswEntry::AppIconMaskHandle |
150 // -------------------------------------------------------------------------- |
197 // -------------------------------------------------------------------------- |
151 // |
198 // |
152 CFbsBitmap* CTsFswEntry::AppIconMask() const |
199 CFbsBitmap* CTsFswEntry::AppIconMask() const |
153 { |
200 { |
154 return iAppIconMask; |
201 return mAppIconMask; |
155 } |
202 } |
156 |
203 |
|
204 // -------------------------------------------------------------------------- |
|
205 // CTsFswEntry::Key |
|
206 // -------------------------------------------------------------------------- |
|
207 // |
|
208 const TTsEntryKey& CTsFswEntry::Key() const |
|
209 { |
|
210 return mKey; |
|
211 } |
157 // -------------------------------------------------------------------------- |
212 // -------------------------------------------------------------------------- |
158 // CTsFswEntry::ExternalizeL |
213 // CTsFswEntry::ExternalizeL |
159 // -------------------------------------------------------------------------- |
214 // -------------------------------------------------------------------------- |
160 // |
215 // |
161 void CTsFswEntry::ExternalizeL( RWriteStream& aStream ) |
216 void CTsFswEntry::ExternalizeL(RWriteStream& stream) |
162 { |
217 { |
163 aStream.WriteInt32L( iWgId ); |
218 stream.WriteInt32L(mWgId); |
164 aStream.WriteInt32L( iAppUid.iUid ); |
219 stream.WriteInt32L(mAppUid.iUid); |
165 aStream << AppName(); |
220 stream << AppName(); |
166 aStream.WriteInt32L( iCloseableApp ); |
221 stream.WriteInt32L(mCloseableApp); |
167 if ( iAppIconBitmap ) |
222 if (mAppIconBitmap) { |
168 { |
223 stream.WriteInt32L(mAppIconBitmap->Handle()); |
169 aStream.WriteInt32L( iAppIconBitmap->Handle() ); |
224 } |
|
225 else { |
|
226 stream.WriteInt32L(KErrNotFound); |
|
227 } |
|
228 |
|
229 if (mAppIconMask) { |
|
230 stream.WriteInt32L(mAppIconMask->Handle()); |
|
231 } |
|
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 } |
|
247 |
|
248 // -------------------------------------------------------------------------- |
|
249 // CTsFswEntry::InternalizeL |
|
250 // -------------------------------------------------------------------------- |
|
251 // |
|
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); |
|
266 } |
|
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 } |
|
279 |
|
280 // -------------------------------------------------------------------------- |
|
281 // CTsFswEntry::ExternalizeArrayL |
|
282 // -------------------------------------------------------------------------- |
|
283 // |
|
284 void CTsFswEntry::ExternalizeArrayL(RWriteStream& stream, const RTsFswArray& aArray) |
|
285 { |
|
286 TInt count = aArray.Count(); |
|
287 stream.WriteInt32L(count); |
|
288 for (TInt i = 0; i < count; ++i) { |
|
289 aArray[i]->ExternalizeL(stream); |
|
290 } |
|
291 } |
|
292 |
|
293 // -------------------------------------------------------------------------- |
|
294 // CTsFswEntry::InternalizeArrayL |
|
295 // -------------------------------------------------------------------------- |
|
296 // |
|
297 void CTsFswEntry::InternalizeArrayL(RReadStream& stream, RTsFswArray& aArray) |
|
298 { |
|
299 aArray.ResetAndDestroy(); |
|
300 TInt count = stream.ReadInt32L(); |
|
301 for (TInt i = 0; i < count; ++i) { |
|
302 CTsFswEntry* entry = CTsFswEntry::NewLC(); |
|
303 entry->InternalizeL(stream); |
|
304 aArray.AppendL(entry); |
|
305 CleanupStack::Pop(entry); |
|
306 } |
|
307 } |
|
308 |
|
309 // -------------------------------------------------------------------------- |
|
310 // CTsFswEntry::Type |
|
311 // -------------------------------------------------------------------------- |
|
312 // |
|
313 TAppType CTsFswEntry::Type() const |
|
314 { |
|
315 return EApp; |
|
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; |
|
342 } |
|
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(); |
170 } |
391 } |
171 else |
392 } |
172 { |
393 } |
173 aStream.WriteInt32L( KErrNotFound ); |
394 |
174 } |
|
175 |
|
176 if ( iAppIconMask ) |
|
177 { |
|
178 aStream.WriteInt32L( iAppIconMask->Handle() ); |
|
179 } |
|
180 else |
|
181 { |
|
182 aStream.WriteInt32L( KErrNotFound ); |
|
183 } |
|
184 } |
|
185 |
|
186 // -------------------------------------------------------------------------- |
|
187 // CTsFswEntry::InternalizeL |
|
188 // -------------------------------------------------------------------------- |
|
189 // |
|
190 void CTsFswEntry::InternalizeL( RReadStream& aStream ) |
|
191 { |
|
192 iWgId = aStream.ReadInt32L(); |
|
193 iAppUid = TUid::Uid( aStream.ReadInt32L() ); |
|
194 delete iAppName; iAppName = NULL; |
|
195 iAppName = HBufC::NewL( aStream, KMaxTInt ); |
|
196 iCloseableApp = aStream.ReadInt32L(); |
|
197 TInt appIconBitmapHandle = aStream.ReadInt32L(); |
|
198 TInt appIconMaskHandle = aStream.ReadInt32L(); |
|
199 if ( appIconBitmapHandle != KErrNotFound ) |
|
200 { |
|
201 iAppIconBitmap = new (ELeave) CFbsBitmap; |
|
202 iAppIconBitmap->Duplicate( appIconBitmapHandle ); |
|
203 } |
|
204 if ( appIconMaskHandle != KErrNotFound ) |
|
205 { |
|
206 iAppIconMask = new (ELeave) CFbsBitmap; |
|
207 iAppIconMask->Duplicate( appIconMaskHandle ); |
|
208 } |
|
209 } |
|
210 |
|
211 // -------------------------------------------------------------------------- |
|
212 // CTsFswEntry::ExternalizeArrayL |
|
213 // -------------------------------------------------------------------------- |
|
214 // |
|
215 void CTsFswEntry::ExternalizeArrayL( RWriteStream& aStream, |
|
216 const RTsFswArray& aArray ) |
|
217 { |
|
218 TInt count = aArray.Count(); |
|
219 aStream.WriteInt32L( count ); |
|
220 for ( TInt i = 0; i < count; ++i ) |
|
221 { |
|
222 aArray[i]->ExternalizeL( aStream ); |
|
223 } |
|
224 } |
|
225 |
|
226 // -------------------------------------------------------------------------- |
|
227 // CTsFswEntry::InternalizeArrayL |
|
228 // -------------------------------------------------------------------------- |
|
229 // |
|
230 void CTsFswEntry::InternalizeArrayL( RReadStream& aStream, |
|
231 RTsFswArray& aArray ) |
|
232 { |
|
233 aArray.ResetAndDestroy(); |
|
234 TInt count = aStream.ReadInt32L(); for ( TInt i = 0; i < count; ++i ) |
|
235 { |
|
236 CTsFswEntry* entry = CTsFswEntry::NewLC(); |
|
237 entry->InternalizeL( aStream ); |
|
238 aArray.AppendL( entry ); |
|
239 CleanupStack::Pop( entry ); |
|
240 } |
|
241 } |
|
242 |
|
243 // -------------------------------------------------------------------------- |
|
244 // CTsFswEntry::Type |
|
245 // -------------------------------------------------------------------------- |
|
246 // |
|
247 TAppType CTsFswEntry::Type() const |
|
248 { |
|
249 return EApp; |
|
250 } |
|
251 // end of file |
395 // end of file |