From 273ead43140dd463f4995766858942a36f5724f6 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Fri, 22 Jun 2001 16:08:01 +0000 Subject: new function for the backends to be able to call the getPassword method on 2001-06-22 Rodrigo Moya * pcs/cal.[ch] (cal_get_password): new function for the backends to be able to call the getPassword method on the associated WombatClient (cal_forget_password): ditto for the forgetPassword method svn path=/trunk/; revision=10396 --- calendar/ChangeLog | 7 ++++ calendar/pcs/cal-backend.c | 1 + calendar/pcs/cal-backend.h | 3 +- calendar/pcs/cal.c | 81 +++++++++++++++++++++++++++++++++++++++++++++- calendar/pcs/cal.h | 6 +++- 5 files changed, 95 insertions(+), 3 deletions(-) diff --git a/calendar/ChangeLog b/calendar/ChangeLog index a018ee1e08..db9d905f95 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,10 @@ +2001-06-22 Rodrigo Moya + + * pcs/cal.[ch] (cal_get_password): new function for the backends to + be able to call the getPassword method on the associated + WombatClient + (cal_forget_password): ditto for the forgetPassword method + 2001-06-22 Rodrigo Moya * idl/evolution-calendar.idl: changed getFreeBusy method to return diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index 76438ad51d..081442e392 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -6,6 +6,7 @@ * * Authors: Federico Mena-Quintero * JP Rosevear + * Rodrigo Moya * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h index 44f87e3f34..132f6c6118 100644 --- a/calendar/pcs/cal-backend.h +++ b/calendar/pcs/cal-backend.h @@ -4,7 +4,8 @@ * Copyright (C) 2000 Helix Code, Inc. * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Authors: Federico Mena-Quintero + * Rodrigo Moya * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 50a2fe06f6..7d01ef03e3 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -3,7 +3,8 @@ * Copyright (C) 2000 Helix Code, Inc. * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Authors: Federico Mena-Quintero + * Rodrigo Moya * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -642,3 +643,81 @@ cal_notify_remove (Cal *cal, const char *uid) CORBA_exception_free (&ev); } + +/** + * cal_get_password: + * @cal: A calendar client interface. + * @prompt: The message to show to the user when asking for the password. + * @key: A key associated with the password being asked. + * + * Gets a password from the calendar client this Cal knows about. It does + * so by using the WombatClient interface being used by the corresponding + * CalClient. + * + * Returns: a password entered by the user. + */ +char * +cal_get_password (Cal *cal, const char *prompt, const char *key) +{ + CalPrivate *priv; + CORBA_Environment ev; + CORBA_char *pwd; + + g_return_val_if_fail (cal != NULL, NULL); + g_return_val_if_fail (IS_CAL (cal), NULL); + + priv = cal->priv; + g_return_val_if_fail (priv->wombat_client != CORBA_OBJECT_NIL, NULL); + + CORBA_exception_init (&ev); + pwd = GNOME_Evolution_WombatClient_getPassword ( + priv->wombat_client, + (const CORBA_char *) prompt, + (const CORBA_char *) key, + &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("cal_get_password: could not get password from associated WombatClient"); + CORBA_exception_free (&ev); + return NULL; + } + + return pwd; +} + +/** + * cal_forget_password: + * @cal: A calendar client interface. + * @key: A key associated with the password to be forgotten. + * + * Notifies the associated calendar client that it should forget + * about the password identified by @key, so that next time the backend + * asks the client about it, the client would ask again the user for it. + * This is done in cases where the password supplied the first time + * was not a valid password and the backend needs the user to enter + * a new one. + */ +void +cal_client_forget_password (Cal *cal, const char *key) +{ + CalPrivate *priv; + CORBA_Environment ev; + + g_return_if_fail (cal != NULL); + g_return_if_fail (IS_CAL (cal)); + + priv = cal->priv; + g_return_if_fail (priv->wombat_client != CORBA_OBJECT_NIL); + + CORBA_exception_init (&ev); + GNOME_Evolution_WombatClient_forgetPassword ( + priv->wombat_client, + (const CORBA_char *) key, + &ev); + + if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("cal_forget_password: could not notify WombatClient about " + "password to be forgotten"); + } + + CORBA_exception_free (&ev); +} diff --git a/calendar/pcs/cal.h b/calendar/pcs/cal.h index f9880178b5..84a973d66b 100644 --- a/calendar/pcs/cal.h +++ b/calendar/pcs/cal.h @@ -3,7 +3,8 @@ * Copyright (C) 2000 Helix Code, Inc. * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Authors: Federico Mena-Quintero + * Rodrigo Moya * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -64,6 +65,9 @@ Cal *cal_new (CalBackend *backend, GNOME_Evolution_Calendar_Listener listener); void cal_notify_update (Cal *cal, const char *uid); void cal_notify_remove (Cal *cal, const char *uid); +char *cal_get_password (Cal *cal, const char *prompt, const char *key); +void cal_forget_password (Cal *cal, const char *key); + END_GNOME_DECLS -- cgit