gssdp_client_initable_iface_init));
struct _GSSDPClientPrivate {
- GMainContext *main_context;
-
char *server_id;
char *iface;
char *host_ip;
static guint signals[LAST_SIGNAL];
-/* Function prototypes */
-static void
-gssdp_client_set_main_context (GSSDPClient *client,
- GMainContext *context);
static char *
make_server_id (void);
static gboolean
return FALSE;
}
- gssdp_socket_source_attach (client->priv->request_socket,
- client->priv->main_context);
-
- gssdp_socket_source_attach (client->priv->multicast_socket,
- client->priv->main_context);
-
- gssdp_socket_source_attach (client->priv->search_socket,
- client->priv->main_context);
+ gssdp_socket_source_attach (client->priv->request_socket);
+ gssdp_socket_source_attach (client->priv->multicast_socket);
+ gssdp_socket_source_attach (client->priv->search_socket);
return TRUE;
}
gssdp_client_get_server_id (client));
break;
case PROP_MAIN_CONTEXT:
+ g_warning ("GSSDPClient:main-context is deprecated."
+ " Please use g_main_context_push_thread_default()");
g_value_set_pointer
(value,
(gpointer)
- gssdp_client_get_main_context (client));
+ g_main_context_get_thread_default ());
break;
case PROP_IFACE:
g_value_set_string (value,
g_value_get_string (value));
break;
case PROP_MAIN_CONTEXT:
- gssdp_client_set_main_context (client,
- g_value_get_pointer (value));
+ g_warning ("GSSDPClient:main-context is deprecated."
+ " Please use g_main_context_push_thread_default()");
break;
case PROP_IFACE:
client->priv->iface = g_value_dup_string (value);
client->priv->search_socket = NULL;
}
- /* Unref the context */
- if (client->priv->main_context) {
- g_main_context_unref (client->priv->main_context);
- client->priv->main_context = NULL;
- }
-
G_OBJECT_CLASS (gssdp_client_parent_class)->dispose (object);
}
* GSSDPClient:main-context
*
* The #GMainContext to use. Set to NULL to use the default.
+ * Deprecated: 0.11.1: Use g_main_context_push_thread_default().
**/
g_object_class_install_property
(object_class,
/**
* gssdp_client_new
- * @main_context: The #GMainContext to associate with, or NULL
+ * @main_context: Deprecated: 0.11.1: Always set to NULL. If you want to
+ * specify a context use g_main_context_push_thread_default()
* @iface: The name of the network interface, or %NULL for auto-detection.
* @error: Location to store error, or NULL
*
const char *iface,
GError **error)
{
+ if (main_context) {
+ g_warning ("GSSDPClient:main-context is deprecated."
+ " Please use g_main_context_push_thread_default()");
+ }
return g_initable_new (GSSDP_TYPE_CLIENT,
NULL,
error,
- "main-context", main_context,
"interface", iface,
NULL);
}
/*
- * Sets the GMainContext @client is associated with to @main_context
- */
-static void
-gssdp_client_set_main_context (GSSDPClient *client,
- GMainContext *main_context)
-{
- g_return_if_fail (GSSDP_IS_CLIENT (client));
-
- /* A NULL main_context is fine */
- if (main_context)
- client->priv->main_context = g_main_context_ref (main_context);
-
- g_object_notify (G_OBJECT (client), "main-context");
-}
-
-/**
* gssdp_client_get_main_context
* @client: A #GSSDPClient
*
* Returns: (transfer none): The #GMainContext @client is associated with, or NULL.
+ * Deprecated: 0.11.1: Returns g_main_context_get_thread_default()
**/
GMainContext *
gssdp_client_get_main_context (GSSDPClient *client)
{
g_return_val_if_fail (GSSDP_IS_CLIENT (client), NULL);
- return client->priv->main_context;
+ return g_main_context_get_thread_default ();
}
/**
const char *iface,
GError **error);
+#ifndef GSSDP_DISABLE_DEPRECATED
GMainContext *
gssdp_client_get_main_context (GSSDPClient *client);
+#endif
void
gssdp_client_set_server_id (GSSDPClient *client,
gboolean was_cached;
guint timeout;
GList *locations;
- GMainContext *context;
usn = soup_message_headers_get_one (headers, "USN");
if (!usn)
resource_expire,
resource, NULL);
- context = gssdp_client_get_main_context
- (resource_browser->priv->client);
- g_source_attach (resource->timeout_src, context);
+ g_source_attach (resource->timeout_src,
+ g_main_context_get_thread_default ());
g_source_unref (resource->timeout_src);
static void
start_discovery (GSSDPResourceBrowser *resource_browser)
{
- GMainContext *context;
-
/* Send one now */
send_discovery_request (resource_browser);
discovery_timeout,
resource_browser, NULL);
- context = gssdp_client_get_main_context
- (resource_browser->priv->client);
- g_source_attach (resource_browser->priv->timeout_src, context);
+ g_source_attach (resource_browser->priv->timeout_src,
+ g_main_context_get_thread_default ());
g_source_unref (resource_browser->priv->timeout_src);
}
resource_group->priv->available = available;
if (available) {
- GMainContext *context;
int timeout;
/* We want to re-announce at least 3 times before the resource
resource_group_timeout,
resource_group, NULL);
- context = gssdp_client_get_main_context
- (resource_group->priv->client);
- g_source_attach (resource_group->priv->timeout_src, context);
+ g_source_attach (resource_group->priv->timeout_src,
+ g_main_context_get_thread_default ());
g_source_unref (resource_group->priv->timeout_src);
/* Match. */
guint timeout;
DiscoveryResponse *response;
- GMainContext *context;
/* Get a random timeout from the interval [0, mx] */
timeout = g_random_int_range (0, mx * 1000);
discovery_response_timeout,
response, NULL);
- context = gssdp_client_get_main_context (client);
- g_source_attach (response->timeout_src, context);
+ g_source_attach (response->timeout_src,
+ g_main_context_get_thread_default ());
g_source_unref (response->timeout_src);
if (resource_group->priv->message_src == NULL) {
/* nothing in the queue: process message immediately
and add a timeout for (possible) next message */
- GMainContext *context;
-
process_queue (resource_group);
resource_group->priv->message_src = g_timeout_source_new (
resource_group->priv->message_delay);
g_source_set_callback (resource_group->priv->message_src,
process_queue, resource_group, NULL);
- context = gssdp_client_get_main_context (
- resource_group->priv->client);
- g_source_attach (resource_group->priv->message_src, context);
+ g_source_attach (resource_group->priv->message_src,
+ g_main_context_get_thread_default ());
g_source_unref (resource_group->priv->message_src);
}
}
}
void
-gssdp_socket_source_attach (GSSDPSocketSource *self,
- GMainContext *context)
+gssdp_socket_source_attach (GSSDPSocketSource *self)
{
g_return_if_fail (self != NULL);
g_return_if_fail (GSSDP_IS_SOCKET_SOURCE (self));
- g_source_attach (self->priv->source, context);
+ g_source_attach (self->priv->source,
+ g_main_context_get_thread_default ());
}
static void
gpointer user_data);
G_GNUC_INTERNAL void
-gssdp_socket_source_attach (GSSDPSocketSource *socket_source,
- GMainContext *context);
+gssdp_socket_source_attach (GSSDPSocketSource *socket_source);
G_END_DECLS
*/
#include <libgssdp/gssdp.h>
+#include <gio/gio.h>
#include <stdlib.h>
static void
g_type_init ();
error = NULL;
- client = gssdp_client_new (NULL, NULL, &error);
+ client = g_initable_new (GSSDP_TYPE_CLIENT,
+ NULL,
+ &error,
+ NULL);
if (error) {
g_printerr ("Error creating the GSSDP client: %s\n",
error->message);
*/
#include <libgssdp/gssdp.h>
+#include <gio/gio.h>
#include <stdlib.h>
int
g_type_init ();
error = NULL;
- client = gssdp_client_new (NULL, NULL, &error);
+ client = g_initable_new (GSSDP_TYPE_CLIENT,
+ NULL,
+ &error,
+ NULL);
if (error) {
g_printerr ("Error creating the GSSDP client: %s\n",
error->message);
GError *error;
error = NULL;
- client = gssdp_client_new (NULL, NULL, &error);
+ client = g_initable_new (GSSDP_TYPE_CLIENT,
+ NULL,
+ &error,
+ NULL);
if (error) {
g_printerr ("Error creating the GSSDP client: %s\n",
error->message);