[evolution-data-server/openismus-work-master] Pushing EBookClientError and associated functions down into libebook-contacts



commit 23edfadd3a86fe86feed33e3e21d2c1286da49f5
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Mon Jan 21 19:42:55 2013 +0900

    Pushing EBookClientError and associated functions down into libebook-contacts
    
    Because EBookClientErrors need to be reported from backends.

 addressbook/libebook-contacts/Makefile.am          |    3 +-
 .../libebook-contacts/e-book-contacts-types.c      |   86 ++++++++++++++++++++
 .../libebook-contacts/e-book-contacts-types.h      |   28 +++++++
 addressbook/libebook/e-book-client.c               |   57 -------------
 addressbook/libebook/e-book-client.h               |   29 -------
 5 files changed, 116 insertions(+), 87 deletions(-)
---
diff --git a/addressbook/libebook-contacts/Makefile.am b/addressbook/libebook-contacts/Makefile.am
index 01c3d33..28bffa7 100644
--- a/addressbook/libebook-contacts/Makefile.am
+++ b/addressbook/libebook-contacts/Makefile.am
@@ -32,9 +32,10 @@ libebook_contacts_1_2_la_CPPFLAGS = \
 	$(CODE_COVERAGE_CFLAGS)				\
 	$(NULL)
 
-libebook_contacts_1_2_la_SOURCES =				\
+libebook_contacts_1_2_la_SOURCES =			\
 	$(ENUM_GENERATED)				\
 	$(MARSHAL_GENERATED)				\
+	e-book-contacts-types.c				\
 	e-address-western.c				\
 	e-name-western.c				\
 	e-name-western-tables.h                         \
diff --git a/addressbook/libebook-contacts/e-book-contacts-types.c b/addressbook/libebook-contacts/e-book-contacts-types.c
new file mode 100644
index 0000000..d558a6b
--- /dev/null
+++ b/addressbook/libebook-contacts/e-book-contacts-types.c
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/* e-book-contacts-types.c - Some helper functions for contact types.
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * This program 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) version 3.
+ *
+ * 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ * Authors: Tristan Van Berkom <tristanvb openismus com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib/gi18n-lib.h>
+
+#include "e-book-contacts-types.h"
+
+GQuark
+e_book_client_error_quark (void)
+{
+	static GQuark q = 0;
+	if (q == 0)
+		q = g_quark_from_static_string ("e-book-client-error-quark");
+
+	return q;
+}
+
+/**
+ * e_book_client_error_to_string:
+ *
+ * FIXME: Document me.
+ *
+ * Since: 3.2
+ **/
+const gchar *
+e_book_client_error_to_string (EBookClientError code)
+{
+	switch (code) {
+	case E_BOOK_CLIENT_ERROR_NO_SUCH_BOOK:
+		return _("No such book");
+	case E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND:
+		return _("Contact not found");
+	case E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS:
+		return _("Contact ID already exists");
+	case E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE:
+		return _("No such source");
+	case E_BOOK_CLIENT_ERROR_NO_SPACE:
+		return _("No space");
+	}
+
+	return _("Unknown error");
+}
+
+/**
+ * e_book_client_error_create:
+ * @code: an #EBookClientError code to create
+ * @custom_msg: custom message to use for the error; can be %NULL
+ *
+ * Returns: a new #GError containing an E_BOOK_CLIENT_ERROR of the given
+ * @code. If the @custom_msg is NULL, then the error message is
+ * the one returned from e_book_client_error_to_string() for the @code,
+ * otherwise the given message is used.
+ *
+ * Returned pointer should be freed with g_error_free().
+ *
+ * Since: 3.2
+ **/
+GError *
+e_book_client_error_create (EBookClientError code,
+                            const gchar *custom_msg)
+{
+	return g_error_new_literal (E_BOOK_CLIENT_ERROR, code, custom_msg ? custom_msg : e_book_client_error_to_string (code));
+}
diff --git a/addressbook/libebook-contacts/e-book-contacts-types.h b/addressbook/libebook-contacts/e-book-contacts-types.h
index 55f1258..2b6db76 100644
--- a/addressbook/libebook-contacts/e-book-contacts-types.h
+++ b/addressbook/libebook-contacts/e-book-contacts-types.h
@@ -18,6 +18,15 @@
 
 #include <libebook-contacts/e-contact.h>
 
+/**
+ * E_BOOK_CLIENT_ERROR:
+ *
+ * FIXME: Document me.
+ *
+ * Since: 3.2
+ **/
+#define E_BOOK_CLIENT_ERROR e_book_client_error_quark ()
+
 G_BEGIN_DECLS
 
 /**
@@ -94,6 +103,20 @@ typedef struct {
 	EContact        *contact;
 } EBookChange;
 
+/**
+ * EBookClientError:
+ *
+ * FIXME: Document me.
+ *
+ * Since: 3.2
+ **/
+typedef enum {
+	E_BOOK_CLIENT_ERROR_NO_SUCH_BOOK,
+	E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND,
+	E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS,
+	E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE,
+	E_BOOK_CLIENT_ERROR_NO_SPACE
+} EBookClientError;
 
 /**
  * EBookIndexType:
@@ -107,6 +130,11 @@ typedef enum {
 	E_BOOK_INDEX_SUFFIX
 } EBookIndexType;
 
+GQuark		e_book_client_error_quark	(void) G_GNUC_CONST;
+const gchar *	e_book_client_error_to_string	(EBookClientError code);
+GError *	e_book_client_error_create	(EBookClientError code,
+						 const gchar *custom_msg);
+
 G_END_DECLS
 
 #endif /* __E_BOOK_CONTACTS_TYPES_H__ */
diff --git a/addressbook/libebook/e-book-client.c b/addressbook/libebook/e-book-client.c
index 3d7a949..ed7617b 100644
--- a/addressbook/libebook/e-book-client.c
+++ b/addressbook/libebook/e-book-client.c
@@ -68,63 +68,6 @@ G_DEFINE_TYPE (EBookClient, e_book_client, E_TYPE_CLIENT)
  *   @CLIENT_BACKEND_PROPERTY_CACHE_DIR, @CLIENT_BACKEND_PROPERTY_CAPABILITIES
  */
 
-GQuark
-e_book_client_error_quark (void)
-{
-	static GQuark q = 0;
-	if (q == 0)
-		q = g_quark_from_static_string ("e-book-client-error-quark");
-
-	return q;
-}
-
-/**
- * e_book_client_error_to_string:
- *
- * FIXME: Document me.
- *
- * Since: 3.2
- **/
-const gchar *
-e_book_client_error_to_string (EBookClientError code)
-{
-	switch (code) {
-	case E_BOOK_CLIENT_ERROR_NO_SUCH_BOOK:
-		return _("No such book");
-	case E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND:
-		return _("Contact not found");
-	case E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS:
-		return _("Contact ID already exists");
-	case E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE:
-		return _("No such source");
-	case E_BOOK_CLIENT_ERROR_NO_SPACE:
-		return _("No space");
-	}
-
-	return _("Unknown error");
-}
-
-/**
- * e_book_client_error_create:
- * @code: an #EBookClientError code to create
- * @custom_msg: custom message to use for the error; can be %NULL
- *
- * Returns: a new #GError containing an E_BOOK_CLIENT_ERROR of the given
- * @code. If the @custom_msg is NULL, then the error message is
- * the one returned from e_book_client_error_to_string() for the @code,
- * otherwise the given message is used.
- *
- * Returned pointer should be freed with g_error_free().
- *
- * Since: 3.2
- **/
-GError *
-e_book_client_error_create (EBookClientError code,
-                            const gchar *custom_msg)
-{
-	return g_error_new_literal (E_BOOK_CLIENT_ERROR, code, custom_msg ? custom_msg : e_book_client_error_to_string (code));
-}
-
 /*
  * If the specified GError is a remote error, then create a new error
  * representing the remote error.  If the error is anything else, then
diff --git a/addressbook/libebook/e-book-client.h b/addressbook/libebook/e-book-client.h
index 085fbf3..79ec010 100644
--- a/addressbook/libebook/e-book-client.h
+++ b/addressbook/libebook/e-book-client.h
@@ -68,32 +68,8 @@
  **/
 #define BOOK_BACKEND_PROPERTY_SUPPORTED_FIELDS		"supported-fields"
 
-/**
- * E_BOOK_CLIENT_ERROR:
- *
- * FIXME: Document me.
- *
- * Since: 3.2
- **/
-#define E_BOOK_CLIENT_ERROR e_book_client_error_quark ()
-
 G_BEGIN_DECLS
 
-/**
- * EBookClientError:
- *
- * FIXME: Document me.
- *
- * Since: 3.2
- **/
-typedef enum {
-	E_BOOK_CLIENT_ERROR_NO_SUCH_BOOK,
-	E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND,
-	E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS,
-	E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE,
-	E_BOOK_CLIENT_ERROR_NO_SPACE
-} EBookClientError;
-
 typedef struct _EBookClient        EBookClient;
 typedef struct _EBookClientClass   EBookClientClass;
 typedef struct _EBookClientPrivate EBookClientPrivate;
@@ -115,11 +91,6 @@ struct _EBookClientClass {
 	EClientClass parent_class;
 };
 
-GQuark		e_book_client_error_quark	(void) G_GNUC_CONST;
-const gchar *	e_book_client_error_to_string	(EBookClientError code);
-GError *	e_book_client_error_create	(EBookClientError code,
-						 const gchar *custom_msg);
-
 GType		e_book_client_get_type		(void) G_GNUC_CONST;
 EBookClient *	e_book_client_new		(ESource *source,
 						 GError **error);



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