aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog17
-rw-r--r--mail/folder-browser-factory.c6
-rw-r--r--mail/folder-browser.c44
-rw-r--r--mail/mail-config.c9
-rw-r--r--mail/mail-ops.c10
-rw-r--r--mail/mail.h12
-rw-r--r--mail/session.c44
7 files changed, 58 insertions, 84 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index db7e063473..9355968765 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,22 @@
2000-05-06 Dan Winship <danw@helixcode.com>
+ * folder-browser-factory.c (folder_browser_factory): Don't
+ hardcode "inbox" here.
+
+ * folder-browser.c (folder_browser_set_uri): Don't hardcode
+ "inbox" here either.
+ (folder_browser_load_folder): Create a new store according to the
+ folder browser's URI, and load the mbox file from that store.
+ Parts of this are temporary.
+
+ * session.c, mail.h: There is no longer a global store, just a
+ global session.
+
+ * mail-config.c, mail-ops.c: Update for default_session -> session
+ change. fetch_mail is currently broken.
+
+2000-05-06 Dan Winship <danw@helixcode.com>
+
* mail-config.c: New code to configure identity, mail source, and
mail transport.
(mail_config_druid): A druid using the config widgets. (Only
diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c
index e941e54197..31d270e708 100644
--- a/mail/folder-browser-factory.c
+++ b/mail/folder-browser-factory.c
@@ -220,11 +220,9 @@ folder_browser_factory (BonoboGenericFactory *factory, void *closure)
if (warning_result)
folder_browser = gtk_label_new ("This should be the mail component");
- else {
+ else
folder_browser = folder_browser_new ();
- folder_browser_set_uri (FOLDER_BROWSER (folder_browser), "inbox");
- }
-
+
if (folder_browser == NULL)
return NULL;
diff --git a/mail/folder-browser.c b/mail/folder-browser.c
index 625a006d50..424523e212 100644
--- a/mail/folder-browser.c
+++ b/mail/folder-browser.c
@@ -64,28 +64,39 @@ folder_browser_class_init (GtkObjectClass *object_class)
static gboolean
folder_browser_load_folder (FolderBrowser *fb, const char *name)
{
+ char *store_name;
+ CamelStore *store;
CamelFolder *new_folder;
- CamelException ex;
+ CamelException *ex;
gboolean new_folder_exists = FALSE;
-
- camel_exception_init (&ex);
- new_folder = camel_store_get_folder (default_session->store, name, &ex);
+ /* Change "file:" to "mbox:". FIXME :) */
+ store_name = g_strdup_printf ("mbox%s", strchr (name, ':'));
+
+ ex = camel_exception_new ();
+ store = camel_session_get_store (session, store_name, ex);
+ g_free (store_name);
+ if (store) {
+ new_folder = camel_store_get_folder (store, "mbox", ex);
+ gtk_object_unref (GTK_OBJECT (store));
+ }
- if (camel_exception_get_id (&ex)){
- printf ("Unable to get folder %s : %s\n",
- name,
- ex.desc?ex.desc:"unknown reason");
+ if (camel_exception_get_id (ex)) {
+ printf ("Unable to get folder %s: %s\n", name,
+ camel_exception_get_description (ex));
+ camel_exception_free (ex);
return FALSE;
}
- /* if the folder does not exist, we don't want to show it */
- new_folder_exists = camel_folder_exists (new_folder, &ex);
- if (camel_exception_get_id (&ex)) {
- printf ("Unable to test for folder existence: %s\n",
- ex.desc?ex.desc:"unknown reason");
- return FALSE;
+ /* If the folder does not exist, we don't want to show it */
+ new_folder_exists = camel_folder_exists (new_folder, ex);
+ if (camel_exception_get_id (ex)) {
+ printf ("Unable to test for folder existence: %s\n",
+ camel_exception_get_description (ex));
+ camel_exception_free (ex);
+ return FALSE;
}
+ camel_exception_free (ex);
if (!new_folder_exists) {
gtk_object_unref (GTK_OBJECT (new_folder));
@@ -108,14 +119,11 @@ folder_browser_load_folder (FolderBrowser *fb, const char *name)
void
folder_browser_set_uri (FolderBrowser *folder_browser, const char *uri)
{
- /* FIXME: hardcoded uri */
- if (!folder_browser_load_folder (folder_browser, "inbox"))
- return;
-
if (folder_browser->uri)
g_free (folder_browser->uri);
folder_browser->uri = g_strdup (uri);
+ folder_browser_load_folder (folder_browser, folder_browser->uri);
}
void
diff --git a/mail/mail-config.c b/mail/mail-config.c
index 869ed58ee4..50444b34e9 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -435,8 +435,7 @@ autodetect_cb (GtkWidget *button, GtkObject *table)
url = get_service_url (table);
ex = camel_exception_new ();
- service = camel_session_get_service (default_session->session,
- url, type, ex);
+ service = camel_session_get_service (session, url, type, ex);
g_free (url);
if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE)
goto error;
@@ -794,8 +793,7 @@ add_service (GList *services, CamelProviderType type, CamelProvider *prov)
ex = camel_exception_new ();
url = g_strdup_printf ("%s:", prov->protocol);
- service = camel_session_get_service (default_session->session,
- url, type, ex);
+ service = camel_session_get_service (session, url, type, ex);
g_free (url);
if (!service) {
camel_exception_free (ex);
@@ -893,8 +891,7 @@ mail_config_druid (void)
GdkImlibImage *source_logo, *transport_logo;
/* Fetch list of all providers. */
- providers = camel_session_list_providers (default_session->session,
- TRUE);
+ providers = camel_session_list_providers (session, TRUE);
sources = transports = NULL;
for (p = providers; p; p = p->next) {
CamelProvider *prov = p->data;
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 34239f8f59..4ff3299d98 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -70,6 +70,7 @@ check_configured (void)
void
fetch_mail (GtkWidget *button, gpointer user_data)
{
+#if 0
FolderBrowser *fb = FOLDER_BROWSER (user_data);
CamelException *ex;
CamelStore *store = NULL;
@@ -145,8 +146,7 @@ fetch_mail (GtkWidget *button, gpointer user_data)
goto cleanup;
}
} else {
- store = camel_session_get_store (default_session->session,
- url, ex);
+ store = camel_session_get_store (session, url, ex);
if (!store) {
mail_exception_dialog ("Unable to get new mail",
ex, fb);
@@ -248,6 +248,9 @@ fetch_mail (GtkWidget *button, gpointer user_data)
camel_exception_free (ex);
if (msg)
gtk_object_unref (GTK_OBJECT (msg));
+#else
+ printf ("Sorry, I'm broken! Try again tomorrow.");
+#endif
}
@@ -291,8 +294,7 @@ composer_send_cb (EMsgComposer *composer, gpointer data)
g_assert (url);
g_free (path);
- transport = camel_session_get_transport (
- default_session->session, url, ex);
+ transport = camel_session_get_transport (session, url, ex);
if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) {
mail_exception_dialog ("Could not load mail transport",
ex, composer);
diff --git a/mail/mail.h b/mail/mail.h
index cb41f3cc7e..60a3113f59 100644
--- a/mail/mail.h
+++ b/mail/mail.h
@@ -52,13 +52,5 @@ void delete_msg (GtkWidget *button, gpointer user_data);
void expunge_folder (GtkWidget *button, gpointer user_data);
/* session */
-typedef struct {
- CamelSession *session;
- CamelStore *store;
-} SessionStore;
-
-SessionStore *session_store_new (const char *uri);
-void session_store_destroy (SessionStore *ss);
-void session_init (void);
-
-extern SessionStore *default_session;
+void session_init (void);
+extern CamelSession *session;
diff --git a/mail/session.c b/mail/session.c
index b822d3e177..b7b24920b0 100644
--- a/mail/session.c
+++ b/mail/session.c
@@ -11,7 +11,7 @@
#include "mail.h"
#include "e-util/e-setup.h"
-SessionStore *default_session;
+CamelSession *session;
static void
request_callback (gchar *string, gpointer data)
@@ -52,51 +52,11 @@ evolution_auth_callback (char *prompt, gboolean secret,
return ans;
}
-SessionStore *
-session_store_new (const char *uri)
-{
- SessionStore *ss = g_new (SessionStore, 1);
- CamelException ex;
-
- ss->session = camel_session_new (evolution_auth_callback);
- camel_exception_init (&ex);
- ss->store = camel_session_get_store (ss->session, uri, &ex);
-
-
- g_assert (ss->session);
- g_assert (ss->store);
-
- return ss;
-}
-
-void
-session_store_destroy (SessionStore *ss)
-{
- g_assert (ss != NULL);
-
- gtk_object_unref (GTK_OBJECT (ss->store));
- gtk_object_unref (GTK_OBJECT (ss->session));
-
- g_free (ss);
-}
-
-static void
-init_default_session (void)
-{
- char *url;
-
- url = g_strconcat ("mbox://", evolution_folders_dir, NULL);
- default_session = session_store_new (url);
- g_free (url);
-}
-
void
session_init (void)
{
e_setup_base_dir ();
camel_init ();
- init_default_session ();
+ session = camel_session_new (evolution_auth_callback);
}
-
-