Hi Bismi,
   Well see the attached file, for the function I had written for getting 
number from SIM. One more thing not all the SIM contain its number, So the SIM 
enabled with it only give you number, Unfortunately none of the Indian 
operator's are having number on their SIM(I also tried on Hutch, Airtel and BPL 
Mobile SIMs, but none of them seems to be working), but I tried these function 
on Cingular SIM and it working perfectly, means we are getting number.

Best Regards
Mukesh Singh
-- 
For information on using the ACCESS Developer Forums, or to unsubscribe, please 
see http://www.access-company.com/developers/forums/
/***********************************************************************
*
* FUNCTION:    GetPhoneNumberFromSIM
*
* DESCRIPTION: This routine returns the main voice Phone # for a GSM phone.
*
* PARAMETERS:  string to return the phone # to.
*
* RETURNED:    phone #.
*
***********************************************************************/
static void GetPhoneNumberFromSIM (UInt16 iRefNum)
{
        Err                                     err;
        PhnAddressList          list;
        PhnAddressHandle        address;
        Boolean                         radioPowered = PhnLibModulePowered 
(iRefNum);

        CharPtr                         number = NULL;
        FieldPtr                        fld = NULL;

        // Get the list of "own number" (voice, data, and fax numbers).
        if (radioPowered)
        {
                err = PhnLibGetOwnNumbers (PhoneLibRefNum, &list);
                if (!err)
                {
                        //OOPS! Till now have worked only on GSM, but this is 
not only the case
                        //hence have to get the CDMA no. also ;)
                        if(GetPhoneType() == hsAttrPhoneTypeGSM)
                                err = PhnLibGetNth (PhoneLibRefNum, list, 1, 
&address);
                        else if(GetPhoneType() == hsAttrPhoneTypeCDMA)
                                err = PhnLibAPGetNth (PhoneLibRefNum, list, 1, 
&address);
                        if (!err)
                        {
                                if (address)  
                                {       // Get the voice phone number
                                        //OOPS! Till now have worked only on 
GSM, but this is not only the case
                                        //hence have to get the CDMA no. also ;)
                                        if(GetPhoneType() == hsAttrPhoneTypeGSM)
                                                number = PhnLibGetField 
(PhoneLibRefNum, address, phnAddrFldPhone);
                                        else if(GetPhoneType() == 
hsAttrPhoneTypeCDMA)
                                                number = PhnLibAPGetField 
(PhoneLibRefNum, address, phnAddrFldPhone);
                                        MemHandleFree (address);
                                }
                        }
                        MemHandleFree (list);
                }

                char* phone = 
gpIMApplication->pResourceManager->GetStringFromResource(VAR_PHONE_NUMBER);

                if(number)
                {
                        if(pEventHandler->PhoneNumber != NULL)
                                delete pEventHandler->PhoneNumber;

                        pEventHandler->PhoneNumber = 
Platform_StringClone(number);
                        if(phone == NULL || (Platform_StrCmpi(phone, number) != 
0))
                                
gpIMApplication->pResourceManager->SetStringToResource(VAR_PHONE_NUMBER, 
pEventHandler->PhoneNumber);

                        MemPtrFree (number);
                        number = NULL;
                }
                //could not find the phone number show message to user to set 
it explicitly
                
                delete phone;
                phone = NULL;
        }       
}

/***************************************************************
 * Function:
 *        GetPhoneType
 * Summary: Return the phone type: cdma or gsm?
 * Parameters:
 * Returns:
 *
 *
 **************************************************************/
static UInt32 GetPhoneType (void)
{

  UInt32 phnType = hsAttrPhoneTypeGSM;

  HsAttrGet(hsAttrPhoneType, 0, &phnType);

  return phnType;
}

Reply via email to