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 --- include/call.h | 6 ++++ samsung-ipc/call.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++ vapi/samsung-ipc-1.0.vapi | 27 +++++++++--------- 3 files changed, 92 insertions(+), 13 deletions(-) diff --git a/include/call.h b/include/call.h index d499371..809f9ed 100644 --- a/include/call.h +++ b/include/call.h @@ -54,6 +54,8 @@ #define IPC_CALL_TERM_MO 0x01 #define IPC_CALL_TERM_MT 0x02 +struct ipc_response; + struct ipc_call_outgoing { unsigned char type; // IPC_CALL_TYPE_... unsigned char identity; // IPC_CALL_IDENTITY_... @@ -89,5 +91,9 @@ struct ipc_call_status { void ipc_call_outgoing_setup(struct ipc_call_outgoing *message, unsigned char type, unsigned char identity, unsigned char prefix, char *number); +unsigned int ipc_call_list_response_get_num_entries(struct ipc_response *response); +struct ipc_call_list_entry* ipc_call_list_response_get_entry(struct ipc_response *response, unsigned int num); +char* ipc_call_list_response_get_entry_number(struct ipc_response *response, unsigned int num); + #endif 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; +} + + diff --git a/vapi/samsung-ipc-1.0.vapi b/vapi/samsung-ipc-1.0.vapi index 9c98faf..053f151 100644 --- a/vapi/samsung-ipc-1.0.vapi +++ b/vapi/samsung-ipc-1.0.vapi @@ -687,26 +687,27 @@ namespace SamsungIpc } } + [CCode (cname = "struct ipc_response", destroy_function = "")] + public struct ListResponseMessage + { + [CCode (cname = "ipc_call_list_response_get_num_entries")] + public uint get_num_entries(); + [CCode (cname = "ipc_call_list_response_get_entry")] + public ListEntry get_entry(uint num); + [CCode (cname = "ipc_call_list_response_get_entry_number")] + public string get_entry_number(uint num); + } + [CCode (cname = "struct ipc_call_list_entry", destroy_function = "")] - public struct ListEntryMessage + public struct ListEntry { - public uint8 type; + public Type type; public uint8 idx; public Termination term; - public State state; + public uint8 state; public uint8 mpty; public uint8 number_len; public uint8 unk4; - - public unowned uint8[] data - { - get - { - unowned uint8[] res = (uint8[])(&this); - res.length = (int) sizeof( ListEntryMessage ); - return res; - } - } } [CCode (cname = "struct ipc_call_status", destroy_function = "")] -- cgit v1.1