From c4e500db37b4b9fa9b354ee0076381f35c74aece Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 24 Aug 2015 17:00:27 +0200 Subject: [PATCH] Add XdgAppError --- lib/Makefile.am.inc | 2 ++ lib/xdg-app-error.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ lib/xdg-app-error.h | 47 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 lib/xdg-app-error.c create mode 100644 lib/xdg-app-error.h diff --git a/lib/Makefile.am.inc b/lib/Makefile.am.inc index 26d6ad0e..4f44dda6 100644 --- a/lib/Makefile.am.inc +++ b/lib/Makefile.am.inc @@ -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 \ diff --git a/lib/xdg-app-error.c b/lib/xdg-app-error.c new file mode 100644 index 00000000..da2c9919 --- /dev/null +++ b/lib/xdg-app-error.c @@ -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 . + * + * Authors: + * Alexander Larsson + */ + +#include "config.h" + +#include "xdg-app-error.h" + +#include + +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; +} diff --git a/lib/xdg-app-error.h b/lib/xdg-app-error.h new file mode 100644 index 00000000..87b502d5 --- /dev/null +++ b/lib/xdg-app-error.h @@ -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 . + * + * Authors: + * Alexander Larsson + */ + +#ifndef XDG_APP_ERROR_H +#define XDG_APP_ERROR_H + +#include + +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 */