summaryrefslogtreecommitdiff
path: root/sendto/plugins/upnp/upnp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sendto/plugins/upnp/upnp.c')
-rw-r--r--sendto/plugins/upnp/upnp.c59
1 files changed, 36 insertions, 23 deletions
diff --git a/sendto/plugins/upnp/upnp.c b/sendto/plugins/upnp/upnp.c
index 4c09e66..b770e37 100644
--- a/sendto/plugins/upnp/upnp.c
+++ b/sendto/plugins/upnp/upnp.c
@@ -25,9 +25,12 @@
*
*/
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <glib/gi18n-lib.h>
+
#include <libgupnp/gupnp.h>
#include "caja-sendto-plugin.h"
@@ -84,25 +87,37 @@ check_required_actions (GUPnPServiceIntrospection *introspection)
}
static void
-get_introspection_cb (GUPnPServiceInfo *service_info,
- GUPnPServiceIntrospection *introspection, const GError *error,
- gpointer user_data)
+get_introspection_cb (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data)
{
GUPnPDeviceInfo *device_info;
gchar *name;
const gchar *udn, *interface;
GtkTreeIter iter;
GUPnPContext *context;
+ GError *error = NULL;
device_info = GUPNP_DEVICE_INFO (user_data);
- if (introspection != NULL) {
- /* If introspection is available, make sure required actions
- * are implemented.
- */
- if (!check_required_actions (introspection))
- goto error;
- }
+ GUPnPServiceIntrospection *introspection =
+ gupnp_service_info_introspect_finish (GUPNP_SERVICE_INFO (GUPNP_SERVICE_INFO (source_object)),
+ res,
+ &error);
+ if (error) {
+ g_warning ("Failed to create introspection for '%s': %s",
+ gupnp_service_info_get_udn (GUPNP_SERVICE_INFO (source_object)),
+ error->message);
+ g_clear_error (&error);
+ goto error;
+ }
+
+ /* If introspection is available, make sure required actions
+ * are implemented.
+ */
+ if (!check_required_actions (introspection)) {
+ goto error;
+ }
udn = gupnp_device_info_get_udn (device_info);
if (G_UNLIKELY (udn == NULL))
@@ -126,10 +141,8 @@ get_introspection_cb (GUPnPServiceInfo *service_info,
-1);
g_free (name);
-
+ g_object_unref (introspection);
error:
- /* We don't need the proxy objects anymore */
- g_object_unref (service_info);
g_object_ref (device_info);
}
@@ -145,9 +158,10 @@ device_proxy_available_cb (GUPnPControlPoint *cp,
return;
}
- gupnp_service_info_get_introspection_async (info,
- get_introspection_cb,
- g_object_ref (proxy));
+ gupnp_service_info_introspect_async (info,
+ NULL,
+ get_introspection_cb,
+ g_object_ref (proxy));
}
static void
@@ -167,7 +181,7 @@ device_proxy_unavailable_cb (GUPnPControlPoint *cp,
}
static void
-on_context_available (GUPnPContextManager *context_manager,
+on_context_available (GUPnPContextManager *manager,
GUPnPContext *context,
gpointer user_data)
{
@@ -187,7 +201,7 @@ on_context_available (GUPnPContextManager *context_manager,
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);
+ gupnp_context_manager_manage_control_point (manager, cp);
g_object_unref (cp);
}
@@ -198,19 +212,17 @@ init (NstPlugin *plugin)
GtkCellRenderer *renderer;
char *upload_cmd;
+#ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif /* ENABLE_NLS */
upload_cmd = g_find_program_in_path ("gupnp-upload");
if (upload_cmd == NULL)
return FALSE;
g_free (upload_cmd);
-#ifdef HAS_GUPNP_VERSION_1_2
context_manager = gupnp_context_manager_create (0);
-#else
- context_manager = gupnp_context_manager_new (NULL, 0);
-#endif
g_assert (context_manager != NULL);
g_signal_connect (context_manager, "context-available",
G_CALLBACK (on_context_available), NULL);
@@ -270,6 +282,7 @@ send_files (NstPlugin *plugin,
g_ptr_array_add (argv, "15"); /* discovery timeout (seconds) */
g_ptr_array_add (argv, "-e");
g_ptr_array_add (argv, interface);
+ g_ptr_array_add (argv, "-u");
g_ptr_array_add (argv, udn);
for (l = file_list ; l; l=l->next) {
gchar *file_path;