📄 gupnp-service-info.c
字号:
"The XML element related to this " "device", G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB));}/** * gupnp_service_info_get_context * @info: A #GUPnPServiceInfo * * Get the #GUPnPContext associated with @info. * * Returns: A #GUPnPContext. **/GUPnPContext *gupnp_service_info_get_context (GUPnPServiceInfo *info){ g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); return info->priv->context;}/** * gupnp_service_info_get_location * @info: A #GUPnPServiceInfo * * Get the location of the device description file. * * Returns: A constant string. **/const char *gupnp_service_info_get_location (GUPnPServiceInfo *info){ g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); return info->priv->location;}/** * gupnp_service_info_get_url_base * @info: A #GUPnPServiceInfo * * Get the URL base of this service. * * Returns: A constant #SoupURI. **/const SoupURI *gupnp_service_info_get_url_base (GUPnPServiceInfo *info){ g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); return info->priv->url_base;}/** * gupnp_service_info_get_udn * @info: A #GUPnPServiceInfo * * Get the Unique Device Name of the containing device. * * Returns: A constant string. **/const char *gupnp_service_info_get_udn (GUPnPServiceInfo *info){ g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); return info->priv->udn;}/** * gupnp_service_info_get_service_type * @info: A #GUPnPServiceInfo * * Get the UPnP service type, or %NULL. * * Returns: A constant string. **/const char *gupnp_service_info_get_service_type (GUPnPServiceInfo *info){ g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); if (!info->priv->service_type) { info->priv->service_type = xml_util_get_child_element_content_glib (info->priv->element, "serviceType"); } return info->priv->service_type;}/** * gupnp_service_info_get_id * @info: A #GUPnPServiceInfo * * Get the ID of this service, or %NULL if there is no ID. * * Return value: A string. This string should be freed with g_free() after use. **/char *gupnp_service_info_get_id (GUPnPServiceInfo *info){ g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); return xml_util_get_child_element_content_glib (info->priv->element, "serviceId");}/** * gupnp_service_info_get_scpd_url * @info: A #GUPnPServiceInfo * * Get the SCPD URL for this service, or %NULL if there is no SCPD. * * Return value: A string. This string should be freed with g_free() after use. **/char *gupnp_service_info_get_scpd_url (GUPnPServiceInfo *info){ g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); return xml_util_get_child_element_content_url (info->priv->element, "SCPDURL", info->priv->url_base);}/** * gupnp_service_info_get_control_url * @info: A #GUPnPServiceInfo * * Get the control URL for this service, or %NULL.. * * Return value: A string. This string should be freed with g_free() after use. **/char *gupnp_service_info_get_control_url (GUPnPServiceInfo *info){ g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); return xml_util_get_child_element_content_url (info->priv->element, "controlURL", info->priv->url_base);}/** * gupnp_service_info_get_event_subscription_url * @info: A #GUPnPServiceInfo * * Get the event subscription URL for this service, or %NULL. * * Return value: A string. This string should be freed with g_free() after use. **/char *gupnp_service_info_get_event_subscription_url (GUPnPServiceInfo *info){ g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); return xml_util_get_child_element_content_url (info->priv->element, "eventSubURL", info->priv->url_base);}/** * gupnp_service_info_get_introspection * @info: A #GUPnPServiceInfo * @error: return location for a #GError, or %NULL * * Note that introspection object is created from the information in service * description document (SCPD) provided by the service so it can not be created * if the service does not provide an SCPD. * * Return value: A new #GUPnPServiceIntrospection for this service or %NULL. * Unref after use. **/GUPnPServiceIntrospection *gupnp_service_info_get_introspection (GUPnPServiceInfo *info, GError **error){ GUPnPServiceIntrospection *introspection; SoupSession *session; SoupMessage *msg; int status; char *scpd_url; xmlDoc *scpd; g_return_val_if_fail (GUPNP_IS_SERVICE_INFO (info), NULL); introspection = NULL; scpd_url = gupnp_service_info_get_scpd_url (info); msg = NULL; if (scpd_url != NULL) { msg = soup_message_new (SOUP_METHOD_GET, scpd_url); g_free (scpd_url); } if (msg == NULL) { g_set_error (error, GUPNP_SERVER_ERROR, GUPNP_SERVER_ERROR_INVALID_URL, "No valid SCPD URL defined"); return NULL; } http_request_set_user_agent (msg); /* Send off the message */ session = _gupnp_context_get_session (info->priv->context); status = soup_session_send_message (session, msg); if (!SOUP_STATUS_IS_SUCCESSFUL (status)) { set_server_error (error, msg); g_object_unref (msg); return NULL; } scpd = xmlParseMemory (msg->response_body->data, msg->response_body->length); g_object_unref (msg); if (scpd) { introspection = gupnp_service_introspection_new (scpd); xmlFreeDoc (scpd); } if (!introspection) { g_set_error (error, GUPNP_SERVER_ERROR, GUPNP_SERVER_ERROR_INVALID_RESPONSE, "Could not parse SCPD"); } return introspection;}/* * SCPD URL downloaded. */static voidgot_scpd_url (SoupSession *session, SoupMessage *msg, GetSCPDURLData *data){ GUPnPServiceIntrospection *introspection; GError *error; introspection = NULL; error = NULL; if (msg->status_code == SOUP_STATUS_CANCELLED) return; if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { xmlDoc *scpd; scpd = xmlParseMemory (msg->response_body->data, msg->response_body->length); if (scpd) { introspection = gupnp_service_introspection_new (scpd); xmlFreeDoc (scpd); } if (!introspection) { error = g_error_new (GUPNP_SERVER_ERROR, GUPNP_SERVER_ERROR_INVALID_RESPONSE, "Could not parse SCPD"); } } else error = new_server_error (msg); data->info->priv->pending_gets = g_list_remove (data->info->priv->pending_gets, data); data->callback (data->info, introspection, error, data->user_data); if (error) g_error_free (error); get_scpd_url_data_free (data);}/** * gupnp_service_info_get_introspection_async * @info: A #GUPnPServiceInfo * @callback: callback to be called when introspection object is ready. * @user_data: user_data to be passed to the callback. * * Note that introspection object is created from the information in service * description document (SCPD) provided by the service so it can not be created * if the service does not provide an SCPD. **/voidgupnp_service_info_get_introspection_async (GUPnPServiceInfo *info, GUPnPServiceIntrospectionCallback callback, gpointer user_data){ GetSCPDURLData *data; char *scpd_url; SoupSession *session; g_return_if_fail (GUPNP_IS_SERVICE_INFO (info)); g_return_if_fail (callback != NULL); data = g_slice_new (GetSCPDURLData); scpd_url = gupnp_service_info_get_scpd_url (info); data->message = NULL; if (scpd_url != NULL) { data->message = soup_message_new (SOUP_METHOD_GET, scpd_url); g_free (scpd_url); } if (data->message == NULL) { GError *error; error = g_error_new (GUPNP_SERVER_ERROR, GUPNP_SERVER_ERROR_INVALID_URL, "No valid SCPD URL defined"); callback (info, NULL, error, user_data); g_error_free (error); g_slice_free (GetSCPDURLData, data); return; } http_request_set_user_agent (data->message); data->info = info; data->callback = callback; data->user_data = user_data; /* Send off the message */ info->priv->pending_gets = g_list_prepend (info->priv->pending_gets, data); session = _gupnp_context_get_session (info->priv->context); soup_session_queue_message (session, data->message, (SoupSessionCallback) got_scpd_url, data);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -