idlefw/plugins/wrtdataplugin/inc/wrtdataplugin.h
changeset 85 7feec50967db
parent 4 1a2a00e78665
child 86 e492551a0d54
equal deleted inserted replaced
4:1a2a00e78665 85:7feec50967db
     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 // FORWARD DECLARATIONS
       
    28 class MAiContentObserver;
       
    29 class MAiContentItemIterator;
       
    30 class MAiPSPropertyObserver;
       
    31 class CWrtData;
       
    32 class CDesC16Array;
       
    33 class CGulIcon;
       
    34 class CLiwDefaultMap;
       
    35 
       
    36 
       
    37 // CLASS DECLARATION
       
    38 /**
       
    39  *  @ingroup group_wrtdataplugin
       
    40  *
       
    41  *  Plug-in main class
       
    42  *
       
    43  *  @since S60 v3.2
       
    44  */
       
    45 class CWrtDataPlugin : public CAiContentPublisher,
       
    46                      	public MAiPropertyExtension,
       
    47                      	public MAiEventHandlerExtension
       
    48                     
       
    49     {
       
    50         
       
    51     public :
       
    52         /**
       
    53         * Plugin's network state.
       
    54         */
       
    55         enum TPluginNetworkStatus 
       
    56             {
       
    57             EUnknown, 
       
    58             EOffline,
       
    59             EOnline
       
    60             };
       
    61         
       
    62         /**
       
    63          * Plugin's state.
       
    64          */
       
    65         enum TPluginStates
       
    66             {
       
    67             ENone,
       
    68             EResume,
       
    69             ESuspend,
       
    70             EInActive,
       
    71             };
       
    72         
       
    73         /**
       
    74         * Content Items
       
    75         */
       
    76         enum TContentItem
       
    77          {
       
    78          EDefaultImage,
       
    79          EDefaultText,
       
    80          EImage1
       
    81          };
       
    82 
       
    83     public:
       
    84     
       
    85         /**
       
    86         * Part of the two phased constuction
       
    87         *
       
    88         * @param none
       
    89         * @return none
       
    90         */
       
    91         static CWrtDataPlugin* NewL();
       
    92         
       
    93         /**
       
    94         * Destructor
       
    95         *
       
    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     };
       
   440 
       
   441 #endif // WRTDATAPLUGIN_H
       
   442 
       
   443