if (priv->gdbus_bookview) {
GError *local_error = NULL;
- if (e_gdbus_book_view_call_start_sync (priv->gdbus_bookview, NULL, &local_error))
- priv->running = TRUE;
+ priv->running = TRUE;
+ if (!e_gdbus_book_view_call_start_sync (priv->gdbus_bookview, NULL, &local_error))
+ priv->running = FALSE;
- e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+ e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
} else {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot start view, D-Bus proxy gone"));
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot start view, D-Bus proxy gone"));
}
}
e_gdbus_book_view_call_stop_sync (priv->gdbus_bookview, NULL, &local_error);
- e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+ e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
} else {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot stop view, D-Bus proxy gone"));
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot stop view, D-Bus proxy gone"));
}
}
e_gdbus_book_view_call_set_fields_of_interest_sync (priv->gdbus_bookview, (const gchar * const *) strv, NULL, &local_error);
g_strfreev (strv);
- e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+ e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
} else {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot set fields of interest, D-Bus proxy gone"));
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot set fields of interest, D-Bus proxy gone"));
}
}
void (* objects_modified) (EBookClientView *view, const GSList *objects);
void (* objects_removed) (EBookClientView *view, const GSList *uids);
- void (* progress) (EBookClientView *view, const gchar *message);
+ void (* progress) (EBookClientView *view, guint percent, const gchar *message);
void (* complete) (EBookClientView *view, const GError *error);
};
return C_("BookClientError", "Contact not found");
case E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS:
return C_("BookClientError", "Contact ID already exists");
- case E_BOOK_CLIENT_ERROR_TLS_NOT_AVAILABLE:
- return C_("BookClientError", "TLS not available");
case E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE:
return C_("BookClientError", "No such source");
- case E_BOOK_CLIENT_ERROR_OFFLINE_UNAVAILABLE:
- return C_("BookClientError", "Offline unavailable");
- case E_BOOK_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD:
- return C_("BookClientError", "Unsupported authentication method");
case E_BOOK_CLIENT_ERROR_NO_SPACE:
return C_("BookClientError", "No space");
}
}
/**
+ * 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().
+ **/
+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
* leave it alone.
{ err ("Success", -1) },
{ err ("ContactNotFound", E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND) },
{ err ("ContactIDAlreadyExists", E_BOOK_CLIENT_ERROR_CONTACT_ID_ALREADY_EXISTS) },
- { err ("UnsupportedAuthenticationMethod", E_BOOK_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD) },
- { err ("TLSNotAvailable", E_BOOK_CLIENT_ERROR_TLS_NOT_AVAILABLE) },
{ err ("NoSuchBook", E_BOOK_CLIENT_ERROR_NO_SUCH_BOOK) },
{ err ("BookRemoved", E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE) },
- { err ("OfflineUnavailable", E_BOOK_CLIENT_ERROR_OFFLINE_UNAVAILABLE) },
{ err ("NoSpace", E_BOOK_CLIENT_ERROR_NO_SPACE) }
}, cl_errors[] = {
{ err ("Busy", E_CLIENT_ERROR_BUSY) },
{ err ("RepositoryOffline", E_CLIENT_ERROR_REPOSITORY_OFFLINE) },
+ { err ("OfflineUnavailable", E_CLIENT_ERROR_OFFLINE_UNAVAILABLE) },
{ err ("PermissionDenied", E_CLIENT_ERROR_PERMISSION_DENIED) },
{ err ("AuthenticationFailed", E_CLIENT_ERROR_AUTHENTICATION_FAILED) },
{ err ("AuthenticationRequired", E_CLIENT_ERROR_AUTHENTICATION_REQUIRED) },
{ err ("CouldNotCancel", E_CLIENT_ERROR_COULD_NOT_CANCEL) },
{ err ("InvalidArg", E_CLIENT_ERROR_INVALID_ARG) },
{ err ("NotSupported", E_CLIENT_ERROR_NOT_SUPPORTED) },
+ { err ("UnsupportedAuthenticationMethod", E_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD) },
+ { err ("TLSNotAvailable", E_CLIENT_ERROR_TLS_NOT_AVAILABLE) },
+ { err ("SearchSizeLimitExceeded", E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED) },
+ { err ("SearchTimeLimitExceeded", E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED) },
+ { err ("InvalidQuery", E_CLIENT_ERROR_INVALID_QUERY) },
+ { err ("QueryRefused", E_CLIENT_ERROR_QUERY_REFUSED) },
{ err ("UnsupportedField", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("SearchSizeLimitExceeded", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("SearchTimeLimitExceeded", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("InvalidQuery", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("QueryRefused", E_CLIENT_ERROR_OTHER_ERROR) },
{ err ("InvalidServerVersion", E_CLIENT_ERROR_OTHER_ERROR) },
{ err ("OtherError", E_CLIENT_ERROR_OTHER_ERROR) }
};
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_TLS_NOT_AVAILABLE,
E_BOOK_CLIENT_ERROR_NO_SUCH_SOURCE,
- E_BOOK_CLIENT_ERROR_OFFLINE_UNAVAILABLE,
- E_BOOK_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD,
E_BOOK_CLIENT_ERROR_NO_SPACE
} EBookClientError;
-const gchar *e_book_client_error_to_string (EBookClientError code);
+const gchar * e_book_client_error_to_string (EBookClientError code);
+GError * e_book_client_error_create (EBookClientError code, const gchar *custom_msg);
typedef struct _EBookClient EBookClient;
typedef struct _EBookClientClass EBookClientClass;
void e_book_query_unref (EBookQuery *q);
EBookQuery* e_book_query_and (gint nqs, EBookQuery **qs, gboolean unref);
-EBookQuery* e_book_query_andv (EBookQuery *q, ...);
+EBookQuery* e_book_query_andv (EBookQuery *q, ...) G_GNUC_NULL_TERMINATED;
EBookQuery* e_book_query_or (gint nqs, EBookQuery **qs, gboolean unref);
-EBookQuery* e_book_query_orv (EBookQuery *q, ...);
+EBookQuery* e_book_query_orv (EBookQuery *q, ...) G_GNUC_NULL_TERMINATED;
EBookQuery* e_book_query_not (EBookQuery *q, gboolean unref);
#include "e-book-client.h"
#include "e-book-view.h"
+G_BEGIN_DECLS
+
+#ifndef E_BOOK_DISABLE_DEPRECATED
struct _EGdbusBookView;
EBookView *_e_book_view_new (EBook *book, struct _EGdbusBookView *gdbus_bookview);
+#endif /* E_BOOK_DISABLE_DEPRECATED */
+
G_END_DECLS
#endif /* __E_BOOK_VIEW_PRIVATE_H__ */
#include "libedata-book/e-data-book-types.h"
#include "e-gdbus-book-view.h"
+#ifndef E_BOOK_DISABLE_DEPRECATED
+
G_DEFINE_TYPE (EBookView, e_book_view, G_TYPE_OBJECT);
struct _EBookViewPrivate {
object_class->dispose = e_book_view_dispose;
}
+
+#endif /* E_BOOK_DISABLE_DEPRECATED */
*book_view = _e_book_view_new (book, gdbus_bookview);
} else {
*book_view = NULL;
- g_set_error (error, E_BOOK_ERROR, E_BOOK_ERROR_DBUS_EXCEPTION,
+ g_set_error_literal (error, E_BOOK_ERROR, E_BOOK_ERROR_DBUS_EXCEPTION,
"Cannot get connection to view");
ret = FALSE;
}
if (dest->priv) {
e_destination_clear (dest);
+ g_free (dest->priv->source_uid);
+ dest->priv->source_uid = NULL;
+
g_free (dest->priv);
dest->priv = NULL;
}
static void
e_destination_clear (EDestination *dest)
{
- g_free (dest->priv->source_uid);
- dest->priv->source_uid = NULL;
-
g_free (dest->priv->contact_uid);
dest->priv->contact_uid = NULL;
}
+#ifndef E_BOOK_DISABLE_DEPRECATED
/**
* e_destination_set_book:
* @dest: an #EDestination
*
* Specify the source @dest's contact comes from. This is useful
* if you need to update the contact later.
+ *
+ * Deprecated: 3.2: Use e_destination_set_client() instead.
**/
void
e_destination_set_book (EDestination *dest, EBook *book)
g_return_if_fail (uid != NULL);
if (!dest->priv->source_uid || strcmp (uid, dest->priv->source_uid)) {
- e_destination_clear (dest);
+ g_free (dest->priv->source_uid);
+ dest->priv->source_uid = g_strdup (uid);
+
+ g_signal_emit (dest, signals[CHANGED], 0);
+ }
+}
+#endif /* E_BOOK_DISABLE_DEPRECATED */
+
+/**
+ * e_destination_set_client:
+ * @dest: an #EDestination
+ * @client: an #EBookClient
+ *
+ * Specify the source @dest's contact comes from. This is useful
+ * if you need to update the contact later.
+ **/
+void
+e_destination_set_client (EDestination *dest, EBookClient *client)
+{
+ ESource *source;
+ const gchar *uid;
+
+ g_return_if_fail (dest && E_IS_DESTINATION (dest));
+ g_return_if_fail (client && E_IS_BOOK_CLIENT (client));
+
+ source = e_client_get_source (E_CLIENT (client));
+ uid = e_source_peek_uid (source);
+ g_return_if_fail (uid != NULL);
+
+ if (!dest->priv->source_uid || strcmp (uid, dest->priv->source_uid)) {
+ g_free (dest->priv->source_uid);
dest->priv->source_uid = g_strdup (uid);
g_signal_emit (dest, signals[CHANGED], 0);
#define __E_DESTINATION_H__
#include <libebook/e-contact.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libxml/tree.h>
+#ifndef E_BOOK_DISABLE_DEPRECATED
+#include <libebook/e-book.h>
+#endif /* E_BOOK_DISABLE_DEPRECATED */
+
#define E_TYPE_DESTINATION (e_destination_get_type ())
#define E_DESTINATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_DESTINATION, EDestination))
#define E_DESTINATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_DESTINATION, EDestinationClass))
/* for use with EDestinations that wrap a particular contact */
void e_destination_set_contact (EDestination *dest, EContact *contact, gint email_num);
void e_destination_set_contact_uid (EDestination *dest, const gchar *uid, gint email_num);
+#ifndef E_BOOK_DISABLE_DEPRECATED
void e_destination_set_book (EDestination *dest, EBook *book);
+#endif
+void e_destination_set_client (EDestination *dest, EBookClient *client);
EContact *e_destination_get_contact (const EDestination *dest);
const gchar *e_destination_get_source_uid (const EDestination *dest);
const gchar *e_destination_get_contact_uid (const EDestination *dest);
void e_destination_freev (EDestination **destv);
#endif /* __E_DESTINATION_H__ */
-
/* Convenience macro to test and set a GError/return on failure */
#define g_set_error_val_if_fail(test, returnval, error, domain, code) G_STMT_START{ \
- if G_LIKELY (test) {} else { \
- g_set_error (error, domain, code, #test); \
- g_warning(#test " failed"); \
- return (returnval); \
- } \
+ if G_LIKELY (test) {} else { \
+ g_set_error_literal (error, domain, code, #test); \
+ g_warning (#test " failed"); \
+ return (returnval); \
+ } \
}G_STMT_END
G_DEFINE_TYPE (EDataBookFactory, e_data_book_factory, G_TYPE_OBJECT);
OP_MODIFY_CONTACT,
OP_GET_BACKEND_PROPERTY,
OP_SET_BACKEND_PROPERTY,
- OP_GET_BOOK_VIEW,
+ OP_GET_VIEW,
OP_CANCEL_OPERATION,
OP_CANCEL_ALL,
OP_CLOSE
/* OP_ADD_CONTACT */
/* OP_MODIFY_CONTACT */
gchar *vcard;
- /* OP_GET_BOOK_VIEW */
+ /* OP_GET_VIEW */
/* OP_GET_CONTACTS */
/* OP_GET_CONTACTS_UIDS */
gchar *query;
g_free (op->d.sbp.prop_name);
g_free (op->d.sbp.prop_value);
break;
- case OP_GET_BOOK_VIEW:
+ case OP_GET_VIEW:
if (op->d.query) {
EBookBackendSExp *card_sexp;
EDataBookView *book_view;
return TRUE;
}
- op = op_new (OP_GET_BOOK_VIEW, book);
+ op = op_new (OP_GET_VIEW, book);
op->d.query = g_strdup (in_query);
e_gdbus_book_complete_get_view (book->priv->gdbus_object, invocation, op->id);
#include <libecal/e-cal-util.h>
#include <libedata-cal/e-cal-backend-util.h>
#include <libedata-cal/e-cal-backend-sexp.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-query.h>
+#include <libebook/e-contact.h>
#define EDC_ERROR(_code) e_data_cal_create_error (_code, NULL)
GHashTable *addressbooks; /* UID -> BookRecord */
gboolean addressbook_loaded;
- EBookView *book_view;
+ EBookClientView *book_view;
GHashTable *tracked_contacts; /* UID -> ContactRecord */
GHashTable *zones;
typedef struct _BookRecord {
ECalBackendContacts *cbc;
- EBook *book;
- EBookView *book_view;
+ EBookClient *book_client;
+ EBookClientView *book_view;
} BookRecord;
typedef struct _ContactRecord {
ECalBackendContacts *cbc;
- EBook *book; /* where it comes from */
+ EBookClient *book_client; /* where it comes from */
EContact *contact;
ECalComponent *comp_birthday, *comp_anniversary;
} ContactRecord;
static ECalComponent * create_birthday (ECalBackendContacts *cbc, EContact *contact);
static ECalComponent * create_anniversary (ECalBackendContacts *cbc, EContact *contact);
-static void contacts_changed_cb (EBookView *book_view, const GList *contacts, gpointer user_data);
-static void contacts_added_cb (EBookView *book_view, const GList *contacts, gpointer user_data);
-static void contacts_removed_cb (EBookView *book_view, const GList *contact_ids, gpointer user_data);
+static void contacts_modified_cb (EBookClientView *book_view, const GSList *contacts, gpointer user_data);
+static void contacts_added_cb (EBookClientView *book_view, const GSList *contacts, gpointer user_data);
+static void contacts_removed_cb (EBookClientView *book_view, const GSList *contact_ids, gpointer user_data);
static void e_cal_backend_contacts_add_timezone (ECalBackendSync *backend, EDataCal *cal, GCancellable *cancellable, const gchar *tzobj, GError **perror);
static void setup_alarm (ECalBackendContacts *cbc, ECalComponent *comp);
static BookRecord *
book_record_new (ECalBackendContacts *cbc, ESource *source)
{
- EBook *book;
- GList *fields = NULL;
+ EBookClient *book_client;
EBookQuery *query;
- EBookView *book_view;
+ EBookClientView *book_view;
BookRecord *br;
- GError *error = NULL;
+ GError *error = NULL;
+ gchar *query_sexp;
- book = e_book_new (source, &error);
- if (!book || !e_book_open (book, TRUE, &error) || error) {
- if (book)
- g_object_unref (book);
+ book_client = e_book_client_new (source, &error);
+ if (!book_client || !e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, &error) || error) {
+ if (book_client)
+ g_object_unref (book_client);
if (error) {
g_warning ("%s: Failed to open book: %s", G_STRFUNC, error->message);
g_error_free (error);
return NULL;
}
- /* Create book view */
- fields = g_list_append (fields, (gchar *) e_contact_field_name (E_CONTACT_FILE_AS));
- fields = g_list_append (fields, (gchar *) e_contact_field_name (E_CONTACT_BIRTH_DATE));
- fields = g_list_append (fields, (gchar *) e_contact_field_name (E_CONTACT_ANNIVERSARY));
- query = e_book_query_any_field_contains ("");
+ query = e_book_query_andv (
+ e_book_query_field_exists (E_CONTACT_FILE_AS),
+ e_book_query_orv (
+ e_book_query_field_exists (E_CONTACT_BIRTH_DATE),
+ e_book_query_field_exists (E_CONTACT_ANNIVERSARY),
+ NULL),
+ NULL);
+ query_sexp = e_book_query_to_string (query);
+ e_book_query_unref (query);
- if (!e_book_get_book_view (book, query, fields, -1, &book_view, &error)) {
+ if (!e_book_client_get_view_sync (book_client, query_sexp, &book_view, NULL, &error)) {
g_warning ("%s: Failed to get book view on '%s': %s", G_STRFUNC, e_source_peek_name (source), error ? error->message : "Unknown error");
- e_book_query_unref (query);
- g_object_unref (book);
- g_list_free (fields);
+ g_free (query_sexp);
+ g_object_unref (book_client);
if (error)
g_error_free (error);
return NULL;
}
- e_book_query_unref (query);
- g_list_free (fields);
+ g_free (query_sexp);
- g_signal_connect (book_view, "contacts_added", G_CALLBACK (contacts_added_cb), cbc);
- g_signal_connect (book_view, "contacts_removed", G_CALLBACK (contacts_removed_cb), cbc);
- g_signal_connect (book_view, "contacts_changed", G_CALLBACK (contacts_changed_cb), cbc);
+ g_signal_connect (book_view, "objects-added", G_CALLBACK (contacts_added_cb), cbc);
+ g_signal_connect (book_view, "objects-removed", G_CALLBACK (contacts_removed_cb), cbc);
+ g_signal_connect (book_view, "objects-modified", G_CALLBACK (contacts_modified_cb), cbc);
- e_book_view_start (book_view);
+ e_book_client_view_start (book_view, NULL);
br = g_new (BookRecord, 1);
br->cbc = cbc;
- br->book = book;
+ br->book_client = book_client;
br->book_view = book_view;
return br;
remove_by_book (gpointer key, gpointer value, gpointer user_data)
{
ContactRecord *cr = value;
- EBook *book = user_data;
+ EBookClient *book_client = user_data;
- return (cr && cr->book == book);
+ return (cr && cr->book_client == book_client);
}
static void
if (!br)
return;
- g_hash_table_foreach_remove (br->cbc->priv->tracked_contacts, remove_by_book, br->book);
+ g_hash_table_foreach_remove (br->cbc->priv->tracked_contacts, remove_by_book, br->book_client);
g_object_unref (br->book_view);
- g_object_unref (br->book);
+ g_object_unref (br->book_client);
g_free (br);
}
/* ContactRecord methods */
static ContactRecord *
-contact_record_new (ECalBackendContacts *cbc, EBook *book, EContact *contact)
+contact_record_new (ECalBackendContacts *cbc, EBookClient *book_client, EContact *contact)
{
ContactRecord *cr = g_new0 (ContactRecord, 1);
gchar *comp_str;
cr->cbc = cbc;
- cr->book = book;
+ cr->book_client = book_client;
cr->contact = contact;
cr->comp_birthday = create_birthday (cbc, contact);
cr->comp_anniversary = create_anniversary (cbc, contact);
if (cr->comp_birthday) {
comp_str = e_cal_component_get_as_string (cr->comp_birthday);
- e_cal_backend_notify_object_created (E_CAL_BACKEND (cbc),
- comp_str);
+ e_cal_backend_notify_object_created (E_CAL_BACKEND (cbc), comp_str);
g_free (comp_str);
}
if (cr->comp_anniversary) {
-
comp_str = e_cal_component_get_as_string (cr->comp_anniversary);
- e_cal_backend_notify_object_created (E_CAL_BACKEND (cbc),
- comp_str);
+ e_cal_backend_notify_object_created (E_CAL_BACKEND (cbc), comp_str);
g_free (comp_str);
}
/************************************************************************************/
static void
-contacts_changed_cb (EBookView *book_view, const GList *contacts, gpointer user_data)
+contacts_modified_cb (EBookClientView *book_view, const GSList *contacts, gpointer user_data)
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
- EBook *book = e_book_view_get_book (book_view);
- const GList *i;
+ EBookClient *book_client = e_book_client_view_get_client (book_view);
+ const GSList *ii;
- for (i = contacts; i; i = i->next) {
- EContact *contact = E_CONTACT (i->data);
+ for (ii = contacts; ii; ii = ii->next) {
+ EContact *contact = E_CONTACT (ii->data);
const gchar *uid = e_contact_get_const (contact, E_CONTACT_UID);
EContactDate *birthday, *anniversary;
anniversary = e_contact_get (contact, E_CONTACT_ANNIVERSARY);
if (birthday || anniversary) {
- ContactRecord *cr = contact_record_new (cbc, book, contact);
+ ContactRecord *cr = contact_record_new (cbc, book_client, contact);
g_hash_table_insert (cbc->priv->tracked_contacts, g_strdup (uid), cr);
}
}
static void
-contacts_added_cb (EBookView *book_view, const GList *contacts, gpointer user_data)
+contacts_added_cb (EBookClientView *book_view, const GSList *contacts, gpointer user_data)
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
- EBook *book = e_book_view_get_book (book_view);
- const GList *i;
+ EBookClient *book_client = e_book_client_view_get_client (book_view);
+ const GSList *ii;
/* See if any new contacts have BIRTHDAY or ANNIVERSARY fields */
- for (i = contacts; i; i = i->next)
- {
- EContact *contact = E_CONTACT (i->data);
+ for (ii = contacts; ii; ii = ii->next) {
+ EContact *contact = E_CONTACT (ii->data);
EContactDate *birthday, *anniversary;
birthday = e_contact_get (contact, E_CONTACT_BIRTH_DATE);
anniversary = e_contact_get (contact, E_CONTACT_ANNIVERSARY);
if (birthday || anniversary) {
- ContactRecord *cr = contact_record_new (cbc, book, contact);
+ ContactRecord *cr = contact_record_new (cbc, book_client, contact);
const gchar *uid = e_contact_get_const (contact, E_CONTACT_UID);
g_hash_table_insert (cbc->priv->tracked_contacts, g_strdup (uid), cr);
}
static void
-contacts_removed_cb (EBookView *book_view, const GList *contact_ids, gpointer user_data)
+contacts_removed_cb (EBookClientView *book_view, const GSList *contact_ids, gpointer user_data)
{
ECalBackendContacts *cbc = E_CAL_BACKEND_CONTACTS (user_data);
- const GList *i;
+ const GSList *ii;
/* Stop tracking these */
- for (i = contact_ids; i; i = i->next)
- g_hash_table_remove (cbc->priv->tracked_contacts, i->data);
+ for (ii = contact_ids; ii; ii = ii->next)
+ g_hash_table_remove (cbc->priv->tracked_contacts, ii->data);
}
/************************************************************************************/
priv = g_new0 (ECalBackendContactsPrivate, 1);
- e_book_get_addressbooks (&priv->addressbook_sources, NULL);
+ e_book_client_get_sources (&priv->addressbook_sources, NULL);
priv->addressbooks = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, (GDestroyNotify) book_record_free);
/* check and patch timezones */
if (!err) {
- if (!e_cal_check_timezones (toplevel_comp,
+ if (!e_cal_client_check_timezones (toplevel_comp,
NULL,
- e_cal_tzlookup_icomp,
+ e_cal_client_tzlookup_icomp,
priv->icalcomp,
+ NULL,
&err)) {
/*
* This makes assumptions about what kind of
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <libical/ical.h>
#include "e-cal-check-timezones.h"
+#ifndef E_CAL_DISABLE_DEPRECATED
#include <libecal/e-cal.h>
+#endif
+#include <libecal/e-cal-client.h>
#include <string.h>
#include <ctype.h>
}
}
+#ifndef E_CAL_DISABLE_DEPRECATED
+
/**
* e_cal_check_timezones:
* @comp: a VCALENDAR containing a list of
* Returns: TRUE if successful, FALSE otherwise.
*
* Since: 2.24
+ *
+ * Deprecated: 3.2: Use e_cal_client_check_timezones() instead.
*/
gboolean
e_cal_check_timezones (icalcomponent *comp,
* can use. Calls e_cal_get_timezone().
*
* Since: 2.24
+ *
+ * Deprecated: 3.2: Use e_cal_client_tzlookup() instead.
*/
icaltimezone *
e_cal_tzlookup_ecal (const gchar *tzid,
icaltimezone *zone = NULL;
GError *local_error = NULL;
+ g_return_val_if_fail (ecal != NULL, NULL);
+ g_return_val_if_fail (E_IS_CAL (ecal), NULL);
+
if (e_cal_get_timezone (ecal, tzid, &zone, &local_error)) {
g_warn_if_fail (local_error == NULL);
return zone;
* in the component list.
*
* Since: 2.24
- */
+ *
+ * Deprecated: 3.2: Use e_cal_client_tzlookup_icomp() instead.
+ **/
icaltimezone *
e_cal_tzlookup_icomp (const gchar *tzid,
gconstpointer custom,
return icalcomponent_get_timezone (icomp, (gchar *) tzid);
}
+
+#endif /* E_CAL_DISABLE_DEPRECATED */
+
+/**
+ * e_cal_client_check_timezones:
+ * @comp: a VCALENDAR containing a list of
+ * VTIMEZONE and arbitrary other components, in
+ * arbitrary order: these other components are
+ * modified by this call
+ * @comps: a list of icalcomponent instances which
+ * also have to be patched; may be NULL
+ * @tzlookup: a callback function which is called to retrieve
+ * a calendar's VTIMEZONE definition; the returned
+ * definition is *not* freed by e_cal_client_check_timezones()
+ * (to be compatible with e_cal_get_timezone());
+ * NULL indicates that no such timezone exists
+ * or an error occurred
+ * @ecalclient: an arbitrary pointer which is passed through to
+ * the @tzlookup function
+ * @cancellable: a #GCancellable to use in @tzlookup function
+ * @error: an error description in case of a failure
+ *
+ * This function cleans up VEVENT, VJOURNAL, VTODO and VTIMEZONE
+ * items which are to be imported into Evolution.
+ *
+ * Using VTIMEZONE definitions is problematic because they cannot be
+ * updated properly when timezone definitions change. They are also
+ * incomplete (for compatibility reason only one set of rules for
+ * summer saving changes can be included, even if different rules
+ * apply in different years). This function looks for matches of the
+ * used TZIDs against system timezones and replaces such TZIDs with
+ * the corresponding system timezone. This works for TZIDs containing
+ * a location (found via a fuzzy string search) and for Outlook TZIDs
+ * (via a hard-coded lookup table).
+ *
+ * Some programs generate broken meeting invitations with TZID, but
+ * without including the corresponding VTIMEZONE. Importing such
+ * invitations unchanged causes problems later on (meeting displayed
+ * incorrectly, e_cal_get_component_as_string() fails). The situation
+ * where this occurred in the past (found by a SyncEvolution user) is
+ * now handled via the location based mapping.
+ *
+ * If this mapping fails, this function also deals with VTIMEZONE
+ * conflicts: such conflicts occur when the calendar already contains
+ * an old VTIMEZONE definition with the same TZID, but different
+ * summer saving rules. Replacing the VTIMEZONE potentially breaks
+ * displaying of old events, whereas not replacing it breaks the new
+ * events (the behavior in Evolution <= 2.22.1).
+ *
+ * The way this problem is resolved is by renaming the new VTIMEZONE
+ * definition until the TZID is unique. A running count is appended to
+ * the TZID. All items referencing the renamed TZID are adapted
+ * accordingly.
+ *
+ * Returns: TRUE if successful, FALSE otherwise.
+ *
+ * Since: 3.2
+ **/
+gboolean
+e_cal_client_check_timezones (
+ icalcomponent *comp,
+ GList *comps,
+ icaltimezone *(*tzlookup) (const gchar *tzid,
+ gconstpointer ecalclient,
+ GCancellable *cancellable,
+ GError **error),
+ gconstpointer ecalclient,
+ GCancellable *cancellable,
+ GError **error)
+{
+ gboolean success = TRUE;
+ icalcomponent *subcomp = NULL;
+ icaltimezone *zone = icaltimezone_new ();
+ gchar *key = NULL, *value = NULL;
+ gchar *buffer = NULL;
+ gchar *zonestr = NULL;
+ gchar *tzid = NULL;
+ GList *l;
+
+ /* a hash from old to new tzid; strings dynamically allocated */
+ GHashTable *mapping = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
+ /* a hash of all system time zone IDs which have to be added; strings are shared with mapping hash */
+ GHashTable *systemtzids = g_hash_table_new (g_str_hash, g_str_equal);
+
+ *error = NULL;
+
+ if (!mapping || !zone) {
+ goto nomem;
+ }
+
+ /* iterate over all VTIMEZONE definitions */
+ subcomp = icalcomponent_get_first_component (comp, ICAL_VTIMEZONE_COMPONENT);
+ while (subcomp) {
+ if (icaltimezone_set_component (zone, subcomp)) {
+ g_free (tzid);
+ tzid = g_strdup (icaltimezone_get_tzid (zone));
+ if (tzid) {
+ const gchar *newtzid = e_cal_match_tzid (tzid);
+ if (newtzid) {
+ /* matched against system time zone */
+ g_free (key);
+ key = g_strdup (tzid);
+ if (!key) {
+ goto nomem;
+ }
+
+ g_free (value);
+ value = g_strdup (newtzid);
+ if (!value) {
+ goto nomem;
+ }
+
+ g_hash_table_insert (mapping, key, value);
+ g_hash_table_insert (systemtzids, value, NULL);
+ key = value = NULL;
+ } else {
+ gint counter;
+
+ zonestr = icalcomponent_as_ical_string_r (subcomp);
+
+ /* check for collisions with existing timezones */
+ for (counter = 0;
+ counter < 100 /* sanity limit */;
+ counter++) {
+ icaltimezone *existing_zone;
+
+ if (counter) {
+ g_free (value);
+ value = g_strdup_printf("%s %d", tzid, counter);
+ }
+ existing_zone = tzlookup (counter ? value : tzid, ecalclient, cancellable, error);
+ if (!existing_zone) {
+ if (*error) {
+ goto failed;
+ } else {
+ break;
+ }
+ }
+ g_free (buffer);
+ buffer = icalcomponent_as_ical_string_r (icaltimezone_get_component (existing_zone));
+
+ if (counter) {
+ gchar *fulltzid = g_strdup_printf("TZID:%s", value);
+ gsize baselen = strlen("TZID:") + strlen(tzid);
+ gsize fulllen = strlen (fulltzid);
+ gchar *tzidprop;
+ /*
+ * Map TZID with counter suffix back to basename.
+ */
+ tzidprop = strstr (buffer, fulltzid);
+ if (tzidprop) {
+ memmove (tzidprop + baselen,
+ tzidprop + fulllen,
+ strlen (tzidprop + fulllen) + 1);
+ }
+ g_free (fulltzid);
+ }
+
+ /*
+ * If the strings are identical, then the
+ * VTIMEZONE definitions are identical. If
+ * they are not identical, then VTIMEZONE
+ * definitions might still be semantically
+ * correct and we waste some space by
+ * needlesly duplicating the VTIMEZONE. This
+ * is expected to occur rarely (if at all) in
+ * practice.
+ */
+ if (!strcmp (zonestr, buffer)) {
+ break;
+ }
+ }
+
+ if (!counter) {
+ /* does not exist, nothing to do */
+ } else {
+ /* timezone renamed */
+ icalproperty *prop = icalcomponent_get_first_property (subcomp, ICAL_TZID_PROPERTY);
+ while (prop) {
+ icalproperty_set_value_from_string(prop, value, "NO");
+ prop = icalcomponent_get_next_property (subcomp, ICAL_ANY_PROPERTY);
+ }
+ g_free (key);
+ key = g_strdup (tzid);
+ g_hash_table_insert (mapping, key, value);
+ key = value = NULL;
+ }
+ }
+ }
+ }
+
+ subcomp = icalcomponent_get_next_component (comp, ICAL_VTIMEZONE_COMPONENT);
+ }
+
+ /*
+ * now replace all TZID parameters in place
+ */
+ subcomp = icalcomponent_get_first_component (comp, ICAL_ANY_COMPONENT);
+ while (subcomp) {
+ /*
+ * Leave VTIMEZONE unchanged, iterate over properties of
+ * everything else.
+ *
+ * Note that no attempt is made to remove unused VTIMEZONE
+ * definitions. That would just make the code more complex for
+ * little additional gain. However, newly used time zones are
+ * added below.
+ */
+ patch_tzids (subcomp, mapping);
+ subcomp = icalcomponent_get_next_component (comp, ICAL_ANY_COMPONENT);
+ }
+
+ for (l = comps; l; l = l->next) {
+ patch_tzids (l->data, mapping);
+ }
+
+ /*
+ * add system time zones that we mapped to: adding them ensures
+ * that the VCALENDAR remains consistent
+ */
+ g_hash_table_foreach (systemtzids, addsystemtz, comp);
+
+ goto done;
+ nomem:
+ /* set gerror for "out of memory" if possible, otherwise abort via g_error() */
+ *error = g_error_new (E_CLIENT_ERROR, E_CLIENT_ERROR_OTHER_ERROR, "out of memory");
+ if (!*error) {
+ g_error("e_cal_check_timezones(): out of memory, cannot proceed - sorry!");
+ }
+ failed:
+ /* gerror should have been set already */
+ success = FALSE;
+ done:
+ if (mapping) {
+ g_hash_table_destroy (mapping);
+ }
+ if (systemtzids) {
+ g_hash_table_destroy (systemtzids);
+ }
+ if (zone) {
+ icaltimezone_free (zone, 1);
+ }
+ g_free (tzid);
+ g_free (zonestr);
+ g_free (buffer);
+ g_free (key);
+ g_free (value);
+
+ return success;
+}
+
+/**
+ * e_cal_client_tzlookup:
+ * @ecalclient: must be a valid ECalCleint pointer
+ *
+ * An implementation of the tzlookup callback which clients
+ * can use. Calls e_cal_client_get_timezone_sync().
+ *
+ * Since: 3.2
+ */
+icaltimezone *
+e_cal_client_tzlookup (const gchar *tzid,
+ gconstpointer ecalclient,
+ GCancellable *cancellable,
+ GError **error)
+{
+ ECalClient *cal_client = (ECalClient *) ecalclient;
+ icaltimezone *zone = NULL;
+ GError *local_error = NULL;
+
+ g_return_val_if_fail (cal_client != NULL, NULL);
+ g_return_val_if_fail (E_IS_CAL_CLIENT (cal_client), NULL);
+
+ if (e_cal_client_get_timezone_sync (cal_client, tzid, &zone, cancellable, &local_error)) {
+ g_warn_if_fail (local_error == NULL);
+ return zone;
+ }
+
+ if (g_error_matches (local_error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND)) {
+ /* We had to trigger this error to check for the
+ * timezone existance, clear it and return NULL. */
+ g_clear_error (&local_error);
+ }
+
+ if (local_error)
+ g_propagate_error (error, local_error);
+
+ return NULL;
+}
+
+/**
+ * e_cal_client_tzlookup_icomp:
+ * @custom: must be a icalcomponent pointer which contains
+ * either a VCALENDAR with VTIMEZONEs or VTIMEZONES
+ * directly
+ *
+ * An implementation of the tzlookup callback which backends
+ * like the file backend can use. Searches for the timezone
+ * in the component list.
+ *
+ * Since: 3.2
+ */
+icaltimezone *
+e_cal_client_tzlookup_icomp (const gchar *tzid,
+ gconstpointer custom,
+ GCancellable *cancellable,
+ GError **error)
+{
+ icalcomponent *icomp = (icalcomponent *) custom;
+
+ return icalcomponent_get_timezone (icomp, (gchar *) tzid);
+}
#include <libical/ical.h>
#include <glib.h>
+#include <gio/gio.h>
G_BEGIN_DECLS
+#ifndef E_CAL_DISABLE_DEPRECATED
+
gboolean e_cal_check_timezones (icalcomponent *comp,
GList *comps,
icaltimezone *(*tzlookup)(const gchar *tzid,
gconstpointer custom,
GError **error);
-icaltimezone *e_cal_tzlookup_icomp (const gchar *tzid,
- gconstpointer custom,
- GError **error);
+icaltimezone *e_cal_tzlookup_icomp
+ (const gchar *tzid,
+ gconstpointer custom,
+ GError **error);
+
+#endif /* E_CAL_DISABLE_DEPRECATED */
+
+gboolean e_cal_client_check_timezones
+ (icalcomponent *comp,
+ GList *comps,
+ icaltimezone *(*tzlookup) (const gchar *tzid,
+ gconstpointer ecalclient,
+ GCancellable *cancellable,
+ GError **error),
+ gconstpointer ecalclient,
+ GCancellable *cancellable,
+ GError **error);
+
+icaltimezone *e_cal_client_tzlookup
+ (const gchar *tzid,
+ gconstpointer ecalclient,
+ GCancellable *cancellable,
+ GError **error);
+
+icaltimezone *e_cal_client_tzlookup_icomp
+ (const gchar *tzid,
+ gconstpointer custom,
+ GCancellable *cancellable,
+ GError **error);
const gchar *e_cal_match_tzid (const gchar *tzid);
if (priv->gdbus_calview) {
GError *local_error = NULL;
- if (e_gdbus_cal_view_call_start_sync (priv->gdbus_calview, NULL, &local_error))
- priv->running = TRUE;
+ priv->running = TRUE;
+ if (!e_gdbus_cal_view_call_start_sync (priv->gdbus_calview, NULL, &local_error))
+ priv->running = FALSE;
- e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+ e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
} else {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot start view, D-Bus proxy gone"));
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot start view, D-Bus proxy gone"));
}
}
e_gdbus_cal_view_call_stop_sync (priv->gdbus_calview, NULL, &local_error);
- e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+ e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
} else {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot stop view, D-Bus proxy gone"));
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot stop view, D-Bus proxy gone"));
}
}
e_gdbus_cal_view_call_set_fields_of_interest_sync (priv->gdbus_calview, (const gchar * const *) strv, NULL, &local_error);
g_strfreev (strv);
- e_client_util_unwrap_dbus_error (local_error, error, NULL, 0, 0, FALSE);
+ e_client_unwrap_dbus_error (E_CLIENT (priv->client), local_error, error);
} else {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot set fields of interest, D-Bus proxy gone"));
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR, _("Cannot set fields of interest, D-Bus proxy gone"));
}
}
void (* objects_modified) (ECalClientView *view, const GSList *objects);
void (* objects_removed) (ECalClientView *view, const GSList *uids);
- void (* progress) (ECalClientView *view, gint percent, const gchar *message);
+ void (* progress) (ECalClientView *view, guint percent, const gchar *message);
void (* complete) (ECalClientView *view, const GError *error);
};
return C_("CalClientError", "Unknown user");
case E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS:
return C_("CalClientError", "Object ID already exists");
+ case E_CAL_CLIENT_ERROR_INVALID_RANGE:
+ return C_("CalClientError", "Invalid range");
}
return C_("CalClientError", "Unknown error");
}
/**
+ * e_cal_client_error_create:
+ * @code: an #ECalClientError code to create
+ * @custom_msg: custom message to use for the error; can be %NULL
+ *
+ * Returns: a new #GError containing an E_CAL_CLIENT_ERROR of the given
+ * @code. If the @custom_msg is NULL, then the error message is
+ * the one returned from e_cal_client_error_to_string() for the @code,
+ * otherwise the given message is used.
+ *
+ * Returned pointer should be freed with g_error_free().
+ **/
+GError *
+e_cal_client_error_create (ECalClientError code, const gchar *custom_msg)
+{
+ return g_error_new_literal (E_CAL_CLIENT_ERROR, code, custom_msg ? custom_msg : e_cal_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
* leave it alone.
{ err ("ObjectIdAlreadyExists", E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS) },
{ err ("NoSuchCal", E_CAL_CLIENT_ERROR_NO_SUCH_CALENDAR) },
{ err ("UnknownUser", E_CAL_CLIENT_ERROR_UNKNOWN_USER) },
+ { err ("InvalidRange", E_CAL_CLIENT_ERROR_INVALID_RANGE) },
}, cl_errors[] = {
{ err ("Busy", E_CLIENT_ERROR_BUSY) },
{ err ("InvalidArg", E_CLIENT_ERROR_INVALID_ARG) },
{ err ("RepositoryOffline", E_CLIENT_ERROR_REPOSITORY_OFFLINE) },
+ { err ("OfflineUnavailable", E_CLIENT_ERROR_OFFLINE_UNAVAILABLE) },
{ err ("PermissionDenied", E_CLIENT_ERROR_PERMISSION_DENIED) },
{ err ("AuthenticationFailed", E_CLIENT_ERROR_AUTHENTICATION_FAILED) },
{ err ("AuthenticationRequired", E_CLIENT_ERROR_AUTHENTICATION_REQUIRED) },
{ err ("CouldNotCancel", E_CLIENT_ERROR_COULD_NOT_CANCEL) },
{ err ("NotSupported", E_CLIENT_ERROR_NOT_SUPPORTED) },
- { err ("InvalidRange", E_CLIENT_ERROR_OTHER_ERROR) },
+ { err ("UnsupportedAuthenticationMethod", E_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD) },
+ { err ("TLSNotAvailable", E_CLIENT_ERROR_TLS_NOT_AVAILABLE) },
+ { err ("SearchSizeLimitExceeded", E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED) },
+ { err ("SearchTimeLimitExceeded", E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED) },
+ { err ("InvalidQuery", E_CLIENT_ERROR_INVALID_QUERY) },
+ { err ("QueryRefused", E_CLIENT_ERROR_QUERY_REFUSED) },
{ err ("UnsupportedField", E_CLIENT_ERROR_OTHER_ERROR) },
{ err ("UnsupportedMethod", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("UnsupportedAuthenticationMethod", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("TLSNotAvailable", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("OfflineUnavailable", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("SearchSizeLimitExceeded", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("SearchTimeLimitExceeded", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("InvalidQuery", E_CLIENT_ERROR_OTHER_ERROR) },
- { err ("QueryRefused", E_CLIENT_ERROR_OTHER_ERROR) },
{ err ("InvalidServerVersion", E_CLIENT_ERROR_OTHER_ERROR) },
{ err ("OtherError", E_CLIENT_ERROR_OTHER_ERROR) }
};
}
/**
- * e_cal_generate_instances:
+ * e_cal_client_generate_instances:
* @client: A calendar client.
* @start: Start time for query.
* @end: End time for query.
res = FALSE;
if (error && !*error)
- g_set_error_literal (error, E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG, e_client_error_to_string (E_CLIENT_ERROR_INVALID_ARG));
+ g_propagate_error (error, e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL));
}
return res;
if (res && out_string) {
*icalcomp = icalparser_parse_string (out_string);
if (!*icalcomp) {
- g_set_error_literal (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, e_cal_client_error_to_string (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
+ g_propagate_error (error, e_cal_client_error_create (E_CAL_CLIENT_ERROR_INVALID_OBJECT, NULL));
res = FALSE;
}
} else {
if (e_gdbus_cal_decode_send_objects ((const gchar * const *) out_strv, &calobj, users)) {
*modified_icalcomp = icalparser_parse_string (calobj);
if (!*modified_icalcomp) {
- g_set_error_literal (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, e_cal_client_error_to_string (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
+ g_propagate_error (error, e_cal_client_error_create (E_CAL_CLIENT_ERROR_INVALID_OBJECT, NULL));
e_client_util_free_string_slist (*users);
*users = NULL;
res = FALSE;
}
} else {
- g_set_error_literal (error, E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG, e_client_error_to_string (E_CLIENT_ERROR_INVALID_ARG));
+ g_propagate_error (error, e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL));
e_client_util_free_string_slist (*users);
*users = NULL;
res = FALSE;
icaltimezone_free (*zone, 1);
icalcomponent_free (icalcomp);
res = FALSE;
- g_set_error_literal (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, e_cal_client_error_to_string (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
+ g_propagate_error (error, e_cal_client_error_create (E_CAL_CLIENT_ERROR_INVALID_OBJECT, NULL));
} else {
g_mutex_lock (client->priv->zone_cache_lock);
g_hash_table_insert (client->priv->zone_cache, g_strdup (icaltimezone_get_tzid (*zone)), *zone);
}
} else {
res = FALSE;
- g_set_error_literal (error, E_CAL_CLIENT_ERROR, E_CAL_CLIENT_ERROR_INVALID_OBJECT, e_cal_client_error_to_string (E_CAL_CLIENT_ERROR_INVALID_OBJECT));
+ g_propagate_error (error, e_cal_client_error_create (E_CAL_CLIENT_ERROR_INVALID_OBJECT, NULL));
}
} else {
res = FALSE;
icalcomp = icaltimezone_get_component (zone);
if (!icalcomp) {
- g_set_error_literal (error, E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG, e_client_error_to_string (E_CLIENT_ERROR_INVALID_ARG));
+ g_propagate_error (error, e_client_error_create (E_CLIENT_ERROR_INVALID_ARG, NULL));
return FALSE;
}
E_CAL_CLIENT_ERROR_OBJECT_NOT_FOUND,
E_CAL_CLIENT_ERROR_INVALID_OBJECT,
E_CAL_CLIENT_ERROR_UNKNOWN_USER,
- E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS
+ E_CAL_CLIENT_ERROR_OBJECT_ID_ALREADY_EXISTS,
+ E_CAL_CLIENT_ERROR_INVALID_RANGE
} ECalClientError;
-const gchar *e_cal_client_error_to_string (ECalClientError code);
+const gchar * e_cal_client_error_to_string (ECalClientError code);
+GError * e_cal_client_error_create (ECalClientError code, const gchar *custom_msg);
typedef struct _ECalClient ECalClient;
typedef struct _ECalClientClass ECalClientClass;
gboolean e_cal_client_get_default_object_finish (ECalClient *client, GAsyncResult *result, icalcomponent **icalcomp, GError **error);
gboolean e_cal_client_get_default_object_sync (ECalClient *client, icalcomponent **icalcomp, GCancellable *cancellable, GError **error);
-void e_cal_client_refresh (ECalClient *client, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
-gboolean e_cal_client_refresh_finish (ECalClient *client, GAsyncResult *result, GError **error);
-gboolean e_cal_client_refresh_sync (ECalClient *client, GCancellable *cancellable, GError **error);
-
void e_cal_client_get_object (ECalClient *client, const gchar *uid, const gchar *rid, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
gboolean e_cal_client_get_object_finish (ECalClient *client, GAsyncResult *result, icalcomponent **icalcomp, GError **error);
gboolean e_cal_client_get_object_sync (ECalClient *client, const gchar *uid, const gchar *rid, icalcomponent **icalcomp, GCancellable *cancellable, GError **error);
G_BEGIN_DECLS
+#ifndef E_CAL_DISABLE_DEPRECATED
+
struct _EGdbusCalView;
ECalView *_e_cal_view_new (struct _ECal *client, struct _EGdbusCalView *gdbus_calview);
+#endif /* E_CAL_DISABLE_DEPRECATED */
+
G_END_DECLS
#endif
#include <config.h>
#endif
+#ifndef E_CAL_DISABLE_DEPRECATED
+
#include <string.h>
#include "e-cal-marshal.h"
#include "e-cal.h"
g_error_free (error);
}
}
+
+#endif /* E_CAL_DISABLE_DEPRECATED */
#include <config.h>
#endif
+#ifndef E_CAL_DISABLE_DEPRECATED
+
#include <unistd.h>
#include <string.h>
#include <glib/gi18n-lib.h>
e_cal_get_error_message (E_CALENDAR_STATUS_NO_SUCH_CALENDAR));
return FALSE;
}
+
+#endif /* E_CAL_DISABLE_DEPRECATED */
#include <libedataserver/e-source-list.h>
#include <libebackend/e-data-server-module.h>
#include <libebackend/e-offline-listener.h>
-#include <libecal/e-cal.h>
+#include <libecal/e-cal-client.h>
#include "e-cal-backend.h"
#include "e-cal-backend-factory.h"
#include "e-data-cal.h"
/* Convenience macro to test and set a GError/return on failure */
#define g_set_error_val_if_fail(test, returnval, error, domain, code) G_STMT_START{ \
- if G_LIKELY (test) {} else { \
- g_set_error (error, domain, code, #test); \
- g_warning(#test " failed"); \
- return (returnval); \
- } \
+ if G_LIKELY (test) {} else { \
+ g_set_error_literal (error, domain, code, #test); \
+ g_warning(#test " failed"); \
+ return (returnval); \
+ } \
} G_STMT_END
G_DEFINE_TYPE (EDataCalFactory, e_data_cal_factory, G_TYPE_OBJECT);
gboolean is_online;
/* this is for notifications of source changes */
- ESourceList *lists[E_CAL_SOURCE_TYPE_LAST];
+ ESourceList *lists[E_CAL_CLIENT_SOURCE_TYPE_LAST];
/* backends divided by their type */
- GSList *backends_by_type[E_CAL_SOURCE_TYPE_LAST];
+ GSList *backends_by_type[E_CAL_CLIENT_SOURCE_TYPE_LAST];
guint exit_timeout;
};
return "UNKNOWN COMPONENT";
}
-static ECalSourceType
-icalkind_to_ecalsourcetype (const icalcomponent_kind kind)
+static ECalClientSourceType
+icalkind_to_ecalclientsourcetype (const icalcomponent_kind kind)
{
switch (kind) {
case ICAL_VEVENT_COMPONENT:
- return E_CAL_SOURCE_TYPE_EVENT;
+ return E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
case ICAL_VTODO_COMPONENT:
- return E_CAL_SOURCE_TYPE_TODO;
+ return E_CAL_CLIENT_SOURCE_TYPE_TASKS;
case ICAL_VJOURNAL_COMPONENT:
- return E_CAL_SOURCE_TYPE_JOURNAL;
+ return E_CAL_CLIENT_SOURCE_TYPE_MEMOS;
default:
break;
}
- return E_CAL_SOURCE_TYPE_LAST;
+ return E_CAL_CLIENT_SOURCE_TYPE_LAST;
}
static void
g_mutex_lock (priv->backends_mutex);
- for (i = 0; i < E_CAL_SOURCE_TYPE_LAST; i++) {
+ for (i = 0; i < E_CAL_CLIENT_SOURCE_TYPE_LAST; i++) {
GSList *iter;
if (list != priv->lists[i])
}
if (!backend) {
- ECalSourceType st;
+ ECalClientSourceType st;
/* There was no existing backend, create a new one */
if (E_IS_CAL_BACKEND_LOADER_FACTORY (backend_factory)) {
goto cleanup;
}
- st = icalkind_to_ecalsourcetype (
- e_cal_backend_get_kind (backend));
- if (st != E_CAL_SOURCE_TYPE_LAST) {
- if (!priv->lists[st] && e_cal_get_sources (
- &(priv->lists[st]), st, NULL)) {
+ st = icalkind_to_ecalclientsourcetype (e_cal_backend_get_kind (backend));
+ if (st != E_CAL_CLIENT_SOURCE_TYPE_LAST) {
+ if (!priv->lists[st] && e_cal_client_get_sources (&(priv->lists[st]), st, NULL)) {
g_signal_connect (
priv->lists[st], "changed",
G_CALLBACK (source_list_changed_cb),
g_mutex_free (factory->priv->backends_mutex);
- for (ii = 0; ii < E_CAL_SOURCE_TYPE_LAST; ii++) {
+ for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++) {
if (factory->priv->lists[ii]) {
g_object_unref (factory->priv->lists[ii]);
factory->priv->lists[ii] = NULL;
LIBEDATASERVER_REVISION=0
LIBEDATASERVER_AGE=0
-LIBEDATASERVERUI_CURRENT=0
+LIBEDATASERVERUI_CURRENT=1
LIBEDATASERVERUI_REVISION=0
LIBEDATASERVERUI_AGE=0
;;
esac
+dnl define disable deprecated for EBook and ECal .am files
+case "$WARNING_FLAGS" in
+*E_BOOK_DISABLE_DEPRECATED*)
+ AM_CONDITIONAL(HAVE_E_BOOK_DISABLE_DEPRECATED, [ test 1 == 1 ])
+ ;;
+*)
+ AM_CONDITIONAL(HAVE_E_BOOK_DISABLE_DEPRECATED, [ test 0 == 1 ])
+ ;;
+esac
+
+case "$WARNING_FLAGS" in
+*E_CAL_DISABLE_DEPRECATED*)
+ AM_CONDITIONAL(HAVE_E_CAL_DISABLE_DEPRECATED, [ test 1 == 1 ])
+ ;;
+*)
+ AM_CONDITIONAL(HAVE_E_CAL_DISABLE_DEPRECATED, [ test 0 == 1 ])
+ ;;
+esac
+
dnl ******************************
dnl Initialize maintainer mode
dnl ******************************
/* protected functions simplifying sync/async calls */
GDBusProxy * e_client_get_dbus_proxy (EClient *client);
-void e_client_unwrap_dbus_error (EClient *client, GError *dbus_error, GError **out_error);
void e_client_proxy_return_async_error (EClient *client, const GError *error, GAsyncReadyCallback callback, gpointer user_data, gpointer source_tag);
return C_("ClientError", "Authentication required");
case E_CLIENT_ERROR_REPOSITORY_OFFLINE:
return C_("ClientError", "Repository offline");
+ case E_CLIENT_ERROR_OFFLINE_UNAVAILABLE:
+ return C_("ClientError", "Offline unavailable");
case E_CLIENT_ERROR_PERMISSION_DENIED:
return C_("ClientError", "Permission denied");
case E_CLIENT_ERROR_CANCELLED:
return C_("ClientError", "Could not cancel");
case E_CLIENT_ERROR_NOT_SUPPORTED:
return C_("ClientError", "Not supported");
+ case E_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD:
+ return C_("ClientError", "Unsupported authentication method");
+ case E_CLIENT_ERROR_TLS_NOT_AVAILABLE:
+ return C_("ClientError", "TLS not available");
+ case E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED:
+ return C_("ClientError", "Search size limit exceeded");
+ case E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED:
+ return C_("ClientError", "Search time limit exceeded");
+ case E_CLIENT_ERROR_INVALID_QUERY:
+ return C_("ClientError", "Invalid query");
+ case E_CLIENT_ERROR_QUERY_REFUSED:
+ return C_("ClientError", "Query refused");
case E_CLIENT_ERROR_DBUS_ERROR:
return C_("ClientError", "D-Bus error");
case E_CLIENT_ERROR_OTHER_ERROR:
return C_("ClientError", "Unknown error");
}
+/**
+ * e_client_error_create:
+ * @code: an #EClientError code to create
+ * @custom_msg: custom message to use for the error; can be %NULL
+ *
+ * Returns: a new #GError containing an E_CLIENT_ERROR of the given
+ * @code. If the @custom_msg is NULL, then the error message is
+ * the one returned from e_client_error_to_string() for the @code,
+ * otherwise the given message is used.
+ *
+ * Returned pointer should be freed with g_error_free().
+ **/
+GError *
+e_client_error_create (EClientError code, const gchar *custom_msg)
+{
+ return g_error_new_literal (E_CLIENT_ERROR, code, custom_msg ? custom_msg : e_client_error_to_string (code));
+}
+
static void client_set_source (EClient *client, ESource *source);
static void client_operation_thread (gpointer data, gpointer user_data);
static void client_handle_authentication (EClient *client, const ECredentials *credentials);
} else {
GError *error;
- error = g_error_new_literal (E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_REQUIRED, e_client_error_to_string (E_CLIENT_ERROR_AUTHENTICATION_REQUIRED));
+ error = e_client_error_create (E_CLIENT_ERROR_AUTHENTICATION_REQUIRED, NULL);
e_client_emit_opened (op_data->client, error);
g_error_free (error);
}
}
/**
- * Unwraps D-Bus error to local error. dbus_error is automatically freed.
- * dbus_erorr and out_error can point to the same variable.
+ * e_client_unwrap_dbus_error:
+ * @client: an #EClient
+ * @dbus_error: a #GError returned bu D-Bus
+ * @out_error: a #GError variable where to store the result
+ *
+ * Unwraps D-Bus error to local error. @dbus_error is automatically freed.
+ * @dbus_erorr and @out_error can point to the same variable.
**/
void
e_client_unwrap_dbus_error (EClient *client, GError *dbus_error, GError **out_error)
E_CLIENT_ERROR_AUTHENTICATION_FAILED,
E_CLIENT_ERROR_AUTHENTICATION_REQUIRED,
E_CLIENT_ERROR_REPOSITORY_OFFLINE,
+ E_CLIENT_ERROR_OFFLINE_UNAVAILABLE,
E_CLIENT_ERROR_PERMISSION_DENIED,
E_CLIENT_ERROR_CANCELLED,
E_CLIENT_ERROR_COULD_NOT_CANCEL,
E_CLIENT_ERROR_NOT_SUPPORTED,
+ E_CLIENT_ERROR_TLS_NOT_AVAILABLE,
+ E_CLIENT_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD,
+ E_CLIENT_ERROR_SEARCH_SIZE_LIMIT_EXCEEDED,
+ E_CLIENT_ERROR_SEARCH_TIME_LIMIT_EXCEEDED,
+ E_CLIENT_ERROR_INVALID_QUERY,
+ E_CLIENT_ERROR_QUERY_REFUSED,
E_CLIENT_ERROR_DBUS_ERROR,
E_CLIENT_ERROR_OTHER_ERROR
} EClientError;
-const gchar *e_client_error_to_string (EClientError code);
+const gchar * e_client_error_to_string (EClientError code);
+GError * e_client_error_create (EClientError code, const gchar *custom_msg);
typedef struct _EClient EClient;
typedef struct _EClientClass EClientClass;
gboolean e_client_is_readonly (EClient *client);
gboolean e_client_is_online (EClient *client);
gboolean e_client_is_opened (EClient *client);
+void e_client_unwrap_dbus_error (EClient *client, GError *dbus_error, GError **out_error);
void e_client_cancel_all (EClient *client);
GSList * e_client_util_copy_object_slist (GSList *copy_to, const GSList *objects);
void e_client_util_free_string_slist (GSList *strings);
void e_client_util_free_object_slist (GSList *objects);
-GSList * e_client_util_parse_comma_strings (const gchar *capabilities);
+GSList * e_client_util_parse_comma_strings (const gchar *strings);
struct EClientErrorsList {
const gchar *name;
* Mostly taken from Evolution's addressbook/gui/component/addressbook.c
*/
+#ifdef HAVE_CONFIG_H
#include <config.h>
+#endif
+
+#ifndef E_BOOK_DISABLE_DEPRECATED
+
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
* then call e_load_book_source_finish() to obtain the resulting #EBook.
*
* Since: 2.32
+ *
+ * Deprecated: 3.2: Use e_client_utils_open_new(), e_client_utils_open_new_finish() instead.
**/
void
e_load_book_source_async (ESource *source,
* Returns: a ready-to-use #EBook, or %NULL or error
*
* Since: 2.32
+ *
+ * Deprecated: 3.2: Use e_client_utils_open_new(), e_client_utils_open_new_finish() instead.
**/
EBook *
e_load_book_source_finish (ESource *source,
return g_object_ref (context->book);
}
+
+#endif /* E_BOOK_DISABLE_DEPRECATED */
#ifndef E_BOOK_AUTH_UTIL_H
#define E_BOOK_AUTH_UTIL_H
+#ifndef E_BOOK_DISABLE_DEPRECATED
+
#include <gtk/gtk.h>
#include <libebook/e-book.h>
G_BEGIN_DECLS
-#ifndef E_BOOK_DISABLE_DEPRECATED
EBook * e_load_book_source (ESource *source,
EBookCallback open_func,
gpointer user_data);
-#endif
void e_load_book_source_async (ESource *source,
GtkWindow *parent,
EBook * e_load_book_source_finish (ESource *source,
GAsyncResult *result,
GError **error);
-
G_END_DECLS
+#endif /* E_BOOK_DISABLE_DEPRECATED */
+
#endif /* E_BOOK_AUTH_UTIL_H */
GAsyncReadyCallback async_cb;
gpointer async_cb_user_data;
GCancellable *cancellable;
+ ESource *source;
EClient *client;
ECredentials *used_credentials;
gboolean open_finished;
g_error_free (async_data->opened_cb_error);
g_object_unref (async_data->cancellable);
g_object_unref (async_data->client);
+ g_object_unref (async_data->source);
g_free (async_data);
}
return FALSE;
}
-#define return_async_error_if_fail(expr, async_cb, async_cb_user_data, source_tag) G_STMT_START { \
+#define return_async_error_if_fail(expr, async_cb, async_cb_user_data, src, source_tag) G_STMT_START { \
if (G_LIKELY ((expr))) { } else { \
GError *error; \
\
error = g_error_new (E_CLIENT_ERROR, E_CLIENT_ERROR_INVALID_ARG, \
"%s: assertion '%s' failed", G_STRFUNC, #expr); \
\
- return_async_error (error, async_cb, async_cb_user_data, source_tag); \
+ return_async_error (error, async_cb, async_cb_user_data, src, source_tag); \
g_error_free (error); \
return; \
} \
} G_STMT_END
static void
-return_async_error (const GError *error, GAsyncReadyCallback async_cb, gpointer async_cb_user_data, gpointer source_tag)
+return_async_error (const GError *error, GAsyncReadyCallback async_cb, gpointer async_cb_user_data, ESource *source, gpointer source_tag)
{
GSimpleAsyncResult *simple;
g_return_if_fail (error != NULL);
g_return_if_fail (source_tag != NULL);
- simple = g_simple_async_result_new (NULL, async_cb, async_cb_user_data, source_tag);
+ simple = g_simple_async_result_new (G_OBJECT (source), async_cb, async_cb_user_data, source_tag);
g_simple_async_result_set_from_error (simple, error);
g_object_set_data (G_OBJECT (simple), "run-main-depth", GINT_TO_POINTER (g_main_depth ()));
if (async_data->auth_handler)
g_signal_connect (async_data->client, "authenticate", G_CALLBACK (async_data->auth_handler), async_data->auth_handler_user_data);
- simple = g_simple_async_result_new (NULL, async_data->async_cb, async_data->async_cb_user_data, e_client_utils_open_new);
+ simple = g_simple_async_result_new (G_OBJECT (async_data->source), async_data->async_cb, async_data->async_cb_user_data, e_client_utils_open_new);
g_simple_async_result_set_op_res_gpointer (simple, g_object_ref (async_data->client), g_object_unref);
g_object_set_data (G_OBJECT (simple), "run-main-depth", GINT_TO_POINTER (g_main_depth ()));
g_return_if_fail (async_data->cancellable == cancellable);
g_return_if_fail (g_cancellable_set_error_if_cancelled (cancellable, &error));
- return_async_error (error, async_data->async_cb, async_data->async_cb_user_data, e_client_utils_open_new);
+ return_async_error (error, async_data->async_cb, async_data->async_cb_user_data, async_data->source, e_client_utils_open_new);
free_client_utils_async_op_data (async_data);
g_error_free (error);
}
e_client_process_authentication (async_data->client, async_data->used_credentials);
} else if (error) {
- return_async_error (error, async_data->async_cb, async_data->async_cb_user_data, e_client_utils_open_new);
+ return_async_error (error, async_data->async_cb, async_data->async_cb_user_data, async_data->source, e_client_utils_open_new);
free_client_utils_async_op_data (async_data);
} else {
client_utils_open_new_done (async_data);
* @source: an #ESource to be opened
* @source_type: an #EClientSourceType of the @source
* @only_if_exists: if %TRUE, fail if this client doesn't already exist, otherwise create it first
+ * @cancellable: a #GCancellable; can be %NULL
* @auth_handler: authentication handler, to be used; the e_client_utils_authenticate_handler() is usually sufficient
* @auth_handler_user_data: user data for @auth_handler function
- * @cancellable: a #GCancellable; can be %NULL
* @async_cb: callback to call when a result is ready
* @async_cb_user_data: user data for the @async_cb
*
* Since: 3.2
**/
void
-e_client_utils_open_new (ESource *source, EClientSourceType source_type, gboolean only_if_exists,
+e_client_utils_open_new (ESource *source, EClientSourceType source_type, gboolean only_if_exists, GCancellable *cancellable,
EClientUtilsAuthenticateHandler auth_handler, gpointer auth_handler_user_data,
- GCancellable *cancellable, GAsyncReadyCallback async_cb, gpointer async_cb_user_data)
+ GAsyncReadyCallback async_cb, gpointer async_cb_user_data)
{
EClient *client;
GError *error = NULL;
EClientUtilsAsyncOpData *async_data;
g_return_if_fail (async_cb != NULL);
- return_async_error_if_fail (source != NULL, async_cb, async_cb_user_data, e_client_utils_open_new);
- return_async_error_if_fail (E_IS_SOURCE (source), async_cb, async_cb_user_data, e_client_utils_open_new);
+ return_async_error_if_fail (source != NULL, async_cb, async_cb_user_data, source, e_client_utils_open_new);
+ return_async_error_if_fail (E_IS_SOURCE (source), async_cb, async_cb_user_data, source, e_client_utils_open_new);
client = e_client_utils_new (source, source_type, &error);
if (!client) {
- return_async_error (error, async_cb, async_cb_user_data, e_client_utils_open_new);
+ return_async_error (error, async_cb, async_cb_user_data, source, e_client_utils_open_new);
g_error_free (error);
return;
}
async_data->auth_handler_user_data = auth_handler_user_data;
async_data->async_cb = async_cb;
async_data->async_cb_user_data = async_cb_user_data;
+ async_data->source = g_object_ref (source);
async_data->client = client;
async_data->open_finished = FALSE;
if (cancellable)
/**
* e_client_utils_open_new_finish:
+ * @source: an #ESource on which the e_client_utils_open_new() was invoked
* @result: a #GAsyncResult
- * @client: (out): Return value for an #EClient.
+ * @client: (out): Return value for an #EClient
* @error: (out): a #GError to set an error, if any
*
* Finishes previous call of e_client_utils_open_new() and
* Since: 3.2
**/
gboolean
-e_client_utils_open_new_finish (GAsyncResult *result, EClient **client, GError **error)
+e_client_utils_open_new_finish (ESource *source, GAsyncResult *result, EClient **client, GError **error)
{
GSimpleAsyncResult *simple;
+ g_return_val_if_fail (source != NULL, FALSE);
g_return_val_if_fail (result != NULL, FALSE);
g_return_val_if_fail (client != NULL, FALSE);
- g_return_val_if_fail (g_simple_async_result_is_valid (result, NULL, e_client_utils_open_new), FALSE);
+ g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (source), e_client_utils_open_new), FALSE);
*client = NULL;
simple = G_SIMPLE_ASYNC_RESULT (result);
return *client != NULL;
}
+/* free returned pointer with g_free() */
+static gchar *
+get_auth_domain (EClient *client)
+{
+ ESource *source;
+ const gchar *auth_domain;
+
+ g_return_val_if_fail (client != NULL, NULL);
+
+ source = e_client_get_source (client);
+ g_return_val_if_fail (source != NULL, NULL);
+
+ auth_domain = e_source_get_property (source, "auth-domain");
+ if (auth_domain && *auth_domain)
+ return g_strdup (auth_domain);
+
+ if (E_IS_BOOK_CLIENT (client))
+ return g_strdup (E_CREDENTIALS_AUTH_DOMAIN_ADDRESSBOOK);
+ if (E_IS_CAL_CLIENT (client))
+ return g_strdup (E_CREDENTIALS_AUTH_DOMAIN_CALENDAR);
+
+ g_return_val_if_reached (NULL);
+}
+
+/* free returned pointer with g_free() */
+static gchar *
+get_prompt_key (EClient *client, const gchar *user_name)
+{
+ SoupURI *suri;
+ gchar *uri_str;
+
+ g_return_val_if_fail (client != NULL, NULL);
+
+ suri = soup_uri_new (e_client_get_uri (client));
+ g_return_val_if_fail (suri != NULL, NULL);
+
+ soup_uri_set_user (suri, user_name);
+ soup_uri_set_password (suri, NULL);
+ soup_uri_set_fragment (suri, NULL);
+
+ uri_str = soup_uri_to_string (suri, FALSE);
+ soup_uri_free (suri);
+
+ return uri_str;
+}
+
/* This function is suitable as a handler for EClient::authenticate signal.
It takes care of all the password prompt and such and returns TRUE if
credentials (password) were provided. Thus just connect it to that signal
and it'll take care of everything else.
+
+ gtk_window_parent is user_data passed into the callback. It can be a pointer
+ to GtkWindow, used as a parent for a pasword prompt dialog.
*/
gboolean
-e_client_utils_authenticate_handler (EClient *client, ECredentials *credentials, gpointer unused_user_data)
+e_client_utils_authenticate_handler (EClient *client, ECredentials *credentials, gpointer gtk_window_parent)
{
ESource *source;
gboolean is_book, is_cal, res, remember_password = FALSE;
return FALSE;
}
- if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN))
- e_credentials_set (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN, is_book ? E_CREDENTIALS_AUTH_DOMAIN_ADDRESSBOOK : E_CREDENTIALS_AUTH_DOMAIN_CALENDAR);
+ if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN)) {
+ gchar *auth_domain = get_auth_domain (client);
+
+ e_credentials_set (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN, auth_domain);
+
+ g_free (auth_domain);
+ }
+
+ if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_KEY)) {
+ gchar *prompt_key = get_prompt_key (client, e_credentials_peek (credentials, E_CREDENTIALS_KEY_USERNAME));
+
+ e_credentials_set (credentials, E_CREDENTIALS_KEY_PROMPT_KEY, prompt_key);
+
+ g_free (prompt_key);
+ }
if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_TEXT)) {
gchar *prompt, *reason;
g_free (prompt);
}
- if (!e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_KEY)) {
- SoupURI *suri;
- gchar *uri_str;
-
- suri = soup_uri_new (e_client_get_uri (client));
- g_return_val_if_fail (suri != NULL, FALSE);
-
- soup_uri_set_user (suri, e_credentials_peek (credentials, E_CREDENTIALS_KEY_USERNAME));
- soup_uri_set_password (suri, NULL);
- soup_uri_set_fragment (suri, NULL);
-
- uri_str = soup_uri_to_string (suri, FALSE);
-
- e_credentials_set (credentials, E_CREDENTIALS_KEY_PROMPT_KEY, uri_str);
-
- g_free (uri_str);
- soup_uri_free (suri);
- }
-
remember_password = g_strcmp0 (e_source_get_property (source, "remember_password"), "true") == 0;
- res = e_credentials_authenticate_helper (credentials, NULL, &remember_password);
+ res = e_credentials_authenticate_helper (credentials, gtk_window_parent, &remember_password);
if (res)
e_source_set_property (source, "remember_password", remember_password ? "true" : NULL);
return res;
}
+/**
+ * e_client_utils_forget_password:
+ * @client: An #EClient
+ *
+ * Forgets stored password for the given @client.
+ *
+ * Since: 3.2
+ **/
+void
+e_client_utils_forget_password (EClient *client)
+{
+ gchar *auth_domain, *prompt_key;
+ ESource *source;
+
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (E_IS_CLIENT (client));
+
+ source = e_client_get_source (client);
+ g_return_if_fail (source != NULL);
+
+ auth_domain = get_auth_domain (client);
+ prompt_key = get_prompt_key (client, e_source_get_property (source, "username"));
+
+ e_passwords_forget_password (auth_domain, prompt_key);
+
+ g_free (auth_domain);
+ g_free (prompt_key);
+}
+
/* Asks for a password based on the provided credentials information.
Credentials should have set following keys:
E_CREDENTIALS_KEY_USERNAME
E_CREDENTIALS_KEY_AUTH_DOMAIN
- E_CREDENTIALS_KEY_PROMPT_TEXT
E_CREDENTIALS_KEY_PROMPT_KEY
+ E_CREDENTIALS_KEY_PROMPT_TEXT
all other keys are optional. If also E_CREDENTIALS_KEY_PASSWORD key is provided,
then it implies a reprompt.
g_return_val_if_fail (credentials != NULL, FALSE);
g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_USERNAME), FALSE);
g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN), FALSE);
- g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_TEXT), FALSE);
g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_KEY), FALSE);
+ g_return_val_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_TEXT), FALSE);
if (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_FLAGS)) {
prompt_flags = e_credentials_util_string_to_prompt_flags (e_credentials_peek (credentials, E_CREDENTIALS_KEY_PROMPT_FLAGS));
return res;
}
+
+/**
+ * e_credentials_forget_password:
+ * @credentials: an #ECredentials
+ *
+ * Forgets stored password for given @credentials, which should contain
+ * E_CREDENTIALS_KEY_AUTH_DOMAIN and E_CREDENTIALS_KEY_PROMPT_KEY.
+ *
+ * Since: 3.2
+ **/
+void
+e_credentials_forget_password (const ECredentials *credentials)
+{
+ gchar *auth_domain, *prompt_key;
+
+ g_return_if_fail (credentials != NULL);
+ g_return_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN));
+ g_return_if_fail (e_credentials_has_key (credentials, E_CREDENTIALS_KEY_PROMPT_KEY));
+
+ auth_domain = e_credentials_get (credentials, E_CREDENTIALS_KEY_AUTH_DOMAIN);
+ prompt_key = e_credentials_get (credentials, E_CREDENTIALS_KEY_PROMPT_KEY);
+
+ e_passwords_forget_password (auth_domain, prompt_key);
+
+ g_free (auth_domain);
+ g_free (prompt_key);
+}
gboolean e_client_utils_set_default_source (ESource *source, EClientSourceType source_type, GError **error);
gboolean e_client_utils_get_sources (ESourceList **sources, EClientSourceType source_type, GError **error);
-void e_client_utils_open_new (ESource *source, EClientSourceType source_type, gboolean only_if_exists,
+void e_client_utils_open_new (ESource *source, EClientSourceType source_type, gboolean only_if_exists, GCancellable *cancellable,
EClientUtilsAuthenticateHandler auth_handler, gpointer auth_handler_user_data,
- GCancellable *cancellable, GAsyncReadyCallback async_cb, gpointer async_cb_user_data);
-gboolean e_client_utils_open_new_finish (GAsyncResult *result, EClient **client, GError **error);
+ GAsyncReadyCallback async_cb, gpointer async_cb_user_data);
+gboolean e_client_utils_open_new_finish (ESource *source, GAsyncResult *result, EClient **client, GError **error);
+
+gboolean e_client_utils_authenticate_handler (EClient *client, ECredentials *credentials, gpointer gtk_window_parent);
+void e_client_utils_forget_password (EClient *client);
-gboolean e_client_utils_authenticate_handler (EClient *client, ECredentials *credentials, gpointer unused_user_data);
gboolean e_credentials_authenticate_helper (ECredentials *credentials, GtkWindow *parent, gboolean *remember_password);
+void e_credentials_forget_password (const ECredentials *credentials);
G_END_DECLS
GArray *contact_sources;
};
+/* Signals */
+
+enum {
+ START_CLIENT_VIEW,
+ STOP_CLIENT_VIEW,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
static void e_contact_store_tree_model_init (GtkTreeModelIface *iface);
G_DEFINE_TYPE_WITH_CODE (
typedef struct
{
- EBook *book;
+ EBookClient *book_client;
- EBookView *book_view;
+ EBookClientView *client_view;
GPtrArray *contacts;
- EBookView *book_view_pending;
+ EBookClientView *client_view_pending;
GPtrArray *contacts_pending;
}
ContactSource;
static void free_contact_ptrarray (GPtrArray *contacts);
static void clear_contact_source (EContactStore *contact_store, ContactSource *source);
-static void stop_view (EContactStore *contact_store, EBookView *view);
+static void stop_view (EContactStore *contact_store, EBookClientView *view);
static void
contact_store_dispose (GObject *object)
clear_contact_source (E_CONTACT_STORE (object), source);
free_contact_ptrarray (source->contacts);
- g_object_unref (source->book);
+ g_object_unref (source->book_client);
}
g_array_set_size (priv->contact_sources, 0);
object_class = G_OBJECT_CLASS (class);
object_class->dispose = contact_store_dispose;
object_class->finalize = contact_store_finalize;
+
+ signals[START_CLIENT_VIEW] =
+ g_signal_new ("start-client-view",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EContactStoreClass, start_client_view),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, E_TYPE_BOOK_CLIENT_VIEW);
+
+ signals[STOP_CLIENT_VIEW] =
+ g_signal_new ("stop-client-view",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EContactStoreClass, stop_client_view),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE, 1, E_TYPE_BOOK_CLIENT_VIEW);
}
static void
* ---------------------- */
static gint
-find_contact_source_by_book (EContactStore *contact_store, EBook *book)
+find_contact_source_by_client (EContactStore *contact_store, EBookClient *book_client)
{
GArray *array;
gint i;
ContactSource *source;
source = &g_array_index (array, ContactSource, i);
- if (source->book == book)
+ if (source->book_client == book_client)
return i;
}
return -1;
}
-EBookView *
-find_contact_source_by_book_return_view (EContactStore *contact_store, EBook *book)
-{
- ContactSource *source = NULL;
- GArray *array;
- gint i;
-
- array = contact_store->priv->contact_sources;
-
- for (i = 0; i < array->len; i++) {
- source = &g_array_index (array, ContactSource, i);
- if (source->book == book)
- break;
- }
- return source->book_view;;
-}
-
static gint
-find_contact_source_by_view (EContactStore *contact_store, EBookView *book_view)
+find_contact_source_by_view (EContactStore *contact_store, EBookClientView *client_view)
{
GArray *array;
gint i;
ContactSource *source;
source = &g_array_index (array, ContactSource, i);
- if (source->book_view == book_view ||
- source->book_view_pending == book_view)
+ if (source->client_view == client_view ||
+ source->client_view_pending == client_view)
return i;
}
}
static gint
-find_contact_by_view_and_uid (EContactStore *contact_store, EBookView *find_view, const gchar *find_uid)
+find_contact_by_view_and_uid (EContactStore *contact_store, EBookClientView *find_view, const gchar *find_uid)
{
GArray *array;
ContactSource *source;
array = contact_store->priv->contact_sources;
source = &g_array_index (array, ContactSource, source_index);
- if (find_view == source->book_view)
+ if (find_view == source->client_view)
contacts = source->contacts; /* Current view */
else
contacts = source->contacts_pending; /* Pending view */
return -1;
}
-static EBook *
+static EBookClient *
get_book_at_row (EContactStore *contact_store, gint row)
{
GArray *array;
array = contact_store->priv->contact_sources;
source = &g_array_index (array, ContactSource, source_index);
- return source->book;
+ return source->book_client;
}
static EContact *
}
static gboolean
-find_contact_source_details_by_view (EContactStore *contact_store, EBookView *book_view,
+find_contact_source_details_by_view (EContactStore *contact_store, EBookClientView *client_view,
ContactSource **contact_source, gint *offset)
{
GArray *array;
gint source_index;
- source_index = find_contact_source_by_view (contact_store, book_view);
+ source_index = find_contact_source_by_view (contact_store, client_view);
if (source_index < 0)
return FALSE;
* ------------------------- */
static void
-view_contacts_added (EContactStore *contact_store, const GList *contacts, EBookView *book_view)
+view_contacts_added (EContactStore *contact_store, const GSList *contacts, EBookClientView *client_view)
{
ContactSource *source;
gint offset;
- const GList *l;
+ const GSList *l;
- if (!find_contact_source_details_by_view (contact_store, book_view, &source, &offset)) {
+ if (!find_contact_source_details_by_view (contact_store, client_view, &source, &offset)) {
g_warning ("EContactStore got 'contacts_added' signal from unknown EBookView!");
return;
}
- for (l = contacts; l; l = g_list_next (l)) {
+ for (l = contacts; l; l = g_slist_next (l)) {
EContact *contact = l->data;
g_object_ref (contact);
- if (book_view == source->book_view) {
+ if (client_view == source->client_view) {
/* Current view */
g_ptr_array_add (source->contacts, contact);
row_inserted (contact_store, offset + source->contacts->len - 1);
}
static void
-view_contacts_removed (EContactStore *contact_store, const GList *uids, EBookView *book_view)
+view_contacts_removed (EContactStore *contact_store, const GSList *uids, EBookClientView *client_view)
{
ContactSource *source;
gint offset;
- const GList *l;
+ const GSList *l;
- if (!find_contact_source_details_by_view (contact_store, book_view, &source, &offset)) {
+ if (!find_contact_source_details_by_view (contact_store, client_view, &source, &offset)) {
g_warning ("EContactStore got 'contacts_removed' signal from unknown EBookView!");
return;
}
- for (l = uids; l; l = g_list_next (l)) {
+ for (l = uids; l; l = g_slist_next (l)) {
const gchar *uid = l->data;
- gint n = find_contact_by_view_and_uid (contact_store, book_view, uid);
+ gint n = find_contact_by_view_and_uid (contact_store, client_view, uid);
EContact *contact;
if (n < 0) {
continue;
}
- if (book_view == source->book_view) {
+ if (client_view == source->client_view) {
/* Current view */
contact = g_ptr_array_index (source->contacts, n);
g_object_unref (contact);
}
static void
-view_contacts_changed (EContactStore *contact_store, const GList *contacts, EBookView *book_view)
+view_contacts_modified (EContactStore *contact_store, const GSList *contacts, EBookClientView *client_view)
{
GPtrArray *cached_contacts;
ContactSource *source;
gint offset;
- const GList *l;
+ const GSList *l;
- if (!find_contact_source_details_by_view (contact_store, book_view, &source, &offset)) {
+ if (!find_contact_source_details_by_view (contact_store, client_view, &source, &offset)) {
g_warning ("EContactStore got 'contacts_changed' signal from unknown EBookView!");
return;
}
- if (book_view == source->book_view)
+ if (client_view == source->client_view)
cached_contacts = source->contacts;
else
cached_contacts = source->contacts_pending;
- for (l = contacts; l; l = g_list_next (l)) {
+ for (l = contacts; l; l = g_slist_next (l)) {
EContact *cached_contact;
EContact *contact = l->data;
const gchar *uid = e_contact_get_const (contact, E_CONTACT_UID);
- gint n = find_contact_by_view_and_uid (contact_store, book_view, uid);
+ gint n = find_contact_by_view_and_uid (contact_store, client_view, uid);
if (n < 0) {
g_warning ("EContactStore got change notification on unknown contact!");
}
/* Emit changes for current view only */
- if (book_view == source->book_view)
+ if (client_view == source->client_view)
row_changed (contact_store, offset + n);
}
}
static void
-view_complete (EContactStore *contact_store, EBookViewStatus status, const gchar *error_msg, EBookView *book_view)
+view_complete (EContactStore *contact_store, const GError *error, EBookClientView *client_view)
{
ContactSource *source;
gint offset;
gint i;
- if (!find_contact_source_details_by_view (contact_store, book_view, &source, &offset)) {
- g_warning ("EContactStore got 'sequence_complete' signal from unknown EBookView!");
+ if (!find_contact_source_details_by_view (contact_store, client_view, &source, &offset)) {
+ g_warning ("EContactStore got 'complete' signal from unknown EBookClientView!");
return;
}
/* If current view finished, do nothing */
- if (book_view == source->book_view) {
- stop_view (contact_store, source->book_view);
+ if (client_view == source->client_view) {
+ stop_view (contact_store, source->client_view);
return;
}
- g_assert (book_view == source->book_view_pending);
+ g_assert (client_view == source->client_view_pending);
/* However, if it was a pending view, calculate and emit the differences between that
* and the current view, and move the pending view up to current.
const gchar *old_uid = e_contact_get_const (old_contact, E_CONTACT_UID);
gint result;
- result = find_contact_by_view_and_uid (contact_store, source->book_view_pending, old_uid);
+ result = find_contact_by_view_and_uid (contact_store, source->client_view_pending, old_uid);
if (result < 0) {
/* Contact is not in new view; removed */
g_object_unref (old_contact);
const gchar *new_uid = e_contact_get_const (new_contact, E_CONTACT_UID);
gint result;
- result = find_contact_by_view_and_uid (contact_store, source->book_view, new_uid);
+ result = find_contact_by_view_and_uid (contact_store, source->client_view, new_uid);
if (result < 0) {
/* Contact is not in old view; inserted */
g_ptr_array_add (source->contacts, new_contact);
}
/* Move pending view up to current */
- stop_view (contact_store, source->book_view);
- g_object_unref (source->book_view);
- source->book_view = source->book_view_pending;
- source->book_view_pending = NULL;
+ stop_view (contact_store, source->client_view);
+ g_object_unref (source->client_view);
+ source->client_view = source->client_view_pending;
+ source->client_view_pending = NULL;
/* Free array of pending contacts (members have been either moved or unreffed) */
g_ptr_array_free (source->contacts_pending, TRUE);
* --------------------- */
static void
-start_view (EContactStore *contact_store, EBookView *view)
+start_view (EContactStore *contact_store, EBookClientView *view)
{
- g_signal_connect_swapped (view, "contacts_added",
+ g_signal_emit (contact_store, signals[START_CLIENT_VIEW], 0, view);
+
+ g_signal_connect_swapped (view, "objects-added",
G_CALLBACK (view_contacts_added), contact_store);
- g_signal_connect_swapped (view, "contacts_removed",
+ g_signal_connect_swapped (view, "objects-removed",
G_CALLBACK (view_contacts_removed), contact_store);
- g_signal_connect_swapped (view, "contacts_changed",
- G_CALLBACK (view_contacts_changed), contact_store);
- g_signal_connect_swapped (view, "view_complete",
+ g_signal_connect_swapped (view, "objects-modified",
+ G_CALLBACK (view_contacts_modified), contact_store);
+ g_signal_connect_swapped (view, "complete",
G_CALLBACK (view_complete), contact_store);
- e_book_view_start (view);
+ e_book_client_view_start (view, NULL);
}
static void
-stop_view (EContactStore *contact_store, EBookView *view)
+stop_view (EContactStore *contact_store, EBookClientView *view)
{
- e_book_view_stop (view);
+ e_book_client_view_stop (view, NULL);
g_signal_handlers_disconnect_matched (view, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, contact_store);
+
+ g_signal_emit (contact_store, signals[STOP_CLIENT_VIEW], 0, view);
}
static void
/* Free main and pending views, clear cached contacts */
- if (source->book_view) {
- stop_view (contact_store, source->book_view);
- g_object_unref (source->book_view);
+ if (source->client_view) {
+ stop_view (contact_store, source->client_view);
+ g_object_unref (source->client_view);
- source->book_view = NULL;
+ source->client_view = NULL;
}
- if (source->book_view_pending) {
- stop_view (contact_store, source->book_view_pending);
- g_object_unref (source->book_view_pending);
+ if (source->client_view_pending) {
+ stop_view (contact_store, source->client_view_pending);
+ g_object_unref (source->client_view_pending);
free_contact_ptrarray (source->contacts_pending);
- source->book_view_pending = NULL;
+ source->client_view_pending = NULL;
source->contacts_pending = NULL;
}
}
static void
+client_view_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data)
+{
+ EContactStore *contact_store = user_data;
+ gint source_idx;
+ EBookClient *book_client;
+ EBookClientView *client_view = NULL;
+
+ g_return_if_fail (contact_store != NULL);
+ g_return_if_fail (source_object != NULL);
+
+ book_client = E_BOOK_CLIENT (source_object);
+ g_return_if_fail (book_client != NULL);
+
+ if (!e_book_client_get_view_finish (book_client, result, &client_view, NULL))
+ client_view = NULL;
+
+ source_idx = find_contact_source_by_client (contact_store, book_client);
+ if (source_idx >= 0) {
+ ContactSource *source;
+
+ source = &g_array_index (contact_store->priv->contact_sources, ContactSource, source_idx);
+
+ if (source->client_view) {
+ if (source->client_view_pending) {
+ stop_view (contact_store, source->client_view_pending);
+ g_object_unref (source->client_view_pending);
+ free_contact_ptrarray (source->contacts_pending);
+ }
+
+ source->client_view_pending = client_view;
+
+ if (source->client_view_pending) {
+ source->contacts_pending = g_ptr_array_new ();
+ start_view (contact_store, client_view);
+ } else {
+ source->contacts_pending = NULL;
+ }
+ } else {
+ source->client_view = client_view;
+
+ if (source->client_view) {
+ start_view (contact_store, client_view);
+ }
+ }
+ }
+
+ g_object_unref (contact_store);
+}
+
+static void
query_contact_source (EContactStore *contact_store, ContactSource *source)
{
- EBookView *view;
+ gboolean is_opened;
- g_assert (source->book != NULL);
+ g_assert (source->book_client != NULL);
if (!contact_store->priv->query) {
clear_contact_source (contact_store, source);
return;
}
- if (!e_book_is_opened (source->book) ||
- !e_book_get_book_view (source->book, contact_store->priv->query, NULL, -1, &view, NULL))
- view = NULL;
+ is_opened = e_client_is_opened (E_CLIENT (source->book_client));
- if (source->book_view) {
- if (source->book_view_pending) {
- stop_view (contact_store, source->book_view_pending);
- g_object_unref (source->book_view_pending);
+ if (source->client_view) {
+ if (source->client_view_pending) {
+ stop_view (contact_store, source->client_view_pending);
+ g_object_unref (source->client_view_pending);
free_contact_ptrarray (source->contacts_pending);
- }
-
- source->book_view_pending = view;
-
- if (source->book_view_pending) {
- source->contacts_pending = g_ptr_array_new ();
- start_view (contact_store, view);
- } else {
+ source->client_view_pending = NULL;
source->contacts_pending = NULL;
}
- } else {
- source->book_view = view;
+ }
- if (source->book_view) {
- start_view (contact_store, view);
- }
+ if (is_opened) {
+ gchar *query_str;
+
+ query_str = e_book_query_to_string (contact_store->priv->query);
+ e_book_client_get_view (source->book_client, query_str, NULL, client_view_ready_cb, g_object_ref (contact_store));
+ g_free (query_str);
}
}
* ----------------- */
/**
- * e_contact_store_get_book:
+ * e_contact_store_get_client:
* @contact_store: an #EContactStore
* @iter: a #GtkTreeIter from @contact_store
*
- * Gets the #EBook that provided the contact at @iter.
+ * Gets the #EBookClient that provided the contact at @iter.
*
- * Returns: An #EBook.
+ * Returns: An #EBookClient.
**/
-EBook *
-e_contact_store_get_book (EContactStore *contact_store, GtkTreeIter *iter)
+EBookClient *
+e_contact_store_get_client (EContactStore *contact_store, GtkTreeIter *iter)
{
gint index;
}
/**
- * e_contact_store_get_books:
+ * e_contact_store_get_clients:
* @contact_store: an #EContactStore
*
- * Gets the list of books that provide contacts for @contact_store.
+ * Gets the list of book clients that provide contacts for @contact_store.
*
- * Returns: A #GList of pointers to #EBook. The caller owns the list,
- * but not the books.
+ * Returns: A #GSList of pointers to #EBookClient. The caller owns the list,
+ * but not the book clients.
**/
-GList *
-e_contact_store_get_books (EContactStore *contact_store)
+GSList *
+e_contact_store_get_clients (EContactStore *contact_store)
{
GArray *array;
- GList *book_list = NULL;
+ GSList *client_list = NULL;
gint i;
g_return_val_if_fail (E_IS_CONTACT_STORE (contact_store), NULL);
ContactSource *source;
source = &g_array_index (array, ContactSource, i);
- book_list = g_list_prepend (book_list, source->book);
+ client_list = g_slist_prepend (client_list, source->book_client);
}
- return book_list;
+ return client_list;
}
/**
- * e_contact_store_add_book:
+ * e_contact_store_add_client:
* @contact_store: an #EContactStore
- * @book: an #EBook
+ * @book_client: an #EBookClient
*
- * Adds @book to the list of books that provide contacts for @contact_store.
+ * Adds @book_client to the list of book clients that provide contacts for @contact_store.
+ * The @contact_store adds a reference to @book_client, if added.
**/
void
-e_contact_store_add_book (EContactStore *contact_store, EBook *book)
+e_contact_store_add_client (EContactStore *contact_store, EBookClient *book_client)
{
GArray *array;
ContactSource source;
ContactSource *indexed_source;
g_return_if_fail (E_IS_CONTACT_STORE (contact_store));
- g_return_if_fail (E_IS_BOOK (book));
+ g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
- if (find_contact_source_by_book (contact_store, book) >= 0) {
- g_warning ("Same book added more than once to EContactStore!");
+ if (find_contact_source_by_client (contact_store, book_client) >= 0) {
+ g_warning ("Same book client added more than once to EContactStore!");
return;
}
array = contact_store->priv->contact_sources;
memset (&source, 0, sizeof (ContactSource));
- source.book = g_object_ref (book);
+ source.book_client = g_object_ref (book_client);
source.contacts = g_ptr_array_new ();
g_array_append_val (array, source);
}
/**
- * e_contact_store_remove_book:
+ * e_contact_store_remove_client:
* @contact_store: an #EContactStore
- * @book: an #EBook
+ * @book_client: an #EBookClient
*
- * Removes @book from the list of books that provide contacts for @contact_store.
+ * Removes @book from the list of book clients that provide contacts for @contact_store.
**/
void
-e_contact_store_remove_book (EContactStore *contact_store, EBook *book)
+e_contact_store_remove_client (EContactStore *contact_store, EBookClient *book_client)
{
GArray *array;
ContactSource *source;
gint source_index;
g_return_if_fail (E_IS_CONTACT_STORE (contact_store));
- g_return_if_fail (E_IS_BOOK (book));
+ g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
- source_index = find_contact_source_by_book (contact_store, book);
+ source_index = find_contact_source_by_client (contact_store, book_client);
if (source_index < 0) {
- g_warning ("Tried to remove unknown book from EContactStore!");
+ g_warning ("Tried to remove unknown book client from EContactStore!");
return;
}
source = &g_array_index (array, ContactSource, source_index);
clear_contact_source (contact_store, source);
free_contact_ptrarray (source->contacts);
- g_object_unref (book);
+ g_object_unref (book_client);
g_array_remove_index (array, source_index); /* Preserve order */
}
#include <gtk/gtk.h>
#include <libebook/e-contact.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-client-view.h>
#include <libebook/e-book-query.h>
-#include <libebook/e-book-types.h>
/* Standard GObject macros */
#define E_TYPE_CONTACT_STORE \
struct _EContactStoreClass {
GObjectClass parent_class;
+
+ /* signals */
+ void (*start_client_view) (EContactStore *contact_store, EBookClientView *client_view);
+ void (*stop_client_view) (EContactStore *contact_store, EBookClientView *client_view);
};
GType e_contact_store_get_type (void);
EContactStore * e_contact_store_new (void);
-EBook * e_contact_store_get_book (EContactStore *contact_store,
+EBookClient * e_contact_store_get_client (EContactStore *contact_store,
GtkTreeIter *iter);
EContact * e_contact_store_get_contact (EContactStore *contact_store,
GtkTreeIter *iter);
GtkTreeIter *iter);
/* Returns a shallow copy; free the list when done, but don't unref elements */
-GList * e_contact_store_get_books (EContactStore *contact_store);
-void e_contact_store_add_book (EContactStore *contact_store,
- EBook *book);
-void e_contact_store_remove_book (EContactStore *contact_store,
- EBook *book);
+GSList * e_contact_store_get_clients (EContactStore *contact_store);
+void e_contact_store_add_client (EContactStore *contact_store,
+ EBookClient *book_client);
+void e_contact_store_remove_client (EContactStore *contact_store,
+ EBookClient *book_client);
void e_contact_store_set_query (EContactStore *contact_store,
EBookQuery *book_query);
EBookQuery * e_contact_store_peek_query (EContactStore *contact_store);
-EBookView * find_contact_source_by_book_return_view
- (EContactStore *contact_store,
- EBook *book);
G_END_DECLS
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n-lib.h>
#include <gconf/gconf-client.h>
-#include <libedataserverui/e-source-combo-box.h>
-#include <libedataserverui/e-destination-store.h>
-#include <libedataserverui/e-contact-store.h>
-#include <libedataserverui/e-book-auth-util.h>
-#include "libedataserver/e-sexp.h"
-#include "libedataserver/e-categories.h"
-#include "libedataserver/libedataserver-private.h"
+
+#include <libedataserver/e-sexp.h>
+#include <libedataserver/e-categories.h>
+
+#include <libebook/e-book-client.h>
+#include <libebook/e-book-client-view.h>
+#include <libebook/e-book-query.h>
+
+#include "e-source-combo-box.h"
+#include "e-destination-store.h"
+#include "e-contact-store.h"
+#include "e-client-utils.h"
#include "e-name-selector-dialog.h"
#include "e-name-selector-entry.h"
/* Get addressbook sources */
- if (!e_book_get_addressbooks (&source_list, NULL)) {
+ if (!e_book_client_get_sources (&source_list, NULL)) {
g_warning ("ENameSelectorDialog can't find any addressbooks!");
return;
}
}
static void
-add_destination (ENameSelectorModel *name_selector_model, EDestinationStore *destination_store, EContact *contact, gint email_n)
+add_destination (ENameSelectorModel *name_selector_model, EDestinationStore *destination_store, EContact *contact, gint email_n, EBookClient *client)
{
EDestination *destination;
GList *email_list, *nth;
destination = e_destination_new ();
e_destination_set_contact (destination, contact, email_n);
+ if (client)
+ e_destination_set_client (destination, client);
e_destination_store_append_destination (destination_store, destination);
g_object_unref (destination);
}
remove_books (ENameSelectorDialog *name_selector_dialog)
{
EContactStore *contact_store;
- GList *books;
- GList *l;
+ GSList *clients, *l;
if (!name_selector_dialog->priv->name_selector_model)
return;
name_selector_dialog->priv->name_selector_model);
/* Remove books (should be just one) being viewed */
- books = e_contact_store_get_books (contact_store);
- for (l = books; l; l = g_list_next (l)) {
- EBook *book = l->data;
- e_contact_store_remove_book (contact_store, book);
+ clients = e_contact_store_get_clients (contact_store);
+ for (l = clients; l; l = g_slist_next (l)) {
+ EBookClient *client = l->data;
+ e_contact_store_remove_client (contact_store, client);
}
- g_list_free (books);
+ g_slist_free (clients);
/* See if we have a book pending; stop loading it if so */
if (name_selector_dialog->priv->cancellable != NULL) {
* -------------------- */
static void
-status_message (EBookView *view, const gchar *message, ENameSelectorDialog *dialog)
+view_progress (EBookClientView *view, guint percent, const gchar *message, ENameSelectorDialog *dialog)
{
if (message == NULL)
gtk_label_set_text (dialog->priv->status_label, "");
}
static void
-view_complete (EBookView *view, EBookViewStatus status, const gchar *error_msg, ENameSelectorDialog *dialog)
+view_complete (EBookClientView *view, const GError *error, ENameSelectorDialog *dialog)
+{
+ view_progress (view, -1, NULL, dialog);
+}
+
+static void
+start_client_view_cb (EContactStore *store, EBookClientView *client_view, ENameSelectorDialog *name_selector_dialog)
+{
+ g_signal_connect (
+ client_view, "progress",
+ G_CALLBACK (view_progress), name_selector_dialog);
+
+ g_signal_connect (
+ client_view, "complete",
+ G_CALLBACK (view_complete), name_selector_dialog);
+}
+
+static void
+stop_client_view_cb (EContactStore *store, EBookClientView *client_view, ENameSelectorDialog *name_selector_dialog)
{
- status_message (view, NULL, dialog);
+ g_signal_handlers_disconnect_by_func (client_view, view_progress, name_selector_dialog);
+ g_signal_handlers_disconnect_by_func (client_view, view_complete, name_selector_dialog);
}
static void
-book_loaded_cb (ESource *source,
+book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- ENameSelectorDialog *name_selector_dialog)
+ gpointer user_data)
{
- EBook *book;
- EBookView *view;
+ ENameSelectorDialog *name_selector_dialog = user_data;
+ EClient *client = NULL;
+ EBookClient *book_client;
EContactStore *store;
ENameSelectorModel *model;
GError *error = NULL;
- book = e_load_book_source_finish (source, result, &error);
+ e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (book == NULL);
+ g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
}
name_selector_dialog->priv->status_label, message);
g_free (message);
- g_warn_if_fail (book == NULL);
+ g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
}
+ book_client = E_BOOK_CLIENT (client);
+ if (!book_client) {
+ g_warn_if_fail (book_client != NULL);
+ goto exit;
+ }
+
model = name_selector_dialog->priv->name_selector_model;
store = e_name_selector_model_peek_contact_store (model);
- e_contact_store_add_book (store, book);
-
- view = find_contact_source_by_book_return_view (store, book);
-
- g_signal_connect (
- view, "status-message",
- G_CALLBACK (status_message), name_selector_dialog);
-
- g_signal_connect (
- view, "view-complete",
- G_CALLBACK (view_complete), name_selector_dialog);
+ e_contact_store_add_client (store, book_client);
+ g_object_unref (book_client);
- g_object_unref (book);
-
-exit:
+ exit:
g_object_unref (name_selector_dialog);
}
name_selector_dialog->priv->cancellable = cancellable;
/* Start loading selected book */
- e_load_book_source_async (
- source, parent, cancellable,
- (GAsyncReadyCallback) book_loaded_cb,
- g_object_ref (name_selector_dialog));
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, cancellable,
+ e_client_utils_authenticate_handler, parent,
+ book_loaded_cb, g_object_ref (name_selector_dialog));
}
/* --------------- *
contact_store = e_name_selector_model_peek_contact_store (
name_selector_dialog->priv->name_selector_model);
e_contact_store_set_query (contact_store, book_query);
-
e_book_query_unref (book_query);
g_free (query_string);
add_destination (
name_selector_dialog->priv->name_selector_model,
- destination_store, contact, email_n);
+ destination_store, contact, email_n,
+ e_contact_store_get_client (contact_store, &iter));
}
static void
add_destination (
name_selector_dialog->priv->name_selector_model,
- destination_store, contact, email_n);
+ destination_store, contact, email_n,
+ e_contact_store_get_client (contact_store, &iter));
}
g_list_free (rows);
}
setup_name_selector_model (ENameSelectorDialog *name_selector_dialog)
{
ETreeModelGenerator *contact_filter;
+ EContactStore *contact_store;
GList *new_sections;
GList *l;
name_selector_dialog->priv->contact_view,
GTK_TREE_MODEL (name_selector_dialog->priv->contact_sort));
+ contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->priv->name_selector_model);
+ if (contact_store) {
+ g_signal_connect (contact_store, "start-client-view", G_CALLBACK (start_client_view_cb), name_selector_dialog);
+ g_signal_connect (contact_store, "stop-client-view", G_CALLBACK (stop_client_view_cb), name_selector_dialog);
+ }
+
/* Make sure UI is consistent */
search_changed (name_selector_dialog);
/* Free backend model */
if (name_selector_dialog->priv->name_selector_model) {
+ EContactStore *contact_store;
+
+ contact_store = e_name_selector_model_peek_contact_store (name_selector_dialog->priv->name_selector_model);
+ if (contact_store) {
+ g_signal_handlers_disconnect_by_func (contact_store, start_client_view_cb, name_selector_dialog);
+ g_signal_handlers_disconnect_by_func (contact_store, stop_client_view_cb, name_selector_dialog);
+ }
+
g_signal_handlers_disconnect_matched (
name_selector_dialog->priv->name_selector_model,
G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_dialog);
#define E_NAME_SELECTOR_DIALOG_H
#include <gtk/gtk.h>
-#include <libebook/e-book.h>
#include <libedataserverui/e-contact-store.h>
#include <libedataserverui/e-name-selector-model.h>
#include <gconf/gconf-client.h>
#include <camel/camel.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-contact.h>
#include <libebook/e-destination.h>
-#include <libedataserverui/e-book-auth-util.h>
+#include <libedataserverui/e-client-utils.h>
#include <libedataserver/e-sexp.h>
#include "e-name-selector-entry.h"
EDestination *popup_destination;
- gpointer (*contact_editor_func) (EBook *,
+ gpointer (*contact_editor_func) (EBookClient *,
EContact *,
gboolean,
gboolean);
gpointer (*contact_list_editor_func)
- (EBook *,
+ (EBookClient *,
EContact *,
gboolean,
gboolean);
static gboolean
find_existing_completion (ENameSelectorEntry *name_selector_entry, const gchar *cue_str,
- EContact **contact, gchar **text, EContactField *matched_field)
+ EContact **contact, gchar **text, EContactField *matched_field, EBookClient **book_client)
{
GtkTreeIter iter;
EContact *best_contact = NULL;
gint best_field_rank = G_MAXINT;
EContactField best_field = 0;
+ EBookClient *best_book_client = NULL;
g_assert (cue_str);
best_contact = current_contact;
best_field_rank = current_field_rank;
best_field = current_field;
+ best_book_client = e_contact_store_get_client (name_selector_entry->priv->contact_store, &iter);
}
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (name_selector_entry->priv->contact_store), &iter));
*text = build_textrep_for_contact (best_contact, best_field);
if (matched_field)
*matched_field = best_field;
+ if (book_client)
+ *book_client = best_book_client;
return TRUE;
}
type_ahead_complete (ENameSelectorEntry *name_selector_entry)
{
EContact *contact;
+ EBookClient *book_client = NULL;
EContactField matched_field;
EDestination *destination;
gint cursor_pos;
cue_str = get_entry_substring (name_selector_entry, range_start, range_end);
if (!find_existing_completion (name_selector_entry, cue_str, &contact,
- &textrep, &matched_field)) {
+ &textrep, &matched_field, &book_client)) {
g_free (cue_str);
return;
}
email_n = matched_field - E_CONTACT_FIRST_EMAIL_ID;
e_destination_set_contact (destination, contact, email_n);
+ if (book_client)
+ e_destination_set_client (destination, book_client);
generate_attribute_list (name_selector_entry);
}
GtkTreeIter *generator_iter)
{
EContact *contact;
+ EBookClient *book_client;
EDestination *destination;
gint cursor_pos;
GtkTreeIter contact_iter;
generator_iter);
contact = e_contact_store_get_contact (name_selector_entry->priv->contact_store, &contact_iter);
+ book_client = e_contact_store_get_client (name_selector_entry->priv->contact_store, &contact_iter);
cursor_pos = gtk_editable_get_position (GTK_EDITABLE (name_selector_entry));
/* Set the contact in the model's destination */
destination = find_destination_at_position (name_selector_entry, cursor_pos);
e_destination_set_contact (destination, contact, email_n);
+ if (book_client)
+ e_destination_set_client (destination, book_client);
sync_destination_at_position (name_selector_entry, cursor_pos, &cursor_pos);
g_signal_handlers_block_by_func (name_selector_entry, user_insert_text, name_selector_entry);
}
static void
-book_loaded_cb (ESource *source,
+book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- EContactStore *contact_store)
+ gpointer user_data)
{
- EBook *book;
+ EContactStore *contact_store = user_data;
+ ESource *source = E_SOURCE (source_object);
+ EBookClient *book_client;
+ EClient *client = NULL;
GError *error = NULL;
- book = e_load_book_source_finish (source, result, &error);
+ e_client_utils_open_new_finish (source, result, &client, &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
- g_warn_if_fail (book == NULL);
+ g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
}
if (error != NULL) {
g_warning ("%s", error->message);
- g_warn_if_fail (book == NULL);
+ g_warn_if_fail (client == NULL);
g_error_free (error);
goto exit;
}
- g_return_if_fail (E_IS_BOOK (book));
- e_contact_store_add_book (contact_store, book);
- g_object_unref (book);
+ book_client = E_BOOK_CLIENT (client);
+
+ g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
+ e_contact_store_add_client (contact_store, book_client);
+ g_object_unref (book_client);
-exit:
+ exit:
g_object_unref (contact_store);
}
&name_selector_entry->priv->cancellables,
cancellable);
- e_load_book_source_async (
- source, NULL, cancellable,
- (GAsyncReadyCallback) book_loaded_cb,
- g_object_ref (contact_store));
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, cancellable,
+ e_client_utils_authenticate_handler, NULL,
+ book_loaded_cb, g_object_ref (contact_store));
}
}
return FALSE;
}
-static EBook *
-find_book_by_contact (GList *books, const gchar *contact_uid)
+static EBookClient *
+find_client_by_contact (GSList *clients, const gchar *contact_uid, const gchar *source_uid)
{
- GList *l;
+ GSList *l;
+
+ if (source_uid && source_uid) {
+ /* this is much quicket than asking each client for an existence */
+ for (l = clients; l; l = g_slist_next (l)) {
+ EBookClient *client = l->data;
+ ESource *source = e_client_get_source (E_CLIENT (client));
+
+ if (!source)
+ continue;
- for (l = books; l; l = g_list_next (l)) {
- EBook *book = l->data;
+ if (g_strcmp0 (source_uid, e_source_peek_uid (source)) == 0)
+ return client;
+ }
+ }
+
+ for (l = clients; l; l = g_slist_next (l)) {
+ EBookClient *client = l->data;
EContact *contact = NULL;
gboolean result;
- result = e_book_get_contact (book, contact_uid, &contact, NULL);
+ result = e_book_client_get_contact_sync (client, contact_uid, &contact, NULL, NULL);
if (contact)
g_object_unref (contact);
if (result)
- return book;
+ return client;
}
return NULL;
EContact *contact;
gchar *contact_uid;
EDestination *destination;
- GList *books;
- EBook *book;
+ GSList *clients;
+ EBookClient *book_client;
gint email_num;
ENameSelectorEntry *name_selector_entry = E_NAME_SELECTOR_ENTRY (data);
destination = name_selector_entry->priv->popup_destination;
contact = e_destination_get_contact (destination);
- if (!contact)
+ if (!contact) {
+ g_object_unref (name_selector_entry);
return;
+ }
+
contact_uid = e_contact_get (contact, E_CONTACT_UID);
- if (!contact_uid)
+ if (!contact_uid) {
+ g_object_unref (contact);
+ g_object_unref (name_selector_entry);
return;
+ }
if (name_selector_entry->priv->contact_store) {
- books = e_contact_store_get_books (name_selector_entry->priv->contact_store);
- book = find_book_by_contact (books, contact_uid);
- g_list_free (books);
+ clients = e_contact_store_get_clients (name_selector_entry->priv->contact_store);
+ book_client = find_client_by_contact (clients, contact_uid, e_destination_get_source_uid (destination));
+ g_slist_free (clients);
} else {
- book = NULL;
+ book_client = NULL;
}
- if (!book)
- return;
- e_book_get_contact (book, contact_uid, &contact, NULL);
- email_num = e_destination_get_email_num (destination);
- e_destination_set_contact (destination, contact, email_num);
+ if (book_client) {
+ contact = NULL;
+
+ e_book_client_get_contact_sync (book_client, contact_uid, &contact, NULL, NULL);
+ email_num = e_destination_get_email_num (destination);
+ e_destination_set_contact (destination, contact, email_num);
+ e_destination_set_client (destination, book_client);
+ } else {
+ contact = NULL;
+ }
g_free (contact_uid);
- g_object_unref (contact);
+ if (contact)
+ g_object_unref (contact);
g_object_unref (name_selector_entry);
}
static void
popup_activate_contact (ENameSelectorEntry *name_selector_entry, GtkWidget *menu_item)
{
- EBook *book;
- GList *books;
+ EBookClient *book_client;
+ GSList *clients;
EDestination *destination;
EContact *contact;
gchar *contact_uid;
contact_uid = e_contact_get (contact, E_CONTACT_UID);
if (!contact_uid)
return;
+
if (name_selector_entry->priv->contact_store) {
- books = e_contact_store_get_books (name_selector_entry->priv->contact_store);
- /*FIXME: read URI from contact and get the book ?*/
- book = find_book_by_contact (books, contact_uid);
- g_list_free (books);
+ clients = e_contact_store_get_clients (name_selector_entry->priv->contact_store);
+ book_client = find_client_by_contact (clients, contact_uid, e_destination_get_source_uid (destination));
+ g_slist_free (clients);
g_free (contact_uid);
} else {
- book = NULL;
+ book_client = NULL;
}
- if (!book)
+ if (!book_client)
return;
if (e_destination_is_evolution_list (destination)) {
if (!name_selector_entry->priv->contact_list_editor_func)
return;
- contact_list_editor = (*name_selector_entry->priv->contact_list_editor_func) (book, contact, FALSE, TRUE);
+ contact_list_editor = (*name_selector_entry->priv->contact_list_editor_func) (book_client, contact, FALSE, TRUE);
g_object_ref (name_selector_entry);
g_signal_connect (contact_list_editor, "editor_closed",
G_CALLBACK (editor_closed_cb), name_selector_entry);
if (!name_selector_entry->priv->contact_editor_func)
return;
- contact_editor = (*name_selector_entry->priv->contact_editor_func) (book, contact, FALSE, TRUE);
+ contact_editor = (*name_selector_entry->priv->contact_editor_func) (book_client, contact, FALSE, TRUE);
g_object_ref (name_selector_entry);
g_signal_connect (contact_editor, "editor_closed",
G_CALLBACK (editor_closed_cb), name_selector_entry);
/* Source list */
- if (!e_book_get_addressbooks (&name_selector_entry->priv->source_list, NULL)) {
- g_warning ("ENameSelectorEntry can't find any addressbooks!");
- return;
+ if (!e_book_client_get_sources (&name_selector_entry->priv->source_list, NULL)) {
+ g_warning ("ENameSelectorEntry can't find any addressbooks!");
+ return;
}
/* read minimum_query_length from gconf*/
gconf = gconf_client_get_default ();
if (COMPLETION_CUE_MIN_LEN == 0) {
- if ((COMPLETION_CUE_MIN_LEN = gconf_client_get_int (gconf, MINIMUM_QUERY_LENGTH, NULL)))
- ;
- else COMPLETION_CUE_MIN_LEN = 3;
+ if ((COMPLETION_CUE_MIN_LEN = gconf_client_get_int (gconf, MINIMUM_QUERY_LENGTH, NULL)))
+ ;
+ else COMPLETION_CUE_MIN_LEN = 3;
}
COMPLETION_FORCE_SHOW_ADDRESS = gconf_client_get_bool (gconf, FORCE_SHOW_ADDRESS, NULL);
name_selector_entry->priv->user_query_fields = gconf_client_get_list (
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
-#include <libebook/e-book.h>
+#include <libebook/e-book-client.h>
#include <libebook/e-contact.h>
-#include <libedataserverui/e-contact-store.h>
-#include <libedataserverui/e-destination-store.h>
-#include <libedataserverui/e-book-auth-util.h>
+
+#include "e-contact-store.h"
+#include "e-destination-store.h"
+#include "e-client-utils.h"
#include "e-name-selector.h"
typedef struct {
} Section;
typedef struct {
- EBook *book;
+ EBookClient *client;
guint is_completion_book : 1;
} SourceBook;
}
static void
-name_selector_book_loaded_cb (ESource *source,
+name_selector_book_loaded_cb (GObject *source_object,
GAsyncResult *result,
- ENameSelector *name_selector)
+ gpointer user_data)
{
- EBook *book;
+ ENameSelector *name_selector = user_data;
+ ESource *source = E_SOURCE (source_object);
+ EBookClient *book_client;
+ EClient *client = NULL;
GArray *sections;
SourceBook source_book;
guint ii;
GError *error = NULL;
- book = e_load_book_source_finish (source, result, &error);
+ e_client_utils_open_new_finish (source, result, &client, &error);
if (error != NULL) {
g_warning (
goto exit;
}
- g_return_if_fail (E_IS_BOOK (book));
+ book_client = E_BOOK_CLIENT (client);
+ g_return_if_fail (E_IS_BOOK_CLIENT (book_client));
- source_book.book = book;
+ source_book.client = book_client;
source_book.is_completion_book = TRUE;
g_array_append_val (name_selector->priv->source_books, source_book);
store = e_name_selector_entry_peek_contact_store (
section->entry);
if (store != NULL)
- e_contact_store_add_book (store, book);
+ e_contact_store_add_client (store, book_client);
}
exit:
GSList *groups;
GSList *iter1;
- if (!e_book_get_addressbooks (&source_list, NULL)) {
+ if (!e_book_client_get_sources (&source_list, NULL)) {
g_warning ("ENameSelector can't find any addressbooks!");
return;
}
continue;
/* XXX Should we allow for cancellation? */
- e_load_book_source_async (
- source, NULL, NULL,
- (GAsyncReadyCallback)
- name_selector_book_loaded_cb,
- g_object_ref (name_selector));
+ e_client_utils_open_new (
+ source, E_CLIENT_SOURCE_TYPE_CONTACTS, TRUE, NULL,
+ e_client_utils_authenticate_handler, NULL,
+ name_selector_book_loaded_cb, g_object_ref (name_selector));
}
}
}
source_book = &g_array_index (
priv->source_books, SourceBook, ii);
- if (source_book->book != NULL)
- g_object_unref (source_book->book);
+ if (source_book->client != NULL)
+ g_object_unref (source_book->client);
}
for (ii = 0; ii < priv->sections->len; ii++) {
for (i = 0; i < priv->source_books->len; i++) {
SourceBook *source_book = &g_array_index (priv->source_books, SourceBook, i);
- if (source_book->is_completion_book && source_book->book)
- e_contact_store_add_book (contact_store, source_book->book);
+ if (source_book->is_completion_book && source_book->client)
+ e_contact_store_add_client (contact_store, source_book->client);
}
e_name_selector_entry_set_contact_store (section->entry, contact_store);
for (i = 0; i < priv->source_books->len; i++) {
SourceBook *source_book = &g_array_index (priv->source_books, SourceBook, i);
- if (source_book->is_completion_book && source_book->book)
- e_contact_store_add_book (contact_store, source_book->book);
+ if (source_book->is_completion_book && source_book->client)
+ e_contact_store_add_client (contact_store, source_book->client);
}
e_name_selector_entry_set_contact_store (section->entry, contact_store);
return (ENameSelectorList *) section->entry;
}
-
/* Make sure the URI has the required components. */
if (uri->user == NULL && uri->host == NULL) {
- g_set_error (
+ g_set_error_literal (
error, EP_KEYRING_ERROR,
GNOME_KEYRING_RESULT_BAD_ARGUMENTS,
_("Keyring key is unusable: no user or host name"));
SUBDIRS = vcard client
+if HAVE_E_BOOK_DISABLE_DEPRECATED
+
+TEST_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ -I$(top_srcdir)/addressbook \
+ -I$(top_builddir)/addressbook \
+ -DSRCDIR=\""$(srcdir)"\" \
+ $(EVOLUTION_ADDRESSBOOK_CFLAGS) \
+ $(NULL)
+
+TEST_LIBS = \
+ $(top_builddir)/addressbook/libebook/libebook-1.2.la \
+ $(EVOLUTION_ADDRESSBOOK_LIBS) \
+ $(NULL)
+
+DEPRECATED_TESTS = $(NULL)
+
+else
+
noinst_LTLIBRARIES = libebook-test-utils.la
libebook_test_utils_la_SOURCES = ebook-test-utils.c ebook-test-utils.h
$(EVOLUTION_ADDRESSBOOK_LIBS) \
$(NULL)
-TEST_LIBS = \
- $(libebook_test_utils_la_LIBADD) \
- libebook-test-utils.la \
+TEST_CPPFLAGS = \
+ $(libebook_test_utils_la_CPPFLAGS) \
+ $(NULL)
+
+TEST_LIBS = \
+ $(libebook_test_utils_la_LIBADD) \
+ libebook-test-utils.la \
$(NULL)
+DEPRECATED_TESTS = \
+ test-changes \
+ test-ebook \
+ test-ebook-async \
+ test-nonexistent-id \
+ test-search \
+ test-self \
+ test-stress-bookviews
+
+endif
+
# Should be kept ordered approximately from least to most difficult/complex
TESTS = \
$(NULL)
# test-ebook-stress-factory--single-book
noinst_PROGRAMS = \
- $(TESTS) \
- test-changes \
- test-categories \
- test-date \
- test-ebook \
- test-ebook-async \
- test-nonexistent-id \
- test-photo \
- test-query \
- test-self \
- test-string \
- test-undefinedfield \
- test-untyped-phones \
- test-search \
- test-stress-bookviews \
- $(NULL)
-
-TEST_CPPFLAGS= \
- $(libebook_test_utils_la_CPPFLAGS) \
+ $(TESTS) \
+ $(DEPRECATED_TESTS) \
+ test-categories \
+ test-date \
+ test-photo \
+ test-query \
+ test-string \
+ test-undefinedfield \
+ test-untyped-phones \
$(NULL)
EXTRA_DIST = \
$(srcdir)/data/vcards/simple-2.vcf \
$(NULL)
-test_search_LDADD=$(TEST_LIBS)
-test_search_CPPFLAGS=$(TEST_CPPFLAGS)
+test_categories_LDADD=$(TEST_LIBS)
+test_categories_CPPFLAGS=$(TEST_CPPFLAGS)
test_date_LDADD=$(TEST_LIBS)
test_date_CPPFLAGS=$(TEST_CPPFLAGS)
+test_photo_LDADD=$(TEST_LIBS)
+test_photo_CPPFLAGS=$(TEST_CPPFLAGS)
+test_query_LDADD=$(TEST_LIBS)
+test_query_CPPFLAGS=$(TEST_CPPFLAGS)
+test_string_LDADD=$(TEST_LIBS)
+test_string_CPPFLAGS=$(TEST_CPPFLAGS)
+test_undefinedfield_LDADD=$(TEST_LIBS)
+test_undefinedfield_CPPFLAGS=$(TEST_CPPFLAGS)
+test_untyped_phones_LDADD=$(TEST_LIBS)
+test_untyped_phones_CPPFLAGS=$(TEST_CPPFLAGS)
+
+if !HAVE_E_BOOK_DISABLE_DEPRECATED
+
+test_search_LDADD=$(TEST_LIBS)
+test_search_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_LDADD=$(TEST_LIBS)
test_ebook_CPPFLAGS=$(TEST_CPPFLAGS)
test_ebook_async_LDADD=$(TEST_LIBS)
test_ebook_stress_factory__single_book_CPPFLAGS=$(TEST_CPPFLAGS)
test_changes_LDADD=$(TEST_LIBS)
test_changes_CPPFLAGS=$(TEST_CPPFLAGS)
-test_categories_LDADD=$(TEST_LIBS)
-test_categories_CPPFLAGS=$(TEST_CPPFLAGS)
test_nonexistent_id_LDADD=$(TEST_LIBS)
test_nonexistent_id_CPPFLAGS=$(TEST_CPPFLAGS)
-test_photo_LDADD=$(TEST_LIBS)
-test_photo_CPPFLAGS=$(TEST_CPPFLAGS)
-test_query_LDADD=$(TEST_LIBS)
-test_query_CPPFLAGS=$(TEST_CPPFLAGS)
test_self_LDADD=$(TEST_LIBS)
test_self_CPPFLAGS=$(TEST_CPPFLAGS)
-test_string_LDADD=$(TEST_LIBS)
-test_string_CPPFLAGS=$(TEST_CPPFLAGS)
-test_undefinedfield_LDADD=$(TEST_LIBS)
-test_undefinedfield_CPPFLAGS=$(TEST_CPPFLAGS)
-test_untyped_phones_LDADD=$(TEST_LIBS)
-test_untyped_phones_CPPFLAGS=$(TEST_CPPFLAGS)
test_stress_bookviews_LDADD=$(TEST_LIBS)
test_stress_bookviews_CPPFLAGS=$(TEST_CPPFLAGS)
+endif
+
-include $(top_srcdir)/git.mk
SUBDIRS = client
+if !HAVE_E_CAL_DISABLE_DEPRECATED
+
noinst_LTLIBRARIES = libecal-test-utils.la
libecal_test_utils_la_SOURCES = ecal-test-utils.c ecal-test-utils.h
libecal-test-utils.la \
$(NULL)
-EXTRA_DIST = \
- $(test_scripts) \
- testdata.ics
-
-test_scripts = \
- test-runner.sh \
- cleanup.sh
-
# ordered by relative complexity
TESTS = \
test-ecal-remove \
$(LIBICAL_LIBS) \
$(EVOLUTION_CALENDAR_LIBS)
+endif
+
+EXTRA_DIST = \
+ $(test_scripts) \
+ testdata.ics
+
+test_scripts = \
+ test-runner.sh \
+ cleanup.sh
+
-include $(top_srcdir)/git.mk
while (async_data && foreach_configured_source_async_next (&async_data, &source)) {
identify_source (source);
- e_client_utils_open_new (source, source_type, TRUE,
+ e_client_utils_open_new (source, source_type, TRUE, NULL,
e_client_utils_authenticate_handler, NULL,
- NULL, client_opened_async, async_data);
+ client_opened_async, async_data);
break;
}
g_return_if_fail (source_object == NULL);
g_return_if_fail (async_data != NULL);
- if (!e_client_utils_open_new_finish (result, &client, &error)) {
+ if (!e_client_utils_open_new_finish (E_SOURCE (source_object), result, &client, &error)) {
report_error ("client utils open new finish", &error);
continue_next_source (async_data);
return;
running_async++;
identify_source (source);
- e_client_utils_open_new (source, source_type, TRUE,
+ e_client_utils_open_new (source, source_type, TRUE, NULL,
e_client_utils_authenticate_handler, NULL,
- NULL, client_opened_async, async_data);
+ client_opened_async, async_data);
return TRUE;
}
GtkWidget *box;
GtkWidget *entry;
GtkTreeViewColumn *column;
- EBook *book;
+ EBookClient *book_client;
EBookQuery *book_query;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view);
- book = e_book_new_default_addressbook (NULL);
- e_book_open (book, TRUE, NULL);
- e_contact_store_add_book (contact_store, book);
- g_object_unref (book);
+ book_client = e_book_client_new_default (NULL);
+ e_client_open_sync (E_CLIENT (book_client), TRUE, NULL, NULL);
+ e_contact_store_add_client (contact_store, book_client);
+ g_object_unref (book_client);
book_query = e_book_query_any_field_contains ("");
e_contact_store_set_query (contact_store, book_query);