/** * To return a valid contact item id. */ TContactItemId CSyncTestStep::GetValidUIDFromContactsDbL() { TContactItemId firstId(KNullContactId); CContactDatabase *iDb = NULL; TRAPD(err,iDb = CContactDatabase::OpenL()); // open existing database CleanupStack::PushL(iDb); if (err != KErrNone) { CleanupStack::PopAndDestroy(); // iDb return firstId; } iDb->SetDbViewContactType(KUidContactICCEntry); // to get the unique groupId for the phonebook TContactItemId groupId(KNullContactId); User::LeaveIfError(iSession.GetPhoneBookId(groupId, RPhoneBookSession::ESyncGroupId)); TESTCHECKCONDITIONL(groupId != KNullContactId); // based on the groupId, get an item belonging to the phonebook CContactGroup* group = static_cast<CContactGroup*>(iDb->ReadContactLC(groupId)); const CContactIdArray* array = group->ItemsContained(); TInt count(array->Count()); if (count > 0) firstId = (*array)[0]; CleanupStack::PopAndDestroy(group); CleanupStack::PopAndDestroy(); // iDb return firstId; }
/** Create a string representation of the IdMap. * @param s is the string in which the result is returned. */ string& IdMap::toString(string& s) const { stringstream ss; ss << "{ "; for (int i = firstId(); i != 0; i = nextId(i)) { ss << "(" << ht->getKey(i) << "," << i << ") "; } ss << "}"; s = ss.str(); return s; }
/** Clear the IdMap. */ void IdMap::clear() { for (int i = firstId(); i != 0; i = firstId()) ids->swap(i); }