srsf/nssvasapi/nssvascore/src/nssvascrrd.cpp
branchRCL_3
changeset 19 e36f3802f733
parent 0 bf1d17376201
equal deleted inserted replaced
18:cad71a31b7fc 19:e36f3802f733
       
     1 /*
       
     2 * Copyright (c) 2003-2006 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:  CNssRRD class encapsulated a RRD. It implements MNssRRD.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32svr.h>
       
    21 
       
    22 #include "rubydebug.h"
       
    23 #include "nssvascrrd.h"
       
    24 #include "nssvascvasdbdataexchanger.h"
       
    25 
       
    26 // ================= MEMBER FUNCTIONS =======================
       
    27 
       
    28 // ---------------------------------------------------------
       
    29 // CNssRRD::CNssRRD
       
    30 // C++ constructor can NOT contain any code, that
       
    31 // might leave.
       
    32 // ---------------------------------------------------------
       
    33 //
       
    34 CNssRRD::CNssRRD()
       
    35     {
       
    36     iTagId = KNssVASDbDefaultValue;
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------
       
    40 // CNssRRD::ConstructL
       
    41 // EPOC constructor can leave.
       
    42 // ---------------------------------------------------------
       
    43 //
       
    44 void CNssRRD::ConstructL()
       
    45     {
       
    46     iTextArray = new (ELeave) CArrayFixFlat<NssRRDText>(1);
       
    47     iIntArray = new (ELeave) CArrayFixFlat<TInt>(1);
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------
       
    51 // CNssRRD::NewL
       
    52 // Two-phased constructor.
       
    53 // ---------------------------------------------------------
       
    54 //
       
    55 CNssRRD* CNssRRD::NewL()
       
    56     {
       
    57     CNssRRD* self = NewLC();
       
    58     CleanupStack::Pop( self );
       
    59     return self;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 // CNssRRD::NewLC
       
    64 // Two-phased constructor.
       
    65 // ---------------------------------------------------------
       
    66 //
       
    67 CNssRRD* CNssRRD::NewLC()
       
    68     {
       
    69     CNssRRD* self = new (ELeave) CNssRRD;
       
    70     CleanupStack::PushL( self );
       
    71     self->ConstructL();
       
    72     return self;
       
    73     }
       
    74 
       
    75 // ---------------------------------------------------------
       
    76 // CNssRRD::~CNssRRD
       
    77 // Destructor
       
    78 // ---------------------------------------------------------
       
    79 //
       
    80 CNssRRD::~CNssRRD()
       
    81     {
       
    82     if ( iTextArray )
       
    83         {
       
    84         iTextArray->Reset(); 
       
    85         delete iTextArray;
       
    86         }
       
    87     if ( iIntArray )
       
    88         {
       
    89         iIntArray->Reset();
       
    90         delete iIntArray;
       
    91         }
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // CNssRRD::TextArray
       
    96 // returns the text array with this RRD
       
    97 // ---------------------------------------------------------
       
    98 //
       
    99 CArrayFixFlat<NssRRDText>* CNssRRD::TextArray()
       
   100     {
       
   101 	return iTextArray; 
       
   102     }
       
   103 
       
   104 // ---------------------------------------------------------
       
   105 // CNssRRD::IntArray
       
   106 // returns the int array with this rrd
       
   107 // ---------------------------------------------------------
       
   108 //
       
   109 CArrayFixFlat<TInt>* CNssRRD::IntArray()
       
   110     {
       
   111     return iIntArray;
       
   112     }
       
   113 
       
   114 // ---------------------------------------------------------
       
   115 // CNssRRD::SetTextArrayL
       
   116 // sets text array for this RRD
       
   117 // ---------------------------------------------------------
       
   118 //
       
   119 void CNssRRD::SetTextArrayL(CArrayFixFlat<NssRRDText>* aTextArray)
       
   120     {
       
   121     iTextArray->Reset();
       
   122     TInt count = aTextArray->Count();
       
   123     for ( TInt i = 0; i < count; i++ )
       
   124         {
       
   125         if ( (*aTextArray)[i].MaxLength() > KNssVASMAXRRDTextLength )
       
   126             {
       
   127             RUBY_DEBUG2("CNssRRD::SetTextArrayL text too long %i, max %i",
       
   128                  (*aTextArray)[i].MaxLength(), KNssVASMAXRRDTextLength );
       
   129             User::Leave( KErrOverflow );
       
   130             }
       
   131          
       
   132         iTextArray->AppendL( (*aTextArray) [i] );
       
   133         }
       
   134     }
       
   135 
       
   136 // ---------------------------------------------------------
       
   137 // CNssRRD::SetIntArrayL
       
   138 // sets int array for this rrd
       
   139 // ---------------------------------------------------------
       
   140 //
       
   141  void CNssRRD::SetIntArrayL(CArrayFixFlat<TInt>* aIntArray)
       
   142      {
       
   143      iIntArray->Reset();
       
   144      TInt count = aIntArray->Count();
       
   145      for ( TInt i = 0; i < count; i++ )
       
   146          {
       
   147          iIntArray->AppendL( (*aIntArray) [i] );
       
   148          }
       
   149      }
       
   150 
       
   151 // ---------------------------------------------------------
       
   152 // CNssRRD::SetTagId
       
   153 // sets the tag id associated with a RRD
       
   154 // for use by the VAS Database
       
   155 // ---------------------------------------------------------
       
   156 //
       
   157 void CNssRRD::SetTagId( TInt aTagId )
       
   158     {
       
   159     iTagId = aTagId;
       
   160     }		
       
   161 
       
   162 // ---------------------------------------------------------
       
   163 // CNssRRD::TagId
       
   164 // gets the tag id associated with the RRD
       
   165 // for use by the VAS Database
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 TInt CNssRRD::TagId()
       
   169     {
       
   170     return iTagId;
       
   171     }		
       
   172 
       
   173 // ---------------------------------------------------------
       
   174 // CNssRRD::CopyL
       
   175 // Make a deep copy of RRD
       
   176 // ---------------------------------------------------------
       
   177 //
       
   178 CNssRRD* CNssRRD::CopyL()
       
   179     {
       
   180     RUBY_DEBUG_BLOCK( "CNssRRD::CopyL" );
       
   181     
       
   182     CNssRRD *copy = CNssRRD::NewL();
       
   183     copy->SetTextArrayL( iTextArray );
       
   184     copy->SetIntArrayL( iIntArray );
       
   185     copy->iTagId = iTagId;
       
   186     return copy;
       
   187     }
       
   188 	
       
   189 //  End of File