[nautilus-sendto] Ability to deal with multiple/dynamic networks
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-sendto] Ability to deal with multiple/dynamic networks
- Date: Thu, 17 Sep 2009 21:07:33 +0000 (UTC)
commit 380cc5f472dfdeb77a93bfde22c6bee8c3f075b9
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sun Aug 23 14:57:00 2009 +0300
Ability to deal with multiple/dynamic networks
Use the new GUPnP API to be able to deal with multiple/dynamic networks.
https://bugzilla.gnome.org/show_bug.cgi?id=592799
src/plugins/upnp/upnp.c | 57 +++++++++++++++++++++++++---------------------
1 files changed, 31 insertions(+), 26 deletions(-)
---
diff --git a/src/plugins/upnp/upnp.c b/src/plugins/upnp/upnp.c
index eb24ed7..cf9a588 100644
--- a/src/plugins/upnp/upnp.c
+++ b/src/plugins/upnp/upnp.c
@@ -43,8 +43,7 @@ enum {
static GtkWidget *combobox;
static GtkTreeModel *model;
-static GUPnPContext *context;
-static GUPnPControlPoint *cp;
+static GUPnPContextManager *context_manager;
static gboolean
find_device (const gchar *udn,
@@ -168,12 +167,36 @@ device_proxy_unavailable_cb (GUPnPControlPoint *cp,
gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
}
+static void
+on_context_available (GUPnPContextManager *context_manager,
+ GUPnPContext *context,
+ gpointer user_data)
+{
+ GUPnPControlPoint *cp;
+
+ cp = gupnp_control_point_new (context, MEDIA_SERVER);
+
+ g_signal_connect (cp,
+ "device-proxy-available",
+ G_CALLBACK (device_proxy_available_cb),
+ NULL);
+ g_signal_connect (cp,
+ "device-proxy-unavailable",
+ G_CALLBACK (device_proxy_unavailable_cb),
+ NULL);
+
+ gssdp_resource_browser_set_active (GSSDP_RESOURCE_BROWSER (cp), TRUE);
+
+ /* Let context manager take care of the control point life cycle */
+ gupnp_context_manager_manage_control_point (context_manager, cp);
+ g_object_unref (cp);
+}
+
static gboolean
init (NstPlugin *plugin)
{
GtkListStore *store;
GtkCellRenderer *renderer;
- GError *error;
char *upload_cmd;
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
@@ -184,27 +207,10 @@ init (NstPlugin *plugin)
return FALSE;
g_free (upload_cmd);
- error = NULL;
- context = gupnp_context_new (NULL, NULL, 0, &error);
- if (error != NULL) {
- g_error (error->message);
- g_error_free (error);
-
- return FALSE;
- }
-
- cp = gupnp_control_point_new (context, MEDIA_SERVER);
-
- g_signal_connect (cp,
- "device-proxy-available",
- G_CALLBACK (device_proxy_available_cb),
- NULL);
- g_signal_connect (cp,
- "device-proxy-unavailable",
- G_CALLBACK (device_proxy_unavailable_cb),
- NULL);
-
- gssdp_resource_browser_set_active (GSSDP_RESOURCE_BROWSER (cp), TRUE);
+ context_manager = gupnp_context_manager_new (NULL, 0);
+ g_assert (context_manager != NULL);
+ g_signal_connect (context_manager, "context-available",
+ G_CALLBACK (on_context_available), NULL);
combobox = gtk_combo_box_new ();
@@ -292,8 +298,7 @@ destroy (NstPlugin *plugin)
gtk_widget_destroy (combobox);
g_object_unref (model);
- g_object_unref (cp);
- g_object_unref (context);
+ g_object_unref (context_manager);
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]