idlefw/plugins/wrtdataplugin/inc/wrtdataplugin.h
changeset 0 79c6a41cd166
child 1 844b978f8d5e
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Plug-in main class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef WRTDATAPLUGIN_H
       
    20 #define WRTDATAPLUGIN_H
       
    21 
       
    22 #include <aicontentpublisher.h>
       
    23 #include <aipropertyextension.h>
       
    24 #include <aicontentmodel.h>
       
    25 #include <aieventhandlerextension.h>
       
    26 
       
    27 class MAiContentObserver;
       
    28 class MAiContentItemIterator;
       
    29 class MAiPSPropertyObserver;
       
    30 class CWrtData;
       
    31 class CDesC16Array;
       
    32 class CGulIcon;
       
    33 
       
    34 enum TContentItem
       
    35 	{
       
    36 	EImage1,
       
    37 	EText1
       
    38 	};
       
    39 /**
       
    40  *  @ingroup group_wrtdataplugin
       
    41  *
       
    42  *  Plug-in main class
       
    43  *
       
    44  *  @since S60 v3.2
       
    45  */
       
    46 class CWrtDataPlugin : public CAiContentPublisher,
       
    47                      	public MAiPropertyExtension,
       
    48                      	public MAiEventHandlerExtension
       
    49                     
       
    50     {
       
    51     
       
    52 public :
       
    53 	 /**
       
    54 	 * Plugin's network state.
       
    55 	 */
       
    56 	enum TPluginNetworkStatus 
       
    57 		{
       
    58 		EUnknown, 
       
    59 		EOffline,
       
    60 		EOnline
       
    61 		};
       
    62 	
       
    63 	/**
       
    64 	 * Plugin's state.
       
    65 	 */
       
    66 	enum TPluginStates
       
    67 		{
       
    68 		ENone,
       
    69 		EResume,
       
    70 		ESuspend,
       
    71 		EInActive,
       
    72 		};
       
    73 public:
       
    74 
       
    75     /**
       
    76     * Part of the two phased constuction
       
    77     *
       
    78     * @param none
       
    79     * @return none
       
    80     */
       
    81     static CWrtDataPlugin* NewL();
       
    82     
       
    83     /**
       
    84     * Destructor
       
    85     *
       
    86     * @param none
       
    87     * @return none
       
    88     */
       
    89     ~CWrtDataPlugin();
       
    90 
       
    91 private:
       
    92     
       
    93     /**
       
    94     * Constructor
       
    95     *
       
    96     * @param none
       
    97     * @return none
       
    98     */
       
    99     CWrtDataPlugin();
       
   100     
       
   101     /**
       
   102     * Publishes widget's texts and images
       
   103     *
       
   104     * @param void
       
   105     * @return void
       
   106     */
       
   107     void PublishL();
       
   108 	
       
   109     /**
       
   110     * Part of the two phased construction
       
   111     *
       
   112     * @param void
       
   113     * @return void
       
   114     */
       
   115     void ConstructL();
       
   116 
       
   117     /**
       
   118     * Resume the plug-in.
       
   119     *
       
   120     * @param aReason reason for state change, see TAiTransitionChange.
       
   121     * @return void
       
   122     */    
       
   123     void DoResumeL(TAiTransitionReason aReason);
       
   124     
       
   125 public: // from base class CAiContentPublisher
       
   126     
       
   127     /**
       
   128     * From CAiContentPublisher
       
   129     * The method is called by the framework to request the plug-in free all
       
   130     * memory and CPU resources and close all its open files, e.g. the plug-in 
       
   131     * should unload its engines due backup operation. The method transits the 
       
   132     * plug-in to "Idle" state.
       
   133     *
       
   134     * @param aReason reason for state change, see TAiTransitionChange.
       
   135     * @return void
       
   136     */
       
   137     void Stop( TAiTransitionReason aReason );
       
   138 
       
   139     /**
       
   140     * From CAiContentPublisher
       
   141     * The method is called by the framework to instruct plug-in that it is
       
   142     * allowed to consume CPU resources, e.g plug-in is able to run timers,
       
   143     * perform asynchronous operations, etc. The method transits the plug-in
       
   144     * to "Alive" state.
       
   145     *
       
   146     * @param aReason reason for state change, see TAiTransitionChange.
       
   147     * @return void
       
   148     */
       
   149     void Resume( TAiTransitionReason aReason );
       
   150 
       
   151     /**
       
   152     * From CAiContentPublisher
       
   153     * The method is called by the framework to instruct plug-in that it is
       
   154     * not allowed to consume CPU resources, e.g plug-in MUST stop each
       
   155     * timers, cancel outstanding asynchronous operations, etc. The method
       
   156     * transits the plug-in to "Suspendend" state.
       
   157     *
       
   158     * @param aReason reason for state change, see TAiTransitionChange.
       
   159     * @return void
       
   160     */
       
   161     void Suspend( TAiTransitionReason aReason );
       
   162 
       
   163     /**
       
   164     * From CAiContentPublisher
       
   165     * Adds the content observer / subscriber to plug-in. The plug-in MUST
       
   166     * maintain a registry of subscribers and send notification to all them
       
   167     * whenever the plug-in changes state or new content available.
       
   168     *
       
   169     * @param aObserver content observer to register.
       
   170     * @return void
       
   171     */
       
   172     void SubscribeL( MAiContentObserver& aObserver );
       
   173     
       
   174     /**
       
   175     * From CAiContentPublisher
       
   176     * Configures the plug-in.
       
   177     * Plug-ins take ownership of the settings array, so it must either
       
   178     * store it in a member or free it. Framework has put the array in cleanup
       
   179     * stack so the plugin shouldn't do that.
       
   180     * If this leaves, the plug-in will be destroyed by AI FW.
       
   181     * Plug-in must support LaunchByValue-event even if normal shortcuts don't
       
   182     * work. The only allowed serious enough leave is KErrNotFound from CenRep.
       
   183     *
       
   184     * @param aSettings setting items defined in the UI definition.
       
   185     * @return void
       
   186     */
       
   187     void ConfigureL( RAiSettingsItemArray& aSettings );
       
   188     
       
   189     /**
       
   190     * From CAiContentPublisher
       
   191     * Returns interface extension. In Series 60 3.1 only event & property
       
   192     * extensions are supported. See MAiEventExtension & MAiPropertyExtension
       
   193     * interfaces.
       
   194     *
       
   195     * @param  aUid - UID of the extension interface to access.
       
   196     * @return the extension interface. Actual type depends on the passed aUid 
       
   197     *         argument.
       
   198     */
       
   199     TAny* Extension( TUid aUid );  
       
   200 
       
   201 // from base class MAiPropertyExtension
       
   202 
       
   203     /**
       
   204     * From MAiPropertyExtension.
       
   205     * Read property of publisher plug-in.
       
   206     *
       
   207     * @param aProperty - identification of property.
       
   208     * @return pointer to property value.
       
   209     */
       
   210     TAny* GetPropertyL( TInt aProperty );
       
   211 
       
   212     /**
       
   213     * From MAiPropertyExtension.
       
   214     * Write property value.
       
   215     *
       
   216     * @param aProperty - identification of property.
       
   217     * @param aValue - contains pointer to property value.
       
   218     */
       
   219     void SetPropertyL( TInt aProperty, TAny* aValue );
       
   220   
       
   221  // from base class MAiEventHandlerExtension
       
   222    
       
   223      /**
       
   224      * From MAiEventHandlerExtension
       
   225      * Invoked by the framework when plug-in must handle an event.
       
   226      * @param aEvent - unique identifier of event from plug-in content model.
       
   227      * @param aParam - parameters associated with event. Each UI Definition
       
   228      *        declares events in the format: <event name>(<event params>),
       
   229      *        where <event name> is mapped by the framework to unique
       
   230      *        identifier supplied in aEvent, <event params> are provided to
       
   231      *        plug-in as-is in the descriptor.
       
   232      * @since S60 3.2
       
   233      */
       
   234      void HandleEvent(TInt aEvent, const TDesC& aParam);
       
   235     
       
   236      /**
       
   237      * From MAiEventHandlerExtension
       
   238      * Invoked by the framework when plug-in must handle an event.
       
   239      *
       
   240      * @param aEventName - name of the event from plug-in content model.
       
   241      * @param aParam - parameters associated with event. Each UI Definition
       
   242      *        declares events in the format: <event name>(<event params>),
       
   243      *        where  <event name> mapping to unique identifier supplied by event 
       
   244      *        is failed by the frame work then the  <event name> and  
       
   245      *        <event params>  are provided to plug-in as-is in the descriptor.
       
   246      */
       
   247      void HandleEvent(const TDesC& aEventName, const TDesC& aParam);
       
   248 
       
   249     /**
       
   250  	* Invoked by the framework for querying if plugin has menu item
       
   251  	*
       
   252  	* @param aMenuItem  menu item name.
       
   253  	* @return ETrue if plugin has specific menu item, EFalse otherwise 
       
   254 	*/
       
   255     TBool HasMenuItem(const TDesC16& aMenuItem);
       
   256      
       
   257 public :
       
   258 
       
   259 	/**
       
   260 	* Gets the id of a content  
       
   261 	*
       
   262 	* @param aObjectId image or text id
       
   263 	* @return id of the content
       
   264 	*/
       
   265 	TInt GetIdL(TDesC16& aObjectId);
       
   266 	
       
   267     /**
       
   268     * Gets the type of a specific content
       
   269     *
       
   270     * @param aObjectId image or text id
       
   271     * @param aType type
       
   272     * @return void
       
   273     */
       
   274 	void GetTypeL( TDesC16& aObjectId, TDes16& aType );
       
   275 	
       
   276     /**
       
   277     * RefereshL a specific image of text in the widget
       
   278     *
       
   279     * @param aOperation operation performed
       
   280     * @return void
       
   281     */
       
   282     void RefreshL(TDesC16& aOperation );
       
   283     
       
   284     /**
       
   285     * Is plugin active to publish the data 
       
   286     *
       
   287     * @param void 
       
   288     * @return boolean (ETrue/EFalse)
       
   289     */
       
   290     TBool IsActive();
       
   291     
       
   292     /**
       
   293 	* Publish a specific text of the widget  
       
   294 	*
       
   295 	* @param aObserver observer
       
   296 	* @param aContentId content model id
       
   297 	* @param aContentValue content value
       
   298 	* @return void
       
   299 	*/
       
   300 	/*void PublishTextL(MAiContentObserver* aObserver, 
       
   301 			TInt& aContentId, TDesC16& aContentValue);*/
       
   302 
       
   303 	/**
       
   304     * Publish a specific image of the widget  
       
   305     *
       
   306     * @param aObserver observer
       
   307     * @param aContentId content model id
       
   308     * @param aHandle image handle 
       
   309     * @param aMaskHandle handle of the mask image
       
   310     * @return void
       
   311     */
       
   312     void PublishImageL(MAiContentObserver* aObserver, 
       
   313     		TContentItem aContentId, TInt aHandle, TInt aMaskHandle);
       
   314 
       
   315     /**
       
   316     * Publish a specific image of the widget  
       
   317     *
       
   318     * @param aObserver observer
       
   319     * @param aContentId content model id
       
   320     * @param aPath image path / skin id pattern / mif id Pattern 
       
   321     * @return void
       
   322     */
       
   323     void PublishImageL(MAiContentObserver* aObserver,
       
   324     		TContentItem aContentId, TDesC16& aPath );
       
   325     
       
   326     /**
       
   327     * Cleans a data from the widget
       
   328     *
       
   329     * @param aObserver observer
       
   330     * @param aContentId content model id
       
   331     * @return void
       
   332     */
       
   333     void Clean(MAiContentObserver* aObserver, 
       
   334             TInt aContentId );
       
   335     
       
   336     /**
       
   337      * CWrtData getter
       
   338      * @return Pointer to CWrtData
       
   339      */
       
   340     inline CWrtData* Data() const
       
   341         {
       
   342         return iData;
       
   343         }
       
   344 
       
   345 	/*
       
   346 	 * Plugin's network status getter
       
   347 	 * @return Pointer to Harvester status observer
       
   348 	 */
       
   349 	inline TPluginNetworkStatus NetworkStatus() const
       
   350 		{
       
   351 		return iNetworkStatus;
       
   352 		}
       
   353 	
       
   354 private: // data
       
   355 
       
   356     // Iterator for plugin content
       
   357     // Own
       
   358     MAiContentItemIterator* iContent;
       
   359 
       
   360     // Array of content observers
       
   361     // Own
       
   362     RPointerArray<MAiContentObserver> iObservers;
       
   363     
       
   364     // Information about the content publisher (this plug-in)
       
   365     TAiPublisherInfo iInfo;
       
   366 	
       
   367 	// Number of data in the content model.
       
   368 	TInt iDataCount;
       
   369 	 
       
   370 	// Dynamic content model
       
   371 	// Own
       
   372 	TAiContentItem* iContentModel;
       
   373 	
       
   374 	// Reference array for Published text
       
   375 	// Own
       
   376 	RPointerArray<HBufC> iDataArray;
       
   377 	
       
   378 	// Service API Data Subscriber.
       
   379 	// Own
       
   380 	CWrtData* iData;
       
   381     
       
   382     // References array for published images 
       
   383     // Own
       
   384     RArray<CGulIcon*> iIconArray;
       
   385     
       
   386     // File Server
       
   387     // Reference
       
   388     RFs iRfs;
       
   389     
       
   390     // Plugin's network status
       
   391     TPluginNetworkStatus iNetworkStatus;
       
   392     
       
   393     // Is Homescreen foreground.
       
   394     TBool iHSForeGround;
       
   395 
       
   396 	// Plugin state    
       
   397     TPluginStates iPluginState;
       
   398     };
       
   399 
       
   400 #endif // WRTDATAPLUGIN_H
       
   401 
       
   402