diff options
Diffstat (limited to 'addressbook/backend/pas')
-rw-r--r-- | addressbook/backend/pas/pas-backend-file.c | 13 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-backend-ldap.c | 34 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.c | 48 | ||||
-rw-r--r-- | addressbook/backend/pas/pas-book.h | 7 |
4 files changed, 93 insertions, 9 deletions
diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c index cfe7c90ab8..5a9a5a1005 100644 --- a/addressbook/backend/pas/pas-backend-file.c +++ b/addressbook/backend/pas/pas-backend-file.c @@ -1083,6 +1083,15 @@ pas_backend_file_extract_path_from_uri (const char *uri) return g_strdup (uri + 5); } +static void +pas_backend_file_process_authenticate_user (PASBackend *backend, + PASBook *book, + PASRequest *req) +{ + pas_book_respond_authenticate_user (book, + GNOME_Evolution_Addressbook_BookListener_Success); +} + static gboolean can_write (PASBackend *backend) { @@ -1154,6 +1163,10 @@ pas_backend_file_process_client_requests (PASBook *book) case GetChanges: pas_backend_file_process_get_changes (backend, book, req); break; + + case AuthenticateUser: + pas_backend_file_process_authenticate_user (backend, book, req); + break; } g_free (req); diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c index 4d86538a6e..1aa49cd17b 100644 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ b/addressbook/backend/pas/pas-backend-ldap.c @@ -210,18 +210,18 @@ pas_backend_ldap_connect (PASBackendLDAP *bl) { PASBackendLDAPPrivate *blpriv = bl->priv; -#ifdef DEBUG - { - extern int ldap_debug; - ldap_debug = LDAP_DEBUG_ANY; - } -#endif - /* close connection first if it's open first */ if (blpriv->ldap) ldap_unbind (blpriv->ldap); blpriv->ldap = ldap_open (blpriv->ldap_host, blpriv->ldap_port); +#ifdef DEBUG + { + int debug_level = ~0; + ldap_set_option (blpriv->ldap, LDAP_OPT_DEBUG_LEVEL, &debug_level); + } +#endif + if (NULL != blpriv->ldap) { ldap_simple_bind_s(blpriv->ldap, NULL /*binddn*/, NULL /*passwd*/); @@ -1249,7 +1249,7 @@ pas_backend_ldap_build_query (gchar *query) r = e_sexp_eval(sexp); - gtk_object_unref(GTK_OBJECT(sexp)); + e_sexp_unref (sexp); e_sexp_result_free(r); if (list->next) { @@ -1550,6 +1550,20 @@ pas_backend_ldap_process_check_connection (PASBackend *backend, pas_book_report_connection (book, bl->priv->connected); } +static void +pas_backend_ldap_process_authenticate_user (PASBackend *backend, + PASBook *book, + PASRequest *req) +{ + PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); + int ldap_error = ldap_simple_bind_s(bl->priv->ldap, + req->user, + req->passwd); + + pas_book_respond_authenticate_user (book, + ldap_error_to_response (ldap_error)); +} + static gboolean pas_backend_ldap_can_write (PASBook *book) { @@ -1603,6 +1617,10 @@ pas_backend_ldap_process_client_requests (PASBook *book) case GetChanges: /* FIXME: Code this. */ break; + + case AuthenticateUser: + pas_backend_ldap_process_authenticate_user (backend, book, req); + break; } g_free (req); diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c index 6fded8301d..783c699603 100644 --- a/addressbook/backend/pas/pas-book.c +++ b/addressbook/backend/pas/pas-book.c @@ -106,6 +106,20 @@ pas_book_queue_get_cursor (PASBook *book, const char *search) } static void +pas_book_queue_authenticate_user (PASBook *book, + const char *user, const char *passwd) +{ + PASRequest *req; + + req = g_new0 (PASRequest, 1); + req->op = AuthenticateUser; + req->user = g_strdup(user); + req->passwd = g_strdup(passwd); + + 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) { PASRequest *req; @@ -206,6 +220,17 @@ impl_GNOME_Evolution_Addressbook_Book_isCardWriteable (PortableServer_Servant se } static void +impl_GNOME_Evolution_Addressbook_Book_authenticateUser (PortableServer_Servant servant, + const char* user, + const char* passwd, + CORBA_Environment *ev) +{ + PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); + + pas_book_queue_authenticate_user (book, user, passwd); +} + +static void impl_GNOME_Evolution_Addressbook_Book_addCard (PortableServer_Servant servant, const GNOME_Evolution_Addressbook_VCard vcard, CORBA_Environment *ev) @@ -451,6 +476,28 @@ pas_book_respond_modify (PASBook *book, } /** + * pas_book_respond_authenticate_user: + */ +void +pas_book_respond_authenticate_user (PASBook *book, + GNOME_Evolution_Addressbook_BookListener_CallStatus status) +{ + CORBA_Environment ev; + + CORBA_exception_init (&ev); + + GNOME_Evolution_Addressbook_BookListener_notifyAuthenticationResult ( + book->priv->listener, status, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("pas_book_respond_authenticate_user: Exception " + "responding to BookListener!\n"); + } + + CORBA_exception_free (&ev); +} + +/** * pas_book_respond_get_cursor: */ void @@ -676,6 +723,7 @@ pas_book_get_epv (void) epv->getVCard = impl_GNOME_Evolution_Addressbook_Book_getVCard; epv->isWriteable = impl_GNOME_Evolution_Addressbook_Book_isWriteable; epv->isCardWriteable = impl_GNOME_Evolution_Addressbook_Book_isCardWriteable; + 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; diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h index 3c7f5a2bde..d94d859d3e 100644 --- a/addressbook/backend/pas/pas-book.h +++ b/addressbook/backend/pas/pas-book.h @@ -30,7 +30,8 @@ typedef enum { GetCursor, GetBookView, GetChanges, - CheckConnection + CheckConnection, + AuthenticateUser } PASOperation; typedef struct { @@ -39,6 +40,8 @@ typedef struct { char *vcard; char *search; char *change_id; + char *user; + char *passwd; GNOME_Evolution_Addressbook_BookViewListener listener; } PASRequest; @@ -76,6 +79,8 @@ void pas_book_respond_remove (PASBook GNOME_Evolution_Addressbook_BookListener_CallStatus status); void pas_book_respond_modify (PASBook *book, GNOME_Evolution_Addressbook_BookListener_CallStatus status); +void pas_book_respond_authenticate_user (PASBook *book, + GNOME_Evolution_Addressbook_BookListener_CallStatus status); void pas_book_respond_get_cursor (PASBook *book, GNOME_Evolution_Addressbook_BookListener_CallStatus status, PASCardCursor *cursor); |