本文整理汇总了C++中CContactIdArray::AddL方法的典型用法代码示例。如果您正苦于以下问题:C++ CContactIdArray::AddL方法的具体用法?C++ CContactIdArray::AddL怎么用?C++ CContactIdArray::AddL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CContactIdArray
的用法示例。
在下文中一共展示了CContactIdArray::AddL方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateTestContactsL
// Creates a few test contacts.
void CTestResources::CreateTestContactsL()
{
TContactItemId id;
id = CreateTestContactL(*iDb, _L("Hakkinen"), _L("Mika"), _L("McLaren"));
iContacts->AddL(id);
id = CreateTestContactL(*iDb, _L("Coulthard"), _L("David"), _L("McLaren"));
iContacts->AddL(id);
id = CreateTestContactL(*iDb, _L("Schumacher"), _L("Michael"), _L("Ferrari"));
iContacts->AddL(id);
id = CreateTestContactL(*iDb, _L("Raikkonen"), _L("Kimi"), _L("Sauber"));
iContacts->AddL(id);
}
示例2: doCreateDefaultCContactIdArrayL
CContactIdArray* CPackagerCntFactory::doCreateDefaultCContactIdArrayL() const
/** Implementation method for constructing a new default CContactIdArray object.
@return a Pointer to the CContactIdArray object. */
{
CContactIdArray* theArray = CContactIdArray::NewL();
CleanupStack::PushL(theArray);
theArray->AddL(KId1);
theArray->AddL(KId2);
theArray->AddL(KId3);
theArray->AddL(KId4);
theArray->AddL(KId5);
CleanupStack::Pop(theArray);
return theArray;
}
示例3: AddContactsL
void CFilteredViewTester::AddContactsL(TInt aCount)
{
for (TInt i = 0; i < aCount; ++i)
{
iIdArray->AddL(DoAddContactL(i));
}
}
示例4: MatchNonPhoneAddrL
/**
Searches the contacts database to find any contact items with an exact match on the address supplied.
@param aCommAddr A descriptor containing the address to be found in the database.
@param aAddrType The type of addresses that is being sought.
@return An array of contact IDs which match the supplied address.
*/
CContactIdArray* CPplCommAddrTable::MatchNonPhoneAddrL(const TDesC& aCommAddr, TCommAddrType aAddrType)
{
// build statement
RSqlStatement stmnt;
CleanupClosePushL(stmnt);
stmnt.PrepareL(iDatabase, iMatchSelectStmnt->SqlStringL() );
const TInt KValueParamIndex(KFirstParam); // first parameter in query...
const TInt KTypeParamIndex(KValueParamIndex + 1); // ...and the second.
User::LeaveIfError(stmnt.BindText(KValueParamIndex, aCommAddr) );
User::LeaveIfError(stmnt.BindInt(KTypeParamIndex, aAddrType) );
// fetch the list of any matching contact ids
CContactIdArray* idArray = CContactIdArray::NewLC();
TInt err(KErrNone);
const TInt KContactIdIdx(iMatchSelectStmnt->ParameterIndex(KCommAddrContactId() ) );
while ((err = stmnt.Next() ) == KSqlAtRow)
{
idArray->AddL(stmnt.ColumnInt(KContactIdIdx) );
}
// leave if we didn't complete going through the results properly
if(err != KSqlAtEnd)
{
User::Leave(err);
}
CleanupStack::Pop(idArray);
CleanupStack::PopAndDestroy(&stmnt);
return idArray;
}
示例5: ExportVcardL
/**
exports all contacts items in db to vcard file, if aDelete, cleans database afterwards
*/
void CPerformanceFunctionalityBase::ExportVcardL(const TBool aDelete, const TDesC &aVCard)
{
iIterate->Reset();
CContactIdArray *ids = CContactIdArray::NewLC();
TInt i = 0;
for(; i < iContacts; ++i)
{
ids->AddL( iIterate->NextL() );
}
RFileWriteStream rfws;
CleanupClosePushL(rfws);
User::LeaveIfError( rfws.Replace( iParent->Fs(),aVCard , EFileWrite | EFileShareAny ) );
iContactsDatabase->ExportSelectedContactsL( TUid::Uid(KUidVCardConvDefaultImpl), *ids, rfws,
CContactDatabase::EIncludeX | CContactDatabase::ETTFormat );
CleanupStack::PopAndDestroy(&rfws);
if( aDelete )
{
CLEAR( iContactsDatabase );
iContactsDatabase = CContactDatabase::ReplaceL();
}
CleanupStack::PopAndDestroy(ids);
}
示例6: DoTestsL
LOCAL_C void DoTestsL()
{
CleanupClosePushL(test);
test.Start(_L("@SYMTESTCaseID:PIM-T-TEMPLATECACHE-0001 ----------- State Tests ----------"));
__UHEAP_MARK;
RCntModel cntClient;
cntClient.ConnectL();
cntClient.OpenDatabase();
CCntTemplateCache* templateCache = CCntTemplateCache::NewL(cntClient);
CleanupStack::PushL(templateCache);
CContactIdArray* cardTemplateIds = CContactIdArray::NewLC();
// Add 15 templates
CContactTemplate* contactTemplate = NULL;
TInt ii = 0;
for (; ii < 15; ++ii)
{
contactTemplate = CContactTemplate::NewLC();
cardTemplateIds->AddL(cntClient.CreateContactL(*contactTemplate));
CleanupStack::PopAndDestroy(); // contactTemplate
}
// Create a contactItem
CCntItemBuilder* cntItemBldr = CCntItemBuilder::NewLC(static_cast<CContactTemplate&>(templateCache->SystemTemplateL()));
CContactItem* cntItem = cntItemBldr->GetCntItemLC();
/*TContactItemId cntId = */cntClient.CreateContactL(*cntItem);
ii = 0;
for (; ii < 15; ++ii)
{
cntItem->SetTemplateRefId((*cardTemplateIds)[ii]);
templateCache->MergeWithTemplateL(*cntItem);
// Merge a second time... the template should now be cached
templateCache->MergeWithTemplateL(*cntItem);
}
CleanupStack::PopAndDestroy(cntItem);
CleanupStack::PopAndDestroy(cntItemBldr);
CleanupStack::PopAndDestroy(cardTemplateIds);
CleanupStack::PopAndDestroy(templateCache);
cntClient.Close();
__UHEAP_MARKEND;
test.Next(_L("---- All Tests Completed OK ----"));
test.End();
CleanupStack::PopAndDestroy(1); // test.Close
}
示例7: GetListForItemL
/**
GetListForItemL has a dual nature. If aIsGroup is ETrue, a list of contact items belonging to
specified group is returned. Otherwise a list of group ids to which contact id belongs is returned.
@param aItemId contact item id
@param aIsGroup ETrue if the method will fill a group.
*/
CContactIdArray* CPplGroupsTable::GetListForItemL(TContactItemId aItemId, TBool aIsGroup)
{
/*
// Check if group membership information was not requested or if the item
// is not derived from CContactItemPlusGroup.
if (!(aType == KUidContactGroup || aType == KUidContactCard ||
aType == KUidContactOwnCard || aType == KUidContactICCEntry) )
{
return NULL;
}
*/
// build the RSqlStatement
RSqlStatement stmnt;
CleanupClosePushL(stmnt);
TInt idIndex;
// build the CCntSqlStatement statement
const TInt KWhereParamIndex(KFirstIndex); // only one parameter in the query
if (aIsGroup)
{
// group -> select members
stmnt.PrepareL(iDatabase, iSelectMembersStmnt->SqlStringL() );
User::LeaveIfError(stmnt.BindInt(KWhereParamIndex, aItemId ) );
idIndex = stmnt.ColumnIndex(KGroupContactGroupMemberId() );
}
else
{
// member -> select groups
stmnt.PrepareL(iDatabase, iSelectGroupsStmnt->SqlStringL() );
User::LeaveIfError(stmnt.BindInt(KWhereParamIndex, aItemId ) );
idIndex = stmnt.ColumnIndex(KGroupContactGroupId() );
}
User::LeaveIfError(idIndex);
// fetch the list of any matching ids
CContactIdArray* items = CContactIdArray::NewLC();
TInt err(KErrNone);
while ((err = stmnt.Next() ) == KSqlAtRow)
{
items->AddL(stmnt.ColumnInt(idIndex) );
}
// leave if we didn't complete going through the results properly
if(err != KSqlAtEnd)
{
User::Leave(err);
}
CleanupStack::Pop(items);
CleanupStack::PopAndDestroy(&stmnt);
return items;
}
示例8: CreateRandomIdArrayL
/*
Creates a random array of numbers corresponding to the Contacts Id in the
Contacts model. No Contact Id is repeated
*/
void CDeleteMany::CreateRandomIdArrayL(CContactIdArray& aUids, TInt aNumIds, TInt aNumEntriesInDb)
{
TTime now;
now.UniversalTime();
TInt64 KRandomSeed = now.DateTime().MicroSecond();
TInt uid(0);
for(TInt i = 0; i < aNumIds; ++i)
{
uid = (Math::Rand(KRandomSeed) % aNumEntriesInDb) + 1;
while(aUids.Find(uid) != KErrNotFound)
{
uid = (Math::Rand(KRandomSeed) % aNumEntriesInDb) + 1;
}
aUids.AddL(uid);
}
}
示例9: GetContactIdsL
/**
Convert between view indexes and contact ids.
This method makes the request to the server.
@capability ReadUserData
*/
void RContactRemoteView::GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds)
{
CBufBase* buffer = CBufFlat::NewL(32);
CleanupStack::PushL(buffer);
RBufWriteStream writeStream(*buffer);
CleanupClosePushL(writeStream);
const TInt count = aIndexes.Count();
writeStream.WriteUint32L(count);
for (TInt i=0; i<count; ++i)
{
writeStream.WriteUint32L(aIndexes[i]);
}
writeStream.CommitL();
CleanupStack::PopAndDestroy(&writeStream); //writeStream.Close()
TPtr8 indexes(buffer->Ptr(0));
const TInt bufferSize = buffer->Size();
TPckg<TInt> size(bufferSize);
HBufC8* buf=HBufC8::NewLC(bufferSize);
TPtr8 ids(buf->Des());
TIpcArgs args(&size, &indexes, &ids);
User::LeaveIfError(SendReceive(ECntGetContactIds,args));
RDesReadStream readStream(ids);
CleanupClosePushL(readStream);
CContactIdArray* array = CContactIdArray::NewLC();
readStream >> *array;
const TInt arrayCount = array->Count();
for(TInt loop=0;loop<arrayCount;loop++)
aContactIds.AddL((*array)[loop]);
CleanupStack::PopAndDestroy(4,buffer); //array, &readStream, buf, buffer
}
示例10: CreateTestContactsL
void CTestResources::CreateTestContactsL()
{
const TInt KContacts = 4;
TInt i;
iContacts = CContactIdArray::NewL();
// Create contacts
for (i=1; i <= KContacts; ++i)
{
CContactCard* card = CContactCard::NewLC();
CContactItemField* field = CContactItemField::NewLC(KStorageTypeText, KUidContactFieldFamilyName);
TBuf<30> name;
name.Format(_L("Contact%02d"), i);
field->TextStorage()->SetTextL(name);
card->AddFieldL(*field);
CleanupStack::Pop(field);
const TContactItemId contactId = iDb->AddNewContactL(*card);
iContacts->AddL(contactId);
CleanupStack::PopAndDestroy(card);
// Eat away contact db events
TContactDbObserverEvent event;
test(iDbEventQueue->ListenForEvent(10,event));
}
// Create a group
CContactItem* group = iDb->CreateContactGroupLC(_L("TestGroup"));
iGroupId = group->Id();
CleanupStack::PopAndDestroy(group);
// Connect half of the contacts to the group
for (i=0; i < iContacts->Count(); ++i)
{
if (i%2 == 0)
{
iDb->AddContactToGroupL((*iContacts)[i], iGroupId);
}
}
}
示例11: BestMatchingPhoneNumberL
/**
Returns an array of contact item IDs for all the contact items which may contain
the specified telephone number in a telephone, fax or SMS type field.
This is improved version of MatchPhoneNumberL method.
The number is compared starting from the right side of the number and
the method returns an array of candidate matches.
Punctuation (e.g. spaces) and other alphabetic characters are ignored
when comparing. Leading zeros are removed. Digits are compared up to
the lenght of shorter number.
@param aNumber Phone number string.
@return Array of contact IDs which are candidate matches.
*/
CContactIdArray* CPplCommAddrTable::BestMatchingPhoneNumberL(const TDesC& aNumber)
{
const TInt KUpperMaxLength = KMaxPhoneMatchLength - KLowerSevenDigits;
CContactIdArray* phoneMatchArray = CContactIdArray::NewLC();
TMatch phoneDigits = CreatePaddedPhoneDigitsL(aNumber, KLowerSevenDigits, KUpperMaxLength);
if (phoneDigits.iNumLowerDigits + phoneDigits.iNumUpperDigits > 0)
{
// build statement
RSqlStatement stmnt;
CleanupClosePushL(stmnt);
stmnt.PrepareL(iDatabase, iMatchSelectStmnt->SqlStringL());
const TInt KValueParamIndex(KFirstParam); // first parameter in query...
const TInt KTypeParamIndex(KValueParamIndex + 1); // ...and the second.
User::LeaveIfError(stmnt.BindInt(KValueParamIndex,
phoneDigits.iLowerSevenDigits));
User::LeaveIfError(stmnt.BindInt(KTypeParamIndex, EPhoneNumber));
// fetch the list of any matching contact ids
TInt err(KErrNone);
const TInt KContactIdIdx(iMatchSelectStmnt->ParameterIndex( KCommAddrContactId()));
const TInt KExtraValueIdx(iMatchSelectStmnt->ParameterIndex(KCommAddrExtraValue()));
while ((err = stmnt.Next()) == KSqlAtRow)
{
// Check the upper digits...
TInt32 number = phoneDigits.iUpperDigits;
TPtrC extValString = stmnt.ColumnTextL(KExtraValueIdx);
TInt32 storedUpperDigits;
User::LeaveIfError(TLex(extValString).Val(storedUpperDigits));
TInt32 stored = storedUpperDigits;
TBool nonZeroInStoredFound = EFalse;
TBool nonZeroInNumberFound = EFalse;
while ((number != 0) && (stored != 0))
{
nonZeroInNumberFound |= (number % 10 != 0);
nonZeroInStoredFound |= (stored % 10 != 0);
if (nonZeroInStoredFound && nonZeroInNumberFound)
{
break;
}
number /= 10;
stored /= 10;
}
if ( (phoneDigits.iUpperDigits == 0) || (storedUpperDigits == 0) ||
(number == stored) )
{
phoneMatchArray->AddL(stmnt.ColumnInt(KContactIdIdx));
}
}
// leave if we didn't complete going through the results properly
if (err != KSqlAtEnd)
{
User::Leave(err);
}
CleanupStack::PopAndDestroy(&stmnt);
}
CleanupStack::Pop(phoneMatchArray);
return phoneMatchArray;
}
示例12: MatchPhoneNumberL
/**
Returns an array of contact item IDs for all the contact items which may contain
the specified telephone number in a telephone, fax or SMS type field.
The comparison method used is not exact. The number is compared starting from
the right side of the number and the method returns an array of candidate
matches. Punctuation (e.g. spaces) and other alphabetic characters are ignored
when comparing.
Additionally, if the Contacts Model Phone Parser (CNTPHONE.DLL) is available,
then any DTMF digits are also excluded from the comparision.
Note that due to the way numbers are stored in the database, it is recommended
that at least 7 match digits are specified even when matching a number
containing fewer digits. Failure to follow this guideline may (depending on the
database contents) mean that the function will not return the expected Contact
IDs.
@param aNumber Phone number string.
@param aMatchLengthFromRight Number of digits from the right of the phone number
to use. Up to 15 digits can be specified, and it is recommended that at least 7
match digits are specified.
@param aDatabase The database.
@return Array of contact IDs which are candidate matches.
*/
CContactIdArray* CPplCommAddrTable::MatchPhoneNumberL(const TDesC& aNumber, const TInt aMatchLengthFromRight)
{
CContactIdArray* phoneMatchArray = CContactIdArray::NewLC();
TInt numLowerDigits = aMatchLengthFromRight;
TInt numUpperDigits = 0;
if(numLowerDigits > KLowerSevenDigits)
{
// New style matching.
numLowerDigits = KLowerSevenDigits;
numUpperDigits = aMatchLengthFromRight - KLowerSevenDigits;
}
TMatch phoneDigits = CreatePaddedPhoneDigitsL(aNumber, numLowerDigits, numUpperDigits);
if (phoneDigits.iNumLowerDigits + phoneDigits.iNumUpperDigits > 0)
{
// build statement
RSqlStatement stmnt;
CleanupClosePushL(stmnt);
stmnt.PrepareL(iDatabase, iMatchSelectStmnt->SqlStringL() );
const TInt KValueParamIndex(KFirstParam); // first parameter in query...
const TInt KTypeParamIndex(KValueParamIndex + 1); // ...and the second.
User::LeaveIfError(stmnt.BindInt(KValueParamIndex, phoneDigits.iLowerSevenDigits ));
User::LeaveIfError(stmnt.BindInt(KTypeParamIndex, EPhoneNumber ));
// fetch the list of any matching contact ids
TInt err(KErrNone);
const TInt KContactIdIdx(iMatchSelectStmnt->ParameterIndex(KCommAddrContactId() ) );
const TInt KExtraValueIdx(iMatchSelectStmnt->ParameterIndex(KCommAddrExtraValue() ) );
while ((err = stmnt.Next() ) == KSqlAtRow)
{
if (aMatchLengthFromRight <= KLowerSevenDigits)
{
// Matching 7 or less digits...we've already matched.
phoneMatchArray->AddL(stmnt.ColumnInt(KContactIdIdx) );
}
else
{
// Check the upper digits...
TInt32 storedUpperDigits(0);
TPtrC extValString = stmnt.ColumnTextL(KExtraValueIdx);
User::LeaveIfError(TLex(extValString).Val(storedUpperDigits) );
const TInt KDigitsToRemove = KMaxPhoneMatchLength - KLowerSevenDigits - phoneDigits.iNumUpperDigits;
for(TInt i = 0; i < KDigitsToRemove; ++i)
{
// repeatedly divide by 10 to lop off the appropriate number of digits from the right
storedUpperDigits /= 10;
}
storedUpperDigits = TMatch::PadOutPhoneMatchNumber(storedUpperDigits, KDigitsToRemove);
if (phoneDigits.iUpperDigits == storedUpperDigits)
{
phoneMatchArray->AddL(stmnt.ColumnInt(KContactIdIdx) );
}
}
}
// leave if we didn't complete going through the results properly
if(err != KSqlAtEnd)
{
User::Leave(err);
}
CleanupStack::PopAndDestroy(&stmnt);
}
CleanupStack::Pop(phoneMatchArray);
return phoneMatchArray;
}
示例13: RunL
void CGroupViewTester::RunL()
{
switch (iCurrentTest)
{
case ECreateLocalView:
iLog.LogLine(_L("Creating local view"));
iLocalView = CContactLocalView::NewL( *this, iDb, iSortOrder_1,
EContactAndGroups );
break;
case ECreateGroupOneView:
iLog.LogLine(_L("Creating group view one."));
// Create a version 2 object.
iGroupViewOne = CContactGroupView::NewL( *iLocalView, iDb, *this,
iGroupOne->Id(), CContactGroupView::EShowContactsInGroup );
break;
case ECreateGroupTwoView:
{
iLog.LogLine(_L("Creating group view two."));
iGroupViewTwo = CContactGroupView::NewL( *iLocalView, iDb, *this,
KNullContactId, CContactGroupView::EShowContactsNotInAnyGroup );
}
break;
case EDeleteItemsFromView:
{
iLog.LogLine(_L("Deleting contacts from group one."));
TInt id1 = 1;
TInt index = iGroupViewOne->FindL( id1 );
iLog.LogLine( _L("Deleting contact id %d. index = %d"), id1, index );
TInt id2 = 2;
index = iGroupViewOne->FindL( 2 );
iLog.LogLine( _L("Deleting contact id %d. index = %d"), id2, index );
// Delete two contacts using a bulk delete.
TInt numContactsInGroup = iGroupViewOne->CountL();
CContactIdArray* itemsToDelete = CContactIdArray::NewL();
CleanupStack::PushL( itemsToDelete );
itemsToDelete->AddL( id1 );
itemsToDelete->AddL( id2 );
iDb.DeleteContactsL( *itemsToDelete );
CleanupStack::PopAndDestroy( itemsToDelete );
break;
}
case EAddItemToGroup:
{
iLog.LogLine(_L("Adding contact to database and group one."));
// Create a new item and add it to group one.
iIdAdded = iTestConductor->AddRandomContactL();
iDb.AddContactToGroupL( iIdAdded, iGroupOne->Id() );
break;
}
case ENumTests:
// Tests complete.
iLog.LogLine(_L("All tests complete."));
CActiveScheduler::Stop();
delete this;
break;
default:
ASSERT( EFalse );
break;
}
}
示例14: ExportContactsL
//.........这里部分代码省略.........
if(iInvalidFileSystem)
{
#ifdef _DEBUG
fsSession.SetErrorCondition(KErrNotReady);
TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter));
if(err == KErrNotReady)
{
SetTestStepResult(EPass);
}
else
{
SetTestStepResult(EFail);
}
fsSession.SetErrorCondition(KErrNone);
#endif
}
else
{
if(!iSetOOM)
{
if(idArray->Count() > 0)
{
for(TInt i=0; i<idArray->Count() ; i++)
{
TInt dCount = dBase->CountL();
if(i>=dCount)
{
break;
}
// temporary array used to export one contact at a time
CContactIdArray* tempIdArray = CContactIdArray::NewL();
CleanupStack::PushL(tempIdArray);
tempIdArray->AddL((*idArray)[i]);
TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, tempIdArray, writeStream, iContactFilter));
if(err != KErrNone )
{
if(err != KErrNotFound)
{
SetTestStepError(err);
}
}
CleanupStack::PopAndDestroy(tempIdArray);
}
}
else
{
if(idArray->Count()==0)
{
TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter));
if(err != KErrNone)
{
SetTestStepError(err);
}
}
}
}
else
{
TInt tryCount = 1;
for ( ;; )
{
__UHEAP_SETFAIL(RHeap::EDeterministic, tryCount);