syncmlfw/ds/settings/inc/NSmlProfileContentHandler.h
changeset 0 b497e44ab2fc
child 2 5594fba90824
equal deleted inserted replaced
-1:000000000000 0:b497e44ab2fc
       
     1 /*
       
     2 * Copyright (c) 2002 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: XML parser call back implementation to read profile setting from xml file
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __NSmlProfileContentHandler_H
       
    21 #define __NSmlProfileContentHandler_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <f32file.h>
       
    26 #include <eikenv.h> //JIM is this needed ??
       
    27 #include "MXMLAttributes.h"
       
    28 #include "MXMLContentHandler.h"
       
    29 
       
    30 #include "nsmldssettings.h"
       
    31 //#include "nsmldsresourceprofiledefs.h"
       
    32 #include <nsmldsconstants.h>
       
    33 #include <nsmlconstants.h>
       
    34 
       
    35 enum TDSparameterState
       
    36 	{
       
    37 	//Management operations
       
    38 	EProfileDisplayName,
       
    39 	EProfileServerURL,
       
    40 	EProfileIAPId,
       
    41 	EProfileTransportId,
       
    42 	EProfileSyncServerUsername,
       
    43 	EProfileSyncServerPassword,
       
    44 	EProfileServerAlertedAction,
       
    45 	EProfileDeleteAllowed,
       
    46 	EProfileHidden,
       
    47 	EProfileHttpAuthUsed,
       
    48 	EProfileHttpAuthUsername,
       
    49 	EProfileHttpAuthPassword,
       
    50 	EProfileAutoChangeIAP,
       
    51     EProfileCreatorId,   
       
    52 	EProfileServerId,
       
    53 	EProfileProtocolVersion,	
       
    54 	ESyncType,
       
    55 	EDefaultProfile,
       
    56 	EAdapterImplementationId,
       
    57 	EAdapterServerDataSource,
       
    58 	EStateHandled
       
    59 	};
       
    60 
       
    61 // CLASS DECLARATION
       
    62 
       
    63 /**
       
    64 *  Interface for SAX Parser Callback events.
       
    65 *  If an application (client) needs to be informed of basic parsing events, 
       
    66 *  it implements this interface and registers an instance with the SAX parser using the SetContentHandler() method.
       
    67 *  The parser uses the instance to report basic document-related events like the start and end of elements.
       
    68 *
       
    69 *  @lib ?library
       
    70 *  @since ?Series60_version
       
    71 */
       
    72 class CNSmlProfileContentHandler: public CBase, public MXMLContentHandler
       
    73 {
       
    74 public:
       
    75 
       
    76 
       
    77 	 /**
       
    78         * Two-phased constructor.
       
    79         */
       
    80         static CNSmlProfileContentHandler* NewL(CNSmlDSSettings* aSettings ,CNSmlProfileArray* aArray);
       
    81 
       
    82 		static CNSmlProfileContentHandler* NewLC();
       
    83         
       
    84         /**
       
    85         * Destructor.
       
    86         */
       
    87         virtual ~CNSmlProfileContentHandler();
       
    88 
       
    89 /**
       
    90 * Receive notification of the beginning of a document.
       
    91 * @since ?Series60_version
       
    92 * @param none
       
    93 * @return none
       
    94 */		
       
    95      TInt StartDocument();
       
    96 
       
    97 /**
       
    98 * Receive notification of the end of a document.
       
    99 * @since ?Series60_version
       
   100 * @param none
       
   101 * @return none
       
   102 */
       
   103 	TInt EndDocument();
       
   104 
       
   105 /**
       
   106 * Receive notification of the beginning of an element.
       
   107 * @since ?Series60_version
       
   108 * @param aURI: The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace
       
   109 *              processing is not being performed.
       
   110 * @param aLocalName: The local name (without prefix), or the empty string if Namespace processing is not being
       
   111 *                    performed.
       
   112 * @param aName: The qualified name, or the empty string if qualified names are not available.
       
   113 * @param aAttributeList: The attributes attached to the element. If there are no attributes, it shall be an 
       
   114 *                        empty Attributes object. 
       
   115 *        
       
   116 * @return none
       
   117 */
       
   118 	TInt StartElement(TDesC& aURI, TDesC& aLocalName, TDesC& aName, MXMLAttributes *aAttributeList);
       
   119 
       
   120 /**
       
   121 * Receive notification 	void ConstructL( TResourceReader& aReader, CNSmlDSSettings* aSettings );of the end of an element.
       
   122 * @since ?Series60_version
       
   123 * @param aURI: The Namespace URI, or the empty string if the element has no Namespace URI or if Namespace
       
   124 *              processing is not being performed.
       
   125 * @param aLocalName: The local name (without prefix), or the empty string if Namespace processing is not being
       
   126 *                    performed.
       
   127 * @param aName: The qualified name, or the empty string if qualified names are not available.
       
   128 * @return none
       
   129 */
       
   130 	TInt EndElement(TDesC& aURI, TDesC& aLocalName, TDesC& aName);
       
   131 
       
   132 /**
       
   133 * Receive notification of the start of a CDATA section. 
       
   134 * The contents of the CDATA section will be reported through the Characters() event. 
       
   135 * @since ?Series60_version
       
   136 * @param none. 
       
   137 * @return none.
       
   138 */
       
   139 	TInt StartCDATA();
       
   140 
       
   141 /**
       
   142 * Receive notification of the end of a CDATA section.  
       
   143 * @since ?Series60_version
       
   144 * @param none. 
       
   145 * @return none.
       
   146 */
       
   147 	TInt EndCDATA();
       
   148 
       
   149 /**
       
   150 * Receive notification of character data inside an element.
       
   151 * @since ?Series60_version
       
   152 * @param aBuff: The characters.
       
   153 * @param aStart: The start position in the character buffer.
       
   154 * @param aLength: The number of characters to use from the character buffer.
       
   155 * @return none
       
   156 */
       
   157 	TInt Charecters(TDesC& aBuf, TInt aStart, TInt aLength);
       
   158 
       
   159 /**
       
   160 * Receive notification of XML comment.
       
   161 * @since ?Series60_version
       
   162 * @param aComment: Buffer containing the comment.
       
   163 * @return none
       
   164 */
       
   165 	TInt Comment(TDesC& aComment); // JIM might need start and end index as params.
       
   166 
       
   167 /**
       
   168 * Receive notification of a processing instruction
       
   169 * @since ?Series60_version
       
   170 * @param aTarget: The processing instruction target.
       
   171 * @param aData: The processing instruction data, or null if none is supplied.
       
   172 * @return none
       
   173 */
       
   174    TInt ProcessingInstructions(TDesC& aTarget, TDesC& aData);
       
   175 
       
   176 /**
       
   177 * Receive notification of ignorable whitespace in element content.
       
   178 * @since ?Series60_version
       
   179 * @param aString: The whitespace characters.
       
   180 * @return none
       
   181 */
       
   182 	TInt IgnoreWhiteSpace(TDesC& aString); // JIM might need start and end index as params.
       
   183 
       
   184 /**
       
   185 * Receive notification of beginning of some internal and external XML entities.
       
   186 * @since ?Series60_version
       
   187 * @param aName: The name of the entity.
       
   188 * @return none
       
   189 */
       
   190 	TInt StartEntity(TDesC& aName);
       
   191 
       
   192 /**
       
   193 * Receive notification of end of XML entities.
       
   194 * @since ?Series60_version
       
   195 * @param aName: The name of the entity.
       
   196 * @return none
       
   197 */
       
   198 	TInt EndEntity(TDesC& aName);
       
   199 
       
   200 /**
       
   201 * Receive notification of a skipped entity.
       
   202 * @since ?Series60_version
       
   203 * @param aName: The name of the skipped entity.
       
   204 * @return none
       
   205 */
       
   206 	TInt SkippedEntity(TDesC& aName);
       
   207 
       
   208 /**
       
   209 * Receive notification of error situation during parsing.
       
   210 * @since ?Series60_version
       
   211 * @param aErrorCode: Error status code.
       
   212 * @param aSeverity: Error Severity.
       
   213 * @return none.
       
   214 */
       
   215 	TInt Error(TInt aErrorCode, TInt aSeverity);
       
   216     
       
   217 /**
       
   218 * Create a content type
       
   219 * @param none
       
   220 * @return none.
       
   221 */
       
   222 	void CreateContentTypeL();
       
   223 	
       
   224 /**
       
   225 * Check whether a content type is already created for the same profile
       
   226 * @param adapter ID
       
   227 * @return ETrue/EFalse.
       
   228 */
       
   229 	TBool IsContentAdded(TInt aAdapter);
       
   230 	
       
   231 /**
       
   232 * Convert XML value to a valid server alert type 
       
   233 * @param TInt xml value
       
   234 * @return TSmlServerAlertedAction type
       
   235 */
       
   236 	TSmlServerAlertedAction ServerAlertType(TInt aType);
       
   237 
       
   238 /**
       
   239 * Convert XML value to a valid sync type 
       
   240 * @param xml value
       
   241 * @return TSmlSyncType type
       
   242 */
       
   243 	TSmlSyncType SyncType(TDesC& aBuf);
       
   244 	
       
   245 /**
       
   246 * Get the resolved access point ID for a string entered in XML
       
   247 * @param xml value
       
   248 * @return TInt access point ID
       
   249 */
       
   250 	TInt AccessPointIdL(TDesC& aBuf);
       
   251 	
       
   252 /**
       
   253 * Check mandatory settings for content defention
       
   254 * @param none
       
   255 * @return ETrue/EFalse
       
   256 */
       
   257 	TBool CheckXMLContentSetting();
       
   258 	
       
   259 /**
       
   260 * Configure visibility based on value entered in xml
       
   261 * @param value
       
   262 * @return none
       
   263 */
       
   264 	void SetVisibility(TInt aValue);
       
   265 	
       
   266 /**
       
   267 * Configure visibility based on value entered in xml
       
   268 * @param value
       
   269 * @return none
       
   270 */
       
   271 	
       
   272 	void SetServerURL(TDesC &aBuf);
       
   273 
       
   274 protected:
       
   275 
       
   276 		CNSmlProfileContentHandler();
       
   277 		
       
   278 
       
   279 	private:
       
   280 		void ConstructL(CNSmlDSSettings* aSettings ,CNSmlProfileArray* aArray);
       
   281 
       
   282 private:
       
   283 
       
   284 	// List of attributes
       
   285 //	CXMLAttributes *iAttr;
       
   286 	RFile iFile;
       
   287 	RFs iSession;
       
   288 	TBuf<255> ifilename;
       
   289 	TLex16 iLex;
       
   290 
       
   291 	TDSparameterState iState;
       
   292 	TInt iCounter;
       
   293 	TInt iContentCounter;
       
   294 	
       
   295 	TBool iDSSettingInProgress;
       
   296 	TBool iDSContentInProgress;
       
   297 	
       
   298 	TBool iInvalidContent;
       
   299 	
       
   300 	CNSmlDSSettings* iSettings;
       
   301 	CArrayFixFlat<TInt>* iSyncTypeArray;
       
   302 	CArrayPtrFlat<CNSmlDSProfile>* iCustomProfileArray;
       
   303 	CArrayPtrFlat<CNSmlDSContentSettingType>* iContentArray;
       
   304 
       
   305 };
       
   306 
       
   307 
       
   308 #endif      // __NSmlProfileContentHandler_H   
       
   309             
       
   310 // End of File