From 3fcbca9b0c1ea0e8dd2ba2d43b07f8090339755d Mon Sep 17 00:00:00 2001 From: Simon Busch Date: Fri, 28 Oct 2011 19:08:29 +0200 Subject: Various changes to code and vala binding regarding call API Signed-off-by: Simon Busch --- samsung-ipc/call.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'samsung-ipc/call.c') diff --git a/samsung-ipc/call.c b/samsung-ipc/call.c index 9573a8d..9d94931 100644 --- a/samsung-ipc/call.c +++ b/samsung-ipc/call.c @@ -36,3 +36,75 @@ void ipc_call_outgoing_setup(struct ipc_call_outgoing *message, unsigned char ty strncpy(message->number, number, OUTGOING_NUMBER_MAX_LENGTH); } +/** + * Retrieve number of calls in list of calls. + **/ +unsigned int ipc_call_list_response_get_num_entries(struct ipc_response *response) +{ + unsigned int count = 0, n = 0; + + assert(response != NULL); + assert(response->data != NULL); + + count = (unsigned int) *((unsigned char*) response->data); + return count; +} + +/** + * Retrieve one specific entry from a list of calls. + **/ +struct ipc_call_list_entry* ipc_call_list_response_get_entry(struct ipc_response *response, unsigned int num) +{ + unsigned int count = 0, pos = 1, n = 0; + struct ipc_call_list_entry *entry = NULL; + + assert(response != NULL); + assert(response->data != NULL); + + count = ipc_call_list_response_get_num_entries(response); + if (num > count) + return NULL; + + for (n = 0; n < num; n++) + { + entry = (struct ipc_call_list_entry*) (response->data + pos); + pos += (unsigned int) (sizeof(struct ipc_call_list_entry) + entry->number_len); + } + + return entry; +} + +/** + * Retrieve the number of a call entry in the list of calls + **/ +char* ipc_call_list_response_get_entry_number(struct ipc_response *response, unsigned int num) +{ + unsigned int count = 0, pos = 1, n = 0; + struct ipc_call_list_entry *entry = NULL; + char *number = NULL; + + assert(response != NULL); + assert(response->data != NULL); + + count = ipc_call_list_response_get_num_entries(response); + if (num > count) + return NULL; + + for (n = 0; n < num; n++) + { + entry = (struct ipc_call_list_entry*) (response->data + pos); + pos += (unsigned int) (sizeof(struct ipc_call_list_entry) + entry->number_len); + } + + if (entry == NULL || + (unsigned char*) (response->data + pos) == NULL || + (unsigned char*) (response->data + pos + entry->number_len) == NULL) + return NULL; + + number = (char*) malloc(sizeof(char) * entry->number_len); + strncpy(number, response->data + pos, entry->number_len); + + return number; +} + + -- cgit v1.2.3