aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-02-22 03:56:49 +0800
committerDan Winship <danw@src.gnome.org>2000-02-22 03:56:49 +0800
commit8ea1212d992c564a3a7849a41be9000ce50d0f6b (patch)
treeebc891496db9d1ad04a43153bd79f2b068902c07 /camel
parent0eff8e4321d63ef1dce20cceae8314b3628767a4 (diff)
downloadgsoc2013-evolution-8ea1212d992c564a3a7849a41be9000ce50d0f6b.tar.gz
gsoc2013-evolution-8ea1212d992c564a3a7849a41be9000ce50d0f6b.tar.zst
gsoc2013-evolution-8ea1212d992c564a3a7849a41be9000ce50d0f6b.zip
Add "authenticator" to CamelSession and update things to use it.
svn path=/trunk/; revision=1890
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog9
-rw-r--r--camel/camel-exception-list.def1
-rw-r--r--camel/camel-session.c41
-rw-r--r--camel/camel-session.h15
4 files changed, 59 insertions, 7 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index c8ec75d11f..00eb1cd4d3 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,6 +1,13 @@
2000-02-21 Dan Winship <danw@helixcode.com>
- * camel-session.h:
+ * camel-session.h: (struct _CamelSession): Add authenticator.
+
+ * camel-session.c (camel_session_new): Add authenticator.
+ (camel_session_query_authenticator): New function to query the
+ session authenticator for password, etc, information.
+
+2000-02-21 Dan Winship <danw@helixcode.com>
+
* camel-session.c: add CamelExceptions to several functions. Use
camel_session_new to initialize the session and URL fields of
created CamelStores as appropriate.
diff --git a/camel/camel-exception-list.def b/camel/camel-exception-list.def
index c157d9544c..e99f0c90d9 100644
--- a/camel/camel-exception-list.def
+++ b/camel/camel-exception-list.def
@@ -10,6 +10,7 @@ CAMEL_EXCEPTION_NONE = 0,
/* Generic exceptions */
CAMEL_EXCEPTION_INVALID_PARAM,
CAMEL_EXCEPTION_SYSTEM,
+CAMEL_EXCEPTION_USER_CANCEL,
/* CamelFolderException */
CAMEL_EXCEPTION_FOLDER_NULL = 100,
diff --git a/camel/camel-session.c b/camel/camel-session.c
index cf5db3c57f..f014d46596 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -85,9 +85,12 @@ camel_session_get_type (void)
CamelSession *
-camel_session_new (void)
+camel_session_new (CamelAuthCallback authenticator)
{
- return gtk_type_new (CAMEL_SESSION_TYPE);
+ CamelSession *session = gtk_type_new (CAMEL_SESSION_TYPE);
+
+ session->authenticator = authenticator;
+ return session;
}
/**
@@ -240,3 +243,37 @@ camel_session_get_store (CamelSession *session, const char *url_string,
g_url_free (url);
return store;
}
+
+
+
+/**
+ * camel_session_query_authenticator: query the session authenticator
+ * @session: session object
+ * @prompt: prompt to use if authenticator can query the user
+ * @secret: whether or not the data is secret (eg, a password)
+ * @service: the service this query is being made by
+ * @item: an identifier, unique within this service, for the information
+ * @ex: a CamelException
+ *
+ * This function is used by a CamelService to request authentication
+ * information it needs to complete a connection. If the authenticator
+ * stores any authentication information in configuration files, it
+ * should use @service and @item as keys to find the right piece of
+ * information. If it doesn't store authentication information in config
+ * files, it should use the given @prompt to ask the user for the
+ * information. If @secret is set, the user's input should not be
+ * echoed back. The authenticator should set @ex to
+ * CAMEL_EXCEPTION_USER_CANCEL if the user did not provide the
+ * information. The caller must g_free() the information when it is
+ * done with it.
+ *
+ * Return value: the authentication information or NULL.
+ **/
+char *
+camel_session_query_authenticator (CamelSession *session, char *prompt,
+ gboolean secret,
+ CamelService *service, char *item,
+ CamelException *ex)
+{
+ return session->authenticator (prompt, secret, service, item, ex);
+}
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 0b65326323..272417644c 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -44,15 +44,19 @@ extern "C" {
#define CAMEL_IS_SESSION(o) (GTK_CHECK_TYPE((o), CAMEL_SESSION_TYPE))
+typedef char *(*CamelAuthCallback) (char *prompt, gboolean secret,
+ CamelService *service, char *item,
+ CamelException *ex);
struct _CamelSession
{
GtkObject parent_object;
+
+ CamelAuthCallback authenticator;
GHashTable *store_provider_list; /* providers are identified by their protocol */
GHashTable *transport_provider_list;
-
-
+
};
@@ -71,7 +75,7 @@ typedef struct {
GtkType camel_session_get_type (void);
-CamelSession *camel_session_new (void);
+CamelSession *camel_session_new (CamelAuthCallback authenticator);
void camel_session_set_provider (CamelSession *session, CamelProvider *provider);
CamelStore *camel_session_get_store_for_protocol (CamelSession *session,
const gchar *protocol,
@@ -79,7 +83,10 @@ CamelStore *camel_session_get_store_for_protocol (CamelSession *session,
CamelStore *camel_session_get_store (CamelSession *session,
const char *url_string,
CamelException *ex);
-
+char *camel_session_query_authenticator (CamelSession *session, char *prompt,
+ gboolean secret,
+ CamelService *service, char *item,
+ CamelException *ex);
#ifdef __cplusplus
}