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 |
|
79 mService = CTsGraphicFileScalingHandler::NewL(*this, |
|
80 session, |
|
81 path, |
|
82 mime, |
|
83 TSize(width(), height()), |
|
84 CTsGraphicFileScalingHandler::EKeepAspectRatio); |
|
85 |
|
86 CleanupStack::PopAndDestroy(&mime); |
|
87 CleanupStack::PopAndDestroy(&path); |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void CActivityThumbnailTask::ImageReadyCallBack(TInt error,const CFbsBitmap *bitmap) |
|
95 { |
|
96 if (EFalse == mMsg.IsNull() && |
|
97 KErrNone == error) { |
|
98 mMsg.Write(0, TPckgBuf<int>(const_cast<CFbsBitmap*>(bitmap)->Handle())); |
|
99 mMsg.Write(1, TPckgBuf<void *>(this)); |
|
100 mMsg.Complete(error); |
|
101 } else { |
|
102 if (EFalse == mMsg.IsNull()) { |
|
103 mMsg.Complete(error); |
|
104 } |
|
105 mStorage.Pop(this); |
|
106 delete this; |
|
107 } |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 const TDesC8& CActivityThumbnailTask::Data() const |
|
115 { |
|
116 return KNullDesC8(); |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CActivityThumbnailTask::BroadcastReceivedL(const RMessage2&) |
|
124 { |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 TBool CActivityThumbnailTask::IsSessionTask(const CSession2* session) |
|
132 { |
|
133 return mMsg.Session() == session ? ETrue : EFalse; |
|
134 } |
|