Add XdgAppError

This commit is contained in:
Alexander Larsson
2015-08-24 17:00:27 +02:00
parent de004081ef
commit c4e500db37
3 changed files with 95 additions and 0 deletions

View File

@@ -25,6 +25,8 @@ libxdgapp_la_SOURCES = \
lib/xdg-app-dir.h \
lib/xdg-app-run.c \
lib/xdg-app-run.h \
lib/xdg-app-error.c \
lib/xdg-app-error.h \
lib/xdg-app-utils.c \
lib/xdg-app-utils.h \
lib/gvdb/gvdb-reader.c \

46
lib/xdg-app-error.c Normal file
View File

@@ -0,0 +1,46 @@
/* xdg-app-error.c
*
* Copyright (C) 2015 Red Hat, Inc
*
* This file is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Alexander Larsson <alexl@redhat.com>
*/
#include "config.h"
#include "xdg-app-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"},
};
GQuark
xdg_app_error_quark (void)
{
static volatile gsize quark_volatile = 0;
g_dbus_error_register_error_domain ("xdg-app--error-quark",
&quark_volatile,
xdg_app_error_entries,
G_N_ELEMENTS (xdg_app_error_entries));
return (GQuark) quark_volatile;
}

47
lib/xdg-app-error.h Normal file
View File

@@ -0,0 +1,47 @@
/* xdg-app-error.c
*
* Copyright (C) 2015 Red Hat, Inc
*
* This file is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Authors:
* Alexander Larsson <alexl@redhat.com>
*/
#ifndef XDG_APP_ERROR_H
#define XDG_APP_ERROR_H
#include <glib.h>
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,
} XdpErrorEnum;
#define XDG_APP_ERROR xdg_app_error_quark()
GQuark xdg_app_error_quark (void);
G_END_DECLS
#endif /* XDG_APP_ERROR_H */