2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Updates applications and icons in Operator Tile.
19 // This file defines the API for hswidgetpublisher.dll
21 #ifndef __HSWIDGETPUBLISHER_H__
22 #define __HSWIDGETPUBLISHER_H__
33 class IHsDataObserver;
34 class HsWidgetPublisherImpl;
37 * Class allowing access to the Homescreen Publishing Api.
38 * Allows creation, update and deletion of widgets, as well as reception of
39 * information for the occuring events.
42 * class ObserverClass : public IHsDataObserver
44 * void handleEvent( std::string aWidgetName,
45 * IHsDataObserver::EEvent aEvent)
49 * void handleItemEvent( std::string aWidgetName,
50 * std::string aWidgetItemName,
51 * IHsDataObserver::EItemEvent aEvent)
56 * ObserverClass* dataObserver = new ObserverClass();
57 * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
58 * HsWidget& widget = publisher->createHsWidget(
59 * "templateName", "widgetName", "uniqueIdentifier" );
60 * // assuming count and values[] exists
63 * widget->setItem( "image", values[count] );
66 * hsPublisher->publishHsWidget( widget );
69 class HsWidgetPublisher
73 * Constructor of the HsWidgetPublisher. Creates an instance of the
74 * publisher, which is used to manage Widgets and Widget's Items.
75 * Please note that attempt of usage, with aDataObserver = NULL
79 * class ObserverClass : public IHsDataObserver
81 * void handleEvent( std::string aWidgetName,
82 * IHsDataObserver::EEvent aEvent)
86 * void handleItemEvent( std::string aWidgetName,
87 * std::string aWidgetItemName,
88 * IHsDataObserver::EItemEvent aEvent)
93 * ObserverClass* dataObserver = new ObserverClass();
94 * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
97 * Client should not completely rely on exceptions while creating
98 * the API. Except for exceptions thrown one should check if
99 * the memory was allocated properly.
102 * ObserverClass* dataObserver = new ObserverClass();
106 * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher(dataObserver);
109 * // do the operations on the API here
112 * catch (HsException& exception)
114 * int errReason = exception.getReason();
118 * @param aDataObserver Callback interface for handling actions.
119 * @exception HsPException
121 IMPORT_C HsWidgetPublisher( IHsDataObserver* aDataObserver );
124 * Destructor of the HsWidgetPublisher.
127 * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
128 * delete hsPublisher;
130 * @exception HsException
132 IMPORT_C ~HsWidgetPublisher();
135 * Method creates a new widget.
136 * Attempt to create already existing widget will cause exception
137 * with KErrAlreadyExists reason.
138 * Other exception reasons are possible and are caused by widget
142 * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
143 * HsWidget& widget = hsPublisher->createHsWidget(
144 * "templateName", "widgetName", "uniqueIdentifier" );
146 * @param aTemplateName Name of the Template.
147 * @param aWidgetName Name of the Widget
148 * @param aIdentifier Unique identification of the content.
149 * @return A widget is returned. If no such widget existed a newly
151 * @exception HsException Exception is thrown when with code
153 * when attempting to create a widget that already exists. Other cases
154 * when excpetion is thrown include problems with widget registration.
156 IMPORT_C HsWidget& createHsWidget( std::string aTemplateName,
157 std::string aWidgetName,
158 std::string aIdentifier );
161 * Method publishes the provided widget.
162 * Widget needs to be published in order for the content
163 * to be seen by the HS.
166 * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
167 * HsWidget& widget = hsPublisher->createHsWidget(
168 * "templateName", "widgetName", "uniqueIdentifier" );
169 * hsPublisher->publishHsWidget( widget );
171 * @param aWidget Reference to a widget object.
172 * @exception HsException
174 IMPORT_C void publishHsWidget( HsWidget& aWidget );
177 * Method removes a widget.
180 * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
181 * hsPublisher->createHsWidget(
182 * "templateName", "widgetName", "uniqueIdentifier" );
183 * publisher->removeHsWidget(
184 * "templateName", "widgetName", "uniqueIdentifier" );
186 * @param aTemplateName Name of the Template.
187 * @param aWidgetName Name of the Widget
188 * @param aIdentifier Unique identification of the content.
189 * @exception HsException
191 IMPORT_C void removeHsWidget( std::string aTemplateName,
192 std::string aWidgetName,
193 std::string aIdentifier );
196 * Obtains a Widget from Homescreen Publishing Api.
197 * Attempt of obtaining Widget that was not created cause exception
198 * with KErrNotFound rason.
202 * HsWidgetPublisher* hsPublisher = new HsWidgetPublisher( dataObserver );
203 * hsPublisher->createHsWidget(
204 * "templateName", "widgetName", "uniqueIdentifier" );
205 * HsWidget& widget = hsPublisher->getHsWidget(
206 * "templateName", "widgetName", "uniqueIdentifier" );
208 * @param aTemplateName Name of the Template.
209 * @param aWidgetName Name of the Widget
210 * @param aIdentifier Unique identification of the content.
211 * @return Error code.
212 * @exception HsException
214 IMPORT_C HsWidget& getHsWidget( std::string aTemplateName,
215 std::string aWidgetName,
216 std::string aIdentifier );
221 std::auto_ptr<HsWidgetPublisherImpl> mImpl;
226 #endif // __HSWIDGETPUBLISHER_H__