webservices/wsmessages/src/senatomentry.cpp
changeset 0 62f9d29f7211
child 1 272b002df977
equal deleted inserted replaced
-1:000000000000 0:62f9d29f7211
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:       
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 // INCLUDE FILES
       
    26 #include <e32std.h>
       
    27 #include <badesca.h>
       
    28 
       
    29 #include <SenDomFragmentBase.h>
       
    30 #include <xmlengnodelist.h>
       
    31 
       
    32 #include "senatomentry.h"
       
    33 
       
    34 #include "sendebug.h"
       
    35 #include "senlogger.h"
       
    36 
       
    37 const TInt KStateParsingMediaGroup       = 19;  // save state     (odd number)
       
    38 
       
    39 EXPORT_C CSenAtomEntry* CSenAtomEntry::NewL()
       
    40     {
       
    41     TLSLOG_L(KSenMessagesLogChannel, KSenMessagesLogLevel, "CSenAtomEntry::NewL()");
       
    42     CSenAtomEntry* pNew = CSenAtomEntry::NewLC();
       
    43     CleanupStack::Pop( pNew ); // pNew
       
    44     return pNew;
       
    45     }
       
    46 
       
    47 EXPORT_C CSenAtomEntry* CSenAtomEntry::NewLC()
       
    48     {
       
    49     TLSLOG_L(KSenMessagesLogChannel, KSenMessagesLogLevel, "CSenAtomEntry::NewLC()");
       
    50     CSenAtomEntry* pNew = new (ELeave) CSenAtomEntry();
       
    51     CleanupStack::PushL(pNew);
       
    52     pNew->BaseConstructL();
       
    53     return pNew;
       
    54     }
       
    55 
       
    56 CSenAtomEntry::CSenAtomEntry () :
       
    57     CSenAtomMessage(),localState(KSenStateSave)
       
    58     {
       
    59     }
       
    60 
       
    61 EXPORT_C CSenAtomEntry::~CSenAtomEntry()
       
    62     {
       
    63     iBuffer.Close();
       
    64     }
       
    65 
       
    66 EXPORT_C void CSenAtomEntry::BaseConstructL()
       
    67     {
       
    68     CSenFragmentBase::BaseConstructL(KSenAtomEntryXmlns, KSenAtomEntryName);
       
    69 
       
    70     }
       
    71 
       
    72 //                     CALLBACKS
       
    73 
       
    74 EXPORT_C void CSenAtomEntry::OnStartElementL(const RTagInfo& aElement,
       
    75         const RAttributeArray& aAttributes,
       
    76         TInt /*aErrorCode*/)
       
    77     {
       
    78     
       
    79     
       
    80     const TPtrC8 saxLocalName = aElement.LocalName().DesC();
       
    81     const TPtrC8 saxNsUri = aElement.Uri().DesC();
       
    82     const TPtrC8 saxPrefix = aElement.Prefix().DesC();
       
    83 
       
    84     if(saxLocalName==KSenAtomGroupName){
       
    85         localState=KStateParsingMediaGroup;
       
    86     }
       
    87     if(saxLocalName==KSenAtomEntryName){
       
    88             iState=KSenStateIgnore;
       
    89         } 
       
    90     CSenFragmentBase::OnStartElementL(aElement,aAttributes,TInt(KErrNone));
       
    91 
       
    92     }
       
    93 
       
    94 EXPORT_C void CSenAtomEntry::OnContentL(const TDesC8& aBytes, TInt /*aErrorCode*/)
       
    95     {
       
    96     iBuffer.Close();
       
    97     iBuffer.Create(aBytes);
       
    98     CSenFragmentBase::OnContentL(aBytes, TInt(KErrNone));
       
    99     }
       
   100 
       
   101 EXPORT_C void CSenAtomEntry::OnEndElementL(
       
   102         const RTagInfo& aElement,
       
   103         TInt /*aErrorCode*/)
       
   104     {
       
   105     TLSLOG_L(KSenMessagesLogChannel, KSenMessagesLogLevel, "CSenAtomEntry::OnEndElementL");
       
   106 
       
   107     const TPtrC8 saxLocalName = aElement.LocalName().DesC();
       
   108     const TPtrC8 saxNsUri = aElement.Uri().DesC();
       
   109     const TPtrC8 saxPrefix = aElement.Prefix().DesC();
       
   110     
       
   111     const TPtrC8 tLocalName = LocalName();
       
   112     const TPtrC8 tNsUri = NsUri();
       
   113     const TPtrC8 tPrefix = NsPrefix();
       
   114 
       
   115     switch (localState)
       
   116         {
       
   117         case KStateParsingMediaGroup:
       
   118             {
       
   119                 if(saxLocalName == KSenAtomGroupName)
       
   120                     localState = KSenStateSave;
       
   121                 CSenFragmentBase::OnEndElementL(aElement, TInt(KErrNone));
       
   122             }
       
   123             break;
       
   124 
       
   125         case KSenStateSave:
       
   126             {
       
   127             if(saxLocalName == KSenAtomTitleName  && localState != KStateParsingMediaGroup)
       
   128                 {
       
   129 
       
   130                 if ( iTitle )
       
   131                     {
       
   132                     delete iTitle;
       
   133                     iTitle = 0;
       
   134                     }
       
   135                 if ( iBuffer.Length()> 0 )
       
   136                     {
       
   137                     iTitle = iBuffer.AllocL();
       
   138 
       
   139                     CSenFragmentBase::OnEndElementL(aElement, TInt(KErrNone));
       
   140                     }
       
   141                 }else
       
   142             if(saxLocalName == KSenAtomIdName  && localState != KStateParsingMediaGroup)
       
   143                 {
       
   144 
       
   145                 if ( iIdTag )
       
   146                     {
       
   147                     delete iIdTag;
       
   148                     iIdTag = 0;
       
   149                     }
       
   150                 if ( iBuffer.Length()> 0 )
       
   151                     {
       
   152                     iIdTag = iBuffer.AllocL();
       
   153 
       
   154                     CSenFragmentBase::OnEndElementL(aElement, TInt(KErrNone));
       
   155                     }
       
   156                 }else
       
   157             if(saxLocalName == KSenAtomPublishedName  && localState != KStateParsingMediaGroup)
       
   158                 {
       
   159 
       
   160                 if ( iPublished )
       
   161                     {
       
   162                     delete iPublished;
       
   163                     iPublished = 0;
       
   164                     }
       
   165                 if ( iBuffer.Length()> 0 )
       
   166                     {
       
   167                     iPublished = iBuffer.AllocL();
       
   168 
       
   169                     CSenFragmentBase::OnEndElementL(aElement, TInt(KErrNone));
       
   170                     }
       
   171                 }else
       
   172             if(saxLocalName == KSenAtomUpdatedName  && localState != KStateParsingMediaGroup)
       
   173                 {
       
   174 
       
   175                 if ( iUpdated )
       
   176                     {
       
   177                     delete iUpdated;
       
   178                     iUpdated = 0;
       
   179                     }
       
   180                 if ( iBuffer.Length()> 0 )
       
   181                     {
       
   182                     iUpdated = iBuffer.AllocL();
       
   183 
       
   184                     CSenFragmentBase::OnEndElementL(aElement, TInt(KErrNone));
       
   185                     }
       
   186                 }
       
   187                 else {
       
   188                     CSenFragmentBase::OnEndElementL(aElement, TInt(KErrNone));
       
   189                 }
       
   190             }
       
   191         break;
       
   192     
       
   193         default:
       
   194         CSenFragmentBase::OnEndElementL(aElement, TInt(KErrNone));
       
   195         break;
       
   196         }
       
   197 
       
   198     iBuffer.Close();
       
   199     
       
   200     }
       
   201 
       
   202 // SET         GET       COUNT          REMOVE
       
   203 
       
   204