Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:jberkman
evolution-exchange-2.6
evolution-exchange-2.6.0-cert-auth-complete.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File evolution-exchange-2.6.0-cert-auth-complete.patch of Package evolution-exchange-2.6
--- evolution-exchange-2.8.2.orig/addressbook/e-book-backend-exchange.c 2006-07-24 06:53:36.000000000 -0400 +++ evolution-exchange-2.8.2.orig/addressbook/e-book-backend-exchange.c 2007-04-18 15:17:40.000000000 -0400 @@ -59,9 +59,21 @@ #include <e-folder-exchange.h> #include "e-book-backend-exchange.h" #include "exchange-component.h" +#include "exchange-gca-creds.h" #define DEBUG -#define d(x) +#define d(x) x +#if 1 +#define GCA_TRACE(s, ...) fprintf (stderr, "%d:%s:%s():%d "s"\n", getpid(), __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) +#else +#define GCA_TRACE(s, ...) +#endif + +#define GCA_TRACEMSG(s) GCA_TRACE("%s", (s)) +#define GCA_ENTER GCA_TRACEMSG("ENTER") +#define GCA_EXIT GCA_TRACEMSG("EXIT") +#define GCA_HASLOCK GCA_TRACEMSG("HAS LOCK") +#define GCA_ALREADYLOCKED GCA_TRACEMSG("ALREADY LOCKED") #define SUMMARY_FLUSH_TIMEOUT 5000 @@ -88,6 +100,9 @@ struct EBookBackendExchangePrivate { EBookBackendSummary *summary; EBookBackendCache *cache; + + GHashTable *creds; + GMutex *creds_mutex; }; typedef struct PropMapping PropMapping; @@ -2141,6 +2156,43 @@ e_book_backend_exchange_get_contact (EBo return GNOME_Evolution_Addressbook_OtherError; } +static void +e_book_backend_exchange_add_client (EBookBackend *backend, + EDataBook *book) +{ + EBookBackendExchange *ebbe = E_BOOK_BACKEND_EXCHANGE (backend); + E2kCreds *creds; + ExchangeAccount *account; + GCA_ENTER; + account = exchange_component_get_account_for_uri (global_exchange_component, NULL); + creds = exchange_gca_creds_add (account, e_data_book_get_listener (book)); + + if (creds) { + GCA_TRACEMSG("have new creds"); + g_mutex_lock (ebbe->priv->creds_mutex); + g_hash_table_insert (ebbe->priv->creds, book, creds); + g_mutex_unlock (ebbe->priv->creds_mutex); + } + GCA_EXIT; + +} + +static void +e_book_backend_exchange_remove_client (EBookBackend *backend, + EDataBook *book) +{ + EBookBackendExchange *ebbe = E_BOOK_BACKEND_EXCHANGE (backend); + E2kCreds *creds; + + g_mutex_lock (ebbe->priv->creds_mutex); + creds = g_hash_table_lookup (ebbe->priv->creds, book); + g_hash_table_remove (ebbe->priv->creds, book); + g_mutex_unlock (ebbe->priv->creds_mutex); + + if (creds) { + exchange_gca_creds_remove (creds); + } +} static void e_book_backend_exchange_authenticate_user (EBookBackend *backend, @@ -2375,6 +2427,28 @@ e_book_backend_exchange_construct (EBook return TRUE; } +typedef struct { + EBookBackend *backend; + ExchangeAccount *account; +} SetModeData; + +static gpointer +set_mode_thread (gpointer user_data) +{ + SetModeData *data = user_data; + ExchangeAccountResult result; + + if (!exchange_account_connect (data->account, NULL, &result)) { + e_book_backend_notify_auth_required (data->backend); + } + + g_object_unref (data->account); + g_object_unref (data->backend); + g_free (data); + + return NULL; +} + static void e_book_backend_exchange_set_mode (EBookBackend *backend, int mode) { @@ -2394,8 +2468,12 @@ e_book_backend_exchange_set_mode (EBookB e_book_backend_notify_writable (backend, bepriv->is_writable); e_book_backend_notify_connection_status (backend, TRUE); account = exchange_component_get_account_for_uri (global_exchange_component, NULL); - if (!exchange_account_get_context (account)) - e_book_backend_notify_auth_required (backend); + if (!exchange_account_get_context (account)) { + SetModeData *data = g_new (SetModeData, 1); + data->account = g_object_ref (account); + data->backend = g_object_ref (backend); + g_thread_create (set_mode_thread, data, FALSE, NULL); + } } /*}*/ } @@ -2454,6 +2532,11 @@ e_book_backend_exchange_dispose (GObject if (be->priv->create_mutex) g_mutex_free (be->priv->create_mutex); + if (be->priv->creds_mutex) + g_mutex_free (be->priv->creds_mutex); + + if (be->priv->creds) + g_hash_table_destroy (be->priv->creds); g_free (be->priv); be->priv = NULL; @@ -2495,6 +2578,8 @@ e_book_backend_exchange_class_init (EBoo backend_class->set_mode = e_book_backend_exchange_set_mode; backend_class->get_supported_auth_methods = e_book_backend_exchange_get_supported_auth_methods; backend_class->authenticate_user = e_book_backend_exchange_authenticate_user; + backend_class->add_client = e_book_backend_exchange_add_client; + backend_class->remove_client = e_book_backend_exchange_remove_client; sync_class->remove_sync = e_book_backend_exchange_remove; sync_class->create_contact_sync = e_book_backend_exchange_create_contact; @@ -2523,6 +2608,8 @@ e_book_backend_exchange_init (EBookBacke priv->is_writable = TRUE; priv->create_mutex = g_mutex_new (); + priv->creds_mutex = g_mutex_new (); + priv->creds = g_hash_table_new (g_direct_hash, g_direct_equal); backend->priv = priv; } --- evolution-exchange-2.8.2.orig/calendar/e-cal-backend-exchange.c 2006-07-12 09:26:56.000000000 -0400 +++ evolution-exchange-2.8.2.orig/calendar/e-cal-backend-exchange.c 2007-04-18 15:17:40.000000000 -0400 @@ -47,6 +47,7 @@ #include <e-folder-exchange.h> #include "exchange-component.h" #include <exchange-hierarchy.h> +#include "exchange-gca-creds.h" struct ECalBackendExchangePrivate { gboolean read_only; @@ -310,6 +311,7 @@ open_calendar (ECalBackendSync *backend, E2kUri *euri = NULL; int nresults = 0; guint access = 0; + E2kCreds *creds; d(printf("ecbe_open_calendar(%p, %p, %sonly if exists, user=%s, pass=%s)\n", backend, cal, only_if_exists?"":"not ", username?username:"(null)", password?password:"(null)")); @@ -371,8 +371,9 @@ open_calendar (ECalBackendSync *backend, cbex->account = exchange_component_get_account_for_uri (global_exchange_component, uristr); if (!cbex->account) { cbex->account = exchange_component_get_account_for_uri (global_exchange_component, NULL); + creds = exchange_gca_creds_add (cbex->account, e_data_cal_get_listener (cal)); exchange_account_set_online (cbex->account); - if (!exchange_account_connect (cbex->account, password, &acresult)) { + if (!exchange_account_connect (cbex->account, creds ? NULL : password, &acresult)) { g_mutex_unlock (cbex->priv->open_lock); e_cal_backend_notify_error (E_CAL_BACKEND (cbex), _("Authentication failed")); return GNOME_Evolution_Calendar_AuthenticationFailed; @@ -381,7 +382,8 @@ open_calendar (ECalBackendSync *backend, if (exchange_account_get_context (cbex->account)) { exchange_account_set_online (cbex->account); - if(!exchange_account_connect (cbex->account, password, &acresult)) { + creds = exchange_gca_creds_add (cbex->account, e_data_cal_get_listener (cal)); + if(!exchange_account_connect (cbex->account, creds ? NULL : password, &acresult)) { g_mutex_unlock (cbex->priv->open_lock); e_cal_backend_notify_error (E_CAL_BACKEND (cbex), _("Authentication failed")); return GNOME_Evolution_Calendar_AuthenticationFailed; --- evolution-exchange-2.8.2.orig/camel/camel-exchange-store.c 2007-04-18 15:17:22.000000000 -0400 +++ evolution-exchange-2.8.2.orig/camel/camel-exchange-store.c 2007-04-18 15:17:40.000000000 -0400 @@ -27,6 +27,10 @@ #include <camel/camel-i18n.h> +#ifdef HAVE_GNOME_CERTAUTH +#include <gnome-certauth/gca-nss.h> +#endif /* HAVE_GNOME_CERTAUTH */ + #include "camel-exchange-store.h" #include "camel-exchange-folder.h" #include "camel-exchange-summary.h" @@ -416,6 +420,7 @@ exchange_connect (CamelService *service, return TRUE; } +#if 0 if (online_mode) { camel_exchange_get_password (service, ex); if (camel_exception_is_set (ex)) { @@ -424,6 +429,7 @@ exchange_connect (CamelService *service, } password = service->url->passwd; } +#endif /* Initialize the stub connection */ if (!camel_stub_send (exch->stub, NULL, CAMEL_STUB_CMD_CONNECT, @@ -837,6 +843,23 @@ exchange_rename_folder (CamelStore *stor CAMEL_STUB_ARG_END); } +#ifdef HAVE_GNOME_CERTAUTH +static gnutls_datum_t * +data_to_datum (gnutls_datum_t *datum, const GByteArray *data) +{ + datum->size = data->len; + datum->data = data->data; + return datum; +} +static GByteArray * +datum_to_data (GByteArray *data, const gnutls_datum_t *datum) +{ + data->len = datum->size; + data->data = datum->data; + return data; +} +#endif + static void stub_notification (CamelObject *object, gpointer event_data, gpointer user_data) { @@ -1114,6 +1137,124 @@ stub_notification (CamelObject *object, break; } + case CAMEL_STUB_RETVAL_PASSWORD_REQUIRED: + { + CamelService *service = CAMEL_SERVICE (exch); + CamelException ex; + char *password = NULL; + + camel_exception_init (&ex); + camel_exchange_get_password (service, &ex); + if (camel_exception_is_set (&ex)) { + camel_exception_clear (&ex); + break; + } else { + password = service->url->passwd; + } + + camel_stub_send_oneway (stub, CAMEL_STUB_CMD_PASSWORD_PRESENTED, + CAMEL_STUB_ARG_STRING, password, + CAMEL_STUB_ARG_END); + } + +#ifdef HAVE_GNOME_CERTAUTH + case CAMEL_STUB_RETVAL_CERTIFICATE_REQUESTED: + { + gnutls_datum_t *req_ca_rdn_der = NULL; + guint32 nreqs; + + gnutls_datum_t *cert_der_ret = NULL; + int cert_der_ret_length = 0; + GPtrArray *gcert_der = NULL; + + GByteArray *tmp; + int i; + int status; + + if (camel_stub_marshal_decode_uint32 (stub->status, &nreqs) == -1) { + nreqs = 0; + goto i_has_an_error; + } + + req_ca_rdn_der = g_new0 (gnutls_datum_t, nreqs); + for (i = 0; i < nreqs && status != -1; i++) { + status = camel_stub_marshal_decode_bytes (stub->status, &tmp); + if (status != -1) { + data_to_datum (&req_ca_rdn_der[i], tmp); + g_byte_array_free (tmp, FALSE); + } + } + if (status == -1) { + /* only clean up part-way */ + nreqs = i; + goto i_has_an_error; + } + + gca_nss_request_certificate (req_ca_rdn_der, nreqs, + &cert_der_ret, &cert_der_ret_length); + + if (cert_der_ret_length) { + /* this is lame... */ + gcert_der = g_ptr_array_sized_new (cert_der_ret_length); + g_ptr_array_set_size (gcert_der, cert_der_ret_length); + for (i = 0; i < cert_der_ret_length; i++) { + tmp = g_byte_array_new (); + datum_to_data (tmp, &cert_der_ret[i]); + g_ptr_array_index (gcert_der, i) = tmp; + } + } + + /* i_has_an_error: */ + camel_stub_send_oneway (stub, CAMEL_STUB_CMD_CERTIFICATE_PRESENTED, + CAMEL_STUB_ARG_BYTEARRAY_ARRAY, gcert_der, + CAMEL_STUB_ARG_END); + + for (i = 0; i < cert_der_ret_length; i++) { + g_byte_array_free (g_ptr_array_index (gcert_der, i), TRUE); + } + g_free (cert_der_ret); + g_ptr_array_free (gcert_der, TRUE); + + i_has_an_error: + for (i = 0; i < nreqs; i++) { + g_free (req_ca_rdn_der[i].data); + } + g_free (req_ca_rdn_der); + + break; + } + + case CAMEL_STUB_RETVAL_SIGN_DATA: + { + GByteArray *cert = NULL; + gnutls_datum_t cert_datum; + GByteArray *hash = NULL; + gnutls_datum_t hash_datum; + GByteArray signature; + gnutls_datum_t signature_datum; + + if (camel_stub_marshal_decode_bytes (stub->status, &cert) == -1 || + camel_stub_marshal_decode_bytes (stub->status, &hash) == -1) { + goto i_has_an_error_sign; + } + + gca_nss_sign_data (data_to_datum (&cert_datum, cert), + data_to_datum (&hash_datum, hash), + data_to_datum (&signature_datum, &signature)); + camel_stub_send_oneway (stub, CAMEL_STUB_CMD_DATA_SIGNED, + CAMEL_STUB_ARG_BYTEARRAY, datum_to_data (&signature, &signature_datum), + CAMEL_STUB_ARG_END); + + g_free (signature.data); + + i_has_an_error_sign: + g_byte_array_free (cert, TRUE); + g_byte_array_free (hash, TRUE); + + break; + } +#endif + default: g_assert_not_reached (); break; --- evolution-exchange-2.8.2.orig/camel/camel-stub.c 2006-08-07 04:30:54.000000000 -0400 +++ evolution-exchange-2.8.2.orig/camel/camel-stub.c 2007-04-18 15:17:40.000000000 -0400 @@ -315,6 +315,19 @@ stub_send_internal (CamelStub *stub, Cam camel_stub_marshal_encode_uint32 (stub->cmd, g_array_index (arr, guint32, i)); break; } + + case CAMEL_STUB_ARG_BYTEARRAY_ARRAY: + { + GPtrArray *arr = va_arg (ap, GPtrArray *); + int len = arr ? arr->len : 0; + int i; + + camel_stub_marshal_encode_uint32 (stub->cmd, len); + for (i = 0; i < len; i++) { + camel_stub_marshal_encode_bytes (stub->cmd, g_ptr_array_index (arr, i)); + } + break; + } default: g_assert_not_reached (); --- evolution-exchange-2.8.2.orig/camel/camel-stub-constants.h 2006-02-13 06:59:42.000000000 -0500 +++ evolution-exchange-2.8.2.orig/camel/camel-stub-constants.h 2007-04-18 15:17:40.000000000 -0400 @@ -32,7 +32,10 @@ typedef enum { CAMEL_STUB_CMD_RENAME_FOLDER, CAMEL_STUB_CMD_SUBSCRIBE_FOLDER, CAMEL_STUB_CMD_UNSUBSCRIBE_FOLDER, - CAMEL_STUB_CMD_IS_SUBSCRIBED_FOLDER + CAMEL_STUB_CMD_IS_SUBSCRIBED_FOLDER, + CAMEL_STUB_CMD_PASSWORD_PRESENTED, + CAMEL_STUB_CMD_CERTIFICATE_PRESENTED, + CAMEL_STUB_CMD_DATA_SIGNED } CamelStubCommand; typedef enum { @@ -44,7 +47,8 @@ typedef enum { CAMEL_STUB_ARG_BYTEARRAY, CAMEL_STUB_ARG_STRINGARRAY, CAMEL_STUB_ARG_FOLDER, - CAMEL_STUB_ARG_UINT32ARRAY + CAMEL_STUB_ARG_UINT32ARRAY, + CAMEL_STUB_ARG_BYTEARRAY_ARRAY } CamelStubArgType; typedef enum { @@ -66,7 +70,10 @@ typedef enum { CAMEL_STUB_RETVAL_FOLDER_CREATED, CAMEL_STUB_RETVAL_FOLDER_DELETED, CAMEL_STUB_RETVAL_FOLDER_RENAMED, - CAMEL_STUB_RETVAL_FOLDER_SET_READONLY + CAMEL_STUB_RETVAL_FOLDER_SET_READONLY, + CAMEL_STUB_RETVAL_PASSWORD_REQUIRED, + CAMEL_STUB_RETVAL_CERTIFICATE_REQUESTED, + CAMEL_STUB_RETVAL_SIGN_DATA } CamelStubRetval; typedef enum { --- evolution-exchange-2.8.2.orig/camel/camel-stub-marshal.c 2006-08-07 10:01:25.000000000 -0400 +++ evolution-exchange-2.8.2.orig/camel/camel-stub-marshal.c 2007-04-18 15:17:40.000000000 -0400 @@ -88,8 +88,8 @@ do_read (CamelStubMarshal *marshal, char { size_t nread = 0; ssize_t n; - - do { + + while (marshal->fd != -1 && nread < len) { if ((n = camel_read (marshal->fd, buf + nread, len - nread)) <= 0) { if (errno != ETIMEDOUT) break; @@ -97,7 +97,7 @@ do_read (CamelStubMarshal *marshal, char n = 0; } nread += n; - } while (nread < len); + } if (nread < len) { close (marshal->fd); --- evolution-exchange-2.8.2.orig/config.h.in 2006-11-20 10:51:42.000000000 -0500 +++ evolution-exchange-2.8.2.orig/config.h.in 2007-04-18 15:17:40.000000000 -0400 @@ -51,6 +51,9 @@ /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H +/* Define if NSS is installed */ +#undef HAVE_NSS + /* Define to 1 if you have the <stdint.h> header file. */ #undef HAVE_STDINT_H --- evolution-exchange-2.8.2.orig/configure.in 2006-11-20 10:49:52.000000000 -0500 +++ evolution-exchange-2.8.2.orig/configure.in 2007-04-18 15:17:40.000000000 -0400 @@ -177,7 +177,18 @@ else LIBSOUP_VERSION=2.2 fi -PKG_CHECK_MODULES(EXCHANGE_STORAGE, evolution-shell-$EVOLUTION_BASE_VERSION evolution-plugin-$EVOLUTION_BASE_VERSION libedataserverui-$EDS_API_VERSION libedata-book-$EDS_API_VERSION libedata-cal-$EDS_API_VERSION libsoup-$LIBSOUP_VERSION libglade-2.0 libgnomeui-2.0 libgnomeprint-2.2 >= 2.2.0 camel-provider-$EDS_API_VERSION) +EXCHANGE_STORAGE_MODULES="evolution-shell-$EVOLUTION_BASE_VERSION evolution-plugin-$EVOLUTION_BASE_VERSION libedataserverui-$EDS_API_VERSION libedata-book-$EDS_API_VERSION libedata-cal-$EDS_API_VERSION libsoup-$LIBSOUP_VERSION libglade-2.0 libgnomeui-2.0 libgnomeprint-2.2 >= 2.2.0 camel-provider-$EDS_API_VERSION" +NSS_MODULES="nss >= 3.11" +PKG_CHECK_EXISTS([$NSS_MODULES], [ + EXCHANGE_STORAGE_MODULES="$EXCHANGE_STORAGE_MODULES $NSS_MODULES" + AC_DEFINE(HAVE_NSS, 1, [Define if NSS is installed]) +]) +GCA_MODULES="gnome-certauth-0.0 >= 0.0" +PKG_CHECK_EXISTS([$GCA_MODULES], [ + EXCHANGE_STORAGE_MODULES="$EXCHANGE_STORAGE_MODULES $GCA_MODULES" + AC_DEFINE(HAVE_GNOME_CERTAUTH, 1, [Define if gnome-certauth is installed]) +]) +PKG_CHECK_MODULES(EXCHANGE_STORAGE, [$EXCHANGE_STORAGE_MODULES]) AC_SUBST(EXCHANGE_STORAGE_CFLAGS) AC_SUBST(EXCHANGE_STORAGE_LIBS) --- evolution-exchange-2.8.2.orig/mail/mail-stub.c 2006-11-20 10:49:52.000000000 -0500 +++ evolution-exchange-2.8.2.orig/mail/mail-stub.c 2007-04-18 15:17:40.000000000 -0400 @@ -79,6 +79,23 @@ free_string_array (GPtrArray *strings) g_ptr_array_free (strings, TRUE); } +#ifdef HAVE_GNOME_CERTAUTH +static gnutls_datum_t * +data_to_datum (gnutls_datum_t *datum, const GByteArray *data) +{ + datum->size = data->len; + datum->data = data->data; + return datum; +} +static GByteArray * +datum_to_data (GByteArray *data, const gnutls_datum_t *datum) +{ + data->len = datum->size; + data->data = datum->data; + return data; +} +#endif + static gboolean connection_handler (GIOChannel *source, GIOCondition condition, gpointer data) { @@ -447,6 +464,67 @@ connection_handler (GIOChannel *source, break; } + case CAMEL_STUB_CMD_PASSWORD_PRESENTED: + { + char *password; + + g_object_ref (stub); + if (!mail_stub_read_args (stub, + CAMEL_STUB_ARG_STRING, &password, + CAMEL_STUB_ARG_END)) + goto comm_fail; + + d(printf("PASSWORD_PRESENTED %s\n", password)); + MS_CLASS (stub)->password_presented (stub, password); + g_free (password); + break; + } + + case CAMEL_STUB_CMD_CERTIFICATE_PRESENTED: + { + GPtrArray *certs; + gnutls_datum_t *gcerts = NULL; + int ncerts; + int i; + + g_object_ref (stub); + if (!mail_stub_read_args (stub, + CAMEL_STUB_ARG_BYTEARRAY_ARRAY, &certs, + CAMEL_STUB_ARG_END)) + goto comm_fail; + + d(printf("CERTIFICATE_PRESENTED %d certs\n", certs->len)); + if (certs->len) { + gcerts = g_new (gnutls_datum_t, certs->len); + for (i = 0; i < certs->len; i++) { + data_to_datum (&gcerts[i], g_ptr_array_index (certs, i)); + } + } + MS_CLASS (stub)->certificate_presented (stub, gcerts, certs->len); + for (i = 0; i < certs->len; i++) { + g_byte_array_free (g_ptr_array_index (certs, i), TRUE); + } + g_ptr_array_free (certs, TRUE); + g_free (gcerts); + break; + } + + case CAMEL_STUB_CMD_DATA_SIGNED: + { + GByteArray *signature; + gnutls_datum_t gsignature; + + g_object_ref (stub); + if (!mail_stub_read_args (stub, + CAMEL_STUB_ARG_BYTEARRAY, &signature, + CAMEL_STUB_ARG_END)) + goto comm_fail; + d(printf("DATA_SIGNED %d bytes\n", signature->len)); + MS_CLASS (stub)->data_signed (stub, data_to_datum (&gsignature, signature)); + g_byte_array_free (signature, TRUE); + break; + } + default: g_assert_not_reached (); break; @@ -563,7 +641,36 @@ mail_stub_read_args (MailStub *stub, ... break; } - + case CAMEL_STUB_ARG_BYTEARRAY_ARRAY: + { + GPtrArray **ret = va_arg (ap, GPtrArray **); + + GByteArray *tmp; + int len; + int i; + + status = camel_stub_marshal_decode_uint32 (stub->cmd, &len); + if (status == -1) + break; + + *ret = g_ptr_array_sized_new (len); + g_ptr_array_set_size (*ret, len); + for (i = 0; i < len && status != -1; i++) { + status = camel_stub_marshal_decode_bytes (stub->cmd, &tmp); + if (status != -1) { + g_ptr_array_index (*ret, i) = tmp; + } + } + if (status == -1) { + for (--i; i >= 0; --i) { + g_byte_array_free (g_ptr_array_index (*ret, i), TRUE); + } + g_ptr_array_free (*ret, TRUE); + *ret = NULL; + } + break; + } + default: g_assert_not_reached (); status = -1; @@ -668,7 +775,18 @@ mail_stub_return_data (MailStub *stub, C camel_stub_marshal_encode_uint32 (marshal, g_array_index (arr, guint32, i)); break; } - + + case CAMEL_STUB_ARG_BYTEARRAY_ARRAY: + { + GPtrArray *arr = va_arg (ap, GPtrArray *); + int i; + + camel_stub_marshal_encode_uint32 (marshal, arr->len); + for (i = 0; i < arr->len; i++) { + camel_stub_marshal_encode_bytes (marshal, g_ptr_array_index (arr, i)); + } + break; + } default: g_assert_not_reached (); --- evolution-exchange-2.8.2.orig/mail/mail-stub-exchange.c 2006-05-10 05:13:41.000000000 -0400 +++ evolution-exchange-2.8.2.orig/mail/mail-stub-exchange.c 2007-04-18 15:17:40.000000000 -0400 @@ -43,7 +43,14 @@ #include <exchange-hierarchy.h> #include <mapi.h> -#define d(x) +#define TRACE(s, ...) d(fprintf (stderr, "%d:%s:%s():%d "s"\n", getpid(), __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)) +#define TRACEMSG(s) TRACE("%s", (s)) +#define ENTER TRACEMSG("ENTER") +#define EXIT TRACEMSG("EXIT") +#define HASLOCK TRACEMSG("HAS LOCK") +#define ALREADYLOCKED TRACEMSG("ALREADY LOCKED") + +#define d(x) x #define PARENT_TYPE MAIL_TYPE_STUB static MailStubClass *parent_class = NULL; @@ -87,6 +94,21 @@ typedef struct { guint sync_deletion_timeout; } MailStubExchangeFolder; +struct _MailStubExchangeCreds { + E2kCreds creds; + GMutex *mutex; + GMutex *cond_mutex; + GCond *cond; + CamelStubCommand expected_cmd; + gboolean returned; + MailStubExchange *mse; + int mode; + char *pwd; + gnutls_datum_t *cert_der_ret; + int cert_der_ret_length; + gnutls_datum_t *signature; +}; + static void dispose (GObject *); static void stub_connect (MailStub *stub, char *pwd); @@ -150,6 +157,10 @@ static void folder_update_linestatus (gp static void free_folder (gpointer value); static gboolean get_folder_online (MailStubExchangeFolder *mfld, gboolean background); +static void certificate_presented (MailStub *, const gnutls_datum_t *, int); +static void data_signed (MailStub *, const gnutls_datum_t *); +static void password_presented (MailStub *, const char *); + static GStaticMutex g_changed_msgs_mutex = G_STATIC_MUTEX_INIT; static void @@ -164,6 +190,9 @@ class_init (GObjectClass *object_class) stub_class->subscribe_folder = subscribe_folder; stub_class->unsubscribe_folder = unsubscribe_folder; stub_class->is_subscribed_folder = is_subscribed_folder; + stub_class->certificate_presented = certificate_presented; + stub_class->data_signed = data_signed; + stub_class->password_presented = password_presented; } static void @@ -232,6 +261,18 @@ dispose (GObject *object) mse->removed_folder_id = 0; } + if (mse->creds) { + exchange_account_remove_creds (mse->account, &mse->creds->creds); + g_object_unref (mse->account); + + g_mutex_free (mse->creds->mutex); + g_mutex_free (mse->creds->cond_mutex); + g_cond_free (mse->creds->cond); + g_free (mse->creds->pwd); + g_free (mse->creds); + mse->creds = NULL; + } + /* if (g_signal_handler_is_connected (G_OBJECT (global_exchange_component), offline_listener_handler_id)) { g_signal_handler_disconnect (G_OBJECT (global_exchange_component), @@ -2792,15 +2833,333 @@ is_subscribed_folder (MailStub *stub, co mail_stub_return_ok (stub); } +static char * +stub_connect_http_auth_method (E2kCreds *ecreds) +{ + MailStubExchangeCreds *creds = (MailStubExchangeCreds *)ecreds; + return exchange_account_get_authtype (creds->mse->account); +} + +static void +password_presented (MailStub *stub, const char *password) +{ + MailStubExchange *mse = MAIL_STUB_EXCHANGE (stub); + MailStubExchangeCreds *creds = mse->creds; + + ENTER; + + g_mutex_lock (creds->cond_mutex); + + HASLOCK; + + if (creds->expected_cmd == CAMEL_STUB_CMD_PASSWORD_PRESENTED) { + creds->pwd = g_strdup (password); + + creds->returned = TRUE; + g_cond_signal (creds->cond); + } else { + fprintf (stderr, "Got Spurious PASSWORD_PRESENTED; ignoring\n"); + } + + g_mutex_unlock (creds->cond_mutex); + + EXIT; +} + +static void +stub_connect_http_authenticate (E2kCreds *ecreds, + const char *auth_type, const char *auth_realm, + char **username, char **password) +{ + MailStubExchangeCreds *creds = (MailStubExchangeCreds *)ecreds; + MailStubExchange *mse; + MailStub *stub; + + ENTER; + + g_mutex_lock (creds->mutex); + g_mutex_lock (creds->cond_mutex); + + HASLOCK; + + mse = creds->mse; + g_object_ref (mse); + + creds->expected_cmd = CAMEL_STUB_CMD_PASSWORD_PRESENTED; + + if (!creds->pwd) { + stub = MAIL_STUB (mse); + *username = exchange_account_get_username (mse->account); + mail_stub_return_data (stub, CAMEL_STUB_RETVAL_PASSWORD_REQUIRED, + CAMEL_STUB_ARG_END); + mail_stub_push_changes (stub); + + while (!creds->returned) { + g_cond_wait (creds->cond, creds->cond_mutex); + } + creds->returned = FALSE; + } + + *password = creds->pwd; + + creds->expected_cmd = -1; + + g_object_unref (mse); + g_mutex_unlock (creds->cond_mutex); + g_mutex_unlock (creds->mutex); + + EXIT; +} + +#ifdef HAVE_GNOME_CERTAUTH +static gnutls_datum_t * +data_to_datum (gnutls_datum_t *datum, const GByteArray *data) +{ + datum->size = data->len; + datum->data = data->data; + return datum; +} +static GByteArray * +datum_to_data (GByteArray *data, const gnutls_datum_t *datum) +{ + data->len = datum->size; + data->data = datum->data; + return data; +} +#endif + +static void +certificate_presented (MailStub *stub, const gnutls_datum_t *certs_der, int ncerts) +{ + MailStubExchange *mse = MAIL_STUB_EXCHANGE (stub); + MailStubExchangeCreds *creds = mse->creds; + int i; + + ENTER; + + g_mutex_lock (creds->cond_mutex); + + HASLOCK; + + if (creds->expected_cmd == CAMEL_STUB_CMD_CERTIFICATE_PRESENTED) { + creds->cert_der_ret_length = ncerts; + creds->cert_der_ret = g_new (gnutls_datum_t, ncerts); + for (i = 0; i < ncerts; i++) { + creds->cert_der_ret[i].size = certs_der[i].size; + creds->cert_der_ret[i].data = g_malloc (certs_der[i].size); + memcpy (creds->cert_der_ret[i].data, certs_der[i].data, certs_der[i].size); + } + + creds->returned = TRUE; + g_cond_signal (creds->cond); + } else { + fprintf (stderr, "Got Spurious CERTIFICATE_PRESENTED; ignoring\n"); + } + + g_mutex_unlock (creds->cond_mutex); + + EXIT; +} + +static int +stub_connect_ssl_cert_request (E2kCreds *ecreds, + const gnutls_datum_t *req_ca_rdn_der, + int nreqs, + gnutls_datum_t **cert_der_ret, + int *cert_der_ret_length) +{ + MailStubExchangeCreds *creds = (MailStubExchangeCreds *)ecreds; + GPtrArray *greqs; + MailStub *stub; + int i; + + ENTER; + + g_mutex_lock (creds->mutex); + g_mutex_lock (creds->cond_mutex); + + HASLOCK; + + g_object_ref (creds->mse); + + creds->expected_cmd = CAMEL_STUB_CMD_CERTIFICATE_PRESENTED; + + stub = MAIL_STUB (creds->mse); + + greqs = g_ptr_array_sized_new (nreqs); + g_ptr_array_set_size (greqs, nreqs); + for (i = 0; i < nreqs; i++) { + g_ptr_array_index (greqs, i) = g_byte_array_new (); + datum_to_data (g_ptr_array_index (greqs, i), &req_ca_rdn_der[i]); + } + + mail_stub_return_data (stub, CAMEL_STUB_RETVAL_CERTIFICATE_REQUESTED, + CAMEL_STUB_ARG_BYTEARRAY_ARRAY, greqs, + CAMEL_STUB_ARG_END); + mail_stub_push_changes (stub); + + for (i = 0; i < nreqs; i++) { + g_byte_array_free (g_ptr_array_index (greqs, i), FALSE); + } + g_ptr_array_free (greqs, TRUE); + + while (!creds->returned) { + g_cond_wait (creds->cond, creds->cond_mutex); + } + creds->returned = FALSE; + + creds->expected_cmd = -1; + + *cert_der_ret = creds->cert_der_ret; + creds->cert_der_ret = NULL; + + *cert_der_ret_length = creds->cert_der_ret_length; + creds->cert_der_ret_length = -1; + + g_object_unref (creds->mse); + g_mutex_unlock (creds->cond_mutex); + g_mutex_unlock (creds->mutex); + + EXIT; + + return 0; +} + +static void +data_signed (MailStub *stub, const gnutls_datum_t *signature) +{ + MailStubExchange *mse = MAIL_STUB_EXCHANGE (stub); + MailStubExchangeCreds *creds = mse->creds; + + ENTER; + + g_mutex_lock (creds->cond_mutex); + + HASLOCK; + + if (creds->expected_cmd == CAMEL_STUB_CMD_DATA_SIGNED) { + creds->signature->size = signature->size; + creds->signature->data = g_malloc (signature->size); + memcpy (creds->signature->data, signature->data, signature->size); + + creds->returned = TRUE; + g_cond_signal (creds->cond); + } else { + fprintf (stderr, "Got Spurious DATA_SIGNED; ignoring\n"); + } + + g_mutex_unlock (creds->cond_mutex); + + EXIT; +} + +static int +stub_connect_ssl_cert_sign (E2kCreds *ecreds, + const gnutls_datum_t *cert_der, + const gnutls_datum_t *hash, + gnutls_datum_t *signature) +{ + MailStubExchangeCreds *creds = (MailStubExchangeCreds *)ecreds; + MailStub *stub; + + ENTER; + + g_mutex_lock (creds->mutex); + g_mutex_lock (creds->cond_mutex); + + HASLOCK; + + g_object_ref (creds->mse); + + creds->expected_cmd = CAMEL_STUB_CMD_DATA_SIGNED; + + stub = MAIL_STUB (creds->mse); + + creds->signature = signature; + + mail_stub_return_data (stub, CAMEL_STUB_RETVAL_SIGN_DATA, + CAMEL_STUB_ARG_BYTEARRAY, cert_der->data, cert_der->size, + CAMEL_STUB_ARG_BYTEARRAY, hash->data, hash->size, + CAMEL_STUB_ARG_END); + mail_stub_push_changes (stub); + + while (!creds->returned) { + g_cond_wait (creds->cond, creds->cond_mutex); + } + + creds->returned = FALSE; + creds->signature = NULL; + creds->expected_cmd = -1; + + g_object_unref (creds->mse); + g_mutex_unlock (creds->cond_mutex); + g_mutex_unlock (creds->mutex); + + EXIT; + + return 0; +} + +static void +stub_connect_end (MailStubExchange *mse, E2kContext *ctx, int mode) +{ + MailStub *stub = MAIL_STUB (mse); + const char *uri; + int retval = 1; + + if (mode == ONLINE_MODE) { + if (ctx) { + mse->ctx = g_object_ref (ctx); + + mse->mail_submission_uri = exchange_account_get_standard_uri (mse->account, "sendmsg"); + uri = exchange_account_get_standard_uri (mse->account, "inbox"); + mse->inbox = exchange_account_get_folder (mse->account, uri); + uri = exchange_account_get_standard_uri (mse->account, "deleteditems"); + mse->deleted_items = exchange_account_get_folder (mse->account, uri); + + /* Will be used for offline->online transition to initialize things for + the first time */ + + g_hash_table_foreach (mse->folders_by_name, + (GHFunc) folder_update_linestatus, + GINT_TO_POINTER (mode)); + } else { + retval = 0; + } + } + + mail_stub_return_data (stub, CAMEL_STUB_RETVAL_RESPONSE, + CAMEL_STUB_ARG_UINT32, retval, + CAMEL_STUB_ARG_END); + + mail_stub_return_ok (stub); +} + +static gpointer +stub_connect_thread (gpointer user_data) +{ + MailStubExchangeCreds *creds = user_data; + ExchangeAccountResult result; + E2kContext *ctx; + + ENTER; + + ctx = exchange_account_connect (creds->mse->account, NULL, &result); + stub_connect_end (creds->mse, ctx, creds->mode); + + g_object_unref (creds->mse); + + EXIT; + + return NULL; +} + static void stub_connect (MailStub *stub, char *pwd) { MailStubExchange *mse = MAIL_STUB_EXCHANGE (stub); ExchangeAccount *account; - ExchangeAccountResult result; E2kContext *ctx; - guint32 retval = 1; - const char *uri; int mode; exchange_component_is_offline (global_exchange_component, &mode); @@ -2812,38 +3171,16 @@ stub_connect (MailStub *stub, char *pwd) exchange_account_set_offline (account); ctx = exchange_account_get_context (account); - if (!ctx) { - ctx = exchange_account_connect (account, pwd, &result); + if (ctx) { + stub_connect_end (mse, ctx, mode); + return; } - - - if (!ctx && mode == ONLINE_MODE) { - retval = 0; - goto end; - } else if (mode == OFFLINE_MODE) { - goto end; - } - - mse->ctx = g_object_ref (ctx); - - mse->mail_submission_uri = exchange_account_get_standard_uri (account, "sendmsg"); - uri = exchange_account_get_standard_uri (account, "inbox"); - mse->inbox = exchange_account_get_folder (account, uri); - uri = exchange_account_get_standard_uri (account, "deleteditems"); - mse->deleted_items = exchange_account_get_folder (account, uri); - /* Will be used for offline->online transition to initialize things for - the first time */ - - g_hash_table_foreach (mse->folders_by_name, - (GHFunc) folder_update_linestatus, - GINT_TO_POINTER (mode)); -end: - mail_stub_return_data (stub, CAMEL_STUB_RETVAL_RESPONSE, - CAMEL_STUB_ARG_UINT32, retval, - CAMEL_STUB_ARG_END); + mse->creds->mode = mode; + mse->creds->pwd = g_strdup (pwd); + g_object_ref (mse); - mail_stub_return_ok (stub); + g_thread_create (stub_connect_thread, mse->creds, FALSE, NULL); } #if 0 @@ -2924,8 +3261,23 @@ mail_stub_exchange_new (ExchangeAccount mail_stub_construct (stub, cmd_fd, status_fd); mse = (MailStubExchange *)stub; - mse->account = account; - + mse->account = g_object_ref (account); + + mse->creds = g_new0 (MailStubExchangeCreds, 1); + + mse->creds->creds.http_auth_method = stub_connect_http_auth_method; + mse->creds->creds.http_authenticate = stub_connect_http_authenticate; + mse->creds->creds.ssl_cert_request = stub_connect_ssl_cert_request; + mse->creds->creds.ssl_cert_sign = stub_connect_ssl_cert_sign; + + mse->creds->mutex = g_mutex_new (); + mse->creds->cond_mutex = g_mutex_new (); + mse->creds->cond = g_cond_new (); + mse->creds->returned = FALSE; + mse->creds->mse = mse; + + exchange_account_add_creds (account, &mse->creds->creds); + /* offline_listener_handler_id = g_signal_connect (G_OBJECT (global_exchange_component), "linestatus-changed", G_CALLBACK (linestatus_listener), mse); */ --- evolution-exchange-2.8.2.orig/mail/mail-stub-exchange.h 2005-06-14 09:12:43.000000000 -0400 +++ evolution-exchange-2.8.2.orig/mail/mail-stub-exchange.h 2007-04-18 15:17:40.000000000 -0400 @@ -20,7 +20,7 @@ extern "C" { typedef struct _MailStubExchange MailStubExchange; typedef struct _MailStubExchangeClass MailStubExchangeClass; - +typedef struct _MailStubExchangeCreds MailStubExchangeCreds; struct _MailStubExchange { MailStub parent; @@ -32,6 +32,7 @@ struct _MailStubExchange { guint new_folder_id, removed_folder_id; const char *ignore_new_folder, *ignore_removed_folder; + MailStubExchangeCreds *creds; }; struct _MailStubExchangeClass { --- evolution-exchange-2.8.2.orig/mail/mail-stub.h 2005-08-22 10:22:02.000000000 -0400 +++ evolution-exchange-2.8.2.orig/mail/mail-stub.h 2007-04-18 15:17:40.000000000 -0400 @@ -8,6 +8,7 @@ #include <glib-object.h> #include "camel-stub-constants.h" #include "camel-stub-marshal.h" +#include <gnutls/gnutls.h> #ifdef __cplusplus extern "C" { @@ -72,6 +73,10 @@ struct _MailStubClass { void (*subscribe_folder) (MailStub *, const char *folder_name); void (*unsubscribe_folder) (MailStub *, const char *folder_name); void (*is_subscribed_folder) (MailStub *, const char *folder_name); + + void (*certificate_presented) (MailStub *, const gnutls_datum_t *cert_der_ret, int ncerts); + void (*data_signed) (MailStub *, const gnutls_datum_t *signature); + void (*password_presented) (MailStub *, const char *password); }; GType mail_stub_get_type (void); --- evolution-exchange-2.8.2.orig/storage/exchange-config-listener.c 2006-03-06 01:38:01.000000000 -0500 +++ evolution-exchange-2.8.2.orig/storage/exchange-config-listener.c 2007-04-18 15:17:40.000000000 -0400 @@ -67,6 +67,11 @@ typedef struct { int type; }FolderInfo; +typedef struct { + E2kCreds creds; + ExchangeAccount *account; +} AccountCreds; + enum { EXCHANGE_ACCOUNT_CREATED, EXCHANGE_ACCOUNT_REMOVED, --- evolution-exchange-2.8.2.orig/storage/exchange-gca-creds.c 1969-12-31 19:00:00.000000000 -0500 +++ evolution-exchange-2.8.2.orig/storage/exchange-gca-creds.c 2007-04-18 15:17:40.000000000 -0400 @@ -0,0 +1,164 @@ +#include "config.h" + +#include "exchange-gca-creds.h" + +#ifdef HAVE_GNOME_CERTAUTH +#include <gnome-certauth/gca-certificate-listener.h> + +#include <glib/gthread.h> +#include <bonobo/bonobo-main.h> +#include <sys/types.h> +#include <unistd.h> + +#if 1 +#define GCA_TRACE(s, ...) fprintf (stderr, "%d:%s:%s():%d "s"\n", getpid(), __FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__) +#else +#define GCA_TRACE(s, ...) +#endif + +#define GCA_TRACEMSG(s) GCA_TRACE("%s", (s)) +#define GCA_ENTER GCA_TRACEMSG("ENTER") +#define GCA_EXIT GCA_TRACEMSG("EXIT") +#define GCA_HASLOCK GCA_TRACEMSG("HAS LOCK") +#define GCA_ALREADYLOCKED GCA_TRACEMSG("ALREADY LOCKED") + +typedef struct { + E2kCreds creds; + GMutex *mutex; + ExchangeAccount *account; + GcaCertificateListener *listener; + GNOME_CertificateAuthentication_CertificateSource source; +} GcaCreds; + +static char * +exchange_gca_creds_http_auth_method (E2kCreds *ecreds) +{ + GcaCreds *creds = (GcaCreds *)ecreds; + char *ret; + GCA_ENTER; + ret = exchange_account_get_authtype (creds->account); + GCA_EXIT; + return ret; +} + +static void +exchange_gca_creds_http_authenticate (E2kCreds *ecreds, + const char *auth_type, const char *auth_realm, + char **username, char **password) +{ + GcaCreds *creds = (GcaCreds *)ecreds; + GCA_ENTER; + *username = exchange_account_get_username (creds->account); + *password = exchange_account_get_password (creds->account); + GCA_ENTER; +} + +static int +exchange_gca_creds_ssl_cert_request (E2kCreds *ecreds, + const gnutls_datum_t *req_ca_rdn_der, + int nreqs, + gnutls_datum_t **cert_der_ret, + int *cert_der_ret_length) +{ + GcaCreds *creds = (GcaCreds *)ecreds; + GCA_ENTER; + g_mutex_lock (creds->mutex); + GCA_HASLOCK; + if (!creds->listener) { + creds->listener = GCA_CERTIFICATE_LISTENER (g_object_new (GCA_TYPE_CERTIFICATE_LISTENER, + "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST), + NULL)); + } + g_mutex_unlock (creds->mutex); + gca_certificate_listener_request_certificate ( + creds->listener, creds->source, + req_ca_rdn_der, nreqs, + cert_der_ret, cert_der_ret_length); + GCA_EXIT; + return 0; +} + +static int +exchange_gca_creds_ssl_cert_sign (E2kCreds *ecreds, + const gnutls_datum_t *cert_der, + const gnutls_datum_t *hash_data, + gnutls_datum_t *sig_data) +{ + GcaCreds *creds = (GcaCreds *)ecreds; + GCA_ENTER; + g_mutex_lock (creds->mutex); + GCA_HASLOCK; + if (!creds->listener) { + creds->listener = GCA_CERTIFICATE_LISTENER (g_object_new (GCA_TYPE_CERTIFICATE_LISTENER, + "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST), + NULL)); + } + g_mutex_unlock (creds->mutex); + gca_certificate_listener_sign_data ( + creds->listener, creds->source, + cert_der, hash_data, sig_data); + GCA_EXIT; + return 0; +} +#endif /* HAVE_GNOME_CERTAUTH */ + +void +exchange_gca_creds_remove (E2kCreds *ecreds) +{ +#ifdef HAVE_GNOME_CERTAUTH + GcaCreds *creds = (GcaCreds *)ecreds; + + fprintf (stderr, "%s: killing creds!\n", G_GNUC_PRETTY_FUNCTION); + + g_mutex_lock (creds->mutex); + exchange_account_remove_creds (creds->account, &creds->creds); + g_mutex_unlock (creds->mutex); + g_mutex_free (creds->mutex); + if (creds->listener) { + g_object_unref (creds->listener); + } + g_free (creds); +#endif /* HAVE_GNOME_CERTAUTH */ +} + +E2kCreds * +exchange_gca_creds_add (ExchangeAccount *account, + Bonobo_Unknown source) +{ +#ifdef HAVE_GNOME_CERTAUTH + GcaCreds *creds; + CORBA_Environment ev; + GNOME_CertificateAuthentication_CertificateSource corba_source; + + CORBA_exception_init (&ev); + corba_source = bonobo_object_query_remote ( + source, + "IDL:GNOME/CertificateAuthentication/CertificateSource:1.0", + &ev); + CORBA_exception_free (&ev); + + if (!corba_source) { + fprintf (stderr, "%s: listener is not a certificate source\n", G_GNUC_PRETTY_FUNCTION); + return NULL; + } + + creds = g_new0 (GcaCreds, 1); + creds->source = corba_source; + creds->account = account; + creds->mutex = g_mutex_new (); + creds->listener = NULL; + creds->creds.http_auth_method = exchange_gca_creds_http_auth_method; + creds->creds.http_authenticate = exchange_gca_creds_http_authenticate; + creds->creds.ssl_cert_request = exchange_gca_creds_ssl_cert_request; + creds->creds.ssl_cert_sign = exchange_gca_creds_ssl_cert_sign; + + exchange_account_add_creds (account, &creds->creds); + + /* bonobo_object_set_immoral (BONOBO_OBJECT (book), TRUE); */ + /* g_object_weak_ref (G_OBJECT (book), book_remove_creds, creds); */ + + return &creds->creds; +#else /* !HAVE_GNOME_CERTAUTH */ + return NULL; +#endif /* !HAVE_GNOME_CERTAUTH */ +} --- evolution-exchange-2.8.2.orig/storage/exchange-gca-creds.h 1969-12-31 19:00:00.000000000 -0500 +++ evolution-exchange-2.8.2.orig/storage/exchange-gca-creds.h 2007-04-18 15:17:40.000000000 -0400 @@ -0,0 +1,13 @@ +#ifndef EXCHANGE_GCA_CREDS_H +#define EXCHANGE_GCA_CREDS_H + +#include <exchange/exchange-account.h> +#include <bonobo/bonobo-object.h> + +E2kCreds *exchange_gca_creds_add (ExchangeAccount *account, + Bonobo_Unknown source); + +void exchange_gca_creds_remove (E2kCreds *creds); + +#endif /* EXCHANGE_GCA_CREDS_H */ + --- evolution-exchange-2.8.2.orig/storage/main.c 2005-12-17 02:27:18.000000000 -0500 +++ evolution-exchange-2.8.2.orig/storage/main.c 2007-04-18 15:17:40.000000000 -0400 @@ -235,6 +235,8 @@ main (int argc, char **argv) } #endif + e_passwords_init (); + bonobo_main (); e_passwords_shutdown (); --- evolution-exchange-2.8.2.orig/storage/Makefile.am 2006-05-24 03:36:09.000000000 -0400 +++ evolution-exchange-2.8.2.orig/storage/Makefile.am 2007-04-18 15:17:40.000000000 -0400 @@ -23,19 +23,21 @@ noinst_PROGRAMS = \ exchange-connector-setup \ migr-test -evolution_exchange_storage_SOURCES = \ - exchange-autoconfig-wizard.c \ - exchange-autoconfig-wizard.h \ - exchange-component.c \ - exchange-component.h \ - exchange-config-listener.c \ - exchange-config-listener.h \ - exchange-change-password.c \ - exchange-change-password.h \ - exchange-migrate.c \ - exchange-migrate.h \ - exchange-storage.c \ - exchange-storage.h \ +evolution_exchange_storage_SOURCES = \ + exchange-autoconfig-wizard.c \ + exchange-autoconfig-wizard.h \ + exchange-component.c \ + exchange-component.h \ + exchange-config-listener.c \ + exchange-config-listener.h \ + exchange-change-password.c \ + exchange-change-password.h \ + exchange-gca-creds.c \ + exchange-gca-creds.h \ + exchange-migrate.c \ + exchange-migrate.h \ + exchange-storage.c \ + exchange-storage.h \ main.c evolution_exchange_storage_LDADD = \ --- evolution-exchange-2.8.2.orig/storage/Makefile.in 2006-11-20 10:51:44.000000000 -0500 +++ evolution-exchange-2.8.2.orig/storage/Makefile.in 2007-04-18 15:17:40.000000000 -0400 @@ -59,7 +59,7 @@ am_evolution_exchange_storage_OBJECTS = exchange-component.$(OBJEXT) \ exchange-config-listener.$(OBJEXT) \ exchange-change-password.$(OBJEXT) exchange-migrate.$(OBJEXT) \ - exchange-storage.$(OBJEXT) main.$(OBJEXT) + exchange-storage.$(OBJEXT) exchange-nss.$(OBJEXT) main.$(OBJEXT) evolution_exchange_storage_OBJECTS = \ $(am_evolution_exchange_storage_OBJECTS) am__DEPENDENCIES_1 = @@ -71,11 +71,13 @@ evolution_exchange_storage_DEPENDENCIES $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_migr_test_OBJECTS = migr-test.$(OBJEXT) \ + exchange-nss.$(OBJEXT) \ exchange-config-listener.$(OBJEXT) exchange-migrate.$(OBJEXT) migr_test_OBJECTS = $(am_migr_test_OBJECTS) migr_test_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_ximian_connector_setup_OBJECTS = ximian-connector-setup.$(OBJEXT) \ + exchange-nss.$(OBJEXT) \ exchange-config-listener.$(OBJEXT) \ exchange-autoconfig-wizard.$(OBJEXT) ximian_connector_setup_OBJECTS = $(am_ximian_connector_setup_OBJECTS) @@ -341,6 +341,8 @@ evolution_exchange_storage_SOURCES = \ exchange-change-password.h \ exchange-migrate.c \ exchange-migrate.h \ + exchange-nss.c \ + exchange-nss.h \ exchange-storage.c \ exchange-storage.h \ main.c @@ -358,6 +360,8 @@ exchange_connector_setup_SOURCES = \ ximian-connector-setup.c \ exchange-config-listener.c \ exchange-config-listener.h \ + exchange-nss.c \ + exchange-nss.h \ exchange-autoconfig-wizard.c exchange_connector_setup_LDADD = \ @@ -369,6 +373,8 @@ migr_test_SOURCES = \ migr-test.c \ exchange-config-listener.c \ exchange-config-listener.h \ + exchange-nss.c \ + exchange-nss.h \ exchange-migrate.c \ exchange-migrate.h --- evolution-exchange-2.8.2/camel/Makefile.am~ 2005-09-16 00:24:25.000000000 -0400 +++ evolution-exchange-2.8.2/camel/Makefile.am 2007-05-04 13:54:26.000000000 -0400 @@ -9,6 +9,7 @@ INCLUDES = \ $(CAMEL_CFLAGS) \ $(SHELL_CFLAGS) \ $(LIBEXCHANGE_CFLAGS) \ + $(EXCHANGE_STORAGE_CFLAGS) \ -DCONNECTOR_LOCALEDIR=\"$(localedir)\" \ -DG_LOG_DOMAIN=\"camel-exchange-provider\" --- evolution-exchange-2.6.0/camel/camel-stub.c~ 2007-05-17 17:13:59.000000000 -0400 +++ evolution-exchange-2.6.0/camel/camel-stub.c 2007-05-17 17:14:54.000000000 -0400 @@ -309,11 +309,10 @@ stub_send_internal (CamelStub *stub, Cam case CAMEL_STUB_ARG_BYTEARRAY_ARRAY: { GPtrArray *arr = va_arg (ap, GPtrArray *); - int len = arr ? arr->len : 0; int i; - camel_stub_marshal_encode_uint32 (stub->cmd, len); - for (i = 0; i < len; i++) { + camel_stub_marshal_encode_uint32 (stub->cmd, arr->len); + for (i = 0; i < arr->len; i++) { camel_stub_marshal_encode_bytes (stub->cmd, g_ptr_array_index (arr, i)); } break; --- evolution-exchange-2.6.0/camel/camel-exchange-store.c~ 2007-05-17 17:13:59.000000000 -0400 +++ evolution-exchange-2.6.0/camel/camel-exchange-store.c 2007-05-17 17:16:21.000000000 -0400 @@ -1172,15 +1172,13 @@ stub_notification (CamelObject *object, gca_nss_request_certificate (req_ca_rdn_der, nreqs, &cert_der_ret, &cert_der_ret_length); - if (cert_der_ret_length) { - /* this is lame... */ - gcert_der = g_ptr_array_sized_new (cert_der_ret_length); - g_ptr_array_set_size (gcert_der, cert_der_ret_length); - for (i = 0; i < cert_der_ret_length; i++) { - tmp = g_byte_array_new (); - datum_to_data (tmp, &cert_der_ret[i]); - g_ptr_array_index (gcert_der, i) = tmp; - } + /* this is lame... */ + gcert_der = g_ptr_array_sized_new (cert_der_ret_length); + g_ptr_array_set_size (gcert_der, cert_der_ret_length); + for (i = 0; i < cert_der_ret_length; i++) { + tmp = g_byte_array_new (); + datum_to_data (tmp, &cert_der_ret[i]); + g_ptr_array_index (gcert_der, i) = tmp; } /* i_has_an_error: */ Index: evolution-exchange-2.6.0/mail/mail-stub-exchange.c =================================================================== --- evolution-exchange-2.6.0/mail/mail-stub-exchange.c (revision 1359) +++ evolution-exchange-2.6.0/mail/mail-stub-exchange.c (working copy) @@ -95,8 +117,11 @@ static void get_trash_name (MailStub *stub); static void sync_folder (MailStub *stub, const char *folder_name); static void refresh_folder (MailStub *stub, const char *folder_name); +typedef void (*FolderRefreshedFunc) (MailStub *stub, MailStubExchangeFolder *mfld, + gpointer user_data); static void refresh_folder_internal (MailStub *stub, MailStubExchangeFolder *mfld, - gboolean background); + gboolean background, + FolderRefreshedFunc func, gpointer user_data); static void sync_deletions (MailStubExchange *mse, MailStubExchangeFolder *mfld); static void expunge_uids (MailStub *stub, const char *folder_name, GPtrArray *uids); static void append_message (MailStub *stub, const char *folder_name, guint32 flags, @@ -462,7 +506,7 @@ time_t now; if (type == E2K_CONTEXT_OBJECT_ADDED) - refresh_folder_internal (MAIL_STUB (mfld->mse), mfld, TRUE); + refresh_folder_internal (MAIL_STUB (mfld->mse), mfld, TRUE, NULL, NULL); else { now = time (NULL); @@ -522,7 +566,7 @@ MailStubExchangeFolder *mfld = user_data; if (e_folder_get_unread_count (folder) > mfld->unread_count) - refresh_folder_internal (MAIL_STUB (mfld->mse), mfld, TRUE); + refresh_folder_internal (MAIL_STUB (mfld->mse), mfld, TRUE, NULL, NULL); } static void @@ -1050,10 +1094,21 @@ }; static const int num_new_message_props = sizeof (new_message_props) / sizeof (new_message_props[0]); -static void -refresh_folder_internal (MailStub *stub, MailStubExchangeFolder *mfld, - gboolean background) +typedef struct { + MailStub *stub; + MailStubExchangeFolder *mfld; + gboolean background; + FolderRefreshedFunc func; + gpointer user_data; +} RefreshFolderData; + +static gpointer +refresh_folder_thread (gpointer user_data) { + RefreshFolderData *data = user_data; + MailStub *stub = data->stub; + MailStubExchangeFolder *mfld = data->mfld;; + gboolean background = data->background; E2kRestriction *rn; GArray *messages; GHashTable *mapi_message_hash; @@ -1068,8 +1123,6 @@ gpointer key, value; MailStubExchangeMessage *mmsg; - g_object_ref (stub); - exchange_component_is_offline (global_exchange_component, &mode); if (mode == OFFLINE_MODE) { if (background) @@ -1077,8 +1130,13 @@ else mail_stub_return_ok (stub); + if (data->func) { + data->func (stub, mfld, data->user_data); + } + g_object_unref (stub); /* Is this needed ? */ - return; + g_free (data); + return NULL; } messages = g_array_new (FALSE, FALSE, sizeof (struct refresh_message)); @@ -1301,10 +1359,39 @@ g_hash_table_destroy (mapi_message_hash); g_ptr_array_free (mapi_hrefs, TRUE); + if (data->func) { + data->func (stub, mfld, data->user_data); + } + g_object_unref (stub); + g_free (data); + return NULL; } static void +refresh_folder_internal (MailStub *stub, MailStubExchangeFolder *mfld, + gboolean background, + FolderRefreshedFunc func, gpointer user_data) +{ + RefreshFolderData *data; + + data = g_new0 (RefreshFolderData, 1); + data->stub = g_object_ref (stub); + data->mfld = mfld; + data->background = background; + data->func = func; + data->user_data = user_data; + + g_thread_create (refresh_folder_thread, data, FALSE, NULL); +} + +static void +folder_refreshed (MailStub *stub, MailStubExchangeFolder *mfld, gpointer user_data) +{ + sync_deletions (MAIL_STUB_EXCHANGE (stub), mfld); +} + +static void refresh_folder (MailStub *stub, const char *folder_name) { MailStubExchange *mse = MAIL_STUB_EXCHANGE (stub); @@ -1314,8 +1401,7 @@ if (!mfld) return; - refresh_folder_internal (stub, mfld, FALSE); - sync_deletions (mse, mfld); + refresh_folder_internal (stub, mfld, FALSE, folder_refreshed, NULL); } static void
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor