Contacts: 2 Choosing Contacts From a Log

Up: GEOS SDK TechDocs| Up | Prev: 1 Setting up a Contact List | Next: 3 Using a Dedicated Contact
RecentContactsSMSControlClass, CONTACTS_CONTROL_NOTIFY_ENTRY_SELECTED_MSG

For a list of recent SMS contacts, use a RecentContactsSMSController. You will need the following line in your .gp file:

library		contlog

The following setup would allow the user to pick a phone number from a list of recently called SMS numbers, sending a MSG_MYPROCESS_SEND_RECENT message to the application's process object:

    @object RecentContactsSMSControlClass MyLog = {
        GCI_output = ( TO_PROCESS );
        ATTR_RECENT_CONTACTS_CONTROL_NOTIFY_ENTRY_SELECTED_MSG = 
            MSG_MYPROCESS_SEND_RECENT;
    }

With this setup, when the user chooses a phone number from the log, a MSG_MYPROCESS_SEND_RECENT message will be sent to the process object, which should handle the message. The message should conform to the CONTACTS_CONTROL_NOTIFY_ENTRY_SELECTED_MSG prototype.

@prototype void
    CONTACTS_CONTROL_NOTIFY_ENTRY_SELECTED_MSG(
                           RecentContactsData *data)
typedef struct {
	dword               RCD_contactID;
	NameOrNumber        RCD_number;
} RecentContactsData;

The data argument's RCD_number field contains the GSM phone number of the selected contact. The RCD_contactID contains either:

The code example below shows a handler that extract's the name associated with the selected contact. It makes use of functions described in Setting up a Contact List.

Code Display: Handling the RecentContacts "Selected" Message

@class MyProcessClass, GenProcessClass;
	@message (CONTACTS_CONTROL_NOTIFY_ENTRY_SELECTED_MSG)
						MSG_MYPROCESS_SEND_RECENT;
@endc
@method MyProcessClass, MSG_MYPROCESS_SEND_RECENT {
        /* Note: the code in this example is only useful if you need 
         * the contact's name. If all you need is the GSM phone number, 
         * none of this code is necessary. The phone number string is in 
         * data->RCD_number. 
         * 
         * If you do need the following code, you will need to make sure 
         * that your .gp file includes the lines
                library contdb
                library foamdb
         */

        TCHAR           theName[MAX_NAME_DATA_LEN+1];
        VMFileHandle    CDBHandle;
        MemHandle       theRecord;
        word            oldOverride;

        /* If the user chose a phone number that doesn't have a contact 
         * associated with it, the contact's RecordID value is 
         * LECI_INVALID_CONTACT_ID, signalling an invalid contact. */

        if ( data->RCD_contactID != LECI_INVALID_CONTACT_ID) {
           oldOverride = ContactSetOverrideDB(CONTACT_DEVICE_DB_NAME);
           CDBHandle = ContactGetDBHandle();
           theRecord = FoamDBGetRecordFromID( CDBHandle, 
                                              data->RCD_contactID );
           ContactGetName(theRecord, theName);

           /* If you need more information about the contact 
            * (e.g., business name, job title), this is a good place 
            * to retrieve it. */

         FoamDBDiscardRecord(CDBHandle, theRecord);
         ContactReleaseDBHandle();
         ContactRestoreOverrideDB(oldOverride);
       }

      /* do something useful with data->RCD_number and theName */
}

Recent versions of the Nokia 9000i Communicator allow fax and SMS contact lists to support multiple selections. Set the RCFCF_MULTIPLE_SELECTION or RCMCF_MULTIPLE_SELECTION bit to enable multiple selection for, respectively, a fax or SMS recent contact list and specify the message ATTR_RECENT_CONTACTS_CONTROL_NOTIFY_ENTRY_SELECTED_MSG which will be sent when the user chooses an item from the list.


Up: GEOS SDK TechDocs| Up | Prev: 1 Setting up a Contact List | Next: 3 Using a Dedicated Contact