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