javaextensions/pim/cntadapter/src.s60/cpimcontactitemadapter.cpp
changeset 76 4ad59aaee882
parent 69 773449708c84
child 71 d5e927d5853b
equal deleted inserted replaced
69:773449708c84 76:4ad59aaee882
   191         const CContactCard& aCard) // Item to update
   191         const CContactCard& aCard) // Item to update
   192 {
   192 {
   193     JELOG2(EPim);
   193     JELOG2(EPim);
   194     const CDesCArray& pimCategories = aItem.ItemData().Categories();
   194     const CDesCArray& pimCategories = aItem.ItemData().Categories();
   195     const TInt pimCategoryCount = pimCategories.Count();
   195     const TInt pimCategoryCount = pimCategories.Count();
   196     CArrayFix<TInt>* newCategoryTable = new(ELeave) CArrayFixFlat<TInt> (pimCategoryCount);
   196     TBool* newCategoryTable = new(ELeave) TBool[pimCategoryCount];
   197     CleanupStack::PushL(newCategoryTable);    
   197     CleanupArrayDeletePushL(newCategoryTable);
   198     TInt i = 0;
   198     TInt i = 0;
   199     for (i = 0; i < pimCategoryCount; i++)
   199     for (i = 0; i < pimCategoryCount; i++)
   200     {
   200     {
   201         newCategoryTable->InsertL(TRUE,i);
   201         newCategoryTable[i] = ETrue;
   202     }
   202     }
   203 
   203 
   204     CContactIdArray* cardCategories = aCard.GroupsJoinedLC();
   204     CContactIdArray* cardCategories = aCard.GroupsJoinedLC();
   205     TContactItemId id = aItem.ContactItemIdL();
   205     TContactItemId id = aItem.ContactItemIdL();
   206 
   206 
   218             // removed group
   218             // removed group
   219             iCategoryManager.RemoveFromGroupL(id, groupId);
   219             iCategoryManager.RemoveFromGroupL(id, groupId);
   220         }
   220         }
   221         else
   221         else
   222         {
   222         {
   223 			// old group
   223             // old group
   224             newCategoryTable->InsertL(FALSE,pos);
   224             newCategoryTable[pos] = EFalse;
   225         }
   225         }
   226     }
   226     }
   227     // then add new categories
   227     // then add new categories
   228     for (i = 0; i < pimCategoryCount; i++)
   228     for (i = 0; i < pimCategoryCount; i++)
   229     {
   229     {
   230         if (newCategoryTable->At(i))
   230         if (newCategoryTable[i])
   231         {
   231         {
   232             TPtrC category = pimCategories[i];
   232             TPtrC category = pimCategories[i];
   233             iCategoryManager.AddToGroupL(id, category);
   233             iCategoryManager.AddToGroupL(id, category);
   234         }
   234         }
   235     }
   235     }