// get device's phone number.
PhnAddressList addList;
PhnAddressHandle addressH;
UInt16 smsLibRef;
DmOpenRef dmOpenRef;
CharPtr numberPtr;
Err e;
UInt32 phnType = 0;
// get phone type (GSM or CDMA)
HsAttrGet (hsAttrPhoneType, 0, &phnType);
HsGetPhoneLibrary(&smsLibRef);
// Turn phone radio on, because otherwise it can't get the phone number
if(PhnLibModulePowered(smsLibRef) == phnPowerOff)
PhnLibSetModulePower(smsLibRef, true);
dmOpenRef = PhnLibGetDBRef(smsLibRef);
e = PhnLibGetOwnNumbers (smsLibRef,&addList);
while(e == phnErrSIMBusy)
e = PhnLibGetOwnNumbers (smsLibRef,&addList);
if (e==0)
{
unsigned short n;
e=PhnLibCount(smsLibRef, addList, &n);
if(e==0 && n>0)
{
if(phnType == hsAttrPhoneTypeCDMA)
{
e= PhnLibAPGetNth (smsLibRef, addList, 1, &addressH);
if (e==0 && addressH!=0)
{
// Get the number (given the ephnAddrField param value: default is phnAddrFldPhone)
// numberPtr = PhnLibAPGetField(smsLibRef, addressH, phnAddrFldFirstName);
// numberPtr = PhnLibAPGetField(smsLibRef, addressH, phnAddrFldLastName);
numberPtr = PhnLibAPGetField(smsLibRef, addressH, phnAddrFldPhone);
if(numberPtr[0]=='1')
StrCopy(g_prefs.phoneNumber,numberPtr+1);
else StrCopy(g_prefs.phoneNumber,numberPtr);
MemHandleFree(addressH);
}
}
else
{
e= PhnLibGetNth (smsLibRef, addList, 1, &addressH);
if (e==0 && addressH!=0)
{
numberPtr = PhnLibGetField(smsLibRef, addressH, phnAddrFldPhone);
if(numberPtr[0]=='1')
StrCopy(g_prefs.phoneNumber,numberPtr+1);
else StrCopy(g_prefs.phoneNumber,numberPtr);
MemHandleFree(addressH);
}
}
}
e=PhnLibDisposeAddressList (smsLibRef, addList);
}
e=PhnLibReleaseDBRef(smsLibRef,dmOpenRef);
Hopefully that will be of some help.
-Benjamin Bloomfield
On 3/16/06, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:
Hi All,
Let me add something more to the above question.
When I try using PhnLibCount() function I am getting the count as 0. That means I am not getting any numbers in the List retrieved by calling the function PhnLibGetOwnNumbers().
So, How can we get the Own numbers.
regards,
Krishna.
--
For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
-- For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
