|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Base class for thumbnail server tasks |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <fbs.h> |
|
21 #include "thumbnailtask.h" |
|
22 #include "thumbnailtaskprocessor.h" |
|
23 #include "thumbnailprovider.h" |
|
24 #include "thumbnaillog.h" |
|
25 #include "thumbnailpanic.h" |
|
26 #include "thumbnailserversession.h" // ConvertSqlErrToE32Err() |
|
27 #include "thumbnailmanagerconstants.h" |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CThumbnailTask::CThumbnailTask() |
|
33 // C++ default constructor can NOT contain any code, that might leave. |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CThumbnailTask::CThumbnailTask( CThumbnailTaskProcessor& aProcessor, TInt |
|
37 aPriority ): CActive( EPriorityStandard ), iProcessor( aProcessor ), |
|
38 iPriority( aPriority ), iState( EIdle ) |
|
39 { |
|
40 TN_DEBUG2( "CThumbnailTask(0x%08x)::CThumbnailTask()", this); |
|
41 CActiveScheduler::Add( this ); |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // CThumbnailTask::~CThumbnailTask() |
|
47 // Destructor. |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CThumbnailTask::~CThumbnailTask() |
|
51 { |
|
52 Cancel(); |
|
53 CancelMessage(); |
|
54 } |
|
55 |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CThumbnailTask::Priority() |
|
59 // Returns priority of task. |
|
60 // --------------------------------------------------------------------------- |
|
61 // |
|
62 TInt CThumbnailTask::Priority()const |
|
63 { |
|
64 return iPriority; |
|
65 } |
|
66 |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CThumbnailTask::State() |
|
70 // Returns state of task. |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CThumbnailTask::TTaskState CThumbnailTask::State()const |
|
74 { |
|
75 return iState; |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CThumbnailTask::StartL() |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CThumbnailTask::StartL() |
|
84 { |
|
85 TN_DEBUG3( "CThumbnailTask(0x%08x)::StartL() iState == %d ", this, iState ); |
|
86 __ASSERT_DEBUG(( iState != ERunning ), ThumbnailPanic( EAlreadyRunning )); |
|
87 iState = ERunning; |
|
88 } |
|
89 |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CThumbnailTask::DoCancel() |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 void CThumbnailTask::DoCancel() |
|
96 { |
|
97 // No implementation required |
|
98 } |
|
99 |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CThumbnailTask::Complete() |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CThumbnailTask::Complete( TInt aReason ) |
|
106 { |
|
107 TN_DEBUG4( "CThumbnailTask(0x%08x)::Complete(aReason=%d) iState was %d", |
|
108 this, aReason, iState ); |
|
109 |
|
110 if ( iState != EComplete ) |
|
111 { |
|
112 iState = EComplete; |
|
113 |
|
114 if ( iMessage.Handle()) |
|
115 { |
|
116 if(iMessage.Identity() == KDaemonUid ) |
|
117 { |
|
118 iProcessor.SetDaemonAsProcess(ETrue); |
|
119 } |
|
120 else |
|
121 { |
|
122 iProcessor.SetDaemonAsProcess(EFalse); |
|
123 } |
|
124 iMessage.Complete( CThumbnailServerSession::ConvertSqlErrToE32Err( aReason )); |
|
125 ResetMessageData(); |
|
126 } |
|
127 |
|
128 iProcessor.TaskComplete( this ); |
|
129 } |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CThumbnailTask::Continue() |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void CThumbnailTask::Continue() |
|
137 { |
|
138 if ( iState != EComplete ) |
|
139 { |
|
140 iState = EIdle; |
|
141 } |
|
142 |
|
143 iProcessor.TaskComplete( this ); |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // CThumbnailTask::StartError() |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CThumbnailTask::StartError( TInt aError ) |
|
151 { |
|
152 // This is called if StartL() left. Complete this task with an error and |
|
153 // continue processing. |
|
154 TN_DEBUG3( "CThumbnailTask(0x%08x)::StartError(aError=%d)", this, aError ); |
|
155 Complete( aError ); |
|
156 } |
|
157 |
|
158 |
|
159 // --------------------------------------------------------------------------- |
|
160 // CThumbnailTask::ChangeTaskPriority() |
|
161 // Changes priority of the task. |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 void CThumbnailTask::ChangeTaskPriority( TInt aNewPriority ) |
|
165 { |
|
166 iPriority = aNewPriority; |
|
167 } |
|
168 |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CThumbnailTask::SetMessageData() |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CThumbnailTask::SetMessageData( const TThumbnailServerRequestId& |
|
175 aRequestId, const RMessage2& aMessage ) |
|
176 { |
|
177 iMessage = aMessage; |
|
178 iRequestId = aRequestId; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CThumbnailTask::SetMessageData() |
|
183 // --------------------------------------------------------------------------- |
|
184 // |
|
185 void CThumbnailTask::SetMessageData( const TThumbnailServerRequestId& |
|
186 aRequestId ) |
|
187 { |
|
188 iMessage = RMessage2(); |
|
189 iRequestId = aRequestId; |
|
190 } |
|
191 |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CThumbnailTask::ResetMessageData() |
|
195 // --------------------------------------------------------------------------- |
|
196 // |
|
197 void CThumbnailTask::ResetMessageData() |
|
198 { |
|
199 iMessage = RMessage2(); |
|
200 iRequestId = TThumbnailServerRequestId(); |
|
201 } |
|
202 |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CThumbnailTask::ResetMessageData() |
|
206 // Returns id of specific task. |
|
207 // --------------------------------------------------------------------------- |
|
208 // |
|
209 TThumbnailServerRequestId CThumbnailTask::RequestId()const |
|
210 { |
|
211 return iRequestId; |
|
212 } |
|
213 |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // CThumbnailTask::CancelMessage() |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 void CThumbnailTask::CancelMessage() |
|
220 { |
|
221 if ( iMessage.Handle()) |
|
222 { |
|
223 iMessage.Complete( KErrCancel ); |
|
224 ResetMessageData(); |
|
225 } |
|
226 } |
|
227 |
|
228 // End of file |