From 40d177765fdb7a0dd67e21d81f3dd6e2469d58a4 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Mon, 23 Sep 2024 02:36:36 +0200 Subject: [PATCH] documents: Move it to the xdp namespace Rename the DocumentFlags enum and related functions to have an XDP prefix. --- src/account.c | 2 +- src/documents.c | 30 +++++++++++++++--------------- src/documents.h | 30 +++++++++++++++--------------- src/file-chooser.c | 16 ++++++++-------- src/open-uri.c | 10 +++++----- src/screenshot.c | 2 +- src/xdg-desktop-portal.c | 2 +- 7 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/account.c b/src/account.c index 3edf117a0..9a01267d9 100644 --- a/src/account.c +++ b/src/account.c @@ -100,7 +100,7 @@ send_response_in_thread_func (GTask *task, if (xdp_app_info_is_host (request->app_info)) ruri = g_strdup (image); else - ruri = register_document (image, xdp_app_info_get_id (request->app_info), DOCUMENT_FLAG_NONE, &error); + ruri = xdp_register_document (image, xdp_app_info_get_id (request->app_info), XDP_DOCUMENT_FLAG_NONE, &error); if (ruri == NULL) g_warning ("Failed to register %s: %s", image, error->message); diff --git a/src/documents.c b/src/documents.c index 38a8834a2..0c31ab015 100644 --- a/src/documents.c +++ b/src/documents.c @@ -42,8 +42,8 @@ static XdpDbusDocuments *documents = NULL; static char *documents_mountpoint = NULL; gboolean -init_document_proxy (GDBusConnection *connection, - GError **error) +xdp_init_document_proxy (GDBusConnection *connection, + GError **error) { documents = xdp_dbus_documents_proxy_new_sync (connection, 0, "org.freedesktop.portal.Documents", @@ -61,10 +61,10 @@ init_document_proxy (GDBusConnection *connection, } char * -register_document (const char *uri, - const char *app_id, - DocumentFlags flags, - GError **error) +xdp_register_document (const char *uri, + const char *app_id, + XdpDocumentFlags flags, + GError **error) { g_autofree char *doc_id = NULL; g_auto(GStrv) doc_ids = NULL; @@ -89,7 +89,7 @@ register_document (const char *uri, basename = g_path_get_basename (path); dirname = g_path_get_dirname (path); - if (flags & DOCUMENT_FLAG_FOR_SAVE) + if (flags & XDP_DOCUMENT_FLAG_FOR_SAVE) fd = open (dirname, O_PATH | O_CLOEXEC); else fd = open (path, O_PATH | O_CLOEXEC); @@ -109,19 +109,19 @@ register_document (const char *uri, i = 0; permissions[i++] = "read"; - if ((flags & DOCUMENT_FLAG_WRITABLE) || (flags & DOCUMENT_FLAG_FOR_SAVE)) + if ((flags & XDP_DOCUMENT_FLAG_WRITABLE) || (flags & XDP_DOCUMENT_FLAG_FOR_SAVE)) permissions[i++] = "write"; permissions[i++] = "grant-permissions"; - if (flags & DOCUMENT_FLAG_DELETABLE) + if (flags & XDP_DOCUMENT_FLAG_DELETABLE) permissions[i++] = "delete"; permissions[i++] = NULL; version = xdp_dbus_documents_get_version (documents); full_flags = DOCUMENT_ADD_FLAGS_REUSE_EXISTING | DOCUMENT_ADD_FLAGS_PERSISTENT | DOCUMENT_ADD_FLAGS_AS_NEEDED_BY_APP; - if (flags & DOCUMENT_FLAG_DIRECTORY) + if (flags & XDP_DOCUMENT_FLAG_DIRECTORY) full_flags |= DOCUMENT_ADD_FLAGS_DIRECTORY; - if (flags & DOCUMENT_FLAG_FOR_SAVE) + if (flags & XDP_DOCUMENT_FLAG_FOR_SAVE) { if (version >= 3) { @@ -211,8 +211,8 @@ register_document (const char *uri, } char * -get_real_path_for_doc_path (const char *path, - XdpAppInfo *app_info) +xdp_get_real_path_for_doc_path (const char *path, + XdpAppInfo *app_info) { g_autofree char *doc_id = NULL; gboolean ret = FALSE; @@ -234,11 +234,11 @@ get_real_path_for_doc_path (const char *path, return g_strdup (path); } - return get_real_path_for_doc_id (doc_id); + return xdp_get_real_path_for_doc_id (doc_id); } char * -get_real_path_for_doc_id (const char *doc_id) +xdp_get_real_path_for_doc_id (const char *doc_id) { gboolean ret = FALSE; char *real_path = NULL; diff --git a/src/documents.h b/src/documents.h index 89724411c..dda92406e 100644 --- a/src/documents.h +++ b/src/documents.h @@ -25,22 +25,22 @@ #include typedef enum { - DOCUMENT_FLAG_NONE = 0, - DOCUMENT_FLAG_FOR_SAVE = (1 << 0), - DOCUMENT_FLAG_WRITABLE = (1 << 1), - DOCUMENT_FLAG_DIRECTORY = (1 << 2), - DOCUMENT_FLAG_DELETABLE = (1 << 3), -} DocumentFlags; + XDP_DOCUMENT_FLAG_NONE = 0, + XDP_DOCUMENT_FLAG_FOR_SAVE = (1 << 0), + XDP_DOCUMENT_FLAG_WRITABLE = (1 << 1), + XDP_DOCUMENT_FLAG_DIRECTORY = (1 << 2), + XDP_DOCUMENT_FLAG_DELETABLE = (1 << 3), +} XdpDocumentFlags; -gboolean init_document_proxy (GDBusConnection *connection, - GError **error); +gboolean xdp_init_document_proxy (GDBusConnection *connection, + GError **error); -char *register_document (const char *uri, - const char *app_id, - DocumentFlags flags, - GError **error); +char *xdp_register_document (const char *uri, + const char *app_id, + XdpDocumentFlags flags, + GError **error); -char *get_real_path_for_doc_path (const char *path, - XdpAppInfo *app_info); +char *xdp_get_real_path_for_doc_path (const char *path, + XdpAppInfo *app_info); -char *get_real_path_for_doc_id (const char *doc_id); +char *xdp_get_real_path_for_doc_id (const char *doc_id); diff --git a/src/file-chooser.c b/src/file-chooser.c index 1985dde97..cb3580e6e 100644 --- a/src/file-chooser.c +++ b/src/file-chooser.c @@ -79,7 +79,7 @@ send_response_in_thread_func (GTask *task, G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_STRING_ARRAY); guint response; GVariant *options; - DocumentFlags flags = DOCUMENT_FLAG_WRITABLE | DOCUMENT_FLAG_DIRECTORY; + XdpDocumentFlags flags = XDP_DOCUMENT_FLAG_WRITABLE | XDP_DOCUMENT_FLAG_DIRECTORY; g_autofree char **uris = NULL; GVariant *choices; GVariant *current_filter; @@ -88,9 +88,9 @@ send_response_in_thread_func (GTask *task, REQUEST_AUTOLOCK (request); if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (request), "for-save")) == TRUE) - flags |= DOCUMENT_FLAG_FOR_SAVE; + flags |= XDP_DOCUMENT_FLAG_FOR_SAVE; if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (request), "directory")) == FALSE) - flags &= ~DOCUMENT_FLAG_DIRECTORY; + flags &= ~XDP_DOCUMENT_FLAG_DIRECTORY; response = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (request), "response")); options = (GVariant *)g_object_get_data (G_OBJECT (request), "options"); @@ -99,7 +99,7 @@ send_response_in_thread_func (GTask *task, writable = g_variant_lookup_value (options, "writable", G_VARIANT_TYPE("b")); if (writable && !g_variant_get_boolean (writable)) - flags &= ~DOCUMENT_FLAG_WRITABLE; + flags &= ~XDP_DOCUMENT_FLAG_WRITABLE; choices = g_variant_lookup_value (options, "choices", G_VARIANT_TYPE ("a(ss)")); if (choices) @@ -129,7 +129,7 @@ send_response_in_thread_func (GTask *task, if (xdp_app_info_is_host (request->app_info)) ruri = g_strdup (uris[i]); else - ruri = register_document (uris[i], xdp_app_info_get_id (request->app_info), flags, &error); + ruri = xdp_register_document (uris[i], xdp_app_info_get_id (request->app_info), flags, &error); if (ruri == NULL) { @@ -193,7 +193,7 @@ looks_like_document_portal_path (const char *path, static char * get_host_folder_for_doc_id (const char *doc_id) { - g_autofree char *real_path = get_real_path_for_doc_id (doc_id); + g_autofree char *real_path = xdp_get_real_path_for_doc_id (doc_id); g_autofree char *host_folder = NULL; if (real_path != NULL) @@ -692,13 +692,13 @@ handle_save_file (XdpDbusFileChooser *object, if (value) { const char *path = g_variant_get_bytestring (value); - g_autofree char *host_path = get_real_path_for_doc_path (path, request->app_info); + g_autofree char *host_path = xdp_get_real_path_for_doc_path (path, request->app_info); g_autofree char *doc_id = NULL; if (strcmp (path, host_path) == 0 && looks_like_document_portal_path (path, &doc_id)) { - char *real_path = get_real_path_for_doc_id (doc_id); + char *real_path = xdp_get_real_path_for_doc_id (doc_id); if (real_path) { diff --git a/src/open-uri.c b/src/open-uri.c index 4af4a26a4..91f4c54de 100644 --- a/src/open-uri.c +++ b/src/open-uri.c @@ -245,7 +245,7 @@ launch_application_with_uri (const char *choice_id, g_autoptr(XdpAppLaunchContext) xdp_context = xdp_app_launch_context_new (); GAppLaunchContext *context = G_APP_LAUNCH_CONTEXT (xdp_context); g_autofree char *ruri = NULL; - DocumentFlags flags = DOCUMENT_FLAG_NONE; + XdpDocumentFlags flags = XDP_DOCUMENT_FLAG_NONE; GList uris; if (info == NULL) @@ -263,9 +263,9 @@ launch_application_with_uri (const char *choice_id, g_debug ("Registering %s for %s", uri, choice_id); if (writable) - flags |= DOCUMENT_FLAG_WRITABLE; + flags |= XDP_DOCUMENT_FLAG_WRITABLE; - ruri = register_document (uri, choice_id, flags, &local_error); + ruri = xdp_register_document (uri, choice_id, flags, &local_error); if (ruri == NULL) { g_warning ("Error registering %s for %s: %s", uri, choice_id, local_error->message); @@ -688,7 +688,7 @@ handle_open_in_thread_func (GTask *task, if (path != NULL) { - host_path = get_real_path_for_doc_path (path, request->app_info); + host_path = xdp_get_real_path_for_doc_path (path, request->app_info); if (host_path) { g_debug ("OpenFile: translating path value '%s' to host path '%s'", path, host_path); @@ -724,7 +724,7 @@ handle_open_in_thread_func (GTask *task, if (open_dir) { - g_autofree char *real_path = get_real_path_for_doc_path (path, request->app_info); + g_autofree char *real_path = xdp_get_real_path_for_doc_path (path, request->app_info); /* Try opening the directory via the file manager interface, then fall back to a plain URI open */ g_autoptr(GError) local_error = NULL; diff --git a/src/screenshot.c b/src/screenshot.c index 2a319e0d4..2c2f7fb5c 100644 --- a/src/screenshot.c +++ b/src/screenshot.c @@ -125,7 +125,7 @@ send_response_in_thread_func (GTask *task, if (xdp_app_info_is_host (request->app_info)) ruri = g_strdup (uri); else - ruri = register_document (uri, xdp_app_info_get_id (request->app_info), DOCUMENT_FLAG_DELETABLE, &error); + ruri = xdp_register_document (uri, xdp_app_info_get_id (request->app_info), XDP_DOCUMENT_FLAG_DELETABLE, &error); if (ruri == NULL) g_warning ("Failed to register %s: %s", uri, error->message); diff --git a/src/xdg-desktop-portal.c b/src/xdg-desktop-portal.c index 40300dac0..06a3129fa 100644 --- a/src/xdg-desktop-portal.c +++ b/src/xdg-desktop-portal.c @@ -224,7 +224,7 @@ on_bus_acquired (GDBusConnection *connection, return; } - if (!init_document_proxy (connection, &error)) + if (!xdp_init_document_proxy (connection, &error)) { g_critical ("No document portal: %s", error->message); exit_with_status (1);