From: Enlightenment S. <no-...@en...> - 2009-09-29 18:21:01
|
Log: Cleanup service proxy module. - Start writing docs - Move new() and free() functions to the parser, also remove them from the API - Add missing eupnp_soap.h header (soap constants and stuff) Author: dieb Date: 2009-09-29 11:20:47 -0700 (Tue, 29 Sep 2009) New Revision: 42805 Added: trunk/PROTO/eupnp/src/lib/eupnp_soap.h Modified: trunk/PROTO/eupnp/src/lib/eupnp_service_parser.c trunk/PROTO/eupnp/src/lib/eupnp_service_proxy.c trunk/PROTO/eupnp/src/lib/eupnp_service_proxy.h Modified: trunk/PROTO/eupnp/src/lib/eupnp_service_parser.c =================================================================== --- trunk/PROTO/eupnp/src/lib/eupnp_service_parser.c 2009-09-29 17:30:44 UTC (rev 42804) +++ trunk/PROTO/eupnp/src/lib/eupnp_service_parser.c 2009-09-29 18:20:47 UTC (rev 42805) @@ -34,6 +34,279 @@ * Private API */ +static int _eupnp_service_parser_init = 0; +static int _log_dom = -1; + +static Eupnp_Service_Action * +eupnp_service_action_new(void) +{ + Eupnp_Service_Action *a; + + a = malloc(sizeof(Eupnp_Service_Action)); + + if (!a) + { + ERROR_D(_log_dom, "Could not alloc for service action"); + return NULL; + } + + a->name = NULL; + a->arguments = NULL; + + return a; +} + +static void +eupnp_service_action_argument_free(Eupnp_Service_Action_Argument *arg) +{ + CHECK_NULL_RET(arg); + free((char *)arg->name); + free(arg->retval); + free((char *)arg->value); + free(arg); +} + +void +eupnp_service_action_free(Eupnp_Service_Action *a) +{ + if (!a) return; + + free((char *)a->name); + + if (a->arguments) + { + Eupnp_Service_Action_Argument *item; + + while (item = (void *)a->arguments) + { + a->arguments = eina_inlist_remove(a->arguments, a->arguments); + eupnp_service_action_argument_free(item); + } + } + + free(a); +} + +Eupnp_Service_Action_Argument * +eupnp_service_action_argument_new(void) +{ + Eupnp_Service_Action_Argument *arg; + arg = malloc(sizeof(Eupnp_Service_Action_Argument)); + + CHECK_NULL_RET_VAL(arg, NULL); + + arg->name = NULL; + arg->direction = EUPNP_ARGUMENT_DIRECTION_IN; + arg->related_state_variable = NULL; + arg->retval = NULL; + arg->value = NULL; + + return arg; +} + +static void +eupnp_service_action_argument_dump(const Eupnp_Service_Action_Argument *arg) +{ + CHECK_NULL_RET(arg); + + INFO_D(_log_dom, "\t\tArgument dump"); + INFO_D(_log_dom, "\t\t\tname: %s", arg->name); + INFO_D(_log_dom, "\t\t\tdirection: %d", arg->direction); + if (arg->related_state_variable) + INFO_D(_log_dom, "\t\t\trelated state var: %s", arg->related_state_variable->name); + INFO_D(_log_dom, "\t\t\tretval: %s", (char *)arg->retval); +} + +static void +eupnp_service_action_dump(const Eupnp_Service_Action *a) +{ + if (!a) return; + + INFO_D(_log_dom, "\tAction dump"); + INFO_D(_log_dom, "\t\tname: %s", a->name); + + if (a->arguments) + { + Eupnp_Service_Action_Argument *arg; + + EINA_INLIST_FOREACH(a->arguments, arg) + eupnp_service_action_argument_dump(arg); + } +} + +static Eupnp_State_Variable * +eupnp_service_state_variable_new1(void) +{ + Eupnp_State_Variable *st; + + st = malloc(sizeof(Eupnp_State_Variable)); + + if (!st) + { + ERROR_D(_log_dom, "Could not alloc for new state variable"); + return NULL; + } + + st->name = NULL; + st->send_events = EINA_TRUE; + st->data_type = EUPNP_DATA_TYPE_STRING; + st->default_value = NULL; + st->allowed_value_list = NULL; + st->range_min = NULL; + st->range_max = NULL; + st->range_step = NULL; + + return st; +} + +static Eupnp_State_Variable * +eupnp_service_state_variable_new(const char *name, int name_len) +{ + Eupnp_State_Variable *st; + + st = eupnp_service_state_variable_new1(); + + if (!st) + { + ERROR_D(_log_dom, "Could not alloc for new state variable"); + return NULL; + } + + st->name = malloc(sizeof(char)*(name_len+1)); + + if (!st->name) + { + ERROR_D(_log_dom, "Could not alloc for state var name"); + free(st); + return NULL; + } + + memcpy((char *)st->name, name, name_len); + ((char *)st->name)[name_len] = '\0'; + + return st; +} + +static void +eupnp_service_state_variable_allowed_value_free(Eupnp_State_Variable_Allowed_Value *value) +{ + CHECK_NULL_RET(value); + free((char *)value->value); + free(value); +} + +void +eupnp_service_state_variable_free(Eupnp_State_Variable *st) +{ + CHECK_NULL_RET(st); + + free((char *)st->name); + free((char *)st->default_value); + free((char *)st->range_min); + free((char *)st->range_max); + free((char *)st->range_step); + + if (st->allowed_value_list) + { + Eupnp_State_Variable_Allowed_Value *item; + + while (item = (void *)st->allowed_value_list) + { + st->allowed_value_list = eina_inlist_remove(st->allowed_value_list, + st->allowed_value_list); + eupnp_service_state_variable_allowed_value_free(item); + } + } + + free(st); +} + +static void +eupnp_service_state_variable_dump(const Eupnp_State_Variable *st) +{ + CHECK_NULL_RET(st); + + INFO_D(_log_dom, "\t\tState variable dump"); + INFO_D(_log_dom, "\t\t\tname: %s", st->name); + INFO_D(_log_dom, "\t\t\tsendEvents: %d", st->send_events); + INFO_D(_log_dom, "\t\t\tdefault value: %s", (char *)st->default_value); + INFO_D(_log_dom, "\t\t\trange min: %s", (char *)st->range_min); + INFO_D(_log_dom, "\t\t\trange max: %s", (char *)st->range_max); + INFO_D(_log_dom, "\t\t\trange step: %s", (char *)st->range_step); + INFO_D(_log_dom, "\t\t\tdata type: %d", st->data_type); + + if (st->allowed_value_list) + { + Eupnp_State_Variable_Allowed_Value *item; + INFO_D(_log_dom, "\t\t\tAllowed value list:"); + + EINA_INLIST_FOREACH(st->allowed_value_list, item) + INFO_D(_log_dom, "\t\t\t\t%s", item->value); + } +} + +static Eina_Bool +eupnp_service_state_variable_allowed_value_add(Eupnp_State_Variable *st, Eupnp_State_Variable_Allowed_Value *v) +{ + CHECK_NULL_RET_VAL(st, EINA_FALSE); + CHECK_NULL_RET_VAL(v, EINA_FALSE); + + st->allowed_value_list = eina_inlist_append(st->allowed_value_list, EINA_INLIST_GET(v)); + + return EINA_TRUE; +} + +static Eina_Bool +eupnp_service_action_argument_add(Eupnp_Service_Action *action, Eupnp_Service_Action_Argument *arg) +{ + CHECK_NULL_RET_VAL(action, EINA_FALSE); + CHECK_NULL_RET_VAL(arg, EINA_FALSE); + + action->arguments = eina_inlist_append(action->arguments, EINA_INLIST_GET(arg)); + + return EINA_TRUE; +} + +static Eupnp_State_Variable_Allowed_Value * +eupnp_service_state_variable_allowed_value_new(void) +{ + Eupnp_State_Variable_Allowed_Value *v; + + v = malloc(sizeof(Eupnp_State_Variable_Allowed_Value)); + + if (!v) + { + ERROR_D(_log_dom, "Could not alloc for allowed value"); + return NULL; + } + + v->value = NULL; + + return v; +} + +static Eina_Bool +eupnp_service_proxy_action_add(Eupnp_Service_Proxy *proxy, Eupnp_Service_Action *action) +{ + CHECK_NULL_RET_VAL(proxy, EINA_FALSE); + CHECK_NULL_RET_VAL(action, EINA_FALSE); + + proxy->actions = eina_inlist_append(proxy->actions, EINA_INLIST_GET(action)); + + return EINA_TRUE; +} + +static Eina_Bool +eupnp_service_proxy_state_variable_add(Eupnp_Service_Proxy *proxy, Eupnp_State_Variable *st) +{ + CHECK_NULL_RET_VAL(proxy, EINA_FALSE); + CHECK_NULL_RET_VAL(st, EINA_FALSE); + + proxy->state_table = eina_inlist_append(proxy->state_table, EINA_INLIST_GET(st)); + + return EINA_TRUE; +} + #define COPY_CHARACTERS(to, from, len) \ if (!to) \ { \ @@ -47,9 +320,6 @@ ((char *)to)[len] = '\0'; \ } -static int _eupnp_service_parser_init = 0; -static int _log_dom = -1; - static void _characters(void *state, const xmlChar *ch, int len) { Modified: trunk/PROTO/eupnp/src/lib/eupnp_service_proxy.c =================================================================== --- trunk/PROTO/eupnp/src/lib/eupnp_service_proxy.c 2009-09-29 17:30:44 UTC (rev 42804) +++ trunk/PROTO/eupnp/src/lib/eupnp_service_proxy.c 2009-09-29 18:20:47 UTC (rev 42805) @@ -620,9 +620,140 @@ } /* + * Frees a proxy. + * + * This function is hidden for avoiding major problems. One should use only + * eupnp_service_proxy_ref() and eupnp_service_proxy_unref(). + */ +static void +eupnp_service_proxy_free(Eupnp_Service_Proxy *proxy) +{ + CHECK_NULL_RET(proxy); + + free(proxy->xml_parser); + + if (proxy->actions) + { + Eupnp_Service_Action *item; + + while (item = (void *)proxy->actions) + { + proxy->actions = eina_inlist_remove(proxy->actions, proxy->actions); + eupnp_service_action_free(item); + } + } + + if (proxy->state_table) + { + Eupnp_State_Variable *item; + + while (item = (void *)proxy->state_table) + { + proxy->state_table = eina_inlist_remove(proxy->state_table, + proxy->state_table); + eupnp_service_state_variable_free(item); + } + } + + free((char *)proxy->control_URL); + free((char *)proxy->eventsub_URL); + free((char *)proxy->base_URL); + free((char *)proxy->service_type); + + free(proxy); +} + +/* + * Requests the service's SCPD XML for mounting the proxy. + */ +static void +eupnp_service_proxy_fetch(Eupnp_Service_Proxy *proxy, const char *base_url, const char *scpd_url) +{ + CHECK_NULL_RET(proxy); + CHECK_NULL_RET(scpd_url); + CHECK_NULL_RET(base_url); + + // Reference for downloading, unref if download fails or if download + // completes. + + if (!eupnp_utils_url_is_relative(scpd_url)) + { + if (!eupnp_core_http_request_send(scpd_url, "GET", NULL, NULL, 0, NULL, + EUPNP_REQUEST_DATA_CB(_data_ready), + EUPNP_REQUEST_COMPLETED_CB(_download_completed), proxy)) + { + ERROR_D(_log_dom, "Could not add a new download job for device %p", proxy); + eupnp_service_proxy_unref(proxy); + } + } + else + { + char *complete_url = NULL; + + if (asprintf(&complete_url, "%s%s", base_url, scpd_url) < 0) + { + ERROR_D(_log_dom, "Could not form complete url for service proxy."); + return; + } + + if (!eupnp_core_http_request_send(complete_url, "GET", NULL, NULL, 0, NULL, + EUPNP_REQUEST_DATA_CB(_data_ready), + EUPNP_REQUEST_COMPLETED_CB(_download_completed), proxy)) + { + ERROR_D(_log_dom, "Could not add a new download job for device %p", proxy); + eupnp_service_proxy_unref(proxy); + } + + free(complete_url); + } +} + +static void +eupnp_service_proxy_actions_dump(Eupnp_Service_Proxy *proxy) +{ + CHECK_NULL_RET(proxy); + + Eupnp_Service_Action *action; + + EINA_INLIST_FOREACH(proxy->actions, action) + eupnp_service_action_dump(action); +} + +static void +eupnp_service_proxy_state_table_dump(Eupnp_Service_Proxy *proxy) +{ + CHECK_NULL_RET(proxy); + + Eupnp_State_Variable *st; + + EINA_INLIST_FOREACH(proxy->state_table, st) + eupnp_service_state_variable_dump(st); +} + + +static void +eupnp_service_proxy_dump(Eupnp_Service_Proxy *proxy) +{ + CHECK_NULL_RET(proxy); + + INFO_D(_log_dom, "\tService Proxy dump"); + INFO_D(_log_dom, "\t\tversion: %d.%d", proxy->spec_version_major, proxy->spec_version_minor); + INFO_D(_log_dom, "\t\tcontrol URL: %s", proxy->control_URL); + INFO_D(_log_dom, "\t\tbase URL: %s", proxy->base_URL); + eupnp_service_proxy_actions_dump(proxy); + eupnp_service_proxy_state_table_dump(proxy); +} + +/* * Public API */ +/* +* Initializes the service proxy module. +* +* @return On error, returns 0. Otherwise, returns the number of times it's been +* called. +*/ EAPI int eupnp_service_proxy_init(void) { @@ -683,6 +814,11 @@ return 0; } +/* + * Shuts down the service proxy module. + * + * @return 0 if completely shutted down the module. + */ EAPI int eupnp_service_proxy_shutdown(void) { @@ -700,258 +836,13 @@ return --_eupnp_service_proxy_init_count; } -EAPI Eupnp_Service_Action * -eupnp_service_action_new(void) -{ - Eupnp_Service_Action *a; - - a = malloc(sizeof(Eupnp_Service_Action)); - - if (!a) - { - ERROR_D(_log_dom, "Could not alloc for service action"); - return NULL; - } - - a->name = NULL; - a->arguments = NULL; - - return a; -} - -EAPI void -eupnp_service_action_free(Eupnp_Service_Action *a) -{ - if (!a) return; - - free((char *)a->name); - - if (a->arguments) - { - Eupnp_Service_Action_Argument *item; - - while (item = (void *)a->arguments) - { - a->arguments = eina_inlist_remove(a->arguments, a->arguments); - eupnp_service_action_argument_free(item); - } - } - - free(a); -} - -EAPI void -eupnp_service_action_dump(Eupnp_Service_Action *a) -{ - if (!a) return; - - INFO_D(_log_dom, "\tAction dump"); - INFO_D(_log_dom, "\t\tname: %s", a->name); - - if (a->arguments) - { - Eupnp_Service_Action_Argument *arg; - - EINA_INLIST_FOREACH(a->arguments, arg) - eupnp_service_action_argument_dump(arg); - } -} - -EAPI Eupnp_State_Variable * -eupnp_service_state_variable_new(const char *name, int name_len) -{ - Eupnp_State_Variable *st; - - st = eupnp_service_state_variable_new1(); - - if (!st) - { - ERROR_D(_log_dom, "Could not alloc for new state variable"); - return NULL; - } - - st->name = malloc(sizeof(char)*(name_len+1)); - - if (!st->name) - { - ERROR_D(_log_dom, "Could not alloc for state var name"); - free(st); - return NULL; - } - - memcpy((char *)st->name, name, name_len); - ((char *)st->name)[name_len] = '\0'; - - return st; -} - -EAPI Eupnp_State_Variable * -eupnp_service_state_variable_new1() -{ - Eupnp_State_Variable *st; - - st = malloc(sizeof(Eupnp_State_Variable)); - - if (!st) - { - ERROR_D(_log_dom, "Could not alloc for new state variable"); - return NULL; - } - - st->name = NULL; - st->send_events = EINA_TRUE; - st->data_type = EUPNP_DATA_TYPE_STRING; - st->default_value = NULL; - st->allowed_value_list = NULL; - st->range_min = NULL; - st->range_max = NULL; - st->range_step = NULL; - - return st; -} - -EAPI void -eupnp_service_state_variable_free(Eupnp_State_Variable *st) -{ - CHECK_NULL_RET(st); - - free((char *)st->name); - free((char *)st->default_value); - free((char *)st->range_min); - free((char *)st->range_max); - free((char *)st->range_step); - - if (st->allowed_value_list) - { - Eupnp_State_Variable_Allowed_Value *item; - - while (item = (void *)st->allowed_value_list) - { - st->allowed_value_list = eina_inlist_remove(st->allowed_value_list, - st->allowed_value_list); - eupnp_service_state_variable_allowed_value_free(item); - } - } - - free(st); -} - -EAPI void -eupnp_service_state_variable_dump(Eupnp_State_Variable *st) -{ - CHECK_NULL_RET(st); - - INFO_D(_log_dom, "\t\tState variable dump"); - INFO_D(_log_dom, "\t\t\tname: %s", st->name); - INFO_D(_log_dom, "\t\t\tsendEvents: %d", st->send_events); - INFO_D(_log_dom, "\t\t\tdefault value: %s", (char *)st->default_value); - INFO_D(_log_dom, "\t\t\trange min: %s", (char *)st->range_min); - INFO_D(_log_dom, "\t\t\trange max: %s", (char *)st->range_max); - INFO_D(_log_dom, "\t\t\trange step: %s", (char *)st->range_step); - INFO_D(_log_dom, "\t\t\tdata type: %d", st->data_type); - - if (st->allowed_value_list) - { - Eupnp_State_Variable_Allowed_Value *item; - INFO_D(_log_dom, "\t\t\tAllowed value list:"); - - EINA_INLIST_FOREACH(st->allowed_value_list, item) - INFO_D(_log_dom, "\t\t\t\t%s", item->value); - } -} - -EAPI Eina_Bool -eupnp_service_state_variable_allowed_value_add(Eupnp_State_Variable *st, Eupnp_State_Variable_Allowed_Value *v) -{ - CHECK_NULL_RET_VAL(st, EINA_FALSE); - CHECK_NULL_RET_VAL(v, EINA_FALSE); - - st->allowed_value_list = eina_inlist_append(st->allowed_value_list, EINA_INLIST_GET(v)); - - return EINA_TRUE; -} - -EAPI Eina_Bool -eupnp_service_action_argument_add(Eupnp_Service_Action *action, Eupnp_Service_Action_Argument *arg) -{ - CHECK_NULL_RET_VAL(action, EINA_FALSE); - CHECK_NULL_RET_VAL(arg, EINA_FALSE); - - action->arguments = eina_inlist_append(action->arguments, EINA_INLIST_GET(arg)); - - return EINA_TRUE; -} - -EAPI Eupnp_Service_Action_Argument * -eupnp_service_action_argument_new(void) -{ - Eupnp_Service_Action_Argument *arg; - arg = malloc(sizeof(Eupnp_Service_Action_Argument)); - - CHECK_NULL_RET_VAL(arg, NULL); - - arg->name = NULL; - arg->direction = EUPNP_ARGUMENT_DIRECTION_IN; - arg->related_state_variable = NULL; - arg->retval = NULL; - arg->value = NULL; - - return arg; -} - -void -eupnp_service_action_argument_free(Eupnp_Service_Action_Argument *arg) -{ - CHECK_NULL_RET(arg); - free((char *)arg->name); - free(arg->retval); - free((char *)arg->value); - free(arg); -} - -EAPI void -eupnp_service_action_argument_dump(Eupnp_Service_Action_Argument *arg) -{ - CHECK_NULL_RET(arg); - - INFO_D(_log_dom, "\t\tArgument dump"); - INFO_D(_log_dom, "\t\t\tname: %s", arg->name); - INFO_D(_log_dom, "\t\t\tdirection: %d", arg->direction); - if (arg->related_state_variable) - INFO_D(_log_dom, "\t\t\trelated state var: %s", arg->related_state_variable->name); - INFO_D(_log_dom, "\t\t\tretval: %s", (char *)arg->retval); -} - -EAPI Eupnp_State_Variable_Allowed_Value * -eupnp_service_state_variable_allowed_value_new(void) -{ - Eupnp_State_Variable_Allowed_Value *v; - - v = malloc(sizeof(Eupnp_State_Variable_Allowed_Value)); - - if (!v) - { - ERROR_D(_log_dom, "Could not alloc for allowed value"); - return NULL; - } - - v->value = NULL; - - return v; -} - -EAPI void -eupnp_service_state_variable_allowed_value_free(Eupnp_State_Variable_Allowed_Value *value) -{ - CHECK_NULL_RET(value); - free((char *)value->value); - free(value); -} - /* - * Creates a service proxy. + * @brief Creates a service proxy. * - * Creates a service proxy capable of controlling the service. + * Creates a service proxy capable of controlling the service. When ready, the + * proxy is forwarded to + * + * @see eupnp_service_proxy_ref(), eupnp_service_proxy_unref() */ EAPI void eupnp_service_proxy_new(Eupnp_Service_Info *service, Eupnp_Service_Proxy_Ready_Cb ready_cb, void *data) @@ -984,6 +875,11 @@ eupnp_service_proxy_fetch(proxy, service->location, service->scpd_URL); } +/* + * @brief Retrieves a new reference of a service proxy. + * + * @return A new reference to @p proxy + */ EAPI Eupnp_Service_Proxy * eupnp_service_proxy_ref(Eupnp_Service_Proxy *proxy) { @@ -997,6 +893,12 @@ return proxy; } +/* + * @brief Unreference a proxy. + * + * Unreferences a proxy. In case no more references are present, the proxy is + * collected and therefore unusable. + */ EAPI void eupnp_service_proxy_unref(Eupnp_Service_Proxy *proxy) { @@ -1016,145 +918,8 @@ eupnp_service_proxy_free(proxy); } -EAPI void -eupnp_service_proxy_free(Eupnp_Service_Proxy *proxy) -{ - CHECK_NULL_RET(proxy); - - free(proxy->xml_parser); - - if (proxy->actions) - { - Eupnp_Service_Action *item; - - while (item = (void *)proxy->actions) - { - proxy->actions = eina_inlist_remove(proxy->actions, proxy->actions); - eupnp_service_action_free(item); - } - } - - if (proxy->state_table) - { - Eupnp_State_Variable *item; - - while (item = (void *)proxy->state_table) - { - proxy->state_table = eina_inlist_remove(proxy->state_table, - proxy->state_table); - eupnp_service_state_variable_free(item); - } - } - - free((char *)proxy->control_URL); - free((char *)proxy->eventsub_URL); - free((char *)proxy->base_URL); - free((char *)proxy->service_type); - - free(proxy); -} - -EAPI void -eupnp_service_proxy_fetch(Eupnp_Service_Proxy *proxy, const char *base_url, const char *scpd_url) -{ - CHECK_NULL_RET(proxy); - CHECK_NULL_RET(scpd_url); - CHECK_NULL_RET(base_url); - - // Reference for downloading, unref if download fails or if download - // completes. - - if (!eupnp_utils_url_is_relative(scpd_url)) - { - if (!eupnp_core_http_request_send(scpd_url, "GET", NULL, NULL, 0, NULL, - EUPNP_REQUEST_DATA_CB(_data_ready), - EUPNP_REQUEST_COMPLETED_CB(_download_completed), proxy)) - { - ERROR_D(_log_dom, "Could not add a new download job for device %p", proxy); - eupnp_service_proxy_unref(proxy); - } - } - else - { - char *complete_url = NULL; - - if (asprintf(&complete_url, "%s%s", base_url, scpd_url) < 0) - { - ERROR_D(_log_dom, "Could not form complete url for service proxy."); - return; - } - - if (!eupnp_core_http_request_send(complete_url, "GET", NULL, NULL, 0, NULL, - EUPNP_REQUEST_DATA_CB(_data_ready), - EUPNP_REQUEST_COMPLETED_CB(_download_completed), proxy)) - { - ERROR_D(_log_dom, "Could not add a new download job for device %p", proxy); - eupnp_service_proxy_unref(proxy); - } - - free(complete_url); - } -} - -EAPI void -eupnp_service_proxy_dump(Eupnp_Service_Proxy *proxy) -{ - CHECK_NULL_RET(proxy); - - INFO_D(_log_dom, "\tService Proxy dump"); - INFO_D(_log_dom, "\t\tversion: %d.%d", proxy->spec_version_major, proxy->spec_version_minor); - INFO_D(_log_dom, "\t\tcontrol URL: %s", proxy->control_URL); - INFO_D(_log_dom, "\t\tbase URL: %s", proxy->base_URL); - eupnp_service_proxy_actions_dump(proxy); - eupnp_service_proxy_state_table_dump(proxy); -} - -EAPI void -eupnp_service_proxy_actions_dump(Eupnp_Service_Proxy *proxy) -{ - CHECK_NULL_RET(proxy); - - Eupnp_Service_Action *action; - - EINA_INLIST_FOREACH(proxy->actions, action) - eupnp_service_action_dump(action); -} - -EAPI void -eupnp_service_proxy_state_table_dump(Eupnp_Service_Proxy *proxy) -{ - CHECK_NULL_RET(proxy); - - Eupnp_State_Variable *st; - - EINA_INLIST_FOREACH(proxy->state_table, st) - eupnp_service_state_variable_dump(st); -} - -EAPI Eina_Bool -eupnp_service_proxy_action_add(Eupnp_Service_Proxy *proxy, Eupnp_Service_Action *action) -{ - CHECK_NULL_RET_VAL(proxy, EINA_FALSE); - CHECK_NULL_RET_VAL(action, EINA_FALSE); - - proxy->actions = eina_inlist_append(proxy->actions, EINA_INLIST_GET(action)); - - return EINA_TRUE; -} - -EAPI Eina_Bool -eupnp_service_proxy_state_variable_add(Eupnp_Service_Proxy *proxy, Eupnp_State_Variable *st) -{ - CHECK_NULL_RET_VAL(proxy, EINA_FALSE); - CHECK_NULL_RET_VAL(st, EINA_FALSE); - - proxy->state_table = eina_inlist_append(proxy->state_table, EINA_INLIST_GET(st)); - - return EINA_TRUE; -} - EAPI Eupnp_State_Variable * -eupnp_service_proxy_state_variable_get(Eupnp_Service_Proxy *proxy, const char *name, int name_len) +eupnp_service_proxy_state_variable_get(const Eupnp_Service_Proxy *proxy, const char *name, int name_len) { CHECK_NULL_RET_VAL(proxy, NULL); CHECK_NULL_RET_VAL(name, NULL); @@ -1174,7 +939,7 @@ } EAPI Eina_Bool -eupnp_service_proxy_has_action(Eupnp_Service_Proxy *proxy, const char *action) +eupnp_service_proxy_has_action(const Eupnp_Service_Proxy *proxy, const char *action) { CHECK_NULL_RET_VAL(action, EINA_FALSE); CHECK_NULL_RET_VAL(proxy, EINA_FALSE); @@ -1370,7 +1135,7 @@ } EAPI Eina_Bool -eupnp_service_proxy_has_variable(Eupnp_Service_Proxy *proxy, const char *variable_name) +eupnp_service_proxy_has_variable(const Eupnp_Service_Proxy *proxy, const char *variable_name) { CHECK_NULL_RET_VAL(variable_name, EINA_FALSE); CHECK_NULL_RET_VAL(proxy, EINA_FALSE); Modified: trunk/PROTO/eupnp/src/lib/eupnp_service_proxy.h =================================================================== --- trunk/PROTO/eupnp/src/lib/eupnp_service_proxy.h 2009-09-29 17:30:44 UTC (rev 42804) +++ trunk/PROTO/eupnp/src/lib/eupnp_service_proxy.h 2009-09-29 18:20:47 UTC (rev 42805) @@ -135,40 +135,13 @@ EAPI int eupnp_service_proxy_init(void); EAPI int eupnp_service_proxy_shutdown(void); -EAPI Eupnp_Service_Action *eupnp_service_action_new(void); -EAPI void eupnp_service_action_free(Eupnp_Service_Action *a); -EAPI Eina_Bool eupnp_service_action_argument_add(Eupnp_Service_Action *action, Eupnp_Service_Action_Argument *arg); -EAPI void eupnp_service_action_dump(Eupnp_Service_Action *a); - -EAPI Eupnp_State_Variable *eupnp_service_state_variable_new(const char *name, int name_len); -EAPI Eupnp_State_Variable *eupnp_service_state_variable_new1(); -EAPI void eupnp_service_state_variable_free(Eupnp_State_Variable *st); -EAPI void eupnp_service_state_variable_dump(Eupnp_State_Variable *st); -EAPI Eina_Bool eupnp_service_state_variable_allowed_value_add(Eupnp_State_Variable *st, Eupnp_State_Variable_Allowed_Value *v); - -EAPI Eupnp_State_Variable_Allowed_Value *eupnp_service_state_variable_allowed_value_new(void); -EAPI void eupnp_service_state_variable_allowed_value_free(Eupnp_State_Variable_Allowed_Value *value); - -EAPI Eupnp_Service_Action_Argument *eupnp_service_action_argument_new(void); -EAPI void eupnp_service_action_argument_free(Eupnp_Service_Action_Argument *arg); -EAPI void eupnp_service_action_argument_dump(Eupnp_Service_Action_Argument *arg); - -EAPI void eupnp_service_proxy_new(Eupnp_Service_Info *service, Eupnp_Service_Proxy_Ready_Cb ready_cb, void *data); -EAPI void eupnp_service_proxy_free(Eupnp_Service_Proxy *proxy); -EAPI Eupnp_Service_Proxy *eupnp_service_proxy_ref(Eupnp_Service_Proxy *proxy); -EAPI void eupnp_service_proxy_unref(Eupnp_Service_Proxy *proxy); -EAPI void eupnp_service_proxy_fetch(Eupnp_Service_Proxy *proxy, const char *base_url, const char *scpd_url); -EAPI Eina_Bool eupnp_service_proxy_action_add(Eupnp_Service_Proxy *proxy, Eupnp_Service_Action *action); -EAPI Eina_Bool eupnp_service_proxy_state_variable_add(Eupnp_Service_Proxy *proxy, Eupnp_State_Variable *st); -EAPI Eupnp_State_Variable *eupnp_service_proxy_state_variable_get(Eupnp_Service_Proxy *proxy, const char *name, int name_len); -EAPI void eupnp_service_proxy_dump(Eupnp_Service_Proxy *proxy); -EAPI void eupnp_service_proxy_actions_dump(Eupnp_Service_Proxy *proxy); -EAPI void eupnp_service_proxy_state_table_dump(Eupnp_Service_Proxy *proxy); - -EAPI Eina_Bool eupnp_service_proxy_has_action(Eupnp_Service_Proxy *proxy, const char *action); -EAPI Eina_Bool eupnp_service_proxy_action_send(Eupnp_Service_Proxy *proxy, const char *action, Eupnp_Action_Response_Cb response_cb, void *data, ...); - -EAPI Eina_Bool eupnp_service_proxy_has_variable(Eupnp_Service_Proxy *proxy, const char *variable_name); +EAPI void eupnp_service_proxy_new(Eupnp_Service_Info *service, Eupnp_Service_Proxy_Ready_Cb ready_cb, void *data); +EAPI Eupnp_Service_Proxy *eupnp_service_proxy_ref(Eupnp_Service_Proxy *proxy); +EAPI void eupnp_service_proxy_unref(Eupnp_Service_Proxy *proxy); +EAPI Eupnp_State_Variable *eupnp_service_proxy_state_variable_get(const Eupnp_Service_Proxy *proxy, const char *name, int name_len); +EAPI Eina_Bool eupnp_service_proxy_has_action(const Eupnp_Service_Proxy *proxy, const char *action); +EAPI Eina_Bool eupnp_service_proxy_has_variable(const Eupnp_Service_Proxy *proxy, const char *variable_name); +EAPI Eina_Bool eupnp_service_proxy_action_send(Eupnp_Service_Proxy *proxy, const char *action, Eupnp_Action_Response_Cb response_cb, void *data, ...); EAPI Eupnp_Event_Subscriber *eupnp_service_proxy_state_variable_events_subscribe(Eupnp_Service_Proxy *proxy, const char *var_name, Eupnp_State_Variable_Event_Cb cb, Eina_Bool auto_renew, Eina_Bool infinite_subscription, int timeout, void *data); EAPI Eina_Bool eupnp_service_proxy_state_variable_events_unsubscribe(Eupnp_Event_Subscriber *subscriber); |