widgets/widgetinstaller/inc/WidgetUIConfigHandler.h
changeset 0 dd21522fd290
child 17 c8a366e56285
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:  Widget installer info file parsing.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef WIDGETUIINFOPLISTCONFIGHANDLER_H
       
    20 #define WIDGETUIINFOPLISTCONFIGHANDLER_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <libxml2_tree.h>
       
    24 #include <WidgetRegistryConstants.h>
       
    25 #include <WidgetPropertyValue.h>
       
    26 
       
    27 // FORWARD DECLARATION
       
    28 
       
    29 
       
    30 namespace SwiUI
       
    31     {
       
    32 
       
    33     // CLASS DECLARATION
       
    34 
       
    35     /**
       
    36      *  Parse the widget info file for widget entry creation.
       
    37      *  @lib WidgetInstallerUI.lib
       
    38      *  @since 3.1
       
    39      */
       
    40     class CWidgetUIConfigHandler: public CBase
       
    41         {
       
    42     public: // constuctors and destructor
       
    43 
       
    44         /**
       
    45          * Two-phased constructor.
       
    46          */
       
    47         static CWidgetUIConfigHandler* NewL();
       
    48 
       
    49         /**
       
    50          * Destructor.
       
    51          */
       
    52         virtual ~CWidgetUIConfigHandler();
       
    53 
       
    54     public:
       
    55 
       
    56         /**
       
    57          * Parse the widget info file and create CWidgetInfo and CWidgetData
       
    58          * check for required keys and values
       
    59          *
       
    60          * @param aBuffer The buffer contains widget info file content.
       
    61          * @param aPropertyValues output filled with parsed values from buf
       
    62          * @since 3.1
       
    63          * @return none.
       
    64          */
       
    65         void ParseValidateBundleMetadataL(
       
    66             TPtr8 aBuffer,
       
    67             RPointerArray<CWidgetPropertyValue>& aPropertyValues,
       
    68             RFs& aFileSession );
       
    69 
       
    70         /**
       
    71          * Parse the localized buffer from infoPlist.strings in format of
       
    72          * CFBundleDisplayName = "localized display name"
       
    73          * and update the widgetInfo's displayname
       
    74          *
       
    75          * @param aBuffer: the buffer holding data from infoPlist.strings file
       
    76          * @param aWidgetInfo: the widget info data which contains the widget display name
       
    77          * @since 3.1
       
    78          */
       
    79         void ParseInfoLocL( TPtrC8 aBuffer,
       
    80                             RFs& aFileSession,
       
    81                             CWidgetPropertyValue& aBundleDisplayName );
       
    82 
       
    83 
       
    84     protected:
       
    85 
       
    86         /**
       
    87          * C++ default constructor.
       
    88          */
       
    89         CWidgetUIConfigHandler();
       
    90 
       
    91         /**
       
    92          * Symbian 2nd phase constructor
       
    93          */
       
    94         void ConstructL();
       
    95 
       
    96         /**
       
    97          * Traverse to the next Node
       
    98          *
       
    99          * @param aNode: current node
       
   100          * @since 3.1
       
   101          * @return next node
       
   102          */
       
   103         xmlNode* TraverseNextNode( xmlNode* aNode );
       
   104 
       
   105         /**
       
   106          * Convert a string in some encoding to UCS2.
       
   107          *
       
   108          * @param aEncoding encoding number
       
   109          * @param aUnicodeSizeMultiplier how many input bytes per unicode char
       
   110          * @param aInBuf input data
       
   111          * @param aOutBuf output data, allocated and returned to caller
       
   112          * @param aFileSession
       
   113          * @since 3.1
       
   114          * @return void
       
   115          */
       
   116         void ToUnicodeL( TInt aEncoding,
       
   117                          TInt aUnicodeSizeMultiplier,
       
   118                          TPtrC8 aInBuf, HBufC16** aOutBuf,
       
   119                          RFs& aFileSession );
       
   120 
       
   121         /**
       
   122         * Utility to bundle extraction of XML text content
       
   123         *
       
   124         * @param aEncoding input buffer encoding
       
   125         * @param aUnicodeSizeMultiplier how many bytes of input make one unicode char
       
   126         * @param aInBuf input data in encoding
       
   127         * @param aOutBuf malloc'ed output buf, caller takes ownership
       
   128         * @param aFileSession CCnvCharacterSetConverter requires it
       
   129         * @since 3.1
       
   130         * @return void
       
   131         */
       
   132         void GetContentL( RFs& aFileSession,
       
   133                           xmlDocPtr aDoc,
       
   134                           xmlNode* aNode,
       
   135                           HBufC** aContent );
       
   136 
       
   137 
       
   138         /**
       
   139          * Validate property values.
       
   140          *
       
   141          * @param aPropertyValues
       
   142          * @since 3.1
       
   143          * @return void
       
   144          */
       
   145         void ValidateL( RPointerArray<CWidgetPropertyValue>& aPropertyValues );
       
   146 
       
   147     private:
       
   148 
       
   149         enum DtdType
       
   150             {
       
   151             EDtdTypeUnknown,
       
   152             EDtdTypeApple,
       
   153             EDtdTypeNokia
       
   154             };
       
   155 
       
   156         // these index iProperties description table, not property
       
   157         // VALUES which are indexed by a TWidgetPropertyId
       
   158         enum TWidgetPropertyDescriptionId
       
   159             {
       
   160             EPropertyDescriptionAppleBundleIdentifier,     // required; string; example: com.apple.hello
       
   161             EPropertyDescriptionAppleBundleDisplayName,    // required; string; example: Hello World
       
   162             EPropertyDescriptionAppleBundleVersion,        // optional; string; example: 1.0
       
   163             EPropertyDescriptionAppleAllowFullAccess,      // optional; bool but int 0/1 internally
       
   164             // AppleAllowFullAccess is mapped to AllowNetworkAccess if that is missing, otherwise ignored
       
   165             EPropertyDescriptionNokiaIdentifier,           // required; string; example: com.nokia.hello
       
   166             EPropertyDescriptionNokiaDisplayName,          // required; string; example: Hello World
       
   167             EPropertyDescriptionNokiaVersion,              // optional; string; example: Hello World
       
   168             EPropertyDescriptionMainHTML,                  // required; string; example: HellowWorld.html
       
   169             EPropertyDescriptionAllowNetworkAccess,        // optional; bool but int 0/1 internally
       
   170             EPropertyDescriptionHeight,                    // optional; integer; example: 100
       
   171             EPropertyDescriptionWidth,                     // optional; integer; example: 100
       
   172             EPropertyDescriptionNokiaMiniViewEnable,       //optional; bool but int 0/1 internally
       
   173             EPropertyDescriptionNokiaPromptNeeded,       //optional; bool but int 0/1 internally
       
   174             // end property description list, begin special values
       
   175             EPropertyDescriptionIdCount,     // must be at end of properties
       
   176             EPropertyDescriptionIdInvalid    // must be after EPropertyDescriptionIdCount
       
   177             };
       
   178 
       
   179         TWidgetPropertyId GetPropertyId(
       
   180             const TDesC& aKeyName,
       
   181             DtdType aDtdType,
       
   182             TWidgetPropertyDescriptionId& aSpecialPropertyDescriptionId );
       
   183 
       
   184         class TWidgetProperty
       
   185             {
       
   186         public:
       
   187             TWidgetPropertyId id; // the registry value id for this name
       
   188             TPtrC name;
       
   189             TWidgetPropertyType type;
       
   190             TInt flags;
       
   191             };
       
   192 
       
   193         // Table describing properties from the bundle metadata.  Used by parser.
       
   194         TFixedArray<TWidgetProperty, EPropertyDescriptionIdCount> iProperties;
       
   195 
       
   196         DtdType iDtdType; // used by lproj processing after manifest parse
       
   197         };
       
   198     }
       
   199 #endif
       
   200 
       
   201 // End of File