// This tests tries to reproduce defect // EDNRTRN-4J5C5E "Groups in Cntmodel cannot be renamed.." // // This defect was caused because groups weren't included in the view and // MoveInSortArrayL doesn't check that the contact item will be in the // iSortedItems list (this list depends on the view chosen). // LOCAL_C void RenameDefectL() { test.Next(_L("Rename a group")); CntTest->CloseDatabase(); CntTest->DeleteDatabaseL(); CContactDatabase* db=CntTest->CreateDatabaseL(); _LIT(KCntmodelOriginalName,"Original"); _LIT(KCntmodelRevisedName,"Revised"); CContactItem* newGroup = CntTest->Db()->CreateContactGroupLC(KCntmodelOriginalName); TContactItemId groupId = newGroup->Id(); CleanupStack::PopAndDestroy(); //newGroup TContactItemId contactA=AddContactL(db,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,_L("a")); TContactItemId contactB=AddContactL(db,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,_L("b")); CntTest->Db()->AddContactToGroupL(contactA,groupId); CntTest->Db()->AddContactToGroupL(contactB,groupId); CntTest->Db()->SetDbViewContactType(KUidContactCard); CntTest->Db()->SortedItemsL(); // ensures theres a iSortedItems SetSortOrderL(*db,TUid::Uid(KUidContactFieldDefinedTextValue)); // required so that the comparision CContactGroup* group = static_cast<CContactGroup*>(CntTest->Db()->OpenContactL(groupId)); CleanupStack::PushL(group); group->SetGroupLabelL(KCntmodelRevisedName); CntTest->Db()->CommitContactL(*group); CntTest->Db()->CloseContactL(groupId); CleanupStack::PopAndDestroy(); //group CContactItem* revisedGroup = CntTest->Db()->ReadContactLC(groupId,*CntTest->Db()->AllFieldsView()); TPtrC testLabel = static_cast<CContactGroup*>(revisedGroup)->GetGroupLabelL(); test(testLabel==KCntmodelRevisedName); CleanupStack::PopAndDestroy(); //revisedGroup }
/** Protected second phase constructor. The view is sorted according to the sort order and view preferences specified, using a low priority idle time active object. The specified view observer is notified when the view is sorted and ready for use. Called by NewL(). @param aObserver An observer that receives notifications when this view is ready for use and when changes take place in it. The observer receives a TContactViewEvent::EReady event when the view is ready. Any attempt to use the view before this notification will Leave with KErrNotReady. @param aSortOrder Specifies the fields to use to sort the items in the view. @param aUseNamedPlugin A flag indicates whether the aSortPluginName parameter is valid. @param aSortPluginName Specifies a plug-in that will be used to compare view contacts when the the view is sorted. This name is used by ECOM to select the plugin, and is matched with the "default_data" of all ECOM plugins that support the required interface. */ void CContactLocalView::ConstructL(MContactViewObserver& aObserver,const RContactViewSortOrder& aSortOrder, TBool aUseNamedPlugin, const TDesC8& aSortPluginName) { CContactViewBase::ConstructL(); if(iFactory == NULL) { iFactory = const_cast<CContactDatabase&>(iDb).FactoryL(); } OpenL(aObserver); if (aUseNamedPlugin) { // find and load Sort plug-in if (aSortPluginName.Length()) { TUid sortPluginUid = FindSortPluginImplL (aSortPluginName); LoadViewSortPluginL(sortPluginUid, iViewPreferences); } } else { // find and load default Sort plug-in (if any) TUid sortPluginUid = FindDefaultViewSortPluginImplL(); if (sortPluginUid != KNullUid) { LoadViewSortPluginL(sortPluginUid, iViewPreferences); } } //Initialise sort order and textdef. SetSortOrderL(aSortOrder); //Create view contact manager to handle sorting iViewCntMgr = CViewContactManager::NewL(*this, *iFactory, *iTextDef, iViewPreferences, SortPluginImpl()); if (&iDb != NULL) { const_cast<CContactDatabase&>(iDb).AddObserverL(*this); } //Doing the sort. SortL(); }
/** Sorts the view using the specified sort order, using a low priority idle time active object. This function is called during view construction and on receipt of certain change events from the underlying database. @param aSortOrder Specifies the fields to use to sort the items in the view. */ EXPORT_C void CContactLocalView::SortL(const RContactViewSortOrder& aSortOrder) { #ifdef CONTACTS_API_PROFILING TContactsApiProfile::CntViewMethodLog(TContactsApiProfile::ECntVwClassLocalView, TContactsApiProfile::ECntViewApiSortL); #endif if (&iDb != NULL) { if (!iDb.DatabaseReadyL()) { User::Leave(KErrNotReady); } } //set new sort order which also updates iTextDef. SetSortOrderL(aSortOrder); // reset sort error iExtension->iError = KErrNone; iViewCntMgr->SortL(*iTextDef); }
// This tests reproduces defect // BET-4YDGB3 "Contacts crashes when creating two entries" // // This was caused because the CContactTables::ContactType() method uses the // iCurrentIdInIdentityTable to determine which contact should be used to read // the type information from. This member stores the last contact ID to be read // from the identity table. However, since AddContactToGroupL() doesn't read any // information from the identity table, the value set in iCurrentIdInIdentityTable // should be set to KErrNotFound so that the correct contact from main CONTACTS table // is used. // LOCAL_C void QuartzGroupDefectL() { test.Next(_L("Quartz defect")); CntTest->CloseDatabase(); CntTest->DeleteDatabaseL(); CContactDatabase* db=CntTest->CreateDatabaseL(); _LIT(KCntmodelGroupAll,"All"); CContactItem* group = db->CreateContactGroupLC(KCntmodelGroupAll); TContactItemId groupId = group->Id(); CleanupStack::PopAndDestroy(group); CntTest->Db()->SetDbViewContactType(KUidContactCard); CntTest->Db()->SortedItemsL(); // ensures theres a iSortedItems SetSortOrderL(*db,TUid::Uid(KUidContactFieldDefinedTextValue)); // required so that the comparision TContactItemId contactB=AddContactL(db,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,_L("B")); CntTest->Db()->AddContactToGroupL(contactB,groupId); TContactItemId contactA=AddContactL(db,KUidContactFieldFamilyName,KUidContactFieldVCardMapUnusedN,_L("A")); CntTest->Db()->AddContactToGroupL(contactA,groupId); }