btobexprofiles/obexreceiveservices/bip/src/BIPCapabilityHandler.cpp
branchRCL_3
changeset 56 9386f31cc85b
parent 55 613943a21004
child 61 269724087bed
equal deleted inserted replaced
55:613943a21004 56:9386f31cc85b
     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:  Implementation of CBIPCapabilityHandler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "BIPCapabilityHandler.h"
       
    21 #include "BIPXMLWriter.h"
       
    22 #include <imageconversion.h>
       
    23 
       
    24 // CONSTANTS
       
    25 _LIT8( KBIPXmlImagePixel, "\" pixel=\"0*0-65535*65535\"");
       
    26 _LIT8( KBIPXmlImageMaxSize, " maxsize=\"50000000\"");
       
    27 
       
    28 const TInt KBIPMaxTypeLenght = 256;
       
    29 const TInt KBIPMaxAttrLength = 32;
       
    30 
       
    31 // MODULE DATA STRUCTURES
       
    32 
       
    33 // ================= MEMBER FUNCTIONS =======================
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // NewL
       
    37 // Two-phased constructor.
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 CBIPCapabilityHandler* CBIPCapabilityHandler::NewL()
       
    41     {
       
    42     TRACE_FUNC_ENTRY
       
    43     CBIPCapabilityHandler* self = new ( ELeave ) CBIPCapabilityHandler();
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL();
       
    46     CleanupStack::Pop(self);
       
    47     return( self );
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------
       
    51 // CBIPCapabilityHandler()
       
    52 // ---------------------------------------------------------
       
    53 //
       
    54 CBIPCapabilityHandler::CBIPCapabilityHandler()
       
    55     {
       
    56     TRACE_FUNC_ENTRY
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CreateCapabilityObjectL()
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 void CBIPCapabilityHandler::CreateCapabilityObjectL( TFileName& aFileName )
       
    64     {
       
    65     TRACE_FUNC_ENTRY
       
    66     iBIPXmlWriter = CBIPXmlWriter::NewL();
       
    67     iBIPXmlWriter->OpenXmlDocumentL( aFileName );
       
    68     SupportedImageTypesL();
       
    69     TBufC8<KBIPMaxAttrLength> pixelRange( KBIPXmlImagePixel );
       
    70     TBufC8<KBIPMaxAttrLength> maxSize( KBIPXmlImageMaxSize );
       
    71     TBufC8<KBIPMaxAttrLength> encoding;
       
    72     for( TInt index = 0; index < iImageTypeArray->Count(); index++ )
       
    73         {
       
    74         encoding = iImageTypeArray->MdcaPoint( index );
       
    75         iBIPXmlWriter->OpenXmlElementL( EImageFormats );
       
    76         iBIPXmlWriter->AddXmlAttributeL( EEncoding, encoding );
       
    77         iBIPXmlWriter->AddXmlAttributeL( EPixel, pixelRange );
       
    78         iBIPXmlWriter->AddXmlAttributeL( EMaxSize, maxSize );
       
    79         iBIPXmlWriter->CloseXmlElementL();
       
    80         }
       
    81     iBIPXmlWriter->CloseXmlDocumentL();
       
    82     TRACE_FUNC_EXIT
       
    83     }    
       
    84 
       
    85 // ---------------------------------------------------------
       
    86 // SupportedImageTypesL()
       
    87 // ---------------------------------------------------------
       
    88 //
       
    89 void CBIPCapabilityHandler::SupportedImageTypesL( )
       
    90     {   
       
    91     TRACE_FUNC_ENTRY
       
    92     TInt retVal = KErrNone;
       
    93 	RFileExtensionMIMETypeArray theFileExtensionArray;
       
    94 	iImageTypeArray->Reset();
       
    95 
       
    96     TRAP( retVal, CImageDecoder::GetFileTypesL( theFileExtensionArray ) );	
       
    97 	if( retVal != KErrNone )
       
    98 		{
       
    99 		theFileExtensionArray.ResetAndDestroy();
       
   100         User::Leave( retVal );
       
   101 		}
       
   102     
       
   103     HBufC8* name = HBufC8::NewLC( KBIPMaxTypeLenght );
       
   104 	for( TInt index = 0; index < theFileExtensionArray.Count(); index++ )
       
   105 		{
       
   106 		CFileExtensionMIMEType& fileExtAndMIMEType = *theFileExtensionArray[index];
       
   107         name->Des().Copy( fileExtAndMIMEType.DisplayName() );
       
   108 
       
   109         TInt dummy;
       
   110         retVal = iImageTypeArray->Find( name->Des(), dummy );
       
   111         if( retVal != KErrNone )
       
   112             {
       
   113             iImageTypeArray->AppendL( name->Des() );
       
   114             }
       
   115         name->Des().Zero();
       
   116         }
       
   117     CleanupStack::PopAndDestroy(name);  
       
   118 
       
   119 	theFileExtensionArray.ResetAndDestroy();
       
   120     TRACE_FUNC_EXIT
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------
       
   124 // ConstructL()
       
   125 // ---------------------------------------------------------
       
   126 //
       
   127 void CBIPCapabilityHandler::ConstructL()
       
   128     {
       
   129     TRACE_FUNC_ENTRY
       
   130     iImageTypeArray = new (ELeave) CDesC8ArrayFlat(1);
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------
       
   134 // ~CBIPCapabilityHandler()
       
   135 // ---------------------------------------------------------
       
   136 //
       
   137 CBIPCapabilityHandler::~CBIPCapabilityHandler()
       
   138     {
       
   139     TRACE_FUNC
       
   140     delete iBIPXmlWriter;
       
   141     delete iImageTypeArray;
       
   142     }
       
   143 
       
   144 //  End of File