[evolution-patches] [PATCH] e-passwords move



These are the changes required to move e-passwords.[ch] from evolution
to libedataserverui and make the name selector do authentication.

Changes that need review are in shell, addressbook, calendar, mailer,
libedataserverui and e-util. It's mostly just #include directives.

There are two new files in libedataserverui; e-book-auth-util.[ch].
They're attached too.

-- 
Hans Petter Jansson | <hpj novell com>
Evolution Developer | http://hp.cl.no/
? 4821.patch
? evolution-passwords-move.patch
? log.diff
? my-autogen.sh
? my-env.sh
? out
? addressbook/70540.patch
? addressbook/util/deleted
? calendar/gui/new
? e-util/old
? help/C/evolution-2.2-C.omf
? mail/out
? mail/default/zh_CN/Makefile
? mail/default/zh_CN/Makefile.in
? plugins/addressbook-file/Makefile
? plugins/addressbook-file/Makefile.in
? plugins/addressbook-file/org-gnome-addressbook-file.eplug
? plugins/addressbook-groupwise/Makefile
? plugins/addressbook-groupwise/Makefile.in
? plugins/addressbook-groupwise/org-gnome-addressbook-groupwise.eplug
? plugins/default-source/Makefile
? plugins/default-source/Makefile.in
? plugins/default-source/org-gnome-default-source.eplug
? plugins/exchange-account-setup/Makefile
? plugins/exchange-account-setup/Makefile.in
? plugins/exchange-account-setup/org-gnome-exchange-account-setup.eplug
? plugins/groupwise-account-setup/Makefile
? plugins/groupwise-account-setup/Makefile.in
? plugins/groupwise-account-setup/org-gnome-gw-account-setup.eplug
? plugins/groupwise-send-options/Makefile
? plugins/groupwise-send-options/Makefile.in
? plugins/groupwise-send-options/org-gnome-compose-send-options.eplug
? plugins/groupwise-status-tracking/Makefile
? plugins/groupwise-status-tracking/Makefile.in
? plugins/groupwise-status-tracking/org-gnome-status-track.eplug
? plugins/new-mail-notify/Makefile
? plugins/new-mail-notify/Makefile.in
? plugins/send-options/Makefile
? plugins/send-options/Makefile.in
? plugins/send-options/org-gnome-send-options.eplug
? plugins/shared-folder/Makefile
? plugins/shared-folder/Makefile.in
? plugins/shared-folder/org-gnome-shared-folder.eplug
Index: configure.in
===================================================================
RCS file: /cvs/gnome/evolution/configure.in,v
retrieving revision 1.784
diff -u -p -r1.784 configure.in
--- configure.in	9 Feb 2005 00:24:57 -0000	1.784
+++ configure.in	22 Feb 2005 08:36:50 -0000
@@ -1214,7 +1214,7 @@ fi
 
 dnl --- evolution-mail flags
 
-EVO_SET_COMPILE_FLAGS(EVOLUTION_MAIL, camel-provider-$EDS_PACKAGE libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED gal-$GAL_PACKAGE >= $GAL_REQUIRED libglade-2.0 gnome-vfs-module-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED libxml-2.0 bonobo-activation-2.0 gthread-2.0 gconf-2.0 $mozilla_nss libebook-$EDS_PACKAGE >= $EDS_REQUIRED)
+EVO_SET_COMPILE_FLAGS(EVOLUTION_MAIL, camel-provider-$EDS_PACKAGE libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED gal-$GAL_PACKAGE >= $GAL_REQUIRED libglade-2.0 gnome-vfs-module-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED libxml-2.0 bonobo-activation-2.0 gthread-2.0 gconf-2.0 $mozilla_nss libebook-$EDS_PACKAGE >= $EDS_REQUIRED libedataserverui-$EDS_PACKAGE >= $EDS_REQUIRED)
 AC_SUBST(EVOLUTION_MAIL_CFLAGS)
 AC_SUBST(EVOLUTION_MAIL_LIBS)
 
Index: addressbook/gui/component/addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook-view.c,v
retrieving revision 1.29
diff -u -p -r1.29 addressbook-view.c
--- addressbook/gui/component/addressbook-view.c	18 Jan 2005 10:47:57 -0000	1.29
+++ addressbook/gui/component/addressbook-view.c	22 Feb 2005 08:36:50 -0000
@@ -40,13 +40,13 @@
 #include <bonobo/bonobo-exception.h>
 #include <gal/util/e-util.h>
 #include <libedataserverui/e-source-selector.h>
+#include <libedataserverui/e-passwords.h>
 
 #include "widgets/misc/e-error.h"
 #include "widgets/misc/e-task-bar.h"
 #include "widgets/misc/e-info-label.h"
 
 
-#include "e-util/e-passwords.h"
 #include "e-util/e-icon-factory.h"
 #include "shell/e-user-creatable-items-handler.h"
 
Index: addressbook/gui/component/addressbook.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook.c,v
retrieving revision 1.247
diff -u -p -r1.247 addressbook.c
--- addressbook/gui/component/addressbook.c	4 Feb 2005 08:08:59 -0000	1.247
+++ addressbook/gui/component/addressbook.c	22 Feb 2005 08:36:50 -0000
@@ -27,8 +27,8 @@
 #include <gtk/gtkmessagedialog.h>
 #include <libgnome/gnome-i18n.h>
 #include <libebook/e-book.h>
+#include <libedataserverui/e-passwords.h>
 
-#include "e-util/e-passwords.h"
 #include "widgets/misc/e-error.h"
 #include "addressbook.h"
 
Index: addressbook/gui/widgets/e-addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-addressbook-view.c,v
retrieving revision 1.158
diff -u -p -r1.158 e-addressbook-view.c
--- addressbook/gui/widgets/e-addressbook-view.c	22 Jan 2005 04:03:51 -0000	1.158
+++ addressbook/gui/widgets/e-addressbook-view.c	22 Feb 2005 08:36:50 -0000
@@ -464,6 +464,7 @@ eab_view_new (void)
 	rule_context_load (eav->search_context, SEARCH_RULE_DIR "/addresstypes.xml", "");
 
 	eav->search_rule = filter_rule_new ();
+	filter_rule_set_is_named (eav->search_rule, FALSE);
 	part = rule_context_next_part (eav->search_context, NULL);
 
 	if (part == NULL)
Index: calendar/common/authentication.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/common/authentication.c,v
retrieving revision 1.9
diff -u -p -r1.9 authentication.c
--- calendar/common/authentication.c	7 Oct 2004 14:20:55 -0000	1.9
+++ calendar/common/authentication.c	22 Feb 2005 08:36:50 -0000
@@ -27,7 +27,7 @@
 
 #include <string.h>
 #include <bonobo/bonobo-i18n.h>
-#include "e-util/e-passwords.h"
+#include <libedataserverui/e-passwords.h>
 #include "authentication.h"
 
 static GHashTable *source_lists_hash = NULL;
Index: calendar/gui/e-pub-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-pub-utils.c,v
retrieving revision 1.6
diff -u -p -r1.6 e-pub-utils.c
--- calendar/gui/e-pub-utils.c	27 Sep 2004 14:14:11 -0000	1.6
+++ calendar/gui/e-pub-utils.c	22 Feb 2005 08:36:50 -0000
@@ -26,9 +26,9 @@
 #include <gconf/gconf-client.h>
 #include <libedataserver/e-source.h>
 #include <libedataserver/e-source-list.h>
+#include <libedataserverui/e-passwords.h>
 #include <libecal/e-cal-time-util.h>
 #include <libgnome/gnome-i18n.h>
-#include "e-util/e-passwords.h"
 #include "calendar-config.h"
 #include "common/authentication.h"
 #include "itip-utils.h"
Index: calendar/gui/itip-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/itip-utils.c,v
retrieving revision 1.96
diff -u -p -r1.96 itip-utils.c
--- calendar/gui/itip-utils.c	15 Feb 2005 14:18:26 -0000	1.96
+++ calendar/gui/itip-utils.c	22 Feb 2005 08:36:50 -0000
@@ -39,7 +39,6 @@
 #include <libsoup/soup-session-async.h>
 #include <libsoup/soup-message.h>
 #include <libsoup/soup-uri.h>
-#include "e-util/e-passwords.h"
 #include "calendar-config.h"
 #include "itip-utils.h"
 #include "dialogs/cal-attachment.h"
Index: calendar/gui/alarm-notify/alarm-notify.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/alarm-notify/alarm-notify.c,v
retrieving revision 1.46
diff -u -p -r1.46 alarm-notify.c
--- calendar/gui/alarm-notify/alarm-notify.c	18 Feb 2005 13:33:01 -0000	1.46
+++ calendar/gui/alarm-notify/alarm-notify.c	22 Feb 2005 08:36:50 -0000
@@ -26,12 +26,12 @@
 #include <string.h>
 #include <bonobo/bonobo-main.h>
 #include <libedataserver/e-url.h>
+#include <libedataserverui/e-passwords.h>
 #include <libecal/e-cal.h>
 #include "alarm-notify.h"
 #include "alarm-queue.h"
 #include "config-data.h"
 #include "common/authentication.h"
-#include "e-util/e-passwords.h"
 
 
 /* Private part of the AlarmNotify structure */
Index: calendar/gui/alarm-notify/notify-main.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/alarm-notify/notify-main.c,v
retrieving revision 1.43
diff -u -p -r1.43 notify-main.c
--- calendar/gui/alarm-notify/notify-main.c	18 May 2004 13:33:40 -0000	1.43
+++ calendar/gui/alarm-notify/notify-main.c	22 Feb 2005 08:36:51 -0000
@@ -38,7 +38,7 @@
 #include <bonobo/bonobo-generic-factory.h>
 #include <bonobo-activation/bonobo-activation.h>
 #include <libedataserver/e-source.h>
-#include "e-util/e-passwords.h"
+#include <libedataserverui/e-passwords.h>
 #include "e-util/e-icon-factory.h"
 #include "alarm.h"
 #include "alarm-queue.h"
Index: calendar/gui/dialogs/url-editor-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/dialogs/url-editor-dialog.c,v
retrieving revision 1.6
diff -u -p -r1.6 url-editor-dialog.c
--- calendar/gui/dialogs/url-editor-dialog.c	7 Oct 2004 21:08:25 -0000	1.6
+++ calendar/gui/dialogs/url-editor-dialog.c	22 Feb 2005 08:36:51 -0000
@@ -34,12 +34,12 @@
 #include "cal-prefs-dialog.h"
 #include "url-editor-dialog.h"
 
-#include "e-util/e-passwords.h"
 #include <gtk/gtk.h>
 #include <gtk/gtksignal.h>
 #include <gtk/gtkoptionmenu.h>
 #include <gtk/gtktogglebutton.h>
 #include <libgnomeui/gnome-color-picker.h>
+#include <libedataserverui/e-passwords.h>
 #include <glade/glade.h>
 #include <e-util/e-dialog-widgets.h>
 #include <e-util/e-icon-factory.h>
Index: e-util/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/e-util/Makefile.am,v
retrieving revision 1.122
diff -u -p -r1.122 Makefile.am
--- e-util/Makefile.am	21 Jan 2005 17:17:35 -0000	1.122
+++ e-util/Makefile.am	22 Feb 2005 08:36:51 -0000
@@ -42,7 +42,6 @@ eutilinclude_HEADERS = 				\
 	e-list.h				\
 	e-menu.h				\
 	e-mktemp.h				\
-	e-passwords.h				\
 	e-print.h				\
 	e-plugin.h				\
 	e-popup.h				\
@@ -80,7 +79,6 @@ libeutil_la_SOURCES =				\
 	e-list.c				\
 	e-menu.c				\
 	e-mktemp.c				\
-	e-passwords.c				\
 	e-plugin.c				\
 	e-popup.c				\
 	e-print.c				\
Index: mail/mail-config.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-config.c,v
retrieving revision 1.313
diff -u -p -r1.313 mail-config.c
--- mail/mail-config.c	18 Jan 2005 13:19:23 -0000	1.313
+++ mail/mail-config.c	22 Feb 2005 08:36:51 -0000
@@ -54,7 +54,6 @@
 #include <gal/util/e-util.h>
 #include <gal/widgets/e-gui-utils.h>
 
-#include <e-util/e-passwords.h>
 #include <e-util/e-account-list.h>
 #include <e-util/e-signature-list.h>
 
@@ -63,6 +62,8 @@
 #include <camel/camel-stream-fs.h>
 #include <camel/camel-mime-filter-charset.h>
 #include <camel/camel-stream-filter.h>
+
+#include <libedataserverui/e-passwords.h>
 
 #include "mail-component.h"
 #include "mail-session.h"
Index: mail/mail-session.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-session.c,v
retrieving revision 1.101
diff -u -p -r1.101 mail-session.c
--- mail/mail-session.c	4 Feb 2005 02:17:21 -0000	1.101
+++ mail/mail-session.c	22 Feb 2005 08:36:51 -0000
@@ -52,7 +52,7 @@
 #include "mail-tools.h"
 #include "mail-mt.h"
 #include "mail-ops.h"
-#include "e-util/e-passwords.h"
+#include <libedataserverui/e-passwords.h>
 #include "libedataserver/e-msgport.h"
 #include "em-junk-filter.h"
 #include "widgets/misc/e-error.h"
Index: plugins/groupwise-account-setup/camel-gw-listener.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/groupwise-account-setup/camel-gw-listener.c,v
retrieving revision 1.28
diff -u -p -r1.28 camel-gw-listener.c
--- plugins/groupwise-account-setup/camel-gw-listener.c	28 Jan 2005 09:11:51 -0000	1.28
+++ plugins/groupwise-account-setup/camel-gw-listener.c	22 Feb 2005 08:36:51 -0000
@@ -29,7 +29,7 @@
 #include <string.h>
 #include  <camel/camel-i18n.h>
 #include <e-gw-connection.h>
-#include <e-util/e-passwords.h>
+#include <libedataserverui/e-passwords.h>
 #include "widgets/misc/e-error.h"
 
 /*stores some info about all currently existing groupwise accounts 
Index: plugins/send-options/send-options.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/send-options/send-options.c,v
retrieving revision 1.4
diff -u -p -r1.4 send-options.c
--- plugins/send-options/send-options.c	10 Feb 2005 08:44:14 -0000	1.4
+++ plugins/send-options/send-options.c	22 Feb 2005 08:36:51 -0000
@@ -32,9 +32,9 @@
 #include <mail/em-config.h>
 #include <e-gw-connection.h>
 #include <camel/camel-url.h>
-#include "e-util/e-passwords.h"
 #include <libecal/e-cal-time-util.h>
 #include <libedataserver/e-source-list.h>
+#include <libedataserverui/e-passwords.h>
 
 ESendOptionsDialog *sod = NULL;
 GtkWidget *parent;
Index: shell/e-shell-window-commands.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell-window-commands.c,v
retrieving revision 1.27
diff -u -p -r1.27 e-shell-window-commands.c
--- shell/e-shell-window-commands.c	2 Feb 2005 01:40:47 -0000	1.27
+++ shell/e-shell-window-commands.c	22 Feb 2005 08:36:51 -0000
@@ -33,7 +33,6 @@
 
 #include "e-util/e-icon-factory.h"
 #include "e-util/e-dialog-utils.h"
-#include "e-util/e-passwords.h"
 
 #include <glib/gprintf.h>
 
@@ -46,6 +45,8 @@
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 
 #include <bonobo/bonobo-ui-component.h>
+
+#include <libedataserverui/e-passwords.h>
 
 #include <string.h>
 
Index: shell/e-shell.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell.c,v
retrieving revision 1.258
diff -u -p -r1.258 e-shell.c
--- shell/e-shell.c	10 Jan 2005 02:35:12 -0000	1.258
+++ shell/e-shell.c	22 Feb 2005 08:36:51 -0000
@@ -32,7 +32,6 @@
 #include "e-util/e-dialog-utils.h"
 #include "e-util/e-bconf-map.h"
 #include "e-util/e-fsutils.h"
-#include "e-util/e-passwords.h"
 #include "widgets/misc/e-error.h"
 
 #include "e-shell-constants.h"
@@ -65,6 +64,8 @@
 #include <bonobo-activation/bonobo-activation.h>
 #include <bonobo/bonobo-exception.h>
 #include <bonobo/bonobo-moniker-util.h>
+
+#include <libedataserverui/e-passwords.h>
 
 #include <gal/util/e-util.h>
 
Index: shell/main.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/main.c,v
retrieving revision 1.165
diff -u -p -r1.165 main.c
--- shell/main.c	29 Dec 2004 16:01:23 -0000	1.165
+++ shell/main.c	22 Feb 2005 08:36:52 -0000
@@ -27,7 +27,6 @@
 #include "e-util/e-dialog-utils.h"
 #include "e-util/e-gtk-utils.h"
 #include "e-util/e-bconf-map.h"
-#include "e-util/e-passwords.h"
 
 #include <e-util/e-icon-factory.h>
 #include "e-shell-constants.h"
@@ -65,6 +64,8 @@
 #include <bonobo/bonobo-exception.h>
 
 #include <bonobo-activation/bonobo-activation.h>
+
+#include <libedataserverui/e-passwords.h>
 
 #include <glade/glade.h>
 
Index: smime/gui/component.c
===================================================================
RCS file: /cvs/gnome/evolution/smime/gui/component.c,v
retrieving revision 1.5
diff -u -p -r1.5 component.c
--- smime/gui/component.c	12 Aug 2004 06:55:36 -0000	1.5
+++ smime/gui/component.c	22 Feb 2005 08:36:52 -0000
@@ -28,10 +28,10 @@
 #include <gtk/gtk.h>
 
 #include <libgnome/gnome-i18n.h>
+#include <libedataserverui/e-passwords.h>
 
 #include "ca-trust-dialog.h"
 #include "e-cert-db.h"
-#include "e-util/e-passwords.h"
 #include "pk11func.h"
 
 static gboolean
Index: smime/lib/e-cert-db.c
===================================================================
RCS file: /cvs/gnome/evolution/smime/lib/e-cert-db.c,v
retrieving revision 1.14
diff -u -p -r1.14 e-cert-db.c
--- smime/lib/e-cert-db.c	19 Jul 2004 19:01:52 -0000	1.14
+++ smime/lib/e-cert-db.c	22 Feb 2005 08:36:52 -0000
@@ -83,10 +83,10 @@
 #include "plstr.h"
 #include "prprf.h"
 #include "prmem.h"
-#include "e-util/e-passwords.h"
 #include "e-util/e-dialog-utils.h"
 #include <gtk/gtkmessagedialog.h>
 #include <libgnome/gnome-i18n.h>
+#include <libedataserverui/e-passwords.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
Index: smime/lib/e-pkcs12.c
===================================================================
RCS file: /cvs/gnome/evolution/smime/lib/e-pkcs12.c,v
retrieving revision 1.7
diff -u -p -r1.7 e-pkcs12.c
--- smime/lib/e-pkcs12.c	4 Sep 2004 02:54:49 -0000	1.7
+++ smime/lib/e-pkcs12.c	22 Feb 2005 08:36:52 -0000
@@ -62,12 +62,12 @@
 
 #include <gtk/gtk.h>
 #include <libgnome/gnome-i18n.h>
+#include <libedataserverui/e-passwords.h>
 
 #include <time.h>
 #include <fcntl.h>
 #include <unistd.h>
 
-#include "e-util/e-passwords.h"
 #include "e-cert-db.h"
 #include "e-pkcs12.h"
 
? libedataserverui/cachegrind.out.31380
? libedataserverui/cachegrind.out.31397
? libedataserverui/cachegrind.out.31411
? libedataserverui/e-book-auth-util.c
? libedataserverui/e-book-auth-util.h
? libedataserverui/e-name-selector-dialog.gladep
? libedataserverui/e-passwords.c
? libedataserverui/e-passwords.h
? libedataserverui/log.diff
? libedataserverui/new
? libedataserverui/old
? libedataserverui/out.diff
? libedataserverui/test-camel-address
? libedataserverui/test-camel-address.c
? libedataserverui/test-contact-store
? libedataserverui/test-name-selector
Index: libedataserverui/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/Makefile.am,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile.am
--- libedataserverui/Makefile.am	22 Jan 2005 09:59:42 -0000	1.10
+++ libedataserverui/Makefile.am	22 Feb 2005 08:48:03 -0000
@@ -21,11 +21,13 @@ libedataserverui_1_2_la_SOURCES =	\
 	$(MARSHAL_GENERATED)		\
 	e-categories-dialog.c		\
 	e-destination-store.c		\
+	e-book-auth-util.c		\
 	e-contact-store.c		\
 	e-name-selector.c		\
 	e-name-selector-dialog.c	\
 	e-name-selector-entry.c		\
 	e-name-selector-model.c		\
+	e-passwords.c			\
 	e-source-selector.c		\
 	e-source-selector-dialog.c	\
 	e-source-option-menu.c		\
@@ -43,11 +45,13 @@ libedataserveruiincludedir = $(privinclu
 libedataserveruiinclude_HEADERS =	\
 	e-categories-dialog.h		\
 	e-destination-store.h		\
+	e-book-auth-util.h		\
 	e-contact-store.h		\
 	e-name-selector.h		\
 	e-name-selector-dialog.h	\
 	e-name-selector-entry.h		\
 	e-name-selector-model.h		\
+	e-passwords.h			\
 	e-source-selector.h		\
 	e-source-selector-dialog.h	\
 	e-source-option-menu.h		\
Index: libedataserverui/e-name-selector-dialog.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/e-name-selector-dialog.c,v
retrieving revision 1.9
diff -u -p -r1.9 e-name-selector-dialog.c
--- libedataserverui/e-name-selector-dialog.c	3 Feb 2005 16:35:02 -0000	1.9
+++ libedataserverui/e-name-selector-dialog.c	22 Feb 2005 08:48:03 -0000
@@ -33,6 +33,7 @@
 #include <libedataserverui/e-source-option-menu.h>
 #include <libedataserverui/e-destination-store.h>
 #include <libedataserverui/e-contact-store.h>
+#include <libedataserverui/e-book-auth-util.h>
 #include "e-name-selector-dialog.h"
 
 typedef struct {
@@ -535,12 +536,8 @@ source_selected (ENameSelectorDialog *na
 	remove_books (name_selector_dialog);
 
 	/* Start loading selected book */
-	name_selector_dialog->pending_book = e_book_new (source, NULL);
-	if (!name_selector_dialog->pending_book)
-		return;
-
-	e_book_async_open (name_selector_dialog->pending_book, TRUE,
-			   book_opened, name_selector_dialog);
+	name_selector_dialog->pending_book = e_load_book_source (source, book_opened,
+								 name_selector_dialog);
 }
 
 /* --------------- *
@@ -558,7 +555,11 @@ search_changed (ENameSelectorDialog *nam
 
 	text = gtk_entry_get_text (name_selector_dialog->search_entry);
 	text_escaped = escape_sexp_string (text);
-	query_string = g_strdup_printf ("(contains \"file_as\" %s)", text_escaped);
+	query_string = g_strdup_printf ("(or (beginswith \"file_as\" %s) "
+					"    (beginswith \"full_name\" %s) "
+					"    (beginswith \"email\" %s) "
+					"    (beginswith \"nickname\" %s))",
+					text_escaped, text_escaped, text_escaped, text_escaped);
 	book_query = e_book_query_from_string (query_string);
 	g_free (query_string);
 	g_free (text_escaped);
Index: libedataserverui/e-name-selector-entry.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/libedataserverui/e-name-selector-entry.c,v
retrieving revision 1.14
diff -u -p -r1.14 e-name-selector-entry.c
--- libedataserverui/e-name-selector-entry.c	3 Feb 2005 16:35:02 -0000	1.14
+++ libedataserverui/e-name-selector-entry.c	22 Feb 2005 08:48:03 -0000
@@ -34,6 +34,7 @@
 #include <libebook/e-book.h>
 #include <libebook/e-contact.h>
 #include <libebook/e-destination.h>
+#include <libedataserverui/e-book-auth-util.h>
 
 #include "e-name-selector-entry.h"
 
@@ -1348,11 +1349,10 @@ setup_default_contact_store (ENameSelect
 			if (!completion || g_ascii_strcasecmp (completion, "true"))
 				continue;
 
-			book = e_book_new (source, NULL);
+			book = e_load_book_source (source, NULL, NULL);
 			if (!book)
 				continue;
 
-			e_book_async_open (book, TRUE, NULL, NULL);
 			e_contact_store_add_book (name_selector_entry->contact_store, book);
 			g_object_unref (book);
 		}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/* e-book-auth-util.c - Lame helper to load addressbooks with authentication.
 *
 * Copyright (C) 2005 Novell, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Authors: Hans Petter Jansson <hpj novell com>
 *
 * Mostly taken from Evolution's addressbook/gui/component/addressbook.c
 */

#include <config.h>
#include <string.h>
#include <gtk/gtkmessagedialog.h>
#include <glib/gi18n-lib.h>
#include <libebook/e-book.h>
#include <libedataserverui/e-passwords.h>
#include "e-book-auth-util.h"

static void addressbook_authenticate (EBook *book, gboolean previous_failure,
				      ESource *source, EBookCallback cb, gpointer closure);

typedef struct {
	ESource       *source;
	EBook         *book;

	EBookCallback  open_func;
	gpointer       open_func_data;
} LoadSourceData;

static void
free_load_source_data (LoadSourceData *data)
{
	if (data->source)
		g_object_unref (data->source);
	if (data->book)
		g_object_unref (data->book);
	g_free (data);
}

static gchar *
remove_parameters_from_uri (gchar *uri)
{
  gchar **components;
  gchar *new_uri = NULL;
                                                                                                                             
  components = g_strsplit (uri, ";", 2);
  if (components[0])
        new_uri = g_strdup (components[0]);
   g_strfreev (components);
   return new_uri;
}

static void
load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure)
{
	LoadSourceData *data = closure;

	if (status != E_BOOK_ERROR_OK) {
		/* the user clicked cancel in the password dialog */
		if (status == E_BOOK_ERROR_CANCELLED) {
			if (e_book_check_static_capability (book, "anon-access")) {
				GtkWidget *dialog;

				/* XXX "LDAP" has to be removed from the folowing message
				   so that it wil valid for other servers which provide 
				   anonymous access*/

				dialog = gtk_message_dialog_new (NULL,
								 0,
								 GTK_MESSAGE_WARNING,
								 GTK_BUTTONS_OK,
								 _("Accessing LDAP Server anonymously"));
				g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
				gtk_widget_show (dialog);
				if (data->open_func)
					data->open_func (book, E_BOOK_ERROR_OK, data->open_func_data);
				free_load_source_data (data);
				return;
			}
		} else if (status == E_BOOK_ERROR_INVALID_SERVER_VERSION) {
#if 0
			e_error_run (NULL, "addressbook:server-version", NULL);
#endif
			status = E_BOOK_ERROR_OK;
			if (data->open_func)
				data->open_func (book, status, data->open_func_data);
			free_load_source_data (data);
			return;
		} else {
			gchar *uri = e_source_get_uri (data->source);
			gchar *stripped_uri = remove_parameters_from_uri (uri);
			const gchar *auth_domain = e_source_get_property (data->source, "auth-domain");
			const gchar *component_name;

			component_name = auth_domain ? auth_domain : "Addressbook";

			e_passwords_forget_password (component_name, stripped_uri);
			addressbook_authenticate (book, TRUE, data->source, load_source_auth_cb, closure);

			g_free (stripped_uri);
			g_free (uri);
			return;
		}
	}

	if (data->open_func)
		data->open_func (book, status, data->open_func_data);

	free_load_source_data (data);
}

static gboolean
get_remember_password (ESource *source)
{
	const gchar *value;

	value = e_source_get_property (source, "remember_password");
	if (value && !strcasecmp (value, "true"))
		return TRUE;

	return FALSE;
}

static void
set_remember_password (ESource *source, gboolean value)
{
	e_source_set_property (source, "remember_password",
			       value ? "true" : "false");
}

static void
addressbook_authenticate (EBook *book, gboolean previous_failure, ESource *source,
			  EBookCallback cb, gpointer closure)
{
	const gchar *auth;
	const gchar *user;
	const gchar *component_name;
	const char *password     = NULL;
	char *pass_dup           = NULL;
	gchar *uri               = e_source_get_uri (source);
        gchar *stripped_uri      = remove_parameters_from_uri (uri);
	const gchar *auth_domain = e_source_get_property (source, "auth-domain");
			
	component_name = auth_domain ? auth_domain : "Addressbook";
	g_free (uri);
	uri = stripped_uri;

	password = e_passwords_get_password (component_name, uri);

	auth = e_source_get_property (source, "auth");

	if (auth && !strcmp ("ldap/simple-binddn", auth))
		user = e_source_get_property (source, "binddn");
	else 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 = "";

	if (!password) {
		char *prompt;
		char *password_prompt;
		gboolean remember;
		char *failed_auth;
		guint32 flags = E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET|E_PASSWORDS_ONLINE;

		if (previous_failure) {
			failed_auth = _("Failed to authenticate.\n");
			flags |= E_PASSWORDS_REPROMPT;
		}
		else {
			failed_auth = "";
		}

		password_prompt = g_strdup_printf (_("Enter password for %s (user %s)"),
						   e_source_peek_name (source), user);

		prompt = g_strconcat (failed_auth, password_prompt, NULL);
		g_free (password_prompt);

		remember = get_remember_password (source);
		pass_dup = e_passwords_ask_password (prompt, component_name, uri, prompt,
						     flags, &remember,
						     NULL);
		if (remember != get_remember_password (source))
			set_remember_password (source, remember);

		g_free (prompt);
	}

	if (password || pass_dup) {
		e_book_async_authenticate_user (book, user, password ? password : pass_dup,
						e_source_get_property (source, "auth"),
						cb, closure);
		g_free (pass_dup);
	}
	else {
		/* they hit cancel */
		cb (book, E_BOOK_ERROR_CANCELLED, closure);
	}

	g_free (uri);
}

static void
auth_required_cb (EBook *book, gpointer data)
{
	LoadSourceData *load_source_data = g_new0 (LoadSourceData, 1);
	
	load_source_data->source = g_object_ref (g_object_ref (e_book_get_source (book)));

	addressbook_authenticate (book, FALSE, load_source_data->source,
				  load_source_auth_cb, load_source_data);
}

static void
load_source_cb (EBook *book, EBookStatus status, gpointer closure)
{
	LoadSourceData *load_source_data = closure;

	if (status == E_BOOK_ERROR_OK && book != NULL) {
		const gchar *auth;

		auth = e_source_get_property (load_source_data->source, "auth");
		if (auth && strcmp (auth, "none")) {
			g_signal_connect (book, "auth_required", (GCallback) auth_required_cb, NULL);
			
			if (e_book_is_online (book)) {
				addressbook_authenticate (book, FALSE, load_source_data->source,
							  load_source_auth_cb, closure);
				return;
			}
		}
	}

	if (load_source_data->open_func)
		load_source_data->open_func (book, status, load_source_data->open_func_data);

	free_load_source_data (load_source_data);
}

EBook *
e_load_book_source (ESource *source, EBookCallback open_func, gpointer user_data)
{
	EBook          *book;
	LoadSourceData *load_source_data = g_new0 (LoadSourceData, 1);

	load_source_data->source = g_object_ref (source);
	load_source_data->open_func = open_func;
	load_source_data->open_func_data = user_data;

	book = e_book_new (source, NULL);
	if (!book)
		return NULL;

	load_source_data->book = book;
	g_object_ref (book);
	e_book_async_open (book, FALSE, load_source_cb, load_source_data);
	return book;
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/* e-book-auth-util.h - Lame helper to load addressbooks with authentication.
 *
 * Copyright (C) 2005 Novell, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General Public
 * License as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Authors: Hans Petter Jansson <hpj novell com>
 *
 * Mostly taken from Evolution's addressbook/gui/component/addressbook.c
 */

#ifndef E_BOOK_AUTH_UTIL_H
#define E_BOOK_AUTH_UTIL_H

#include <libebook/e-book.h>

EBook *e_load_book_source (ESource *source, EBookCallback open_func, gpointer user_data);

#endif


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