pushmtm/Plugins/PushContentHandler/PushContentHandlerUtils.cpp
changeset 51 48e827313edd
parent 37 481242ead638
child 53 f427d27b98d8
equal deleted inserted replaced
37:481242ead638 51:48e827313edd
     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 the License "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:  Utilities
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 
       
    22 #include "PushContentHandlerUtils.h"
       
    23 #include <e32std.h>
       
    24 #include <nw_dom_document.h>
       
    25 
       
    26 // ---------------------------------------------------------
       
    27 // NwxStatusToErrCode
       
    28 // ---------------------------------------------------------
       
    29 //
       
    30 TInt NwxStatusToErrCode( NW_Status_t aNwxErrorCode )
       
    31     {
       
    32     TInt ret( KErrGeneral );
       
    33 
       
    34     switch ( aNwxErrorCode )
       
    35         {
       
    36         case NW_STAT_SUCCESS:
       
    37             {
       
    38             ret = KErrNone;
       
    39             break;
       
    40             }
       
    41         case NW_STAT_OUT_OF_MEMORY:
       
    42             {
       
    43             ret = KErrNoMemory;
       
    44             break;
       
    45             }
       
    46         case NW_STAT_CANCELLED:
       
    47         case NW_STAT_CONN_CANCELLED:
       
    48             {
       
    49             ret = KErrCancel;
       
    50             break;
       
    51             }
       
    52         default:
       
    53             {
       
    54             ret = KErrGeneral;
       
    55             break;
       
    56             }
       
    57         }
       
    58 
       
    59     return ret;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // RWbxmlDictionary::InitializeL
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 void RWbxmlDictionary::InitializeL( NW_Int32 aCount, 
       
    67                                     NW_WBXML_Dictionary_t* aDictArray[] )
       
    68     {
       
    69     NW_Status_t stat = NW_STAT_SUCCESS;
       
    70     stat = NW_WBXML_Dictionary_initialize( aCount, aDictArray );
       
    71     User::LeaveIfError( NwxStatusToErrCode( stat ) );
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------
       
    75 // RWbxmlDictionary::Close
       
    76 // ---------------------------------------------------------
       
    77 //
       
    78 void RWbxmlDictionary::Close()
       
    79     {
       
    80     NW_WBXML_Dictionary_destroy();
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------
       
    84 // CDocumentTreeOwner::CDocumentTreeOwner
       
    85 // ---------------------------------------------------------
       
    86 //
       
    87 CDocumentTreeOwner::CDocumentTreeOwner() 
       
    88 :   iDocTree( NULL )
       
    89     {
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CDocumentTreeOwner::CDocumentTreeOwner
       
    94 // ---------------------------------------------------------
       
    95 //
       
    96 CDocumentTreeOwner::CDocumentTreeOwner( NW_DOM_DocumentNode_t* aDocTree ) 
       
    97 :   iDocTree( aDocTree )
       
    98     {
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CDocumentTreeOwner::~CDocumentTreeOwner
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 CDocumentTreeOwner::~CDocumentTreeOwner() 
       
   106     {
       
   107     if ( iDocTree )
       
   108         {
       
   109         NW_DOM_DocumentNode_Delete( iDocTree );
       
   110         }
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------
       
   114 // CDocumentTreeOwner::SetDocTree
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 void CDocumentTreeOwner::SetDocTree( NW_DOM_DocumentNode_t* aDocTree ) 
       
   118     {
       
   119     iDocTree = aDocTree;
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------
       
   123 // CStringOwner::CStringOwner
       
   124 // ---------------------------------------------------------
       
   125 //
       
   126 CStringOwner::CStringOwner() 
       
   127 :   iString( NULL )
       
   128     {
       
   129     }
       
   130 
       
   131 // ---------------------------------------------------------
       
   132 // CStringOwner::CStringOwner
       
   133 // ---------------------------------------------------------
       
   134 //
       
   135 CStringOwner::CStringOwner( NW_String_t* aString ) 
       
   136 :   iString( aString )
       
   137     {
       
   138     }
       
   139 
       
   140 // ---------------------------------------------------------
       
   141 // CStringOwner::~CStringOwner
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 CStringOwner::~CStringOwner() 
       
   145     {
       
   146     if ( iString )
       
   147         {
       
   148         NW_String_delete( iString );
       
   149         }
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------
       
   153 // CStringOwner::SetString
       
   154 // ---------------------------------------------------------
       
   155 //
       
   156 void CStringOwner::SetString( NW_String_t* aString ) 
       
   157     {
       
   158     iString = aString;
       
   159     }