summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaotian Wu <[email protected]>2023-10-16 10:42:27 +0800
committerraveit65 <[email protected]>2023-10-24 09:21:51 +0200
commit1d21084e8ffdacb3e3b60840261b6d456d23887e (patch)
tree5a7a8cbc8b694e1b3c91c3ee034723691afdc150
parent282756dbfaca7984af2f74f9c2b8417e27c5c85e (diff)
downloadcaja-extensions-1d21084e8ffdacb3e3b60840261b6d456d23887e.tar.bz2
caja-extensions-1d21084e8ffdacb3e3b60840261b6d456d23887e.tar.xz
sendto: require gupnp-1.6
-rw-r--r--configure.ac6
-rw-r--r--sendto/plugins/upnp/upnp.c48
2 files changed, 30 insertions, 24 deletions
diff --git a/configure.ac b/configure.ac
index c8fb513..8df589a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,7 +119,7 @@ if test "x$enable_sendto" = "xyes"; then
GTHREAD_REQUIRED=2.6.0
DBUS_REQUIRED=1.0
DBUS_GLIB_REQUIRED=0.60
- GUPNP_REQUIRED=0.13
+ GUPNP_REQUIRED=1.6
PKG_CHECK_MODULES(SENDTO,
glib-2.0 >= $GLIB_REQUIRED
gthread-2.0 >= $GTHREAD_REQUIRED
@@ -233,9 +233,7 @@ if test "x$enable_sendto" = "xyes"; then
fi
;;
upnp)
- PKG_CHECK_MODULES(UPNP, gupnp-1.2 >= $GUPNP_REQUIRED,
- enable_upnp=yes AC_DEFINE([HAS_GUPNP_VERSION_1_2], 1, ["Version is at least 1.2"]), enable_upnp=no)
- PKG_CHECK_MODULES(UPNP, gupnp-1.0 >= $GUPNP_REQUIRED,
+ PKG_CHECK_MODULES(UPNP, gupnp-1.6 >= $GUPNP_REQUIRED,
enable_upnp=yes, enable_upnp=no)
if test "${enable_upnp}" != "yes" ; then
sendto_plugin_error_or_ignore "you need gupnp installed to build the upnp plugin"
diff --git a/sendto/plugins/upnp/upnp.c b/sendto/plugins/upnp/upnp.c
index 7b6775b..b770e37 100644
--- a/sendto/plugins/upnp/upnp.c
+++ b/sendto/plugins/upnp/upnp.c
@@ -87,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))
@@ -129,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);
}
@@ -148,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
@@ -211,11 +222,7 @@ init (NstPlugin *plugin)
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);
@@ -275,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;