uiservicetab/vimpststorage/tsrc/vimpststorage_ut/stubs/s_CVPbkStoreContactField.cpp
branchRCL_3
changeset 29 9a48e301e94b
parent 0 5e5d6b214f4f
equal deleted inserted replaced
28:3104fc151679 29:9a48e301e94b
       
     1 /*
       
     2 * Copyright (c) 2004-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 // INCLUDES
       
    22 #include "s_CVPbkStoreContactField.h"
       
    23 #include <VPbkEng.rsg>
       
    24 #include "CVPbkContactFieldTextData_stub.h"
       
    25 #include "s_MVPbkContactFieldUriData_stub.h"
       
    26 #include "s_MVPbkContactFieldBinaryDatastub.h"
       
    27 
       
    28 CVPbkContactFieldTextData_stub gTextFieldData;
       
    29 CVPbkContactFieldUriData_Stub gUriFieldData;
       
    30 CVPbkContactFieldBinaryDataStub gBinaryFieldData;
       
    31 CVPbkContactFieldTextData_stub gJunkFieldData;
       
    32 TBool gBestMatchingFieldType;
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 //ctor
       
    37 CVPbkStoreContactFieldStub::CVPbkStoreContactFieldStub( TInt aIndex)
       
    38 : iIndex(aIndex)
       
    39 {
       
    40 	
       
    41 }
       
    42 /**
       
    43  * Destructor
       
    44  */
       
    45 CVPbkStoreContactFieldStub::~CVPbkStoreContactFieldStub(){ }
       
    46 
       
    47 const MVPbkContactFieldData& CVPbkStoreContactFieldStub::FieldData() const 
       
    48 	{ 
       
    49 	if (iIndex == 0)
       
    50 		{
       
    51 		return gTextFieldData;	
       
    52 		}
       
    53 	
       
    54 	if (iIndex == 1)
       
    55 		{
       
    56 		return gUriFieldData;	
       
    57 		}
       
    58 	
       
    59 	if (iIndex == 2)
       
    60 		{
       
    61 		return gBinaryFieldData;	
       
    62 		}
       
    63 	
       
    64 	return gJunkFieldData; //some junk
       
    65 
       
    66 	}
       
    67 
       
    68 
       
    69 /**
       
    70  * Returns ETrue if the field supports label. 
       
    71  * 
       
    72  * Overwrites the global setting in MVPbkContactStoreProperties. 
       
    73  * This must be confirmed before using SetFieldLabelL or 
       
    74  * MaxLabelLength.
       
    75  * 
       
    76  * @return ETrue if the field supports label. Otherwise EFalse.
       
    77  */
       
    78 TBool CVPbkStoreContactFieldStub::SupportsLabel() const { return EFalse; }
       
    79 
       
    80 /**
       
    81  * Returns the label of the field or KNullDesC if there is no field 
       
    82  * label.
       
    83  *
       
    84  * @return The label of the field or KNullDesC
       
    85  */
       
    86 TPtrC CVPbkStoreContactFieldStub::FieldLabel() const { return KNullDesC(); }
       
    87 
       
    88 /**
       
    89  * Sets this field's label.
       
    90  *
       
    91  * SupportsLabel must be true for using this.
       
    92  *
       
    93  * @param aText The label for the field.
       
    94  */
       
    95 void CVPbkStoreContactFieldStub::SetFieldLabelL( const TDesC& /*aText*/ ) { }
       
    96 
       
    97 /**
       
    98  * Gets the maximum length of the label. 
       
    99  *
       
   100  * SupportsLabel must be true for using this.
       
   101  * 
       
   102  * @return The maximum length of the label or KVPbkUnlimitedLabelLength
       
   103  *         if the store has no limits. Zero should be returned in other
       
   104  *         cases though this shouldn't be called if labels are 
       
   105  *         not supported.
       
   106  */
       
   107 TInt CVPbkStoreContactFieldStub::MaxLabelLength() const { return 0; }
       
   108 
       
   109 /**
       
   110  * Returns the data storage (read-write) of the field. 
       
   111  *
       
   112  * The data type depends on the field and it's client's responsibility
       
   113  * to check the type before casting the type.
       
   114  *
       
   115  * @return The data storage of the field.
       
   116  * @see MVPbkContactFieldTextData::Cast
       
   117  * @see MVPbkContactFieldDateTimeData::Cast
       
   118  * @see MVPbkContactFieldBinaryData::Cast
       
   119  */
       
   120 MVPbkContactFieldData& CVPbkStoreContactFieldStub::FieldData() 
       
   121 	{
       
   122 	
       
   123 
       
   124 	if (iIndex == 0)
       
   125 		{
       
   126 		return gTextFieldData;	
       
   127 		}
       
   128 	
       
   129 	if (iIndex == 1)
       
   130 		{
       
   131 		return gUriFieldData;	
       
   132 		}
       
   133 	
       
   134 	if (iIndex == 2)
       
   135 		{
       
   136 		return gBinaryFieldData;	
       
   137 		}
       
   138 	
       
   139 	return gJunkFieldData; //some junk
       
   140 	}
       
   141 	
       
   142 	
       
   143 /**
       
   144  * Clones the field. 
       
   145  * 
       
   146  * Pushes the created copy to the cleanup stack.
       
   147  *
       
   148  * @return A copy of the field.
       
   149  * @see MVPbkStoreContactFieldCollection::FieldAt
       
   150  */
       
   151 MVPbkStoreContactField* CVPbkStoreContactFieldStub::CloneLC() const { return NULL; }
       
   152 
       
   153 /**
       
   154  * Creates a link representing the contact and the field.
       
   155  *
       
   156  * The field can be later retrieved using the RetrieveField of
       
   157  * MVPbkStoreContactFieldCollection interface.
       
   158  *
       
   159  * NOTE: implementations of stores are possibly using an index
       
   160  *       of the field as an identifier so clients should prefer not
       
   161  *       to save field links permanently. E.g modifying the contact
       
   162  *       can invalidate the link in some store implementations.
       
   163  *       A field link is practical in use cases where the link is
       
   164  *       created and immediately given to another component.
       
   165  *
       
   166  * @return A link representing the contact and the field or NULL
       
   167  *         if the contact doesn't exist in the store. E.g a new
       
   168  *         contact that hasn't been committed has no unique
       
   169  *         identifier yet.
       
   170  *         NULL is not put into the CleanupStack.
       
   171  */
       
   172 MVPbkContactLink* CVPbkStoreContactFieldStub::CreateLinkLC() const { return NULL; }
       
   173 
       
   174 
       
   175 /**
       
   176  * Returns the parent contact where this field is from.
       
   177  *
       
   178  * @return The parent contact where this field is from.
       
   179  */
       
   180 MVPbkBaseContact& CVPbkStoreContactFieldStub::ParentContact() const 
       
   181 { 
       
   182 MVPbkBaseContact* ret=NULL;
       
   183 return *ret;
       
   184 }
       
   185 
       
   186 /**
       
   187  * Returns this field's type or NULL if no mapping exists
       
   188  * between the native type and phonebook type.
       
   189  *
       
   190  * @param aMatchPriority    matching priority to use.
       
   191  * @return The field type or NULL
       
   192  * @postcond !FieldType(list) || list.ContainsSame(*FieldType(list))
       
   193  */
       
   194 const MVPbkFieldType* CVPbkStoreContactFieldStub::MatchFieldType(
       
   195         TInt /*aMatchPriority*/) const { return NULL; }
       
   196 
       
   197 /**
       
   198  * Returns the best matching type of the field or NULL 
       
   199  * if no mapping exists between the native type and 
       
   200  * phonebook type. This is the same as looping 
       
   201  * MatchFieldType from priority 0 and getting the first 
       
   202  * matched type.
       
   203  *
       
   204  * @return The field type or NULL
       
   205  * @postcond !FieldType(list) || list.ContainsSame(*FieldType(list))
       
   206  */
       
   207 const MVPbkFieldType* CVPbkStoreContactFieldStub::BestMatchingFieldType() const 
       
   208 	{
       
   209 	if (gBestMatchingFieldType)
       
   210 		{
       
   211 		return this;
       
   212 		}
       
   213 	return NULL;
       
   214 	}
       
   215 
       
   216 
       
   217 
       
   218 /**
       
   219  * Returns true if this field is the same as another field in the
       
   220  * contact instance. 
       
   221  * Doesn't work for fields from different contact instances.
       
   222  * Always use this method instead of direct pointer comparison.
       
   223  *
       
   224  * @param aOther another field inside the contact
       
   225  * @return ETrue if contact is same
       
   226  */
       
   227 TBool CVPbkStoreContactFieldStub::IsSame(const MVPbkBaseContactField& /*aOther*/) const { return EFalse;}
       
   228 
       
   229 
       
   230 /**
       
   231  * Returns the parent object of this object. For the root of the 
       
   232  * hierarchy returns self.
       
   233  * @return The parent object.
       
   234  */
       
   235 MVPbkObjectHierarchy& CVPbkStoreContactFieldStub::ParentObject() const 
       
   236 { 
       
   237 MVPbkObjectHierarchy* ret =NULL;
       
   238 return *ret;
       
   239 }
       
   240 
       
   241 
       
   242 /**
       
   243  * Returns the Versit properties mapped to this field type.
       
   244  *
       
   245  * @return Versit properties.
       
   246  */
       
   247 TArray<TVPbkFieldVersitProperty> CVPbkStoreContactFieldStub::VersitProperties() const 
       
   248 { 
       
   249 
       
   250 }
       
   251 
       
   252 /**
       
   253  * Returns the Versit parameters fields of this type should not have.
       
   254  *
       
   255  * @return Excluded parameters.
       
   256  */
       
   257 const TVPbkFieldTypeParameters& CVPbkStoreContactFieldStub::ExcludedParameters() const 
       
   258 { 
       
   259 TVPbkFieldTypeParameters* ret = NULL;
       
   260 return *ret;
       
   261 }
       
   262 
       
   263 /**
       
   264  * Type name for field types not supported by the Versit 2.1 standard.
       
   265  *
       
   266  * @return A non-Versit type.
       
   267  */
       
   268 TVPbkNonVersitFieldType CVPbkStoreContactFieldStub::NonVersitType() const 
       
   269 { 
       
   270 return EVPbkNonVersitTypeNone;
       
   271 }
       
   272 
       
   273 /**
       
   274  * Returns true if this field type is the same as aOtherType.
       
   275  *
       
   276  * @param aOtherType The type to compare.
       
   277  * @return ETrue if the field types are the same.
       
   278  */
       
   279 TBool CVPbkStoreContactFieldStub::IsSame(
       
   280         const MVPbkFieldType& /*aOtherType*/ ) const { return EFalse; }
       
   281 
       
   282 /**
       
   283  * Returns true if this field type matches a Versit property.
       
   284  *
       
   285  * @param aMatchProperty A versit property to match against.
       
   286  * @param aMatchPriority A matching priority. Priorities start
       
   287  *                       from zero which is the highest priority.
       
   288  *                       Priority is also a direct index to
       
   289  *                       VersitProperties() array.
       
   290  * @return ETrue if this field type matches aMatchProperty at
       
   291  *         aMatchPriority. Returns always false if 
       
   292  *         aMatchPriority >= VersitProperties().Count().
       
   293  */
       
   294 TBool CVPbkStoreContactFieldStub::Matches(
       
   295         const TVPbkFieldVersitProperty& /*aMatchProperty*/,
       
   296         TInt /*aMatchPriority*/ ) const { return EFalse; }
       
   297 
       
   298 /**
       
   299  * Returns the field type resource id from VPbkEng.rsg
       
   300  * that be used to identify a type.
       
   301  *
       
   302  * @return A field type resource id.
       
   303  */
       
   304 TInt CVPbkStoreContactFieldStub::FieldTypeResId() const 
       
   305 	{ 	
       
   306 
       
   307 	if (iIndex == 0)
       
   308 		{
       
   309 		return R_VPBK_FIELD_TYPE_VOIPHOME;	
       
   310 		}
       
   311 	
       
   312 	if (iIndex == 1)
       
   313 		{
       
   314 		return R_VPBK_FIELD_TYPE_IMPP;	
       
   315 		}
       
   316 	
       
   317 	if (iIndex == 2)
       
   318 		{
       
   319 		return R_VPBK_FIELD_TYPE_THUMBNAILPIC;	
       
   320 		}
       
   321 	
       
   322 	return R_VPBK_FIELD_TYPE_JOBTITLE; //some junk
       
   323 	} 
       
   324         
       
   325 // End of file