[gnome-online-accounts] identity: Register the GOA_IDENTITY_MANAGER_ERROR domain with D-Bus



commit 9518aa91a275d4c4714dc1bed67377e82cc2e872
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue May 30 19:59:26 2017 +0200

    identity: Register the GOA_IDENTITY_MANAGER_ERROR domain with D-Bus
    
    This will enable proper marshalling of these errors across D-Bus so
    that users of the org.gnome.Identity D-Bus API can detect them.
    
    The error codes and domain definition were separated out so that
    org.gnome.Identity users can link against them without pulling in too
    many needless dependencies.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=686131

 src/goaidentity/Makefile.am                  |    2 +
 src/goaidentity/goaidentitymanager.c         |   11 ------
 src/goaidentity/goaidentitymanager.h         |   12 +------
 src/goaidentity/goaidentitymanagererror.c    |   44 ++++++++++++++++++++++++++
 src/goaidentity/goaidentitymanagererror.h    |   43 +++++++++++++++++++++++++
 src/goaidentity/goaidentityservice.c         |    1 +
 src/goaidentity/goakerberosidentitymanager.c |    1 +
 7 files changed, 92 insertions(+), 22 deletions(-)
---
diff --git a/src/goaidentity/Makefile.am b/src/goaidentity/Makefile.am
index 537287a..0187b2e 100644
--- a/src/goaidentity/Makefile.am
+++ b/src/goaidentity/Makefile.am
@@ -30,6 +30,7 @@ identity_headers =                                            \
        goaidentityservice.h                                    \
        goaidentitymanagerprivate.h                             \
        goaidentitymanager.h                                    \
+       goaidentitymanagererror.h                               \
        goaidentityutils.h                                      \
        goakerberosidentity.h                                   \
        goakerberosidentityinquiry.h                            \
@@ -43,6 +44,7 @@ identity_sources =                                            \
        goaidentityinquiry.c                                    \
        goaidentityservice.c                                    \
        goaidentitymanager.c                                    \
+       goaidentitymanagererror.c                               \
        goaidentityutils.c                                      \
        goakerberosidentity.c                                   \
        goakerberosidentityinquiry.c                            \
diff --git a/src/goaidentity/goaidentitymanager.c b/src/goaidentity/goaidentitymanager.c
index 94ef7af..0825356 100644
--- a/src/goaidentity/goaidentitymanager.c
+++ b/src/goaidentity/goaidentitymanager.c
@@ -119,17 +119,6 @@ goa_identity_manager_default_init (GoaIdentityManagerInterface *interface)
                                             GOA_TYPE_IDENTITY);
 }
 
-GQuark
-goa_identity_manager_error_quark (void)
-{
-  static GQuark error_quark = 0;
-
-  if (error_quark == 0)
-    error_quark = g_quark_from_static_string ("goa-identity-manager-error");
-
-  return error_quark;
-}
-
 void
 goa_identity_manager_get_identity (GoaIdentityManager  *self,
                                    const char          *identifier,
diff --git a/src/goaidentity/goaidentitymanager.h b/src/goaidentity/goaidentitymanager.h
index ffa5923..415f424 100644
--- a/src/goaidentity/goaidentitymanager.h
+++ b/src/goaidentity/goaidentitymanager.h
@@ -32,7 +32,7 @@ G_BEGIN_DECLS
 #define GOA_IDENTITY_MANAGER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GOA_TYPE_IDENTITY_MANAGER, 
GoaIdentityManagerInterface))
 #define GOA_IS_IDENTITY_MANAGER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOA_TYPE_IDENTITY_MANAGER))
 #define GOA_IDENTITY_MANAGER_GET_IFACE(obj)   (G_TYPE_INSTANCE_GET_INTERFACE((obj), 
GOA_TYPE_IDENTITY_MANAGER, GoaIdentityManagerInterface))
-#define GOA_IDENTITY_MANAGER_ERROR            (goa_identity_manager_error_quark ())
+
 typedef struct _GoaIdentityManager GoaIdentityManager;
 typedef struct _GoaIdentityManagerInterface GoaIdentityManagerInterface;
 
@@ -110,17 +110,7 @@ struct _GoaIdentityManagerInterface
                             GoaIdentity        *identity);
 };
 
-typedef enum
-{
-  GOA_IDENTITY_MANAGER_ERROR_INITIALIZING,
-  GOA_IDENTITY_MANAGER_ERROR_IDENTITY_NOT_FOUND,
-  GOA_IDENTITY_MANAGER_ERROR_CREATING_IDENTITY,
-  GOA_IDENTITY_MANAGER_ERROR_ACCESSING_CREDENTIALS,
-  GOA_IDENTITY_MANAGER_ERROR_UNSUPPORTED_CREDENTIALS
-} GoaIdentityManagerError;
-
 GType  goa_identity_manager_get_type    (void);
-GQuark goa_identity_manager_error_quark (void);
 
 void goa_identity_manager_get_identity (GoaIdentityManager  *identity_manager,
                                         const char          *identifier,
diff --git a/src/goaidentity/goaidentitymanagererror.c b/src/goaidentity/goaidentitymanagererror.c
new file mode 100644
index 0000000..28150c1
--- /dev/null
+++ b/src/goaidentity/goaidentitymanagererror.c
@@ -0,0 +1,44 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/*
+ * Copyright © 2017 Red Hat, Inc.
+ *
+ * This library 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 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 Lesser General
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gio/gio.h>
+
+#include "goaidentitymanagererror.h"
+
+static const GDBusErrorEntry dbus_error_entries[] =
+{
+  {GOA_IDENTITY_MANAGER_ERROR_INITIALIZING,             "org.gnome.Identity.Manager.Error.Initializing"},
+  {GOA_IDENTITY_MANAGER_ERROR_IDENTITY_NOT_FOUND,       "org.gnome.Identity.Manager.Error.IdentityNotFound"},
+  {GOA_IDENTITY_MANAGER_ERROR_CREATING_IDENTITY,        "org.gnome.Identity.Manager.Error.CreatingIdentity"},
+  {GOA_IDENTITY_MANAGER_ERROR_ACCESSING_CREDENTIALS,    
"org.gnome.Identity.Manager.Error.AccessingCredentials"},
+  {GOA_IDENTITY_MANAGER_ERROR_UNSUPPORTED_CREDENTIALS,  
"org.gnome.Identity.Manager.Error.UnsupportedCredentials"}
+};
+
+GQuark
+goa_identity_manager_error_quark (void)
+{
+  G_STATIC_ASSERT (G_N_ELEMENTS (dbus_error_entries) == GOA_IDENTITY_MANAGER_ERROR_NUM_ENTRIES);
+  static volatile gsize quark_volatile = 0;
+  g_dbus_error_register_error_domain ("goa-identity-manager-error",
+                                      &quark_volatile,
+                                      dbus_error_entries,
+                                      G_N_ELEMENTS (dbus_error_entries));
+  return (GQuark) quark_volatile;
+}
diff --git a/src/goaidentity/goaidentitymanagererror.h b/src/goaidentity/goaidentitymanagererror.h
new file mode 100644
index 0000000..4238648
--- /dev/null
+++ b/src/goaidentity/goaidentitymanagererror.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
+ *
+ * Copyright © 2017 Red Hat, Inc.
+ *
+ * This library 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 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 Lesser General
+ * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GOA_IDENTITY_MANAGER_ERROR_H__
+#define __GOA_IDENTITY_MANAGER_ERROR_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+#define GOA_IDENTITY_MANAGER_ERROR (goa_identity_manager_error_quark ())
+
+#define GOA_IDENTITY_MANAGER_ERROR_NUM_ENTRIES (GOA_IDENTITY_MANAGER_ERROR_UNSUPPORTED_CREDENTIALS + 1)
+
+typedef enum
+{
+  GOA_IDENTITY_MANAGER_ERROR_INITIALIZING,           /* org.gnome.Identity.Manager.Error.Initializing */
+  GOA_IDENTITY_MANAGER_ERROR_IDENTITY_NOT_FOUND,     /* org.gnome.Identity.Manager.Error.IdentityNotFound */
+  GOA_IDENTITY_MANAGER_ERROR_CREATING_IDENTITY,      /* org.gnome.Identity.Manager.Error.CreatingIdentity */
+  GOA_IDENTITY_MANAGER_ERROR_ACCESSING_CREDENTIALS,  /* 
org.gnome.Identity.Manager.Error.AccessingCredentials */
+  GOA_IDENTITY_MANAGER_ERROR_UNSUPPORTED_CREDENTIALS /* 
org.gnome.Identity.Manager.Error.UnsupportedCredentials */
+} GoaIdentityManagerError;
+
+GQuark goa_identity_manager_error_quark (void);
+
+G_END_DECLS
+
+#endif /* __GOA_IDENTITY_MANAGER_ERROR_H__ */
diff --git a/src/goaidentity/goaidentityservice.c b/src/goaidentity/goaidentityservice.c
index 4e55184..b0ec13d 100644
--- a/src/goaidentity/goaidentityservice.c
+++ b/src/goaidentity/goaidentityservice.c
@@ -31,6 +31,7 @@
 #include <goa/goa.h>
 
 #include "goaidentityenumtypes.h"
+#include "goaidentitymanagererror.h"
 #include "goaidentityutils.h"
 
 #include "goakerberosidentitymanager.h"
diff --git a/src/goaidentity/goakerberosidentitymanager.c b/src/goaidentity/goakerberosidentitymanager.c
index 0a5eca2..bf7cb7b 100644
--- a/src/goaidentity/goakerberosidentitymanager.c
+++ b/src/goaidentity/goakerberosidentitymanager.c
@@ -20,6 +20,7 @@
 
 #include "goakerberosidentitymanager.h"
 #include "goaidentitymanager.h"
+#include "goaidentitymanagererror.h"
 #include "goaidentitymanagerprivate.h"
 #include "goakerberosidentityinquiry.h"
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]