diff -r 2bb96f4ecad8 -r 8e7494275d3a omads/omadsextensions/adapters/mediads/src/omadsfolderobject.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/omads/omadsextensions/adapters/mediads/src/omadsfolderobject.cpp Tue Aug 31 15:05:37 2010 +0300 @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: COMADSFolderObject class implementation. +* +*/ + + +#include +#include "omadsfolderobject.h" +#include "logger.h" + +_LIT(KFolderBeginTag, ""); +_LIT(KFolderEndTag, ""); +_LIT(KNameBeginTag, ""); +_LIT(KNameEndTag, ""); +_LIT(KCreatedBeginTag, ""); +_LIT(KCreatedEndTag, ""); +_LIT(KModifiedBeginTag, ""); +_LIT(KModifiedEndTag, ""); +_LIT(KDateFormat, "%04d%02d%02dT%02d%02d%02d"); +const TInt KDateFormatLength( 15 ); + + +COMADSFolderObject* COMADSFolderObject::NewLC() + { + COMADSFolderObject* self = new (ELeave) COMADSFolderObject; + CleanupStack::PushL( self ); + return self; + } + +COMADSFolderObject::~COMADSFolderObject() + { + } + +void COMADSFolderObject::ExportFolderXmlL( CBufBase& aBuffer ) + { + iBuffer = &aBuffer; + iWriteBufPosition = 0; + iWriteBufSize = aBuffer.Size(); + + ExportL(); + } + +void COMADSFolderObject::ExportL() + { + // Folder + WriteL( KFolderBeginTag ); + + // Name + WriteL( KNameBeginTag ); + WriteL( iName ); + WriteL( KNameEndTag ); + + // Created Date + TBuf tempdate; + tempdate.Format( KDateFormat, iCreatedDate.Year(), iCreatedDate.Month() + 1, + iCreatedDate.Day(), iCreatedDate.Hour(), iCreatedDate.Minute(), iCreatedDate.Second() ); + + WriteL( KCreatedBeginTag ); + WriteL( tempdate ); + WriteL( KCreatedEndTag ); + + // Modified Date + tempdate.Format( KDateFormat, iModifiedDate.Year(), iModifiedDate.Month() + 1, + iModifiedDate.Day(), iModifiedDate.Hour(), iModifiedDate.Minute(), iModifiedDate.Second() ); + + WriteL( KModifiedBeginTag ); + WriteL( tempdate ); + WriteL( KModifiedEndTag ); + + // Folder end + WriteL(KFolderEndTag); + } + +void COMADSFolderObject::WriteL( const TDesC& aData ) + { + User::LeaveIfError( CnvUtfConverter::ConvertFromUnicodeToUtf8( iTemp, aData ) ); + + TInt newPosition = iWriteBufPosition + iTemp.Length(); + + if ( newPosition > iWriteBufSize ) + { + TInt expand = newPosition - iWriteBufSize; + iBuffer->ExpandL( iWriteBufSize, expand ); + iWriteBufSize += expand; + } + + iBuffer->Write( iWriteBufPosition, iTemp ); + iWriteBufPosition = newPosition; + }