idlefw/plugins/mcsplugin/publisher/inc/mcsplugin.h
changeset 0 79c6a41cd166
child 2 b7904b40483f
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 CMCSPLUGIN_H
       
    20 #define CMCSPLUGIN_H
       
    21 
       
    22 #include <aicontentpublisher.h>
       
    23 #include <aipropertyextension.h>
       
    24 #include <aicontentmodel.h>
       
    25 #include <aieventhandlerextension.h>
       
    26 
       
    27 
       
    28 class MAiContentObserver;
       
    29 class MAiContentItemIterator;
       
    30 class CMCSPluginEngine;
       
    31 class TMCSData;
       
    32 //class CMCSPluginData;
       
    33 
       
    34 //class RAiSettingsItemArray;
       
    35 
       
    36 /**
       
    37  *  @ingroup group_mcsplugin
       
    38  *
       
    39  *  Plug-in main class
       
    40  *
       
    41  *  @since S60 v3.2
       
    42  */
       
    43 class CMCSPlugin : public CAiContentPublisher,
       
    44                    public MAiPropertyExtension,
       
    45                    public MAiEventHandlerExtension
       
    46 
       
    47 
       
    48     {
       
    49 
       
    50 public:
       
    51 
       
    52     /**
       
    53     * Part of the two phased constuction
       
    54     *
       
    55     * @param none
       
    56     * @return none
       
    57     */
       
    58     static CMCSPlugin* NewL();
       
    59 
       
    60     /**
       
    61      * CompareItems
       
    62      * 
       
    63      * @param aFirst
       
    64      * @param aSecond
       
    65      */
       
    66     static TInt CompareItems(const MAiPluginSettings& aFirst,
       
    67         const MAiPluginSettings& aSecond );
       
    68     /**
       
    69     * Constructor
       
    70     *
       
    71     * @param none
       
    72     * @return none
       
    73     */
       
    74     CMCSPlugin();
       
    75     
       
    76     /**
       
    77     * Destructor
       
    78     *
       
    79     * @param none
       
    80     * @return none
       
    81     */
       
    82     ~CMCSPlugin();
       
    83     
       
    84     /**
       
    85     * Publishes profile names
       
    86     *
       
    87     * @param void
       
    88     * @return void
       
    89     */
       
    90     void PublishL();
       
    91 
       
    92 // from base class CAiContentPublisher
       
    93   
       
    94     /**
       
    95     * From CAiContentPublisher
       
    96     * The method is called by the framework to request the plug-in free all
       
    97     * memory and CPU resources and close all its open files, e.g. the plug-in 
       
    98     * should unload its engines due backup operation. The method transits the 
       
    99     * plug-in to "Idle" state.
       
   100     *
       
   101     * @param aReason reason for state change, see TAiTransitionChange.
       
   102     * @return void
       
   103     */
       
   104     void Stop( TAiTransitionReason aReason );
       
   105 
       
   106     /**
       
   107     * From CAiContentPublisher
       
   108     * The method is called by the framework to instruct plug-in that it is
       
   109     * allowed to consume CPU resources, e.g plug-in is able to run timers,
       
   110     * perform asynchronous operations, etc. The method transits the plug-in
       
   111     * to "Alive" state.
       
   112     *
       
   113     * @param aReason reason for state change, see TAiTransitionChange.
       
   114     * @return void
       
   115     */
       
   116     void Resume( TAiTransitionReason aReason );
       
   117 
       
   118     /**
       
   119     * From CAiContentPublisher
       
   120     * The method is called by the framework to instruct plug-in that it is
       
   121     * not allowed to consume CPU resources, e.g plug-in MUST stop each
       
   122     * timers, cancel outstanding asynchronous operations, etc. The method
       
   123     * transits the plug-in to "Suspendend" state.
       
   124     *
       
   125     * @param aReason reason for state change, see TAiTransitionChange.
       
   126     * @return void
       
   127     */
       
   128     void Suspend( TAiTransitionReason aReason );
       
   129 
       
   130     /**
       
   131     * From CAiContentPublisher
       
   132     * Adds the content observer / subscriber to plug-in. The plug-in MUST
       
   133     * maintain a registry of subscribers and send notification to all them
       
   134     * whenever the plug-in changes state or new content available.
       
   135     *
       
   136     * @param aObserver content observer to register.
       
   137     * @return void
       
   138     */
       
   139     void SubscribeL( MAiContentObserver& aObserver );
       
   140     
       
   141     /**
       
   142     * From CAiContentPublisher
       
   143     * Configures the plug-in.
       
   144     * Plug-ins take ownership of the settings array, so it must either
       
   145     * store it in a member or free it. Framework has put the array in cleanup
       
   146     * stack so the plugin shouldn't do that.
       
   147     * If this leaves, the plug-in will be destroyed by AI FW.
       
   148     * Plug-in must support LaunchByValue-event even if normal shortcuts don't
       
   149     * work. The only allowed serious enough leave is KErrNotFound from CenRep.
       
   150     *
       
   151     * @param aSettings setting items defined in the UI definition.
       
   152     * @return void
       
   153     */
       
   154     void ConfigureL( RAiSettingsItemArray& aSettings );
       
   155 
       
   156     /**
       
   157     * From CAiContentPublisher
       
   158     * Returns interface extension. In Series 60 3.1 only event & property
       
   159     * extensions are supported. See MAiEventExtension & MAiPropertyExtension
       
   160     * interfaces.
       
   161     *
       
   162     * @param  aUid - UID of the extension interface to access.
       
   163     * @return the extension interface. Actual type depends on the passed aUid 
       
   164     *         argument.
       
   165     */
       
   166     TAny* Extension( TUid aUid );  
       
   167 
       
   168 // from base class MAiPropertyExtension
       
   169 
       
   170     /**
       
   171     * From MAiPropertyExtension.
       
   172     * Read property of publisher plug-in.
       
   173     *
       
   174     * @param aProperty - identification of property.
       
   175     * @return pointer to property value.
       
   176     */
       
   177     TAny* GetPropertyL( TInt aProperty );
       
   178 
       
   179     /**
       
   180     * From MAiPropertyExtension.
       
   181     * Write property value.
       
   182     *
       
   183     * @param aProperty - identification of property.
       
   184     * @param aValue - contains pointer to property value.
       
   185     */
       
   186     void SetPropertyL( TInt aProperty, TAny* aValue );
       
   187   
       
   188  // from base class MAiEventHandlerExtension
       
   189    
       
   190      /**
       
   191      * From MAiEventHandlerExtension
       
   192      * Invoked by the framework when plug-in must handle an event.
       
   193      *
       
   194      * @param aEvent - unique identifier of event from plug-in content model.
       
   195      * @param aParam - parameters associated with event. Each UI Definition
       
   196      *        declares events in the format: <event name>(<event params>),
       
   197      *        where <event name> is mapped by the framework to unique
       
   198      *        identifier supplied in aEvent, <event params> are provided to
       
   199      *        plug-in as-is in the descriptor.
       
   200      * @since S60 3.2
       
   201      */
       
   202     void HandleEvent(TInt aEvent, const TDesC& aParam);
       
   203     
       
   204     /**
       
   205      * From MAiEventHandlerExtension
       
   206      * Invoked by the framework when plug-in must handle an event.
       
   207      *
       
   208      * @param aEventName - name of the event from plug-in content model.
       
   209      * @param aParam - parameters associated with event. Each UI Definition
       
   210      *        declares events in the format: <event name>(<event params>),
       
   211      *        where  <event name> mapping to unique identifier supplied by event 
       
   212      *        is failed by the frame work then the  <event name> and  
       
   213      *        <event params>  are provided to plug-in as-is in the descriptor.
       
   214      */
       
   215      void HandleEvent(const TDesC& aEventName, const TDesC& aParam);
       
   216 
       
   217 protected:
       
   218 
       
   219 private:
       
   220 
       
   221     /**
       
   222     * Part of the two phased construction
       
   223     *
       
   224     * @param void
       
   225     * @return void
       
   226     */
       
   227     void ConstructL();
       
   228     
       
   229     /**
       
   230     * Resume the plug-in.
       
   231     *
       
   232     * @param aReason reason for state change, see TAiTransitionChange.
       
   233     * @return void
       
   234     */    
       
   235     void DoResumeL(TAiTransitionReason aReason);
       
   236     
       
   237     /**
       
   238      * Publishes content for one menu item
       
   239      */
       
   240     void PublishLItemL( MAiContentObserver& aObserver, TMCSData& aDataItem, TInt aIndex );
       
   241         
       
   242     /**
       
   243     * Free the engine
       
   244     *
       
   245     * @param void
       
   246     * @return void
       
   247     */  
       
   248     void FreeEngine();
       
   249 
       
   250     /**
       
   251     * Delete content model
       
   252     */  
       
   253     void DeleteContentModel();    
       
   254     
       
   255 private: // data
       
   256 
       
   257     // Iterator for plugin content
       
   258     // Own
       
   259     MAiContentItemIterator* iContent;
       
   260 
       
   261     // Number of data in the content model.
       
   262     TInt iDataCount;
       
   263 
       
   264     // Dynamic content model
       
   265     // Own.
       
   266     TAiContentItem* iContentModel;
       
   267 
       
   268     // Plugin engine
       
   269     // Own
       
   270     CMCSPluginEngine* iEngine;
       
   271 
       
   272     // Array of content observers
       
   273     // not own
       
   274     RPointerArray<MAiContentObserver> iObservers;
       
   275 
       
   276     // Information about the content publisher (this plug-in)
       
   277     TAiPublisherInfo iInfo;
       
   278 
       
   279     // Boolean, which expresses whether the content has been updated
       
   280     //TBool iIsUpdated;
       
   281 
       
   282     };
       
   283 
       
   284 #endif // CMCSPLUGIN_H