-
-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GetRealPath to document portal #1269
Changes from all commits
6dab11a
dfe03e6
64ed5b0
1794b06
6821356
797ea01
7aab70f
8a4e19e
341f35c
1dd61b9
5ad6f8f
a1a7c8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -273,5 +273,21 @@ | |||||
<arg type='s' name='app_id' direction='in'/> | ||||||
<arg type='a{say}' name='docs' direction='out'/> | ||||||
</method> | ||||||
|
||||||
<!-- | ||||||
GetRealPath: | ||||||
@doc_id: the ID of the file in the document store | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
@path: the path for the file in the host filesystem | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Gets the filesystem path for a document store entry. | ||||||
grulja marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
This call is available inside the sandbox, if the application has the permission for the document. | ||||||
|
||||||
This method was added in version 5 of this interface. | ||||||
--> | ||||||
<method name="GetRealPath"> | ||||||
grulja marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<arg type='as' name='doc_id' direction='in'/> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<arg type='aay' name='path' direction='out'/> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
</method> | ||||||
</interface> | ||||||
</node> |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1416,6 +1416,90 @@ portal_list (GDBusMethodInvocation *invocation, | |||||
return TRUE; | ||||||
} | ||||||
|
||||||
const char * | ||||||
get_real_path_internal (GDBusMethodInvocation *invocation, | ||||||
XdpAppInfo *app_info, | ||||||
const char *id) | ||||||
{ | ||||||
g_autoptr(PermissionDbEntry) entry = NULL; | ||||||
|
||||||
XDP_AUTOLOCK (db); | ||||||
|
||||||
entry = permission_db_lookup (db, id); | ||||||
|
||||||
if (!entry) | ||||||
{ | ||||||
g_dbus_method_invocation_return_error (invocation, | ||||||
XDG_DESKTOP_PORTAL_ERROR, XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENT, | ||||||
g_strdup_printf("Invalid ID passed (%s)", id)); | ||||||
return NULL; | ||||||
} | ||||||
|
||||||
if (!xdp_app_info_is_host (app_info)) | ||||||
{ | ||||||
g_autofree const char **apps = NULL; | ||||||
const char *app_id = NULL; | ||||||
gboolean app_found = FALSE; | ||||||
int i; | ||||||
|
||||||
app_id = xdp_app_info_get_id(app_info); | ||||||
|
||||||
apps = permission_db_entry_list_apps (entry); | ||||||
for (i = 0; apps[i] != NULL; i++) | ||||||
{ | ||||||
if (g_strcmp0 (app_id, apps[i]) == 0) | ||||||
{ | ||||||
app_found = TRUE; | ||||||
break; | ||||||
} | ||||||
} | ||||||
|
||||||
if (!app_found) | ||||||
{ | ||||||
g_dbus_method_invocation_return_error (invocation, | ||||||
XDG_DESKTOP_PORTAL_ERROR, XDG_DESKTOP_PORTAL_ERROR_NOT_ALLOWED, | ||||||
"Not enough permissions"); | ||||||
return NULL; | ||||||
} | ||||||
} | ||||||
|
||||||
g_autoptr (GVariant) data = permission_db_entry_get_data (entry); | ||||||
const char *path; | ||||||
|
||||||
g_variant_get (data, "(^&ayttu)", &path, NULL, NULL, NULL); | ||||||
|
||||||
return path; | ||||||
} | ||||||
|
||||||
static gboolean | ||||||
portal_get_real_path (GDBusMethodInvocation *invocation, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
GVariant *parameters, | ||||||
XdpAppInfo *app_info) | ||||||
{ | ||||||
g_autofree const char **id_list = NULL; | ||||||
const char *path; | ||||||
int i; | ||||||
|
||||||
g_variant_get (parameters, "(^a&s)", &id_list); | ||||||
|
||||||
GVariantBuilder builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("aay")); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
for (i = 0; id_list[i]; i++) | ||||||
{ | ||||||
path = get_real_path_internal(invocation, app_info, id_list[i]); | ||||||
if (path == NULL) | ||||||
{ | ||||||
return FALSE; | ||||||
} | ||||||
|
||||||
g_variant_builder_add (&builder, "^ay", path); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
g_dbus_method_invocation_return_value (invocation, g_variant_new ("(aay)", &builder)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
return TRUE; | ||||||
} | ||||||
|
||||||
static void | ||||||
peer_died_cb (const char *name) | ||||||
{ | ||||||
|
@@ -1432,7 +1516,7 @@ on_bus_acquired (GDBusConnection *connection, | |||||
|
||||||
dbus_api = xdp_dbus_documents_skeleton_new (); | ||||||
|
||||||
xdp_dbus_documents_set_version (XDP_DBUS_DOCUMENTS (dbus_api), 4); | ||||||
xdp_dbus_documents_set_version (XDP_DBUS_DOCUMENTS (dbus_api), 5); | ||||||
|
||||||
g_signal_connect_swapped (dbus_api, "handle-get-mount-point", G_CALLBACK (handle_get_mount_point), NULL); | ||||||
g_signal_connect_swapped (dbus_api, "handle-add", G_CALLBACK (handle_method), portal_add); | ||||||
|
@@ -1445,6 +1529,7 @@ on_bus_acquired (GDBusConnection *connection, | |||||
g_signal_connect_swapped (dbus_api, "handle-lookup", G_CALLBACK (handle_method), portal_lookup); | ||||||
g_signal_connect_swapped (dbus_api, "handle-info", G_CALLBACK (handle_method), portal_info); | ||||||
g_signal_connect_swapped (dbus_api, "handle-list", G_CALLBACK (handle_method), portal_list); | ||||||
g_signal_connect_swapped (dbus_api, "handle-get-real-path", G_CALLBACK (handle_method), portal_get_real_path); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
file_transfer = file_transfer_create (); | ||||||
g_dbus_interface_skeleton_set_flags (file_transfer, | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.