summaryrefslogtreecommitdiff
path: root/document-portal
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2015-09-17 20:08:10 +0200
committerAlexander Larsson <alexl@redhat.com>2015-09-17 20:09:50 +0200
commiteec8798f5e88af289b5e53c658391fff410e8ae0 (patch)
treec3aca93611029bf39c68733ca91153d229e0b20f /document-portal
parent7fccaf1e5792129f2f96d0b443cc8f29efc760cb (diff)
downloadxdg-app-eec8798f5e88af289b5e53c658391fff410e8ae0.tar.gz
document portal: Add support for transient documents
These are useful for passing temporary files.
Diffstat (limited to 'document-portal')
-rw-r--r--document-portal/xdp-main.c55
-rw-r--r--document-portal/xdp-util.h1
2 files changed, 35 insertions, 21 deletions
diff --git a/document-portal/xdp-main.c b/document-portal/xdp-main.c
index cea1090..5c2cbb5 100644
--- a/document-portal/xdp-main.c
+++ b/document-portal/xdp-main.c
@@ -86,6 +86,14 @@ xdp_lookup_doc (guint32 id)
return xdg_app_db_lookup (db, doc_id);
}
+static gboolean
+persist_entry (XdgAppDbEntry *entry)
+{
+ guint32 flags = xdp_entry_get_flags (entry);
+
+ return (flags & XDP_ENTRY_FLAG_TRANSIENT) == 0;
+}
+
static void
do_set_permissions (XdgAppDbEntry *entry,
const char *doc_id,
@@ -102,14 +110,15 @@ do_set_permissions (XdgAppDbEntry *entry,
xdp_fuse_invalidate_doc_app (doc_id, app_id, entry);
- xdg_app_permission_store_call_set_permission (permission_store,
- TABLE_NAME,
- FALSE,
- doc_id,
- app_id,
- perms_s,
- NULL,
- NULL, NULL);
+ if (persist_entry (new_entry))
+ xdg_app_permission_store_call_set_permission (permission_store,
+ TABLE_NAME,
+ FALSE,
+ doc_id,
+ app_id,
+ perms_s,
+ NULL,
+ NULL, NULL);
}
static void
@@ -245,14 +254,15 @@ portal_delete (GDBusMethodInvocation *invocation,
xdp_fuse_invalidate_doc_app (id, old_apps[i], entry);
xdp_fuse_invalidate_doc (id, entry);
- xdg_app_permission_store_call_delete (permission_store, TABLE_NAME,
- id, NULL, NULL, NULL);
+ if (persist_entry (entry))
+ xdg_app_permission_store_call_delete (permission_store, TABLE_NAME,
+ id, NULL, NULL, NULL);
g_dbus_method_invocation_return_value (invocation, g_variant_new ("()"));
}
char *
-do_create_doc (struct stat *parent_st_buf, const char *path, gboolean reuse_existing)
+do_create_doc (struct stat *parent_st_buf, const char *path, gboolean reuse_existing, gboolean persistent)
{
g_autoptr(GVariant) data = NULL;
g_autoptr (XdgAppDbEntry) entry = NULL;
@@ -262,6 +272,8 @@ do_create_doc (struct stat *parent_st_buf, const char *path, gboolean reuse_exis
if (!reuse_existing)
flags |= XDP_ENTRY_FLAG_UNIQUE;
+ if (!persistent)
+ flags |= XDP_ENTRY_FLAG_TRANSIENT;
data =
g_variant_ref_sink (g_variant_new ("(^ayttu)",
path,
@@ -295,13 +307,14 @@ do_create_doc (struct stat *parent_st_buf, const char *path, gboolean reuse_exis
xdp_fuse_invalidate_doc (id, entry);
- xdg_app_permission_store_call_set (permission_store,
- TABLE_NAME,
- TRUE,
- id,
- g_variant_new_array (G_VARIANT_TYPE("{sas}"), NULL, 0),
- g_variant_new_variant (data),
- NULL, NULL, NULL);
+ if (persistent)
+ xdg_app_permission_store_call_set (permission_store,
+ TABLE_NAME,
+ TRUE,
+ id,
+ g_variant_new_array (G_VARIANT_TYPE("{sas}"), NULL, 0),
+ g_variant_new_variant (data),
+ NULL, NULL, NULL);
return id;
}
@@ -323,9 +336,9 @@ portal_add (GDBusMethodInvocation *invocation,
struct stat st_buf, real_st_buf, real_parent_st_buf;
g_autofree char *dirname = NULL;
g_autofree char *name = NULL;
- gboolean reuse_existing;
+ gboolean reuse_existing, persistent;
- g_variant_get (parameters, "(hb)", &fd_id, &reuse_existing);
+ g_variant_get (parameters, "(hbb)", &fd_id, &reuse_existing, &persistent);
message = g_dbus_method_invocation_get_message (invocation);
fd_list = g_dbus_message_get_unix_fd_list (message);
@@ -420,7 +433,7 @@ portal_add (GDBusMethodInvocation *invocation,
}
else
{
- id = do_create_doc (&real_parent_st_buf, path_buffer, reuse_existing);
+ id = do_create_doc (&real_parent_st_buf, path_buffer, reuse_existing, persistent);
if (app_id[0] != '\0')
{
diff --git a/document-portal/xdp-util.h b/document-portal/xdp-util.h
index e58e3a6..b0967ba 100644
--- a/document-portal/xdp-util.h
+++ b/document-portal/xdp-util.h
@@ -8,6 +8,7 @@
G_BEGIN_DECLS
#define XDP_ENTRY_FLAG_UNIQUE (1<<0)
+#define XDP_ENTRY_FLAG_TRANSIENT (1<<1)
const char ** xdg_unparse_permissions (XdpPermissionFlags permissions);
XdpPermissionFlags xdp_parse_permissions (const char **permissions);