40 * Plugin factory class for Active idle framework. |
41 * Plugin factory class for Active idle framework. |
41 * |
42 * |
42 * @lib aifw |
43 * @lib aifw |
43 * @since S60 5.2 |
44 * @since S60 5.2 |
44 */ |
45 */ |
45 NONSHARABLE_CLASS( CAiPluginFactory ) : public CBase |
46 NONSHARABLE_CLASS( CAiPluginFactory ) : public CTimer |
46 { |
47 { |
47 public: |
48 public: |
48 // Constructors and destructor |
49 // Constructors and destructor |
49 |
50 |
50 /** |
51 /** |
51 * Two-phased constructor. |
52 * Two-phased constructor. |
52 */ |
53 */ |
53 static CAiPluginFactory* NewL( CAiUiControllerManager& aManager ); |
54 static CAiPluginFactory* NewL( CAiUiControllerManager& aManager ); |
54 |
55 |
|
56 /** |
|
57 * 2nd phase constructor |
|
58 */ |
|
59 void ConstructL(); |
|
60 |
55 /** |
61 /** |
56 * Destructor |
62 * Destructor |
57 */ |
63 */ |
58 ~CAiPluginFactory(); |
64 ~CAiPluginFactory(); |
59 |
65 |
60 public: |
66 public: |
61 // new functions |
67 // new functions |
62 |
68 |
63 /** |
69 /** |
64 * Create plugin |
70 * Lists KInterfaceUidHsContentPlugin ECom implementations |
65 * |
71 * |
66 * @since S60 5.2 |
72 * @since S60 5.2 |
67 * @param aPublisherInfo plugin to create. Factory keeps plugin's ownership. |
73 */ |
68 * @return KErrNone if plugin is created succesfully, otherwise system wide error code. |
74 void ListImplementationsL(); |
69 */ |
75 |
70 TInt CreatePlugin( |
76 /** |
71 const THsPublisherInfo& aPublisherInfo ); |
77 * Schedules plugin loading |
72 |
78 * |
|
79 * @since S60 5.2 |
|
80 * @param aInfo Plugin to load |
|
81 */ |
|
82 void LoadPlugin( const TAiFwPublisherInfo& aInfo ); |
|
83 |
|
84 /** |
|
85 * Schedules plugin destroyal |
|
86 * |
|
87 * @since S60 5.2 |
|
88 * @param aInfo Plugin to destroy |
|
89 */ |
|
90 void DestroyPlugin( const TAiFwPublisherInfo& aInfo ); |
|
91 |
73 /** |
92 /** |
74 * Destroy plugin |
93 * Destroy plugin |
75 * |
94 * |
76 * @since S60 5.2 |
95 * @since S60 5.2 |
77 * @param aPublisherInfo plugin to destroy. |
96 * @param aUid Implementation UID of a plugin to destroy. |
78 */ |
97 */ |
79 void DestroyPlugin( |
98 void DestroyPlugin( |
80 const THsPublisherInfo& aPublisherInfo ); |
99 const TUid& aUid ); |
81 |
100 |
82 /** |
101 /** |
83 * Destroy plugin |
102 * Destroys all plugins during system shutdown |
84 * |
103 * |
85 * @since S60 5.2 |
104 * @since S60 5.2 |
86 * @param aUid Implementation UID of a plugin to destroy. |
105 */ |
87 */ |
106 void DestroyAllPlugins(); |
88 void DestroyPlugin( |
107 |
89 const TUid& aUid ); |
108 /** |
90 |
109 * Flushes cps command buffer |
|
110 * |
|
111 * @since S60 5.2 |
|
112 */ |
|
113 void FlushCommandBuffer(); |
|
114 |
91 /** |
115 /** |
92 * Finds plugin by publisher info. |
116 * Finds plugin by publisher info. |
93 * |
117 * |
94 * @since S60 5.2 |
118 * @since S60 5.2 |
95 * @param aInfo publisher info. |
119 * @param aInfo publisher info. |
115 * @return Pointer to plugin, NULL if not found. Factory keeps plugin's ownership. |
139 * @return Pointer to plugin, NULL if not found. Factory keeps plugin's ownership. |
116 */ |
140 */ |
117 CHsContentPublisher* PluginByName( const TDesC& aName ) const; |
141 CHsContentPublisher* PluginByName( const TDesC& aName ) const; |
118 |
142 |
119 /** |
143 /** |
120 * Sets cps command buffer |
144 * Sets state manager |
121 * |
145 * |
122 * @since S60 5.2 |
146 * @since S60 5.2 |
123 * @param aCommanddBuffer Command buffer |
147 * @param aStateManager State Manager |
124 */ |
148 */ |
125 void SetCommandBuffer( CAiCpsCommandBuffer* aCommanddBuffer ); |
149 void SetStateManager( CAiStateManager* aStateManager ); |
|
150 |
|
151 /** |
|
152 * Gets all plugins from factory |
|
153 * |
|
154 * @since S60 5.2 |
|
155 * @return Array of plugins |
|
156 */ |
|
157 RPointerArray< CHsContentPublisher >& Publishers() const; |
|
158 |
|
159 private: |
|
160 // from CTimer |
|
161 |
|
162 /** |
|
163 * @see CTimer |
|
164 */ |
|
165 void RunL(); |
|
166 |
|
167 /** |
|
168 * @see CTimer |
|
169 */ |
|
170 void DoCancel(); |
126 |
171 |
127 private: |
172 private: |
128 // private constructors |
173 // private constructors |
129 |
|
130 /** |
|
131 * Leaving constructor |
|
132 */ |
|
133 void ConstructL(); |
|
134 |
174 |
135 /** |
175 /** |
136 * C++ default constructor |
176 * C++ default constructor |
137 */ |
177 */ |
138 CAiPluginFactory( CAiUiControllerManager& aManager ); |
178 CAiPluginFactory( CAiUiControllerManager& aManager ); |
139 |
179 |
140 private: |
180 private: |
141 // new functions |
181 // new functions |
142 |
182 |
143 void CreatePluginL( |
183 TInt DoCreatePlugin( |
144 const THsPublisherInfo& aPublisherInfo ); |
184 const TAiFwPublisherInfo& aPublisherInfo ); |
145 |
185 |
146 void SubscribeContentObserversL( |
186 void DoDestroyPlugin( |
|
187 const TAiFwPublisherInfo& aPublisherInfo ); |
|
188 |
|
189 void DoCreatePluginL( |
|
190 const TAiFwPublisherInfo& aPublisherInfo ); |
|
191 |
|
192 void SubscribePluginL( |
147 CHsContentPublisher& aContentPublisher, |
193 CHsContentPublisher& aContentPublisher, |
148 const THsPublisherInfo& aPublisherInfo ); |
194 const THsPublisherInfo& aPublisherInfo ); |
149 |
195 |
150 void ConfigurePluginL( |
196 void ConfigurePluginL( |
151 CHsContentPublisher& aContentPublisher, |
197 CHsContentPublisher& aContentPublisher, |
152 const THsPublisherInfo& aPublisherInfo ); |
198 const THsPublisherInfo& aPublisherInfo ); |
153 |
199 |
154 RPointerArray< CHsContentPublisher >& Publishers() const; |
200 void HandleQueueChanged(); |
155 |
201 |
|
202 static TInt ProcessQueue( TAny* aAny ); |
|
203 |
156 private: |
204 private: |
157 // data |
205 // data |
158 |
206 |
159 /** UI Controller Manager, Not owned */ |
207 /** UI Controller Manager, Not owned */ |
160 CAiUiControllerManager& iUiControllerManager; |
208 CAiUiControllerManager& iUiControllerManager; |
161 /** Cps command buffer, Not owned */ |
209 /** State Manager, Not owned */ |
|
210 CAiStateManager* iStateManager; |
|
211 /** Cps command buffer, Owned */ |
162 CAiCpsCommandBuffer* iCommandBuffer; |
212 CAiCpsCommandBuffer* iCommandBuffer; |
|
213 /** Queue starter, Owned */ |
|
214 CPeriodic* iStarter; |
163 /** Array of loaded data plugins, Owned */ |
215 /** Array of loaded data plugins, Owned */ |
164 mutable RPointerArray< CHsContentPublisher > iPublishers; |
216 mutable RPointerArray< CHsContentPublisher > iPublishers; |
165 /** Ecom implementation info, Owned */ |
217 /** Ecom implementation info, Owned */ |
166 RImplInfoPtrArray iEComPlugins; |
218 RImplInfoPtrArray iEComPlugins; |
|
219 /** Load queue, Owned */ |
|
220 RArray< TAiFwPublisherInfo > iLoadQueue; |
|
221 /** Destroy queue, Owned */ |
|
222 RArray< TAiFwPublisherInfo > iDestroyQueue; |
|
223 /** Flag to determine wheter flush is allowed */ |
|
224 TBool iAllowFlush; |
167 |
225 |
168 private: |
226 private: |
169 // friend classes |
227 // friend classes |
170 friend class CAiStateManager; |
|
171 |
228 |
172 #ifdef _AIFW_UNIT_TEST |
229 #ifdef _AIFW_UNIT_TEST |
173 friend class UT_AiPluginFactory; |
230 friend class UT_AiPluginFactory; |
174 #endif |
231 #endif |
175 }; |
232 }; |