Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

Hi,

    I have added successfully few records into address book while reading it is crashing.

here i have attached code snippet.

plz can anyone check this let me know the problem.

 

 

static void Create_AddressBook(ContactsNew* pMe)
{
pim_IContactsRecord *pIContactsRec = NULL;
int Result, i;

if(!pMe->pIContacts)
Result = ISHELL_CreateInstance(pMe->m_pIShell, pim_AEECLSID_EFSDBDevice, (void**)&pMe->pIContacts);

for(i = 0; i < 5; i++)
{
Result = pim_IContacts_CreateRecord( pMe->pIContacts,&pIContactsRec);

Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/1/Type",L"HOME");
Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/1/Value",L"1111111111");

Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/2/Type",L"CELL");
Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/2/Value",L"3333333333");

Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/3/Type",L"WORK");
Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/3/Value",L"5555555555");

Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/4/Type",L"PAGER");
Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/4/Value",L"");

Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/5/Type",L"FAX");
Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/5/Value",L"9999999999");

Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/6/Type",L"GENERIC");
Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/6/Value",L"1111122222");

Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/7/Type",L"OTHER");
Result =pim_IContactsRecord_SetFieldValue(pIContactsRec,"Phone/7/Value",L"1111133333");

// Add First record
Result = pim_IContacts_AddRecord(pMe->pIContacts, pIContactsRec);
if(pIContactsRec)
{
pim_IContactsRecord_Release(pIContactsRec);
pIContactsRec = NULL;
}
}
if (pMe->pIContacts)
{
pim_IContacts_Release(pMe->pIContacts);
pMe->pIContacts = NULL;
}
Readab(pMe, "Phone/1/Value");
Readab(pMe, "Phone/2/Value");
Readab(pMe, "Phone/3/Value");
Readab(pMe, "Phone/4/Value");
Readab(pMe, "Phone/5/Value");
Readab(pMe, "Phone/6/Value");
Readab(pMe, "Phone/7/Value");

static void Readab(ContactsNew* pMe, char *temp2)
{
pim_IContactsRecord *pIContactsRec = NULL;
int Result;
int NumOfRecords;
int nLenReq;

if(!pMe->pIContacts)
Result = ISHELL_CreateInstance(pMe->m_pIShell, pim_AEECLSID_EFSDBDevice, (void**)&pMe->pIContacts);

Result = pim_IContacts_SearchCount( pMe->pIContacts, L"", &NumOfRecords);
Result = pim_IContacts_Search( pMe->pIContacts, L"", &pMe->pIContactResult);

while ((AEE_SUCCESS == Result) && pMe->pIContactResult)
{
Result = pim_IContactsResults_GetNext( pMe->pIContactResult, &pIContactsRec);

if (AEE_SUCCESS == Result)
{
Result = pim_IContactsRecord_GetFieldValue(pIContactsRec,temp2,NULL,0,&nLenReq);
if (AEE_SUCCESS == Result)
{
AECHAR *FieldValue;
// allocate a buffer for the result
FieldValue = (AECHAR*)MALLOC(nLenReq);
Result = pim_IContactsRecord_GetFieldValue( pIContactsRec,temp2,FieldValue, nLenReq, &nLenReq);

FREEIF(FieldValue);
}
}
IQI_RELEASEIF(pIContactsRec);
}
IQI_RELEASEIF(pMe->pIContactResult);
if (pMe->pIContacts)
{
pim_IContacts_Release(pMe->pIContacts);
pMe->pIContacts = NULL;
}

I tried my below code and it worked without any crash..
addgetcontact *pMe = (addgetcontact *)pme;
AEEResult nErr;
pim_IContactsRecord *pRecord = NULL;
pim_IContactsRecord *piRecord = NULL;
int nCount;
int i;

pim_IContactsRecord *pIContactsRec = NULL;
int Result;
int NumOfRecords;
int nLenReq;

AECHAR* pwszSpeedDial;
AECHAR* pwszName;
AECHAR* pwszNumber;

nErr = pim_IContacts_CreateRecord(pMe->pEfsContacts, &pRecord);

pwszSpeedDial = L"5";
pwszName = L"Happy";
pwszNumber = L"12345";

nErr = pim_IContactsRecord_SetFieldValue(pRecord, "Name/1/Value", pwszName);

nErr = pim_IContactsRecord_SetFieldValue(pRecord, "Phone/1/Value", pwszNumber);

nErr = pim_IContactsRecord_SetFieldValue(pRecord, "Phone/1/SpeedDial", pwszSpeedDial);

nErr = pim_IContacts_AddRecord(pMe->pEfsContacts, pRecord);

Result = pim_IContacts_SearchCount( pMe->pEfsContacts, L"", &NumOfRecords);
Result = pim_IContacts_Search( pMe->pEfsContacts, L"", &pMe->pIContactResult);

while ((AEE_SUCCESS == Result) && pMe->pIContactResult)
{
IQI_RELEASEIF(pIContactsRec);
Result = pim_IContactsResults_GetNext( pMe->pIContactResult, &pIContactsRec);

if (AEE_SUCCESS == Result)
{
Result = pim_IContactsRecord_GetFieldValue(pIContactsRec,"Name/1/Value",NULL,0,&nLenReq);
}
}

IQI_RELEASEIF(pMe->pIContactResult);

IQI_RELEASEIF(pRecord);
IQI_RELEASEIF(piRecord);Can you debug further which api is crashng?

I tried my below code and it worked without any crash..
addgetcontact *pMe = (addgetcontact *)pme;
AEEResult nErr;
pim_IContactsRecord *pRecord = NULL;
pim_IContactsRecord *piRecord = NULL;
int nCount;
int i;

pim_IContactsRecord *pIContactsRec = NULL;
int Result;
int NumOfRecords;
int nLenReq;

AECHAR* pwszSpeedDial;
AECHAR* pwszName;
AECHAR* pwszNumber;

nErr = pim_IContacts_CreateRecord(pMe->pEfsContacts, &pRecord);

pwszSpeedDial = L"5";
pwszName = L"Happy";
pwszNumber = L"12345";

nErr = pim_IContactsRecord_SetFieldValue(pRecord, "Name/1/Value", pwszName);

nErr = pim_IContactsRecord_SetFieldValue(pRecord, "Phone/1/Value", pwszNumber);

nErr = pim_IContactsRecord_SetFieldValue(pRecord, "Phone/1/SpeedDial", pwszSpeedDial);

nErr = pim_IContacts_AddRecord(pMe->pEfsContacts, pRecord);

Result = pim_IContacts_SearchCount( pMe->pEfsContacts, L"", &NumOfRecords);
Result = pim_IContacts_Search( pMe->pEfsContacts, L"", &pMe->pIContactResult);

while ((AEE_SUCCESS == Result) && pMe->pIContactResult)
{
IQI_RELEASEIF(pIContactsRec);
Result = pim_IContactsResults_GetNext( pMe->pIContactResult, &pIContactsRec);

if (AEE_SUCCESS == Result)
{
Result = pim_IContactsRecord_GetFieldValue(pIContactsRec,"Name/1/Value",NULL,0,&nLenReq);
}
}

IQI_RELEASEIF(pMe->pIContactResult);

IQI_RELEASEIF(pRecord);
IQI_RELEASEIF(piRecord);Can you debug further which api is crashng?

Hi,
    it is crashing at IQI_RELEASEIF(pIContactsRec), while reading Readab(pMe, "Phone/3/Value");
plz once can u debug my code u ll get the exact scenario.
 
Thanks
 

Hi,
    it is crashing at IQI_RELEASEIF(pIContactsRec), while reading Readab(pMe, "Phone/3/Value");
plz once can u debug my code u ll get the exact scenario.
 
Thanks
 

Hi,
    i have added record with name(fname, lname, fullname), phone(home, work, cell, pager, fax, generic,
other), address, url, email and notes fields.
pim_IContacts_AddRecord() returns success.
when i tried to read name or email fields its working fine.
but if i tried to read phone fields its crashing at pim_IContactsRecord_GetFieldValue() or
IQI_RELEASEIF(pIContactsRec).
what may be the problem?? is it problem with phone fields ??
am i adding phone field properly??

Hi,
    i have added record with name(fname, lname, fullname), phone(home, work, cell, pager, fax, generic,
other), address, url, email and notes fields.
pim_IContacts_AddRecord() returns success.
when i tried to read name or email fields its working fine.
but if i tried to read phone fields its crashing at pim_IContactsRecord_GetFieldValue() or
IQI_RELEASEIF(pIContactsRec).
what may be the problem?? is it problem with phone fields ??
am i adding phone field properly??

I was able to replicate the issue, happening randomly and sometimes not reproducible, I have communicated issue with concerned team.

I was able to replicate the issue, happening randomly and sometimes not reproducible, I have communicated issue with concerned team.

Hi Hanamant,
Note that AECHAR is of two bytes length. As such, the input value to MALLOC should be (nLenReq * 2).
i.e. FieldValue = (AECHAR*)MALLOC(nLenReq * 2);
 
Can you kindly check with this change and update us with your observations?
Regards,
Suresh Kumar S

Hi Hanamant,
Note that AECHAR is of two bytes length. As such, the input value to MALLOC should be (nLenReq * 2).
i.e. FieldValue = (AECHAR*)MALLOC(nLenReq * 2);
 
Can you kindly check with this change and update us with your observations?
Regards,
Suresh Kumar S