summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2020-07-25 19:30:47 +0200
committerJens Georg <mail@jensge.org>2020-07-29 22:44:37 +0200
commit914c2b71d08896777a9c1531575daa10d389adf7 (patch)
treeb9f73d9e945cd21e815c17ac421e992bbebefdd2
parentb526286a4798bc4f3f9f5d13bdcaeee316011e2a (diff)
downloadgupnp-tools-914c2b71d08896777a9c1531575daa10d389adf7.tar.gz
upload: Remove deprecated functions
-rw-r--r--src/upload/container-search.c94
-rw-r--r--src/upload/item-creation.c59
-rw-r--r--src/upload/transfer.c128
3 files changed, 174 insertions, 107 deletions
diff --git a/src/upload/container-search.c b/src/upload/container-search.c
index 6284b2c..d584be1 100644
--- a/src/upload/container-search.c
+++ b/src/upload/container-search.c
@@ -72,22 +72,34 @@ parse_result (const char *result)
}
static void
-browse_cb (GUPnPServiceProxy *cds_proxy,
- GUPnPServiceProxyAction *action,
- gpointer user_data)
+browse_cb (GObject *object, GAsyncResult *res, gpointer user_data)
{
- GError *error;
- char *result;
- char *container_id;
+ GError *error = NULL;
+ char *result = NULL;
+ char *container_id = NULL;
+ GUPnPServiceProxyAction *action = NULL;
+ GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY (object);
- error = NULL;
- if (!gupnp_service_proxy_end_action (cds_proxy,
- action,
- &error,
- "Result",
- G_TYPE_STRING,
- &result,
- NULL)) {
+ action = gupnp_service_proxy_call_action_finish (proxy, res, &error);
+
+ if (error != NULL) {
+ g_critical ("Failed to browse root container: %s",
+ error->message);
+
+ g_error_free (error);
+
+ application_exit ();
+
+ return;
+ }
+
+ gupnp_service_proxy_action_get_result (action,
+ &error,
+ "Restul",
+ G_TYPE_STRING,
+ &result,
+ NULL);
+ if (error != NULL) {
g_critical ("Failed to browse root container: %s",
error->message);
@@ -119,29 +131,35 @@ browse_cb (GUPnPServiceProxy *cds_proxy,
void
search_container (GUPnPServiceProxy *cds_proxy)
{
- gupnp_service_proxy_begin_action (cds_proxy,
- "Browse",
- browse_cb,
- NULL,
- /* IN args */
- "ObjectID",
- G_TYPE_STRING,
- "0",
- "BrowseFlag",
- G_TYPE_STRING,
- "BrowseDirectChildren",
- "Filter",
- G_TYPE_STRING,
- "*",
- "StartingIndex",
- G_TYPE_UINT,
- 0,
- "RequestedCount",
- G_TYPE_UINT,
- 0,
- "SortCriteria",
- G_TYPE_STRING,
- "",
- NULL);
+ GUPnPServiceProxyAction *action = NULL;
+ action = gupnp_service_proxy_action_new ("Browse",
+ /* IN args */
+ "ObjectID",
+ G_TYPE_STRING,
+ "0",
+ "BrowseFlag",
+ G_TYPE_STRING,
+ "BrowseDirectChildren",
+ "Filter",
+ G_TYPE_STRING,
+ "*",
+ "StartingIndex",
+ G_TYPE_UINT,
+ 0,
+ "RequestedCount",
+ G_TYPE_UINT,
+ 0,
+ "SortCriteria",
+ G_TYPE_STRING,
+ "",
+ NULL);
+
+ gupnp_service_proxy_call_action_async (cds_proxy,
+ action,
+ NULL,
+ browse_cb,
+ NULL);
+
+ gupnp_service_proxy_action_unref (action);
}
diff --git a/src/upload/item-creation.c b/src/upload/item-creation.c
index b9681e7..f51449d 100644
--- a/src/upload/item-creation.c
+++ b/src/upload/item-creation.c
@@ -182,22 +182,31 @@ parse_result (const char *result)
}
static void
-create_object_cb (GUPnPServiceProxy *cds_proxy,
- GUPnPServiceProxyAction *action,
- gpointer user_data)
+create_object_cb (GObject *object, GAsyncResult *res, gpointer user_data)
{
- GError *error;
+ GError *error = NULL;
char *result;
const char *import_uri;
+ GUPnPServiceProxyAction *action;
+ GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY (object);
error = NULL;
- if (!gupnp_service_proxy_end_action (cds_proxy,
- action,
- &error,
- "Result",
- G_TYPE_STRING,
- &result,
- NULL)) {
+
+ action = gupnp_service_proxy_call_action_finish (proxy, res, &error);
+ if (error != NULL) {
+ g_critical ("CreateObject call failed: %s", error->message);
+ g_clear_error (&error);
+ item_created (NULL);
+
+ return;
+ }
+
+ if (!gupnp_service_proxy_action_get_result (action,
+ &error,
+ "Result",
+ G_TYPE_STRING,
+ &result,
+ NULL)) {
g_critical ("Failed to create new item on remote container: %s",
error->message);
@@ -231,6 +240,7 @@ create_item (const char *file_path,
const char *container_id)
{
char *didl;
+ GUPnPServiceProxyAction *action;
didl = create_didl_for_file (file_path, title, container_id);
if (didl == NULL) {
@@ -239,15 +249,20 @@ create_item (const char *file_path,
return;
}
- gupnp_service_proxy_begin_action (cds_proxy,
- "CreateObject",
- create_object_cb,
- NULL,
- "ContainerID",
- G_TYPE_STRING,
- container_id,
- "Elements",
- G_TYPE_STRING,
- didl,
- NULL);
+ action = gupnp_service_proxy_action_new ("CreateObject",
+ "ContainerID",
+ G_TYPE_STRING,
+ container_id,
+ "Elements",
+ G_TYPE_STRING,
+ didl,
+ NULL);
+
+ gupnp_service_proxy_call_action_async (cds_proxy,
+ action,
+ NULL,
+ create_object_cb,
+ NULL);
+
+ gupnp_service_proxy_action_unref (action);
}
diff --git a/src/upload/transfer.c b/src/upload/transfer.c
index df1630b..d493a3b 100644
--- a/src/upload/transfer.c
+++ b/src/upload/transfer.c
@@ -36,9 +36,9 @@ typedef struct
} TrackTransferData;
static void
-get_transfer_progress_cb (GUPnPServiceProxy *cds_proxy,
- GUPnPServiceProxyAction *action,
- gpointer user_data)
+get_transfer_progress_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
{
GError *error;
TrackTransferData *data;
@@ -50,19 +50,31 @@ get_transfer_progress_cb (GUPnPServiceProxy *cds_proxy,
error = NULL;
total = length = 0;
status = NULL;
- if (!gupnp_service_proxy_end_action (cds_proxy,
- action,
- &error,
- "TransferStatus",
- G_TYPE_STRING,
- &status,
- "TransferLength",
- G_TYPE_UINT64,
- &length,
- "TransferTotal",
- G_TYPE_UINT64,
- &total,
- NULL)) {
+ gupnp_service_proxy_call_action_finish (GUPNP_SERVICE_PROXY (object),
+ result,
+ &error);
+ if (error != NULL) {
+ g_critical ("Failed to track file transfer: %s",
+ error->message);
+ g_clear_error (&error);
+
+ transfer_completed ();
+
+ return;
+ }
+
+ if (!gupnp_service_proxy_action_get_result (data->action,
+ &error,
+ "TransferStatus",
+ G_TYPE_STRING,
+ &status,
+ "TransferLength",
+ G_TYPE_UINT64,
+ &length,
+ "TransferTotal",
+ G_TYPE_UINT64,
+ &total,
+ NULL)) {
g_critical ("Failed to track file transfer: %s",
error->message);
@@ -104,15 +116,19 @@ track_transfer (gpointer user_data)
return TRUE;
}
- data->action = gupnp_service_proxy_begin_action (
- data->cds_proxy,
- "GetTransferProgress",
- get_transfer_progress_cb,
- data,
- "TransferID",
- G_TYPE_UINT,
- data->transfer_id,
- NULL);
+ data->action = gupnp_service_proxy_action_new ("GetTransferProgress",
+ "TransferID",
+ G_TYPE_UINT,
+ data->transfer_id,
+ NULL);
+
+ gupnp_service_proxy_call_action_async (data->cds_proxy,
+ data->action,
+ NULL,
+ get_transfer_progress_cb,
+ data);
+
+ gupnp_service_proxy_action_unref (data->action);
return TRUE;
}
@@ -134,24 +150,36 @@ start_tracking_transfer (GUPnPServiceProxy *cds_proxy,
}
static void
-import_resource_cb (GUPnPServiceProxy *cds_proxy,
- GUPnPServiceProxyAction *action,
- gpointer user_data)
+import_resource_cb (GObject *object, GAsyncResult *result, gpointer user_data)
{
GError *error;
guint transfer_id;
char *file_name;
+ GUPnPServiceProxyAction *action;
+ GUPnPServiceProxy *proxy = GUPNP_SERVICE_PROXY (object);
file_name = (gchar *) user_data;
error = NULL;
- if (!gupnp_service_proxy_end_action (cds_proxy,
- action,
- &error,
- "TransferID",
- G_TYPE_UINT,
- &transfer_id,
- NULL)) {
+ action = gupnp_service_proxy_call_action_finish (proxy, result, &error);
+ if (error != NULL) {
+ g_critical ("Failed to start file transfer: %s",
+ error->message);
+
+ g_free (file_name);
+ g_error_free (error);
+
+ transfer_completed ();
+
+ return;
+ }
+
+ if (!gupnp_service_proxy_action_get_result (action,
+ &error,
+ "TransferID",
+ G_TYPE_UINT,
+ &transfer_id,
+ NULL)) {
g_critical ("Failed to start file transfer: %s",
error->message);
@@ -164,7 +192,7 @@ import_resource_cb (GUPnPServiceProxy *cds_proxy,
}
g_print ("Uploading %s: 00%%", file_name);
- start_tracking_transfer (cds_proxy, transfer_id);
+ start_tracking_transfer (GUPNP_SERVICE_PROXY (object), transfer_id);
g_free (file_name);
}
@@ -177,6 +205,7 @@ start_transfer (const char *file_path,
{
char *source_uri;
char *file_name;
+ GUPnPServiceProxyAction *action;
if (!g_path_is_absolute (file_path)) {
g_critical ("Given file path '%s' is not absolute.", file_path);
@@ -195,17 +224,22 @@ start_transfer (const char *file_path,
file_path);
file_name = g_path_get_basename (file_path);
- gupnp_service_proxy_begin_action (cds_proxy,
- "ImportResource",
- import_resource_cb,
- file_name,
- "SourceURI",
- G_TYPE_STRING,
- source_uri,
- "DestinationURI",
- G_TYPE_STRING,
- dest_uri,
- NULL);
+ action = gupnp_service_proxy_action_new ("ImportResource",
+ "SourceURI",
+ G_TYPE_STRING,
+ source_uri,
+ "DestinationURI",
+ G_TYPE_STRING,
+ dest_uri,
+ NULL);
+
+ gupnp_service_proxy_call_action_async (cds_proxy,
+ action,
+ NULL,
+ import_resource_cb,
+ file_name);
+
+ gupnp_service_proxy_action_unref (action);
g_free (source_uri);
}