|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "activitythumbnailtask.h" |
|
19 #include "activitycmd.h" |
|
20 |
|
21 #include <fbs.h> |
|
22 |
|
23 // ----------------------------------------------------------------------------- |
|
24 // |
|
25 // ----------------------------------------------------------------------------- |
|
26 // |
|
27 CActivityThumbnailTask::CActivityThumbnailTask(MActivityTaskStorage& storage, |
|
28 const RMessage2 msg) |
|
29 : |
|
30 mStorage(storage), |
|
31 mMsg(msg) |
|
32 { |
|
33 // No implementation required |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CActivityThumbnailTask::~CActivityThumbnailTask() |
|
41 { |
|
42 delete mService; |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CActivityThumbnailTask::ExecuteLD(RFs& session, |
|
50 MActivityTaskStorage& taskStorage, |
|
51 const RMessage2& message) |
|
52 { |
|
53 CActivityThumbnailTask *self = new (ELeave)CActivityThumbnailTask(taskStorage, |
|
54 message); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(session); |
|
57 taskStorage.PushL(self); |
|
58 CleanupStack::Pop(self); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CActivityThumbnailTask::ConstructL(RFs& session) |
|
66 { |
|
67 TPckgBuf<int> width(0), height(0); |
|
68 RBuf path; |
|
69 RBuf8 mime; |
|
70 CleanupClosePushL(path); |
|
71 CleanupClosePushL(mime); |
|
72 mMsg.ReadL(0, width); |
|
73 mMsg.ReadL(1, height); |
|
74 path.CreateL(mMsg.GetDesLengthL(2)); |
|
75 mMsg.ReadL(2, path); |
|
76 mime.CreateL(mMsg.GetDesLengthL(3)); |
|
77 mMsg.ReadL(3, mime); |
|
78 if(0 >= width() || |
|
79 0 >=height() || |
|
80 0 >= path.Length() || |
|
81 0 >= mime.Length() |
|
82 ) { |
|
83 User::Leave(KErrCorrupt); |
|
84 } |
|
85 |
|
86 mService = CGraphicsSalingHandler::NewL(*this, |
|
87 session, |
|
88 path, |
|
89 mime, |
|
90 TSize(width(), height()), |
|
91 CGraphicsSalingHandler::EKeepAspectRatio); |
|
92 |
|
93 CleanupStack::PopAndDestroy(&mime); |
|
94 CleanupStack::PopAndDestroy(&path); |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CActivityThumbnailTask::ImageReadyCallBack(TInt error,const CFbsBitmap *bitmap) |
|
102 { |
|
103 if (KErrNone == error) { |
|
104 mMsg.Write(0, TPckgBuf<int>(const_cast<CFbsBitmap*>(bitmap)->Handle())); |
|
105 mMsg.Write(1, TPckgBuf<void *>(this)); |
|
106 mMsg.Complete(error); |
|
107 } else { |
|
108 mMsg.Complete(error); |
|
109 mStorage.Pop(this); |
|
110 delete this; |
|
111 } |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 const TDesC8& CActivityThumbnailTask::Data() const |
|
119 { |
|
120 return KNullDesC8(); |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CActivityThumbnailTask::BroadcastReceivedL(const RMessage2& ) |
|
128 { |
|
129 } |
|
130 |