phonebookui/Phonebook2/ccapplication/ccapp/inc/ccapppluginloader.h
changeset 0 e686773b3f54
child 12 5072fb0f5b46
child 14 81f8547efd4f
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 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:  Class for loading and handling the view plugins
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __CCAPPLUGINLOADER_H__
       
    20 #define __CCAPPLUGINLOADER_H__
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 class CCCAppView;
       
    25 class CCCAppPluginData;
       
    26 class CCCAppViewPluginBase;
       
    27 class CImplementationInformation;
       
    28 class CEikonEnv;
       
    29 class MCCAppEngine;
       
    30 class TCCAPluginsOrderInfo;
       
    31 class CcaPluginFactoryOwner;
       
    32 
       
    33 /**
       
    34  *  Class for loading and handling the plugins
       
    35  *
       
    36  *  @code
       
    37  *   ?good_class_usage_example(s)
       
    38  *  @endcode
       
    39  *
       
    40  *  @lib ccaapp.exe
       
    41  *  @since S60 v5.0
       
    42  */
       
    43 class CCCAppPluginLoader : public CBase
       
    44     {
       
    45 #ifdef __CCAPPUNITTESTMODE
       
    46     friend class T_CCCAppPluginLoader;
       
    47 #endif// __CCAPPUNITTESTMODE       
       
    48 
       
    49 public:
       
    50 
       
    51     /**
       
    52      * Two phase contstructor
       
    53      */
       
    54     static CCCAppPluginLoader* NewL(
       
    55         MCCAppEngine* aAppEngine, 
       
    56         const TDesC8& aPluginProperties, 
       
    57         const TDesC8& aTypeFilter = KNullDesC8 );
       
    58 
       
    59     /**
       
    60      * Destructor.
       
    61      */
       
    62     ~CCCAppPluginLoader();
       
    63 
       
    64 private:
       
    65     
       
    66     CCCAppPluginLoader(MCCAppEngine* aAppEngine);
       
    67     void ConstructL(const TDesC8& aPluginProperties, const TDesC8& aTypeFilter);
       
    68 
       
    69 public:
       
    70     
       
    71     /**
       
    72      * Returns the next plug-in data relative to the one in focus
       
    73      * and changes the focus
       
    74      *
       
    75      * @since S60 v5.0
       
    76      * @param aOnlyVisiblePlugins EFalse: includes also hidden plugins 
       
    77      * @return A plug-in data if it exists, NULL otherwise.
       
    78      */
       
    79     CCCAppPluginData* NextPlugin( TBool aOnlyVisiblePlugins );
       
    80     
       
    81     /**
       
    82      * Returns the previous plug-in data relative to the one in focus
       
    83      * and changes the focus
       
    84      *
       
    85      * @since S60 v5.0
       
    86      * @param aOnlyVisiblePlugins EFalse: includes also hidden plugins
       
    87      * @return A plug-in data if it exists, NULL otherwise.
       
    88      */
       
    89     CCCAppPluginData* PreviousPlugin( TBool aOnlyVisiblePlugins );
       
    90 
       
    91     /**
       
    92      * Tries to set certain plugin in focus.
       
    93      *
       
    94      * @since S60 v5.0
       
    95      * @param aUid is the plugin wanted to be in focus
       
    96      * @return index of succesfully set plugin, otherwise KErrNotFound.
       
    97      */
       
    98     TInt SetPluginInFocus( const TUid aUid );   
       
    99     
       
   100     /**
       
   101      * Returns the current plug-in data in focus
       
   102      *
       
   103      * @since S60 v5.0
       
   104      * @return A plug-in data, NULL if first
       
   105      */
       
   106     CCCAppPluginData* PluginInFocus();
       
   107     
       
   108     /**
       
   109      * Returns the number of all available plug-ins
       
   110      *
       
   111      * @since S60 v5.0
       
   112      * @return Number loaded plug-ins.
       
   113      */
       
   114     TInt PluginsCount() const;
       
   115 
       
   116     /**
       
   117      * Returns the number of visible plug-ins
       
   118      *
       
   119      * @since S60 v5.0
       
   120      * @return Number visible plug-ins.
       
   121      */    
       
   122     TInt VisiblePluginCount() const; 
       
   123     
       
   124     /**
       
   125      * Returns the plug-in data at certain index.
       
   126      *
       
   127      * @since S60 v5.0
       
   128      * @param aIndex is the plugin wanted
       
   129      * @param aChangefocus if the focus is needed to change also
       
   130      * @return A plug-in data if it exists, NULL otherwise.
       
   131      */
       
   132     CCCAppPluginData* PluginAt( TInt aIndex, TBool aChangefocus = EFalse );
       
   133 
       
   134     /**
       
   135      * Returns the plug-in data at certain index within visible plugins.
       
   136      *
       
   137      * @since S60 v5.0
       
   138      * @param aIndex Index of the plugin within visible plugins.
       
   139      * @param aChangefocus if the focus is needed to change also
       
   140      * @return A plug-in data if it exists, NULL otherwise.
       
   141      */
       
   142     CCCAppPluginData* VisiblePlugin( TInt aIndex, TBool aChangefocus = EFalse );    
       
   143     
       
   144     /**
       
   145      * Removes plugin from plugin loader. 
       
   146      * Needed for error cases. 
       
   147      *
       
   148      * @since S60 v5.0
       
   149      * @param index of plugin in loader.
       
   150      */
       
   151     void RemovePlugin( TUid aPlugin );
       
   152 
       
   153     /**
       
   154      * Returns plugin.
       
   155      *
       
   156      * @since S60 v5.0
       
   157      * @param aPlugin Uid of plugin
       
   158      * @return A plug-in data if it exists, NULL otherwise.
       
   159      */
       
   160     CCCAppViewPluginBase* Plugin( TUid aPlugin );    
       
   161 
       
   162     /**
       
   163      * Getter for plugin visiblity.
       
   164      *
       
   165      * @since S60 v5.0
       
   166      * @return plugin visibility, see enum CCCAppPluginData::TPluginVisibility.
       
   167      */     
       
   168     TInt PluginVisibility(TUid aPlugin, TInt& aTabNbr);    
       
   169     
       
   170     /**
       
   171      * Setter for plugin visiblity.
       
   172      *
       
   173      * @since S60 v5.0
       
   174      * @param aPluginVisibility, see enum CCCAppPluginData::TPluginVisibility.
       
   175      */    
       
   176     TBool SetPluginVisibility(
       
   177         TUid aPlugin,
       
   178         TInt aVisibility);
       
   179     
       
   180 private:
       
   181 
       
   182     /**
       
   183      * Loads multiple views using factory functionality from a factory. Through this interface one 
       
   184      * plugin dll can instantiate multiple views.  
       
   185      *
       
   186      * @since S60 v5.0
       
   187      */	
       
   188     void LoadOneMultiViewPluginL(CImplementationInformation* aImplementationInformation);    
       
   189     
       
   190     /**
       
   191      * Goes through the iPluginInfoArray, loads all the plugins and 
       
   192      * appends them to array.
       
   193      *
       
   194      * @since S60 v5.0
       
   195      */
       
   196     void LoadAllPlugins( const RArray<TCCAPluginsOrderInfo>& aPluginOrderInfoArray, const TDesC8& aPluginProperties );
       
   197     
       
   198     /**
       
   199      * Loads plugin and appends it to array.
       
   200      *
       
   201      * @since S60 v5.0
       
   202      * @param aImplementationUid Implementation UID of the plug-in to be loaded.
       
   203      */
       
   204     void LoadPluginL( TUid aImplementationUid );
       
   205     
       
   206     /** 
       
   207      * Extract sXP plug-in names from name string and put them to name array.
       
   208      * 
       
   209      * @param aPbksXPExtesionNamesArray, names are stored.
       
   210      * @param aNameString, name string contains all sXP plug-in names, each plugin
       
   211      *        name is seperated be pipeline "|", e.g Google|MSN|Ovi|
       
   212      */
       
   213     void GetPbksXPExtesionNamesL( RArray<TPtrC>& aPbksXPExtesionNamesArray,
       
   214             const TDesC& aNameString);
       
   215     
       
   216     /**
       
   217     * copy pluginInfo address from pluginInforArrays to RArray<TCCAPluginsOrderInfo> array.
       
   218     * plus opaques values. make RArray<TCCAPluginsOrderInfo> array 3 group: ECCAInHousePlugins,
       
   219     * ECCAPlugindInBothCCAAndNameList and ECCAPluginsOnlyInCCA, store group info.
       
   220     * 
       
   221     * @param aOrderInfoArray, store address copy pluginInfo object from iPluginInforArray,
       
   222     *        plus order and groupInfo.
       
   223     * @param aNameListPluginNameArray, phonebook mainview sXPExtension plugins name list
       
   224     * @param aOldPluginInfoArray	
       
   225     * @param aNewPluginInfoArray 
       
   226     */
       
   227     void GetPluginsInfoL( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray,
       
   228             const RArray<TPtrC>& aNameListPluginNameArray,
       
   229             RPointerArray<CImplementationInformation>& aOldPluginInfoArray,
       
   230             RPointerArray<CImplementationInformation>& aNewPluginInfoArray);
       
   231 
       
   232     /**
       
   233     * copy pluginInfo address from pluginInforArray to RArray<TCCAPluginsOrderInfo> array.
       
   234     * plus opaques values. make RArray<TCCAPluginsOrderInfo> array 3 group: ECCAInHousePlugins,
       
   235     * ECCAPlugindInBothCCAAndNameList and ECCAPluginsOnlyInCCA, store group info.
       
   236     * 
       
   237     * @param aOrderInfoArray, store address copy pluginInfo object from iPluginInforArray,
       
   238     *        plus order and groupInfo.
       
   239     * @param aNameListPluginNameArray, phonebook mainview sXPExtension plugins name list
       
   240     * @param aPluginInfoArray    
       
   241     * @param aIsOldInterFaceType ETrue if old interface type plugins are processed  
       
   242     */
       
   243     void AppendOrderInfoL( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray,
       
   244             const RArray<TPtrC>& aNameListPluginNameArray,
       
   245             RPointerArray<CImplementationInformation>& aPluginInfoArray,
       
   246             TBool aIsOldInterFaceType);    
       
   247     
       
   248     /**
       
   249      * Find smallest opaque value from plugins only in cca.
       
   250      * 
       
   251      * @param aOrderInfoArray array contains TCCAPluginsOrderInfo
       
   252      * @return smallest opaque value
       
   253      */
       
   254     TInt SmallestOpaqueFromPluginsOnlyInCCA( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray );
       
   255     
       
   256     /**
       
   257      * Find largest opaque value from in-house plugins.
       
   258      * 
       
   259      * @param aOrderInfoArray array contains TCCAPluginsOrderInfo
       
   260      * @return largest opaque value
       
   261      */
       
   262     TInt LargestOpaqueFromInHousePlugins( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray );
       
   263 
       
   264     /**
       
   265      * Update orders for plugins only in CCA view
       
   266      * 
       
   267      * @param aStartPosition used for order updating
       
   268      * @param aOrderInfoArray array of TCCAPluginsOrderInfo
       
   269      */
       
   270     void UpdateOrdersForPluginsOnlyInCCA(const TInt aStartPosition,
       
   271             RArray<TCCAPluginsOrderInfo>& aOrderInfoArray);
       
   272     
       
   273     /**
       
   274       * Update orders for plugins in both CCA and name list
       
   275       * 
       
   276       * @param aLastPosition used for order updating, itself is also updated
       
   277       * @param aOrderInfoArray array of TCCAPluginsOrderInfo
       
   278       * @param aNameListPluginNameArray array contains plugins names in Name list view
       
   279       */
       
   280     void UpdateOrdersForPluginsInBothCCAAndNameList( TInt& aLastPosition,
       
   281             RArray<TCCAPluginsOrderInfo>& aOrderInfoArray,
       
   282             const RArray<TPtrC>& aNameListPluginNameArray);
       
   283     /**
       
   284      * changed iOrder informatin of each element in orderinfoarray.
       
   285      * then Sort sXP plug-ins orderinforarray by iOrder. 
       
   286      *       
       
   287      * @param aOrderInfoArray order information will be updated, the array will be sorted
       
   288      *        then by order.
       
   289      *        
       
   290      * @param aNameListPluginNameArray contains sXP plug-in names for Name List.
       
   291      *        Used for find element in aOrderInfoArray.
       
   292      */
       
   293     void SortPluginsOrderInfoL( RArray<TCCAPluginsOrderInfo>& aOrderInfoArray,
       
   294             const RArray<TPtrC>& aNameListPluginNameArray);
       
   295    
       
   296     /**
       
   297      * Find phonebook main view sXPExtension Plugin name from name array 
       
   298      *
       
   299      * @param aCCAPluginInfo, a CImplementationInformation type object.
       
   300      * @param aNameListPluginNameArray, phonebook main view sXPExtension Plugins name array
       
   301      * 
       
   302      * @return found name's position in aNameListPluginNameArray, KErrNotFound if not found.
       
   303      */
       
   304     TInt FindPluginNameFromNameListByCCAPluginInfo(const CImplementationInformation& aCCAPluginInfo,
       
   305             const RArray<TPtrC>& aNameListPluginNameArray);
       
   306     
       
   307     /**
       
   308      * Get Opaque integer value from a refrerence of CImplementationInformation
       
   309      * 
       
   310      * @param aInfo, object of CImplementationInformation
       
   311      * @return opaque integer value.
       
   312      */
       
   313     TInt CCCAppPluginLoader::OpaqueValueFrom( const CImplementationInformation& aInfo );
       
   314     
       
   315     /**
       
   316      * Loads a plugin.
       
   317      * 
       
   318      * @param aPluginsOrderInfo ordering info
       
   319      * @param aPluginProperties properties to fulfill  
       
   320      * @return opaque integer value.
       
   321      */
       
   322     void CheckAndLoadPluginL(
       
   323             const TCCAPluginsOrderInfo& aPluginsOrderInfo,            
       
   324             const TDesC8& aPluginProperties );
       
   325     
       
   326     /**
       
   327      * Returns plugin order.
       
   328      * 
       
   329      * @param aImplementationInformation ecom implementation information
       
   330      * @return order
       
   331      */    
       
   332     TInt GetOrderValueL( const CImplementationInformation& aInfo );
       
   333     
       
   334     /**
       
   335      * Compares properties of two propertystrings.
       
   336      * 
       
   337      * @param aData properties to compare
       
   338      * @param aRefData properties to compare
       
   339      * @param aMatchValuesToo ETrue if also property values need to becompared 
       
   340      * @return matching properties.
       
   341      */    
       
   342     HBufC8* GetmachingPropertiesLC(
       
   343             const TDesC8& aData, const TDesC8& aRefData, TBool aMatchValuesToo);
       
   344     
       
   345     /**
       
   346      * Extracts name value pair data from property string. Extracted data
       
   347      * is removed from property string
       
   348      * 
       
   349      * @param aName name extracted
       
   350      * @param aValue value extracted
       
   351      * @param aDataPtr property string  
       
   352      */    
       
   353     void GetNameValue( TPtrC8& aName, TPtrC8& aValue, TPtrC8& aDataPtr );
       
   354     
       
   355 private://data
       
   356 
       
   357 
       
   358     /**
       
   359      * Pointer array of loaded plugin data structures.
       
   360      * Own.
       
   361      */
       
   362     RPointerArray<CCCAppPluginData> iPluginDataArray;
       
   363     /**
       
   364      * Current plugin in use
       
   365      */
       
   366     TInt iCurrentPlugin;
       
   367     
       
   368     /**
       
   369      * Reference to the cca application engine
       
   370      * not owned
       
   371      */
       
   372     MCCAppEngine* iAppEngine;
       
   373     
       
   374     /**
       
   375      * Temporary holder for CcaPluginFactoryOwner, 
       
   376      * owned unless ownership handed over.
       
   377      */    
       
   378     CcaPluginFactoryOwner* iFactoryTempPtr;    
       
   379 	};
       
   380 
       
   381 #endif // __CCAPPUNITTESTMODE
       
   382 //End of file