diff -r 4096754ee773 -r 52a167391590 localconnectivityservice/obexreceiveservices/bip/src/BIPXMLWriter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/localconnectivityservice/obexreceiveservices/bip/src/BIPXMLWriter.cpp Wed Sep 01 12:20:40 2010 +0100 @@ -0,0 +1,199 @@ +/* +* Copyright (c) 2002 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: Implementation of CBIPXMLWriter class +* +*/ + + +// INCLUDE FILES +#include "BIPXMLWriter.h" +#include + + +// CONSTANTS +_LIT8( KBIPXmlDocBegin," " ); +_LIT8( KBIPXmlDocEnd, "" ); +_LIT8( KBIPXmlImageFormatsBegin, ""); +_LIT8( KBIPImageTypes, "JPEGBMPGIFWBMPPNGJPEG2000" ); +_LIT8( KBIPUserSeries60, "USR-SERIES60-" ); + +const TInt KBIPImageTypesLength = 30; +// ================= MEMBER FUNCTIONS ======================= + +// ----------------------------------------------------------------------------- +// NewL +// Two-phased constructor. +// ----------------------------------------------------------------------------- +// +CBIPXmlWriter* CBIPXmlWriter::NewL() + { + TRACE_FUNC + CBIPXmlWriter* self = new ( ELeave ) CBIPXmlWriter(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(self); + return( self ); + } + +// --------------------------------------------------------- +// CBIPXmlWriter() +// --------------------------------------------------------- +// +CBIPXmlWriter::CBIPXmlWriter() + { + } + +// --------------------------------------------------------- +// OpenXmlDocumentL() +// --------------------------------------------------------- +// +void CBIPXmlWriter::OpenXmlDocumentL( TFileName& aFileName ) + { + TRACE_FUNC + User::LeaveIfError( iFileSession.Connect() ); + TPath tempPath; + TInt drive = TObexUtilsMessageHandler::GetMessageCentreDriveL(); + TDriveUnit driveString (drive); + User::LeaveIfError(iFileSession.CreatePrivatePath( drive )); + User::LeaveIfError(iFileSession.PrivatePath(tempPath)); + User::LeaveIfError(ifile.Temp( iFileSession, tempPath, aFileName, EFileWrite )); + User::LeaveIfError( ifile.Write( KBIPXmlDocBegin ) ); + } + +// --------------------------------------------------------- +// CloseXmlDocumentL() +// --------------------------------------------------------- +// +void CBIPXmlWriter::CloseXmlDocumentL() + { + TRACE_FUNC + User::LeaveIfError( ifile.Write( KBIPXmlDocEnd ) ); + User::LeaveIfError( ifile.Flush() ); + ifile.Close(); + iFileSession.Close(); + } + +// --------------------------------------------------------- +// OpenXmlElementL() +// --------------------------------------------------------- +// +void CBIPXmlWriter::OpenXmlElementL( TElementType aElement ) + { + switch( aElement ) + { + case EImageFormats: + { + User::LeaveIfError( ifile.Write( KBIPXmlImageFormatsBegin ) ); + break; + } + case EPreferredFormat: + { + break; + } + case EAttachmentFormats: + { + break; + } + case EFilteringParameters: + { + break; + } + case EDPOFOptions: + { + break; + } + default: + { + } + } + TRACE_FUNC + } + +// --------------------------------------------------------- +// AddXmlAttributeL() +// --------------------------------------------------------- +// +void CBIPXmlWriter::AddXmlAttributeL( TAttributeType aAttributeType, TDesC8& aAttr ) + { + TRACE_FUNC_ENTRY + TBuf8 attribute = KBIPImageTypes(); + switch( aAttributeType ) + { + case EEncoding: + { + if( attribute.Find( aAttr ) == KErrNotFound ) + { + User::LeaveIfError( ifile.Write( KBIPUserSeries60 ) ); + User::LeaveIfError( ifile.Write( aAttr ) ); + + } + else + { + User::LeaveIfError( ifile.Write( aAttr ) ); + } + break; + } + case EPixel: + { + User::LeaveIfError( ifile.Write( aAttr ) ); + break; + } + case EMaxSize: + { + User::LeaveIfError( ifile.Write( aAttr ) ); + break; + } + case ETransformation: + { + break; + } + default: + { + } + } + TRACE_FUNC_EXIT + } + +// --------------------------------------------------------- +// CloseXmlElementL() +// --------------------------------------------------------- +// +void CBIPXmlWriter::CloseXmlElementL() + { + TRACE_FUNC + User::LeaveIfError( ifile.Write( KBIPXmlImageFormatsEnd ) ); + } + +// --------------------------------------------------------- +// ConstructL() +// --------------------------------------------------------- +// +void CBIPXmlWriter::ConstructL() + { + TRACE_FUNC + } + +// --------------------------------------------------------- +// ~CBIPXmlWriter() +// --------------------------------------------------------- +// +CBIPXmlWriter::~CBIPXmlWriter() + { + TRACE_FUNC + ifile.Close(); + iFileSession.Close(); + } + +// End of File