IMPSengine/messageencoder/wbxml/src/ImpsDecodeWbXml.cpp
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2003 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:  Imps engine wbxml message decoder
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    <apparc.h>
       
    22 #include    <s32mem.h>
       
    23 #include    <utf.h>
       
    24 #include    <e32std.h>
       
    25 
       
    26 #include    "ImpsDecodewbxml.h"
       
    27 #include    "Imps_1_1_Tokens.h"
       
    28 #include    "Imps_1_2_Tokens.h"
       
    29 #include    "ImpsDataAccessorApi.h"
       
    30 #include    "ImpsErrors.h"
       
    31 #include    "ImpsWbXmlCommon.h"
       
    32 #include    "ImpsVariantAPI.h"
       
    33 #include    "impsutils.h"
       
    34 #include    "ImpsFields.h"
       
    35 #include    "ImpsDataUtils.h"
       
    36 
       
    37 //LITERALS
       
    38 // TODO: This could be changed so that the NS form the message itself is used!
       
    39 // There is no simple solution for proper attribute handling because of the callback
       
    40 // interface logic!!!
       
    41 
       
    42 _LIT8( KAttr11, " xmlns=\"http://www.wireless-village.org/TRC1.1\"");
       
    43 _LIT8( KAttr12, " xmlns=\"http://www.openmobilealliance.org/DTD/WV-TRC1.2\"");
       
    44 _LIT8( KPresSubListAttr11, " xmlns=\"http://www.wireless-village.org/PA1.1\"");
       
    45 _LIT8( KPresSubListAttr12,  " xmlns=\"http://www.openmobilealliance.org/DTD/WV-PA1.2\"");
       
    46 
       
    47 // Maximum length of the element in DTD
       
    48 const TInt KDtdElementMaxLength = 100;
       
    49 
       
    50 // ==================== LOCAL FUNCTIONS ====================
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // TagStart
       
    54 // Callback function for handling tag begin
       
    55 // Returns: NW_Status_t indicates success
       
    56 // ---------------------------------------------------------
       
    57 //
       
    58 NW_Status_t TagStart(NW_WBXML_Parser_t* aParser, void* aContext)
       
    59     {
       
    60 
       
    61     if(aParser)
       
    62     {
       
    63         ((CImpsDecodeWbXml*)aContext)->SetState(EImpsDecodeStateTagStart);
       
    64     }
       
    65     return NW_STAT_SUCCESS;
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------
       
    69 // AttributeStart
       
    70 // Callback function for handling attribute begin
       
    71 // Returns: NW_Status_t indicates success
       
    72 // ---------------------------------------------------------
       
    73 //
       
    74 NW_Status_t AttributeStart(NW_WBXML_Parser_t* aParser, void* aContext)
       
    75     {
       
    76  
       
    77     if(aParser)
       
    78     {
       
    79         ((CImpsDecodeWbXml*)aContext)->SetState(EImpsDecodeStateAttributeStart);
       
    80     }
       
    81     return NW_STAT_SUCCESS;
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // Binary
       
    86 // Callback function for handling WBXML binary data
       
    87 // Returns: NW_Status_t indicates success
       
    88 // ---------------------------------------------------------
       
    89 //
       
    90 NW_Status_t Binary(NW_WBXML_Parser_t* aParser,TUint32 aValue, void* aContext)
       
    91     {
       
    92     
       
    93     if(aParser)
       
    94     {
       
    95         NW_Status_t rcode = NW_STAT_SUCCESS;
       
    96         TRAPD(error,rcode = ((CImpsDecodeWbXml*)aContext)->StoreTokenL(aValue));
       
    97         if(error != KErrNone)
       
    98         {
       
    99             return NW_STAT_FAILURE;
       
   100         }
       
   101         else
       
   102         {
       
   103             return rcode;
       
   104         }
       
   105     }
       
   106     else
       
   107     {
       
   108         return NW_STAT_FAILURE;
       
   109     }
       
   110 
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------
       
   114 // FQTokenL
       
   115 // Callback function for handling WBXML tokens
       
   116 // Returns: NW_Status_t indicates success
       
   117 // ---------------------------------------------------------
       
   118 //
       
   119 NW_Status_t FQTokenL(NW_WBXML_Parser_t* aParser,TUint32 aFqtoken, void* aContext)
       
   120     {
       
   121 
       
   122     if(aParser)
       
   123     {
       
   124         NW_Status_t rcode = NW_STAT_SUCCESS;
       
   125         TRAPD(error,rcode = ((CImpsDecodeWbXml*)aContext)->StoreTokenL(aFqtoken));
       
   126         if(error != KErrNone)
       
   127         {
       
   128             return NW_STAT_FAILURE;
       
   129         }
       
   130         else
       
   131         {
       
   132             return rcode;
       
   133         }
       
   134     }
       
   135     return NW_STAT_FAILURE;
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------
       
   139 // InlineStringL
       
   140 // Callback function for handling WBXML inline strings
       
   141 // Returns: NW_Status_t indicates success
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 NW_Status_t InlineStringL(NW_WBXML_Parser_t* aParser,TUint32 aLength, void* aContext)
       
   145     {
       
   146     
       
   147     if(aParser)
       
   148     {
       
   149         NW_Status_t rcode = NW_STAT_SUCCESS;
       
   150         TRAPD(error,rcode = ((CImpsDecodeWbXml*)aContext)->StoreInlineStringL(aParser,aLength));
       
   151         if(error != KErrNone)
       
   152         {
       
   153             return NW_STAT_FAILURE;
       
   154         }
       
   155         else
       
   156         {
       
   157             return rcode;
       
   158         }
       
   159     }
       
   160     
       
   161     return NW_STAT_SUCCESS;
       
   162     }
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // TableStringL
       
   166 // Callback function for handling WBXML string table strings
       
   167 // Returns: NW_Status_t indicates success
       
   168 // ---------------------------------------------------------
       
   169 //
       
   170 NW_Status_t TableStringL(NW_WBXML_Parser_t* aParser,TUint32 aIndex, void* aContext)
       
   171     {
       
   172     
       
   173     if(aParser)
       
   174     {
       
   175         NW_Status_t rcode = NW_STAT_SUCCESS;
       
   176         TRAPD(error,rcode = ((CImpsDecodeWbXml*)aContext)->StoreTableStringL(aIndex));
       
   177         if(error != KErrNone)
       
   178         {
       
   179             return NW_STAT_FAILURE;
       
   180         }
       
   181         else
       
   182         {
       
   183             return rcode;
       
   184         }
       
   185     }
       
   186     else
       
   187     {
       
   188         return NW_STAT_FAILURE;
       
   189     }
       
   190     }
       
   191 
       
   192 // ---------------------------------------------------------
       
   193 // Extension
       
   194 // Callback function for handling WBXML extension tokens
       
   195 // Returns: NW_Status_t indicates success
       
   196 // ---------------------------------------------------------
       
   197 //
       
   198 NW_Status_t Extension(NW_WBXML_Parser_t* aParser,void* aContext)
       
   199     {
       
   200     
       
   201     if(aParser)
       
   202     {
       
   203         ((CImpsDecodeWbXml*)aContext)->SetState(EImpsDecodeStateExtension);
       
   204     }
       
   205     
       
   206     return NW_STAT_SUCCESS;
       
   207     }
       
   208 
       
   209 // ---------------------------------------------------------
       
   210 // Opaque
       
   211 // Callback function for handling WBXML opaque data
       
   212 // Returns: NW_Status_t indicates success
       
   213 // ---------------------------------------------------------
       
   214 //
       
   215 NW_Status_t Opaque(NW_WBXML_Parser_t* aParser,TUint32 aLength, void* aContext)
       
   216     {
       
   217     
       
   218     return(((CImpsDecodeWbXml*)aContext)->StoreOpaqueData(aParser,aLength));
       
   219     
       
   220     }
       
   221 
       
   222 // ---------------------------------------------------------
       
   223 // BinaryL
       
   224 // Callback function for handling WBXML binary data
       
   225 // Returns: NW_Status_t indicates success
       
   226 // ---------------------------------------------------------
       
   227 //
       
   228 NW_Status_t BinaryL(NW_WBXML_Parser_t* aParser,TUint32 aValue, void* aContext)
       
   229     {
       
   230     
       
   231     if(aParser)
       
   232     {
       
   233         NW_Status_t rcode = NW_STAT_SUCCESS;
       
   234         TRAPD(error,rcode = ((CImpsDecodeWbXml*)aContext)->StoreTokenL(aValue));
       
   235         if(error != KErrNone)
       
   236         {
       
   237             return NW_STAT_FAILURE;
       
   238         }
       
   239         else
       
   240         {
       
   241             return rcode;
       
   242         }
       
   243     }
       
   244     else
       
   245     {
       
   246         return NW_STAT_FAILURE;
       
   247     }
       
   248     
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------
       
   252 // StartDocument
       
   253 // Callback function for handling wbxml document header information
       
   254 // Returns: NW_Status_t indicates success
       
   255 // ---------------------------------------------------------
       
   256 //
       
   257 
       
   258 NW_Status_t StartDocument(NW_WBXML_Parser_t* aParser,
       
   259                           NW_WBXML_Document_t* aDocument, void* aContext)
       
   260     {
       
   261     
       
   262     if(aParser)
       
   263     {
       
   264         return(((CImpsDecodeWbXml*)aContext)->StoreDocument(aDocument));
       
   265     }
       
   266     return NW_STAT_SUCCESS;
       
   267 
       
   268     }
       
   269 
       
   270 // ---------------------------------------------------------
       
   271 // AttributeValue
       
   272 // Callback function for handling attribute value
       
   273 // Returns: NW_Status_t indicates success
       
   274 // ---------------------------------------------------------
       
   275 //
       
   276 NW_Status_t AttributeValue(NW_WBXML_Parser_t* aParser, void* aContext)
       
   277     {
       
   278     
       
   279     if(aParser)
       
   280     {
       
   281         ((CImpsDecodeWbXml*)aContext)->SetState(EImpsDecodeStateAttributeValue);
       
   282     }
       
   283     
       
   284     return NW_STAT_SUCCESS;
       
   285     }
       
   286 
       
   287 // ---------------------------------------------------------
       
   288 // TagEndL
       
   289 // Callback function for handling tag end
       
   290 // Returns: NW_Status_t indicates success
       
   291 // ---------------------------------------------------------
       
   292 //
       
   293 
       
   294 NW_Status_t TagEndL(NW_WBXML_Parser_t* aParser, void* aContext)
       
   295     {
       
   296     
       
   297     if(aParser)
       
   298     {   
       
   299         NW_Status_t rcode = NW_STAT_SUCCESS;
       
   300         TRAPD(error,rcode = ((CImpsDecodeWbXml*)aContext)->TagEndHandleL( ));
       
   301         if(error != KErrNone)
       
   302         {
       
   303             return NW_STAT_FAILURE;
       
   304         }
       
   305         else
       
   306         {
       
   307             return rcode;
       
   308         }
       
   309     }
       
   310     else
       
   311     {
       
   312         return NW_STAT_FAILURE;
       
   313     }
       
   314     
       
   315     }
       
   316 
       
   317 // ---------------------------------------------------------
       
   318 // Content
       
   319 // Callback function for handling WBXML content
       
   320 // Returns: NW_Status_t indicates success
       
   321 // ---------------------------------------------------------
       
   322 //
       
   323 NW_Status_t Content(NW_WBXML_Parser_t* aParser, void* aContext)
       
   324     {
       
   325 
       
   326     if(aParser)
       
   327     {
       
   328         ((CImpsDecodeWbXml*)aContext)->SetState(EImpsDecodeStateContent);
       
   329     }
       
   330     
       
   331     return NW_STAT_SUCCESS;
       
   332     
       
   333     }
       
   334 
       
   335 // ---------------------------------------------------------
       
   336 // EntityL
       
   337 // Callback function for handling WBXML entity
       
   338 // Returns: NW_Status_t indicates success
       
   339 // ---------------------------------------------------------
       
   340 //
       
   341 NW_Status_t EntityL(NW_WBXML_Parser_t* aParser, TUint32 aValue, void* aContext)
       
   342     {
       
   343     
       
   344     if(aParser)
       
   345     {
       
   346         if(aValue)
       
   347         {
       
   348             TRAPD(error, ((CImpsDecodeWbXml*)aContext)->DecodeEntityL(aValue));
       
   349             if(error != KErrNone)
       
   350             {
       
   351                 return NW_STAT_FAILURE;
       
   352             }
       
   353         }
       
   354     }
       
   355     
       
   356     return NW_STAT_SUCCESS;
       
   357     
       
   358     }
       
   359 
       
   360 // ---------------------------------------------------------
       
   361 // Exception
       
   362 // Callback function for handling WBXML parser exceptions
       
   363 // Returns: NW_Status_t indicates success
       
   364 // ---------------------------------------------------------
       
   365 //
       
   366 NW_Status_t Exception(NW_WBXML_Parser_t* aParser,NW_WBXML_Exception_t aException, void* aContext)
       
   367     {
       
   368     
       
   369     if(aParser)
       
   370     {
       
   371     
       
   372         ((CImpsDecodeWbXml*)aContext)->ExceptionHandle(aException);
       
   373     }
       
   374     
       
   375     return NW_STAT_FAILURE;
       
   376     
       
   377     }
       
   378 
       
   379 // ================= MEMBER FUNCTIONS =======================
       
   380 
       
   381 // C++ default constructor can NOT contain any code, that
       
   382 // might leave.
       
   383 //
       
   384 CImpsDecodeWbXml::CImpsDecodeWbXml():
       
   385     iDecodeToXml(EFalse),
       
   386     iTransactions(0),
       
   387     iTypeStatus(EFalse),
       
   388     iPureMessageType( EImpsMessageNone )
       
   389     {
       
   390     
       
   391     }
       
   392 
       
   393 // default constructor can leave.
       
   394 void CImpsDecodeWbXml::ConstructL()
       
   395     {
       
   396         // create buffers for data handling
       
   397     
       
   398     iStoreValue8   = HBufC8::NewL(KImpsWbXmlMaxStringLength);
       
   399     iElementValue  = HBufC8::NewL(KImpsWbXmlMaxStringLength);
       
   400     iStoreValue    = HBufC::NewL(KImpsWbXmlMaxStringLength);
       
   401 
       
   402     // create handler for wbxml data
       
   403     iWbXmlData = CImpsWbXmlData::NewL( );
       
   404 
       
   405     // PEC in use ?
       
   406     CImpsVariant* dpb = CImpsVariant::NewLC();
       
   407     if (dpb->IsFeatureSupportedL(EDpb))
       
   408     {
       
   409         iXmlUtils = CImpsXmlUtils::NewL( );
       
   410         iPEC = ETrue;
       
   411     }
       
   412     else
       
   413     {
       
   414         iXmlUtils = NULL;
       
   415         iPEC = EFalse;
       
   416     }
       
   417     CleanupStack::PopAndDestroy( );
       
   418 
       
   419     iCurrentDictionary = iDictionaryCount = 0;
       
   420     iDictionaries[iDictionaryCount++] = 
       
   421         (NW_WBXML_Dictionary_s*)&NW_Imps_1_1_WBXMLDictionary;
       
   422     iDictionaries[iDictionaryCount++] = 
       
   423         (NW_WBXML_Dictionary_s*)&NW_Imps_1_2_WBXMLDictionary;
       
   424     if(NW_WBXML_Dictionary_initialize (iDictionaryCount,iDictionaries) != NW_STAT_SUCCESS)
       
   425         {
       
   426         User::Leave(KImpsErrorEncode);
       
   427         }
       
   428 
       
   429 
       
   430     iStack = new(ELeave) CStack<NW_String_UCS2Buff_t, EFalse>();
       
   431     }
       
   432 
       
   433 // Two-phased constructor.
       
   434 CImpsDecodeWbXml* CImpsDecodeWbXml::NewL( MImpsCSPSession* /*aCallback*/ )
       
   435     {
       
   436 
       
   437     CImpsDecodeWbXml* self = new (ELeave) CImpsDecodeWbXml;
       
   438     
       
   439     CleanupStack::PushL( self );
       
   440     self->ConstructL();
       
   441     CleanupStack::Pop();
       
   442 
       
   443     return self;
       
   444     }
       
   445 
       
   446     
       
   447 // Destructor
       
   448 CImpsDecodeWbXml::~CImpsDecodeWbXml()
       
   449     {
       
   450     
       
   451     delete iWbXmlData;
       
   452     delete iStoreValue;
       
   453     delete iStoreValue8;
       
   454     delete iElementValue;
       
   455     delete iXmlUtils;
       
   456     delete iStack;
       
   457 
       
   458     NW_WBXML_Dictionary_destroy(); 
       
   459     }
       
   460 
       
   461 // ---------------------------------------------------------
       
   462 // CImpsDecodeXml::DecodeMsgAsyncL
       
   463 // ---------------------------------------------------------
       
   464 //
       
   465 TInt CImpsDecodeWbXml::DecodeMsgAsyncL( HBufC8** aBuffer )
       
   466     {
       
   467 
       
   468     // TODO: implement it!
       
   469     __ASSERT_DEBUG(aBuffer, User::Panic(KImpsPanicCategory, KErrArgument));
       
   470     delete *aBuffer;
       
   471     *aBuffer = NULL; // indicate that the ownerships was taken
       
   472     return 0;
       
   473     }
       
   474 
       
   475 // ---------------------------------------------------------
       
   476 // CImpsDecodeXml::DecodeMessageL
       
   477 // ---------------------------------------------------------
       
   478 //
       
   479 void CImpsDecodeWbXml::CancelDecoding()
       
   480     {
       
   481     // TODO: implement it!
       
   482 //    TTime finished;
       
   483 //    finished.HomeTime();
       
   484 //    TReal sec = finished.MicroSecondsFrom(started).Int64()/1000000.0;
       
   485     }
       
   486 
       
   487 
       
   488 // ---------------------------------------------------------
       
   489 // CImpsDecodeXml::DecodeMessageL
       
   490 // IMPS engine WBXML message decoder main function and API for user
       
   491 // aImpsData provides data storage for parsed out values
       
   492 // aDecodeBuffer contains message to be decoded
       
   493 // if error occurs method leaves with error code
       
   494 // ---------------------------------------------------------
       
   495 //
       
   496 void CImpsDecodeWbXml::DecodeMessageL(
       
   497     MImpsDataAccessor& aImpsData,
       
   498     HBufC8**  aDecodeBuffer )
       
   499     {
       
   500 
       
   501     __ASSERT_DEBUG(aDecodeBuffer, User::Panic(KImpsPanicCategory, KErrArgument));
       
   502     HBufC8* decodeBuffer = *aDecodeBuffer;
       
   503     *aDecodeBuffer = NULL; // indicate that the ownership was taken;
       
   504     CleanupStack::PushL(decodeBuffer); // take the message buffer
       
   505     iImpsData = &aImpsData;
       
   506         
       
   507     // initializing the XML decoder states
       
   508     iTransactions = 0;
       
   509     iDecodeToXml = EFalse;
       
   510     iTypeStatus = EFalse;
       
   511     iStack->Reset();
       
   512     //////////////////////////////////////
       
   513    
       
   514 
       
   515     // CREATE AND INITIALIZE WBXML PARSER
       
   516     NW_WBXML_Parser_t WBXML_parser;
       
   517     NW_WBXML_Parser_newInPlace(&WBXML_parser);
       
   518     WBXML_parser.ext_t_not_table_index = NW_TINYDOM_EXTENSION_TYPE_EXT_T_INTEGER;
       
   519     WBXML_parser.recursiveCallCnt = 0;
       
   520 
       
   521     // CREATE EVENT HANDLER AND SET EVENT HANDLER CALLBACK
       
   522     // FUNCTION POINTERS
       
   523     NW_WBXML_EventHandler_t WBXML_event_handler;
       
   524     WBXML_event_handler.StartDocument_CB = StartDocument;
       
   525     WBXML_event_handler.EndDocument_CB = NULL;
       
   526     WBXML_event_handler.Pi_CB = NULL;
       
   527     WBXML_event_handler.Tag_Start_CB = TagStart;
       
   528     WBXML_event_handler.Tag_End_CB = TagEndL;
       
   529     WBXML_event_handler.Attr_Start_CB = AttributeStart;
       
   530     WBXML_event_handler.Attr_Val_CB = AttributeValue;
       
   531     WBXML_event_handler.Content_CB = Content;
       
   532     WBXML_event_handler.CodePage_CB = NULL;
       
   533     WBXML_event_handler.Extension_CB = Extension;
       
   534     WBXML_event_handler.FQToken_CB = FQTokenL;
       
   535     WBXML_event_handler.InlineString_CB = InlineStringL;
       
   536     WBXML_event_handler.TableString_CB = TableStringL;
       
   537     WBXML_event_handler.Opaque_CB = Opaque;
       
   538     WBXML_event_handler.Binary_CB = BinaryL;
       
   539     WBXML_event_handler.Entity_CB = EntityL;
       
   540     WBXML_event_handler.Exception_CB = Exception;
       
   541 
       
   542         // REGISTER EVENT HANDLER TO PARSER
       
   543     NW_Status_t status = NW_WBXML_Parser_registerHandler(&WBXML_parser,&WBXML_event_handler,(void*)this);
       
   544     if(status != NW_STAT_SUCCESS)
       
   545     {
       
   546         User::Leave(KImpsErrorDecode);
       
   547     }
       
   548 
       
   549     iNameSpace = KImpsNameSpaceCspMessage;
       
   550     iPreviousNameSpace = KImpsNameSpaceCspMessage;
       
   551 
       
   552     // PREPARE PARSER AND START PARSING
       
   553 //    iVersion.Copy(KImpsMessageVersion);
       
   554     NW_WBXML_Document_t document;
       
   555 //    document.doc_type = NULL;
       
   556     NW_WBXML_Document_construct(&document,KImpsWvCsp11PublicIdentifier);
       
   557     TUint32 size = decodeBuffer->Size();
       
   558 //    iDecodeBuffer->ResizeL(size+1);
       
   559     TPtr8 p = decodeBuffer->Des();
       
   560 //    p.SetLength(size);
       
   561     const unsigned char *buffer = decodeBuffer->Ptr();
       
   562 
       
   563     // GET DATA ACCESS KEY FROM DATA STORAGE
       
   564     iAccessKey = iImpsData->NewKeyL();
       
   565 
       
   566     // change wbxml public document identifier for IOP purposes
       
   567     // Assume that Unknown ID is CSP 1.1
       
   568     if(p[KImpsWbXmlPublicID] == KImpsWbXmlPublicIdUnknown)
       
   569     {
       
   570         p[KImpsWbXmlPublicID] = KImpsWvCsp11PublicIdentifier;
       
   571     }
       
   572 
       
   573     // START PARSER
       
   574     iError = KErrNone;
       
   575     iDecodingState = EImpsDecodeStateContent;
       
   576     status = NW_WBXML_Parser_parseBuffer(&WBXML_parser,&document,(unsigned char*)buffer,size);
       
   577 
       
   578     NW_WBXML_Document_destruct(&document);
       
   579     iAccessKey->Destroy( );
       
   580 
       
   581     if(status != NW_STAT_SUCCESS)
       
   582     {
       
   583         if(iError == KErrNone)
       
   584         {
       
   585             User::Leave(KImpsErrorDecode);
       
   586         }
       
   587         else
       
   588         {
       
   589             User::Leave(iError);
       
   590         }
       
   591     }
       
   592 
       
   593     CleanupStack::PopAndDestroy(); // message buffer
       
   594     }
       
   595 
       
   596 // ---------------------------------------------------------
       
   597 // CImpsDecodeWbXml::SetState
       
   598 // method updates current parser state
       
   599 // ---------------------------------------------------------
       
   600 //
       
   601 void CImpsDecodeWbXml::SetState(TImpsDecodeState aState)
       
   602     {
       
   603     
       
   604 
       
   605     iDecodingState = aState;
       
   606     
       
   607     }
       
   608 
       
   609 // ---------------------------------------------------------
       
   610 // CImpsDecodeWbXml::StoreDocument
       
   611 // method verifies document header information
       
   612 // ---------------------------------------------------------
       
   613 //
       
   614 NW_Status_t CImpsDecodeWbXml::StoreDocument(NW_WBXML_Document_t* aDocument)
       
   615     {
       
   616     
       
   617     if(aDocument->version !=  KImpsWbXmlVersion)
       
   618     {
       
   619         return NW_STAT_FAILURE;
       
   620     }
       
   621     if(aDocument->charset !=  KImpsDefaultCharset)
       
   622     {
       
   623         return NW_STAT_FAILURE;
       
   624     }
       
   625 
       
   626     if(aDocument->publicid==KImpsWvCsp12PublicIdentifier)
       
   627         {
       
   628         iImpsData->GetImpsFields()->SetCspVersion(EImpsCspVersion12);
       
   629         }
       
   630     else // the default CSP version is 1.1
       
   631         {
       
   632         iImpsData->GetImpsFields()->SetCspVersion(EImpsCspVersion11);
       
   633         }
       
   634 
       
   635     iDocument = aDocument;
       
   636     return NW_STAT_SUCCESS;
       
   637 
       
   638     }
       
   639 
       
   640 // ---------------------------------------------------------
       
   641 // CImpsDecodeWbXml::ExceptionHandle
       
   642 // method for parser exception handling
       
   643 // ---------------------------------------------------------
       
   644 //
       
   645 void CImpsDecodeWbXml::ExceptionHandle(NW_WBXML_Exception_t aException)
       
   646     {
       
   647     
       
   648     iError = (TInt)aException;
       
   649 
       
   650     }
       
   651 
       
   652 // ---------------------------------------------------------
       
   653 // CImpsDecodeWbXml::TagEndHandleL
       
   654 // method stores parsed out data to data accessor and removes
       
   655 // token from data accessor key
       
   656 // ---------------------------------------------------------
       
   657 //
       
   658 NW_Status_t CImpsDecodeWbXml::TagEndHandleL( )
       
   659     {
       
   660     
       
   661     //////////////////////////////////////////////////////////////////////////
       
   662     if (iDecodeToXml)
       
   663         {
       
   664         if ( !iStack->IsEmpty() )
       
   665             {
       
   666             NW_String_UCS2Buff_t* nw_str = iStack->Pop();
       
   667             TBuf8<KDtdElementMaxLength> elementString;
       
   668             ConvertToDes8((TUint16*)nw_str->bytes, elementString);
       
   669             iXmlUtils->EndElementL(elementString);
       
   670             }
       
   671         else
       
   672             {
       
   673             // we are done with TransactionContent
       
   674             iDecodeToXml = EFalse;
       
   675 
       
   676             iXmlUtils->StorePureDataL(*iImpsData, iTransactions-1, iPureMessageType );
       
   677                    
       
   678             // reseting the XML decoder states
       
   679             // the transaction number is not reseted as there can be more in the message
       
   680             iDecodeToXml = EFalse;
       
   681             // reset the variable
       
   682             iPureMessageType = EImpsMessageNone;
       
   683             iNameSpace = KImpsNameSpaceCspMessage;
       
   684             iPreviousNameSpace = KImpsNameSpaceCspMessage;
       
   685             iStack->Reset();
       
   686             if (iTypeStatus)
       
   687                 {
       
   688                 iTypeStatus = EFalse;
       
   689                 iAccessKey->PopL();
       
   690                 }
       
   691             else
       
   692                 {
       
   693                 // clean the IMPS keys too
       
   694                 // POP Transaction and TransactionContent
       
   695                 iAccessKey->PopL(2);
       
   696                 return NW_STAT_SUCCESS;
       
   697                 }
       
   698 
       
   699             //////////////////////////////////////
       
   700             }
       
   701         if (!iTypeStatus)
       
   702             {
       
   703             return NW_STAT_SUCCESS;
       
   704             }
       
   705         }
       
   706 
       
   707     //////////////////////////////////////////////////////////////////////////
       
   708     
       
   709 
       
   710     TInt type = 0;
       
   711     
       
   712     if(iAccessKey->Count())
       
   713         {
       
   714         type = iImpsData->KeyTypeL(iAccessKey);
       
   715         }
       
   716     else
       
   717         {
       
   718         type = EImpsDataTypeNone;
       
   719         }
       
   720     
       
   721     if ( type == EImpsDataTypeContentData )
       
   722         {
       
   723         type = TImpsDataUtils::GetContentDataTypeL( iImpsData, ( iTransactions-1 ) );
       
   724         }
       
   725 
       
   726     if(type == EImpsDataTypeNone || type == EImpsDataTypeNotSupported)
       
   727         {
       
   728         iExtension = 0;
       
   729         iOpaque.length = 0;
       
   730         iElementValue->Des().Zero();
       
   731         }
       
   732     else if(type == EImpsDataTypeInt)
       
   733         {
       
   734         if(iExtension == NW_WBXML_EXT_T_0 || iExtension == NW_WBXML_EXT_T_1 || iExtension == NW_WBXML_EXT_T_2)
       
   735             {
       
   736             TInt value = iWbXmlData->GetImpsEngineValue(iElementToken,iExtensionValue);
       
   737             if(value != KErrNotFound) iImpsData->StoreIntegerL(iAccessKey,value);
       
   738             iExtension = 0;
       
   739             }
       
   740         else if(iOpaque.length)
       
   741             {
       
   742             TInt value = 0;
       
   743             if (iOpaque.data)
       
   744             	{
       
   745 	            for(TUint8 i=0;i<iOpaque.length;i++) 
       
   746 	                {
       
   747 	                value = (value << 8) + iOpaque.data[i];
       
   748 	                }
       
   749             	}
       
   750             iImpsData->StoreIntegerL(iAccessKey,value);
       
   751             iOpaque.length = 0;
       
   752             if(iElementToken == KImpsWbXmlContentSize)
       
   753                 {
       
   754                 iContentSize = value;
       
   755                 }
       
   756             }
       
   757         else if(iElementValue->Des().Length())
       
   758             {
       
   759             if(iExtension == NW_WBXML_EXT_I_0 || iExtension == NW_WBXML_EXT_I_1 || iExtension == NW_WBXML_EXT_I_2)
       
   760                 {
       
   761                 iExtension = 0;
       
   762                 }
       
   763             else
       
   764                 {
       
   765                 TInt value = iWbXmlData->GetImpsEngineValue(iElementToken,iElementValue->Des());
       
   766                 if(value == KImpsWbXmlDataNotFound)
       
   767                     {
       
   768                     // Try to convert the string to integer
       
   769                     TLex8 tmp(iElementValue->Des());
       
   770                     if (tmp.Val(value) != KErrNone )
       
   771                         {
       
   772                         // Cannot be converted
       
   773                         return NW_STAT_FAILURE;
       
   774                         }
       
   775                     }
       
   776                 iImpsData->StoreIntegerL(iAccessKey,value);
       
   777                 }
       
   778             iElementValue->Des().Zero();
       
   779             }
       
   780         }
       
   781     else if(type == EImpsDataTypeBoolean)
       
   782         {
       
   783         if(iExtension == NW_WBXML_EXT_T_0 || iExtension == NW_WBXML_EXT_T_1 || iExtension == NW_WBXML_EXT_T_2)
       
   784             {
       
   785             TInt value = iWbXmlData->GetImpsEngineValue(iElementToken,iExtensionValue);
       
   786             if(value != KErrNotFound)
       
   787                 {
       
   788                 iImpsData->StoreBooleanL(iAccessKey,value);
       
   789                 }
       
   790             iExtension = 0;
       
   791             }
       
   792         else if(iOpaque.length)
       
   793             {
       
   794             iImpsData->StoreBooleanL(iAccessKey,(TInt)*iOpaque.data);
       
   795             iOpaque.length = 0;
       
   796             }
       
   797         }
       
   798     else if(type == EImpsDataTypeDesc8)
       
   799         {
       
   800         iStoreValue8->Des().Zero();
       
   801         if(iExtension == NW_WBXML_EXT_T_0 || iExtension == NW_WBXML_EXT_T_1 || iExtension == NW_WBXML_EXT_T_2)
       
   802             {
       
   803             iStoreValue8->Des().Copy(iWbXmlData->GetImpsEngineDesc8Value(iElementToken,iExtensionValue));
       
   804             iExtension = 0;
       
   805             }
       
   806         if(iElementValue->Des().Length())
       
   807             {
       
   808             if(iExtension == NW_WBXML_EXT_I_0 || iExtension == NW_WBXML_EXT_I_1 || iExtension == NW_WBXML_EXT_I_2)
       
   809                 {
       
   810                 iExtension = 0;
       
   811                 }
       
   812             else
       
   813                 {
       
   814                 if((iElementValue->Des().Length() + (iStoreValue8->Des().Length()) > iStoreValue8->Des().MaxLength()))
       
   815                     {
       
   816                     HBufC8* ptr = HBufC8::NewL(iStoreValue8->Des().Length() + iElementValue->Des().Length());
       
   817                     ptr->Des().Append(iStoreValue8->Des());
       
   818                     delete iStoreValue8;
       
   819                     iStoreValue8 = ptr;
       
   820                     }
       
   821                 iStoreValue8->Des().Append(iElementValue->Des());
       
   822                 }
       
   823             iElementValue->Des().Zero();
       
   824             }
       
   825         else if(iOpaque.length)
       
   826             {
       
   827             if(((TInt)iOpaque.length + iStoreValue8->Des().Length()) > iStoreValue8->Des().MaxLength())
       
   828                 {
       
   829                 HBufC8* ptr = HBufC8::NewL(iStoreValue8->Des().Length() + iOpaque.length + 1);
       
   830                 ptr->Des().Append(iStoreValue8->Des());
       
   831                 delete iStoreValue8;
       
   832                 iStoreValue8 = ptr;
       
   833                 }
       
   834             for(TInt i=0;i<(TInt)iOpaque.length;i++)
       
   835                 {
       
   836                 iStoreValue8->Des().Append(iOpaque.data[i]);
       
   837                 }
       
   838             iOpaque.length = 0;
       
   839             }
       
   840         if(iStoreValue8->Des().Length())
       
   841             {
       
   842             iImpsData->StoreDesc8L(iAccessKey,iStoreValue8->Des());
       
   843             }
       
   844         if(iStoreValue8->Des().Length() > KImpsWbXmlMaxBufferSize)
       
   845             {
       
   846             delete iStoreValue8;
       
   847             iStoreValue8 = NULL;
       
   848             iStoreValue8 = HBufC8::NewL(KImpsWbXmlMaxStringLength);
       
   849             }
       
   850         }
       
   851     else if(type == EImpsDataTypeDesc)
       
   852         {
       
   853         iStoreValue->Des().Zero();
       
   854         if(iExtension == NW_WBXML_EXT_T_0 || iExtension == NW_WBXML_EXT_T_1 || iExtension == NW_WBXML_EXT_T_2)
       
   855             {
       
   856             TInt token = 0;
       
   857             if(iNameSpace == KImpsNameSpacePresenceSubList)
       
   858                 {
       
   859                 token = iAccessKey->GetElementL((iAccessKey->Count() - 2),iKeyType);
       
   860 //                token = iWbXmlData->GetWbXmlTokenPre(token);
       
   861                 }
       
   862             else
       
   863                 {
       
   864                 token = iElementToken;
       
   865                 }
       
   866             iStoreValue->Des().Copy(iWbXmlData->GetImpsEngineDescValue(token,iExtensionValue));
       
   867             iExtension = 0;
       
   868             }
       
   869         TPtr p = iStoreValue->Des();
       
   870         if(iElementValue->Des().Length())
       
   871             {
       
   872             if(iExtension == NW_WBXML_EXT_I_0 || iExtension == NW_WBXML_EXT_I_1 || iExtension == NW_WBXML_EXT_I_2)
       
   873                 {
       
   874                 iExtension = 0;
       
   875                 }
       
   876             else
       
   877                 {
       
   878                 if((iElementValue->Des().Length() + iStoreValue->Des().Length()) > iStoreValue->Des().MaxLength())
       
   879                     {
       
   880                     HBufC* ptr = HBufC::NewL(iElementValue->Des().Length() + iStoreValue->Des().Length());
       
   881                     ptr->Des().Append(iStoreValue->Des());
       
   882                     delete iStoreValue;
       
   883                     iStoreValue = ptr;
       
   884                     p.Set(iStoreValue->Des());
       
   885                     }
       
   886                 if(iStoreValue->Des().Length())
       
   887                     {
       
   888                     TPtrC pp = iStoreValue->Mid(p.Length());
       
   889                     p.Set((unsigned short*)pp.Ptr(),0,(p.MaxLength() - p.Length()));
       
   890                     if(CnvUtfConverter::ConvertToUnicodeFromUtf8(p,iElementValue->Des()) != KErrNone)
       
   891                         {
       
   892                         return NW_STAT_FAILURE;
       
   893                         }
       
   894                     p.Set((unsigned short*)iStoreValue->Des().Ptr(),
       
   895                         (iStoreValue->Des().Length() + iElementValue->Des().Length()),
       
   896                         iStoreValue->Des().MaxLength());
       
   897                     }
       
   898                 else
       
   899                     {
       
   900                     if(CnvUtfConverter::ConvertToUnicodeFromUtf8(p,iElementValue->Des()) != KErrNone)
       
   901                         {
       
   902                         return NW_STAT_FAILURE;
       
   903                         }
       
   904                     }
       
   905                 }
       
   906             iElementValue->Des().Zero();
       
   907             }
       
   908         // Handle also the case when String is encoded as Opaque!
       
   909         if(iOpaque.length)
       
   910             {
       
   911             if ( iElementToken == (KImpsWbXmlDateTime & KImpsTokenMask) ) 
       
   912                 {
       
   913                 // !DateTime needs special handling as it is not string!
       
   914                 // TODO: Now just ignored, needs proper date&time decoding
       
   915                 }
       
   916             else
       
   917                 {
       
   918                 // Normal String decoding
       
   919                 // Check the buffer size
       
   920                 if(((TInt)iOpaque.length + iStoreValue->Des().Length()) > iStoreValue->Des().MaxLength())
       
   921                     {
       
   922                     HBufC* ptr = HBufC::NewL(iStoreValue->Des().Length() + iOpaque.length + 1);
       
   923                     ptr->Des().Append(iStoreValue->Des());
       
   924                     delete iStoreValue;
       
   925                     iStoreValue = ptr;
       
   926                     p.Set(iStoreValue->Des());
       
   927                     }
       
   928                 // Copy the data from opaque to string format
       
   929                 for(TInt i=0;i<(TInt)iOpaque.length;i++)
       
   930                     {
       
   931                     iElementValue->Des().Append(iOpaque.data[i]);
       
   932                     }
       
   933                 // convert the UTF-8 to Unicode
       
   934                 if(iStoreValue->Des().Length())
       
   935                     {
       
   936                     // if iStoreValue has already a string which was encoded as EXT, e.g. "http://"
       
   937                     TPtrC pp = iStoreValue->Mid(p.Length());
       
   938                     p.Set((unsigned short*)pp.Ptr(),0,(p.MaxLength() - p.Length()));
       
   939                     if(CnvUtfConverter::ConvertToUnicodeFromUtf8(p,iElementValue->Des()) != KErrNone)
       
   940                         {
       
   941                         return NW_STAT_FAILURE;
       
   942                         }
       
   943                     p.Set((unsigned short*)iStoreValue->Des().Ptr(),
       
   944                         (iStoreValue->Des().Length() + iElementValue->Des().Length()),
       
   945                         iStoreValue->Des().MaxLength());
       
   946                     }
       
   947                 else
       
   948                     {
       
   949                     if(CnvUtfConverter::ConvertToUnicodeFromUtf8(p,iElementValue->Des()) != KErrNone)
       
   950                         {
       
   951                         return NW_STAT_FAILURE;
       
   952                         }
       
   953                     }
       
   954                 }
       
   955             iOpaque.length = 0;
       
   956             iElementValue->Des().Zero();
       
   957             }
       
   958         
       
   959         // FIX: empty values are now stored too
       
   960         // if this fix causes that the TransactionContent and PresenceSubList 
       
   961         // will appear in the iImpsData with zero length descriptor value
       
   962 //        if(p.Length())
       
   963 //            {
       
   964        iImpsData->StoreDescL(iAccessKey,p);
       
   965 //            }
       
   966 
       
   967        // reduce the size of the buffer if needed
       
   968        if(iStoreValue->Des().Length() > KImpsWbXmlMaxBufferSize)
       
   969             {
       
   970             delete iStoreValue;
       
   971             iStoreValue = NULL;
       
   972             iStoreValue = HBufC::NewL(KImpsWbXmlMaxStringLength);
       
   973             }
       
   974         }
       
   975         else if(type == EImpsDataTypeExt)
       
   976             {
       
   977             TPtr8 name = iElementValue->Des();
       
   978             TPtrC8 ext = iElementValue->Mid(name.Locate(NULL) + 1);
       
   979             name.SetLength(name.Locate(NULL));
       
   980             if(name.Length())
       
   981                 {
       
   982                 iImpsData->StoreExtL(iAccessKey,name,ext);
       
   983                 }
       
   984             iElementValue->Des().Zero();
       
   985             }
       
   986         if(iAccessKey->Count())
       
   987             {
       
   988             iPreviousElement = iAccessKey->GetElementL((iAccessKey->Count() - 1),iKeyType);
       
   989             iPreviousNameSpace = iNameSpace;
       
   990             iAccessKey->PopL( );
       
   991             switch(iPreviousElement)
       
   992                 {
       
   993                 case EImpsKeyTransactionContent:
       
   994                     if(iNameSpace == KImpsNameSpaceTransactionContent)
       
   995                         {
       
   996                         iPreviousNameSpace = iNameSpace;
       
   997                         iNameSpace = KImpsNameSpaceCspMessage;
       
   998                         }
       
   999                     break;
       
  1000                     
       
  1001                 case EImpsKeyPresenceSubList:
       
  1002                     if(iNameSpace == KImpsNameSpacePresenceSubList)
       
  1003                         {
       
  1004                         iPreviousNameSpace = iNameSpace;
       
  1005                         iNameSpace = KImpsNameSpaceTransactionContent;
       
  1006                         }
       
  1007                     break;
       
  1008                     
       
  1009                 default:
       
  1010                     break;
       
  1011                 }
       
  1012             }
       
  1013         
       
  1014         return NW_STAT_SUCCESS;
       
  1015         
       
  1016     }
       
  1017 
       
  1018 // ---------------------------------------------------------
       
  1019 // CImpsDecodeWbXml::StoreTokenL
       
  1020 // method for handling wbxml tokens 
       
  1021 // ---------------------------------------------------------
       
  1022 //
       
  1023 NW_Status_t CImpsDecodeWbXml::StoreTokenL(TUint32 aToken)
       
  1024     {
       
  1025     
       
  1026     TInt impskey = 0;
       
  1027     TInt index = 0;
       
  1028 
       
  1029     switch(iDecodingState)
       
  1030     {
       
  1031     
       
  1032     case EImpsDecodeStateTagStart:
       
  1033     
       
  1034         if((aToken & KImpsByteMask) == NW_WBXML_LITERAL ||
       
  1035             (aToken & KImpsByteMask) == NW_WBXML_LITERAL_A ||
       
  1036             (aToken & KImpsByteMask) == NW_WBXML_LITERAL_AC ||
       
  1037             (aToken & KImpsByteMask) == NW_WBXML_LITERAL_C)
       
  1038             {
       
  1039             iDecodingState = EImpsDecodeStateLiteral;
       
  1040             iElementToken = aToken;
       
  1041             impskey = EImpsKeyPRExt;
       
  1042             iKeyType = EImpsKeyTypePre;
       
  1043             }
       
  1044         else
       
  1045             {
       
  1046             iElementToken = aToken & KImpsTokenMask;
       
  1047             
       
  1048             //////////////////////////////////////////////////////////////////////////
       
  1049             
       
  1050             // keep track of the transaction number in case of multitrans
       
  1051             if ( iElementToken == KImpsWbXmlTransaction ) 
       
  1052                 {
       
  1053                 ++iTransactions;
       
  1054                 }
       
  1055             // Decoding directly to XML
       
  1056 
       
  1057             
       
  1058             // We have started to write the XML even we don't know the Transaction type yet
       
  1059             // If the transaction type is not what we want we have to cancel the XML processing
       
  1060             if ( iStack->Count() == 1 )
       
  1061                 {
       
  1062                 // we have only 1 element in the stack and that is  TransactionContent
       
  1063                 // now we can check the Transaction type
       
  1064                 if ( IsPureTransaction(iElementToken) ) 
       
  1065                     {
       
  1066 #ifndef _NO_IMPS_LOGGING_
       
  1067                     CImpsClientLogger::Log(_L("WBXMLdecoder: decoding to XML, TR_Key %x"), iElementToken);
       
  1068 #endif
       
  1069                     iDecodeToXml = ETrue;
       
  1070                     // store the message type to the variable
       
  1071                     iPureMessageType = iElementToken;
       
  1072                     }
       
  1073                 else
       
  1074                     {
       
  1075 #ifndef _NO_IMPS_LOGGING_
       
  1076                     CImpsClientLogger::Log(_L("WBXMLdecoder: decoding to internal, TR_Key %x"),iElementToken);
       
  1077 #endif
       
  1078                     // Not presence transaction, let's get rid of the pushed element
       
  1079                     iStack->Pop(); 
       
  1080                     }
       
  1081                 }
       
  1082 
       
  1083             if ( iDecodeToXml )
       
  1084                 {
       
  1085 
       
  1086                 NW_String_UCS2Buff_t* nw_str = NW_WBXML_Dictionary_getTagByFqToken(aToken);
       
  1087                 
       
  1088                 if ( nw_str == NULL ) 
       
  1089                     {
       
  1090                     return NW_STAT_FAILURE;
       
  1091                     }
       
  1092 
       
  1093 				iStack->PushL(nw_str);
       
  1094 				
       
  1095                 TBuf8<KDtdElementMaxLength> elementString;
       
  1096                 ConvertToDes8((TUint16*)nw_str->bytes, elementString);
       
  1097 //                iXmlUtils->WriteToBufferL(_L8("<"));
       
  1098 //                iXmlUtils->WriteToBufferL(elementString);
       
  1099                 if ( iElementToken == KImpsWbXmlPresenceSubList ) 
       
  1100                     {
       
  1101                     iXmlUtils->StartElementL(elementString, 
       
  1102                         iDocument->publicid == 0x10 ? KPresSubListAttr11() : KPresSubListAttr12());
       
  1103                     }
       
  1104                 else
       
  1105                     {
       
  1106                     iXmlUtils->StartElementL(elementString, KNullDesC8);
       
  1107                     }
       
  1108 				
       
  1109 				// Status is decoded to internal too
       
  1110                 if ( !iTypeStatus ) 
       
  1111                     {
       
  1112                     break;
       
  1113                     }
       
  1114                 }
       
  1115 
       
  1116             // check for TransactionContent
       
  1117             // because the <TransactionConent> is present in pure data we must
       
  1118             // continue also with normal decoding
       
  1119             // in the next round we will get the Transaction type and can decide
       
  1120             // whether we need to continue to decode normally
       
  1121             if(iElementToken == KImpsWbXmlTransactionContent)
       
  1122                 {
       
  1123 #ifndef _NO_IMPS_LOGGING_
       
  1124                 CImpsClientLogger::Log(_L("WBXMLdecoder: Transaction content found"));
       
  1125 #endif
       
  1126 
       
  1127                 iXmlUtils->ResetL();
       
  1128 
       
  1129                 NW_String_UCS2Buff_t* nw_str = NW_WBXML_Dictionary_getTagByFqToken(aToken);
       
  1130                 if ( nw_str == NULL ) 
       
  1131                     {
       
  1132                     return NW_STAT_FAILURE;
       
  1133                     }
       
  1134 //                TPtrC elementPtr;
       
  1135 //                elementPtr.Set((TUint16*)nw_str->bytes);
       
  1136                 // Simple UCS2 to 8bit conversion
       
  1137                 // it is safe as we have only 8bit characters
       
  1138                 TBuf8<KDtdElementMaxLength> elementString;
       
  1139                 ConvertToDes8((TUint16*)nw_str->bytes, elementString);
       
  1140 
       
  1141 //                elementString.Copy(elementPtr);
       
  1142                 iXmlUtils->StartElementL(elementString, 
       
  1143                 		iDocument->version == 0x10? KAttr11() : KAttr12());
       
  1144 //                iXmlUtils->WriteToBufferL(_L8("<"));
       
  1145 //                iXmlUtils->WriteToBufferL(elementString);
       
  1146                 iStack->PushL(nw_str);
       
  1147                 }
       
  1148 
       
  1149             //////////////////////////////////////////////////////////////////////////
       
  1150             
       
  1151             
       
  1152             if(iNameSpace == KImpsNameSpaceCspMessage && iElementToken == KImpsMessageRootElement)
       
  1153                 {
       
  1154                 iPreviousElement = EImpsKeyEND;
       
  1155                 }
       
  1156             else
       
  1157                 {
       
  1158                 switch(iNameSpace)
       
  1159                     {
       
  1160                     case KImpsNameSpaceCspMessage:
       
  1161                         //impskey = iWbXmlData->GetHeaderAccessKey(iElementToken);
       
  1162                         impskey = iElementToken;
       
  1163                         iKeyType = EImpsKeyTypeIM;
       
  1164                         break;
       
  1165                         
       
  1166                     case KImpsNameSpaceTransactionContent:
       
  1167                         //impskey = iWbXmlData->GetContentAccessKey(iElementToken);
       
  1168                         impskey = iElementToken;
       
  1169                         iKeyType = EImpsKeyTypeIM;
       
  1170                         break;
       
  1171                         
       
  1172                     case KImpsNameSpacePresenceSubList:
       
  1173                         //impskey = iWbXmlData->GetPresenceAccessKey(iElementToken);
       
  1174                         impskey = iElementToken;
       
  1175                         iKeyType = EImpsKeyTypePre;
       
  1176                         break;
       
  1177                         
       
  1178                     default:
       
  1179                         return NW_STAT_FAILURE;
       
  1180                     }
       
  1181                 
       
  1182                 // !!!! Fix for JHAU-63PBMG !!!!
       
  1183                 // Check whether the same level already exists
       
  1184                 iAccessKey->AddL(CREATEKEY(impskey,index),iKeyType);
       
  1185                 CheckIfMultipleElementsL(impskey);
       
  1186                 ////////////////////////////////////////////////
       
  1187 
       
  1188                 if(iAccessKey->Count() > 1)
       
  1189                     {
       
  1190                     if(iAccessKey->GetElementL((iAccessKey->Count() - 2),iKeyType) == EImpsKeyTransactionContent)
       
  1191                         {
       
  1192                         iImpsData->StoreEmptyL(iAccessKey);
       
  1193                         }
       
  1194                     }
       
  1195 //                if(impskey == EImpsKeyPresenceSubList && iNameSpace == KImpsNameSpaceTransactionContent)
       
  1196 //                    {
       
  1197 //                    iImpsData->StoreDescL(iAccessKey,static_cast<TPtrC>(KImpsPresenceSublist()));
       
  1198 //                    }
       
  1199                 if(!(aToken & KImpsTokenEmpty))
       
  1200                     {
       
  1201                     iImpsData->StoreEmptyL(iAccessKey);
       
  1202                     }
       
  1203                 }
       
  1204             }       
       
  1205         switch(impskey)
       
  1206         {
       
  1207         
       
  1208         case EImpsKeyTransactionContent:
       
  1209         if(iNameSpace == KImpsNameSpaceCspMessage)
       
  1210         {
       
  1211             iPreviousNameSpace = iNameSpace;
       
  1212             iNameSpace = KImpsNameSpaceTransactionContent;
       
  1213         }
       
  1214         break;
       
  1215             
       
  1216         case EImpsKeyPresenceSubList:
       
  1217         if(iNameSpace == KImpsNameSpaceTransactionContent)
       
  1218         {
       
  1219             iPreviousNameSpace = iNameSpace;
       
  1220             iNameSpace = KImpsNameSpacePresenceSubList;
       
  1221         }
       
  1222         break;
       
  1223 
       
  1224         default:
       
  1225         break;
       
  1226         
       
  1227         }
       
  1228         break;
       
  1229 
       
  1230         
       
  1231         case EImpsDecodeStateAttributeStart:
       
  1232         iAttribute = aToken & KImpsByteMask;
       
  1233         // literal attributes are ignored
       
  1234         if(iElementToken == NW_WBXML_LITERAL_A ||
       
  1235             iElementToken == NW_WBXML_LITERAL_AC)
       
  1236         {
       
  1237             break;
       
  1238         }
       
  1239         if(iElementToken == KImpsWbXmlWV_CSP_Message  && 
       
  1240             (iAttribute != KImpsWbXmlCsp11Xmlns) && (iAttribute != KImpsWbXmlCsp12Xmlns))
       
  1241         {
       
  1242             return NW_STAT_FAILURE;
       
  1243         }
       
  1244         if(iElementToken == KImpsWbXmlTransactionContent && 
       
  1245             (iAttribute != KImpsWbXmlTrc11Xmlns) && (iAttribute != KImpsWbXmlTrc12Xmlns))
       
  1246         {
       
  1247             return NW_STAT_FAILURE;
       
  1248         }
       
  1249         if(iElementToken == KImpsWbXmlPresenceSubList && 
       
  1250             (iAttribute != KImpsWbXmlPa11Xmlns) && (iAttribute != KImpsWbXmlPa12Xmlns))
       
  1251         {
       
  1252             return NW_STAT_FAILURE;
       
  1253         }
       
  1254         break;
       
  1255 
       
  1256         case EImpsDecodeStateExtension:
       
  1257         if((aToken & KImpsByteMask) == NW_WBXML_EXT_T_0 
       
  1258             || (aToken & KImpsByteMask) == NW_WBXML_EXT_T_1 
       
  1259             || (aToken & KImpsByteMask) == NW_WBXML_EXT_T_2
       
  1260             || (aToken & KImpsByteMask) == NW_WBXML_EXT_I_0
       
  1261             || (aToken & KImpsByteMask) == NW_WBXML_EXT_I_1
       
  1262             || (aToken & KImpsByteMask) == NW_WBXML_EXT_I_2
       
  1263             || (aToken & KImpsByteMask) == NW_WBXML_EXT_0
       
  1264             || (aToken & KImpsByteMask) == NW_WBXML_EXT_1
       
  1265             || (aToken & KImpsByteMask) == NW_WBXML_EXT_2)
       
  1266         {
       
  1267             iExtension = aToken & KImpsByteMask;
       
  1268             iDecodingState = EImpsDecodeStateExtensionValue;
       
  1269         }
       
  1270         break;
       
  1271         
       
  1272         case EImpsDecodeStateExtensionValue:
       
  1273             {
       
  1274             iExtensionValue = aToken;
       
  1275             //////////////////////////////////////////////////////////////////////////
       
  1276             
       
  1277             if (iDecodeToXml)
       
  1278                 {
       
  1279                 
       
  1280                 NW_String_UCS2Buff_t* nw_str = 
       
  1281                     NW_WBXML_Dictionary_getAttributeNameByToken
       
  1282                         (
       
  1283                         iDictionaries[iCurrentDictionary], 
       
  1284                         (NW_Uint16)aToken //conversion from 32 to 16 is OK since
       
  1285                                           // we have masked it already
       
  1286                         );
       
  1287 
       
  1288                 if ( nw_str == NULL ) 
       
  1289                     {
       
  1290                     return NW_STAT_FAILURE; 
       
  1291                     }
       
  1292 
       
  1293                 TPtrC elementPtr;
       
  1294                 elementPtr.Set((TUint16*)nw_str->bytes);
       
  1295                 
       
  1296                 // Simple UCS2 to 8bit conversion
       
  1297                 // it is safe as we have only 8bit characters
       
  1298                 TBuf8<100> valueString;
       
  1299                 valueString.Copy(elementPtr);
       
  1300                 
       
  1301 
       
  1302                 iXmlUtils->WriteToBufferL(valueString);
       
  1303                 if (!iTypeStatus)
       
  1304                     {
       
  1305                     // in case of not Status transaction we must break
       
  1306                     break;
       
  1307                     }
       
  1308 
       
  1309                 }
       
  1310             //////////////////////////////////////////////////////////////////////////
       
  1311             
       
  1312 
       
  1313 //////////////////////////////////////////////////////////////////////////
       
  1314             // FIX: extension embedded in string. Only EImpsDataTypeDesc
       
  1315             // is supported now!
       
  1316             TInt type = 0;
       
  1317             if( iAccessKey->Count() )
       
  1318                 {
       
  1319                 type = iImpsData->KeyTypeL(iAccessKey);
       
  1320                 }
       
  1321             else
       
  1322                 {
       
  1323                 type = EImpsDataTypeNone;
       
  1324                 }
       
  1325 
       
  1326             if( type == EImpsDataTypeDesc )
       
  1327                 {
       
  1328                 // decode the EXTENSION as string
       
  1329                 TInt token = 0;
       
  1330                 if(iNameSpace == KImpsNameSpacePresenceSubList)
       
  1331                     {
       
  1332                     token = iAccessKey->GetElementL((iAccessKey->Count() - 2),iKeyType);
       
  1333                     //token = iWbXmlData->GetWbXmlTokenPre(token);
       
  1334                     }
       
  1335                 else
       
  1336                     {
       
  1337                     token = iElementToken;
       
  1338                     }
       
  1339                 iElementValue->Des().Append(iWbXmlData->GetImpsEngineDescValue(token,iExtensionValue));
       
  1340                 iExtension = 0;
       
  1341                 }
       
  1342 //////////////////////////////////////////////////////////////////////////
       
  1343             break;
       
  1344             }
       
  1345 
       
  1346        default:
       
  1347   
       
  1348            break;
       
  1349     }
       
  1350     
       
  1351     return(NW_STAT_SUCCESS);
       
  1352     
       
  1353     }
       
  1354 
       
  1355 // ---------------------------------------------------------
       
  1356 // CImpsDecodeWbXml::DecodeEntityL
       
  1357 // method decodes WBXML entity value
       
  1358 // ---------------------------------------------------------
       
  1359 //
       
  1360 NW_Status_t CImpsDecodeWbXml::DecodeEntityL(TUint32 aValue)
       
  1361     {
       
  1362     
       
  1363     NW_String_t string;
       
  1364 
       
  1365     string.storage = (TUint8*)&aValue;
       
  1366     string.length = 1;
       
  1367     StoreStringL(string);
       
  1368 
       
  1369     return NW_STAT_SUCCESS;
       
  1370     
       
  1371     }
       
  1372 
       
  1373 // ---------------------------------------------------------
       
  1374 // CImpsDecodeWbXml::StoreString
       
  1375 // method stores parsed out string
       
  1376 // ---------------------------------------------------------
       
  1377 //
       
  1378 void CImpsDecodeWbXml::StoreStringL(NW_String_t aString)
       
  1379     {
       
  1380     
       
  1381     TPtrC8 p8((TUint8*)aString.storage,aString.length);
       
  1382     
       
  1383     //////////////////////////////////////////////////////////////////////////
       
  1384     
       
  1385     if ( iDecodeToXml ) 
       
  1386         {
       
  1387         iXmlUtils->WriteToBufferL(iXmlUtils->EscapeXmlL(p8));
       
  1388         if ( !iTypeStatus ) 
       
  1389             {
       
  1390             return;
       
  1391             }
       
  1392         }
       
  1393     //////////////////////////////////////////////////////////////////////////
       
  1394     
       
  1395     if((p8.Length() + iElementValue->Des().Length()) > iElementValue->Des().MaxLength())
       
  1396     {
       
  1397         HBufC8* ptr = HBufC8::NewL(p8.Length() + iElementValue->Des().Length() + 1);
       
  1398         ptr->Des().Append(iElementValue->Des());
       
  1399         delete iElementValue;
       
  1400         iElementValue = ptr;
       
  1401     }
       
  1402     
       
  1403     if(!iElementValue)
       
  1404     {    
       
  1405         iElementValue  = HBufC8::NewL(KImpsWbXmlMaxStringLength);
       
  1406     }
       
  1407    
       
  1408 	   iElementValue->Des().Append(p8);
       
  1409     
       
  1410     }
       
  1411 
       
  1412 // ---------------------------------------------------------
       
  1413 // CImpsDecodeWbXml::StoreTableStringL
       
  1414 // method stores WBXML table string value
       
  1415 // ---------------------------------------------------------
       
  1416 //
       
  1417 NW_Status_t CImpsDecodeWbXml::StoreTableStringL(TUint32 aIndex)
       
  1418     {
       
  1419 
       
  1420     
       
  1421     NW_Status_t rcode = NW_STAT_SUCCESS;
       
  1422     TInt maxlength = 0;
       
  1423     NW_String_t string;
       
  1424 
       
  1425     if((rcode = NW_WBXML_Document_getTableString(iDocument,aIndex,&string)) == NW_STAT_SUCCESS)
       
  1426     {
       
  1427         switch(iDecodingState)
       
  1428         {
       
  1429  
       
  1430         case EImpsDecodeStateAttributeValue:
       
  1431             if(iElementToken == KImpsWbXmlWV_CSP_Message ||
       
  1432                iElementToken == KImpsWbXmlTransactionContent ||
       
  1433                iElementToken == KImpsWbXmlPresenceSubList)
       
  1434                {
       
  1435 //                    TPtrC8 p8((TUint8*)string.storage);
       
  1436 //                    if((iVersion.Match(p8)))
       
  1437 //                    {
       
  1438 //                        rcode = NW_STAT_FAILURE;
       
  1439 //                        iError = KImpsErrorCSPVersion;
       
  1440 //                    }
       
  1441                     string.length = 0;
       
  1442                }
       
  1443                break;
       
  1444 
       
  1445         
       
  1446         // check string length  
       
  1447         case EImpsDecodeStateContent:        
       
  1448             iWbXmlData->GetWbXmlElementValue(iElementToken,0,maxlength);
       
  1449             // string length checking removed !!!
       
  1450             string.length--;
       
  1451             StoreStringL(string);
       
  1452             break;
       
  1453 
       
  1454         case EImpsDecodeStateLiteral:
       
  1455         	// APIClient is literal
       
  1456         	{
       
  1457         	TPtrC8 element((TUint8*)string.storage,string.length-1);
       
  1458         	if (element.CompareF( _L8("APIClient")/*KImpsAPIClient_8*/ ) == 0)
       
  1459         		{
       
  1460         		iAccessKey->AddL(CREATEKEY(KImpsKeyAPIClient,0),EImpsKeyTypeIM);
       
  1461         		}
       
  1462             break;
       
  1463 			}
       
  1464             
       
  1465         default:
       
  1466             break;
       
  1467             
       
  1468         }
       
  1469     }
       
  1470 
       
  1471    
       
  1472     return(rcode);
       
  1473     
       
  1474     }
       
  1475 
       
  1476 // ---------------------------------------------------------
       
  1477 // CImpsDecodeWbXml::StoreInlineStringL
       
  1478 // method stores WBXML inline string value
       
  1479 // ---------------------------------------------------------
       
  1480 //
       
  1481 NW_Status_t CImpsDecodeWbXml::StoreInlineStringL(NW_WBXML_Parser_t* aParser,TInt aLength)
       
  1482     {
       
  1483     
       
  1484     
       
  1485     NW_Status_t rcode = NW_STAT_SUCCESS;
       
  1486     NW_String_t string;
       
  1487 
       
  1488     // check string length
       
  1489     if(!aLength)
       
  1490     {
       
  1491         return NW_STAT_FAILURE;
       
  1492     }
       
  1493     if(iDecodingState == EImpsDecodeStateContent)
       
  1494     {
       
  1495         TInt maxlength = 0;
       
  1496         iWbXmlData->GetWbXmlElementValue(iElementToken,0,maxlength);
       
  1497         // string length checking removed !!!
       
  1498     }
       
  1499 
       
  1500     if((rcode = NW_WBXML_Parser_getStringInline(aParser,iDocument,&string)) == NW_STAT_SUCCESS)
       
  1501     {
       
  1502         switch(iDecodingState)
       
  1503         {
       
  1504 
       
  1505         case EImpsDecodeStateAttributeValue:
       
  1506             if(iElementToken == KImpsWbXmlWV_CSP_Message ||
       
  1507                iElementToken == KImpsWbXmlTransactionContent ||
       
  1508                iElementToken == KImpsWbXmlPresenceSubList)   
       
  1509             {
       
  1510 //                TPtrC8 p8((TUint8*)string.storage);
       
  1511 //                if((iVersion.Match(p8)))
       
  1512 //                {
       
  1513 //                    rcode = NW_STAT_FAILURE;
       
  1514 //                    iError = KImpsErrorCSPVersion;
       
  1515 //                }
       
  1516                 string.length = 0;    
       
  1517             }
       
  1518             break;
       
  1519     
       
  1520         case EImpsDecodeStateContent:
       
  1521             string.length = aLength - 1;
       
  1522             StoreStringL(string);
       
  1523             break;
       
  1524         
       
  1525         default:
       
  1526             break;
       
  1527         }
       
  1528     }
       
  1529 
       
  1530     return(rcode);
       
  1531     
       
  1532     }
       
  1533 
       
  1534 // ---------------------------------------------------------
       
  1535 // CImpsDecodeWbXml::StoreOpaqueData
       
  1536 // method stores WBXML opaque data value
       
  1537 // ---------------------------------------------------------
       
  1538 //
       
  1539 NW_Status_t CImpsDecodeWbXml::StoreOpaqueData(NW_WBXML_Parser_t* aParser,TUint32 aLength)
       
  1540     {
       
  1541     
       
  1542     NW_Status_t status = NW_STAT_SUCCESS;
       
  1543     switch(iDecodingState)
       
  1544     {
       
  1545     
       
  1546     case EImpsDecodeStateContent:
       
  1547         if(aLength)
       
  1548         {
       
  1549             status = NW_WBXML_Parser_getOpaque(aParser,aLength,&iOpaque);
       
  1550             
       
  1551             //////////////////////////////////////////////////////////////////////////
       
  1552             if ( iDecodeToXml ) 
       
  1553                 {
       
  1554 
       
  1555                 // NOTE: Only integer encoded as opaque is supported
       
  1556                 // String cannot be encoded as opaque !!!
       
  1557                 TBuf8<100> valueString;
       
  1558                 // Copy the data from opaque to string format
       
  1559                 TInt value = 0;
       
  1560                 for(TUint8 i=0;i<iOpaque.length;i++) 
       
  1561                     {
       
  1562                     value = (value << 8) + iOpaque.data[i];
       
  1563                     }
       
  1564                 valueString.AppendNum(value);
       
  1565 //                for(TInt i=0;i<(TInt)iOpaque.length;i++)
       
  1566 //                    {
       
  1567 //                    valueString.Append(iOpaque.data[i]);
       
  1568 //                    }
       
  1569 
       
  1570                 TRAPD(err, iXmlUtils->WriteToBufferL( valueString ));
       
  1571                 if (err)
       
  1572                     {
       
  1573                     status = NW_STAT_FAILURE;
       
  1574                     }
       
  1575                 if ( !iTypeStatus ) 
       
  1576                     {
       
  1577                     iOpaque.length = 0; // consume the opaque data
       
  1578                     }
       
  1579                 }
       
  1580             //////////////////////////////////////////////////////////////////////////
       
  1581             
       
  1582         }
       
  1583         else // aLength == 0
       
  1584         	{
       
  1585         	// 0 must be also included in case when it was in WBXML like "C3 00"
       
  1586         	// NOTE: the data is still NULL!!!
       
  1587         	iOpaque.length = 1;
       
  1588         	}
       
  1589     break;
       
  1590 
       
  1591     case EImpsDecodeStateAttributeValue:
       
  1592         break;
       
  1593 
       
  1594     default:      
       
  1595         break;
       
  1596     }
       
  1597     
       
  1598     return(status);
       
  1599 
       
  1600     }
       
  1601 
       
  1602 
       
  1603 // ---------------------------------------------------------
       
  1604 // CImpsDecodeWbXml::CheckIfMultipleElementsL
       
  1605 // Creating the index in case of multiple elements
       
  1606 // ---------------------------------------------------------
       
  1607 
       
  1608 
       
  1609 void CImpsDecodeWbXml::CheckIfMultipleElementsL(TInt aImpsKey)
       
  1610     {
       
  1611     TInt index ( 0 );
       
  1612     switch ( aImpsKey )
       
  1613         {
       
  1614         case EImpsKeyTransaction: // for MultiTrans
       
  1615         case EImpsKeyUserID:
       
  1616         case EImpsKeyGroupID:
       
  1617         case EImpsKeyMessageID:
       
  1618         case EImpsKeyScreenName:
       
  1619         case EImpsKeyUser:
       
  1620         case EImpsKeyGroup: 
       
  1621         case EImpsKeyProperty:
       
  1622         case EImpsKeyPresence:
       
  1623         case EImpsKeySearchPairList:
       
  1624         case EImpsKeyDetailedResult:
       
  1625         case EImpsKeyContactList:
       
  1626         case EImpsKeyPresenceSubList:
       
  1627         case EImpsKeyMessageInfo:
       
  1628         case EImpsKeyAcceptedCharSet:
       
  1629         case EImpsKeyAcceptedContentType:
       
  1630         case EImpsKeyAcceptedTransferEncoding:
       
  1631         case EImpsKeySupportedBearer:
       
  1632         case EImpsKeySupportedCIRMethod:
       
  1633         case EImpsKeyNickName:
       
  1634         case EImpsKeyMapping:
       
  1635             while ( iImpsData->CheckBranchExistenceL( iAccessKey ) )
       
  1636                 {
       
  1637                 iAccessKey->PopL();
       
  1638                 ++index;
       
  1639                 iAccessKey->AddL( CREATEKEY( aImpsKey, index ) );
       
  1640                 }
       
  1641             break;
       
  1642         default:
       
  1643             break;
       
  1644         }
       
  1645     switch ( aImpsKey )
       
  1646         {
       
  1647         case EImpsKeyPRCommC:
       
  1648         case EImpsKeyPRAddrPref:
       
  1649             while ( iImpsData->CheckBranchExistenceL( iAccessKey ) )
       
  1650                 {
       
  1651                 iAccessKey->PopL();
       
  1652                 ++index;
       
  1653                 iAccessKey->AddL( CREATEKEY( aImpsKey, index ), EImpsKeyTypePre );
       
  1654                 }
       
  1655             break;
       
  1656         default:
       
  1657             break;
       
  1658         }
       
  1659     }
       
  1660 
       
  1661 // ---------------------------------------------------------
       
  1662 // CImpsDecodeXml::TrConToXmlL
       
  1663 // ---------------------------------------------------------
       
  1664 //void CImpsDecodeWbXml::TrConToXmlL ( MImpsDataAccessor& aImpsData)
       
  1665 //    {
       
  1666 //    
       
  1667 //    // pure data handle
       
  1668 //    if(iXmlUtils)
       
  1669 //    {
       
  1670 //        iXmlUtils->TransactionContentToXmlL(aImpsData);
       
  1671 //    }
       
  1672 //    
       
  1673 //    }    
       
  1674 //
       
  1675 //
       
  1676 // ---------------------------------------------------------
       
  1677 // NewDecoderL()
       
  1678 // function creates new wbxml decoder instance
       
  1679 // Returns: C-class entity of abstract MImpsDecoder class
       
  1680 // ---------------------------------------------------------
       
  1681 //
       
  1682 
       
  1683 EXPORT_C GLDEF_C MImpsDecoder* NewDecoderL( MImpsCSPSession* aCallback )
       
  1684     {
       
  1685     
       
  1686     return (MImpsDecoder*) CImpsDecodeWbXml::NewL( aCallback );
       
  1687     
       
  1688     }
       
  1689 
       
  1690 // ---------------------------------------------------------
       
  1691 // CImpsDecodeWbXml::Destroy
       
  1692 // decoder destructor 
       
  1693 // ---------------------------------------------------------
       
  1694 //
       
  1695 void CImpsDecodeWbXml::Destroy( )
       
  1696     {
       
  1697 
       
  1698     delete this;
       
  1699     
       
  1700     }
       
  1701 
       
  1702 // ---------------------------------------------------------
       
  1703 // CImpsDecodeWbXml::IsPureTransaction ()
       
  1704 // ---------------------------------------------------------
       
  1705 TBool CImpsDecodeWbXml::IsPureTransaction(TInt aToken)
       
  1706     {
       
  1707     switch ( aToken )
       
  1708         {
       
  1709         case KImpsWbXmlPresenceNotificationRequest:
       
  1710         case KImpsWbXmlGetPresenceResponse:
       
  1711         case KImpsWbXmlGetWatcherListResponse:
       
  1712         case KImpsWbXmlGetListResponse:
       
  1713         case KImpsWbXmlListManageResponse:
       
  1714         case KImpsWbXmlGetAttributeListResponse:
       
  1715         case KImpsWbXmlPresenceAuthRequest:
       
  1716         case KImpsKeyGetReactiveAuthStatus_Response:
       
  1717             return ETrue;
       
  1718         case KImpsWbXmlStatus:
       
  1719             // the Status transaction needs special handling because
       
  1720             // it has to be also in normal decoded version too
       
  1721             iTypeStatus = ETrue;
       
  1722             return ETrue;
       
  1723         default:
       
  1724             return EFalse;
       
  1725         }
       
  1726 
       
  1727     }
       
  1728 
       
  1729 
       
  1730 // ---------------------------------------------------------
       
  1731 // CImpsDecodeWbXml::ConvertToDes8 ()
       
  1732 // ---------------------------------------------------------
       
  1733 void CImpsDecodeWbXml::ConvertToDes8( TUint16* aElement, TDes8& aConverted )
       
  1734     {
       
  1735 
       
  1736     TPtrC elementPtr;
       
  1737     elementPtr.Set(aElement);
       
  1738     __ASSERT_DEBUG(elementPtr.Length()<aConverted.MaxLength(), User::Panic(_L("WBXML Panic"), KErrTooBig));
       
  1739     // Simple UCS2 to 8bit conversion
       
  1740     // it is safe as we have only 8bit characters
       
  1741 //    TBuf8<KDtdElementMaxLength> elementString;
       
  1742     aConverted.Copy(elementPtr);
       
  1743     }
       
  1744 
       
  1745 //  End of File