diff options
| author | Frederic Peters <fpeters@entrouvert.com> | 2008-05-14 16:37:00 +0000 |
|---|---|---|
| committer | Frederic Peters <fpeters@entrouvert.com> | 2008-05-14 16:37:00 +0000 |
| commit | ce18fb098f11eb1b307723b01f93cd16f46e0bdf (patch) | |
| tree | cdc1226598ca1d1fd968ea475599f762f8cf848f | |
| parent | e6f63010f4deaf6ebbae5fff437f5e075e1fde81 (diff) | |
| download | lasso-ce18fb098f11eb1b307723b01f93cd16f46e0bdf.tar.gz lasso-ce18fb098f11eb1b307723b01f93cd16f46e0bdf.tar.xz lasso-ce18fb098f11eb1b307723b01f93cd16f46e0bdf.zip | |
added lasso_idwsf2_data_service_get_attribute_nodes method
| -rw-r--r-- | lasso/id-wsf-2.0/data_service.c | 60 | ||||
| -rw-r--r-- | lasso/id-wsf-2.0/data_service.h | 3 |
2 files changed, 63 insertions, 0 deletions
diff --git a/lasso/id-wsf-2.0/data_service.c b/lasso/id-wsf-2.0/data_service.c index 1ebe1ddb..ea81cabc 100644 --- a/lasso/id-wsf-2.0/data_service.c +++ b/lasso/id-wsf-2.0/data_service.c @@ -51,6 +51,8 @@ extern GHashTable *idwsf2_dst_services_by_prefix; /* cf xml/xml.c */ static void lasso_register_idwsf2_xpath_namespaces(xmlXPathContext *xpathCtx); +static GList* duplicate_glist_of_xmlnodes(GList*); + /*****************************************************************************/ /* public methods */ /*****************************************************************************/ @@ -368,6 +370,52 @@ lasso_idwsf2_data_service_process_query_response_msg(LassoIdWsf2DataService *ser return 0; } + +GList* +lasso_idwsf2_data_service_get_attribute_nodes(LassoIdWsf2DataService *service, const gchar *item_id) +{ + LassoIdWsf2Profile *profile = LASSO_IDWSF2_PROFILE(service); + LassoIdWsf2DstRefQueryResponse *response; + LassoIdWsf2DstRefAppData *data = NULL; + GList *iter; + + g_return_val_if_fail(LASSO_IS_IDWSF2_DATA_SERVICE(service), NULL); + + g_return_val_if_fail(LASSO_IS_IDWSF2_DSTREF_QUERY_RESPONSE( + LASSO_PROFILE(profile)->response), NULL); + + response = LASSO_IDWSF2_DSTREF_QUERY_RESPONSE(LASSO_PROFILE(profile)->response); + + /* If no item_id is given, return the first item */ + if (item_id == NULL && response->Data != NULL && response->Data->data != NULL) { + data = LASSO_IDWSF2_DSTREF_APP_DATA(response->Data->data); + if (data->any != NULL && data->any->data != NULL) { + return duplicate_glist_of_xmlnodes(data->any); + } + } + if (item_id == NULL) { + return NULL; + } + + /* Find the item which has the given item_id */ + for (iter = g_list_first(response->Data); iter != NULL; iter = g_list_next(iter)) { + if (! LASSO_IS_IDWSF2_DSTREF_ITEM_DATA(iter->data)) { + continue; + } + if (strcmp(LASSO_IDWSF2_DSTREF_ITEM_DATA(iter->data)->itemIDRef, item_id) == 0) { + data = LASSO_IDWSF2_DSTREF_APP_DATA(iter->data); + break; + } + } + + if (data == NULL || data->any == NULL || data->any->data == NULL) { + /* Item not found */ + return NULL; + } + + return duplicate_glist_of_xmlnodes(data->any); +} + xmlNode* lasso_idwsf2_data_service_get_attribute_node(LassoIdWsf2DataService *service, const gchar *item_id) { @@ -792,6 +840,18 @@ lasso_register_idwsf2_xpath_namespaces(xmlXPathContext *xpathCtx) (GHFunc)register_xpath_namespace, xpathCtx); } +static GList* +duplicate_glist_of_xmlnodes(GList *list) +{ + GList *r = NULL; + GList *t; + + for (t = list; t; t = g_list_next(t)) { + r = g_list_append(r, xmlCopyNode(t->data, 1)); + } + + return r; +} /*****************************************************************************/ diff --git a/lasso/id-wsf-2.0/data_service.h b/lasso/id-wsf-2.0/data_service.h index 116f89d6..97501918 100644 --- a/lasso/id-wsf-2.0/data_service.h +++ b/lasso/id-wsf-2.0/data_service.h @@ -89,6 +89,9 @@ LASSO_EXPORT gint lasso_idwsf2_data_service_parse_query_items(LassoIdWsf2DataSer LASSO_EXPORT gint lasso_idwsf2_data_service_process_query_response_msg( LassoIdWsf2DataService *service, const gchar *message); +LASSO_EXPORT GList* lasso_idwsf2_data_service_get_attribute_nodes( + LassoIdWsf2DataService *service, const gchar *item_id); + LASSO_EXPORT xmlNode* lasso_idwsf2_data_service_get_attribute_node(LassoIdWsf2DataService *service, const gchar *item_id); |
