javamanager/javasettings/appmngrplugin/inc/appmngr2midletmanifestreader.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     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:  CManifestReader header file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef APPMNGR2MIDLETMANIFESTREADER_H
       
    20 #define APPMNGR2MIDLETMANIFESTREADER_H
       
    21 
       
    22 #include <f32file.h>
       
    23 #include <e32base.h>
       
    24 #include <caf/data.h>
       
    25 #include <memory>
       
    26 #include <mjavaattribute.h>
       
    27 
       
    28 using namespace Java;
       
    29 
       
    30 /**
       
    31  * CManifestReader is a simple utility class to read manifest content.
       
    32  * It validates only attribute name parameter and parses all attributes
       
    33  * from the manifest file.
       
    34  */
       
    35 class AppMngr2MidletManifestReader : public CBase
       
    36 {
       
    37 public:
       
    38 
       
    39     AppMngr2MidletManifestReader(RFs& aFs);
       
    40     ~AppMngr2MidletManifestReader();
       
    41 
       
    42     /**
       
    43      * Read manifest file from the JAR file or read plain manifest file.
       
    44      *
       
    45      * @param aManifestFileName Manifest file name inside JAR package or
       
    46      *        path to plain manifest file. If ManifestParser is created
       
    47      *        with CJavaFileHandle, then file handle is used and manifest
       
    48      *        file name is ignored.
       
    49      * @param aAttributes Array is populated with manifest attributes.
       
    50      */
       
    51     void ReadManifestL(const TDesC& aManifestFileName,
       
    52                        RPointerArray<MJavaAttribute>& aAttributes);
       
    53 
       
    54 private:
       
    55 
       
    56     /**
       
    57      * Read manifest file to buffer.
       
    58      *
       
    59      * @param aManifestFileName Manifest file name inside JAR package or
       
    60      *        path to plain manifest file.
       
    61      */
       
    62     void ContentL(const TDesC& aManifestFileName);
       
    63 
       
    64     /**
       
    65      * Read manifest file content to buffer.
       
    66      *
       
    67      * @param  aManifestFile manifest file
       
    68      * @return A pointer to content. Ownership is transferred.
       
    69      */
       
    70     HBufC8* ReadRawManifestFileL(ContentAccess::CData& aManifestFile);
       
    71 
       
    72     /**
       
    73      * Read content from plain manifest file.
       
    74      *
       
    75      * @param aManifestFile Reference to manifest file handle.
       
    76      */
       
    77     void ReadManifestContentL(RFile& aManifestFile);
       
    78 
       
    79     /**
       
    80      * Read manifest file content from package.
       
    81      *
       
    82      * @param aPackageFile Reference to package file handle.
       
    83      */
       
    84     void ReadManifestContentFromPackageL(RFile& aPackageFile);
       
    85 
       
    86     /**
       
    87      * Read all attributes from internal buffer.
       
    88      *
       
    89      * @param aAttributes Attribute array to be populated.
       
    90      */
       
    91     void ReadAttributesL(RPointerArray<MJavaAttribute>& aAttributes);
       
    92 
       
    93     /**
       
    94      * Read one line from the internal buffer.
       
    95      *
       
    96      * @param aContinuation if line is continuation it can be shorter
       
    97      *        than attribute name line.
       
    98      * @return TInt index to internal buffer where line ends.
       
    99      */
       
   100     TInt ReadLineIndexL(TBool aContinuation);
       
   101 
       
   102     /**
       
   103      * Detect continuational line and append it to attribute value.
       
   104      *
       
   105      * @param aValue      Reference to attribute to be appended if continuational line.
       
   106      * @param aContent    Reference to manifest content
       
   107      * @param aAttributes Attribute array where attribute is stored if continuational line.
       
   108      */
       
   109     void ReadContinuationLineL(TDes16& aValue, TDes16& aContent, TInt& aIndex);
       
   110 
       
   111     /**
       
   112      * Validate Attribute name. Name can contain only
       
   113      * {A-Z} | {a-z} | {0-9} | - | _ characters.
       
   114      *
       
   115      * @param aName Attribute name
       
   116      * @exception   if invalid characters this will leave with code
       
   117      *              KJavaErrInvalidManifest
       
   118      */
       
   119     void ValidateAttributeNameL(TDesC16& aName);
       
   120 
       
   121 private:
       
   122     RFs mFs;
       
   123     bool mSessionOpen;
       
   124     std::auto_ptr<HBufC16>mManifestContent;
       
   125 };
       
   126 
       
   127 #endif // APPMNGR2MIDLETMANIFESTREADER_H
       
   128