diff --git a/src/Makefile.am b/src/Makefile.am index ae87b491d..87fe41074 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,6 +24,8 @@ AM_CPPFLAGS = \ bin_PROGRAMS = fwupdmgr fwupdmgr_SOURCES = \ + fu-common.c \ + fu-common.h \ fu-device.c \ fu-device.h \ fu-util.c @@ -61,6 +63,7 @@ libexec_PROGRAMS = \ fwupd_SOURCES = \ fu-cleanup.h \ + fu-common.c \ fu-common.h \ fu-debug.c \ fu-debug.h \ diff --git a/src/fu-common.c b/src/fu-common.c new file mode 100644 index 000000000..6364a6a63 --- /dev/null +++ b/src/fu-common.c @@ -0,0 +1,47 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2015 Richard Hughes + * + * Licensed under the GNU General Public License Version 2 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#include +#include + +#include "fu-common.h" + +/** + * fu_error_quark: + * + * Return value: An error quark. + * + * Since: 0.1.0 + **/ +GQuark +fu_error_quark (void) +{ + static GQuark quark = 0; + if (!quark) { + quark = g_quark_from_static_string ("FuError"); + g_dbus_error_register_error (quark, + FU_ERROR_INTERNAL, + "org.freedesktop.fwupd.InternalError"); + } + return quark; +} diff --git a/src/fu-common.h b/src/fu-common.h index fac2dc7a5..70abc6188 100644 --- a/src/fu-common.h +++ b/src/fu-common.h @@ -26,12 +26,19 @@ #define FWUPD_DBUS_SERVICE "org.freedesktop.fwupd" #define FWUPD_DBUS_INTERFACE "org.freedesktop.fwupd" -#define FU_ERROR 1 -#define FU_ERROR_INTERNAL 0 +#define FU_ERROR fu_error_quark() #define FU_DEVICE_KEY_VERSION "Version" #define FU_DEVICE_KEY_PROVIDER "Provider" #define FU_DEVICE_KEY_GUID "Guid" #define FU_DEVICE_KEY_ONLY_OFFLINE "OnlyOffline" +typedef enum { + FU_ERROR_INTERNAL, + /* private */ + FU_ERROR_LAST +} FuError; + +GQuark fu_error_quark (void); + #endif /* __FU_COMMON_H */ diff --git a/src/fu-util.c b/src/fu-util.c index 355dd3dc5..104fe80da 100644 --- a/src/fu-util.c +++ b/src/fu-util.c @@ -33,7 +33,6 @@ #include "fu-common.h" #include "fu-provider.h" -#define FU_ERROR 1 #define FU_ERROR_INVALID_ARGUMENTS 0 #define FU_ERROR_NO_SUCH_CMD 1