|
1 /* |
|
2 * Copyright (c) 2006-2008 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: CCFActionPlugIn class declaration. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_CFACTIONPLUGIN_H |
|
21 #define C_CFACTIONPLUGIN_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <badesca.h> |
|
25 |
|
26 #include <CFActionPlugInConst.hrh> |
|
27 |
|
28 class CCFActionPlugInImpl; |
|
29 class CCFActionIndication; |
|
30 |
|
31 /** |
|
32 * Action plug in Ecom interface Uid |
|
33 */ |
|
34 const TUid KActionPluginUid = {KActionPluginInterfaceUid}; |
|
35 |
|
36 /** |
|
37 * Base class for all Action plugins. |
|
38 * |
|
39 * For every action plug-in implementation there will be also an action |
|
40 * execution thread. |
|
41 * Action execution thread uses shared heap with Context Framework |
|
42 * Server main thread. Cleanup stack and active scheduler will be created |
|
43 * for Action execution thread. |
|
44 * |
|
45 * Actions are exeucted in three phase: |
|
46 * - PrepareExecutionL |
|
47 * - ExecuteL (Mandatory) |
|
48 * - FinishedExecution |
|
49 * Implementation needs to return correct TExecutionTime from ExecuteL if |
|
50 * the action being performed is asynchronous an will not be completed when |
|
51 * ExecuteL returns. |
|
52 * |
|
53 * NOTE: |
|
54 * It is crucial to only return ENone from ExecuteL if |
|
55 * the action is really completed. Any active objects, timers or asynchronous |
|
56 * requests won't be run since the action execution thread starts to wait |
|
57 * in semaphore for a new action signalation when ExecuteL returns with ENone. |
|
58 * In other cases action execution thread starts to wait for action to be completed. |
|
59 * When the action is completed call AsyncExecutionCompleted to stop the wait. |
|
60 * |
|
61 * @lib CFActivatorEngine.lib |
|
62 * @since S60 5.0 |
|
63 */ |
|
64 class CCFActionPlugIn : public CBase |
|
65 { |
|
66 public: |
|
67 |
|
68 // Execution time. |
|
69 // Execution time defines aprroximately how long |
|
70 // it takes to complete async request. Active scheduler |
|
71 // will wait the specified amount of time before it will be |
|
72 // stopped automatically. |
|
73 enum TExecutionTime |
|
74 { |
|
75 // ENone = Not async, will return right away |
|
76 ENone, |
|
77 |
|
78 // ESmall = 5 seconds reserved |
|
79 ESmall, |
|
80 |
|
81 // EMedium = 15 seconds reserved |
|
82 EMedium, |
|
83 |
|
84 // ELong = 30 seconds reserved |
|
85 ELong |
|
86 }; |
|
87 |
|
88 public: |
|
89 |
|
90 /** |
|
91 * Symbian two phased contrstuctors. |
|
92 * |
|
93 * @since S60 5.0 |
|
94 * @param aImplementationUid Implementation to create. |
|
95 * @return CCFActionPlugIn* |
|
96 */ |
|
97 IMPORT_C static CCFActionPlugIn* NewL( const TUid& aImplementationUid ); |
|
98 IMPORT_C static CCFActionPlugIn* NewLC( const TUid& aImplementationUid ); |
|
99 |
|
100 /** |
|
101 * Destructor. |
|
102 */ |
|
103 IMPORT_C ~CCFActionPlugIn(); |
|
104 |
|
105 public: // New methods |
|
106 |
|
107 /** |
|
108 * Notifies the base implementation that async request has been |
|
109 * completed. All errors will be ignored. |
|
110 * If the operation executed is not async then this method |
|
111 * is not needed to be called. |
|
112 * Note: |
|
113 * - If this method is not called scheduler is blocked maximum of |
|
114 * 30 seconds before it will be automatically stopped. |
|
115 * |
|
116 * @since S60 5.0 |
|
117 * @param None |
|
118 * @return None |
|
119 */ |
|
120 IMPORT_C void AsyncExecutionCompleted(); |
|
121 |
|
122 /** |
|
123 * Prepares execution. |
|
124 * If PrepareExecutionL leaves, ExecuteL and FinishedExecution won't |
|
125 * be called. |
|
126 * Default implementation is empty. |
|
127 * |
|
128 * @since S60 5.0 |
|
129 * @param None |
|
130 * @return None |
|
131 */ |
|
132 IMPORT_C virtual void PrepareExecutionL(); |
|
133 |
|
134 /** |
|
135 * Finishes execution. |
|
136 * Default implementation is empty. |
|
137 * |
|
138 * @since S60 5.0 |
|
139 * @param None |
|
140 * @return None |
|
141 */ |
|
142 IMPORT_C virtual void FinishedExecution(); |
|
143 |
|
144 /** |
|
145 * Returns an extension interface. |
|
146 * The extension interface is mapped with the extension UID. |
|
147 * |
|
148 * The default implemementation returns NULL. |
|
149 * |
|
150 * @since S60 5.0 |
|
151 * @param aExtensionUid: The identifier of the extension. |
|
152 * @return Pointer to the extension. |
|
153 */ |
|
154 IMPORT_C virtual TAny* Extension( const TUid& aExtensionUid ) const; |
|
155 |
|
156 public: // Implementation specific |
|
157 |
|
158 /** |
|
159 * Plug-in is allowed to reserve memory. |
|
160 * It is nessecary that no memory is allocated before |
|
161 * InitializeL is called. |
|
162 * |
|
163 * @since S60 5.0 |
|
164 * @param None |
|
165 * @return None |
|
166 */ |
|
167 virtual void InitializeL() = 0; |
|
168 |
|
169 /** |
|
170 * Executes action. |
|
171 * If ExecuteL leaves, FinishedExecution won't be called. |
|
172 * Note: |
|
173 * - Do not delete aActionIndication. aActionIndication will be deleted |
|
174 * automatically after the execution is ended. |
|
175 * |
|
176 * @since S60 5.0 |
|
177 * @param aActionIndication Action indication. |
|
178 * @return None |
|
179 */ |
|
180 virtual TExecutionTime ExecuteL( |
|
181 CCFActionIndication* aActionIndication ) = 0; |
|
182 |
|
183 /** |
|
184 * Get actions the plugin can perform. |
|
185 * Activator Engine calls this when it wants to know which |
|
186 * actions the module supports. |
|
187 * |
|
188 * @since S60 5.0 |
|
189 * @param aActionList Supported actions by the plug-in. |
|
190 * @return None |
|
191 */ |
|
192 virtual void GetActionsL( CDesCArray& aActionList ) const = 0; |
|
193 |
|
194 /** |
|
195 * Returns the security policy assigned with the plugin. |
|
196 * |
|
197 * @since S60 5.0 |
|
198 * @param None |
|
199 * @return const TSecurityPolicy& |
|
200 */ |
|
201 virtual const TSecurityPolicy& SecurityPolicy() const = 0; |
|
202 |
|
203 protected: |
|
204 |
|
205 // C++ constrcutor |
|
206 IMPORT_C CCFActionPlugIn(); |
|
207 |
|
208 private: // New methods |
|
209 |
|
210 // Friend classes |
|
211 friend class CCFActivatorEngineActionPluginManager; |
|
212 |
|
213 // Appends new action in the queue |
|
214 // Returns ETrue if action thread is elligble to run |
|
215 TBool AppendQueue( CCFActionIndication* aAction ); |
|
216 |
|
217 // Executes action |
|
218 void ExecuteAction(); |
|
219 |
|
220 private: |
|
221 |
|
222 // Second phase constructor |
|
223 void ConstructL(); |
|
224 |
|
225 private: |
|
226 |
|
227 /** Destructor Id */ |
|
228 TUid iDtorKey; |
|
229 |
|
230 /** Plug-in logic */ |
|
231 CCFActionPlugInImpl* iImpl; |
|
232 |
|
233 /** Reserved */ |
|
234 TAny* iReserved1; |
|
235 TAny* iReserved2; |
|
236 TAny* iReserved3; |
|
237 }; |
|
238 |
|
239 #endif |