new files for managing interactive authentication with backends.

2003-12-22  Rodrigo Moya <rodrigo@ximian.com>

	* common/authentication.[ch]: new files for managing interactive
	authentication with backends.

	* common/Makefile.am: build new private library.

	* gui/alarm-notify/alarm-notify.c (alarm_notify_add_calendar):
	* gui/dialogs/event-page.c (source_changed_cb):
	* gui/dialogs/task-page.c (source_changed_cb):
	* gui/dialogs/copy-source-dialog.c (copy_source):
	* gui/calendar-component.c (setup_create_ecal):
	* gui/calendar-offline-handler.c (backend_go_offline,
	backend_go_online, calendar_offline_handler_init):
	* gui/comp-editor-factory.c (open_client):
	* gui/e-itip-control.c (start_calendar_server):
	* gui/e-tasks.c (e_tasks_add_todo_uri):
	* gui/gnome-cal.c (gnome_calendar_construct,
	gnome_calendar_add_event_uri):
	* gui/tasks-component.c (setup_create_ecal):
	* importers/icalendar-importer.c (load_file_fn, vcal_load_file_fn,
	gnome_calendar_import_data_fn): create the ECal's via the
	auth_new_cal_from* functions in the authentication module.

	* gui/alarm-notify/Makefile.am:
	* gui/Makefile.am:
	* importers/Makefile.am: link new private library.

	* Makefile.am: added new directory to the build.

svn path=/trunk/; revision=23999
This commit is contained in:
Rodrigo Moya
2003-12-22 15:57:30 +00:00
committed by Rodrigo Moya
parent 0dfb205f6a
commit f3aed51eeb
21 changed files with 208 additions and 33 deletions

View File

@ -1,3 +1,33 @@
2003-12-22 Rodrigo Moya <rodrigo@ximian.com>
* common/authentication.[ch]: new files for managing interactive
authentication with backends.
* common/Makefile.am: build new private library.
* gui/alarm-notify/alarm-notify.c (alarm_notify_add_calendar):
* gui/dialogs/event-page.c (source_changed_cb):
* gui/dialogs/task-page.c (source_changed_cb):
* gui/dialogs/copy-source-dialog.c (copy_source):
* gui/calendar-component.c (setup_create_ecal):
* gui/calendar-offline-handler.c (backend_go_offline,
backend_go_online, calendar_offline_handler_init):
* gui/comp-editor-factory.c (open_client):
* gui/e-itip-control.c (start_calendar_server):
* gui/e-tasks.c (e_tasks_add_todo_uri):
* gui/gnome-cal.c (gnome_calendar_construct,
gnome_calendar_add_event_uri):
* gui/tasks-component.c (setup_create_ecal):
* importers/icalendar-importer.c (load_file_fn, vcal_load_file_fn,
gnome_calendar_import_data_fn): create the ECal's via the
auth_new_cal_from* functions in the authentication module.
* gui/alarm-notify/Makefile.am:
* gui/Makefile.am:
* importers/Makefile.am: link new private library.
* Makefile.am: added new directory to the build.
2003-12-21 JP Rosevear <jpr@ximian.com>
* gui/e-itip-control.[hc]: rewrite for new ecal api, cache all

View File

@ -4,7 +4,7 @@ else
CONDUIT_DIR =
endif
SUBDIRS = idl gui importers $(CONDUIT_DIR)
SUBDIRS = idl common gui importers $(CONDUIT_DIR)
EXTRA_DIST = \
ChangeLog.pre-1-4 \

View File

@ -0,0 +1,28 @@
noinst_LTLIBRARIES = libevolution-calendarprivate.la
INCLUDES = \
-DG_LOG_DOMAIN=\"calendar-gui\" \
-I$(top_builddir)/shell \
-I$(top_srcdir)/shell \
-I$(top_srcdir) \
-I$(top_srcdir)/calendar \
-I$(top_srcdir)/widgets \
-I$(top_srcdir)/a11y/calendar \
-DEVOLUTION_DATADIR=\""$(datadir)"\" \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
-DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \
-DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \
-DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \
-DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \
-DPREFIX=\""$(prefix)"\" \
$(EVOLUTION_CALENDAR_CFLAGS)
libevolution_calendarprivate_la_SOURCES = \
authentication.c \
authentication.h
libevolution_calendarprivate_la_LIBADD = \
$(top_builddir)/e-util/libeutil.la \
$(EVOLUTION_CALENDAR_LIBS)
libevolution_calendarprivate_la_LDFLAGS = -avoid-version -module

View File

@ -0,0 +1,73 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors :
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
* This program 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 program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#include <string.h>
#include <bonobo/bonobo-i18n.h>
#include "e-util/e-passwords.h"
#include "authentication.h"
static char *
auth_func_cb (ECal *ecal, const char *prompt, const char *key, gpointer user_data)
{
gboolean remember;
return e_passwords_ask_password (_("Enter password"), "Calendar", key, prompt, TRUE,
E_PASSWORDS_REMEMBER_FOREVER, &remember,
NULL);
}
ECal *
auth_new_cal_from_source (ESource *source, ECalSourceType type)
{
ECal *cal;
cal = e_cal_new (source, type);
e_cal_set_auth_func (cal, (ECalAuthFunc) auth_func_cb, NULL);
return cal;
}
ECal *
auth_new_cal_from_uri (const char *uri, ECalSourceType type)
{
ESourceGroup *group;
ESource *source;
ECal *cal;
group = e_source_group_new ("", uri);
source = e_source_new ("", "");
e_source_set_group (source, group);
/* we explicitly check for groupwise:// uris, to force authentication on them */
if (!strncmp (uri, "groupwise://", strlen ("groupwise://"))) {
e_source_set_property (source, "auth", "yes");
/* FIXME: need to retrieve the username */
}
cal = auth_new_cal_from_source (source, type);
g_object_unref (source);
g_object_unref (group);
return cal;
}

View File

@ -0,0 +1,33 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Authors :
* Rodrigo Moya <rodrigo@ximian.com>
*
* Copyright 2003, Novell, Inc.
*
* This program 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 program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*/
#ifndef _AUTHENTICATION_H_
#define _AUTHENTICATION_H_
#include <libedataserver/e-source.h>
#include <libecal/e-cal.h>
ECal *auth_new_cal_from_source (ESource *source, ECalSourceType type);
ECal *auth_new_cal_from_uri (const char *uri, ECalSourceType type);
#endif

View File

@ -213,6 +213,7 @@ libevolution_calendar_la_SOURCES = \
libevolution_calendar_la_LIBADD = \
$(top_builddir)/widgets/menus/libmenus.la \
$(top_builddir)/shell/libeshell.la \
$(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(top_builddir)/calendar/gui/dialogs/libcal-dialogs.la \
$(top_builddir)/widgets/e-timezone-dialog/libetimezonedialog.la \
$(top_builddir)/widgets/misc/libemiscwidgets.la \

View File

@ -21,6 +21,7 @@ INCLUDES = \
-DG_LOG_DOMAIN=\"evolution-alarm-notify\" \
-I$(top_srcdir) \
-I$(top_srcdir)/widgets \
-I$(top_srcdir)/calendar \
-DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \
-DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \
-DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \
@ -49,6 +50,7 @@ evolution_alarm_notify_SOURCES = \
evolution_alarm_notify_LDADD = \
$(top_builddir)/e-util/libeutil.la \
$(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(EVOLUTION_CALENDAR_LIBS)
server_in_files = GNOME_Evolution_Calendar_AlarmNotify.server.in.in

View File

@ -27,6 +27,7 @@
#include "alarm-notify.h"
#include "alarm-queue.h"
#include "save.h"
#include "common/authentication.h"
#include "e-util/e-url.h"
@ -173,7 +174,7 @@ alarm_notify_add_calendar (AlarmNotify *an, const char *str_uri, gboolean load_a
if (g_hash_table_lookup (priv->uri_client_hash, str_uri))
return;
client = e_cal_new_from_uri (str_uri, E_CAL_SOURCE_TYPE_EVENT);
client = auth_new_cal_from_uri (str_uri, E_CAL_SOURCE_TYPE_EVENT);
if (client) {
if (e_cal_open (client, FALSE, NULL)) {

View File

@ -38,6 +38,7 @@
#include "migration.h"
#include "e-comp-editor-registry.h"
#include "comp-util.h"
#include "common/authentication.h"
#include "dialogs/new-calendar.h"
#include "dialogs/comp-editor.h"
#include "dialogs/copy-source-dialog.h"
@ -693,14 +694,14 @@ setup_create_ecal (CalendarComponent *calendar_component)
source = e_source_list_peek_source_by_uid (priv->source_list, uid);
g_free (uid);
priv->create_ecal = e_cal_new (source, E_CAL_SOURCE_TYPE_EVENT);
priv->create_ecal = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT);
}
if (!priv->create_ecal) {
/* Try to create a default if there isn't one */
source = find_first_source (priv->source_list);
if (source)
priv->create_ecal = e_cal_new (source, E_CAL_SOURCE_TYPE_EVENT);
priv->create_ecal = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT);
}
if (priv->create_ecal) {

View File

@ -34,6 +34,7 @@
#include "e-util/e-url.h"
#include <libecal/e-cal.h>
#include "calendar-offline-handler.h"
#include "common/authentication.h"
#define PARENT_TYPE bonobo_object_get_type ()
static BonoboObjectClass *parent_class = NULL;
@ -184,7 +185,7 @@ backend_go_offline (gpointer data, gpointer user_data)
GError *error = NULL;
/* FIXME This should not use LAST */
client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_LAST);
client = auth_new_cal_from_uri (uri, E_CAL_SOURCE_TYPE_LAST);
g_signal_connect (client, "cal_opened", G_CALLBACK (backend_cal_opened_offline), offline_handler);
success = e_cal_open (client, TRUE, &error);
if (!success) {
@ -206,7 +207,7 @@ backend_go_online (gpointer data, gpointer user_data)
GError *error = NULL;
/* FIXME This should not use LAST */
client = e_cal_new_from_uri (uri, E_CAL_SOURCE_TYPE_LAST);
client = auth_new_cal_from_uri (uri, E_CAL_SOURCE_TYPE_LAST);
g_signal_connect (G_OBJECT (client), "cal_opened",
G_CALLBACK (backend_cal_opened_online), offline_handler);
success = e_cal_open (client, TRUE, &error);
@ -330,7 +331,7 @@ calendar_offline_handler_init (CalendarOfflineHandler *offline_handler)
/* FIXME This should not use LAST */
/* FIXME: what URI to use? */
priv->client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_LAST);
priv->client = auth_new_cal_from_uri ("", E_CAL_SOURCE_TYPE_LAST);
priv->listener_interface = CORBA_OBJECT_NIL;
priv->is_offline = FALSE;
}

View File

@ -32,6 +32,7 @@
#include "e-comp-editor-registry.h"
#include "comp-editor-factory.h"
#include "comp-util.h"
#include "common/authentication.h"
#include "dialogs/event-editor.h"
#include "dialogs/task-editor.h"
@ -496,7 +497,7 @@ open_client (CompEditorFactory *factory, const char *uristr)
priv = factory->priv;
/* FIXME get the type here */
client = e_cal_new_from_uri (uristr, E_CAL_SOURCE_TYPE_LAST);
client = auth_new_cal_from_uri (uristr, E_CAL_SOURCE_TYPE_LAST);
if (!client)
return NULL;

View File

@ -25,6 +25,7 @@
#include <bonobo/bonobo-i18n.h>
#include <widgets/misc/e-source-option-menu.h>
#include "copy-source-dialog.h"
#include "common/authentication.h"
typedef struct {
GtkWidget *dialog;
@ -65,7 +66,7 @@ copy_source (CopySourceDialogData *csdd)
return FALSE;
/* open the source */
source_client = e_cal_new (csdd->orig_source, csdd->obj_type);
source_client = auth_new_cal_from_source (csdd->orig_source, csdd->obj_type);
if (!e_cal_open (source_client, TRUE, NULL)) {
g_object_unref (source_client);
g_warning (G_STRLOC ": Could not open source");
@ -73,7 +74,7 @@ copy_source (CopySourceDialogData *csdd)
}
/* open the destination */
dest_client = e_cal_new (csdd->selected_source, csdd->obj_type);
dest_client = auth_new_cal_from_source (csdd->selected_source, csdd->obj_type);
if (!e_cal_open (dest_client, FALSE, NULL)) {
g_object_unref (dest_client);
g_object_unref (source_client);

View File

@ -33,6 +33,7 @@
#include <libgnome/gnome-i18n.h>
#include <glade/glade.h>
#include <gal/widgets/e-categories.h>
#include "common/authentication.h"
#include "e-util/e-categories-config.h"
#include "e-util/e-dialog-widgets.h"
#include "widgets/misc/e-dateedit.h"
@ -1212,7 +1213,7 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
if (!priv->updating) {
ECal *client;
client = e_cal_new (source, E_CAL_SOURCE_TYPE_EVENT);
client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_EVENT);
if (!client || !e_cal_open (client, FALSE, NULL)) {
GtkWidget *dialog;

View File

@ -37,6 +37,7 @@
#include <gal/widgets/e-categories.h>
#include <widgets/misc/e-dateedit.h>
#include "widgets/misc/e-source-option-menu.h"
#include "common/authentication.h"
#include "e-util/e-dialog-widgets.h"
#include "e-util/e-categories-config.h"
#include "../e-timezone-entry.h"
@ -794,7 +795,7 @@ source_changed_cb (GtkWidget *widget, ESource *source, gpointer data)
if (!priv->updating) {
ECal *client;
client = e_cal_new (source, E_CAL_SOURCE_TYPE_TODO);
client = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
if (!client || !e_cal_open (client, FALSE, NULL)) {
GtkWidget *dialog;

View File

@ -33,9 +33,7 @@
#include "e-cal-view.h"
#include "gnome-cal.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
G_BEGIN_DECLS
/*
* EDayView - displays the Day & Work-Week views of the calendar.
@ -579,8 +577,6 @@ void e_day_view_ensure_rows_visible (EDayView *day_view,
gint end_row);
#ifdef __cplusplus
}
#endif /* __cplusplus */
G_END_DECLS
#endif /* _E_DAY_VIEW_H_ */

View File

@ -54,6 +54,7 @@
#include "calendar-config.h"
#include "itip-utils.h"
#include "e-itip-control.h"
#include "common/authentication.h"
struct _EItipControlPrivate {
GtkWidget *html;
@ -136,7 +137,7 @@ start_calendar_server (EItipControl *itip, ESource *source, ECalSourceType type)
if (ecal)
return ecal;
ecal = e_cal_new (source, type);
ecal = auth_new_cal_from_source (source, type);
if (!e_cal_open (ecal, TRUE, NULL))
return NULL;

View File

@ -46,8 +46,8 @@
#include "comp-util.h"
#include "e-calendar-table-config.h"
#include "misc.h"
#include "e-tasks.h"
#include "common/authentication.h"
/* Private part of the GnomeCalendar structure */
@ -850,7 +850,7 @@ e_tasks_add_todo_uri (ETasks *tasks, const char *str_uri)
if (client)
return TRUE;
client = e_cal_new_from_uri (str_uri, E_CAL_SOURCE_TYPE_TODO);
client = auth_new_cal_from_uri (str_uri, E_CAL_SOURCE_TYPE_TODO);
g_hash_table_insert (priv->clients, g_strdup (str_uri), client);
priv->clients_list = g_list_prepend (priv->clients_list, client);

View File

@ -67,6 +67,7 @@
#include "tag-calendar.h"
#include "misc.h"
#include "ea-calendar.h"
#include "common/authentication.h"
@ -2031,7 +2032,7 @@ gnome_calendar_construct (GnomeCalendar *gcal)
/*
* TaskPad Folder Client.
*/
priv->task_pad_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_TODO); /* FIXME: use default tasks */
priv->task_pad_client = auth_new_cal_from_uri ("", E_CAL_SOURCE_TYPE_TODO); /* FIXME: use default tasks */
if (!priv->task_pad_client)
return NULL;
@ -2160,7 +2161,7 @@ gnome_calendar_add_event_uri (GnomeCalendar *gcal, const char *str_uri)
if (client)
return TRUE;
client = e_cal_new_from_uri (str_uri, E_CAL_SOURCE_TYPE_EVENT);
client = auth_new_cal_from_uri (str_uri, E_CAL_SOURCE_TYPE_EVENT);
if (!client)
return FALSE;

View File

@ -39,6 +39,7 @@
#include "migration.h"
#include "comp-util.h"
#include "calendar-config.h"
#include "common/authentication.h"
#include "dialogs/comp-editor.h"
#include "dialogs/copy-source-dialog.h"
#include "dialogs/new-task-list.h"
@ -643,14 +644,14 @@ setup_create_ecal (TasksComponent *component)
source = e_source_list_peek_source_by_uid (priv->source_list, uid);
g_free (uid);
priv->create_ecal = e_cal_new (source, E_CAL_SOURCE_TYPE_TODO);
priv->create_ecal = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
}
if (!priv->create_ecal) {
/* Try to create a default if there isn't one */
source = find_first_source (priv->source_list);
if (source)
priv->create_ecal = e_cal_new (source, E_CAL_SOURCE_TYPE_TODO);
priv->create_ecal = auth_new_cal_from_source (source, E_CAL_SOURCE_TYPE_TODO);
}
if (priv->create_ecal) {

View File

@ -23,7 +23,8 @@ libevolution_calendar_importers_la_SOURCES = \
libevolution_calendar_importers_la_LDFLAGS = -avoid-version -module
libevolution_calendar_importers_la_LIBADD = \
$(top_builddir)/shell/importer/libevolution-importer.la \
$(top_builddir)/shell/importer/libevolution-importer.la \
$(top_builddir)/calendar/common/libevolution-calendarprivate.la \
$(IMPORTERS_LIBS)
# evolution_calendar_importer_SOURCES = \
@ -50,4 +51,4 @@ CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = $(server_in_files)
dist-hook:
cd $(distdir); rm -f $(BUILT_SOURCES)
cd $(distdir); rm -f $(BUILT_SOURCES)

View File

@ -38,6 +38,7 @@
#include <importer/GNOME_Evolution_Importer.h>
#include <libical/icalvcal.h>
#include "evolution-calendar-importer.h"
#include "common/authentication.h"
/* We timeout after 2 minutes, when opening the folders. */
#define IMPORTER_TIMEOUT_SECONDS 120
@ -374,9 +375,9 @@ load_file_fn (EvolutionImporter *importer,
/* create ECal's */
if (!ici->client)
ici->client = e_cal_new_from_uri (real_uri, E_CAL_SOURCE_TYPE_EVENT);
ici->client = auth_new_cal_from_uri (real_uri, E_CAL_SOURCE_TYPE_EVENT);
if (!ici->tasks_client)
ici->tasks_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_TODO); /* FIXME */
ici->tasks_client = auth_new_cal_from_uri ("", E_CAL_SOURCE_TYPE_TODO); /* FIXME */
if (e_cal_open (ici->client, TRUE, NULL)
&& e_cal_open (ici->tasks_client, FALSE, NULL)) {
@ -526,9 +527,9 @@ vcal_load_file_fn (EvolutionImporter *importer,
/* create ECal's */
if (!ici->client)
ici->client = e_cal_new_from_uri (real_uri, E_CAL_SOURCE_TYPE_EVENT);
ici->client = auth_new_cal_from_uri (real_uri, E_CAL_SOURCE_TYPE_EVENT);
if (!ici->tasks_client)
ici->tasks_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_TODO);
ici->tasks_client = auth_new_cal_from_uri ("", E_CAL_SOURCE_TYPE_TODO);
if (e_cal_open (ici->client, TRUE, NULL)
&& e_cal_open (ici->tasks_client, FALSE, NULL)) {
@ -614,13 +615,13 @@ gnome_calendar_import_data_fn (EvolutionIntelligentImporter *ii,
/* Try to open the default calendar & tasks folders. */
if (ici->do_calendar) {
calendar_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_EVENT); /* FIXME: use default folder */
calendar_client = auth_new_cal_from_uri ("", E_CAL_SOURCE_TYPE_EVENT); /* FIXME: use default folder */
if (!e_cal_open (calendar_client, FALSE, NULL))
goto out;
}
if (ici->do_tasks) {
tasks_client = e_cal_new_from_uri ("", E_CAL_SOURCE_TYPE_TODO); /* FIXME: use default folder */
tasks_client = auth_new_cal_from_uri ("", E_CAL_SOURCE_TYPE_TODO); /* FIXME: use default folder */
if (!e_cal_open (tasks_client, FALSE, NULL))
goto out;
}