btobexprofiles/obexsendservices/obexservicesendutils/src/BTSURefObjectResolver.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:  Reference object resolver
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "BTServiceUtils.h"
       
    21 #include "BTSURefObjectResolver.h"
       
    22 #include "BTSUDebug.h"
       
    23 #include <utf.h>
       
    24 
       
    25 // CONSTANTS
       
    26 _LIT8( KBTSUElementImage,    "img" );
       
    27 _LIT8( KBTSUElementLink,     "link" );
       
    28 _LIT8( KBTSUElementObject,   "object" );
       
    29 
       
    30 _LIT8( KBTSUAttributeSrc,    "src" );
       
    31 _LIT8( KBTSUAttributeData,   "data" );
       
    32 _LIT8( KBTSUAttributeHref,   "href" );
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CBTSURefObjectResolver::NewL
       
    39 // Two-phased constructor.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CBTSURefObjectResolver* CBTSURefObjectResolver::NewL(CDesCArrayFlat* aCapabilityList)
       
    43     {
       
    44     CBTSURefObjectResolver* self = new( ELeave ) CBTSURefObjectResolver( aCapabilityList );
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructL( );
       
    47     CleanupStack::Pop(self);
       
    48     return self;
       
    49     }
       
    50     
       
    51 // -----------------------------------------------------------------------------
       
    52 // CBTSURefObjectResolver::CBTSURefObjectResolver
       
    53 // C++ default constructor can NOT contain any code, that
       
    54 // might leave.
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 CBTSURefObjectResolver::CBTSURefObjectResolver( 
       
    58     CDesCArrayFlat* aObjectList ) : iObjectList( aObjectList )
       
    59     {
       
    60     }
       
    61   
       
    62  // -----------------------------------------------------------------------------
       
    63 // CBTSURefObjectResolver::ConstructL
       
    64 // Symbian 2nd phase constructor can leave.
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 void CBTSURefObjectResolver::ConstructL ()
       
    68     {
       
    69     }   
       
    70 
       
    71  
       
    72 // -----------------------------------------------------------------------------
       
    73 // Destructor
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 CBTSURefObjectResolver::~CBTSURefObjectResolver()
       
    77     {
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CBTSURefObjectResolver::OnStartDocumentL
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 void CBTSURefObjectResolver::OnStartDocumentL(const Xml::RDocumentParameters& /*aDocParam*/, TInt aErrorCode)
       
    85     {
       
    86     FLOG(_L("[BTSU]\t CBTSURefObjectResolver::OnStartDocumentL()"));
       
    87     if(aErrorCode!=KErrNone)
       
    88         {
       
    89         FLOG(_L("[BTSU]\t Error OnStartDocument"));            
       
    90         }
       
    91    
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CBTSURefObjectResolver::OnEndDocumentL
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 void CBTSURefObjectResolver::OnEndDocumentL(TInt aErrorCode)
       
    99     {
       
   100     FLOG(_L("[BTSU]\t CBTSURefObjectResolver::EndDocument()"));
       
   101     if(aErrorCode!=KErrNone)
       
   102         {
       
   103         FLOG(_L("[BTSU]\t Error EndDocument"));            
       
   104         }    
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CBTSURefObjectResolver::StartElement
       
   109 // If a certain element has a certain attribute, append the attribute's
       
   110 // value into the object list.
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CBTSURefObjectResolver::OnStartElementL(const Xml::RTagInfo& aElement, const Xml::RAttributeArray& aAttributes, 
       
   114 								 TInt aErrorCode)    
       
   115     {
       
   116     
       
   117     if(aErrorCode!=KErrNone)
       
   118         {
       
   119         FLOG(_L("[BTSU]\t Error OnStartElementL"));            
       
   120         }     
       
   121         
       
   122     RString aLocalName = aElement.LocalName();   
       
   123 
       
   124     TBuf<KBTSUMaxStringLength> conversionBuf;
       
   125     // Images
       
   126     //
       
   127     if ( aLocalName.DesC() == KBTSUElementImage /*|| aName == KBTSUElementImage()*/ )
       
   128     
       
   129         {                                                         
       
   130         // Check the attributes
       
   131         for ( TInt iCounter = 0 ; iCounter < aAttributes.Count() ; iCounter++ )
       
   132             {
       
   133             if ( aAttributes[iCounter].Attribute().LocalName().DesC() == KBTSUAttributeSrc )
       
   134                 {                              
       
   135                 User::LeaveIfError( CnvUtfConverter::ConvertToUnicodeFromUtf8( conversionBuf, aAttributes[iCounter].Value().DesC() )); 
       
   136                 if(conversionBuf.Length())               
       
   137                     iObjectList->AppendL(conversionBuf );
       
   138                 }
       
   139             }                                
       
   140            
       
   141         }
       
   142     else if ( aLocalName.DesC() == KBTSUElementObject() /*|| aName == KBTSUElementObject() */)
       
   143         {
       
   144         for ( TInt iCounter = 0 ; iCounter < aAttributes.Count() ; iCounter++ )
       
   145             {
       
   146             if ( aAttributes[iCounter].Attribute().LocalName().DesC() == KBTSUAttributeData )
       
   147                 {                              
       
   148                 User::LeaveIfError( CnvUtfConverter::ConvertToUnicodeFromUtf8( conversionBuf, aAttributes[iCounter].Value().DesC() ));   
       
   149                 if(conversionBuf.Length())                         
       
   150                     iObjectList->AppendL(conversionBuf );
       
   151                 }
       
   152             }                    
       
   153         }
       
   154 
       
   155     // Other objects
       
   156     //
       
   157     else if ( aLocalName.DesC() == KBTSUElementLink() /*|| aName == KBTSUElementLink() */)
       
   158         {
       
   159         for ( TInt iCounter = 0 ; iCounter < aAttributes.Count() ; iCounter++ )
       
   160             {
       
   161             if ( aAttributes[iCounter].Attribute().LocalName().DesC() == KBTSUAttributeHref )
       
   162                 {                              
       
   163                 User::LeaveIfError( CnvUtfConverter::ConvertToUnicodeFromUtf8( conversionBuf, aAttributes[iCounter].Value().DesC() ));                
       
   164                 if(conversionBuf.Length())            
       
   165                     iObjectList->AppendL(conversionBuf );
       
   166                 
       
   167                 }
       
   168             }                      
       
   169         }
       
   170 
       
   171     }
       
   172     
       
   173 // -----------------------------------------------------------------------------
       
   174 // CBTSURefObjectResolver::OnEndElementL
       
   175 // -----------------------------------------------------------------------------
       
   176 //    
       
   177 void CBTSURefObjectResolver::OnEndElementL(const Xml::RTagInfo& /*aElement*/, TInt /*aErrorCode*/)
       
   178     {       
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CBTSURefObjectResolver::OnContentL
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void CBTSURefObjectResolver::OnContentL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
       
   186     {   
       
   187     }
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CBTSURefObjectResolver::OnStartPrefixMappingL
       
   191 // -----------------------------------------------------------------------------
       
   192 //
       
   193 void CBTSURefObjectResolver::OnStartPrefixMappingL(const RString& /*aPrefix*/, const RString& /*aUri*/, 
       
   194 								   TInt /*aErrorCode*/)
       
   195     {    
       
   196     }
       
   197 
       
   198 // -----------------------------------------------------------------------------
       
   199 // CBTSURefObjectResolver::OnEndPrefixMappingL
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 void CBTSURefObjectResolver::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/)
       
   203     {        
       
   204     }
       
   205 
       
   206 // -----------------------------------------------------------------------------
       
   207 // CBTSURefObjectResolver::OnIgnorableWhiteSpaceL
       
   208 // -----------------------------------------------------------------------------
       
   209 //
       
   210 void CBTSURefObjectResolver::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/)
       
   211     {    
       
   212     }
       
   213 
       
   214 // -----------------------------------------------------------------------------
       
   215 // CBTSURefObjectResolver::OnSkippedEntityL
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 void CBTSURefObjectResolver::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
       
   219     {    
       
   220     }
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // CBTSURefObjectResolver::OnProcessingInstructionL
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 void CBTSURefObjectResolver::OnProcessingInstructionL(const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, 
       
   227 										  TInt /*aErrorCode*/)
       
   228     {    
       
   229     }
       
   230 
       
   231 // -----------------------------------------------------------------------------
       
   232 // CBTSURefObjectResolver::OnError
       
   233 // -----------------------------------------------------------------------------
       
   234 //
       
   235 void CBTSURefObjectResolver::OnError(TInt /*aErrorCode*/)
       
   236     {    
       
   237     }
       
   238 
       
   239 // -----------------------------------------------------------------------------
       
   240 // CBTSURefObjectResolver::GetExtendedInterface
       
   241 // -----------------------------------------------------------------------------
       
   242 //
       
   243 TAny* CBTSURefObjectResolver::GetExtendedInterface(const TInt32 /*aUid*/)
       
   244     {
       
   245  
       
   246     return NULL;   
       
   247     }
       
   248 
       
   249 //  End of File