[evolution-patches] Conduits: Add authentication logic for syncing against Exchange/Groupwise accounts



Hi,

Attached patches allows calendar/addressbook-conduits to sync against
Exchange/Groupwise accounts that requires authentication while opening
calendar/addressbook.

P.S:- AUTHENTICATION WILL WORK ONLY IF THE PASSWORD FOR THE
CORRESPONDING ACCOUNT IS SAVED THROUGH EVOLUTION CLIENT.

Let me know your comments.

Thanks, 

V. Varadhan
Index: calendar/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.2847
diff -u -p -r1.2847 ChangeLog
--- calendar/ChangeLog	22 Nov 2005 07:51:19 -0000	1.2847
+++ calendar/ChangeLog	23 Nov 2005 08:38:02 -0000
@@ -1,3 +1,9 @@
+2005-11-23  Veerapuram Varadhan <vvaradhan novell com>
+	
+	* conduits/calendar/calendar-conduit.c: (start_calendar_server):
+	Authenticate by reading the store-password for calendars that has
+	"auth" property set.
+	
 2005-11-22  Boby Wang <boby wang sun com>
 	Fixes #321237
 	* gui/dialogs/event-page.glade: Add the categories' name
@@ -469,7 +475,7 @@
 	modifying the properties of an ECalComponent and before fetching
 	its icalcomponent.
 
-	Reworked the patch from Dave Malcolm <dmalcolm redhat com>
+	Reworked the patch from Bastien Nocera <hadess hadess net>
 	
 2005-09-30  Viren.L  <lviren novell com>
 
Index: calendar/conduits/calendar/calendar-conduit.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/conduits/calendar/calendar-conduit.c,v
retrieving revision 1.129
diff -u -p -r1.129 calendar-conduit.c
--- calendar/conduits/calendar/calendar-conduit.c	30 Sep 2005 17:13:04 -0000	1.129
+++ calendar/conduits/calendar/calendar-conduit.c	23 Nov 2005 08:38:02 -0000
@@ -28,6 +28,8 @@
 #include <libecal/e-cal-types.h>
 #include <libecal/e-cal.h>
 #include <libecal/e-cal-time-util.h>
+#include <libedataserver/e-url.h>
+#include <libedataserverui/e-passwords.h>
 #include <pi-source.h>
 #include <pi-socket.h>
 #include <pi-dlp.h>
@@ -426,21 +428,51 @@ static char *print_remote (GnomePilotRec
 	return buff;
 }
 
+static char *
+auth_func_cb (ECal *ecal, const char* prompt, const char *key, gpointer user_data)
+{
+	char *password;
+	ESource *source;
+	const gchar *auth_domain, *component_name;
+
+	source = e_cal_get_source (ecal);
+	auth_domain = e_source_get_property (source, "auth-domain");
+	component_name = auth_domain ? auth_domain : "Calendar";
+	password = e_passwords_get_password (component_name, key);
+
+	return password;
+}
+
 static int
 start_calendar_server (ECalConduitContext *ctxt)
 {
+	EUri *e_uri;
+	char *str_uri = NULL;
+	char *pass_key = NULL;
+	int retval = 0;
+
 	g_return_val_if_fail (ctxt != NULL, -2);
 
 	if (ctxt->cfg->source) {
 		ctxt->client = e_cal_new (ctxt->cfg->source, E_CAL_SOURCE_TYPE_EVENT);
+		
+		if (e_source_get_property (ctxt->cfg->source, "auth")) {
+			LOG (g_message ("Authenticating calendar\n"));
+			str_uri = e_source_get_uri (ctxt->cfg->source);
+			e_uri = e_uri_new (str_uri);
+			pass_key = e_uri_to_string (e_uri, FALSE);
+			e_uri_free (e_uri);
+			if (ctxt->client)
+				e_cal_set_auth_func (ctxt->client, (ECalAuthFunc) auth_func_cb, NULL);
+		}
 		if (!e_cal_open (ctxt->client, TRUE, NULL))
-			return -1;
+			retval = -1;
 	} else if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_EVENT, NULL, NULL, NULL)) {
-		return -1;
+		retval = -1;
 	}
-
-        return 0;
-
+	g_free (str_uri);
+	g_free (pass_key);
+	return retval;
 }
 
 /* Utility routines */
? addressbook.error
? auth-contact-conduit.diff
? auth-contacts-fix.diff
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.2006
diff -u -p -r1.2006 ChangeLog
--- ChangeLog	15 Nov 2005 16:23:33 -0000	1.2006
+++ ChangeLog	23 Nov 2005 09:31:12 -0000
@@ -1,3 +1,11 @@
+2005-11-23  Veerapuram Varadhan <vvaradhan novell com>
+	
+	* conduits/addressbook-conduit.c: (pre_sync):
+	Authenticate by reading the store-password for calendars that has
+	"auth" property set.
+	* conduits/addressbook-conduit.c: (addressbook_authenticate):
+	Implement authentication using e-passwords.
+	
 2005-10-04  Srinivasa Ragavan <sragavan novell com>
 
 	* gui/component/addressbook-view.c (abv_source_popups): 
Index: conduit/address-conduit.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/conduit/address-conduit.c,v
retrieving revision 1.87
diff -u -p -r1.87 address-conduit.c
--- conduit/address-conduit.c	23 Sep 2004 18:50:17 -0000	1.87
+++ conduit/address-conduit.c	23 Nov 2005 09:31:12 -0000
@@ -34,6 +34,8 @@
 #include <pi-socket.h>
 #include <pi-dlp.h>
 #include <pi-address.h>
+#include <libedataserver/e-url.h>
+#include <libedataserverui/e-passwords.h>
 #include <libebook/e-book.h>
 #include <gpilotd/gnome-pilot-conduit.h>
 #include <gpilotd/gnome-pilot-conduit-sync-abs.h>
@@ -1151,6 +1153,50 @@ check_for_slow_setting (GnomePilotCondui
 	}
 }
 
+static void
+addressbook_authenticate (EBook *book, 
+			  gpointer data)
+{
+	gchar *auth;
+	gchar *user;
+	gchar *passwd;
+	gchar *str_uri;
+	gchar *pass_key;
+	gchar *auth_domain;
+	gchar *component_name;
+	EUri *e_uri;
+
+	ESource *source = (ESource *)data;
+
+	auth = e_source_get_property (source, "auth");
+	auth_domain = e_source_get_property (source, "auth-domain");
+	component_name = auth_domain ? auth_domain : "Addressbook";
+
+	if (auth && !strcmp ("plain/password", auth))
+		user = e_source_get_property (source, "user");
+	else 
+		user = e_source_get_property (source, "email_addr");
+	if (!user)
+		user = "";	
+
+	str_uri = e_source_get_uri (source);
+	e_uri = e_uri_new (str_uri);	
+	pass_key = e_uri_to_string (e_uri, FALSE);
+	e_uri_free (e_uri);
+	
+	passwd = e_passwords_get_password (component_name, pass_key);
+	if (passwd)
+		passwd = "";
+
+	if (book)
+		if (!e_book_authenticate_user (book, user, passwd, auth, NULL))
+			LOG (g_warning ("Authentication failed"));
+	g_free (pass_key);
+	g_free (str_uri);
+
+	return;
+}
+
 /* Pilot syncing callbacks */
 static gint
 pre_sync (GnomePilotConduit *conduit,
@@ -1164,6 +1210,7 @@ pre_sync (GnomePilotConduit *conduit,
 	unsigned char *buf;
 	char *filename;
 	char *change_id;
+	char *auth;
 	gint num_records, add_records = 0, mod_records = 0, del_records = 0;
 
 	abs_conduit = GNOME_PILOT_CONDUIT_SYNC_ABS (conduit);
@@ -1178,6 +1225,12 @@ pre_sync (GnomePilotConduit *conduit,
 		ctxt->ebook = e_book_new (ctxt->cfg->source, NULL);
 	} else {
 		ctxt->ebook = e_book_new_default_addressbook (NULL);
+	}
+	auth = e_source_get_property (ctxt->cfg->source, "auth");
+	if (auth) {
+		LOG (g_message ("contacts needs authentication\n"));
+		g_signal_connect (ctxt->ebook, "auth_required", 
+				  G_CALLBACK (addressbook_authenticate), ctxt->cfg->source);
 	}
 	if (!ctxt->ebook || !e_book_open (ctxt->ebook, TRUE, NULL)) {
 		WARN(_("Could not load addressbook"));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]