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: Processor object for running queued tasks |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef THUMBNAILTASKPROCESSOR_H |
|
20 #define THUMBNAILTASKPROCESSOR_H |
|
21 |
|
22 #include "thumbnailmanager.h" // TThumbnailFlags |
|
23 #include "thumbnailmanagerconstants.h" // TThumbnailServerRequestId |
|
24 #include "thumbnailprovider.h" |
|
25 #include <e32property.h> |
|
26 |
|
27 |
|
28 class CThumbnailTask; |
|
29 |
|
30 /** |
|
31 * Processor object for running queued tasks. |
|
32 * |
|
33 * @since S60 v5.0 |
|
34 */ |
|
35 class CThumbnailTaskProcessor: public CActive |
|
36 { |
|
37 public: |
|
38 |
|
39 /** |
|
40 * Two-phased constructor. |
|
41 * |
|
42 * @since S60 v5.0 |
|
43 * @return Instance of CThumbnailTaskProcessor. |
|
44 */ |
|
45 static CThumbnailTaskProcessor* NewL(); |
|
46 |
|
47 /** |
|
48 * Destructor |
|
49 * |
|
50 * @since S60 v5.0 |
|
51 */ |
|
52 virtual ~CThumbnailTaskProcessor(); |
|
53 |
|
54 /** |
|
55 * Adds new task to the task queue. |
|
56 * |
|
57 * @since S60 v5.0 |
|
58 * @param aTask Task to be added to the queue. |
|
59 */ |
|
60 void AddTaskL( CThumbnailTask* aTask ); |
|
61 |
|
62 /** |
|
63 * Removes specific task from the queue. |
|
64 * |
|
65 * @since S60 v5.0 |
|
66 * @param aRequestId ID of the task to be removed. |
|
67 */ |
|
68 TInt RemoveTask( const TThumbnailServerRequestId& aRequestId ); |
|
69 |
|
70 /** |
|
71 * Removes specific task from the queue. |
|
72 * |
|
73 * @since S60 v5.0 |
|
74 * @param aSession Identifier for task to be removed. |
|
75 */ |
|
76 void RemoveTasks( CThumbnailServerSession* aSession ); |
|
77 |
|
78 /** |
|
79 * Removes all tasks from the queue. |
|
80 * |
|
81 * @since S60 v5.0 |
|
82 */ |
|
83 |
|
84 void RemoveAllTasks(); |
|
85 |
|
86 /** |
|
87 * Changes priority of a task. |
|
88 * |
|
89 * @since S60 v5.0 |
|
90 * @param aRequestId ID of the task. |
|
91 * @param aNewPriority New priority to be assigned to the task. |
|
92 */ |
|
93 TInt ChangeTaskPriority( const TThumbnailServerRequestId& aRequestId, const |
|
94 TInt aNewPriority ); |
|
95 |
|
96 /** |
|
97 * Marks task to completed. |
|
98 * |
|
99 * @since S60 v5.0 |
|
100 * @param aTask Completed task. |
|
101 */ |
|
102 void TaskComplete( CThumbnailTask* aTask ); |
|
103 |
|
104 void SetDaemonAsProcess(TBool aValue); |
|
105 |
|
106 protected: |
|
107 // from base class CActive |
|
108 |
|
109 /** |
|
110 * Handles an active object's request completion event. |
|
111 * |
|
112 * @since S60 v5.0 |
|
113 */ |
|
114 void RunL(); |
|
115 |
|
116 /** |
|
117 * Implements cancellation of an outstanding request. |
|
118 * |
|
119 * @since S60 v5.0 |
|
120 */ |
|
121 void DoCancel(); |
|
122 |
|
123 /** |
|
124 * Handles a leave occurring in the request completion event handler |
|
125 * RunL(). |
|
126 * |
|
127 * @since S60 v5.0 |
|
128 * @return Error code. |
|
129 */ |
|
130 TInt RunError( TInt aError ); |
|
131 |
|
132 private: |
|
133 |
|
134 /** |
|
135 * C++ default constructor |
|
136 * |
|
137 * @since S60 v5.0 |
|
138 * @return Instance of CThumbnailTaskProcessor. |
|
139 */ |
|
140 CThumbnailTaskProcessor(); |
|
141 |
|
142 /** |
|
143 * Symbian 2nd phase constructor can leave. |
|
144 * |
|
145 * @since S60 v5.0 |
|
146 */ |
|
147 void ConstructL(); |
|
148 |
|
149 /** |
|
150 * Callback for harvesting complete timer |
|
151 * |
|
152 * @since S60 v5.0 |
|
153 */ |
|
154 static TInt PeriodicTimerCallBack(TAny* aAny); |
|
155 |
|
156 private: |
|
157 // data |
|
158 |
|
159 /** |
|
160 * Task queue. Task objects are own by this class. |
|
161 * Own. |
|
162 */ |
|
163 RPointerArray < CThumbnailTask > iTasks; |
|
164 |
|
165 /** |
|
166 * Current active task. Not own. |
|
167 */ |
|
168 CThumbnailTask* iActiveTask; |
|
169 |
|
170 /** |
|
171 * PS used to notify Daemon when server is idle |
|
172 */ |
|
173 RProperty iProperty; |
|
174 /** |
|
175 * Holds current idle value |
|
176 */ |
|
177 TBool iIdle; |
|
178 |
|
179 CPeriodic* iPeriodicTimer; |
|
180 |
|
181 TBool iTimerActive; |
|
182 |
|
183 TBool iIsDaemonAsProcess; |
|
184 }; |
|
185 |
|
186 #endif // THUMBNAILTASKPROCESSOR_H |
|