serviceproviders/sapi_contacts_vpbk/contactservice/src/singlecontactfield.cpp
changeset 5 989d2f495d90
child 10 fc9cf246af83
equal deleted inserted replaced
1:a36b1e19a461 5:989d2f495d90
       
     1 /*
       
     2 * Copyright (c) 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 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <MVPbkFieldType.h>
       
    20 #include <MVPbkContactFieldTextData.h>
       
    21 
       
    22 #include "singlecontact.h"
       
    23 #include "singlecontactfield.h"
       
    24 
       
    25 /*
       
    26 -----------------------------------------------------------------------------
       
    27     CSingleContactField  ::NewL()
       
    28     Description          : static method which creates the object and constructs it.
       
    29     Return values        : CSingleContactField*
       
    30 -----------------------------------------------------------------------------
       
    31 */
       
    32 EXPORT_C CSingleContactField* CSingleContactField::NewL()
       
    33 	{
       
    34 	return new (ELeave) CSingleContactField();
       
    35 	}
       
    36 
       
    37 /*
       
    38 -----------------------------------------------------------------------------
       
    39     CSingleContactField  ::CSingleContactField().
       
    40     Description          : Default Constructor.
       
    41     Return values        : None.
       
    42 -----------------------------------------------------------------------------
       
    43 */
       
    44 CSingleContactField::CSingleContactField()
       
    45 	{
       
    46 	}
       
    47 
       
    48 /*
       
    49 -----------------------------------------------------------------------------
       
    50     CSingleContactField  ::GetFieldDataL(TPtrC8& aFieldKey,
       
    51                                          TPtrC& aLabel,
       
    52                                          TPtrC& aValue).
       
    53     Description          : Gets the Field Data and returns them as output parameters.
       
    54                          : If one of the params is not there then leaves.
       
    55     Return values        : None.
       
    56 -----------------------------------------------------------------------------
       
    57 */
       
    58 EXPORT_C void CSingleContactField::GetFieldDataL(TPtrC8& aFieldKey,
       
    59                                                  TPtrC& aLabel,
       
    60                                                  TPtrC& aValue)
       
    61 	{
       
    62 	if(iFieldKey && iLabel && iValue)
       
    63     	{
       
    64     	aFieldKey.Set(*iFieldKey);
       
    65     	aLabel.Set(*iLabel);
       
    66     	aValue.Set(*iValue);    
       
    67     	}
       
    68     else
       
    69         {
       
    70         User::Leave(KErrNotFound);    
       
    71         }		
       
    72 	}
       
    73 
       
    74 /*
       
    75 -----------------------------------------------------------------------------
       
    76     CSingleContactField  ::GetFieldDataL(TPtrC8& aFieldKey,
       
    77                                          TPtrC& aLabel,
       
    78                                          TPtrC& aValue).
       
    79     Description          : Gets the Field Data and returns them as output parameters.
       
    80                          : Can leave.
       
    81     Return values        : None.
       
    82 -----------------------------------------------------------------------------
       
    83 */
       
    84 EXPORT_C void CSingleContactField::
       
    85               SetFieldParamsL(const TDesC8& aFieldKey,
       
    86                               const TDesC& aLabel,
       
    87                               const TDesC& aValue)
       
    88 	{
       
    89 	if(iFieldKey)
       
    90 	    {
       
    91 	    delete iFieldKey;
       
    92 	    iFieldKey = NULL;
       
    93 	    }
       
    94     if( iLabel )
       
    95         {
       
    96         delete iLabel;
       
    97         iLabel = NULL;
       
    98         }
       
    99     if( iValue )
       
   100         {
       
   101         delete iValue;
       
   102         iValue = NULL;
       
   103         }
       
   104 	iFieldKey= aFieldKey.AllocL();
       
   105 	iLabel = aLabel.AllocL();
       
   106 	iValue = aValue.AllocL();
       
   107 	}
       
   108 
       
   109 //Gets the Group Data and returns them as output parameters
       
   110 /*
       
   111 -----------------------------------------------------------------------------
       
   112     CSingleContactField  ::CSingleContactField::
       
   113                            GetFieldDataL(TPtrC& aGroupLabel,
       
   114                                          RPointerArray<HBufC8>& aArray)
       
   115     Description          : Gets the Field Data and returns them as output parameters.
       
   116                          : Can leave.
       
   117     Return values        : None.
       
   118 -----------------------------------------------------------------------------
       
   119 */
       
   120 EXPORT_C void CSingleContactField::
       
   121               GetFieldDataL(TPtrC& aGroupLabel,
       
   122                             RPointerArray<TDesC8>& aArray)
       
   123 	{
       
   124 	aGroupLabel.Set(*iGroupLabel);
       
   125 	
       
   126 	TInt count = iContactIdArray.Count();
       
   127 	
       
   128 	for(TInt i=0;i<count;i++)
       
   129     	{
       
   130     	 aArray.AppendL(iContactIdArray[i]);    	 
       
   131     	}    		
       
   132 	}
       
   133 
       
   134 //Sets the Group Data.
       
   135 void CSingleContactField::
       
   136      SetFieldParamsL(const TPtrC& aGroupLabel,
       
   137      RPointerArray<HBufC8>& aArray)
       
   138 	{
       
   139 	if( iGroupLabel )
       
   140 	    {
       
   141 	    delete iGroupLabel;
       
   142 	    iGroupLabel = NULL;
       
   143 	    }
       
   144 	iGroupLabel = aGroupLabel.AllocL();
       
   145 	iContactIdArray.ResetAndDestroy();
       
   146 	iContactIdArray = aArray;
       
   147 	}
       
   148 
       
   149 //Private method used to set TTime variable
       
   150 EXPORT_C void CSingleContactField::SetDateTime(TTime aDateTime)
       
   151 	{
       
   152 	iDateAndTime = aDateTime;
       
   153 	}
       
   154 
       
   155 //Method to get the TTime variable
       
   156 EXPORT_C TTime CSingleContactField::GetDateTime()
       
   157 	{
       
   158 	return iDateAndTime;
       
   159 	}
       
   160 
       
   161 CSingleContactField::~CSingleContactField()
       
   162     {
       
   163     delete iFieldKey;
       
   164     delete iLabel;
       
   165     delete iValue;
       
   166     delete iGroupLabel;
       
   167     iContactIdArray.ResetAndDestroy();
       
   168     }