[evolution-data-server] Bug 695539 - Birthdays don't show up in the calendar
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug 695539 - Birthdays don't show up in the calendar
- Date: Fri, 15 Mar 2013 00:55:32 +0000 (UTC)
commit dadf08807934b68ba5adbfd7fbd87a6eb55f0684
Author: Sebastian Keller <sebastian-keller gmx de>
Date: Thu Mar 14 19:52:24 2013 -0400
Bug 695539 - Birthdays don't show up in the calendar
EBookClients don't emit "opened" signals anymore, so use
e_book_client_connect() instead.
.../backends/contacts/e-cal-backend-contacts.c | 145 ++++----------------
1 files changed, 30 insertions(+), 115 deletions(-)
---
diff --git a/calendar/backends/contacts/e-cal-backend-contacts.c
b/calendar/backends/contacts/e-cal-backend-contacts.c
index 6090796..254e519 100644
--- a/calendar/backends/contacts/e-cal-backend-contacts.c
+++ b/calendar/backends/contacts/e-cal-backend-contacts.c
@@ -31,7 +31,6 @@
#include "e-cal-backend-contacts.h"
#include <glib/gi18n-lib.h>
-#include <libsoup/soup.h>
#include <libebook/libebook.h>
@@ -82,7 +81,6 @@ typedef struct _BookRecord {
ECalBackendContacts *cbc;
EBookClient *book_client;
EBookClientView *book_view;
- gulong book_client_opened_id;
} BookRecord;
typedef struct _ContactRecord {
@@ -120,9 +118,9 @@ static void e_cal_backend_contacts_add_timezone
GError **perror);
static void setup_alarm (ECalBackendContacts *cbc,
ECalComponent *comp);
-static void book_client_opened_cb (EBookClient *book_client,
- const GError *error,
- BookRecord *br);
+static void book_client_connected_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data);
static gboolean
remove_by_book (gpointer key,
@@ -135,34 +133,19 @@ remove_by_book (gpointer key,
return (cr && cr->book_client == book_client);
}
-static BookRecord *
-book_record_new (ECalBackendContacts *cbc,
- ESource *source)
+static void
+create_book_record (ECalBackendContacts *cbc,
+ ESource *source)
{
BookRecord *br;
- EBookClient *book_client;
- GError *error = NULL;
-
- book_client = e_book_client_new (source, &error);
- if (error != NULL) {
- g_warning ("%s: %s", G_STRFUNC, error->message);
- g_error_free (error);
- return NULL;
- }
-
- g_return_val_if_fail (E_IS_BOOK_CLIENT (book_client), NULL);
br = g_slice_new0 (BookRecord);
br->ref_count = 1;
g_mutex_init (&br->lock);
br->cbc = g_object_ref (cbc);
- br->book_client = book_client; /* takes ownership */
- br->book_client_opened_id = g_signal_connect (
- br->book_client, "opened",
- G_CALLBACK (book_client_opened_cb), br);
-
- return br;
+ e_book_client_connect (
+ source, NULL, book_client_connected_cb, br);
}
static BookRecord *
@@ -183,10 +166,6 @@ book_record_unref (BookRecord *br)
g_return_if_fail (br->ref_count > 0);
if (g_atomic_int_dec_and_test (&br->ref_count)) {
- if (br->book_client_opened_id)
- g_signal_handler_disconnect (
- br->book_client,
- br->book_client_opened_id);
g_rec_mutex_lock (&br->cbc->priv->tracked_contacts_lock);
g_hash_table_foreach_remove (
br->cbc->priv->tracked_contacts,
@@ -253,19 +232,6 @@ cal_backend_contacts_remove_book_record (ECalBackendContacts *cbc,
return removed;
}
-static void
-cbc_reopen_book_client (BookRecord *br)
-{
- g_mutex_lock (&br->lock);
-
- g_warn_if_fail (br->book_client_opened_id == 0);
- br->book_client_opened_id = g_signal_connect (
- br->book_client, "opened",
- G_CALLBACK (book_client_opened_cb), br);
-
- g_mutex_unlock (&br->lock);
-}
-
static gpointer
book_record_get_view_thread (gpointer user_data)
{
@@ -343,92 +309,41 @@ exit:
}
static void
-book_client_opened_cb (EBookClient *book_client,
- const GError *error,
- BookRecord *br)
+book_client_connected_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
{
+ EClient *client;
ESource *source;
- const gchar *source_uid;
-
- g_return_if_fail (book_client != NULL);
- g_return_if_fail (br != NULL);
-
- g_mutex_lock (&br->lock);
- g_signal_handler_disconnect (
- br->book_client,
- br->book_client_opened_id);
- br->book_client_opened_id = 0;
- g_mutex_unlock (&br->lock);
-
- source = e_client_get_source (E_CLIENT (book_client));
- source_uid = e_source_get_uid (source);
- g_return_if_fail (source_uid != NULL);
-
- if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_AUTHENTICATION_FAILED)) {
- cbc_reopen_book_client (br);
- } else if (!error) {
- GThread *thread;
-
- thread = g_thread_new (NULL, book_record_get_view_thread, book_record_ref (br));
- g_thread_unref (thread);
- }
-}
-
-static void
-client_open_cb (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
+ GThread *thread;
BookRecord *br = user_data;
- EClient *client;
GError *error = NULL;
- client = E_CLIENT (source_object);
-
- e_client_open_finish (client, result, &error);
+ g_return_if_fail (br != NULL);
- if (error != NULL) {
- ESource *source;
+ client = e_book_client_connect_finish (result, &error);
- g_mutex_lock (&br->lock);
- if (br->book_client_opened_id) {
- g_signal_handler_disconnect (
- br->book_client,
- br->book_client_opened_id);
- br->book_client_opened_id = 0;
- }
- g_mutex_unlock (&br->lock);
+ /* Sanity check. */
+ g_return_if_fail (
+ ((client != NULL) && (error == NULL)) ||
+ ((client == NULL) && (error != NULL)));
- g_warning (
- "%s: Failed to open book: %s",
- G_STRFUNC, error->message);
+ if (error != NULL) {
+ g_warning ("%s: %s", G_STRFUNC, error->message);
g_error_free (error);
-
- source = e_client_get_source (client);
- cal_backend_contacts_remove_book_record (br->cbc, source);
+ g_slice_free (BookRecord, br);
+ return;
}
- book_record_unref (br);
-}
+ source = e_client_get_source (client);
+ br->book_client = g_object_ref (client);
+ cal_backend_contacts_insert_book_record (br->cbc, source, br);
-/* BookRecord methods */
-static void
-create_book_record (ECalBackendContacts *cbc,
- ESource *source)
-{
- BookRecord *br;
-
- br = book_record_new (cbc, source);
+ thread = g_thread_new (
+ NULL, book_record_get_view_thread, book_record_ref (br));
+ g_thread_unref (thread);
- if (br != NULL) {
- cal_backend_contacts_insert_book_record (cbc, source, br);
-
- e_client_open (
- E_CLIENT (br->book_client), TRUE, NULL,
- client_open_cb, book_record_ref (br));
-
- book_record_unref (br);
- }
+ g_object_unref (client);
}
/* ContactRecord methods */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]