webengine/widgetregistry/Server/inc/WidgetRegistry.h
changeset 0 dd21522fd290
child 15 60c5402cb945
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2006 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 the License "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:  This file contains the header file of the CWidgetRegistry class.
       
    15 *
       
    16 *                This class implements the CWidgetRegistry class.
       
    17 *
       
    18 */
       
    19 
       
    20 #ifndef WIDGETREGISTRY_H
       
    21 #define WIDGETREGISTRY_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32hashtab.h>
       
    25 #include <apgcli.h>
       
    26 #include <Browser_platform_variant.hrh>
       
    27 #include "WidgetRegistryData.h"
       
    28 #include "WidgetRegistryConstants.h"
       
    29 #include "WidgetPropertyValue.h"
       
    30 #include "WidgetRegistryLog.h"
       
    31 
       
    32 // CONSTANTS
       
    33 #define KWidgetRegistryMaxPathName 64
       
    34 
       
    35 // MACROS
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class RFs;
       
    39 class CWidgetMMCHandler;
       
    40 class CWidgetEntry;
       
    41 class CWidgetInstaller;
       
    42 class CWidgetRegistryXml;
       
    43 
       
    44 #if defined( BRDO_WRT_SECURITY_MGR_FF )
       
    45 class CRTSecManager;
       
    46 #endif
       
    47 
       
    48 typedef RPointerArray<CWidgetEntry> RWidgetArray;
       
    49 
       
    50 // DATA TYPES
       
    51 
       
    52 // FUNCTION PROTOTYPES
       
    53 
       
    54 // CLASS DECLARATION
       
    55 
       
    56 /**
       
    57 *  CWidgetRegistry
       
    58 *  @since 3.1
       
    59 */
       
    60 
       
    61 class CWidgetRegistry : public CBase
       
    62     {
       
    63 public:
       
    64     /**
       
    65      * Returns singleton of factory.
       
    66      */
       
    67     static CWidgetRegistry* NewL( RFs& aFs );
       
    68 
       
    69     /**
       
    70      * Destructor.
       
    71      */
       
    72     virtual ~CWidgetRegistry();
       
    73 
       
    74     /**
       
    75      * Returns true if the Uid falls within the range specified for widgets.
       
    76      */
       
    77     TBool IsWidget( const TUid& aUid ) const;
       
    78 
       
    79     /**
       
    80      * Returns true if the widget is installed.
       
    81      */
       
    82     TBool WidgetExists( const TDesC& aBundleId ) const;
       
    83 
       
    84     /**
       
    85      * Returns true if the widget is running.
       
    86      */
       
    87     TBool IsWidgetRunning( const TUid& aUid ) const;
       
    88 
       
    89     /**
       
    90      * Returns if widget sapi access is prompted, promptless or denied.
       
    91      */
       
    92     TInt WidgetSapiAccessState( const TUid& aUid ) const;
       
    93 
       
    94     /**
       
    95      * Returns true if the widget is in miniview
       
    96      */
       
    97     TBool IsWidgetInMiniView( const TUid& aUid ) const;
       
    98 
       
    99     /**
       
   100      * Returns true if the widget is started in fullview
       
   101      */
       
   102     TBool IsWidgetInFullView( const TUid& aUid ) const;
       
   103 
       
   104     /**
       
   105      * Returns true if blanket permission is granted
       
   106      */
       
   107     TBool IsBlanketPermGranted( const TUid& aUid ) const;
       
   108 
       
   109     /**
       
   110      * Returns count of widgets installed.
       
   111      */
       
   112     TInt WidgetCount() const { return iEntries.Count();}
       
   113 
       
   114     /**
       
   115      * Returns path of the widget with a particular UId.
       
   116      */
       
   117     void GetWidgetPath( const TUid& aUid, TDes& aPath );
       
   118 
       
   119     /**
       
   120      * Returns the lproj name
       
   121      */
       
   122     void GetLprojNameL( TDes& aLprojName );
       
   123 
       
   124     /**
       
   125      * Returns UId of the widget with a particular bundle identifier.
       
   126      */
       
   127     TUid GetWidgetUid( const TDesC& aBundleId ) const;
       
   128 
       
   129     /**
       
   130      * Returns uid of the widget with a particular html path.
       
   131      */
       
   132     TUid GetWidgetUidForUrl( const TDesC& aUrl ) const;
       
   133 
       
   134     /**
       
   135      * Get next available UId
       
   136      */
       
   137     TUid GetAvailableUidL( TInt aDriveLetter );
       
   138 
       
   139     /**
       
   140      * Returns bundle Id of the widget with a particular UId.
       
   141      */
       
   142     void GetWidgetBundleId( const TUid& aUid, TDes& aBundleId );
       
   143 
       
   144     /**
       
   145      * Returns bundle display name of the widget with a particular UId.
       
   146      */
       
   147     void GetWidgetBundleName( const TUid& aUid, TDes& aBundleName );
       
   148 
       
   149     /**
       
   150      * return serialized value of property aId for the widget aUid or leave
       
   151      */
       
   152     CBufFlat* CWidgetRegistry::GetWidgetPropertyValueL(
       
   153         const TUid& aUid,
       
   154         TWidgetPropertyId aId,
       
   155         TInt aMaxLength );
       
   156 
       
   157     /**
       
   158      * Returns widget info for all the installed widgets.
       
   159      */
       
   160     void InstalledWidgetsL( RWidgetInfoArray& );
       
   161 
       
   162     /**
       
   163      * Returns widget info for all the running widgets.
       
   164      */
       
   165     void RunningWidgetsL( RWidgetInfoArray& );
       
   166 
       
   167     /**
       
   168      * Registers the widget and creates a widget entry.
       
   169      */
       
   170     void RegisterWidgetL( RReadStream& aStream );
       
   171 
       
   172     /**
       
   173      * Deregisters the widget and removes the widget entry.
       
   174      */
       
   175     void DeRegisterWidgetL( const TUid& aUid );
       
   176 
       
   177     /**
       
   178      * Set/Reset active status of the widget with a particular UId
       
   179      */
       
   180     void SetActive( TUid aUid, TInt aStatus );
       
   181 
       
   182     /**
       
   183      * Set/Reset Widget status for launched in MiniView
       
   184      */
       
   185     void SetMiniView( TUid aUid, TInt aStatus );
       
   186 
       
   187     /**
       
   188      * Set/Reset Widget status for widget  in FullView
       
   189      */
       
   190     void SetFullView( TUid aUid, TInt aStatus );
       
   191 
       
   192     /**
       
   193     * Set/Reset Widget Blanket permission for platform services
       
   194     */
       
   195     void SetBlanketPermissionL( TUid aUid, TInt aStatus );
       
   196 
       
   197     /**
       
   198      * Load widget information from a file, detect consistency
       
   199      * errors and correct them.  Leave only if unrecoverable issue,
       
   200      * dirty flag is true only in non leave case and some change
       
   201      * needs to be written out
       
   202      */
       
   203     void InternalizeL( TBool& aDirtyFlag );
       
   204 
       
   205     /**
       
   206      * Store widget information to a file
       
   207      */
       
   208     void ExternalizeL();
       
   209 
       
   210     /**
       
   211      * Returns security policyId.
       
   212      */
       
   213      TInt SecurityPolicyId() { return FetchSecurityPolicyIdL(); }
       
   214 
       
   215 private:
       
   216 
       
   217     /**
       
   218      * Insert a widget entry
       
   219      */
       
   220     TInt InsertL( CWidgetEntry* aEntry );
       
   221 
       
   222     /**
       
   223      * Get widget entry with a particular UId
       
   224      */
       
   225     CWidgetEntry& GetWidgetEntryL( const TUid& aUid ) const;
       
   226 
       
   227     /**
       
   228      * Get widget entry with a particular UId
       
   229      */
       
   230     TInt GetWidgetEntry( const TUid& aUid, CWidgetEntry*& aEntry ) const;
       
   231 
       
   232     /**
       
   233      * Get widget entry with a particular bundle Id
       
   234      */
       
   235     TInt GetWidgetEntry(
       
   236         const TDesC& aBundleId, CWidgetEntry*& aEntry ) const;
       
   237 
       
   238     /**
       
   239      * Get widget entry at a particular position in the array
       
   240      */
       
   241     const CWidgetEntry* GetWidgetEntry( const TInt& aPos );
       
   242 
       
   243     /**
       
   244      * Remove widget entry with a particular bundle Id
       
   245      */
       
   246     void Remove( const TDesC& aBundleId );
       
   247 
       
   248     /**
       
   249      * Remove widget entry with a particular bundle UId
       
   250      */
       
   251     void Remove( const TUid& aUid );
       
   252 
       
   253 
       
   254     /**
       
   255      * Returns array of used UIds.
       
   256      */
       
   257     void UsedUidsL( RUidArray& aUsedUids );
       
   258 
       
   259     /**
       
   260      * Reset widget entry array
       
   261      */
       
   262     void ResetWidgetEntry();
       
   263 
       
   264     /**
       
   265      * Get policy Id from security manager
       
   266      */
       
   267      TInt FetchSecurityPolicyIdL();
       
   268 
       
   269 protected:
       
   270     /**
       
   271      * 2-phase constructor
       
   272      */
       
   273     void ConstructL();
       
   274 
       
   275     /**
       
   276      * Constructor
       
   277      */
       
   278     CWidgetRegistry( RFs& aFs );
       
   279 
       
   280     /**
       
   281      * create the mapping table for language and lproj dir
       
   282      */
       
   283     void CreateLangDirListL();
       
   284 
       
   285     void ExternalizeBinaryL( const TDesC& aFilename,
       
   286                              const CArrayFixFlat<TInt>* aIndices );
       
   287 
       
   288     void ExternalizeXmlL( const TDesC& aFilename,
       
   289                           const CArrayFixFlat<TInt>* aIndices );
       
   290 
       
   291     void InternalizeBinaryL( const TDesC& aFileName,
       
   292                              const TDriveUnit& aDriveUnit,
       
   293                              TBool aDoConsistency,
       
   294                              RArray<TUid>& aAppArchList,
       
   295                              RArray<TInt>& aAppArchListFlags,
       
   296                              const CDir* aInstalledListForDrive,
       
   297                              RArray<TInt>& aInstalledListForDriveFlags,
       
   298                              TBool& aDirtyFlag );
       
   299 
       
   300     void InternalizeXmlL( const TDesC& aFileName,
       
   301                           const TDriveUnit& aDriveUnit,
       
   302                           TBool aDoConsistency,
       
   303                           RArray<TUid>& aAppArchList,
       
   304                           RArray<TInt>& aAppArchListFlags,
       
   305                           const CDir* aInstalledListForDrive,
       
   306                           RArray<TInt>& aInstalledListForDriveFlags,
       
   307                           TBool& aDirtyFlag );
       
   308 
       
   309     CWidgetEntry* EntryConsistency(
       
   310         CWidgetEntry* entry,
       
   311         const RArray<TUid>& aAppArchList,
       
   312         RArray<TInt>& aAppArchListFlags,
       
   313         const CDir* aInstalledListForDrive,
       
   314         RArray<TInt>& aInstalledListForDriveFlags,
       
   315         const TDriveUnit& aDriveUnit,
       
   316         TBool& aDirtyFlag );
       
   317 
       
   318     void InstallDirConsistency( const CDir* aInstalledListForDrive,
       
   319                                 RArray<TInt>& aInstalledListForDriveFlags,
       
   320                                 TBool& aDirtyFlag );
       
   321 
       
   322     void AppArchListConsistency( const RArray<TUid>& aAppArchList,
       
   323                                  RArray<TInt>& aAppArchListFlags );
       
   324 
       
   325     TBool IsEntryInstalled( CWidgetEntry* entry,
       
   326                             const CDir* aInstalledListForDrive,
       
   327                             RArray<TInt>& aInstalledListForDriveFlags );
       
   328 
       
   329     TInt IsEntryInAppList( CWidgetEntry* entry,
       
   330                            const RArray<TUid>& aAppArchList,
       
   331                            RArray<TInt>& aAppArchListFlags,
       
   332                            TBool& aInAppList,
       
   333                            TUid& uid );
       
   334 
       
   335     TInt AppArchWidgetUids( RArray< TUid >& aUids );
       
   336 
       
   337     TBool AppArchWidgets( RArray<TUid>& aAppArchList,
       
   338                           RArray<TInt>& aAppArchListFlags );
       
   339 
       
   340     TBool InstallDirWidgets( const TDriveUnit& aDriveUnit,
       
   341                              CDir*& aInstalledListForDrive,
       
   342                              RArray<TInt>& aInstalledListForDriveFlags );
       
   343 
       
   344     TInt InternalizeEntryNewUidIfNeeded( CWidgetEntry* aEntry,
       
   345                                          const TDriveUnit& aDriveUnit );
       
   346 
       
   347 private:
       
   348 
       
   349     RWidgetArray                iEntries;
       
   350     RUidArray                   iUsedUids;
       
   351     RFs                         iFs; // not owned
       
   352 
       
   353     // added for validation purpose
       
   354     RApaLsSession               iAppArch;
       
   355     CWidgetInstaller*           iInstaller;
       
   356     TBuf<KWidgetRegistryMaxPathName> iWidgetInstallPath;
       
   357     TBuf<KWidgetRegistryMaxPathName> iRegistryBinaryFileName;
       
   358     TBuf<KWidgetRegistryMaxPathName> iRegistryXmlFileName;
       
   359     TBuf<KWidgetRegistryMaxPathName> iRegistryXmlTempFileName;
       
   360     TBuf<KWidgetRegistryMaxPathName> iLprojName;
       
   361 
       
   362     // map of language code to lproj dir
       
   363     RPtrHashMap<TInt,HBufC8>    iLangDirList;
       
   364     CWidgetMMCHandler*          iMMCHandler;
       
   365     TInt                        iPolicyId;
       
   366     CWidgetRegistryXml*         iXmlProcessor;
       
   367 public:
       
   368     LOG_MEMBER_VARS
       
   369     };
       
   370 
       
   371 #endif  //WIDGETREGISTRY_H