[evolution-data-server/dbus: 21/33] Remove redundant code
- From: Ross Burton <rburton src gnome org>
- To: svn-commits-list gnome org
- Subject: [evolution-data-server/dbus: 21/33] Remove redundant code
- Date: Mon, 1 Jun 2009 11:14:24 -0400 (EDT)
commit 9b1b4965e275b1df5fd8cfb13ba5b2c61e5622b1
Author: Ross Burton <ross linux intel com>
Date: Mon Jun 1 15:43:28 2009 +0100
Remove redundant code
---
addressbook/libebook/e-book-listener.c | 495 ---------------------------
addressbook/libebook/e-book-listener.h | 120 -------
addressbook/libebook/e-book-view-listener.c | 405 ----------------------
addressbook/libebook/e-book-view-listener.h | 93 -----
4 files changed, 0 insertions(+), 1113 deletions(-)
diff --git a/addressbook/libebook/e-book-listener.c b/addressbook/libebook/e-book-listener.c
deleted file mode 100644
index 242b6dd..0000000
--- a/addressbook/libebook/e-book-listener.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Exports the BookListener interface. Maintains a queue of messages
- * which come in on the interface.
- *
- * Author:
- * Nat Friedman (nat ximian com)
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- */
-
-#include <config.h>
-#include <bonobo/bonobo-main.h>
-#include "e-contact.h"
-#include "e-book-listener.h"
-
-#define d(x)
-
-extern GMainContext *_ebook_context;
-
-static EBookStatus e_book_listener_convert_status (GNOME_Evolution_Addressbook_CallStatus status);
-
-enum {
- RESPONSE,
- LAST_SIGNAL
-};
-
-static guint e_book_listener_signals [LAST_SIGNAL];
-
-static BonoboObjectClass *parent_class;
-
-struct _EBookListenerPrivate {
- guint stopped : 1;
-};
-
-static EBookStatus
-e_book_listener_convert_status (const GNOME_Evolution_Addressbook_CallStatus status)
-{
- switch (status) {
- case GNOME_Evolution_Addressbook_Success:
- return E_BOOK_ERROR_OK;
- case GNOME_Evolution_Addressbook_RepositoryOffline:
- return E_BOOK_ERROR_REPOSITORY_OFFLINE;
- case GNOME_Evolution_Addressbook_PermissionDenied:
- return E_BOOK_ERROR_PERMISSION_DENIED;
- case GNOME_Evolution_Addressbook_ContactNotFound:
- return E_BOOK_ERROR_CONTACT_NOT_FOUND;
- case GNOME_Evolution_Addressbook_ContactIdAlreadyExists:
- return E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS;
- case GNOME_Evolution_Addressbook_AuthenticationFailed:
- return E_BOOK_ERROR_AUTHENTICATION_FAILED;
- case GNOME_Evolution_Addressbook_AuthenticationRequired:
- return E_BOOK_ERROR_AUTHENTICATION_REQUIRED;
- case GNOME_Evolution_Addressbook_UnsupportedAuthenticationMethod:
- return E_BOOK_ERROR_UNSUPPORTED_AUTHENTICATION_METHOD;
- case GNOME_Evolution_Addressbook_TLSNotAvailable:
- return E_BOOK_ERROR_TLS_NOT_AVAILABLE;
- case GNOME_Evolution_Addressbook_NoSuchBook:
- return E_BOOK_ERROR_NO_SUCH_BOOK;
- case GNOME_Evolution_Addressbook_OfflineUnavailable:
- return E_BOOK_ERROR_OFFLINE_UNAVAILABLE;
- case GNOME_Evolution_Addressbook_InvalidServerVersion:
- return E_BOOK_ERROR_INVALID_SERVER_VERSION;
-
- case GNOME_Evolution_Addressbook_OtherError:
- default:
- return E_BOOK_ERROR_OTHER_ERROR;
- }
-}
-
-static void
-impl_BookListener_respond_create_contact (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- const CORBA_char* id,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = CreateContactResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
- response.id = g_strdup (id);
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-
- g_free (response.id);
-}
-
-static void
-impl_BookListener_respond_remove_contacts (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = RemoveContactResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_respond_modify_contact (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = ModifyContactResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_respond_get_contact (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- const CORBA_char* card,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = GetContactResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
- response.vcard = g_strdup (card);
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-
- g_free (response.vcard);
-}
-
-static void
-impl_BookListener_respond_get_contact_list (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- const GNOME_Evolution_Addressbook_stringlist *cards,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
- int i;
-
- if (listener->priv->stopped)
- return;
-
- response.op = GetContactListResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
- response.list = NULL;
-
- for (i = 0; i < cards->_length; i ++) {
- response.list = g_list_prepend (response.list, e_contact_new_from_vcard (cards->_buffer[i]));
- }
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-
- g_list_foreach (response.list, (GFunc)g_object_unref, NULL);
- g_list_free (response.list);
-}
-
-static void
-impl_BookListener_respond_get_view (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- const GNOME_Evolution_Addressbook_BookView book_view,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- d(printf ("impl_BookListener_respond_get_view\n"));
-
- if (listener->priv->stopped)
- return;
-
- response.op = GetBookViewResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
- response.book_view = book_view;
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_respond_get_changes (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- const GNOME_Evolution_Addressbook_BookChangeList *changes,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
- int i;
-
- response.op = GetChangesResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
- response.list = NULL;
-
- for (i = 0; i < changes->_length; i ++) {
- EBookChange *change = g_new (EBookChange, 1);
- GNOME_Evolution_Addressbook_BookChangeItem corba_change = changes->_buffer[i];
-
- switch (corba_change.changeType) {
- case GNOME_Evolution_Addressbook_ContactAdded:
- change->change_type = E_BOOK_CHANGE_CARD_ADDED;
- break;
- case GNOME_Evolution_Addressbook_ContactDeleted:
- change->change_type = E_BOOK_CHANGE_CARD_DELETED;
- break;
- case GNOME_Evolution_Addressbook_ContactModified:
- change->change_type = E_BOOK_CHANGE_CARD_MODIFIED;
- break;
- }
- change->contact = e_contact_new_from_vcard (corba_change.vcard);
-
- response.list = g_list_prepend (response.list, change);
- }
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_respond_open_book (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = OpenBookResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_respond_remove_book (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = RemoveBookResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_respond_authentication_result (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = AuthenticationResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_respond_get_required_fields (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- const GNOME_Evolution_Addressbook_stringlist *fields,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
- int i;
-
- response.op = GetRequiredFieldsResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
- response.list = NULL;
-
- for (i = 0; i < fields->_length; i ++)
- response.list = g_list_prepend (response.list, g_strdup (fields->_buffer[i]));
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-
-static void
-impl_BookListener_respond_get_supported_fields (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- const GNOME_Evolution_Addressbook_stringlist *fields,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
- int i;
-
- response.op = GetSupportedFieldsResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
- response.list = NULL;
-
- for (i = 0; i < fields->_length; i ++)
- response.list = g_list_prepend (response.list, g_strdup (fields->_buffer[i]));
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_respond_get_supported_auth_methods (PortableServer_Servant servant,
- const CORBA_long opid,
- const GNOME_Evolution_Addressbook_CallStatus status,
- const GNOME_Evolution_Addressbook_stringlist *auth_methods,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
- int i;
-
- response.op = GetSupportedAuthMethodsResponse;
- response.opid = opid;
- response.status = e_book_listener_convert_status (status);
- response.list = NULL;
-
- for (i = 0; i < auth_methods->_length; i ++)
- response.list = g_list_prepend (response.list, g_strdup (auth_methods->_buffer[i]));
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_report_writable (PortableServer_Servant servant,
- const CORBA_boolean writable,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = WritableStatusEvent;
- response.writable = writable;
-
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_report_link_status (PortableServer_Servant servant,
- const CORBA_boolean is_online,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = LinkStatusEvent;
- response.connected = is_online;
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_report_auth_required (PortableServer_Servant servant,
- CORBA_Environment *ev)
-{
- EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant));
- EBookListenerResponse response;
-
- response.op = AuthRequiredEvent;
- g_signal_emit (listener, e_book_listener_signals [RESPONSE], 0, &response);
-}
-
-static void
-impl_BookListener_respond_progress (PortableServer_Servant servant,
- const CORBA_char * message,
- const CORBA_short percent,
- CORBA_Environment *ev)
-{
-}
-
-/**
- * e_book_listener_new:
- *
- * Creates and returns a new #EBookListener.
- *
- * Returns: a new #EBookListener
- */
-EBookListener *
-e_book_listener_new (void)
-{
- static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
- static PortableServer_POA poa = NULL;
- EBookListener *listener;
-
- g_static_mutex_lock (&mutex);
- if (poa == NULL)
- poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_ON_CONTEXT, _ebook_context, NULL);
- g_static_mutex_unlock (&mutex);
-
- listener = g_object_new (E_TYPE_BOOK_LISTENER, "poa", poa, NULL);
-
- return listener;
-}
-
-static void
-e_book_listener_init (EBookListener *listener)
-{
- listener->priv = g_new0 (EBookListenerPrivate, 1);
-}
-
-/**
- * e_book_listener_stop:
- * @listener: an #EBookListener
- *
- * Stops @listener from generating events.
- **/
-void
-e_book_listener_stop (EBookListener *listener)
-{
- g_return_if_fail (E_IS_BOOK_LISTENER (listener));
-
- listener->priv->stopped = TRUE;
-}
-
-static void
-e_book_listener_finalize (GObject *object)
-{
- EBookListener *listener = E_BOOK_LISTENER (object);
- if (listener->priv) {
- g_free (listener->priv);
- listener->priv = NULL;
- }
- if (G_OBJECT_CLASS (parent_class)->finalize)
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-e_book_listener_class_init (EBookListenerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- POA_GNOME_Evolution_Addressbook_BookListener__epv *epv;
-
- parent_class = g_type_class_ref (BONOBO_TYPE_OBJECT);
-
- e_book_listener_signals [RESPONSE] =
- g_signal_new ("response",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EBookListenerClass, response),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE, 1,
- G_TYPE_POINTER);
-
- epv = &klass->epv;
- epv->notifyProgress = impl_BookListener_respond_progress;
- epv->notifyBookOpened = impl_BookListener_respond_open_book;
- epv->notifyBookRemoved = impl_BookListener_respond_remove_book;
- epv->notifyContactCreated = impl_BookListener_respond_create_contact;
- epv->notifyContactsRemoved = impl_BookListener_respond_remove_contacts;
- epv->notifyContactModified = impl_BookListener_respond_modify_contact;
- epv->notifyAuthenticationResult = impl_BookListener_respond_authentication_result;
- epv->notifyRequiredFields = impl_BookListener_respond_get_required_fields;
- epv->notifySupportedFields = impl_BookListener_respond_get_supported_fields;
- epv->notifySupportedAuthMethods = impl_BookListener_respond_get_supported_auth_methods;
- epv->notifyContactRequested = impl_BookListener_respond_get_contact;
- epv->notifyContactListRequested = impl_BookListener_respond_get_contact_list;
- epv->notifyViewRequested = impl_BookListener_respond_get_view;
- epv->notifyChangesRequested = impl_BookListener_respond_get_changes;
- epv->notifyWritable = impl_BookListener_report_writable;
- epv->notifyConnectionStatus = impl_BookListener_report_link_status;
- epv->notifyAuthRequired = impl_BookListener_report_auth_required;
-
- object_class->finalize = e_book_listener_finalize;
-}
-
-BONOBO_TYPE_FUNC_FULL (
- EBookListener,
- GNOME_Evolution_Addressbook_BookListener,
- BONOBO_TYPE_OBJECT,
- e_book_listener)
diff --git a/addressbook/libebook/e-book-listener.h b/addressbook/libebook/e-book-listener.h
deleted file mode 100644
index 2ac29a5..0000000
--- a/addressbook/libebook/e-book-listener.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * A client-side GObject which exposes the
- * Evolution:BookListener interface.
- *
- * Author:
- * Nat Friedman (nat ximian com)
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- */
-
-#ifndef __E_BOOK_LISTENER_H__
-#define __E_BOOK_LISTENER_H__
-
-#include <bonobo/bonobo-object.h>
-#include <libebook/e-book-types.h>
-
-#include "Evolution-DataServer-Addressbook.h"
-
-#define E_TYPE_BOOK_LISTENER (e_book_listener_get_type ())
-#define E_BOOK_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_LISTENER, EBookListener))
-#define E_BOOK_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_BOOK_LISTENER, EBookListenerClass))
-#define E_IS_BOOK_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_LISTENER))
-#define E_IS_BOOK_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK_LISTENER))
-#define E_BOOK_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_LISTENER, EBookListenerClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EBookListener EBookListener;
-typedef struct _EBookListenerClass EBookListenerClass;
-typedef struct _EBookListenerPrivate EBookListenerPrivate;
-typedef struct _EBookListenerResponse EBookListenerResponse;
-
-struct _EBookListener {
- BonoboObject parent;
- /*< private >*/
- EBookListenerPrivate *priv;
-};
-
-struct _EBookListenerClass {
- BonoboObjectClass parent;
-
- POA_GNOME_Evolution_Addressbook_BookListener__epv epv;
-
- /*
- * Signals
- */
-
- void (*response) (EBookListener *listener, EBookListenerResponse *response);
-
- /* Padding for future expansion */
- void (*_ebook_reserved0) (void);
- void (*_ebook_reserved1) (void);
- void (*_ebook_reserved2) (void);
- void (*_ebook_reserved3) (void);
- void (*_ebook_reserved4) (void);
-};
-
-typedef enum {
- /* Async responses */
- OpenBookResponse,
- RemoveBookResponse,
- CreateContactResponse,
- RemoveContactResponse,
- ModifyContactResponse,
- GetContactResponse,
- GetContactListResponse,
- GetBookViewResponse,
- GetChangesResponse,
- AuthenticationResponse,
- GetSupportedFieldsResponse,
- GetRequiredFieldsResponse,
- GetSupportedAuthMethodsResponse,
-
- /* Async events */
- LinkStatusEvent,
- WritableStatusEvent,
- AuthRequiredEvent,
- ProgressEvent
-} EBookListenerOperation;
-
-struct _EBookListenerResponse {
- EBookListenerOperation op;
-
- /* The tag that e_book_* assigned to the operation this is a
- response for */
- guint32 opid;
-
- /* For most Response notifications */
- EBookStatus status;
-
- /* For GetBookViewReponse */
- GNOME_Evolution_Addressbook_BookView book_view;
-
- /* For GetSupportedFields/GetSupportedAuthMethods */
- GList *list;
-
- /* For ProgressEvent */
- char *msg;
- short percent;
-
- /* For LinkStatusEvent */
- gboolean connected;
-
- /* For WritableStatusEvent */
- gboolean writable;
-
- /* For Card[Added|Removed|Modified]Event */
- char *id;
- char *vcard;
-};
-
-
-EBookListener *e_book_listener_new (void);
-GType e_book_listener_get_type (void);
-void e_book_listener_stop (EBookListener *listener);
-
-G_END_DECLS
-
-#endif /* ! __E_BOOK_LISTENER_H__ */
diff --git a/addressbook/libebook/e-book-view-listener.c b/addressbook/libebook/e-book-view-listener.c
deleted file mode 100644
index e0d5935..0000000
--- a/addressbook/libebook/e-book-view-listener.c
+++ /dev/null
@@ -1,405 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Exports the BookViewListener interface. Maintains a queue of messages
- * which come in on the interface.
- *
- * Author:
- * Nat Friedman (nat ximian com)
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- */
-
-#include <config.h>
-#include <bonobo/bonobo-main.h>
-#include "e-book-view-listener.h"
-#include "e-book-view.h"
-#include "e-contact.h"
-
-#define d(x)
-
-static EBookViewStatus e_book_view_listener_convert_status (GNOME_Evolution_Addressbook_CallStatus status);
-
-enum {
- RESPONSE,
- LAST_SIGNAL
-};
-
-static guint e_book_view_listener_signals [LAST_SIGNAL];
-
-static BonoboObjectClass *parent_class;
-
-#define READ_END 0
-#define WRITE_END 1
-
-struct _EBookViewListenerPrivate {
- guint stopped : 1;
- GAsyncQueue *queue;
-
- GMutex *idle_mutex;
- guint idle_id;
-};
-
-static void
-free_response (EBookViewListenerResponse *response)
-{
- g_return_if_fail (response != NULL);
-
- g_list_foreach (response->ids, (GFunc)g_free, NULL);
- g_list_free (response->ids);
- g_list_foreach (response->contacts, (GFunc) g_object_unref, NULL);
- g_list_free (response->contacts);
- g_free (response->message);
- g_free (response);
-}
-
-static gboolean
-main_thread_get_response (gpointer data)
-{
- EBookViewListener *listener = data;
- EBookViewListenerResponse *response;
-
- bonobo_object_ref (listener);
-
- g_mutex_lock (listener->priv->idle_mutex);
-
- /* remove the idle call */
-
- while ((response = g_async_queue_try_pop (listener->priv->queue)) != NULL) {
-
- g_signal_emit (listener, e_book_view_listener_signals [RESPONSE], 0, response);
-
- free_response (response);
- }
-
- listener->priv->idle_id = -1;
-
- g_mutex_unlock (listener->priv->idle_mutex);
-
- bonobo_object_unref (listener);
-
- return FALSE;
-}
-
-static void
-e_book_view_listener_queue_response (EBookViewListener *listener,
- EBookViewListenerResponse *response)
-{
- if (response == NULL)
- return;
-
- if (listener->priv->stopped) {
- free_response (response);
- return;
- }
-
- g_mutex_lock (listener->priv->idle_mutex);
-
- g_async_queue_push (listener->priv->queue, response);
-
- if (listener->priv->idle_id == -1)
- listener->priv->idle_id = g_idle_add (main_thread_get_response, listener);
- g_mutex_unlock (listener->priv->idle_mutex);
-}
-
-/* Add, Remove, Modify */
-static void
-e_book_view_listener_queue_status_event (EBookViewListener *listener,
- EBookViewListenerOperation op,
- EBookViewStatus status)
-{
- EBookViewListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookViewListenerResponse, 1);
-
- resp->op = op;
- resp->status = status;
-
- e_book_view_listener_queue_response (listener, resp);
-}
-
-/* Add, Remove, Modify */
-static void
-e_book_view_listener_queue_idlist_event (EBookViewListener *listener,
- EBookViewListenerOperation op,
- const GNOME_Evolution_Addressbook_ContactIdList *ids)
-{
- EBookViewListenerResponse *resp;
- int i;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookViewListenerResponse, 1);
-
- resp->op = op;
- resp->status = E_BOOK_VIEW_STATUS_OK;
-
- for (i = 0; i < ids->_length; i ++) {
- resp->ids = g_list_prepend (resp->ids, g_strdup (ids->_buffer[i]));
- }
-
- e_book_view_listener_queue_response (listener, resp);
-}
-
-/* Add, Remove, Modify */
-static void
-e_book_view_listener_queue_sequence_event (EBookViewListener *listener,
- EBookViewListenerOperation op,
- const GNOME_Evolution_Addressbook_VCardList *vcards)
-{
- EBookViewListenerResponse *resp;
- int i;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookViewListenerResponse, 1);
-
- resp->op = op;
- resp->status = E_BOOK_VIEW_STATUS_OK;
-
- for ( i = 0; i < vcards->_length; i++ ) {
- resp->contacts = g_list_prepend (resp->contacts, e_contact_new_from_vcard (vcards->_buffer[i]));
- }
- resp->contacts = g_list_reverse (resp->contacts);
-
- e_book_view_listener_queue_response (listener, resp);
-}
-
-/* Status Message */
-static void
-e_book_view_listener_queue_message_event (EBookViewListener *listener,
- EBookViewListenerOperation op,
- const char *message)
-{
- EBookViewListenerResponse *resp;
-
- if (listener->priv->stopped)
- return;
-
- resp = g_new0 (EBookViewListenerResponse, 1);
-
- resp->op = op;
- resp->status = E_BOOK_VIEW_STATUS_OK;
- resp->message = g_strdup(message);
-
- e_book_view_listener_queue_response (listener, resp);
-}
-
-static void
-impl_BookViewListener_notify_contacts_added (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_VCardList *vcards,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant));
-
- d(printf ("%p: impl_BookViewListener_notify_contacts_added (%p)\n", g_thread_self(), listener));
-
- e_book_view_listener_queue_sequence_event (
- listener, ContactsAddedEvent, vcards);
-}
-
-static void
-impl_BookViewListener_notify_contacts_removed (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_ContactIdList *ids,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant));
-
- d(printf ("%p: impl_BookViewListener_notify_contacts_removed (%p)\n", g_thread_self(), listener));
-
- e_book_view_listener_queue_idlist_event (listener, ContactsRemovedEvent, ids);
-}
-
-static void
-impl_BookViewListener_notify_contacts_changed (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_VCardList *vcards,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant));
-
- d(printf ("%p: impl_BookViewListener_notify_contacts_changed (%p)\n", g_thread_self(), listener));
-
- e_book_view_listener_queue_sequence_event (
- listener, ContactsModifiedEvent, vcards);
-}
-
-static void
-impl_BookViewListener_notify_sequence_complete (PortableServer_Servant servant,
- const GNOME_Evolution_Addressbook_CallStatus status,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant));
-
- d(printf ("%p: impl_BookViewListener_notify_sequence_complete (%p)\n", g_thread_self(), listener));
-
- e_book_view_listener_queue_status_event (listener, SequenceCompleteEvent,
- e_book_view_listener_convert_status (status));
-}
-
-static void
-impl_BookViewListener_notify_progress (PortableServer_Servant servant,
- const char *message,
- const CORBA_short percent,
- CORBA_Environment *ev)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object (servant));
-
- d(printf ("%p: impl_BookViewListener_notify_progress (%p,`%s')\n", g_thread_self(), listener, message));
-
- e_book_view_listener_queue_message_event (listener, StatusMessageEvent, message);
-}
-
-static EBookViewStatus
-e_book_view_listener_convert_status (const GNOME_Evolution_Addressbook_CallStatus status)
-{
- switch (status) {
- case GNOME_Evolution_Addressbook_Success:
- return E_BOOK_VIEW_STATUS_OK;
- case GNOME_Evolution_Addressbook_SearchTimeLimitExceeded:
- return E_BOOK_VIEW_STATUS_TIME_LIMIT_EXCEEDED;
- case GNOME_Evolution_Addressbook_SearchSizeLimitExceeded:
- return E_BOOK_VIEW_STATUS_SIZE_LIMIT_EXCEEDED;
- case GNOME_Evolution_Addressbook_InvalidQuery:
- return E_BOOK_VIEW_ERROR_INVALID_QUERY;
- case GNOME_Evolution_Addressbook_QueryRefused:
- return E_BOOK_VIEW_ERROR_QUERY_REFUSED;
- case GNOME_Evolution_Addressbook_OtherError:
- default:
- return E_BOOK_VIEW_ERROR_OTHER_ERROR;
- }
-}
-
-/**
- * e_book_view_listener_new:
- *
- * Creates and returns a new #EBookViewListener.
- *
- * Return value: a new #EBookViewListener
- */
-EBookViewListener *
-e_book_view_listener_new (void)
-{
- static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
- static PortableServer_POA poa = NULL;
- EBookViewListener *listener;
-
- g_static_mutex_lock (&mutex);
- if (poa == NULL)
- poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_OBJECT, NULL);
- g_static_mutex_unlock (&mutex);
-
- listener = g_object_new (E_TYPE_BOOK_VIEW_LISTENER, "poa", poa, NULL);
-
- listener->priv->queue = g_async_queue_new();
- listener->priv->idle_mutex = g_mutex_new();
- listener->priv->idle_id = -1;
-
- return listener;
-}
-
-static void
-e_book_view_listener_init (EBookViewListener *listener)
-{
- listener->priv = g_new0 (EBookViewListenerPrivate, 1);
- listener->priv->stopped = TRUE;
-}
-
-/**
- * e_book_view_listener_start:
- * @listener: an #EBookViewListener
- *
- * Makes @listener start generating events.
- **/
-void
-e_book_view_listener_start (EBookViewListener *listener)
-{
- g_return_if_fail (E_IS_BOOK_VIEW_LISTENER (listener));
- d(printf ("%p: e_book_view_listener_start (%p)\n", g_thread_self(), listener));
- listener->priv->stopped = FALSE;
-}
-
-/**
- * e_book_view_listener_stop:
- * @listener: an #EBookViewListener
- *
- * Makes @listener stop generating events.
- **/
-void
-e_book_view_listener_stop (EBookViewListener *listener)
-{
- g_return_if_fail (E_IS_BOOK_VIEW_LISTENER (listener));
- d(printf ("%p: e_book_view_listener_stop (%p)\n", g_thread_self(), listener));
- listener->priv->stopped = TRUE;
-
- if (listener->priv->idle_id != -1) {
- g_source_remove (listener->priv->idle_id);
- listener->priv->idle_id = -1;
- }
-}
-
-static void
-e_book_view_listener_dispose (GObject *object)
-{
- EBookViewListener *listener = E_BOOK_VIEW_LISTENER (object);
-
- d(printf ("%p: in e_book_view_listener_dispose (%p)\n", g_thread_self(), object));
-
- if (listener->priv) {
- EBookViewListenerResponse *response;
-
- if (listener->priv->idle_id != -1)
- g_source_remove (listener->priv->idle_id);
-
- g_mutex_free (listener->priv->idle_mutex);
-
- /* Free pending events */
- while ((response = g_async_queue_try_pop (listener->priv->queue)) != NULL)
- free_response (response);
-
- g_async_queue_unref (listener->priv->queue);
-
- g_free (listener->priv);
- listener->priv = NULL;
- }
-
- if (G_OBJECT_CLASS (parent_class)->dispose)
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
-e_book_view_listener_class_init (EBookViewListenerClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- POA_GNOME_Evolution_Addressbook_BookViewListener__epv *epv;
-
- parent_class = g_type_class_ref (BONOBO_TYPE_OBJECT);
-
- e_book_view_listener_signals [RESPONSE] =
- g_signal_new ("response",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EBookViewListenerClass, response),
- NULL, NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
-
- object_class->dispose = e_book_view_listener_dispose;
-
- epv = &klass->epv;
- epv->notifyContactsChanged = impl_BookViewListener_notify_contacts_changed;
- epv->notifyContactsRemoved = impl_BookViewListener_notify_contacts_removed;
- epv->notifyContactsAdded = impl_BookViewListener_notify_contacts_added;
- epv->notifySequenceComplete = impl_BookViewListener_notify_sequence_complete;
- epv->notifyProgress = impl_BookViewListener_notify_progress;
-}
-
-BONOBO_TYPE_FUNC_FULL (
- EBookViewListener,
- GNOME_Evolution_Addressbook_BookViewListener,
- BONOBO_TYPE_OBJECT,
- e_book_view_listener)
diff --git a/addressbook/libebook/e-book-view-listener.h b/addressbook/libebook/e-book-view-listener.h
deleted file mode 100644
index 57d9374..0000000
--- a/addressbook/libebook/e-book-view-listener.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * A client-side GObject which exposes the
- * Evolution:BookViewListener interface.
- *
- * Author:
- * Nat Friedman (nat ximian com)
- *
- * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
- */
-
-#ifndef __E_BOOK_VIEW_LISTENER_H__
-#define __E_BOOK_VIEW_LISTENER_H__
-
-#include <bonobo/bonobo-object.h>
-#include <libebook/e-book-types.h>
-
-#include "Evolution-DataServer-Addressbook.h"
-
-#define E_TYPE_BOOK_VIEW_LISTENER (e_book_view_listener_get_type ())
-#define E_BOOK_VIEW_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK_VIEW_LISTENER, EBookViewListener))
-#define E_BOOK_VIEW_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_BOOK_VIEW_LISTENER, EBookViewListenerClass))
-#define E_IS_BOOK_VIEW_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK_VIEW_LISTENER))
-#define E_IS_BOOK_VIEW_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK_VIEW_LISTENER))
-#define E_BOOK_VIEW_LISTENER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK_VIEW_LISTENER, EBookViewListenerClass))
-
-G_BEGIN_DECLS
-
-typedef struct _EBookViewListener EBookViewListener;
-typedef struct _EBookViewListenerClass EBookViewListenerClass;
-typedef struct _EBookViewListenerPrivate EBookViewListenerPrivate;
-
-typedef struct _EBookViewListenerResponse EBookViewListenerResponse;
-
-struct _EBookViewListener {
- BonoboObject parent;
- /*< private >*/
- EBookViewListenerPrivate *priv;
-};
-
-struct _EBookViewListenerClass {
- BonoboObjectClass parent;
-
- POA_GNOME_Evolution_Addressbook_BookViewListener__epv epv;
-
- /*
- * Signals
- */
- void (*response) (EBookViewListener *listener, EBookViewListenerResponse *response);
-
-
- /* Padding for future expansion */
- void (*_ebook_reserved0) (void);
- void (*_ebook_reserved1) (void);
- void (*_ebook_reserved2) (void);
- void (*_ebook_reserved3) (void);
- void (*_ebook_reserved4) (void);
-};
-
-typedef enum {
- /* Async events */
- ContactsAddedEvent,
- ContactsRemovedEvent,
- ContactsModifiedEvent,
- SequenceCompleteEvent,
- StatusMessageEvent
-} EBookViewListenerOperation;
-
-struct _EBookViewListenerResponse {
- EBookViewListenerOperation op;
-
- /* For SequenceComplete */
- EBookViewStatus status;
-
- /* For ContactsRemovedEvent */
- GList *ids;
-
- /* For Contact[sAdded|Modified]Event */
- GList *contacts; /* Of type EContact. */
-
- /* For StatusMessageEvent */
- char *message;
-
-};
-
-EBookViewListener *e_book_view_listener_new (void);
-GType e_book_view_listener_get_type (void);
-void e_book_view_listener_start (EBookViewListener *listener);
-void e_book_view_listener_stop (EBookViewListener *listener);
-
-G_END_DECLS
-
-#endif /* ! __E_BOOK_VIEW_LISTENER_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]