|
1 /* |
|
2 * Copyright (c) 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: Updates applications and icons in Operator Tile. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __HSWIDGETPUBLISHERIMPL_H__ |
|
20 #define __HSWIDGETPUBLISHERIMPL_H__ |
|
21 |
|
22 #include <liwservicehandler.h> |
|
23 #include <liwvariant.h> |
|
24 #include <liwgenericparam.h> |
|
25 #include <liwcommon.h> |
|
26 #include <vector> |
|
27 #include <map> |
|
28 #include <memory> |
|
29 #include <string> |
|
30 |
|
31 #include "hsdataobserver.h" |
|
32 |
|
33 namespace Hs { |
|
34 |
|
35 class HsWidget; |
|
36 |
|
37 typedef std::map<std::string, std::wstring> WidgetContentIdMapType; |
|
38 |
|
39 class HsWidgetPublisherImpl : |
|
40 public MLiwNotifyCallback |
|
41 { |
|
42 public://MLiwNotifyCallback |
|
43 |
|
44 /** |
|
45 * Handles notifications caused by an asynchronous Execute*CmdL call |
|
46 * or an event. |
|
47 * |
|
48 * @param aCmdId The service command associated to the event. |
|
49 * @param aEventId Occured event, see LiwCommon.hrh. |
|
50 * @param aEventParamList Event parameters, if any, as defined per |
|
51 * each event. |
|
52 * @param aInParamList Input parameters, if any, given in the |
|
53 * related HandleCommmandL. |
|
54 * @return Error code for the callback. |
|
55 */ |
|
56 virtual TInt HandleNotifyL( |
|
57 TInt aCmdId, |
|
58 TInt aEventId, |
|
59 CLiwGenericParamList& aEventParamList, |
|
60 const CLiwGenericParamList& aInParamList); |
|
61 |
|
62 public: |
|
63 /** |
|
64 */ |
|
65 HsWidgetPublisherImpl(); |
|
66 |
|
67 /** |
|
68 */ |
|
69 virtual ~HsWidgetPublisherImpl(); |
|
70 |
|
71 /** |
|
72 */ |
|
73 HsWidget& CreateWidget( std::string& aTemplateName, |
|
74 std::string& aWidgetName, |
|
75 std::string& aIdentifier, |
|
76 std::string& aDescription, |
|
77 std::string& aIconLocation ); |
|
78 |
|
79 /** |
|
80 */ |
|
81 void RemoveWidget( std::string& aTemplateName, |
|
82 std::string& aWidgetName, |
|
83 std::string& aIdentifier ); |
|
84 |
|
85 /** |
|
86 */ |
|
87 void SetDataObserver( IHsDataObserver* aDataObserver ); |
|
88 |
|
89 /** |
|
90 */ |
|
91 HsWidget& GetWidget( std::string& aTemplateName, |
|
92 std::string& aWidgetName, |
|
93 std::string& aIdentifier ); |
|
94 |
|
95 /** |
|
96 */ |
|
97 void PublishWidget( HsWidget& aWidget ); |
|
98 |
|
99 |
|
100 private: |
|
101 /** |
|
102 */ |
|
103 MLiwInterface* GetServiceInterfaceL(); |
|
104 |
|
105 /** |
|
106 */ |
|
107 void RegisterNotificationL( HsWidget& aWidget ); |
|
108 |
|
109 /** |
|
110 */ |
|
111 void UnegisterNotificationL(); |
|
112 |
|
113 /** |
|
114 */ |
|
115 void PublishWidgetActionsL( HsWidget& aWidget ); |
|
116 |
|
117 /** |
|
118 */ |
|
119 void PublishWidgetDataL( HsWidget& aWidget ); |
|
120 |
|
121 /** |
|
122 */ |
|
123 void RemoveWidgetL( HsWidget& aWidget ); |
|
124 |
|
125 /** |
|
126 */ |
|
127 void RemoveFromCpsL( CLiwDefaultMap* aCpDataMap, const TDesC& aType ); |
|
128 |
|
129 /** |
|
130 */ |
|
131 void TranslateObserverAction( const TDesC8& aActionDes, |
|
132 IHsDataObserver::EEvent& aAction ); |
|
133 |
|
134 /** |
|
135 */ |
|
136 HsWidget* GetWidgetL( const CLiwMap* aMap ); |
|
137 |
|
138 /** |
|
139 */ |
|
140 int HandleWidgetActionL( const TDesC8& aActionDes, |
|
141 HsWidget& aWidget ); |
|
142 |
|
143 /** |
|
144 */ |
|
145 int HandleWidgetItemActionL( const TDesC8& aActionDes, |
|
146 HsWidget& aWidget ); |
|
147 |
|
148 /** |
|
149 */ |
|
150 bool CheckIfWidgetExist( std::string& aTemplateName, |
|
151 std::string& aWidgetName, |
|
152 std::string& aIdentifier, |
|
153 TBool aAdjustToIdentifier ); |
|
154 |
|
155 /** |
|
156 */ |
|
157 std::string ToStringL( const TDesC& aText ); |
|
158 |
|
159 /** |
|
160 */ |
|
161 std::wstring ToWideStringL( const TDesC& aText ) const; |
|
162 |
|
163 /** |
|
164 */ |
|
165 void InsertWidgetIdentifiersL( HsWidget& aWidget, |
|
166 CLiwDefaultMap* aDataMap ); |
|
167 |
|
168 /** |
|
169 */ |
|
170 void InsertWidgetDataIdentifiersL( HsWidget& aWidget, |
|
171 CLiwDefaultMap* aDataMap ); |
|
172 |
|
173 /** |
|
174 */ |
|
175 void InsertWidgetInfoL( HsWidget& aWidget, |
|
176 CLiwDefaultMap* aDataMap ); |
|
177 |
|
178 /** |
|
179 */ |
|
180 void InsertWidgetItemsL( HsWidget& aWidget, |
|
181 CLiwDefaultMap* aDataMap ); |
|
182 |
|
183 /** |
|
184 */ |
|
185 TInt ObtainErrorCode( const CLiwGenericParamList& aOutParamList ); |
|
186 |
|
187 /** |
|
188 */ |
|
189 TInt TranslateServiceError( TInt32 aServiceErrorCode ); |
|
190 |
|
191 /** |
|
192 */ |
|
193 void InsertItemsTriggersL( HsWidget& aWidget, |
|
194 CLiwDefaultMap* aTriggerMap ); |
|
195 |
|
196 /** |
|
197 */ |
|
198 void InsertWidgetACLL( CLiwDefaultMap* aDataMap ); |
|
199 |
|
200 /** |
|
201 * Returns publisher name that should be used with a certain widget |
|
202 * when registering the widget, writing/deleting widget data or |
|
203 * requesting event notification. |
|
204 * |
|
205 * @param aWidget A valid widget object. |
|
206 * @return Publisher name. |
|
207 */ |
|
208 std::string GetPublisherNameL( HsWidget& aWidget ); |
|
209 |
|
210 /** |
|
211 * Parses publisher name in order to determine widget identifier. |
|
212 * Will leave with KErrNotFound if publisher name is invalid. |
|
213 * |
|
214 * @param aPublisherName Publisher name |
|
215 * @return Widget identifier. |
|
216 */ |
|
217 std::string GetWidgetIdentifierFromPublisherNameL( |
|
218 const TDesC& aPublisherName ); |
|
219 |
|
220 /** |
|
221 * Wraps CnvUtfConverter::ConvertToUnicodeFromUtf8. |
|
222 * |
|
223 * @param aSrcString 8-bit utf8-encoded string. |
|
224 * @return Converted unicode-encoded (16 bit) string. |
|
225 */ |
|
226 HBufC* Utf8ToUnicodeLC( const TDesC8& aSrcString ) const; |
|
227 |
|
228 /** |
|
229 * A convenient std::string to HBufC converter. |
|
230 * |
|
231 * @param aSrcString utf8-encoded std::string. |
|
232 * @return Converted unicode-encoded (16 bit) string. |
|
233 */ |
|
234 HBufC* StdStringToUnicodeLC( const std::string& aSrcString ) const; |
|
235 |
|
236 private: |
|
237 |
|
238 std::vector<HsWidget*> mWidgets; |
|
239 WidgetContentIdMapType mWidgetContentIds; |
|
240 CLiwServiceHandler* mServiceHandler; |
|
241 MLiwInterface* mServiceInterface; |
|
242 IHsDataObserver* mHsDataObserver; |
|
243 TInt32 iWidgetUid; |
|
244 }; |
|
245 } |
|
246 |
|
247 #endif /*__HSWIDGETPUBLISHERIMPL_H__*/ |