diff options
author | Chris Toshok <toshok@ximian.com> | 2003-01-10 09:55:27 +0800 |
---|---|---|
committer | Chris Toshok <toshok@src.gnome.org> | 2003-01-10 09:55:27 +0800 |
commit | 2a174936f49118ce60e76b0debe4600fdbb4bc33 (patch) | |
tree | 7bce87f3a0a6ca53f04d5c63f6ed2aa4aece5fea | |
parent | 50a352b3670e6b8e8d29a9559d2442fcf0b62c5e (diff) | |
download | gsoc2013-evolution-2a174936f49118ce60e76b0debe4600fdbb4bc33.tar gsoc2013-evolution-2a174936f49118ce60e76b0debe4600fdbb4bc33.tar.gz gsoc2013-evolution-2a174936f49118ce60e76b0debe4600fdbb4bc33.tar.bz2 gsoc2013-evolution-2a174936f49118ce60e76b0debe4600fdbb4bc33.tar.lz gsoc2013-evolution-2a174936f49118ce60e76b0debe4600fdbb4bc33.tar.xz gsoc2013-evolution-2a174936f49118ce60e76b0debe4600fdbb4bc33.tar.zst gsoc2013-evolution-2a174936f49118ce60e76b0debe4600fdbb4bc33.zip |
build up the list of supported auth_methods.
2003-01-09 Chris Toshok <toshok@ximian.com>
* backend/pas/pas-backend-ldap.c (query_ldap_root_dse): build up
the list of supported auth_methods.
(pas_backend_ldap_process_get_supported_auth_methods): respond
with the list of auth methods we've built up.
(pas_backend_ldap_dispose): unref the auth_method list.
(pas_backend_ldap_class_init): hook up
pas_backend_ldap_process_get_supported_auth_methods.
* backend/pas/pas-backend.c
(pas_backend_get_supported_auth_methods): new function.
(process_client_requests): add clause for GetSupportedAuthMethods.
* backend/pas/pas-backend.h: add prototype for
pas_backend_get_supported_auth_methods, and add it to the class
vtable.
* backend/pas/pas-book.h: add GetSupportedAuthMethods enum member
and PASGetSupportedAuthMethodsRequest. and add prototype for
pas_book_respond_get_supported_auth_methods.
* backend/pas/pas-book.c
(pas_book_queue_get_supported_auth_methods): new function.
(impl_GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods):
new function.
(pas_book_respond_get_supported_auth_methods): new function.
(pas_book_free_request): add clause for GetSupportedAuthMethods.
(pas_book_class_init): hook up getSupportedAuthMethods.
* backend/ebook/e-book-listener.c
(e_book_listener_queue_get_supported_fields_response): fields ->
list.
(e_book_listener_queue_get_supported_auth_methods_response): new
function.
(impl_BookListener_response_get_supported_auth_methods): new
function.
(e_book_listener_class_init): hook up
epv->notifySupportedAuthMethods.
* backend/ebook/e-book-listener.h: add
GetSupportedAuthMethodsResponse enum member, and change the field
name from "fields" to list (and use it for both GetSupportedFields
and GetSupportedAuthMethods)
* backend/ebook/e-book.c (e_book_get_supported_auth_methods): new
function.
(e_book_do_response_get_supported_auth_methods): new function.
* backend/ebook/e-book.h: add prototype for
e_book_get_supported_auth_methods.
* backend/idl/addressbook.idl: add getSupportedAuthMethods IDL
call.
svn path=/trunk/; revision=19386
-rw-r--r-- | addressbook/ChangeLog | 55 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book-listener.c | 41 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book-listener.h | 5 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book.c | 65 | ||||
-rw-r--r-- | addressbook/backend/ebook/e-book.h | 4 | ||||
-rw-r--r-- | addressbook/backend/idl/addressbook.idl | 27 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-ldap.c | 136 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend.c | 18 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend.h | 4 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.c | 85 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.h | 37 |
11 files changed, 411 insertions, 66 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 8dacf693d9..0dae516a4f 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,5 +1,60 @@ 2003-01-09 Chris Toshok <toshok@ximian.com> + * backend/pas/pas-backend-ldap.c (query_ldap_root_dse): build up + the list of supported auth_methods. + (pas_backend_ldap_process_get_supported_auth_methods): respond + with the list of auth methods we've built up. + (pas_backend_ldap_dispose): unref the auth_method list. + (pas_backend_ldap_class_init): hook up + pas_backend_ldap_process_get_supported_auth_methods. + + * backend/pas/pas-backend.c + (pas_backend_get_supported_auth_methods): new function. + (process_client_requests): add clause for GetSupportedAuthMethods. + + * backend/pas/pas-backend.h: add prototype for + pas_backend_get_supported_auth_methods, and add it to the class + vtable. + + * backend/pas/pas-book.h: add GetSupportedAuthMethods enum member + and PASGetSupportedAuthMethodsRequest. and add prototype for + pas_book_respond_get_supported_auth_methods. + + * backend/pas/pas-book.c + (pas_book_queue_get_supported_auth_methods): new function. + (impl_GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods): + new function. + (pas_book_respond_get_supported_auth_methods): new function. + (pas_book_free_request): add clause for GetSupportedAuthMethods. + (pas_book_class_init): hook up getSupportedAuthMethods. + + * backend/ebook/e-book-listener.c + (e_book_listener_queue_get_supported_fields_response): fields -> + list. + (e_book_listener_queue_get_supported_auth_methods_response): new + function. + (impl_BookListener_response_get_supported_auth_methods): new + function. + (e_book_listener_class_init): hook up + epv->notifySupportedAuthMethods. + + * backend/ebook/e-book-listener.h: add + GetSupportedAuthMethodsResponse enum member, and change the field + name from "fields" to list (and use it for both GetSupportedFields + and GetSupportedAuthMethods) + + * backend/ebook/e-book.c (e_book_get_supported_auth_methods): new + function. + (e_book_do_response_get_supported_auth_methods): new function. + + * backend/ebook/e-book.h: add prototype for + e_book_get_supported_auth_methods. + + * backend/idl/addressbook.idl: add getSupportedAuthMethods IDL + call. + +2003-01-09 Chris Toshok <toshok@ximian.com> + * backend/pas/pas-book-factory.c (backend_last_client_gone_cb): deal with backends that might not have loaded successfully (they'll have a NULL uri). diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c index 6fb9b737ae..ecb9c0e9a8 100644 --- a/addressbook/backend/ebook/e-book-listener.c +++ b/addressbook/backend/ebook/e-book-listener.c @@ -360,10 +360,34 @@ e_book_listener_queue_get_supported_fields_response (EBookListener *listener, resp->op = GetSupportedFieldsResponse; resp->status = status; - resp->fields = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL); + resp->list = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL); for (i = 0; i < fields->_length; i ++) { - e_list_append (resp->fields, fields->_buffer[i]); + e_list_append (resp->list, fields->_buffer[i]); + } + + e_book_listener_queue_response (listener, resp); +} + +static void +e_book_listener_queue_get_supported_auth_methods_response (EBookListener *listener, + EBookStatus status, + const GNOME_Evolution_Addressbook_stringlist *auth_methods) +{ + EBookListenerResponse *resp; + int i; + + if (listener->priv->stopped) + return; + + resp = g_new0 (EBookListenerResponse, 1); + + resp->op = GetSupportedAuthMethodsResponse; + resp->status = status; + resp->list = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL); + + for (i = 0; i < auth_methods->_length; i ++) { + e_list_append (resp->list, auth_methods->_buffer[i]); } e_book_listener_queue_response (listener, resp); @@ -545,6 +569,18 @@ impl_BookListener_response_get_supported_fields (PortableServer_Servant servant, } static void +impl_BookListener_response_get_supported_auth_methods (PortableServer_Servant servant, + const GNOME_Evolution_Addressbook_BookListener_CallStatus status, + const GNOME_Evolution_Addressbook_stringlist *auth_methods, + CORBA_Environment *ev) +{ + EBookListener *listener = E_BOOK_LISTENER (bonobo_object (servant)); + + e_book_listener_queue_get_supported_auth_methods_response ( + listener, status, auth_methods); +} + +static void impl_BookListener_report_connection_status (PortableServer_Servant servant, const CORBA_boolean connected, CORBA_Environment *ev) @@ -745,6 +781,7 @@ e_book_listener_class_init (EBookListenerClass *klass) epv->notifyCardModified = impl_BookListener_respond_modify_card; epv->notifyAuthenticationResult = impl_BookListener_respond_authentication_result; epv->notifySupportedFields = impl_BookListener_response_get_supported_fields; + epv->notifySupportedAuthMethods = impl_BookListener_response_get_supported_auth_methods; epv->notifyCardRequested = impl_BookListener_respond_get_vcard; epv->notifyCursorRequested = impl_BookListener_respond_get_cursor; epv->notifyViewRequested = impl_BookListener_respond_get_view; diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h index 26cd684aab..1b02dd4bb6 100644 --- a/addressbook/backend/ebook/e-book-listener.h +++ b/addressbook/backend/ebook/e-book-listener.h @@ -57,6 +57,7 @@ typedef enum { GetChangesResponse, AuthenticationResponse, GetSupportedFieldsResponse, + GetSupportedAuthMethodsResponse, /* Async events */ LinkStatusEvent, @@ -79,8 +80,8 @@ typedef struct { /* For GetBookViewReponse */ GNOME_Evolution_Addressbook_BookView book_view; - /* For GetSupportedFields */ - EList *fields; + /* For GetSupportedFields/GetSupportedAuthMethods */ + EList *list; /* For OpenProgressEvent */ char *msg; diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c index 2ec99c1a37..195418d29b 100644 --- a/addressbook/backend/ebook/e-book.c +++ b/addressbook/backend/ebook/e-book.c @@ -481,12 +481,38 @@ e_book_do_response_get_supported_fields (EBook *book, if (op->cb) { if (op->active) - ((EBookFieldsCallback) op->cb) (book, resp->status, resp->fields, op->closure); + ((EBookFieldsCallback) op->cb) (book, resp->status, resp->list, op->closure); else ((EBookFieldsCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure); } - g_object_unref(resp->fields); + g_object_unref(resp->list); + + e_book_op_free (op); +} + +static void +e_book_do_response_get_supported_auth_methods (EBook *book, + EBookListenerResponse *resp) +{ + EBookOp *op; + + op = e_book_pop_op (book); + + if (op == NULL) { + g_warning ("e_book_do_response_get_supported_auth_methods: Cannot find operation " + "in local op queue!\n"); + return; + } + + if (op->cb) { + if (op->active) + ((EBookAuthMethodsCallback) op->cb) (book, resp->status, resp->list, op->closure); + else + ((EBookAuthMethodsCallback) op->cb) (book, E_BOOK_STATUS_CANCELLED, NULL, op->closure); + } + + g_object_unref(resp->list); e_book_op_free (op); } @@ -531,6 +557,9 @@ e_book_check_listener_queue (EBookListener *listener, EBook *book) case GetSupportedFieldsResponse: e_book_do_response_get_supported_fields (book, resp); break; + case GetSupportedAuthMethodsResponse: + e_book_do_response_get_supported_auth_methods (book, resp); + break; case OpenProgressEvent: e_book_do_progress_event (book, resp); @@ -870,6 +899,38 @@ e_book_get_supported_fields (EBook *book, return tag; } +guint +e_book_get_supported_auth_methods (EBook *book, + EBookAuthMethodsCallback cb, + gpointer closure) +{ + CORBA_Environment ev; + guint tag; + + CORBA_exception_init (&ev); + + if (book->priv->load_state != URILoaded) { + g_warning ("e_book_unload_uri: No URI is loaded!\n"); + return 0; + } + + tag = e_book_queue_op (book, cb, closure, NULL); + + GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods(book->priv->corba_book, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("e_book_get_supported_auth_methods: Exception " + "during get_supported_auth_methods!\n"); + CORBA_exception_free (&ev); + e_book_unqueue_op (book); + return 0; + } + + CORBA_exception_free (&ev); + + return tag; +} + static gboolean e_book_construct (EBook *book) { diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h index c7b8a100e8..bbc49b711c 100644 --- a/addressbook/backend/ebook/e-book.h +++ b/addressbook/backend/ebook/e-book.h @@ -60,6 +60,7 @@ typedef void (*EBookCardCallback) (EBook *book, EBookStatus status, ECard *c typedef void (*EBookCursorCallback) (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure); typedef void (*EBookBookViewCallback) (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure); typedef void (*EBookFieldsCallback) (EBook *book, EBookStatus status, EList *fields, gpointer closure); +typedef void (*EBookAuthMethodsCallback) (EBook *book, EBookStatus status, EList *auth_methods, gpointer closure); /* Creating a new addressbook. */ EBook *e_book_new (void); @@ -78,6 +79,9 @@ guint e_book_get_supported_fields (EBook *book, EBookFieldsCallback cb, gpointer closure); +guint e_book_get_supported_auth_methods (EBook *book, + EBookAuthMethodsCallback cb, + gpointer closure); /* User authentication. */ void e_book_authenticate_user (EBook *book, diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl index 18a60f074f..84996fe75e 100644 --- a/addressbook/backend/idl/addressbook.idl +++ b/addressbook/backend/idl/addressbook.idl @@ -103,6 +103,30 @@ module Addressbook { void getSupportedFields (); + /* + * This function returns a list of strings + * representing the auth methods (e.g. SASL mechs) + * that a backend/server supports. + * + * Some examples are: + * + * "ldap/simple-email|By email Address" + * "sasl/CRAM-MD5|CRAM-MD5(SASL)" + * + * The format should be: + * + * <class>/<type>|<i18nized string> + * + * "i18nized string" is shown in the UI, and should be + * a user friendly representation of the auth method. + * + * in the case of SASL auth mechs, the text trailing + * the '/' should be the proper name of the mechanism, + * as it will be passed unchanged to the backend auth + * function (eg. ldap_sasl_bind) + */ + void getSupportedAuthMethods (); + string getStaticCapabilities (); string getName (); @@ -120,6 +144,7 @@ module Addressbook { AuthenticationFailed, AuthenticationRequired, UnsupportedField, + UnsupportedAuthenticationMethod, TLSNotAvailable, NoSuchBook, @@ -148,6 +173,8 @@ module Addressbook { void notifySupportedFields (in CallStatus status, in stringlist fields); + void notifySupportedAuthMethods (in CallStatus status, in stringlist fields); + /** * notifyConnectionStatus: * diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c index 353879e6e1..3ef2bcb4dd 100644 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ b/addressbook/backend/pas/pas-backend-ldap.c @@ -44,6 +44,9 @@ #include <stdlib.h> +/* this is broken currently, don't enable it */ +/*#define ENABLE_SASL_BINDS*/ + typedef enum { PAS_BACKEND_LDAP_TLS_NO, PAS_BACKEND_LDAP_TLS_ALWAYS, @@ -109,6 +112,7 @@ struct _PASBackendLDAPPrivate { LDAP *ldap; EList *supported_fields; + EList *supported_auth_methods; /* whether or not there's support for the objectclass we need to store all our additional fields */ @@ -585,8 +589,25 @@ query_ldap_root_dse (PASBackendLDAP *bl) values = ldap_get_values (ldap, resp, "supportedSASLMechanisms"); if (values) { - for (i = 0; values[i]; i++) + char *auth_method; + if (bl->priv->supported_auth_methods) + g_object_unref (bl->priv->supported_auth_methods); + bl->priv->supported_auth_methods = e_list_new ((EListCopyFunc)g_strdup, (EListFreeFunc)g_free, NULL); + + auth_method = g_strdup_printf ("ldap/simple-binddn|%s", _()); + e_list_append (bl->priv->supported_auth_methods, auth_method); + g_free (auth_method); + + auth_method = g_strdup_printf ("ldap/simple-email|%s"); + e_list_append (bl->priv->supported_auth_methods, auth_method); + g_free (auth_method); + + for (i = 0; values[i]; i++) { + auth_method = g_strdup_printf ("sasl/%s|%s", values[i], values[i]); + e_list_append (bl->priv->supported_auth_methods, auth_method); + g_free (auth_method); g_message ("supported SASL mechanism: %s", values[i]); + } ldap_value_free (values); } @@ -3129,6 +3150,9 @@ pas_backend_ldap_process_check_connection (PASBackend *backend, pas_book_report_connection (book, bl->priv->connected); } +#define LDAP_SIMPLE_PREFIX "ldap/simple-" +#define SASL_PREFIX "sasl/" + static void pas_backend_ldap_process_authenticate_user (PASBackend *backend, PASBook *book, @@ -3138,51 +3162,78 @@ pas_backend_ldap_process_authenticate_user (PASBackend *backend, int ldap_error; char *dn = NULL; - if (!strcmp (req->auth_method, "ldap/simple-email")) { - LDAPMessage *res, *e; - char *query = g_strdup_printf ("(mail=%s)", req->user); + if (!strncasecmp (req->auth_method, LDAP_SIMPLE_PREFIX, strlen (LDAP_SIMPLE_PREFIX))) { + + if (!strcmp (req->auth_method, "ldap/simple-email")) { + LDAPMessage *res, *e; + char *query = g_strdup_printf ("(mail=%s)", req->user); - ldap_error = ldap_search_s (bl->priv->ldap, - bl->priv->ldap_rootdn, - bl->priv->ldap_scope, - query, - NULL, 0, &res); - g_free (query); + ldap_error = ldap_search_s (bl->priv->ldap, + bl->priv->ldap_rootdn, + bl->priv->ldap_scope, + query, + NULL, 0, &res); + g_free (query); - if (ldap_error == LDAP_SUCCESS) { - char *entry_dn; + if (ldap_error == LDAP_SUCCESS) { + char *entry_dn; - e = ldap_first_entry (bl->priv->ldap, res); + e = ldap_first_entry (bl->priv->ldap, res); - entry_dn = ldap_get_dn (bl->priv->ldap, e); - dn = g_strdup(entry_dn); + entry_dn = ldap_get_dn (bl->priv->ldap, e); + dn = g_strdup(entry_dn); - ldap_memfree (entry_dn); - ldap_msgfree (res); + ldap_memfree (entry_dn); + ldap_msgfree (res); + } + else { + pas_book_respond_authenticate_user (book, + GNOME_Evolution_Addressbook_BookListener_PermissionDenied); + return; + } } - else { - pas_book_respond_authenticate_user (book, - GNOME_Evolution_Addressbook_BookListener_PermissionDenied); - return; + else if (!strcmp (req->auth_method, "ldap/simple-binddn")) { + dn = g_strdup (req->user); } - } - else if (!strcmp (req->auth_method, "ldap/simple-binddn")) { - dn = g_strdup (req->user); - } - /* now authenticate against the DN we were either supplied or queried for */ - printf ("authenticating as %s\n", dn); - ldap_error = ldap_simple_bind_s(bl->priv->ldap, - dn, - req->passwd); + /* now authenticate against the DN we were either supplied or queried for */ + printf ("simple auth as %s\n", dn); + ldap_error = ldap_simple_bind_s(bl->priv->ldap, + dn, + req->passwd); - bl->priv->auth_dn = dn; - bl->priv->auth_passwd = g_strdup (req->passwd); + pas_book_respond_authenticate_user (book, + ldap_error_to_response (ldap_error)); + } +#ifdef ENABLE_SASL_BINDS + else if (!strncasecmp (req->auth_method, SASL_PREFIX, strlen (SASL_PREFIX))) { + g_print ("sasl bind (mech = %s) as %s", req->auth_method + strlen (SASL_PREFIX), req->user); + ldap_error = ldap_sasl_bind_s (bl->priv->ldap, + NULL, + req->auth_method + strlen (SASL_PREFIX), + req->passwd, + NULL, + NULL, + NULL); - pas_book_respond_authenticate_user (book, - ldap_error_to_response (ldap_error)); + if (ldap_error == LDAP_NOT_SUPPORTED) + pas_book_respond_authenticate_user (book, + GNOME_Evolution_Addressbook_BookListener_UnsupportedAuthenticationMethod); + else + pas_book_respond_authenticate_user (book, + ldap_error_to_response (ldap_error)); + } +#endif + else { + pas_book_respond_authenticate_user (book, + GNOME_Evolution_Addressbook_BookListener_UnsupportedAuthenticationMethod); + return; + } if (ldap_error == LDAP_SUCCESS) { + bl->priv->auth_dn = dn; + bl->priv->auth_passwd = g_strdup (req->passwd); + pas_backend_set_is_writable (backend, TRUE); /* force a requery on the root dse since some ldap @@ -3218,6 +3269,19 @@ pas_backend_ldap_process_get_supported_fields (PASBackend *backend, bl->priv->supported_fields); } +static void +pas_backend_ldap_process_get_supported_auth_methods (PASBackend *backend, + PASBook *book, + PASGetSupportedAuthMethodsRequest *req) + +{ + PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); + + pas_book_respond_get_supported_auth_methods (book, + GNOME_Evolution_Addressbook_BookListener_Success, + bl->priv->supported_auth_methods); +} + static GNOME_Evolution_Addressbook_BookListener_CallStatus pas_backend_ldap_load_uri (PASBackend *backend, const char *uri) @@ -3377,6 +3441,9 @@ pas_backend_ldap_dispose (GObject *object) if (bl->priv->supported_fields) g_object_unref (bl->priv->supported_fields); + if (bl->priv->supported_auth_methods) + g_object_unref (bl->priv->supported_auth_methods); + g_free (bl->priv->uri); g_free (bl->priv); @@ -3416,6 +3483,7 @@ pas_backend_ldap_class_init (PASBackendLDAPClass *klass) parent_class->get_changes = pas_backend_ldap_process_get_changes; parent_class->authenticate_user = pas_backend_ldap_process_authenticate_user; parent_class->get_supported_fields = pas_backend_ldap_process_get_supported_fields; + parent_class->get_supported_auth_methods = pas_backend_ldap_process_get_supported_auth_methods; object_class->dispose = pas_backend_ldap_dispose; } diff --git a/addressbook/backend/pas/pas-backend.c b/addressbook/backend/pas/pas-backend.c index 513632c909..c8acad3c93 100644 --- a/addressbook/backend/pas/pas-backend.c +++ b/addressbook/backend/pas/pas-backend.c @@ -220,6 +220,20 @@ pas_backend_get_supported_fields (PASBackend *backend, return (* PAS_BACKEND_GET_CLASS (backend)->get_supported_fields) (backend, book, req); } +void +pas_backend_get_supported_auth_methods (PASBackend *backend, + PASBook *book, + PASGetSupportedAuthMethodsRequest *req) +{ + g_return_if_fail (PAS_IS_BACKEND (backend)); + g_return_if_fail (PAS_IS_BOOK (book)); + g_return_if_fail (req != NULL); + + g_assert (PAS_BACKEND_GET_CLASS (backend)->get_supported_auth_methods != NULL); + + return (* PAS_BACKEND_GET_CLASS (backend)->get_supported_auth_methods) (backend, book, req); +} + static void process_client_requests (PASBook *book, gpointer user_data) { @@ -276,6 +290,10 @@ process_client_requests (PASBook *book, gpointer user_data) case GetSupportedFields: pas_backend_get_supported_fields (backend, book, &req->get_supported_fields); break; + + case GetSupportedAuthMethods: + pas_backend_get_supported_auth_methods (backend, book, &req->get_supported_auth_methods); + break; } pas_book_free_request (req); diff --git a/addressbook/backend/pas/pas-backend.h b/addressbook/backend/pas/pas-backend.h index 8c3cab2c60..a87e28c2a2 100644 --- a/addressbook/backend/pas/pas-backend.h +++ b/addressbook/backend/pas/pas-backend.h @@ -64,6 +64,7 @@ typedef struct { void (*get_changes) (PASBackend *backend, PASBook *book, PASGetChangesRequest *req); void (*authenticate_user) (PASBackend *backend, PASBook *book, PASAuthenticateUserRequest *req); void (*get_supported_fields) (PASBackend *backend, PASBook *book, PASGetSupportedFieldsRequest *req); + void (*get_supported_auth_methods) (PASBackend *backend, PASBook *book, PASGetSupportedAuthMethodsRequest *req); /* Notification signals */ void (* last_client_gone) (PASBackend *backend); @@ -121,6 +122,9 @@ void pas_backend_authenticate_user (PASBackend *backen void pas_backend_get_supported_fields (PASBackend *backend, PASBook *book, PASGetSupportedFieldsRequest *req); +void pas_backend_get_supported_auth_methods (PASBackend *backend, + PASBook *book, + PASGetSupportedAuthMethodsRequest *req); GType pas_backend_get_type (void); diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c index 9ca049e350..2cb373b9d7 100644 --- a/addressbook/backend/pas/pas-book.c +++ b/addressbook/backend/pas/pas-book.c @@ -153,6 +153,17 @@ pas_book_queue_get_supported_fields (PASBook *book) pas_book_queue_request (book, req); } +static void +pas_book_queue_get_supported_auth_methods (PASBook *book) +{ + PASRequest *req; + + req = g_new0 (PASRequest, 1); + req->op = GetSupportedAuthMethods; + + pas_book_queue_request (book, req); +} + static void pas_book_queue_get_book_view (PASBook *book, const GNOME_Evolution_Addressbook_BookViewListener listener, const char *search) @@ -365,6 +376,15 @@ impl_GNOME_Evolution_Addressbook_Book_getSupportedFields (PortableServer_Servant pas_book_queue_get_supported_fields (book); } +static void +impl_GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + PASBook *book = PAS_BOOK (bonobo_object (servant)); + + pas_book_queue_get_supported_auth_methods (book); +} + /** * pas_book_get_backend: */ @@ -584,6 +604,43 @@ pas_book_respond_get_supported_fields (PASBook *book, CORBA_free(stringlist._buffer); } +void +pas_book_respond_get_supported_auth_methods (PASBook *book, + GNOME_Evolution_Addressbook_BookListener_CallStatus status, + EList *auth_methods) +{ + CORBA_Environment ev; + GNOME_Evolution_Addressbook_stringlist stringlist; + int num_auth_methods; + EIterator *iter; + int i; + + CORBA_exception_init (&ev); + + num_auth_methods = e_list_length (auth_methods); + + stringlist._buffer = CORBA_sequence_CORBA_string_allocbuf (num_auth_methods); + stringlist._maximum = num_auth_methods; + stringlist._length = num_auth_methods; + + iter = e_list_get_iterator (auth_methods); + + for (i = 0; e_iterator_is_valid (iter); e_iterator_next (iter), i ++) { + stringlist._buffer[i] = CORBA_string_dup (e_iterator_get(iter)); + } + + g_object_unref (auth_methods); + + GNOME_Evolution_Addressbook_BookListener_notifySupportedAuthMethods ( + book->priv->listener, status, + &stringlist, + &ev); + + CORBA_exception_free (&ev); + + CORBA_free(stringlist._buffer); +} + /** * pas_book_respond_get_cursor: */ @@ -861,6 +918,9 @@ pas_book_free_request (PASRequest *req) case GetSupportedFields: /* nothing to free */ break; + case GetSupportedAuthMethods: + /* nothing to free */ + break; } g_free (req); @@ -927,18 +987,19 @@ pas_book_class_init (PASBookClass *klass) epv = &klass->epv; - epv->getVCard = impl_GNOME_Evolution_Addressbook_Book_getVCard; - epv->authenticateUser = impl_GNOME_Evolution_Addressbook_Book_authenticateUser; - epv->addCard = impl_GNOME_Evolution_Addressbook_Book_addCard; - epv->removeCard = impl_GNOME_Evolution_Addressbook_Book_removeCard; - epv->modifyCard = impl_GNOME_Evolution_Addressbook_Book_modifyCard; - epv->checkConnection = impl_GNOME_Evolution_Addressbook_Book_checkConnection; - epv->getStaticCapabilities = impl_GNOME_Evolution_Addressbook_Book_getStaticCapabilities; - epv->getSupportedFields = impl_GNOME_Evolution_Addressbook_Book_getSupportedFields; - epv->getCursor = impl_GNOME_Evolution_Addressbook_Book_getCursor; - epv->getBookView = impl_GNOME_Evolution_Addressbook_Book_getBookView; - epv->getCompletionView = impl_GNOME_Evolution_Addressbook_Book_getCompletionView; - epv->getChanges = impl_GNOME_Evolution_Addressbook_Book_getChanges; + epv->getVCard = impl_GNOME_Evolution_Addressbook_Book_getVCard; + epv->authenticateUser = impl_GNOME_Evolution_Addressbook_Book_authenticateUser; + epv->addCard = impl_GNOME_Evolution_Addressbook_Book_addCard; + epv->removeCard = impl_GNOME_Evolution_Addressbook_Book_removeCard; + epv->modifyCard = impl_GNOME_Evolution_Addressbook_Book_modifyCard; + epv->checkConnection = impl_GNOME_Evolution_Addressbook_Book_checkConnection; + epv->getStaticCapabilities = impl_GNOME_Evolution_Addressbook_Book_getStaticCapabilities; + epv->getSupportedFields = impl_GNOME_Evolution_Addressbook_Book_getSupportedFields; + epv->getSupportedAuthMethods = impl_GNOME_Evolution_Addressbook_Book_getSupportedAuthMethods; + epv->getCursor = impl_GNOME_Evolution_Addressbook_Book_getCursor; + epv->getBookView = impl_GNOME_Evolution_Addressbook_Book_getBookView; + epv->getCompletionView = impl_GNOME_Evolution_Addressbook_Book_getCompletionView; + epv->getChanges = impl_GNOME_Evolution_Addressbook_Book_getChanges; } static void diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h index 2ed87ff799..1474e760f4 100644 --- a/addressbook/backend/pas/pas-book.h +++ b/addressbook/backend/pas/pas-book.h @@ -41,7 +41,8 @@ typedef enum { GetChanges, CheckConnection, AuthenticateUser, - GetSupportedFields + GetSupportedFields, + GetSupportedAuthMethods } PASOperation; typedef struct { @@ -103,20 +104,25 @@ typedef struct { PASOperation op; } PASGetSupportedFieldsRequest; +typedef struct { + PASOperation op; +} PASGetSupportedAuthMethodsRequest; + typedef union { - PASOperation op; - - PASCreateCardRequest create; - PASRemoveCardRequest remove; - PASModifyCardRequest modify; - PASGetVCardRequest get_vcard; - PASGetCursorRequest get_cursor; - PASGetBookViewRequest get_book_view; - PASGetCompletionViewRequest get_completion_view; - PASGetChangesRequest get_changes; - PASCheckConnectionRequest check_connection; - PASAuthenticateUserRequest auth_user; - PASGetSupportedFieldsRequest get_supported_fields; + PASOperation op; + + PASCreateCardRequest create; + PASRemoveCardRequest remove; + PASModifyCardRequest modify; + PASGetVCardRequest get_vcard; + PASGetCursorRequest get_cursor; + PASGetBookViewRequest get_book_view; + PASGetCompletionViewRequest get_completion_view; + PASGetChangesRequest get_changes; + PASCheckConnectionRequest check_connection; + PASAuthenticateUserRequest auth_user; + PASGetSupportedFieldsRequest get_supported_fields; + PASGetSupportedAuthMethodsRequest get_supported_auth_methods; } PASRequest; struct _PASBook { @@ -158,6 +164,9 @@ void pas_book_respond_authenticate_user (PASBook void pas_book_respond_get_supported_fields (PASBook *book, GNOME_Evolution_Addressbook_BookListener_CallStatus status, EList *fields); +void pas_book_respond_get_supported_auth_methods (PASBook *book, + GNOME_Evolution_Addressbook_BookListener_CallStatus status, + EList *fields); void pas_book_respond_get_cursor (PASBook *book, GNOME_Evolution_Addressbook_BookListener_CallStatus status, |