5c5f64e25183aadcd6569ca4cae6fb9327d2b785
[platform/upstream/evolution-data-server.git] / addressbook / libebook-contacts / e-book-contacts-types.c
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
4
5 #include <glib/gi18n-lib.h>
6
7 #include "e-book-contacts-types.h"
8
9 G_DEFINE_QUARK (e-book-client-error-quark, e_book_client_error)
10
11 /**
12  * e_book_client_error_to_string:
13  *
14  * FIXME: Document me.
15  *
16  * Since: 3.2
17  **/
18 const gchar *
19 e_book_client_error_to_string (EBookClientError code)
20 {
21         switch (code) {
22         case E_BOOK_CLIENT_ERROR_NO_SUCH_BOOK:
23                 return _("No such book");
24         case E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND:
25                 return _("Contact not found");
26         case E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS:
27                 return _("Contact ID already exists");
28         case E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE:
29                 return _("No such source");
30         case E_BOOK_CLIENT_ERROR_NO_SPACE:
31                 return _("No space");
32         }
33
34         return _("Unknown error");
35 }
36
37 /**
38  * e_book_client_error_create:
39  * @code: an #EBookClientError code to create
40  * @custom_msg: custom message to use for the error; can be %NULL
41  *
42  * Returns: a new #GError containing an E_BOOK_CLIENT_ERROR of the given
43  * @code. If the @custom_msg is NULL, then the error message is
44  * the one returned from e_book_client_error_to_string() for the @code,
45  * otherwise the given message is used.
46  *
47  * Returned pointer should be freed with g_error_free().
48  *
49  * Since: 3.2
50  *
51  * Deprecated: 3.8: Just use the #GError API directly.
52  **/
53 GError *
54 e_book_client_error_create (EBookClientError code,
55                             const gchar *custom_msg)
56 {
57         return g_error_new_literal (E_BOOK_CLIENT_ERROR, code, custom_msg ? custom_msg : e_book_client_error_to_string (code));
58 }