aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--camel/camel-provider.h8
-rw-r--r--camel/camel-session.c62
-rw-r--r--camel/camel-session.h8
4 files changed, 79 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 7ec4cbfa3d..0e324a0f86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
1999-04-25 bertrand <Bertrand.Guiheneuf@inria.fr>
+ * camel/camel-session.c (camel_session_set_provider):
+ new method to set the default provider for a protocol.
+ (camel_session_get_store_from_provider):
+ new method to instantiate a folder from a provider.
+
+ * camel/camel-provider.h: s/GString/gchar/g
+ + typo fix.
+
* camel/camel-provider.[ch]:
basic provider structure. Have to write the
code for dynamic loading.
diff --git a/camel/camel-provider.h b/camel/camel-provider.h
index 85eb11ee57..54b9ef2a2a 100644
--- a/camel/camel-provider.h
+++ b/camel/camel-provider.h
@@ -40,10 +40,10 @@ typedef enum {
typedef struct {
GtkType object_type; /* used to create instance of the provider */
ProviderType provider_type; /* is a store or a transport */
- GString *protocol; /* name of the protocol ("imap"/"smtp"/"mh" ...) */
- GString *provider_name; /* name of the provider ("Raymond the imap provider") */
- GString *description; /* Useful when multiple providers are available for a same protocol */
-} CameProvider;
+ gchar *protocol; /* name of the protocol ("imap"/"smtp"/"mh" ...) */
+ gchar *provider_name; /* name of the provider ("Raymond the imap provider") */
+ gchar *description; /* Useful when multiple providers are available for a same protocol */
+} CamelProvider;
diff --git a/camel/camel-session.c b/camel/camel-session.c
index cbc363662e..6acde38d79 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -43,6 +43,13 @@ camel_session_class_init (CamelSessionClass *camel_session_class)
+static void
+camel_session_init (CamelSession *session)
+{
+ store_provider_list = g_hash_table_new (g_str_hash, g_str_equal);
+ transport_provider_list = g_hash_table_new (g_str_hash, g_str_equal);
+}
+
GtkType
@@ -57,7 +64,7 @@ camel_session_get_type (void)
sizeof (CamelSession),
sizeof (CamelSessionClass),
(GtkClassInitFunc) camel_session_class_init,
- (GtkObjectInitFunc) NULL,
+ (GtkObjectInitFunc) camel_session_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
@@ -69,3 +76,56 @@ camel_session_get_type (void)
return camel_session_type;
}
+
+/**
+ * camel_session_set_provider: set the default provider for a protocol
+ * @session: session object for wich the provider will the default
+ * @provider: provider object
+ *
+ * Set the default implementation for a protocol. The protocol
+ * is determined by provider->protocol field (See CamelProtocol).
+ * It overrides the default provider for this protocol.
+ *
+ **/
+void
+camel_session_set_provider (CamelSession *session, CamelProvider *provider)
+{
+ GHashTable *table;
+
+ g_assert(session);
+ g_assert(provider);
+
+ if (provider->provider_type == PROVIDER_STORE)
+ table = session->store_provider_list;
+ else
+ table = session->transport_provider_list;
+
+ g_hash_table_insert (table, (gpointer)(provider->protocol), (gpointer)(provider));
+
+}
+
+
+
+
+
+/**
+ * camel_session_get_store_from_provider: create a folder instance for a given provider
+ * @session: session object the folder will be initialized with
+ * @provider: provider folder to instantiate
+ *
+ *
+ *
+ * Return value: the newly instantiated folder
+ **/
+CamelStore *
+camel_session_get_store_from_provider (CamelSession *session, CamelProvider *provider)
+{
+ CamelStore *store;
+
+ g_assert(session);
+ g_assert(provider);
+
+ store = gtk_object_new (provider->object_type, NULL);
+#warning add session initialisation on object
+ return store;
+}
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 2b6e40ae40..d6242182cd 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -32,7 +32,7 @@ extern "C" {
#endif /* __cplusplus }*/
#include <gtk/gtk.h>
-
+#include "camel-provider.h"
#define CAMEL_SESSION_TYPE (camel_session_get_type ())
#define CAMEL_SESSION(obj) (GTK_CHECK_CAST((obj), CAMEL_SESSION_TYPE, CamelSession))
@@ -46,6 +46,9 @@ typedef struct _CamelSession CamelSession;
struct _CamelSession
{
GtkObject parent_object;
+ GHashTable *store_provider_list; /* providers are identified by their protocol */
+ GHashTable *transport_provider_list;
+
};
@@ -53,7 +56,7 @@ struct _CamelSession
typedef struct {
GtkObjectClass parent_class;
-
+
/* Virtual methods */
} CamelSessionClass;
@@ -66,6 +69,7 @@ GtkType camel_session_get_type (void);
+void camel_session_set_provider (CamelSession *session, CamelProvider *provider);
#ifdef __cplusplus