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