static void cancellable_cancelled_cb (GCancellable *cancellable, gpointer user_data) { GUPnPServiceInfo *info; GetSCPDURLData *data; SoupSession *session; GError *error; data = user_data; info = data->info; session = gupnp_context_get_session (info->priv->context); soup_session_cancel_message (session, data->message, SOUP_STATUS_CANCELLED); info->priv->pending_gets = g_list_remove (info->priv->pending_gets, data); error = g_error_new (G_IO_ERROR, G_IO_ERROR_CANCELLED, "The call was canceled"); data->callback (data->info, NULL, error, data->user_data); get_scpd_url_data_free (data); }
/* * SCPD URL downloaded. */ static void got_scpd_url (G_GNUC_UNUSED SoupSession *session, SoupMessage *msg, GetSCPDURLData *data) { GUPnPServiceIntrospection *introspection; GError *error; GUPnPServiceInfoPrivate *priv; introspection = NULL; error = NULL; if (msg->status_code == SOUP_STATUS_CANCELLED) return; if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) { xmlDoc *scpd; scpd = xmlRecoverMemory (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 = _gupnp_error_new_server_error (msg); /* prevent the callback from canceling the cancellable * (and so freeing data just before we do) */ if (data->cancellable) g_cancellable_disconnect (data->cancellable, data->cancelled_id); priv = gupnp_service_info_get_instance_private (data->info); priv->pending_gets = g_list_remove (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); }
/* * SCPD URL downloaded. */ static void got_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 = xmlRecoverMemory (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 = _gupnp_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); }
static void gupnp_service_info_dispose (GObject *object) { GUPnPServiceInfo *info; GUPnPServiceInfoPrivate *priv; info = GUPNP_SERVICE_INFO (object); priv = gupnp_service_info_get_instance_private (info); /* Cancel any pending SCPD GETs */ if (priv->context) { SoupSession *session; session = gupnp_context_get_session (priv->context); while (priv->pending_gets) { GetSCPDURLData *data; data = priv->pending_gets->data; if (data->cancellable) g_cancellable_disconnect (data->cancellable, data->cancelled_id); soup_session_cancel_message (session, data->message, SOUP_STATUS_CANCELLED); get_scpd_url_data_free (data); priv->pending_gets = g_list_delete_link (priv->pending_gets, priv->pending_gets); } /* Unref context */ g_object_unref (priv->context); priv->context = NULL; } if (priv->doc) { g_object_unref (priv->doc); priv->doc = NULL; } G_OBJECT_CLASS (gupnp_service_info_parent_class)->dispose (object); }