javaextensions/pim/cntadapter/src.s60/cpimcmadaptermanager.cpp
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 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:  Provides static information about contact lists and creates
       
    15  *                contact list adapters.
       
    16  *
       
    17 */
       
    18 
       
    19 
       
    20 // CLASS HEADER
       
    21 #include "cpimcmadaptermanager.h"
       
    22 
       
    23 // INTERNAL INCLUDES
       
    24 #include "cpimcontactlistadapter.h"
       
    25 #include "pimlocalizationids.h"
       
    26 #include "mpimitem.h"
       
    27 #include "logger.h"
       
    28 
       
    29 // EXTERNAL INCLUDES
       
    30 #include <badesca.h>
       
    31 
       
    32 //LOCAL FUNCTION PROTOTYPES
       
    33 HBufC* CreateFullNameLC(const CDesCArray& aNames);
       
    34 
       
    35 //============================== LOCAL FUNCTIONS ===============================
       
    36 
       
    37 //------------------------------------------------------------------------------
       
    38 //CreateFullNameLC
       
    39 //Creates a buffer to contain both family name and given name (if present)
       
    40 //Returns: pointer to the buffer
       
    41 //------------------------------------------------------------------------------
       
    42 //
       
    43 HBufC* CreateFullNameLC(const CDesCArray& aNames)
       
    44 {
       
    45     JELOG2(EPim);
       
    46     HBufC* name = HBufC::NewLC(aNames[EPIMContactNameGiven].Length()
       
    47                                + aNames[EPIMContactNameFamily].Length());
       
    48 
       
    49     TPtr namePtr(name->Des());
       
    50     if (aNames[EPIMContactNameFamily] != KPIMNullArrayElement)
       
    51     {
       
    52         namePtr.Append(aNames[EPIMContactNameFamily]);
       
    53     }
       
    54     if (aNames[EPIMContactNameGiven] != KPIMNullArrayElement)
       
    55     {
       
    56         namePtr.Append(aNames[EPIMContactNameGiven]);
       
    57     }
       
    58 
       
    59     return name;
       
    60 }
       
    61 
       
    62 // ============================ MEMBER FUNCTIONS ===============================
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CPIMCMAdapterManager::NewL
       
    66 // Two-phased constructor.
       
    67 // -----------------------------------------------------------------------------
       
    68 //
       
    69 CPIMCMAdapterManager* CPIMCMAdapterManager::NewL(const TDesC& aListName)
       
    70 {
       
    71     JELOG2(EPim);
       
    72     CPIMCMAdapterManager* self = new(ELeave) CPIMCMAdapterManager;
       
    73 
       
    74     CleanupStack::PushL(self);
       
    75     self->ConstructL(aListName);
       
    76     CleanupStack::Pop(self);
       
    77 
       
    78     return self;
       
    79 }
       
    80 
       
    81 CPIMCMAdapterManager::~CPIMCMAdapterManager()
       
    82 {
       
    83     JELOG2(EPim);
       
    84     delete iListName;
       
    85     delete iSupportedFields;
       
    86     delete iNoAttributes;
       
    87     delete iAddrAttributes;
       
    88     delete iEmailAttributes;
       
    89     delete iTelAttributes;
       
    90     delete iNameElements;
       
    91     delete iAddrElements;
       
    92     delete iVoipAttributes;
       
    93 }
       
    94 
       
    95 const TDesC& CPIMCMAdapterManager::ListNameL()
       
    96 {
       
    97     JELOG2(EPim);
       
    98     return *iListName;
       
    99 }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CPIMCMAdapterManager::MaxCategories
       
   103 // Returns:     Number of maximum supported categories
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 
       
   107 TInt CPIMCMAdapterManager::MaxCategories()
       
   108 {
       
   109     JELOG2(EPim);
       
   110     return -1;
       
   111 }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CPIMCMAdapterManager::IsSupportedField
       
   115 // Returns:     ETrue: field is supported
       
   116 //              EFalse: field is not supported
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 
       
   120 TBool CPIMCMAdapterManager::IsSupportedField(TPIMField aField) // The field to be checked
       
   121 {
       
   122     JELOG2(EPim);
       
   123     for (TInt i = 0; i < KPIMSupportedFieldsCount; i++)
       
   124     {
       
   125         if (KPIMSupportedFields[i] == aField)
       
   126         {
       
   127             return ETrue;
       
   128         }
       
   129     }
       
   130     return EFalse;
       
   131 }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CPIMCMAdapterManager::GetSupportedFieldsL
       
   135 // Returns: An array containing all supported attributes
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 
       
   139 const CArrayFix<TPIMField>& CPIMCMAdapterManager::GetSupportedFieldsL()
       
   140 {
       
   141     JELOG2(EPim);
       
   142     if (NULL == iSupportedFields)
       
   143     {
       
   144         iSupportedFields
       
   145         = new(ELeave) CArrayFixFlat<TPIMField> (KPIMSupportedFieldsCount);  // codescanner::leave
       
   146         iSupportedFields->AppendL(KPIMSupportedFields, KPIMSupportedFieldsCount); // codescanner::leave
       
   147     }
       
   148     return *iSupportedFields;
       
   149 }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CPIMCMAdapterManager::IsSupportedAttribute
       
   153 // Returns:     ETrue: attribute is supported
       
   154 //              EFalse: attribute is not supported
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 
       
   158 TBool CPIMCMAdapterManager::IsSupportedAttribute(TPIMField aField, // the field to be checked
       
   159         TPIMAttribute aAttribute) // The attribute to be checked
       
   160 {
       
   161     JELOG2(EPim);
       
   162     TBool retval = EFalse;
       
   163     TRAPD(err, retval = IsSupportedAttributeL(aField, aAttribute));
       
   164     if (err != KErrNone)
       
   165     {
       
   166         return EFalse;
       
   167     }
       
   168     return retval;
       
   169 }
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CPIMCMAdapterManager::GetSupportedAttributesL
       
   173 // Returns: An array containing all supported attributes
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 
       
   177 const CArrayFix<TPIMAttribute>&
       
   178 CPIMCMAdapterManager::GetSupportedAttributesL(TPIMField aField)
       
   179 {
       
   180     JELOG2(EPim);
       
   181     CArrayFix<TPIMAttribute>* retVal = NULL;
       
   182     switch (aField)
       
   183     {
       
   184     case EPIMContactName:
       
   185     case EPIMContactFormattedName:
       
   186     case EPIMContactOrg:
       
   187     case EPIMContactTitle:
       
   188     case EPIMContactNickname:
       
   189     case EPIMContactBirthday:
       
   190     case EPIMContactNote:
       
   191     case EPIMContactPhoto:
       
   192     case EPIMContactUid:
       
   193     case EPIMContactClass:
       
   194     case EPIMContactExtWvUserId:
       
   195     case EPIMContactExtSip:
       
   196     case EPIMContactExtDtmf:
       
   197     case EPIMContactRevision:
       
   198     case EPIMContactExtDepartment:
       
   199     case EPIMContactExtAssistantName:
       
   200     case EPIMContactExtSpouse:
       
   201     case EPIMContactExtChildren:
       
   202     case EPIMContactExtAnniversary:
       
   203     case EPIMContactExtPTT:
       
   204     case EPIMContactExtSWIS:
       
   205     {
       
   206         if (NULL == iNoAttributes)
       
   207         {
       
   208             iNoAttributes = new(ELeave) CArrayFixFlat<TPIMAttribute> (1);
       
   209         }
       
   210         retVal = iNoAttributes;
       
   211         break;
       
   212     }
       
   213     case EPIMContactAddr:
       
   214     case EPIMContactUrl:
       
   215     {
       
   216         if (NULL == iAddrAttributes)
       
   217         {
       
   218             iAddrAttributes
       
   219             = new(ELeave) CArrayFixFlat<TPIMAttribute> (KPIMAddrAttributeCount);
       
   220             iAddrAttributes->AppendL(KPIMAddrAttributes, KPIMAddrAttributeCount);
       
   221         }
       
   222         retVal = iAddrAttributes;
       
   223         break;
       
   224     }
       
   225     case EPIMContactEmail:
       
   226     {
       
   227         if (NULL == iEmailAttributes)
       
   228         {
       
   229             iEmailAttributes
       
   230             = new(ELeave) CArrayFixFlat<TPIMAttribute> (KPIMEmailAttributeCount);
       
   231             iEmailAttributes->AppendL(KPIMEmailAttributes,
       
   232                                       KPIMEmailAttributeCount);
       
   233         }
       
   234         retVal = iEmailAttributes;
       
   235         break;
       
   236     }
       
   237     case EPIMContactTel:
       
   238     {
       
   239         if (NULL == iTelAttributes)
       
   240         {
       
   241             iTelAttributes
       
   242             = new(ELeave) CArrayFixFlat<TPIMAttribute> (KPIMTelAttributeCount);
       
   243             iTelAttributes->AppendL(KPIMTelAttributes, KPIMTelAttributeCount);
       
   244         }
       
   245         retVal = iTelAttributes;
       
   246         break;
       
   247     }
       
   248     case EPIMContactExtVoip:
       
   249     {
       
   250         if (NULL == iVoipAttributes)
       
   251         {
       
   252             iVoipAttributes
       
   253             = new(ELeave) CArrayFixFlat<TPIMAttribute> (KPIMVoipAttributeCount);
       
   254             iVoipAttributes->AppendL(KPIMVoipAttributes, KPIMVoipAttributeCount);
       
   255         }
       
   256         retVal = iVoipAttributes;
       
   257         break;
       
   258     }
       
   259     default:
       
   260     {
       
   261         User::Leave(KErrArgument);
       
   262     }
       
   263     }
       
   264     return *retVal;
       
   265 }
       
   266 
       
   267 // -----------------------------------------------------------------------------
       
   268 // CPIMCMAdapterManager::GetSupportedAttributesCombinedL
       
   269 // Returns: An integer holding the combination of all attributes
       
   270 //          supported for aField.
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 TPIMAttribute CPIMCMAdapterManager::GetSupportedAttributesCombinedL(
       
   274     TPIMField aField)
       
   275 {
       
   276     JELOG2(EPim);
       
   277     const CArrayFix<TPIMAttribute>& attributeArray = GetSupportedAttributesL(
       
   278                 aField);
       
   279     TPIMAttribute retVal = KPIMAttrNone;
       
   280     TInt attributeCount = attributeArray.Count();
       
   281     for (TInt i = 0; i < attributeCount; i++)
       
   282     {
       
   283         retVal |= attributeArray[i];
       
   284     }
       
   285     return retVal;
       
   286 }
       
   287 
       
   288 // -----------------------------------------------------------------------------
       
   289 // CPIMCMAdapterManager::GetAllSupportedAttributesCombinedL
       
   290 // Returns: An integer holding the combination of all attributes
       
   291 //          supported.
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 TPIMAttribute CPIMCMAdapterManager::GetAllSupportedAttributesCombined()
       
   295 {
       
   296     JELOG2(EPim);
       
   297     return KPIMAddrAttributesCombined | KPIMEmailAttributesCombined
       
   298            | KPIMTelAttributesCombined;
       
   299 }
       
   300 
       
   301 // -----------------------------------------------------------------------------
       
   302 // CPIMCMAdapterManager::IsSupportedArrayElement
       
   303 // Returns:     ETrue: element is supported
       
   304 //              EFalse: element is not supported
       
   305 // -----------------------------------------------------------------------------
       
   306 //
       
   307 
       
   308 TBool CPIMCMAdapterManager::IsSupportedArrayElement(
       
   309     TPIMField aStringArrayField, // the field to be checked
       
   310     TPIMArrayElement aArrayElement) // The array element to be checked
       
   311 {
       
   312     JELOG2(EPim);
       
   313     TBool retval = EFalse;
       
   314     TRAPD(err, retval = IsSupportedArrayElementL(aStringArrayField,
       
   315                         aArrayElement));
       
   316     if (err != KErrNone)
       
   317     {
       
   318         return EFalse;
       
   319     }
       
   320     return retval;
       
   321 }
       
   322 
       
   323 // -----------------------------------------------------------------------------
       
   324 // CPIMCMAdapterManager::GetSupportedArrayElementsL
       
   325 // Returns: An array containing all supported array elements
       
   326 // -----------------------------------------------------------------------------
       
   327 //
       
   328 
       
   329 const CArrayFix<TPIMArrayElement>&
       
   330 CPIMCMAdapterManager::GetSupportedArrayElementsL(TPIMField aStringArrayField)
       
   331 {
       
   332     JELOG2(EPim);
       
   333     CArrayFix<TPIMArrayElement>* retVal = NULL;
       
   334     switch (aStringArrayField)
       
   335     {
       
   336     case EPIMContactName:
       
   337     {
       
   338         retVal = iNameElements;
       
   339         break;
       
   340     }
       
   341     case EPIMContactAddr:
       
   342     {
       
   343         retVal = iAddrElements;
       
   344         break;
       
   345     }
       
   346     default:
       
   347     {
       
   348         User::Leave(KErrArgument);
       
   349     }
       
   350     }
       
   351     return *retVal;
       
   352 }
       
   353 
       
   354 // -----------------------------------------------------------------------------
       
   355 // CPIMCMAdapterManager::MaxValues
       
   356 // Returns: Number of values supported for the field
       
   357 // -----------------------------------------------------------------------------
       
   358 //
       
   359 
       
   360 TInt CPIMCMAdapterManager::MaxValues(TPIMField aField)
       
   361 {
       
   362     JELOG2(EPim);
       
   363     TInt retVal = 0;
       
   364 
       
   365     if (aField >= KPIMContactSmallestField)
       
   366     {
       
   367         if (aField <= KPIMContactLargestField)
       
   368         {
       
   369             retVal = KPIMMaxValues[aField - KPIMContactMaxValueMappingOffset];
       
   370         }
       
   371         else if (aField >= KPIMContactSmallestExtField)
       
   372         {
       
   373             if (aField <= KPIMContactLargestExtField)
       
   374             {
       
   375                 retVal = KPIMMaxExtValues[aField
       
   376                                           - KPIMContactMaxExtValueMappingOffset];
       
   377             }
       
   378             // else over extended fields
       
   379         }
       
   380         // else under extended fields
       
   381     }
       
   382     // else under standard fields
       
   383 
       
   384     return retVal;
       
   385 }
       
   386 
       
   387 // -----------------------------------------------------------------------------
       
   388 // CPIMCMAdapterManager::StringArraySizeL
       
   389 // Returns: Number of elements in a single string array value
       
   390 // -----------------------------------------------------------------------------
       
   391 //
       
   392 
       
   393 TInt CPIMCMAdapterManager::StringArraySizeL(TPIMField aStringArrayField)
       
   394 {
       
   395     JELOG2(EPim);
       
   396     TInt retVal = 0;
       
   397     switch (aStringArrayField)
       
   398     {
       
   399     case EPIMContactName:
       
   400     {
       
   401         retVal = KPIMNameArraySize;
       
   402         break;
       
   403     }
       
   404     case EPIMContactAddr:
       
   405     {
       
   406         retVal = KPIMAddrElementCount;
       
   407         break;
       
   408     }
       
   409     default:
       
   410     {
       
   411         User::Leave(KErrArgument);
       
   412     }
       
   413     }
       
   414     return retVal;
       
   415 }
       
   416 
       
   417 // -----------------------------------------------------------------------------
       
   418 // CPIMCMAdapterManager::ItemOrder
       
   419 // Provides pointer to a function which implements an algorithm that
       
   420 // determines the order of two items.
       
   421 // -----------------------------------------------------------------------------
       
   422 //
       
   423 TPIMItemComparisonFunc CPIMCMAdapterManager::ItemOrder()
       
   424 {
       
   425     JELOG2(EPim);
       
   426     return ItemComparisonFunc;
       
   427 }
       
   428 
       
   429 // -----------------------------------------------------------------------------
       
   430 // CPIMCMAdapterManager::GetFieldDataType
       
   431 // Returns: Field type
       
   432 // -----------------------------------------------------------------------------
       
   433 //
       
   434 
       
   435 TPIMFieldDataType CPIMCMAdapterManager::GetFieldDataTypeL(TPIMField aField)
       
   436 {
       
   437     JELOG2(EPim);
       
   438     TPIMFieldDataType retVal = EPIMFieldInvalid;
       
   439     switch (aField)
       
   440     {
       
   441     case EPIMContactName:
       
   442     case EPIMContactAddr:
       
   443     {
       
   444         retVal = EPIMFieldStringArray;
       
   445         break;
       
   446     }
       
   447     case EPIMContactEmail:
       
   448     case EPIMContactFormattedName:
       
   449     case EPIMContactNickname:
       
   450     case EPIMContactNote:
       
   451     case EPIMContactOrg:
       
   452     case EPIMContactTel:
       
   453     case EPIMContactTitle:
       
   454     case EPIMContactUrl:
       
   455     case EPIMContactUid:
       
   456     case EPIMContactExtWvUserId:
       
   457     case EPIMContactExtSip:
       
   458     case EPIMContactExtDtmf:
       
   459     case EPIMContactExtDepartment:
       
   460     case EPIMContactExtAssistantName:
       
   461     case EPIMContactExtSpouse:
       
   462     case EPIMContactExtChildren:
       
   463     case EPIMContactExtVoip:
       
   464     case EPIMContactExtPTT:
       
   465     case EPIMContactExtSWIS:
       
   466     {
       
   467         retVal = EPIMFieldString;
       
   468         break;
       
   469     }
       
   470     case EPIMContactBirthday:
       
   471     case EPIMContactRevision:
       
   472     case EPIMContactExtAnniversary:
       
   473     {
       
   474         retVal = EPIMFieldDate;
       
   475         break;
       
   476     }
       
   477     case EPIMContactPhoto:
       
   478     {
       
   479         retVal = EPIMFieldBinary;
       
   480         break;
       
   481     }
       
   482     case EPIMContactClass:
       
   483     {
       
   484         retVal = EPIMFieldInt;
       
   485         break;
       
   486     }
       
   487     default:
       
   488     {
       
   489         User::Leave(KErrArgument);
       
   490     }
       
   491     }
       
   492     return retVal;
       
   493 }
       
   494 
       
   495 // -----------------------------------------------------------------------------
       
   496 // CPIMCMAdapterManager::GetAdapterManager
       
   497 // Provides access to the MPIMAdapterManager representation of this object
       
   498 // Returns: MPIMAdapterManager representation of this object
       
   499 // -----------------------------------------------------------------------------
       
   500 //
       
   501 MPIMAdapterManager* CPIMCMAdapterManager::GetAdapterManager()
       
   502 {
       
   503     JELOG2(EPim);
       
   504     return this;
       
   505 }
       
   506 
       
   507 // -----------------------------------------------------------------------------
       
   508 // CPIMCMAdapterManager::ItemComparisonFunc
       
   509 // Compares two MPIMItemData objects.
       
   510 // Returns: < 0: aFirst < aSecond
       
   511 //          0: aFirst == aSecond
       
   512 //          > 0: aFirst > aSecond
       
   513 // -----------------------------------------------------------------------------
       
   514 //
       
   515 TInt CPIMCMAdapterManager::ItemComparisonFunc(const MPIMItem& aFirst,
       
   516         const MPIMItem& aSecond)
       
   517 {
       
   518     JELOG2(EPim);
       
   519     TInt retVal = 0;
       
   520     TRAPD(err, retVal = ItemComparisonFuncL(aFirst, aSecond));
       
   521     if (err != KErrNone)
       
   522     {
       
   523         // the comparison failed, but there is no way to tell about it
       
   524         return 0;
       
   525     }
       
   526     return retVal;
       
   527 }
       
   528 
       
   529 // -----------------------------------------------------------------------------
       
   530 // CPIMCMAdapterManager::ItemComparisonFuncL
       
   531 // Compares two MPIMItemData objects.
       
   532 // Returns: < 0: aFirst < aSecond
       
   533 //          0: aFirst == aSecond
       
   534 //          > 0: aFirst > aSecond
       
   535 // -----------------------------------------------------------------------------
       
   536 //
       
   537 
       
   538 TInt CPIMCMAdapterManager::ItemComparisonFuncL(const MPIMItem& aFirst,
       
   539         const MPIMItem& aSecond)
       
   540 {
       
   541     JELOG2(EPim);
       
   542     TInt result = 0; // Items are considered as equal by default
       
   543     TInt countFirst = aFirst.CountValuesL(EPIMContactName);
       
   544     TInt countSecond = aSecond.CountValuesL(EPIMContactName);
       
   545 
       
   546     if (countFirst != 0 && countSecond != 0)
       
   547     {
       
   548         // Both have same values in the name array so compare family and given
       
   549         // name based on that is there a value in the element or not. Family name
       
   550         // first. If not available, use given name. Note that if family names
       
   551         // are equal, the given name must be used
       
   552         const CDesCArray& fNames = aFirst.GetStringArrayL(EPIMContactName, 0);
       
   553         const CDesCArray& sNames = aSecond.GetStringArrayL(EPIMContactName, 0);
       
   554 
       
   555         HBufC* firstName = CreateFullNameLC(fNames);
       
   556         HBufC* secondName = CreateFullNameLC(sNames);
       
   557 
       
   558         result = firstName->CompareC(*secondName);
       
   559         CleanupStack::PopAndDestroy(2, firstName);
       
   560     }
       
   561     // The first has a name but the second does not. The second
       
   562     // is considered as lower priority in the sort order
       
   563     else if (countFirst != 0 && countSecond == 0)
       
   564     {
       
   565         result = -1;
       
   566     }
       
   567     // The second has a name but the first does not. The first
       
   568     // is considered as lower priority in the sort order
       
   569     else if (countFirst == 0 && countSecond != 0)
       
   570     {
       
   571         result = 1;
       
   572     }
       
   573 
       
   574     return result;
       
   575 }
       
   576 // -----------------------------------------------------------------------------
       
   577 // CPIMCMAdapterManager::CPIMCMAdapterManager
       
   578 // C++ default constructor can NOT contain any code, that
       
   579 // might leave.
       
   580 // -----------------------------------------------------------------------------
       
   581 //
       
   582 CPIMCMAdapterManager::CPIMCMAdapterManager()
       
   583 {
       
   584     JELOG2(EPim);
       
   585 }
       
   586 
       
   587 // -----------------------------------------------------------------------------
       
   588 // CPIMCMAdapterManager::ConstructL
       
   589 // Symbian 2nd phase constructor can leave.
       
   590 // -----------------------------------------------------------------------------
       
   591 //
       
   592 void CPIMCMAdapterManager::ConstructL(const TDesC& aListName)
       
   593 {
       
   594     JELOG2(EPim);
       
   595     iListName = aListName.AllocL();
       
   596 
       
   597     iNameElements
       
   598     = new(ELeave) CArrayFixFlat<TPIMArrayElement> (KPIMNameElementCount);
       
   599     iNameElements->AppendL(KPIMNameElements, KPIMNameElementCount);
       
   600 
       
   601     iAddrElements
       
   602     = new(ELeave) CArrayFixFlat<TPIMArrayElement> (KPIMAddrElementCount);
       
   603     iAddrElements->AppendL(KPIMAddrElements, KPIMAddrElementCount);
       
   604 }
       
   605 
       
   606 // -----------------------------------------------------------------------------
       
   607 // CPIMCMAdapterManager::IsSupportedAttribute
       
   608 // Returns:     ETrue: attribute is supported
       
   609 //              EFalse: attribute is not supported
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 
       
   613 TBool CPIMCMAdapterManager::IsSupportedAttributeL(TPIMField aField, // the field to be checked
       
   614         TPIMAttribute aAttribute) // The attribute to be checked
       
   615 {
       
   616     JELOG2(EPim);
       
   617     if (!IsSupportedField(aField))
       
   618     {
       
   619         return EFalse;
       
   620     }
       
   621     const CArrayFix<TPIMAttribute>& attributes =
       
   622         GetSupportedAttributesL(aField);
       
   623     TInt attributeCount = attributes.Count();
       
   624     for (TInt i = 0; i < attributeCount; i++)
       
   625     {
       
   626         if (attributes[i] == aAttribute)
       
   627         {
       
   628             return ETrue;
       
   629         }
       
   630     }
       
   631     return EFalse;
       
   632 }
       
   633 
       
   634 // -----------------------------------------------------------------------------
       
   635 // CPIMCMAdapterManager::IsSupportedArrayElementL
       
   636 // Returns:     ETrue: element is supported
       
   637 //              EFalse: element is not supported
       
   638 // -----------------------------------------------------------------------------
       
   639 //
       
   640 
       
   641 TBool CPIMCMAdapterManager::IsSupportedArrayElementL(
       
   642     TPIMField aStringArrayField, // the field to be checked
       
   643     TPIMArrayElement aArrayElement) // The array element to be checked
       
   644 {
       
   645     JELOG2(EPim);
       
   646     if (!IsSupportedField(aStringArrayField))
       
   647     {
       
   648         return EFalse;
       
   649     }
       
   650     if (GetFieldDataTypeL(aStringArrayField) != EPIMFieldStringArray)
       
   651     {
       
   652         return EFalse;
       
   653     }
       
   654     const CArrayFix<TPIMArrayElement>& elements = GetSupportedArrayElementsL(
       
   655                 aStringArrayField);
       
   656     TInt elementCount = elements.Count();
       
   657     for (TInt i = 0; i < elementCount; i++)
       
   658     {
       
   659         if (elements[i] == aArrayElement)
       
   660         {
       
   661             return ETrue;
       
   662         }
       
   663     }
       
   664     return EFalse;
       
   665 }