+2003-12-19 Rodrigo Moya <rodrigo@ximian.com>
+
+ * idl/Evolution-DataServer-Calendar.idl: added 'username' and 'password'
+ arguments to Cal::open method, so that we can send authentication
+ from the clients.
+
+ * libedata-cal/e-cal-backend.[ch] (e_cal_backend_open):
+ * libedata-cal/e-cal-backend-sync.[ch] (e_cal_backend_sync_open,
+ _e_cal_backend_open):
+ * libedata-cal/e-data-cal.c (impl_Cal_open):
+ * backends/http/e-cal-backend-http.c (e_cal_backend_http_open):
+ * backends/groupwise/e-cal-backend-groupwise.c
+ (e_cal_backend_groupwise_open):
+ * backends/file/e-cal-backend-file.c (e_cal_backend_file_open): adapted
+ to changes in above method.
+
+ * libecal/e-cal.[ch]: added E_CAL_LOAD_AUTHENTICATING to LoadState enum.
+ (e_cal_open): check with the ESource if the server needs authentication
+ or not, and if so, ask the client's provided auth function. Call
+ GNOME_Evolution_Calendar_Cal_Open with the new arguments.
+
2003-12-18 Rodrigo Moya <rodrigo@ximian.com>
* backends/groupwise/e-cal-backend-groupwise.c: use a GMutex for
/* Open handler for the file backend */
static ECalBackendSyncStatus
-e_cal_backend_file_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists)
+e_cal_backend_file_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
+ const char *username, const char *password)
{
ECalBackendFile *cbfile;
ECalBackendFilePrivate *priv;
return GNOME_Evolution_Calendar_Success;
}
-/*return email address of the person who opened the calender */
+/* return email address of the person who opened the calender */
static ECalBackendSyncStatus
e_cal_backend_groupwise_get_cal_address (ECalBackendSync *backend, EDataCal *cal, char **address)
{
/* Open handler for the file backend */
static ECalBackendSyncStatus
-e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists)
+e_cal_backend_groupwise_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
+ const char *username, const char *password)
{
ECalBackendGroupwise *cbgw;
ECalBackendGroupwisePrivate *priv;
GNOME_VFS_URI_HIDE_USER_NAME |
GNOME_VFS_URI_HIDE_PASSWORD);
priv->cnc = e_gw_connection_new (real_uri,
- gnome_vfs_uri_get_user_name (vuri),
- gnome_vfs_uri_get_password (vuri));
+ username ? username : gnome_vfs_uri_get_user_name (vuri),
+ password ? password : gnome_vfs_uri_get_password (vuri));
gnome_vfs_uri_unref (vuri);
g_free (real_uri);
/* Open handler for the file backend */
static ECalBackendSyncStatus
-e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists)
+e_cal_backend_http_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
+ const char *username, const char *password)
{
ECalBackendHttp *cbhttp;
ECalBackendHttpPrivate *priv;
g_idle_add ((GSourceFunc) begin_retrieval_cb, cbhttp);
}
- e_cal_backend_sync_open (priv->file_backend, cal, FALSE);
+ e_cal_backend_sync_open (priv->file_backend, cal, FALSE, username, password);
return GNOME_Evolution_Calendar_Success;
}
/* A calendar is identified by its URI */
readonly attribute string uri;
- oneway void open (in boolean only_if_exists);
+ oneway void open (in boolean only_if_exists, in string username, in string password);
oneway void remove ();
/* Check write permissions for calendar */
return NULL;
}
-
+
return ecal;
}
CORBA_Environment ev;
ECalendarStatus status;
ECalendarOp *our_op;
+ const char *username = NULL, *password = NULL;
g_return_val_if_fail (ecal != NULL, FALSE);
g_return_val_if_fail (E_IS_CAL (ecal), FALSE);
E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_BUSY, error);
}
+ /* see if the backend needs authentication */
+ if (e_source_get_property (priv->source, "auth")) {
+ char *prompt, *key;
+
+ priv->load_state = E_CAL_LOAD_AUTHENTICATING;
+
+ if (priv->auth_func == NULL) {
+ g_mutex_unlock (priv->mutex);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED, error);
+ }
+
+ username = e_source_get_property (priv->source, "username");
+ if (!username) {
+ g_mutex_unlock (priv->mutex);
+ E_CALENDAR_CHECK_STATUS (E_CALENDAR_STATUS_AUTHENTICATION_REQUIRED, error);
+ }
+
+ /* actually ask the client for authentication */
+ prompt = g_strdup_printf (_("Enter password for %s (user %s)"),
+ e_source_peek_name (priv->source), username);
+ key = e_source_get_uri (priv->source);
+
+ password = priv->auth_func (ecal, prompt, key, priv->auth_user_data);
+
+ g_free (prompt);
+ g_free (key);
+ }
+
+ /* start the open operation */
our_op = e_calendar_new_op (ecal);
g_mutex_lock (our_op->mutex);
priv->load_state = E_CAL_LOAD_LOADING;
- GNOME_Evolution_Calendar_Cal_open (priv->cal, only_if_exists, &ev);
+ GNOME_Evolution_Calendar_Cal_open (priv->cal, only_if_exists,
+ username ? username : "",
+ password ? password : "",
+ &ev);
+ if (password)
+ g_free (password);
+
if (BONOBO_EX (&ev)) {
e_calendar_remove_op (ecal, our_op);
g_mutex_unlock (our_op->mutex);
/* Whether the ecal is not loaded, is being loaded, or is already loaded */
typedef enum {
E_CAL_LOAD_NOT_LOADED,
+ E_CAL_LOAD_AUTHENTICATING,
E_CAL_LOAD_LOADING,
E_CAL_LOAD_LOADED
} ECalLoadState;
void (* backend_died) (ECal *ecal);
};
-typedef gchar * (* ECalAuthFunc) (ECal *ecal,
- const gchar *prompt,
- const gchar *key,
- gpointer user_data);
+typedef char * (* ECalAuthFunc) (ECal *ecal,
+ const char *prompt,
+ const char *key,
+ gpointer user_data);
GType e_cal_get_type (void);
}
ECalBackendSyncStatus
-e_cal_backend_sync_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists)
+e_cal_backend_sync_open (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists,
+ const char *username, const char *password)
{
ECalBackendSyncPrivate *priv;
ECalBackendSyncStatus status;
g_mutex_lock (priv->sync_mutex);
- status = (* E_CAL_BACKEND_SYNC_GET_CLASS (backend)->open_sync) (backend, cal, only_if_exists);
+ status = (* E_CAL_BACKEND_SYNC_GET_CLASS (backend)->open_sync) (backend, cal, only_if_exists, username, password);
g_mutex_unlock (priv->sync_mutex);
}
static void
-_e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists)
+_e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists,
+ const char *username, const char *password)
{
ECalBackendSyncStatus status;
- status = e_cal_backend_sync_open (E_CAL_BACKEND_SYNC (backend), cal, only_if_exists);
+ status = e_cal_backend_sync_open (E_CAL_BACKEND_SYNC (backend), cal, only_if_exists, username, password);
e_data_cal_notify_open (cal, status);
}
ECalBackendSyncStatus (*get_ldap_attribute_sync) (ECalBackendSync *backend, EDataCal *cal, char **attribute);
ECalBackendSyncStatus (*get_static_capabilities_sync) (ECalBackendSync *backend, EDataCal *cal, char **capabilities);
- ECalBackendSyncStatus (*open_sync) (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists);
+ ECalBackendSyncStatus (*open_sync) (ECalBackendSync *backend, EDataCal *cal, gboolean only_if_exists, const char *username, const char *password);
ECalBackendSyncStatus (*remove_sync) (ECalBackendSync *backend, EDataCal *cal);
ECalBackendSyncStatus (*create_object_sync) (ECalBackendSync *backend, EDataCal *cal, const char *calobj, char **uid);
EDataCal *cal,
char **capabiliites);
ECalBackendSyncStatus e_cal_backend_sync_open (ECalBackendSync *backend,
- EDataCal *cal,
- gboolean only_if_exists);
+ EDataCal *cal,
+ gboolean only_if_exists,
+ const char *username,
+ const char *password);
ECalBackendSyncStatus e_cal_backend_sync_remove (ECalBackendSync *backend,
EDataCal *cal);
ECalBackendSyncStatus e_cal_backend_sync_create_object (ECalBackendSync *backend,
* @only_if_exists: Whether the calendar should be opened only if it already
* exists. If FALSE, a new calendar will be created when the specified @uri
* does not exist.
+ * @username: User name to use for authentication (if needed).
+ * @password: Password for @username.
*
* Opens a calendar backend with data from a calendar stored at the specified
* URI.
* Return value: An operation status code.
**/
void
-e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists)
+e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists,
+ const char *username, const char *password)
{
g_return_if_fail (backend != NULL);
g_return_if_fail (E_IS_CAL_BACKEND (backend));
g_assert (CLASS (backend)->open != NULL);
- (* CLASS (backend)->open) (backend, cal, only_if_exists);
+ (* CLASS (backend)->open) (backend, cal, only_if_exists, username, password);
}
void
void (* get_ldap_attribute) (ECalBackend *backend, EDataCal *cal);
void (* get_static_capabilities) (ECalBackend *backend, EDataCal *cal);
- void (* open) (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists);
+ void (* open) (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const char *username, const char *password);
void (* remove) (ECalBackend *backend, EDataCal *cal);
/* Object related virtual methods */
void e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal);
void e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal);
-void e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists);
+void e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists, const char *username, const char *password);
void e_cal_backend_remove (ECalBackend *backend, EDataCal *cal);
void e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, const char *calobj);
static void
impl_Cal_open (PortableServer_Servant servant,
CORBA_boolean only_if_exists,
+ const CORBA_char *username,
+ const CORBA_char *password,
CORBA_Environment *ev)
{
EDataCal *cal;
cal = E_DATA_CAL (bonobo_object_from_servant (servant));
priv = cal->priv;
- e_cal_backend_open (priv->backend, cal, only_if_exists);
+ e_cal_backend_open (priv->backend, cal, only_if_exists, username, password);
}
static void