how to pass TBuf type variable to a functions which will return integer type
| Tue, 2008-08-12 14:21 | |
|
Hi, 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 |
|






Forum posts: 85
I don't think I understood your problem. Where do you get and what error?
Forum posts: 672
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
numberandcontactfor local, automatic variables. Also, sincemakeCallcan leave, it should beMakeCallL. Also, it seems that you leave the contact object to the cleanup stack. Either Pop/PopAndDestroy it or changeMakeCallLtoMakeCallLCand 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);Forum posts: 159
A TBuf is a TDesC, but sometime not putting the const in the parameter declaration causes a compilation error.
Forum posts: 20
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.
Forum posts: 165
Hi rajeshpadhiary,
In your code use
also use CContactItemField and CContactTextField.
Hopefully, it will solve your problem.
Thanks & Regards,
Md.Khalid Ahmad