Syntax
VM_RESULT vm_gsm_sms_read_message(
    VMUINT16 message_id, 
    VMBOOL change_status, 
    vm_gsm_sms_read_message_data_t* message_data, 
    vm_gsm_sms_callback callback, 
    void* user_data
);
ContentsIndex
PreviousUpNext
vm_gsm_sms_read_message
Example
Syntax
VM_RESULT vm_gsm_sms_read_message(
    VMUINT16 message_id, 
    VMBOOL change_status, 
    vm_gsm_sms_read_message_data_t* message_data, 
    vm_gsm_sms_callback callback, 
    void* user_data
);
Description

Reads message data, including message status, number, content and other attributes (Storage Type, SIM Card, Profile element, etc.) specified by the flag. The buffer to save the content should be provided by the caller. The Callback Action Data Structure is vm_gsm_sms_read_message_data_callback_t;

Parameters
Parameters 
Description 
VMUINT16 message_id 
[IN] Used to specify the message to be read. 
VMBOOL change_status 
[IN] Whether to change the UNREAD message to READ. 
vm_gsm_sms_read_message_data_t* message_data 
[IN/OUT] Message data for filling back the read data. 
vm_gsm_sms_callback callback 
[IN] Callback function. 
void* user_data 
[IN] User data. 
Returns

Refer to VM_GSM_SMS_RESULT for return result and error code.

Example
void custom_sms_read_message_callback(vm_gsm_sms_callback_t* callback_data)
{
    vm_gsm_sms_read_message_data_callback_t* read_message;
    if(callback_data->action == VM_GSM_SMS_ACTION_READ)
    {
        if(callback_data->cause == VM_GSM_SMS_CAUSE_NO_ERROR)
        {
            if(!callback_data->action_data)
            {
                 vm_log_debug("action_data is NULL.");
                 return;
            }
            read_message = (vm_gsm_sms_read_message_data_callback_t*)callback_data->action_data;
            vm_log_debug("message content is %s.",
                         vm_gb2312_string((VMWSTR)(read_message->message_data->content_buffer)));
            //maybe copy content_buff to other place
            vm_free(read_message->message_data->content_buffer);
            vm_free(read_message->message_data);
        }
        else
        {
            vm_log_debug("read message failed.");
        }
    }
}

void custom_sms_read_message(void)
{
    VMINT16 message_id;
    vm_gsm_sms_read_message_data_t * message_data = NULL;
    VMWCHAR * content_buff;
    VMINT res;

    message_id = vm_gsm_sms_get_message_id(VM_GSM_SMS_BOX_INBOX, 0);
    if(message_id == -1)
    {
        vm_log_debug("0 message-index does not exist.");
    }
    message_data = vm_calloc(sizeof(vm_gsm_sms_read_message_data_t));
    if(message_data == NULL)
    {
        vm_log_debug("message_data vm_calloc failed.");
    }
    content_buff = vm_calloc((500+1)*sizeof(VMWCHAR));
    if(content_buff == NULL)
    {
        vm_free(message_data);
        vm_log_debug("content_buff vm_calloc failed.");
    }
    message_data->content_buffer = content_buff;
    message_data->content_buffer_size = 500;
    res = vm_gsm_sms_read_message(message_id, VM_TRUE, message_data,
                                  custom_sms_read_message_callback, NULL);
    if(res != VM_GSM_SMS_RESULT_OK)
    {
        vm_log_debug("read message failed.");
    }
}
File

vmgsm_sms.h

Group
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at support@toolsfactory.com.