omads/omadsextensions/adapters/bookmark/inc/omadsfolderobject.h
changeset 0 dab8a81a92de
child 3 c2b8a5ae6ed5
equal deleted inserted replaced
-1:000000000000 0:dab8a81a92de
       
     1 /*
       
     2 * Copyright (c) 2005-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:  OMA DS Folder object XML parser
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __OMADSFOLDEROBJECT_H__
       
    20 #define __OMADSFOLDEROBJECT_H__
       
    21 
       
    22 #include <f32file.h>
       
    23 #include <MSenContentHandlerClient.h>
       
    24 #include <FavouritesItem.h>
       
    25 
       
    26 
       
    27 const TInt KMaxFolderNameLength = KFavouritesMaxName;
       
    28 const TInt KMaxElementLength = 255;
       
    29 const TInt KMaxXmlLineLength = 1024;
       
    30 
       
    31 class CSenXmlReader;
       
    32 class CFolderItem;
       
    33 
       
    34 class COMADSFolderObject : public CBase, public MSenContentHandlerClient
       
    35 {
       
    36 public:
       
    37 
       
    38     static COMADSFolderObject* NewLC();
       
    39     static COMADSFolderObject* NewL();
       
    40     ~COMADSFolderObject();
       
    41     
       
    42     // Get methods
       
    43     inline const TDesC& GetName() const {return iName;}
       
    44     inline const TDateTime& GetCreatedDate() const {return iCreatedDate;}
       
    45     inline const TDateTime& GetModifiedDate() const {return iModifiedDate;}
       
    46     
       
    47     // Set methods
       
    48     inline void SetName(const TDesC& aName) {iName.Copy(aName);}
       
    49     inline void SetCreatedDate(const TDateTime& aDateTime) {iCreatedDate = aDateTime;}
       
    50     inline void SetModifiedDate(const TDateTime& aDateTime) {iModifiedDate = aDateTime;}
       
    51     
       
    52     // Import & export
       
    53     TInt ImportFolderXml(const TDesC8& aData);
       
    54     TInt ImportFolderXml(RFs& aFs, const TDesC& aFilename);
       
    55     void ExportFolderXmlL(TDes8& aBuffer);
       
    56     void ExportFolderXmlL(CBufBase& aBuffer);    
       
    57     void ExportDbItemL(CFavouritesItem& aItem);		
       
    58 	void ImportDbItem(const CFavouritesItem& aItem);
       
    59 	void ImportDbItem(const CFolderItem& aItem);
       
    60     
       
    61     // MSenContentHandlerClient virtual functionality
       
    62 	TInt StartDocument();
       
    63 	TInt EndDocument();
       
    64 	TInt StartElement(const TDesC8& aURI, 
       
    65 					  const TDesC8& aLocalName, 
       
    66 					  const TDesC8& aName, 
       
    67 					  const RAttributeArray& apAttrs);
       
    68 	TInt EndElement(const TDesC8& aURI, 
       
    69 					const TDesC8& aLocalName, 
       
    70 					const TDesC8& aName);
       
    71     TInt Characters(const TDesC8& aBuf, TInt aStart, TInt aLength);
       
    72 	TInt Error(TInt aErrorCode);
       
    73 	
       
    74 private:
       
    75     void ConstructL();
       
    76     void ExportL();	
       
    77 	void WriteL(const TDesC &aData);
       
    78 	void WriteEncodedXmlL(const TDesC &aData);
       
    79 	void ReadFolderNameL( TDes& aName, const TInt aResID );
       
    80 	void Reset();
       
    81     TInt ParseDateString(const TDesC8& aString, TDateTime& aDateTime);
       
    82 
       
    83 private:
       
    84    	CSenXmlReader*              iXmlReader;
       
    85     TBuf8<KMaxElementLength>    iCurrentElement;
       
    86     TBuf8<KMaxXmlLineLength>    iTemp;
       
    87     TBuf<KMaxFolderNameLength>  iName;
       
    88     TDateTime   iCreatedDate;
       
    89     TDateTime   iModifiedDate;
       
    90     TInt        iError;
       
    91 	CBufBase*   iBuffer;
       
    92 	TInt        iWriteBufPosition;
       
    93 	TInt        iWriteBufSize;
       
    94 	TDes8*      iDesc;
       
    95 };
       
    96 
       
    97 #endif