voipplugins/accountcreationplugin/engine/src/acpproviderfield.cpp
changeset 0 a4daefaec16c
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:  Implements CAcpProviderField methods
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "acpproviderfield.h"
       
    20 #include "accountcreationpluginlogger.h"
       
    21 
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // CAcpProviderField::CAcpProviderField
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CAcpProviderField::CAcpProviderField() 
       
    28     {
       
    29     }
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // CAcpProviderField::NewL
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 CAcpProviderField* CAcpProviderField::NewL()
       
    36     {
       
    37     CAcpProviderField* self = CAcpProviderField::NewLC();
       
    38     CleanupStack::Pop( self );
       
    39     return self;
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CAcpProviderField::NewLC
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CAcpProviderField* CAcpProviderField::NewLC()
       
    47     {
       
    48     CAcpProviderField* self = new ( ELeave ) CAcpProviderField();
       
    49     CleanupStack::PushL( self );
       
    50     return self;
       
    51     }
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CAcpProviderField::~CAcpProviderField
       
    55 // ---------------------------------------------------------------------------
       
    56 //
       
    57 CAcpProviderField::~CAcpProviderField()
       
    58     {
       
    59     ACPLOG( "CAcpProviderField::~CAcpProviderField begin" );
       
    60     delete iFieldName; // Field name
       
    61     delete iFieldData; // Field data
       
    62     ACPLOG( "CAcpProviderField::~CAcpProviderField end" );
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CAcpProviderField::CopyL
       
    67 // Copies provider fields data from given parameter to member data.
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 void CAcpProviderField::CopyL( const CAcpProviderField& aProviderField )
       
    71     {
       
    72     ACPLOG( "CAcpProviderField::CopyL begin" );
       
    73 
       
    74     // Set field name descriptor 
       
    75     SetFieldNameL( aProviderField.FieldName() );
       
    76     // Set field type
       
    77     iType = aProviderField.iType;
       
    78 
       
    79     ACPLOG( "CAcpProviderField::CopyL end" );
       
    80     }
       
    81 
       
    82 // ---------------------------------------------------------------------------
       
    83 // CAcpProviderField::FieldName
       
    84 // Returns name of the field.
       
    85 // ---------------------------------------------------------------------------
       
    86 //
       
    87 TPtrC CAcpProviderField::FieldName() const
       
    88     {
       
    89     if ( iFieldName )
       
    90         {
       
    91         return *iFieldName;
       
    92         }
       
    93     return KNullDesC();
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CAcpProviderField::SetFieldNameL
       
    98 // Sets name of the field.
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 void CAcpProviderField::SetFieldNameL( const TDesC& aFieldName )
       
   102     {
       
   103     // Check whether field name defined or not
       
   104     if( aFieldName.Length() > KErrNone )
       
   105         {
       
   106         // Old filed name should be deleted at first
       
   107         delete iFieldName;
       
   108         iFieldName = NULL;
       
   109         // Allocate descriptor for the filed name with the 
       
   110         // requested maximum length
       
   111         iFieldName = HBufC::NewL( aFieldName.Length() );
       
   112         // Copy the filed name into the descriptor
       
   113         iFieldName->Des().Copy( aFieldName );
       
   114         }
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CAcpProviderField::FieldType
       
   119 // Returns type of the field.
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 CAcpProviderField::TFieldTypes CAcpProviderField::FieldType() const
       
   123     {
       
   124     ACPLOG2( "CAcpProviderField::FieldType: %d", iType );
       
   125     return iType; // Field type
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CAcpProviderField::SetFieldType
       
   130 // Sets type of the field.
       
   131 // ---------------------------------------------------------------------------
       
   132 //
       
   133 void CAcpProviderField::SetFieldType( CAcpProviderField::TFieldTypes aType )
       
   134     {
       
   135     iType = aType; // Set field type
       
   136     }    
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // CAcpProviderField::FieldData
       
   140 // Returns data of the field.
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 TPtrC CAcpProviderField::FieldData() const
       
   144     {
       
   145     if( iFieldData ) return *iFieldData; // The field data
       
   146     return KNullDesC(); // Unspecified
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // CAcpProviderField::SetFieldDataL
       
   151 // Sets data of the field.
       
   152 // ---------------------------------------------------------------------------
       
   153 //
       
   154 void CAcpProviderField::SetFieldDataL( const TDesC& aFieldData )
       
   155     {
       
   156     // Check whether the requested field data definec or not
       
   157     if( aFieldData.Length() > KErrNone )
       
   158         {
       
   159         // The field data descriptor should be deleted at first
       
   160         delete iFieldData;
       
   161         iFieldData = NULL;
       
   162 
       
   163         // Allocate new descriptor for the field data with the requested
       
   164         // maximum lenght
       
   165         iFieldData = HBufC::NewL( aFieldData.Length() );
       
   166         // Copy the field data into the descriptor
       
   167         iFieldData->Des().Copy( aFieldData );
       
   168         }
       
   169     }
       
   170 
       
   171 // End of file.