/* * Send a discovery response */ static gboolean discovery_response_timeout (gpointer user_data) { DiscoveryResponse *response = user_data; GSSDPClient *client; SoupDate *date; char *al, *date_str, *message; guint max_age; char *usn; GSSDPResourceGroup *self = response->resource->resource_group; GSSDPResourceGroupPrivate *priv; priv = gssdp_resource_group_get_instance_private (self); /* Send message */ client = priv->client; max_age = priv->max_age; al = construct_al (response->resource); usn = construct_usn (response->resource->usn, response->target, response->resource->target); date = soup_date_new_from_now (0); date_str = soup_date_to_string (date, SOUP_DATE_HTTP); soup_date_free (date); message = g_strdup_printf (SSDP_DISCOVERY_RESPONSE, (char *) response->resource->locations->data, al ? al : "", usn, gssdp_client_get_server_id (client), max_age, response->target, date_str); _gssdp_client_send_message (client, response->dest_ip, response->dest_port, message, _GSSDP_DISCOVERY_RESPONSE); g_free (message); g_free (date_str); g_free (al); g_free (usn); discovery_response_free (response); return FALSE; }
/* * Free a Resource structure and its contained data */ static void resource_free (Resource *resource) { while (resource->responses) discovery_response_free (resource->responses->data); if (resource->resource_group->priv->available) resource_byebye (resource); g_free (resource->usn); g_free (resource->target); if (resource->target_regex) g_regex_unref (resource->target_regex); while (resource->locations) { g_free (resource->locations->data); resource->locations = g_list_delete_link (resource->locations, resource->locations); } g_slice_free (Resource, resource); }
/* * Free a Resource structure and its contained data */ static void resource_free (Resource *resource) { GSSDPResourceGroupPrivate *priv; priv = gssdp_resource_group_get_instance_private (resource->resource_group); /* discovery_response_free will take clear of freeing the list * elements and data */ while (resource->responses) discovery_response_free (resource->responses->data); if (priv->available) resource_byebye (resource); g_free (resource->usn); g_free (resource->target); g_clear_pointer (&resource->target_regex, g_regex_unref); g_list_free_full (resource->locations, g_free); g_slice_free (Resource, resource); }