how to pass TBuf type variable to a functions which will return integer type

Login to reply to this topic.
Tue, 2008-08-12 14:21
Joined: 2008-08-08
Forum posts: 20

Hi,
in my applications i am getting error,plz help me out.
CMapCall::makeCall()
{
TBuf<200> iNumber;
iNumber.Append(_L("Calling\n"));
iNumber.Append(aNumber);
CMapContact *iContact=CMapContact::NewL();
CleanupStack::PushL(iContact);
iContact->FindContactsFromDbL(iNumber);

}

TInt CMapContact::FindContactsFromDbL(TDesC& aMobileNumber)

so error is comming functions mismatch.so plz me how i can TBuf type to functions which is returning int type


Tue, 2008-08-12 14:28
Joined: 2008-06-23
Forum posts: 85
Re: how to pass TBuf type variable to a functions which will ret

I don't think I understood your problem. Where do you get and what error?

Tue, 2008-08-12 19:30
Joined: 2003-12-05
Forum posts: 672
Re: how to pass TBuf type variable to a functions...

CMapCall::makeCall()
{
TBuf<200> iNumber;
iNumber.Append(_L("Calling\n"));
iNumber.Append(aNumber);
CMapContact *iContact=CMapContact::NewL();
CleanupStack::PushL(iContact);
iContact->FindContactsFromDbL(iNumber);
}

Variables with naming convention iSomething should always be member variables of a class -- error here, use just names like number and contact for local, automatic variables. Also, since makeCall can leave, it should be MakeCallL. Also, it seems that you leave the contact object to the cleanup stack. Either Pop/PopAndDestroy it or change MakeCallL to MakeCallLC and make sure the caller is popping and destroying the object from the cleanup stack.

TInt CMapContact::FindContactsFromDbL(TDesC& aMobileNumber);

The parameter you pass is correct. TBuf is-a TDesC (see the descriptor class hierarchy). If you want to receive the integer value from FindContactsFromDbl, do:

TInt result = iContact->FindContactsFromDbL(number);

Tue, 2008-08-12 20:49
Joined: 2007-09-23
Forum posts: 159
Re: how to pass TBuf type variable to a functions which

A TBuf is a TDesC, but sometime not putting the const in the parameter declaration causes a compilation error.

Wed, 2008-08-13 06:10
Joined: 2008-08-08
Forum posts: 20
mapping number with contact database and display the name.

here i have to access the contactdatabase if the number is present ,i have display the name .

void CMapCall::MakeCall(const TDesC& aNumber)
{
TBuf<200> Number;
Number.Append(_L("Calling\n"));
Number.Append(aNumber);
//check with the default database if number is present or not
//OpenDefaultDatabaseL();
//iContact->OpenDefaultDatabaseL();
CMapContact *iContact=CMapContact::NewL();
CleanupStack::PushL(iContact);
iContact->OpenDefaultDatabaseL();
TInt result=iContact->FindContactsFromDbL(Number);
CleanupStack::Pop();

CMapUtil::DisplayMessage(Number);

}

TInt CMapContact::FindContactsFromDbL(const TDesC& aMobileNumber)
{
TInt iNumberOfContacts;
//CContactDatabase* iContactDb=CContactDatabase::OpenL();
iNumberOfContacts=iContactDb->CountL();

const CContactIdArray* iContactIdArray=iContactDb->SortedItemsL();

_LIT(KStandarded,"+91");

TBuf<20>MobileNumber=NULL;
TBuf<20>InternationalNumber(KStandarded);
MobileNumber.Append(aMobileNumber);
InternationalNumber.Append(aMobileNumber);
CContactItem* iContactItem=NULL;
for(TInt i=0;i {
iContactItem=iContactDb->OpenContactL((*iContactIdArray)[i]);
CleanupStack::PushL(iContactItem);
CContactItemFieldSet& aFieldSet=iContactItem->CardFields();

TInt Index=0;
Index=aFieldSet.Find(KUidContactFieldVCardMapCELL);
CContactItemField& aField=aFieldSet

;
CContactTextField* aTestField=aField.TextStorage();

//Phone Number from the ContactDatabase is retrived

MobileNumber=aTestField->Text();
InternationalNumber.Append(MobileNumber);
if(aMobileNumber==MobileNumber||aMobileNumber==InternationalNumber)
{
//can you help me ,here i have to display the name instead of number in ithe information note

}
else
{
//back to the CMapCall::MakeCall()
}
}
CleanupStack::Pop();
//return InternationalNumber;

}

can any help out,if number is present than i have display the name instead number.

Tue, 2008-08-19 10:38
Joined: 2008-01-16
Forum posts: 165
Re: how to pass TBuf type variable to a functions which

Hi rajeshpadhiary,

In your code use

aFieldSet.Find(KUidContactFieldGivenName); //to get First Name
aFieldSet.Find(KUidContactFieldFamilyName); //to get last Name

also use CContactItemField and CContactTextField.

Hopefully, it will solve your problem.


Thanks & Regards,
Md.Khalid Ahmad

  • Login to reply to this topic.