common: Make it explicit that XdgAppError are portal errors

tingping/wmclass
Alexander Larsson 2015-12-08 12:16:38 +01:00
parent a28ced36c7
commit 4177f358cb
10 changed files with 54 additions and 56 deletions

View File

@ -26,8 +26,8 @@ libxdgapp_common_la_SOURCES = \
common/xdg-app-dir.h \
common/xdg-app-run.c \
common/xdg-app-run.h \
common/xdg-app-error.c \
common/xdg-app-error.h \
common/xdg-app-portal-error.c \
common/xdg-app-portal-error.h \
common/xdg-app-utils.c \
common/xdg-app-utils.h \
common/xdg-app-chain-input-stream.c \

View File

@ -21,18 +21,18 @@
#include "config.h"
#include "xdg-app-error.h"
#include "xdg-app-portal-error.h"
#include <gio/gio.h>
static const GDBusErrorEntry xdg_app_error_entries[] = {
{XDG_APP_ERROR_FAILED, "org.freedesktop.XdgApp.Failed"},
{XDG_APP_ERROR_INVALID_ARGUMENT, "org.freedesktop.XdgApp.InvalidArgument"},
{XDG_APP_ERROR_NOT_FOUND, "org.freedesktop.XdgApp.NotFound"},
{XDG_APP_ERROR_EXISTS, "org.freedesktop.XdgApp.Exists"},
{XDG_APP_ERROR_NOT_ALLOWED, "org.freedesktop.XdgApp.NotAllowed"},
{XDG_APP_ERROR_CANCELLED, "org.freedesktop.XdgApp.Cancelled"},
{XDG_APP_ERROR_WINDOW_DESTROYED, "org.freedesktop.XdgApp.WindowDestroyed"},
{XDG_APP_PORTAL_ERROR_FAILED, "org.freedesktop.XdgApp.Failed"},
{XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT, "org.freedesktop.XdgApp.InvalidArgument"},
{XDG_APP_PORTAL_ERROR_NOT_FOUND, "org.freedesktop.XdgApp.NotFound"},
{XDG_APP_PORTAL_ERROR_EXISTS, "org.freedesktop.XdgApp.Exists"},
{XDG_APP_PORTAL_ERROR_NOT_ALLOWED, "org.freedesktop.XdgApp.NotAllowed"},
{XDG_APP_PORTAL_ERROR_CANCELLED, "org.freedesktop.XdgApp.Cancelled"},
{XDG_APP_PORTAL_ERROR_WINDOW_DESTROYED, "org.freedesktop.XdgApp.WindowDestroyed"},
};
GQuark

View File

@ -19,8 +19,8 @@
* Alexander Larsson <alexl@redhat.com>
*/
#ifndef XDG_APP_ERROR_H
#define XDG_APP_ERROR_H
#ifndef XDG_APP_PORTAL_ERROR_H
#define XDG_APP_PORTAL_ERROR_H
#include <glib.h>
@ -30,20 +30,20 @@ G_BEGIN_DECLS
* XdpErrorEnum:
*/
typedef enum {
XDG_APP_ERROR_FAILED = 0,
XDG_APP_ERROR_INVALID_ARGUMENT,
XDG_APP_ERROR_NOT_FOUND,
XDG_APP_ERROR_EXISTS,
XDG_APP_ERROR_NOT_ALLOWED,
XDG_APP_ERROR_CANCELLED,
XDG_APP_ERROR_WINDOW_DESTROYED,
XDG_APP_PORTAL_ERROR_FAILED = 0,
XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
XDG_APP_PORTAL_ERROR_NOT_FOUND,
XDG_APP_PORTAL_ERROR_EXISTS,
XDG_APP_PORTAL_ERROR_NOT_ALLOWED,
XDG_APP_PORTAL_ERROR_CANCELLED,
XDG_APP_PORTAL_ERROR_WINDOW_DESTROYED,
} XdgAppErrorEnum;
#define XDG_APP_ERROR xdg_app_error_quark()
#define XDG_APP_PORTAL_ERROR xdg_app_error_quark()
GQuark xdg_app_error_quark (void);
G_END_DECLS
#endif /* XDG_APP_ERROR_H */
#endif /* XDG_APP_PORTAL_ERROR_H */

View File

@ -22,7 +22,7 @@
#include "xdg-app-utils.h"
#include "xdg-app-dir.h"
#include "xdg-app-error.h"
#include "xdg-app-portal-error.h"
#include <string.h>
#include <stdlib.h>
@ -874,7 +874,7 @@ got_credentials_cb (GObject *source_object,
GTask *task = l->data;
if (info->app_id == NULL)
g_task_return_new_error (task, XDG_APP_ERROR, XDG_APP_ERROR_FAILED,
g_task_return_new_error (task, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_FAILED,
"Can't find app id");
else
g_task_return_pointer (task, g_strdup (info->app_id), g_free);

View File

@ -15,7 +15,7 @@
#include <gio/gio.h>
#include <pthread.h>
#include "xdg-app-error.h"
#include "xdg-app-portal-error.h"
#include "xdp-fuse.h"
#include "xdp-util.h"
#include "xdg-app-utils.h"
@ -2206,7 +2206,7 @@ xdp_fuse_init (GError **error)
if (g_mkdir_with_parents (mount_path, 0700))
{
g_set_error (error, XDG_APP_ERROR, XDG_APP_ERROR_FAILED,
g_set_error (error, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_FAILED,
"Unable to create dir %s\n", mount_path);
return FALSE;
}
@ -2214,7 +2214,7 @@ xdp_fuse_init (GError **error)
main_ch = fuse_mount (mount_path, &args);
if (main_ch == NULL)
{
g_set_error (error, XDG_APP_ERROR, XDG_APP_ERROR_FAILED, "Can't mount fuse fs");
g_set_error (error, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_FAILED, "Can't mount fuse fs");
return FALSE;
}
@ -2222,7 +2222,7 @@ xdp_fuse_init (GError **error)
sizeof (xdp_fuse_oper), NULL);
if (session == NULL)
{
g_set_error (error, XDG_APP_ERROR, XDG_APP_ERROR_FAILED,
g_set_error (error, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_FAILED,
"Can't create fuse session");
return FALSE;
}

View File

@ -16,7 +16,7 @@
#include "xdg-app-db.h"
#include "xdg-app-dbus.h"
#include "xdg-app-utils.h"
#include "xdg-app-error.h"
#include "xdg-app-portal-error.h"
#include "xdp-fuse.h"
#include <sys/eventfd.h>
@ -139,14 +139,14 @@ portal_grant_permissions (GDBusMethodInvocation *invocation,
entry = xdg_app_db_lookup (db, id);
if (entry == NULL)
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_ERROR, XDG_APP_ERROR_NOT_FOUND,
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_FOUND,
"No such document: %s", id);
return;
}
if (!xdg_app_is_valid_name (target_app_id))
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_ERROR, XDG_APP_ERROR_INVALID_ARGUMENT,
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
"Invalid app name: %s", target_app_id);
return;
}
@ -157,7 +157,7 @@ portal_grant_permissions (GDBusMethodInvocation *invocation,
if (!xdp_entry_has_permissions (entry, app_id,
XDP_PERMISSION_FLAGS_GRANT_PERMISSIONS | perms))
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_ERROR, XDG_APP_ERROR_NOT_ALLOWED,
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_ALLOWED,
"Not enough permissions");
return;
}
@ -186,14 +186,14 @@ portal_revoke_permissions (GDBusMethodInvocation *invocation,
entry = xdg_app_db_lookup (db, id);
if (entry == NULL)
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_ERROR, XDG_APP_ERROR_NOT_FOUND,
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_FOUND,
"No such document: %s", id);
return;
}
if (!xdg_app_is_valid_name (target_app_id))
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_ERROR, XDG_APP_ERROR_INVALID_ARGUMENT,
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
"Invalid app name: %s", target_app_id);
return;
}
@ -205,7 +205,7 @@ portal_revoke_permissions (GDBusMethodInvocation *invocation,
XDP_PERMISSION_FLAGS_GRANT_PERMISSIONS) ||
strcmp (app_id, target_app_id) == 0)
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_ERROR, XDG_APP_ERROR_NOT_ALLOWED,
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_ALLOWED,
"Not enough permissions");
return;
}
@ -233,14 +233,14 @@ portal_delete (GDBusMethodInvocation *invocation,
entry = xdg_app_db_lookup (db, id);
if (entry == NULL)
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_ERROR, XDG_APP_ERROR_NOT_FOUND,
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_FOUND,
"No such document: %s", id);
return;
}
if (!xdp_entry_has_permissions (entry, app_id, XDP_PERMISSION_FLAGS_DELETE))
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_ERROR, XDG_APP_ERROR_NOT_ALLOWED,
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_ALLOWED,
"Not enough permissions");
return;
}
@ -369,7 +369,7 @@ portal_add (GDBusMethodInvocation *invocation,
(symlink_size = readlink (proc_path, path_buffer, sizeof (path_buffer) - 1)) < 0)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_INVALID_ARGUMENT,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
"Invalid fd passed");
return;
}
@ -390,7 +390,7 @@ portal_add (GDBusMethodInvocation *invocation,
{
/* Don't leak any info about real file path existance, etc */
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_INVALID_ARGUMENT,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
"Invalid fd passed");
return;
}
@ -410,7 +410,7 @@ portal_add (GDBusMethodInvocation *invocation,
if (old_id == 0)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_INVALID_ARGUMENT,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
"Invalid fd passed");
return;
}
@ -426,7 +426,7 @@ portal_add (GDBusMethodInvocation *invocation,
!reuse_existing)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_INVALID_ARGUMENT,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
"Invalid fd passed");
return;
}
@ -482,7 +482,7 @@ portal_add_named (GDBusMethodInvocation *invocation,
/* This is only allowed from the host, or else we could leak existance of files */
if (*app_id != 0)
{
g_dbus_method_invocation_return_error (invocation, XDG_APP_ERROR, XDG_APP_ERROR_NOT_ALLOWED,
g_dbus_method_invocation_return_error (invocation, XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_ALLOWED,
"Not enough permissions");
return;
}
@ -501,7 +501,7 @@ portal_add_named (GDBusMethodInvocation *invocation,
if (strchr (filename, '/') != NULL)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_INVALID_ARGUMENT,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
"Invalid filename passed");
return;
}
@ -524,7 +524,7 @@ portal_add_named (GDBusMethodInvocation *invocation,
(symlink_size = readlink (proc_path, parent_path_buffer, sizeof (parent_path_buffer) - 1)) < 0)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_INVALID_ARGUMENT,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
"Invalid fd passed");
return;
}
@ -532,7 +532,7 @@ portal_add_named (GDBusMethodInvocation *invocation,
if (parent_st_buf.st_dev == fuse_dev)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_INVALID_ARGUMENT,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_INVALID_ARGUMENT,
"Invalid fd passed");
return;
}

View File

@ -2,7 +2,7 @@
#include <string.h>
#include <errno.h>
#include <gio/gio.h>
#include "xdg-app-error.h"
#include "xdg-app-portal-error.h"
#include "xdp-util.h"
const char **

View File

@ -24,7 +24,6 @@
#include "xdg-app-installed-ref.h"
#include "xdg-app-enum-types.h"
#include "xdg-app-error.h"
#include "xdg-app-utils.h"
#include "xdg-app-run.h"
#include "xdg-app-dir.h"
@ -195,7 +194,7 @@ xdg_app_installed_ref_load_metadata (XdgAppInstalledRef *self,
if (priv->deploy_dir == NULL)
{
g_set_error (error, XDG_APP_ERROR, XDG_APP_ERROR_NOT_FOUND,
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"Unknown deploy directory");
return NULL;
}

View File

@ -25,7 +25,6 @@
#include "xdg-app-remote-ref-private.h"
#include "xdg-app-remote-ref.h"
#include "xdg-app-enum-types.h"
#include "xdg-app-error.h"
typedef struct _XdgAppRemoteRefPrivate XdgAppRemoteRefPrivate;

View File

@ -26,7 +26,7 @@
#include <gio/gio.h>
#include "xdg-app-permission-store.h"
#include "xdg-app-db.h"
#include "xdg-app-error.h"
#include "xdg-app-portal-error.h"
GHashTable *tables = NULL;
@ -70,7 +70,7 @@ lookup_table (const char *name,
if (db == NULL)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_FAILED,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_FAILED,
"Unable to load db file: %s", error->message);
return NULL;
}
@ -105,7 +105,7 @@ writeout_done (GObject *source_object,
g_variant_new ("()"));
else
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_FAILED,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_FAILED,
"Unable to write db: %s", error->message);
}
@ -180,7 +180,7 @@ handle_lookup (XdgAppPermissionStore *object,
if (entry == NULL)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_NOT_FOUND,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_FOUND,
"No entry for %s", id);
return TRUE;
}
@ -224,7 +224,7 @@ handle_delete (XdgAppPermissionStore *object,
if (entry == NULL)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_NOT_FOUND,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_FOUND,
"No entry for %s", id);
return TRUE;
}
@ -260,7 +260,7 @@ handle_set (XdgAppPermissionStore *object,
if (old_entry == NULL && !create)
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_NOT_FOUND,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_FOUND,
"Id %s not found", id);
return TRUE;
}
@ -317,7 +317,7 @@ handle_set_permission (XdgAppPermissionStore *object,
else
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_NOT_FOUND,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_FOUND,
"Id %s not found", id);
return TRUE;
}
@ -355,7 +355,7 @@ handle_set_value (XdgAppPermissionStore *object,
else
{
g_dbus_method_invocation_return_error (invocation,
XDG_APP_ERROR, XDG_APP_ERROR_NOT_FOUND,
XDG_APP_PORTAL_ERROR, XDG_APP_PORTAL_ERROR_NOT_FOUND,
"Id %s not found", id);
return TRUE;
}