diff options
Diffstat (limited to 'mail')
33 files changed, 0 insertions, 5389 deletions
diff --git a/mail/.cvsignore b/mail/.cvsignore deleted file mode 100644 index 728f3debdd..0000000000 --- a/mail/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -Mail-stubs.c -Mail-skels.c -Mail-common.c -Mail.h -evolution-mail -test-mail -test-sources diff --git a/mail/ChangeLog b/mail/ChangeLog deleted file mode 100644 index ee0f155806..0000000000 --- a/mail/ChangeLog +++ /dev/null @@ -1,415 +0,0 @@ -2000-04-23 Dan Winship <danw@helixcode.com> - - * folder-browser-factory.c: rename "send" to "send_msg", to avoid - name clash with the tcp function. Connect the "forward" button. - - * mail-ops.c: rename "send" to "send_msg", to avoid name clash - with the tcp function. Add forward_msg function. - - * mail-format.c (mail_generate_forward): support function for - forward_msg. Pretty much a big kludge right now, pending the - attachment/attachment-bar changes. - -2000-04-22 Dan Winship <danw@helixcode.com> - - * mail-display.c (on_url_requested): Change cid expectations to - match current camel reality. - - * main.c (main): call glade_gnome_init, for composer. - - * folder-browser-factory.c: move msg_composer_cb and - msg_composer_send_cb to mail-ops. Attach send, reply, and "reply - to all" buttons. - - * mail-ops.c (composer_send_cb, send): moved from - folder-browser-factory.c. - (reply_to_sender, reply_to_all): new functions to do replies. - - * mail-format.c (text_to_html): Add an "add_pre" flag, to make - it wrap the output in <pre></pre>. - (mail_generate_reply): New function to create a composer and build - a reply in it. - -2000-04-21 Dan Winship <danw@helixcode.com> - - * mail-display.c (on_url_requested): deal with cid: URLs. - (find_cid): helper routine for above. (This could be much better.) - (mail_display_init): connect url_requested signal - - * mail-format.c (handle_multipart_related): Make this work. - - * mail-display.c (mail_display_set_message): ref the message we - display, since we're going to unref it when we remove it. Fixes a - bug that showed up with the new camel code, but it's not obvious - if it's due to a bug or a feature in the new code. - -2000-04-20 NotZed <NotZed@HelixCode.com> - - * Makefile.am (evolution_mail_LDADD): Add libibex.la to link. - - * message-list.h: Removed folder summary. - - * message-list.c: Dont include folder-summary anymore. - (select_msg): Changed to use folder, not summary in - summary_get_message_info(). God this code is grotty. - (ml_value_at): Ditto. - (ml_value_at): Changed to use new interface. Hmm, this returns a - static variable, that seems wrong. - (message_list_set_folder): Remove folder summary. - (ml_row_count): Oops, remove some debug i put there. - -2000-04-20 Dan Winship <danw@helixcode.com> - - * mail-display.c: update for bonobo change, and remove a - now-unused variable. - -2000-04-17 Chris Toshok <toshok@helixcode.com> - - * message-list.c (on_row_selection_idle): new function, actually - calls select_msg. - (on_row_selection_cmd): register an idle instead of calling - select_msg directly. this fixes the lag before the row is - selected - selection is instantaneous now, with message loading - happening afterward. - - * message-list.h: add row_to_select and an idle_id to the message - list to make the select_msg call happen in an idle func. - - * message-list.c (message_list_init_renderers): no more - e_cell_set_editable. this info always comes from the model. - -2000-04-14 Dan Winship <danw@helixcode.com> - - * mail-format.[ch]: Moved from camel/camel-formatter, and changed - slightly. (More to come.) - - * html-stream.[ch]: No longer necessary. mail-format uses - GtkHTMLStreamHandles directly. - - * mail-display.[ch]: update for new message formatting code. - -2000-04-14 Chris Toshok <toshok@helixcode.com> - - * folder-browser-factory.c (control_activate): use - gnome_app_fill_toolbar_with_data, so we get the beautiful gnome - toolbar. - -2000-04-14 Dan Winship <danw@helixcode.com> - - * folder-browser-factory.c (development_warning): Fix up the - warning message a bit. - (folder_browser_factory): Make the warning bypassable. - -2000-04-12 Miguel de Icaza <miguel@gnu.org> - - * main.c (main): Call e_cursors_init. - -2000-04-10 Dan Winship <danw@helixcode.com> - - * mail-ops.c (fetch_mail): use camel_movemail when fetching mail - from an mbox store. This leaves behind temp files for now, - because CamelMboxFolder::delete is too confused to use, and NotZed - is rewriting CamelMboxFolder, so I'm not going to bother to try to - fix it. - - * mail-ops.c: Add some #includes for the non-HAVE_MKSTEMP case - -2000-04-09 Matt Loper <matt@helixcode.com> - - * folder-browser.c (folder_browser_new): set folder_browser->uri - to NULL, so that we know when to free it. - -2000-04-07 Miguel de Icaza <miguel@gnu.org> - - * message-list.c (states_pixmaps): Add more beautiful art from - Miggue, the Diego Rivera of the next millenium. - (message_list_init_header): Use the beautiful art. - - * pixmaps: Miguel rediscovers the "transparent" concept. - -2000-04-07 Matt Loper <matt@helixcode.com> - - * folder-browser.c (folder_browser_destroy): Unref the shell - interface that we have a handle to. - - * folder-browser-factory.c (control_destroy_cb): New function; - destroys a folder-browser when its control is destroyed. - (folder_browser_factory): Hook up to the above. - -2000-04-07 Dan Winship <danw@helixcode.com> - - * mail-ops.c: new file, for toolbar/menu callbacks - (fetch_mail): fetch mail. Doesn't do mbox locking. Many kludges. - - * folder-browser-factory.c (control_activate): use new fetch_mail - function as the callback for the "New mail" icon. Rename check_cb - to random_cb. - - * Makefile.am: don't build test-sources since the version in - CVS doesn't do much and once I've fixed it it won't be a separate - program. Add mail-ops.[ch]. - -2000-04-06 Miguel de Icaza <miguel@gnu.org> - - * message-list.c: Stick pixmaps here. - - * mail-display.c (embeddable_destroy_cb): Replaced C++ comments - with C comments. - - * message-list.c (load_internal_images): New function, loads images. - (message_list_init_renderers): Load images, fix previous attempt - at loading images. - - * Makefile.am (dist-hook): Added distribution of pixmaps. - - * pixmaps: New directory, used to hold the XPMs we ship with. - - * pixmaps/envelope-closed.xpm, pixmaps/envelope-open.xpm: Tigert's - envelopes incorporated. - -2000-03-31 Miguel de Icaza <miguel@gnu.org> - - * message-list.c (ml_value_at): Fix miss-used variable. - -2000-04-01 Michael Meeks <michael@helixcode.com> - - * folder-browser.c (folder_browser_properties_init): update to - new property (folder_browser_property_changed): kill. - (get_prop, set_prop): do the donkey work + make properly RW. - -2000-03-31 Dan Winship <danw@helixcode.com> - - * folder-browser-factory.c (folder_browser_set_shell): - * folder-browser.c (folder_browser_new): - * message-list.c (on_row_selection_cmd, select_msg, - message_list_init, message_list_set_folder): - - remove debugging printf()s that no longer seem useful - -2000-03-29 Dan Winship <danw@helixcode.com> - - * folder-browser-factory.c (control_activate): build a toolbar. - (control_deactivate): and hide it. - -2000-03-27 Chris Toshok <toshok@helixcode.com> - * mail-display.c: quiet warnings when building in ../po - -2000-03-26 Miguel de Icaza <miguel@gnu.org> - - * folder-browser-factory.c (folder_browser_set_shell): Memory leak - fix. - -2000-03-25 Dan Winship <danw@helixcode.com> - - * message-list.c (select_msg, ml_value_at): update for summary - changes. Hey, neat, it really does make it more efficient. - -2000-03-22 Christopher James Lahey <clahey@helixcode.com> - - * .cvsignore: Updated .cvsignore. - -2000-03-21 Matt Loper <matt@helixcode.com> - - * mail-display.c: Minor cleanup & commenting. - - * folder-browser-factory.c: Minor cleanup & warning elimination. - -2000-03-21 bertrand <bertrand@helixcode.com> - - * message-list.c (ml_value_at): display message size - -2000-03-20 Christopher James Lahey <clahey@helixcode.com> - - * message-list.c: Properly ref & sink the table and header models. - -2000-03-14 Dan Winship <danw@helixcode.com> - - * mail-sources.c: First cut at a mail source selection wizard. - Basically a rigged demo at this point. Doesn't use camel to get - its information, and is not yet complete or integrated with the - mail component. Did I mention that the code is ugly? - -2000-03-13 bertrand <bertrand@helixcode.com> - - * folder-browser-factory.c (folder_browser_set_shell): - for testing and demonstration purpose, immediately - register a fake service. - -2000-03-12 bertrand <bertrand@helixcode.com> - - * folder-browser-factory.c (folder_browser_factory_init): - name change. - (control_activate_cb): when the control is activated, - it merges its own UI with the remote UIHandler. - (control_add_menu): sample menu merging. - (folder_browser_factory): connect the control "activate" signal. - - * evolution-mail.gnorba: - name changes - - * folder-browser.h: added a reference to an - Evolution::Shell object. - - * folder-browser-factory.c (folder_browser_set_shell): - (folder_browser_control_add_service_repository_interface): - (folder_browser_factory): the folder-browser control now - implements the Evolution/ServiceRepository interface. - -2000-03-07 bertrand <bertrand@helixcode.com> - - * folder-browser-factory.c (development_warning): - added a warning so that the user knows that this - version may crash his mails. - -2000-03-05 bertrand <bertrand@helixcode.com> - - * message-list.h: include a referrence to the parent - folder browser. - - * message-list.c (ml_value_at): use the message summary - from the - - * html-stream.c (html_stream_close): when the stream - is closed, set the html stream to NULL - (html_stream_write): don't write anything if the - html handle does not exist. - (html_stream_reset): implemented. close the current - html handle and begins a new html parser. - - * session.c (session_store_new): use static exception - here. - -2000-03-05 Christopher James Lahey <clahey@helixcode.com> - - * message-list.c: Added a prototype message listing. - -2000-03-04 Christopher James Lahey <clahey@helixcode.com> - - * message-list.c: Set up the column headers properly. - - * folder-browser.c: Show the folder_browser widget. - -2000-03-04 Christopher James Lahey <clahey@helixcode.com> - - * message-list.c: Define ml_duplicate_value and ml_free_value - correctly. - -2000-03-04 Christopher James Lahey <clahey@helixcode.com> - - * message-list.c: Use g_int_compare and g_str_compare as we should - be instead of g_int_equal and g_str_equal. - -2000-03-04 bertrand <bertrand@helixcode.com> - - * test-mail.c (main): replace the bonobo-active/gtk-main - by bonobo-main. - Include Gnorba headers. - (main): don't call the container creation routine - before we entered the main loop. Use idle for that. - -2000-03-04 Christopher James Lahey <clahey@helixcode.com> - - * message-list.c: Change this to use the ETable widget itself - instead of building it from all the parts. - -2000-03-03 Christopher James Lahey <clahey@helixcode.com> - - * message-list.c: Ref the table columns since we unref them at the - end. - -2000-03-01 Ettore Perazzoli <ettore@helixcode.com> - - * Makefile.am (INCLUDES): Add `$(top_srcdir)'. Also, the - `top_srcdir' includes must come first everything else to avoid - including installed headers instead of our fresh ones. - -2000-02-28 NotZed <NotZed@HelixCode.com> - - * Makefile.am (evolution_mail_LDADD): Fixed references to eutil. - -2000-02-24 Christopher James Lahey <clahey@helixcode.com> - - * message-list.c: Changed to match new e_table_simple interface. - -2000-02-24 Dan Winship <danw@helixcode.com> - - * message-list.c (message_list_set_folder): update for CamelFolder - changes - -2000-02-24 Christopher James Lahey <clahey@helixcode.com> - - * message-list.c: Changed this to not use the "x" and "y" - arguments to e-table-item. - -2000-02-23 Matt Loper <matt@helixcode.com> - - * message-list.c (message_list_set_folder): Check 'desc'riptions - of exceptions. - -2000-02-22 bertrand <Bertrand.Guiheneuf@aful.org> - - * message-list.c (message_list_set_folder): - fix to show a sample correct implementation. - -2000-02-21 Matt Loper <matt@helixcode.com> - - * Makefile.am: added -lunicode to evolution_mail_LDADD. - -2000-02-21 Dan Winship <danw@helixcode.com> - - * session.c (session_store_new): Pass a CamelAuthCallback - (evolution_auth_callback) to camel_session_new. - -2000-02-21 Dan Winship <danw@helixcode.com> - - * session.c (session_store_new): Update session_store_new to - deal with the fact that camel_session_get_store takes a - CamelException now. Doesn't actually do anything with the - exception yet, because nothing else does yet either. - -2000-02-19 Matt Loper <matt@helixcode.com> - - * .cvsignore: added test-mail. - -2000-02-14 Miguel de Icaza <miguel@gnu.org> - - * folder-browser.c (folder_browser_load_folder): New routine, - loads a camel folder. - (folder_browser_set_uri): redo. - - * session.c: new file. Implements SessionStores to keep track of - a Session/Store tuple. - -2000-02-13 Matt Loper <matt@helixcode.com> - - * html-stream.c (html_stream_new): Second param of gtk_html_begin - should be "", not NULL. - (html_stream_new): gtk_html_parse() is deprecated, so the call was - removed. - - * html-stream.h: HTMLStreamClass's parent changed to - CamelStreamClass, not CamelStream. - -2000-02-11 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Add the e-text directory to the includes list. - - * message-list.c: Change the call to e_cell_text_new, since - there's an added argument. - -2000-02-09 Christopher James Lahey <clahey@helixcode.com> - - * Makefile.am: Added libetext as libetable depends on it. - -2000-02-08 Iain Holmes <ih@csd.abdn.ac.uk> - - * Makefile.am: Changed the order of the compilation so the CORBA stuff - was made before it was needed. - -2000-01-19 Miguel de Icaza <miguel@gnu.org> - - * Started work on the mail display engine. - - * html-stream.c, html-stream.h: New files, they are CamelStreams - used to write to the GtkHTML widget. - diff --git a/mail/Mail.idl b/mail/Mail.idl deleted file mode 100644 index 1d12a39c5c..0000000000 --- a/mail/Mail.idl +++ /dev/null @@ -1,30 +0,0 @@ -/* - * mail.idl: Mail interfaces for Evolution - * - * Author: - * Miguel de Icaza (miguel@helixcode.com) - * - * (C) 2000 Helix Code, Inc. - */ - -#include <Bonobo.idl> - -module Evolution { - - interface MessageList : Bonobo::Unknown { - - void select_message (in long message_number); - void open_message (in long message_number); - }; - - /* - * FolderBrowser object. - * - * configuration of this widget is done trough - * Bonobo Properties - */ - interface FolderBrowser : Bonobo::Unknown { - MessageList get_message_list (); - }; -}; - diff --git a/mail/Makefile.am b/mail/Makefile.am deleted file mode 100644 index 4c2193330f..0000000000 --- a/mail/Makefile.am +++ /dev/null @@ -1,76 +0,0 @@ -bin_PROGRAMS = evolution-mail test-mail - -providerdir = $(libdir)/evolution/camel-providers/$(VERSION) - -EXTRA_DIST = e-attchmt.png -pkgdata_DATA = e-attchmt.png - -INCLUDES = \ - -I$(top_srcdir)/widgets \ - -I$(top_srcdir)/widgets/e-text \ - -I$(top_srcdir) \ - -I$(top_builddir)/shell \ - $(BONOBO_HTML_GNOME_CFLAGS) \ - -DEVOLUTION_VERSION=\""$(VERSION)"\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ - -DEVOLUTION_LOCALEDIR=\""$(datadir)/locale"\" \ - -DCAMEL_PROVIDERDIR=\""$(providerdir)"\" - -EVOLUTION_MAIL_CORBA_GENERATED = \ - Mail.h \ - Mail-common.c \ - Mail-skels.c \ - Mail-stubs.c - -evolution_mail_SOURCES = \ - $(EVOLUTION_MAIL_CORBA_GENERATED) \ - folder-browser.c \ - folder-browser.h \ - folder-browser-factory.c \ - folder-browser-factory.h \ - mail-display.c \ - mail-display.h \ - mail-format.c \ - mail-format.h \ - mail-ops.c \ - mail-ops.h \ - main.c \ - message-list.c \ - message-list.h \ - session.c \ - session.h - - -evolution_mail_LDADD = \ - ../shell/Evolution-common.o \ - ../shell/Evolution-stubs.o \ - ../shell/Evolution-skels.o \ - ../shell/evolution-service-repository.o \ - ../composer/libcomposer.la \ - ../widgets/e-table/libetable.a \ - ../widgets/e-text/libetext.a \ - ../camel/libcamel.la \ - ../e-util/libeutil.la \ - ../libibex/libibex.la \ - $(BONOBO_HTML_GNOME_LIBS) \ - -lunicode - -test_mail_SOURCES = \ - test-mail.c - -test_mail_LDADD = \ - $(BONOBO_HTML_GNOME_LIBS) - - -gnorbadir = $(sysconfdir)/CORBA/servers -gnorba_DATA = evolution-mail.gnorba - -$(EVOLUTION_MAIL_CORBA_GENERATED): Mail.idl - orbit-idl -I`$(GNOME_CONFIG) --datadir`/idl -I$(srcdir) $(srcdir)/Mail.idl - -EXTRA_DIST = Mail.idl evolution-mail.gnorba - -dist-hook: - -mkdir $(distdir)/pixmaps - cp $(srcdir)/pixmaps/*.xpm $(distdir)/pixmaps
\ No newline at end of file diff --git a/mail/e-attchmt.png b/mail/e-attchmt.png Binary files differdeleted file mode 100644 index b4bac8db67..0000000000 --- a/mail/e-attchmt.png +++ /dev/null diff --git a/mail/evolution-mail.gnorba b/mail/evolution-mail.gnorba deleted file mode 100644 index 7eb90dbc8a..0000000000 --- a/mail/evolution-mail.gnorba +++ /dev/null @@ -1,13 +0,0 @@ -[control-factory:evolution-mail] -type=exe -repo_id=IDL:GNOME/GenericFactory:1.0 -description=Evolution mail folder factory component. -location_info=evolution-mail - -[control:evolution-mail] -type=factory -repo_id=IDL:BonoboControl/evolution-mail:1.0 IDL:GNOME/Control:1.0 -description=Evolution mail folder display component. -location_info=control-factory:evolution-mail - - diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c deleted file mode 100644 index 0f438a7118..0000000000 --- a/mail/folder-browser-factory.c +++ /dev/null @@ -1,269 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * folder-browser-factory.c: A Bonobo Control factory for Folder Browsers - * - * Author: - * Miguel de Icaza (miguel@helixcode.com) - * - * (C) 2000 Helix Code, Inc. - */ -#include <config.h> -#include <gnome.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-object.h> -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-control.h> -#include "e-util/e-util.h" -#include "e-util/e-gui-utils.h" -#include "folder-browser.h" -#include "main.h" -#include "shell/Evolution.h" -#include "shell/evolution-service-repository.h" -#include "composer/e-msg-composer.h" -#include <camel/camel-stream-fs.h> -#include "mail-ops.h" - - -static void -folder_browser_set_shell (EvolutionServiceRepository *sr, - Evolution_Shell shell, - void *closure) -{ - FolderBrowser *folder_browser; - CORBA_Environment ev; - - g_return_if_fail (closure); - g_return_if_fail (IS_FOLDER_BROWSER (closure)); - g_return_if_fail (shell != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - folder_browser = FOLDER_BROWSER (closure); - - folder_browser->shell = shell; - - /* test the component->shell registration */ - Evolution_Shell_register_service (shell, Evolution_Shell_MAIL_STORE, "a_service", &ev); - - CORBA_exception_free (&ev); -} - -static void -folder_browser_control_add_service_repository_interface (BonoboControl *control, - GtkWidget *folder_browser) -{ - EvolutionServiceRepository *sr; - - /* - * create an implementation for the Evolution::ServiceRepository - * interface - */ - sr = evolution_service_repository_new (folder_browser_set_shell, - (void *)folder_browser); - - /* add the interface to the control */ - bonobo_object_add_interface (BONOBO_OBJECT (control), - BONOBO_OBJECT (sr)); -} - - -static int -development_warning () -{ - gint result; - GtkWidget *label, *warning_dialog; - - warning_dialog = gnome_dialog_new ( - "Don't do that", - "I know what I'm doing,\nI want to lose mail!", - "I'll try it later", - NULL); - - label = gtk_label_new ( - _("This is a development version of Evolution.\n" - "Using the mail component on your mail files\n" - "is extremely hazardous.\n\n" - "Do not run this program on your real mail\n " - "and do not give it access to your real mail server.\n\n" - "You have been warned\n")); - gtk_widget_show (label); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (warning_dialog)->vbox), - label, TRUE, TRUE, 0); - - result = gnome_dialog_run (GNOME_DIALOG (warning_dialog)); - - gtk_object_destroy (GTK_OBJECT (label)); - gtk_object_destroy (GTK_OBJECT (warning_dialog)); - - return result; -} - -static void -random_cb (GtkWidget *button, gpointer user_data) -{ - printf ("Yow! I am called back!\n"); -} - -static GnomeUIInfo gnome_toolbar [] = { - GNOMEUIINFO_ITEM_STOCK (N_("New mail"), N_("Check for new mail"), fetch_mail, GNOME_STOCK_PIXMAP_MAIL_RCV), - GNOMEUIINFO_ITEM_STOCK (N_("Send"), N_("Send a new message"), send_msg, GNOME_STOCK_PIXMAP_MAIL_SND), - GNOMEUIINFO_ITEM_STOCK (N_("Find"), N_("Find messages"), random_cb, GNOME_STOCK_PIXMAP_SEARCH), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Reply"), N_("Reply to the sender of this message"), reply_to_sender, GNOME_STOCK_PIXMAP_MAIL_RPL), - GNOMEUIINFO_ITEM_STOCK (N_("Reply to All"), N_("Reply to all recipients of this message"), reply_to_all, GNOME_STOCK_PIXMAP_MAIL_RPL), - - GNOMEUIINFO_ITEM_STOCK (N_("Forward"), N_("Forward this message"), forward_msg, GNOME_STOCK_PIXMAP_MAIL_FWD), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print the selected message"), random_cb, GNOME_STOCK_PIXMAP_PRINT), - - GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete this message"), random_cb, GNOME_STOCK_PIXMAP_TRASH), - - GNOMEUIINFO_END -}; - -static void -control_activate (BonoboControl *control, BonoboUIHandler *uih) -{ - Bonobo_UIHandler remote_uih; - BonoboControl *toolbar_control; - GtkWidget *toolbar, *folder_browser; - - remote_uih = bonobo_control_get_remote_ui_handler (control); - bonobo_ui_handler_set_container (uih, remote_uih); - - bonobo_ui_handler_menu_new_item (uih, "/File/Mail", N_("_Mail"), - NULL, -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, send_msg, NULL); - - folder_browser = bonobo_control_get_widget (control); - - toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, - GTK_TOOLBAR_BOTH); - - gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), - gnome_toolbar, - NULL, folder_browser); - - gtk_widget_show_all (toolbar); - - toolbar_control = bonobo_control_new (toolbar); - bonobo_ui_handler_dock_add (uih, "/Toolbar", - bonobo_object_corba_objref (BONOBO_OBJECT (toolbar_control)), - GNOME_DOCK_ITEM_BEH_LOCKED | - GNOME_DOCK_ITEM_BEH_EXCLUSIVE, - GNOME_DOCK_TOP, - 1, 1, 0); -} - -static void -control_deactivate (BonoboControl *control, BonoboUIHandler *uih) -{ - bonobo_ui_handler_menu_remove (uih, "/File/Mail"); - bonobo_ui_handler_dock_remove (uih, "/Toolbar"); -} - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - gpointer user_data) -{ - BonoboUIHandler *uih; - - uih = bonobo_control_get_ui_handler (control); - g_assert (uih); - - if (activate) - control_activate (control, uih); - else - control_deactivate (control, uih); -} - -static void -control_destroy_cb (BonoboControl *control, - gpointer user_data) -{ - GtkWidget *folder_browser = user_data; - - gtk_object_destroy (GTK_OBJECT (folder_browser)); -} - -/* - * Creates the Folder Browser, wraps it in a Bonobo Control, and - * sets the Bonobo Control properties to point to the Folder Browser - * Properties - */ -static BonoboObject * -folder_browser_factory (BonoboGenericFactory *factory, void *closure) -{ - BonoboControl *control; - GtkWidget *folder_browser; - gint warning_result = 0; - - - if (!getenv ("EVOLVE_ME_HARDER")) - warning_result = development_warning (); - - if (warning_result) - folder_browser = gtk_label_new ("This should be the mail component"); - else { - folder_browser = folder_browser_new (); - folder_browser_set_uri (FOLDER_BROWSER (folder_browser), "inbox"); - } - - if (folder_browser == NULL) - return NULL; - - gtk_widget_show(folder_browser); - - control = bonobo_control_new (folder_browser); - - if (control == NULL){ - gtk_object_destroy (GTK_OBJECT (folder_browser)); - return NULL; - } - - gtk_signal_connect (GTK_OBJECT (control), "activate", - control_activate_cb, NULL); - - gtk_signal_connect (GTK_OBJECT (control), "destroy", - control_destroy_cb, folder_browser); - - bonobo_control_set_property_bag (control, - FOLDER_BROWSER (folder_browser)->properties); - - /* for the moment, the control has the ability to register - * some services itself, but this should not last. - * - * It's not the way to do it, but we don't have the - * correct infrastructure in the shell now. - */ - folder_browser_control_add_service_repository_interface (control, folder_browser); - return BONOBO_OBJECT (control); -} - -void -folder_browser_factory_init (void) -{ - static BonoboGenericFactory *bonobo_folder_browser_factory = NULL; - - - if (bonobo_folder_browser_factory != NULL) - return; - - bonobo_folder_browser_factory = - bonobo_generic_factory_new ( - "control-factory:evolution-mail", - folder_browser_factory, NULL); - - if (bonobo_folder_browser_factory == NULL){ - e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, - _("We are sorry, Evolution's Folder Browser can not be initialized.")); - exit (1); - } -} diff --git a/mail/folder-browser.c b/mail/folder-browser.c deleted file mode 100644 index 1e9603040b..0000000000 --- a/mail/folder-browser.c +++ /dev/null @@ -1,263 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * folder-browser.c: Folder browser top level component - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 2000 Helix Code, Inc. - */ -#include <config.h> -#include <gnome.h> -#include "e-util/e-util.h" -#include "camel/camel-exception.h" -#include "folder-browser.h" -#include "session.h" -#include "message-list.h" - - -#define PARENT_TYPE (gtk_table_get_type ()) - -static GtkObjectClass *folder_browser_parent_class; - - -#define PROPERTY_FOLDER_URI "folder_uri" -#define PROPERTY_MESSAGE_PREVIEW "message_preview" - -#define PROPERTY_FOLDER_URI_IDX 1 -#define PROPERTY_MESSAGE_PREVIEW_IDX 2 - - - -static void -folder_browser_destroy (GtkObject *object) -{ - FolderBrowser *folder_browser = FOLDER_BROWSER (object); - - if (folder_browser->shell) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - Bonobo_Unknown_unref (folder_browser->shell, &ev); - CORBA_exception_free (&ev); - } - - if (folder_browser->uri) - g_free (folder_browser->uri); - - if (folder_browser->folder) - gtk_object_unref (GTK_OBJECT (folder_browser->folder)); - - if (folder_browser->message_list) - bonobo_object_unref (BONOBO_OBJECT (folder_browser->message_list)); - - folder_browser_parent_class->destroy (object); -} - -static void -folder_browser_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = folder_browser_destroy; - - folder_browser_parent_class = gtk_type_class (PARENT_TYPE); -} - -static gboolean -folder_browser_load_folder (FolderBrowser *fb, const char *name) -{ - CamelFolder *new_folder; - CamelException ex; - gboolean new_folder_exists = FALSE; - - - camel_exception_init (&ex); - new_folder = camel_store_get_folder (default_session->store, name, &ex); - - if (camel_exception_get_id (&ex)){ - printf ("Unable to get folder %s : %s\n", - name, - 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", - ex.desc?ex.desc:"unknown reason"); - return FALSE; - } - - if (!new_folder_exists) { - gtk_object_unref (GTK_OBJECT (new_folder)); - return FALSE; - } - - - if (fb->folder) - gtk_object_unref (GTK_OBJECT (fb->folder)); - - fb->folder = new_folder; - - message_list_set_folder (fb->message_list, new_folder); - - return TRUE; -} - -#define EQUAL(a,b) (strcmp (a,b) == 0) - -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); -} - -void -folder_browser_set_message_preview (FolderBrowser *folder_browser, gboolean show_message_preview) -{ - if (folder_browser->preview_shown == show_message_preview) - return; - - g_warning ("FIXME: implement me"); -} - -static void -get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - FolderBrowser *fb = user_data; - - switch (arg_id) { - - case PROPERTY_FOLDER_URI_IDX: - if (fb && fb->uri) - BONOBO_ARG_SET_STRING (arg, fb->uri); - else - BONOBO_ARG_SET_STRING (arg, ""); - break; - - case PROPERTY_MESSAGE_PREVIEW_IDX: - g_warning ("Implement me; no return value"); - BONOBO_ARG_SET_BOOLEAN (arg, FALSE); - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - } -} - -static void -set_prop (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - FolderBrowser *fb = user_data; - - switch (arg_id) { - - case PROPERTY_FOLDER_URI_IDX: - folder_browser_set_uri (fb, BONOBO_ARG_GET_STRING (arg)); - break; - - case PROPERTY_MESSAGE_PREVIEW_IDX: - folder_browser_set_message_preview (fb, BONOBO_ARG_GET_BOOLEAN (arg)); - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - break; - } -} - -static void -folder_browser_properties_init (FolderBrowser *fb) -{ - fb->properties = bonobo_property_bag_new (get_prop, set_prop, fb); - - bonobo_property_bag_add ( - fb->properties, PROPERTY_FOLDER_URI, PROPERTY_FOLDER_URI_IDX, - BONOBO_ARG_STRING, NULL, _("The URI that the Folder Browser will display"), 0); - bonobo_property_bag_add ( - fb->properties, PROPERTY_MESSAGE_PREVIEW, PROPERTY_MESSAGE_PREVIEW_IDX, - BONOBO_ARG_BOOLEAN, NULL, _("Whether a message preview should be shown"), 0); -} - -static void -folder_browser_gui_init (FolderBrowser *fb) -{ - /* - * The panned container - */ - fb->vpaned = gtk_vpaned_new (); - gtk_widget_show (fb->vpaned); - - gtk_table_attach ( - GTK_TABLE (fb), fb->vpaned, - 0, 1, 0, 2, - GTK_FILL | GTK_EXPAND, - GTK_FILL | GTK_EXPAND, - 0, 0); - - fb->message_list_w = message_list_get_widget (fb->message_list); - gtk_paned_add1 (GTK_PANED (fb->vpaned), fb->message_list_w); - gtk_widget_show (fb->message_list_w); - - gtk_paned_add2 (GTK_PANED (fb->vpaned), GTK_WIDGET (fb->mail_display)); - gtk_paned_set_position (GTK_PANED (fb->vpaned), 200); - - gtk_widget_show (GTK_WIDGET (fb->mail_display)); - gtk_widget_show (GTK_WIDGET (fb)); - -} - -static void -folder_browser_init (GtkObject *object) -{ -} - -static void -my_folder_browser_init (GtkObject *object) -{ - FolderBrowser *fb = FOLDER_BROWSER (object); - - /* - * Setup parent class fields. - */ - GTK_TABLE (fb)->homogeneous = FALSE; - gtk_table_resize (GTK_TABLE (fb), 1, 2); - - /* - * Our instance data - */ - fb->message_list = MESSAGE_LIST (message_list_new (fb)); - fb->mail_display = MAIL_DISPLAY (mail_display_new (fb)); - - folder_browser_properties_init (fb); - folder_browser_gui_init (fb); -} - -GtkWidget * -folder_browser_new (void) -{ - FolderBrowser *folder_browser = gtk_type_new (folder_browser_get_type ()); - - my_folder_browser_init (GTK_OBJECT (folder_browser)); - folder_browser->uri = NULL; - - return GTK_WIDGET (folder_browser); -} - - -E_MAKE_TYPE (folder_browser, "FolderBrowser", FolderBrowser, folder_browser_class_init, folder_browser_init, PARENT_TYPE); - - diff --git a/mail/folder-browser.h b/mail/folder-browser.h deleted file mode 100644 index 04c3dbcb4a..0000000000 --- a/mail/folder-browser.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - - -#ifndef _FOLDER_BROWSER_H_ -#define _FOLDER_BROWSER_H_ - -#include "mail-types.h" -#include <gtk/gtktable.h> -#include "camel/camel-stream.h" -#include <bonobo/bonobo-property-bag.h> -#include "message-list.h" -#include "mail-display.h" -#include "shell/Evolution.h" - - -#define FOLDER_BROWSER_TYPE (folder_browser_get_type ()) -#define FOLDER_BROWSER(o) (GTK_CHECK_CAST ((o), FOLDER_BROWSER_TYPE, FolderBrowser)) -#define FOLDER_BROWSER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), FOLDER_BROWSER_TYPE, FolderBrowserClass)) -#define IS_FOLDER_BROWSER(o) (GTK_CHECK_TYPE ((o), FOLDER_BROWSER_TYPE)) -#define IS_FOLDER_BROWSER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), FOLDER_BROWSER_TYPE)) - - -struct _FolderBrowser { - GtkTable parent; - - BonoboPropertyBag *properties; - - Evolution_Shell shell; - - /* - * The current URI being displayed by the FolderBrowser - */ - char *uri; - CamelFolder *folder; - - MessageList *message_list; - GtkWidget *message_list_w; - MailDisplay *mail_display; - GtkWidget *vpaned; - gboolean preview_shown; - -}; - - -typedef struct { - GtkTableClass parent_class; -} FolderBrowserClass; - - - - -GtkType folder_browser_get_type (void); -GtkWidget *folder_browser_new (void); -void folder_browser_set_uri (FolderBrowser *folder_browser, - const char *uri); -void folder_browser_set_message_preview (FolderBrowser *folder_browser, - gboolean show_message_preview); - -#endif /* _FOLDER_BROWSER_H_ */ diff --git a/mail/mail-component.c b/mail/mail-component.c deleted file mode 100644 index 66d223ab2c..0000000000 --- a/mail/mail-component.c +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * mail-component.c: The core of the mail component - * - * Author: - * Miguel de Icaza (miguel@helixcode.com) - * - * (C) 2000 Helix Code, Inc. - */ -#include <config.h> -#include <gnome.h> -#include <bonobo/bonobo-main.h> -#include "e-util/e-gui-utils.h" - -CORBA_Environment ev; -CORBA_ORB orb; - -static void -init_bonobo (int argc, char **argv) -{ - gnome_CORBA_init_with_popt_table ( - "evolution-mail-component", "1.0", - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE){ - e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, - _("Mail Component: I could not initialize Bonobo")); - exit (1); - } -} - -static void -main (int argc, char *argv []) -{ - bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR); - textdomain (PACKAGE); - - CORBA_exception_init (&ev); - - init_bonobo (argc, argv); - - mail_display_factory_init (); - - bonobo_main (); - - return 0; -} diff --git a/mail/mail-display.c b/mail/mail-display.c deleted file mode 100644 index e0eb584a17..0000000000 --- a/mail/mail-display.c +++ /dev/null @@ -1,471 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * mail-display.c: Mail display widget - * - * Author: - * Miguel de Icaza - * Bertrand Guiheneuf (bg@aful.org) - * - * (C) 2000 Helix Code, Inc. - */ -#include <config.h> -#include <gnome.h> -#include "e-util/e-util.h" -#include "mail-display.h" -#include "mail-format.h" - -/* corba/bonobo stuff */ -#include <bonobo.h> -#include <libgnorba/gnorba.h> -#include <bonobo/bonobo-stream-memory.h> - -#define PARENT_TYPE (gtk_table_get_type ()) - -static GtkObjectClass *mail_display_parent_class; - - -/*----------------------------------------------------------------------* - * Helper utility functions - *----------------------------------------------------------------------*/ - - -/* stuff to display Bonobo Components inside the html message - * body view */ -static gboolean -hydrate_persist_stream_from_gstring (Bonobo_PersistStream persist_stream, - GString* gstr) -{ - CORBA_Environment ev; - BonoboStream* mem_stream = - bonobo_stream_mem_create (gstr->str, gstr->len, TRUE, FALSE); - CORBA_Object mem_stream_corba = - bonobo_object_corba_objref (BONOBO_OBJECT (mem_stream)); - - g_assert (persist_stream != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - /* - * Load the file into the component using PersistStream. - */ - Bonobo_PersistStream_load (persist_stream, mem_stream_corba, &ev); - - bonobo_object_unref (BONOBO_OBJECT (mem_stream)); - - if (ev._major != CORBA_NO_EXCEPTION) { - gnome_warning_dialog (_("An exception occured while trying " - "to load data into the component with " - "PersistStream")); - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - return TRUE; -} - - -static GString* -camel_stream_to_gstring (CamelStream* stream) -{ - gchar tmp_buffer[4097]; - GString *tmp_gstring = g_string_new (""); - - do { /* read next chunk of text */ - - gint nb_bytes_read; - - nb_bytes_read = camel_stream_read (stream, - tmp_buffer, - 4096); - tmp_buffer [nb_bytes_read] = '\0'; - - /* If there's any text, append it to the gstring */ - if (nb_bytes_read > 0) { - tmp_gstring = g_string_append (tmp_gstring, tmp_buffer); - } - - } while (!camel_stream_eos (stream)); - - return tmp_gstring; -} - -/*----------------------------------------------------------------------* - * Callbacks - *----------------------------------------------------------------------*/ - -static void -embeddable_destroy_cb (GtkObject *obj, gpointer user_data) -{ - BonoboWidget *be; /* bonobo embeddable */ - BonoboViewFrame *vf; /* the embeddable view frame */ - BonoboObjectClient* server; - CORBA_Environment ev; - - - printf ("in the bonobo embeddable destroy callback\n"); - be = BONOBO_WIDGET (obj); - server = bonobo_widget_get_server (be); - - - - vf = bonobo_widget_get_view_frame (be); - bonobo_control_frame_control_deactivate ( - BONOBO_CONTROL_FRAME (vf)); - /* w = bonobo_control_frame_get_widget (BONOBO_CONTROL_FRAME (vf)); */ - - /* gtk_widget_destroy (w); */ - - CORBA_exception_init (&ev); - Bonobo_Unknown_unref ( - bonobo_object_corba_objref (BONOBO_OBJECT(server)), &ev); - CORBA_Object_release ( - bonobo_object_corba_objref (BONOBO_OBJECT(server)), &ev); - - CORBA_exception_free (&ev); - bonobo_object_destroy (BONOBO_OBJECT (vf)); - /* gtk_object_unref (obj); */ -} - - - -/* - * As a page is loaded, when gtkhtml comes across <object> tags, this - * callback is invoked. The GtkHTMLEmbedded param is a GtkContainer; - * our job in this function is to simply add a child widget to it. - */ -static void -on_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, void *unused) -{ - CamelStream *stream; - GString *camel_stream_gstr; - - GtkWidget *bonobo_embeddable; - BonoboObjectClient* server; - Bonobo_PersistStream persist; - CORBA_Environment ev; - gchar *uid = gtk_html_embedded_get_parameter (eb, "uid"); - - - /* Both the classid (which specifies which bonobo object to - * fire up) and the uid (which tells us where to find data to - * persist from) must be available; if one of them isn't, - * print an error and bail. */ - if (!uid || !eb->classid) { - printf ("on_object_requested: couldn't find %s%s%s\n", - uid?"a uid":"", - (!uid && !eb->classid)?" or ":"", - eb->classid?"a classid":""); - return; - } - printf ("object requested : %s\n", eb->classid); - printf ("UID = %s\n", uid); - - /* Try to get a server with goadid specified by eb->classid */ - bonobo_embeddable = bonobo_widget_new_subdoc (eb->classid, NULL); - gtk_signal_connect (GTK_OBJECT (bonobo_embeddable), - "destroy", embeddable_destroy_cb, NULL); - - server = bonobo_widget_get_server (BONOBO_WIDGET (bonobo_embeddable)); - if (!server) { - printf ("Couldn't get the server for the bonobo embeddable\n"); - return; - } - - /* The UID should be a pointer to a CamelStream */ - if (sscanf (uid, "camel://%p", &stream) != 1) { - printf ("Couldn't get a pointer from url \"%s\"\n", uid); - gtk_object_unref (GTK_OBJECT (bonobo_embeddable)); - - return; - } - - /* Try to get a PersistStream interface from the server; - if it doesn't support that interface, bail. */ - persist = (Bonobo_PersistStream) bonobo_object_client_query_interface ( - server, - "IDL:Bonobo/PersistStream:1.0", - NULL); - - if (persist == CORBA_OBJECT_NIL) { - gchar* msg = g_strdup_printf ( - _("The %s component doesn't support PersistStream!\n"), - uid); - - gnome_warning_dialog (msg); - gtk_object_unref (GTK_OBJECT (bonobo_embeddable)); - - g_free (msg); - return; - } - - /* Hydrate the PersistStream from the CamelStream */ - camel_stream_gstr = camel_stream_to_gstring (stream); - printf ("on_object_requested: The CamelStream has %d elements\n", - camel_stream_gstr->len); - hydrate_persist_stream_from_gstring (persist, camel_stream_gstr); - - /* Give our new window to the container */ - - gtk_widget_show (bonobo_embeddable); - gtk_container_add (GTK_CONTAINER(eb), bonobo_embeddable); - - /* Destroy the PersistStream object.*/ - CORBA_exception_init (&ev); - Bonobo_Unknown_unref (persist, &ev); - CORBA_Object_release (persist, &ev); - CORBA_exception_free (&ev); - - g_string_free (camel_stream_gstr, TRUE); -} - -static CamelMimePart * -find_cid (const char *cid, CamelMimePart *part) -{ - const char *msg_cid; - CamelDataWrapper *content; - CamelMultipart *mp; - int i, nparts; - - msg_cid = camel_mime_part_get_content_id (part); - if (msg_cid && !strcmp (cid, msg_cid)) - return part; - - content = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - if (!content) - return NULL; - - if (CAMEL_IS_MIME_PART (content)) - return find_cid (cid, CAMEL_MIME_PART (content)); - else if (!CAMEL_IS_MULTIPART (content)) - return NULL; - - mp = CAMEL_MULTIPART (content); - nparts = camel_multipart_get_number (mp); - for (i = 0; i < nparts; i++) { - CamelMimePart *found_part; - - part = CAMEL_MIME_PART (camel_multipart_get_part (mp, i)); - found_part = find_cid (cid, part); - if (found_part) - return found_part; - } - - return NULL; -} - -static void -on_url_requested (GtkHTML *html, const char *url, GtkHTMLStreamHandle handle, - gpointer user_data) -{ - char buf[1024]; - int nread; - CamelMimePart *part; - CamelDataWrapper *data; - CamelStream *output; - - if (strncmp (url, "cid:", 4)) - return; - - part = gtk_object_get_data (GTK_OBJECT (html), "message"); - g_return_if_fail (part != NULL); - - part = find_cid (url + 4, part); - if (!part) - return; - - data = camel_medium_get_content_object (CAMEL_MEDIUM (part)); - output = camel_data_wrapper_get_output_stream (data); - do { - nread = camel_stream_read (output, buf, sizeof (buf)); - if (nread > 0) - gtk_html_write (html, handle, buf, nread); - } while (!camel_stream_eos (output)); -} - - -/** - * mail_display_set_message: - * @mail_display: the mail display object - * @mime_message: the input camel medium - * - * Makes the mail_display object show the contents of the medium - * param. This means feeding mail_display->body_stream and - * mail_display->headers_stream with html. - * - **/ -void -mail_display_set_message (MailDisplay *mail_display, - CamelMedium *medium) -{ - GtkHTMLStreamHandle *headers_stream, *body_stream; - - /* - * for the moment, camel-formatter deals only with - * mime messages, but in the future, it should be - * able to deal with any medium. - * It can work on pretty much data wrapper, but in - * fact, only the medium class has the distinction - * header / body - */ - if (!CAMEL_IS_MIME_MESSAGE (medium)) - return; - - /* we were given a reference to the message in the last call - * to mail_display_set_message, free it now. */ - if (mail_display->current_message) - gtk_object_unref (GTK_OBJECT (mail_display->current_message)); - - mail_display->current_message = CAMEL_MIME_MESSAGE (medium); - gtk_object_ref (GTK_OBJECT (medium)); - - headers_stream = gtk_html_begin (mail_display->headers_html_widget, ""); - body_stream = gtk_html_begin (mail_display->body_html_widget, ""); - - /* Convert the message into html and stream the result to the - * gtkhtml widgets. - */ - mail_write_html (headers_stream, "\n\ -<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\n\ -<html>\n\ -<head>\n\ - <meta name=\"GENERATOR\" content=\"Evolution Mail Component (Rhon Rhon release)\">\n\ -</head>\n\ -<body text=\"#000000\" bgcolor=\"#EEEEEE\">\n\ -<font>\n\ -"); - - mail_write_html (body_stream, "\n\ -<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">\n\ -<html>\n\ -<head>\n\ - <meta name=\"GENERATOR\" content=\"Evolution Mail Component (Rhon Rhon release)\">\n\ -</head>\n\ -<body text=\"#000000\" bgcolor=\"#FFFFFF\">\n\ -"); - - mail_format_mime_message (CAMEL_MIME_MESSAGE (medium), - headers_stream, - body_stream); - gtk_object_set_data (GTK_OBJECT (mail_display->body_html_widget), - "message", medium); - - mail_write_html (headers_stream, "\n</font>\n</body>\n</html>\n"); - mail_write_html (body_stream, "\n</body>\n</html>\n"); - - gtk_html_end (mail_display->headers_html_widget, headers_stream, - GTK_HTML_STREAM_OK); - gtk_html_end (mail_display->body_html_widget, body_stream, - GTK_HTML_STREAM_OK); -} - - -/*----------------------------------------------------------------------* - * Standard Gtk+ Class functions - *----------------------------------------------------------------------*/ - -static void -mail_display_init (GtkObject *object) -{ - MailDisplay *mail_display = MAIL_DISPLAY (object); - - /* create the headers html widget */ - mail_display->headers_html_widget = (GtkHTML *) gtk_html_new (); - gtk_widget_show (GTK_WIDGET (mail_display->headers_html_widget)); - - /* create the body html widget */ - mail_display->body_html_widget = (GtkHTML *) gtk_html_new (); - gtk_signal_connect (GTK_OBJECT (mail_display->body_html_widget), - "object_requested", - GTK_SIGNAL_FUNC (on_object_requested), - NULL); - gtk_signal_connect (GTK_OBJECT (mail_display->body_html_widget), - "url_requested", - GTK_SIGNAL_FUNC (on_url_requested), - NULL); - gtk_widget_show (GTK_WIDGET (mail_display->body_html_widget)); - - /* various other initializations */ - mail_display->current_message = NULL; -} - -static void -mail_display_destroy (GtkObject *object) -{ - /* MailDisplay *mail_display = MAIL_DISPLAY (object); */ - - mail_display_parent_class->destroy (object); -} - -static void -mail_display_class_init (GtkObjectClass *object_class) -{ - object_class->destroy = mail_display_destroy; - mail_display_parent_class = gtk_type_class (PARENT_TYPE); -} - -GtkWidget * -mail_display_new (FolderBrowser *parent_folder_browser) -{ - MailDisplay *mail_display = gtk_type_new (mail_display_get_type ()); - GtkTable *table = GTK_TABLE (mail_display); - GtkWidget *scroll_wnd; - GtkWidget* frame_wnd = NULL; - - g_assert (parent_folder_browser); - - mail_display->parent_folder_browser = parent_folder_browser; - - /* the table has table with 1 column and 2 lines */ - table->homogeneous = FALSE; - - gtk_table_resize (table, 1, 2); - gtk_widget_show (GTK_WIDGET (mail_display)); - - - /* create a scrolled window and put the headers - * html widget inside */ - scroll_wnd = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_wnd), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_NEVER); - frame_wnd = gtk_frame_new (NULL); - gtk_frame_set_shadow_type ( - GTK_FRAME (frame_wnd), GTK_SHADOW_OUT); - gtk_widget_show (scroll_wnd); - gtk_container_add (GTK_CONTAINER (frame_wnd), scroll_wnd); - gtk_widget_show (frame_wnd); - gtk_container_add (GTK_CONTAINER (scroll_wnd), - GTK_WIDGET (mail_display->headers_html_widget)); - gtk_widget_set_usize (GTK_WIDGET (scroll_wnd), -1, 100); - /* add it on the top part of the table */ - gtk_table_attach (table, GTK_WIDGET (frame_wnd), - 0, 1, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); - - - /* create a scrolled window and put the body - * html widget inside */ - scroll_wnd = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll_wnd), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_ALWAYS); - - gtk_widget_show (scroll_wnd); - gtk_container_add (GTK_CONTAINER (scroll_wnd), - GTK_WIDGET (mail_display->body_html_widget)); - - /* add it at the bottom part of the table */ - gtk_table_attach (table, GTK_WIDGET (scroll_wnd), - 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); - - return GTK_WIDGET (mail_display); -} - - - -E_MAKE_TYPE (mail_display, "MailDisplay", MailDisplay, mail_display_class_init, mail_display_init, PARENT_TYPE); - - - diff --git a/mail/mail-display.h b/mail/mail-display.h deleted file mode 100644 index 685bd4c8f8..0000000000 --- a/mail/mail-display.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - - - - - - - - - - - - -#ifndef _MAIL_DISPLAY_H_ -#define _MAIL_DISPLAY_H_ - -#include <gtk/gtktable.h> -#include <gtkhtml/gtkhtml.h> -#include "camel/camel-stream.h" -#include "camel/camel-mime-message.h" -#include "folder-browser.h" - - -#define MAIL_DISPLAY_TYPE (mail_display_get_type ()) -#define MAIL_DISPLAY(o) (GTK_CHECK_CAST ((o), MAIL_DISPLAY_TYPE, MailDisplay)) -#define MAIL_DISPLAY_CLASS(k) (GTK_CHECK_CLASS_CAST((k), MAIL_DISPLAY_TYPE, MailDisplayClass)) -#define IS_MAIL_DISPLAY(o) (GTK_CHECK_TYPE ((o), MAIL_DISPLAY_TYPE)) -#define IS_MAIL_DISPLAY_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), MAIL_DISPLAY_TYPE)) - -struct _MailDisplay { - GtkTable parent; - - FolderBrowser *parent_folder_browser; - - GtkHTML * headers_html_widget; - GtkHTML * body_html_widget; - - CamelMimeMessage *current_message; -}; - -typedef struct { - GtkTableClass parent_class; -} MailDisplayClass; - -GtkType mail_display_get_type (void); -GtkWidget * mail_display_new (FolderBrowser *parent_folder_browser); - -void mail_display_set_message (MailDisplay *mail_display, - CamelMedium *medium); - - - -#endif /* _MAIL_DISPLAY_H_ */ diff --git a/mail/mail-format.c b/mail/mail-format.c deleted file mode 100644 index b5aba4ca32..0000000000 --- a/mail/mail-format.c +++ /dev/null @@ -1,1118 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Matt Loper <matt@helixcode.com> - * - * Copyright 2000, Helix Code, Inc. (http://www.helixcode.com) - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#include <config.h> -#include "mail-format.h" -#include "camel/hash-table-utils.h" - -#include <libgnome/libgnome.h> -#include <ctype.h> /* for isprint */ -#include <string.h> /* for strstr */ - -static void handle_text_plain (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); -static void handle_text_html (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); -static void handle_image (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); -static void handle_vcard (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); -static void handle_mime_part (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); -static void handle_multipart_mixed (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); -static void handle_multipart_related (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); -static void handle_multipart_alternative(CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); -static void handle_unknown_type (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); - -/* encodes some characters into their 'escaped' version; - * so '<' turns into '<', and '"' turns into '"' */ -static gchar *text_to_html (const guchar *input, - guint len, - guint *encoded_len_return, - gboolean add_pre, - gboolean convert_newlines_to_br); - -/* writes the header info for a mime message into an html stream */ -static void write_header_info_to_stream (CamelMimeMessage* mime_message, - GtkHTMLStreamHandle *stream); - -/* dispatch html printing via mimetype */ -static void call_handler_function (CamelDataWrapper *wrapper, - gchar *mimetype_whole, - gchar *mimetype_main, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); - -#if 0 -/** - * camel_formatter_wrapper_to_html: - * @formatter: the camel formatter object - * @data_wrapper: the data wrapper - * @stream: byte stream where data will be written - * - * Writes a CamelDataWrapper out, as html, into a stream passed in as - * a parameter. - **/ -void camel_formatter_wrapper_to_html (CamelFormatter* formatter, - CamelDataWrapper* data_wrapper, - CamelStream* stream_out) -{ - CamelFormatterPrivate* fmt = formatter->priv; - gchar *mimetype_whole = - g_strdup_printf ("%s/%s", - data_wrapper->mime_type->type, - data_wrapper->mime_type->subtype); - - debug ("camel_formatter_wrapper_to_html: entered\n"); - g_assert (formatter && data_wrapper && stream_out); - - /* give the root CamelDataWrapper and the stream to the formatter */ - initialize_camel_formatter (formatter, data_wrapper, stream_out); - - if (stream_out) { - - /* write everything to the stream */ - camel_stream_write_string ( - fmt->stream, "<html><body bgcolor=\"white\">\n"); - call_handler_function ( - formatter, - data_wrapper, - mimetype_whole, - data_wrapper->mime_type->type); - - camel_stream_write_string (fmt->stream, "\n</body></html>\n"); - } - - - g_free (mimetype_whole); -} -#endif - -/** - * mail_format_mime_message: - * @mime_message: the input mime message - * @header_stream: HTML stream to write headers to - * @body_stream: HTML stream to write data to - * - * Writes a CamelMimeMessage out, as html, into streams passed in as - * a parameter. Either stream may be #NULL. - **/ -void -mail_format_mime_message (CamelMimeMessage *mime_message, - GtkHTMLStreamHandle *header_stream, - GtkHTMLStreamHandle *body_stream) -{ - g_return_if_fail (CAMEL_IS_MIME_MESSAGE (mime_message)); - - /* Write the headers fields out as HTML to the header stream. */ - if (header_stream) - write_header_info_to_stream (mime_message, header_stream); - - /* Write the contents of the MIME message to the body stream. */ - if (body_stream) { - mail_write_html (body_stream, "<html><body>\n"); - call_handler_function (CAMEL_DATA_WRAPPER (mime_message), - "message/rfc822", - "message", - body_stream, - CAMEL_DATA_WRAPPER (mime_message)); - mail_write_html (body_stream, "\n</body></html>\n"); - } -} - -/* We're maintaining a hashtable of mimetypes -> functions; - * Those functions have the following signature... - */ -typedef void (*mime_handler_fn) (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root); - -static gchar* -lookup_unique_id (CamelDataWrapper *root, CamelDataWrapper *child) -{ - /* ** FIXME : replace this with a string representing - the location of the objetc in the tree */ - /* TODO: assert our return value != NULL */ - - gchar *temp_hack_uid; - - temp_hack_uid = g_strdup_printf ("%p", camel_data_wrapper_get_output_stream (child)); - - return temp_hack_uid; -} - -static GHashTable *mime_function_table; - -/* This tries to create a tag, given a mimetype and the child of a - * mime message. It can return NULL if it can't match the mimetype to - * a bonobo object. - */ -static gchar * -get_bonobo_tag_for_object (CamelDataWrapper *wrapper, - gchar *mimetype, CamelDataWrapper *root) -{ - char *uid = lookup_unique_id (root, wrapper); - const char *goad_id = gnome_mime_get_value (mimetype, - "bonobo-goad-id"); - - if (goad_id) { - return g_strdup_printf ("<object classid=\"%s\"> " - "<param name=\"uid\" " - "value=\"camel://%s\"> </object>", - goad_id, uid); - } else - return NULL; -} - - -/* - * This takes a mimetype, and tries to map that mimetype to a function - * or a bonobo object. - * - * - If it's mapped to a bonobo object, this function prints a tag - * into the stream, designating the bonobo object and a place that - * the bonobo object can find data to hydrate from - * - * - otherwise, the mimetype is mapped to another function, which can - * print into the stream - */ -static void -call_handler_function (CamelDataWrapper *wrapper, - gchar *mimetype_whole_in, /* ex. "image/jpeg" */ - gchar *mimetype_main_in, /* ex. "image" */ - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - mime_handler_fn handler_function = NULL; - gchar *mimetype_whole = NULL; - gchar *mimetype_main = NULL; - - g_return_if_fail (mimetype_whole_in || mimetype_main_in); - g_return_if_fail (CAMEL_IS_DATA_WRAPPER (wrapper)); - g_return_if_fail (CAMEL_IS_DATA_WRAPPER (root)); - - if (mime_function_table == NULL) { - mime_function_table = g_hash_table_new (g_strcase_hash, - g_strcase_equal); - - /* hook up mime types to functions that handle them */ - g_hash_table_insert (mime_function_table, "text/plain", - handle_text_plain); - g_hash_table_insert (mime_function_table, "text/richtext", - handle_text_plain); - g_hash_table_insert (mime_function_table, "text/html", - handle_text_html); - g_hash_table_insert (mime_function_table, "multipart/alternative", - handle_multipart_alternative); - g_hash_table_insert (mime_function_table, "multipart/related", - handle_multipart_related); - g_hash_table_insert (mime_function_table, "multipart/mixed", - handle_multipart_mixed); - g_hash_table_insert (mime_function_table, "message/rfc822", - handle_mime_part); - g_hash_table_insert (mime_function_table, "image", - handle_image); - g_hash_table_insert (mime_function_table, "vcard", - handle_vcard); - - /* RFC 2046 says unrecognized multipart subtypes should - * be treated like multipart/mixed. - */ - g_hash_table_insert (mime_function_table, "multipart", - handle_multipart_mixed); - - /* Body parts don't have mime parts per se, so Camel - * sticks on the following one. - */ - g_hash_table_insert (mime_function_table, "mime/body-part", - handle_mime_part); - } - - /* Try to find a handler function in our own lookup table */ - if (mimetype_whole_in) { - mimetype_whole = g_strdup (mimetype_whole_in); - g_strdown (mimetype_whole); - - handler_function = g_hash_table_lookup (mime_function_table, - mimetype_whole); - } - - if (mimetype_main_in && !handler_function) { - mimetype_main = g_strdup (mimetype_main_in); - g_strdown (mimetype_main); - - handler_function = g_hash_table_lookup (mime_function_table, - mimetype_main); - } - - /* Upon failure, try to find a bonobo object to show the object */ - if (!handler_function) { - gchar *bonobo_tag = NULL; - - if (mimetype_whole) - bonobo_tag = get_bonobo_tag_for_object ( - wrapper, mimetype_whole, root); - - if (mimetype_main && !bonobo_tag) - bonobo_tag = get_bonobo_tag_for_object ( - wrapper, mimetype_main, root); - - if (bonobo_tag) { - /* We can print a tag, and return! */ - - mail_write_html (stream, bonobo_tag); - g_free (bonobo_tag); - if (mimetype_whole) - g_free (mimetype_whole); - if (mimetype_main) - g_free (mimetype_main); - - return; - } - } - - /* Use either a handler function we've found, or a default handler. */ - if (handler_function) - (*handler_function) (wrapper, stream, root); - else - handle_unknown_type (wrapper, stream, root); - if (mimetype_whole) - g_free (mimetype_whole); - if (mimetype_main) - g_free (mimetype_main); -} - - -/* Convert plain text in equivalent-looking valid HTML. */ -static gchar * -text_to_html (const guchar *input, guint len, - guint *encoded_len_return, gboolean add_pre, - gboolean convert_newlines_to_br) -{ - const guchar *cur = input; - guchar *buffer = NULL; - guchar *out = NULL; - gint buffer_size = 0; - - /* Allocate a translation buffer. */ - buffer_size = len * 2 + 5; - buffer = g_malloc (buffer_size); - - out = buffer; - if (add_pre) - out += sprintf (out, "<PRE>\n"); - - while (len--) { - if (out - buffer > buffer_size - 100) { - gint index = out - buffer; - - buffer_size *= 2; - buffer = g_realloc (buffer, buffer_size); - out = buffer + index; - } - - switch (*cur) { - case '<': - strcpy (out, "<"); - out += 4; - break; - - case '>': - strcpy (out, ">"); - out += 4; - break; - - case '&': - strcpy (out, "&"); - out += 5; - break; - - case '"': - strcpy (out, """); - out += 6; - break; - - case '\n': - *out++ = *cur; - if (convert_newlines_to_br) { - strcpy (out, "<br>"); - out += 4; - } - break; - - default: - if ((*cur >= 0x20 && *cur < 0x80) || - (*cur == '\r' || *cur == '\t')) { - /* Default case, just copy. */ - *out++ = *cur; - } else - out += g_snprintf(out, 9, "&#%d;", *cur); - break; - } - - cur++; - } - - if (add_pre) - strcpy (out, "</PRE>"); - else - *out = '\0'; - if (encoded_len_return) - *encoded_len_return = out - buffer; - - return buffer; -} - - -static void -write_field_to_stream (const gchar *description, const gchar *value, - gboolean bold, GtkHTMLStreamHandle *stream) -{ - gchar *s; - gchar *encoded_value; - - if (value) { - unsigned char *p; - - encoded_value = text_to_html (value, strlen(value), - NULL, FALSE, TRUE); - for (p = (unsigned char *)encoded_value; *p; p++) { - if (!isprint (*p)) - *p = '?'; - } - } else - encoded_value = g_strdup (""); - - s = g_strdup_printf ("<tr valign=top><%s align=right>%s</%s>" - "<td>%s</td></tr>", bold ? "th" : "td", - description, bold ? "th" : "td", - encoded_value); - mail_write_html (stream, s); - g_free (encoded_value); - g_free (s); -} - -static void -write_recipients_to_stream (const gchar *recipient_type, - const GList *recipients, gboolean bold, - GtkHTMLStreamHandle *stream) -{ - gchar *recipients_string = NULL; - - while (recipients) { - gchar *old_string = recipients_string; - recipients_string = - g_strdup_printf ("%s%s%s", - old_string ? old_string : "", - old_string ? "; " : "", - (gchar *)recipients->data); - g_free (old_string); - - recipients = recipients->next; - } - - write_field_to_stream (recipient_type, recipients_string, - bold, stream); - g_free (recipients_string); -} - - - -static void -write_header_info_to_stream (CamelMimeMessage *mime_message, - GtkHTMLStreamHandle *stream) -{ - const GList *recipients; - - mail_write_html (stream, "<table>"); - - /* A few fields will probably be available from the mime_message; - * for each one that's available, write it to the output stream - * with a helper function, 'write_field_to_stream'. - */ - - write_field_to_stream ("From:", - camel_mime_message_get_from (mime_message), - TRUE, stream); - - if (camel_mime_message_get_reply_to (mime_message)) { - write_field_to_stream ("Reply-To:", - camel_mime_message_get_reply_to (mime_message), - FALSE, stream); - } - - write_recipients_to_stream ("To:", - camel_mime_message_get_recipients (mime_message, CAMEL_RECIPIENT_TYPE_TO), - TRUE, stream); - - recipients = camel_mime_message_get_recipients (mime_message, CAMEL_RECIPIENT_TYPE_CC); - if (recipients) - write_recipients_to_stream ("Cc:", recipients, TRUE, stream); - write_field_to_stream ("Subject:", - camel_mime_message_get_subject (mime_message), - TRUE, stream); - - mail_write_html (stream, "</table>"); -} - -#define MIME_TYPE_WHOLE(a) (gmime_content_field_get_mime_type ( \ - camel_mime_part_get_content_type (CAMEL_MIME_PART (a)))) -#define MIME_TYPE_MAIN(a) ((camel_mime_part_get_content_type (CAMEL_MIME_PART (a)))->type) -#define MIME_TYPE_SUB(a) ((camel_mime_part_get_content_type (CAMEL_MIME_PART (a)))->subtype) - - -/*----------------------------------------------------------------------* - * Mime handling functions - *----------------------------------------------------------------------*/ - -static void -handle_text_plain (CamelDataWrapper *wrapper, GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - gchar *text; - CamelStream *wrapper_output_stream; - gchar tmp_buffer[4096]; - gint nb_bytes_read; - gboolean empty_text = TRUE; - - - mail_write_html (stream, "\n<!-- text/plain below -->\n"); - mail_write_html (stream, "<pre>\n"); - - /* FIXME: text/richtext is not difficult to translate into HTML */ - if (strcmp (wrapper->mime_type->subtype, "richtext") == 0) { - mail_write_html (stream, "<center><b>" - "<table bgcolor=\"b0b0ff\" cellpadding=3>" - "<tr><td>Warning: the following " - "richtext may not be formatted correctly. " - "</b></td></tr></table></center><br>"); - } - - /* Get the output stream of the data wrapper. */ - wrapper_output_stream = camel_data_wrapper_get_output_stream (wrapper); - camel_stream_reset (wrapper_output_stream); - - do { - /* Read next chunk of text. */ - nb_bytes_read = camel_stream_read (wrapper_output_stream, - tmp_buffer, 4096); - - /* If there's any text, write it to the stream. */ - if (nb_bytes_read > 0) { - int returned_strlen; - - empty_text = FALSE; - - /* replace '<' with '<', etc. */ - text = text_to_html (tmp_buffer, - nb_bytes_read, - &returned_strlen, - FALSE, FALSE); - mail_write_html (stream, text); - g_free (text); - } - } while (!camel_stream_eos (wrapper_output_stream)); - - if (empty_text) - mail_write_html (stream, "<b>(empty)</b>"); - - mail_write_html (stream, "</pre>\n"); -} - -static void -handle_text_html (CamelDataWrapper *wrapper, GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - CamelStream *wrapper_output_stream; - gchar tmp_buffer[4096]; - gint nb_bytes_read; - gboolean empty_text = TRUE; - - /* Get the output stream of the data wrapper. */ - wrapper_output_stream = camel_data_wrapper_get_output_stream (wrapper); - camel_stream_reset (wrapper_output_stream); - - /* Write the header. */ - mail_write_html (stream, "\n<!-- text/html below -->\n"); - - do { - /* Read next chunk of text. */ - nb_bytes_read = camel_stream_read (wrapper_output_stream, - tmp_buffer, 4096); - - /* If there's any text, write it to the stream */ - if (nb_bytes_read > 0) { - empty_text = FALSE; - - /* Write the buffer to the html stream */ - gtk_html_stream_write (stream, tmp_buffer, - nb_bytes_read); - } - } while (!camel_stream_eos (wrapper_output_stream)); - - if (empty_text) - mail_write_html (stream, "<b>(empty)</b>"); -} - -static void -handle_image (CamelDataWrapper *wrapper, GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - gchar *uuid; - gchar *tag; - - uuid = lookup_unique_id (root, wrapper); - - mail_write_html (stream, "\n<!-- image below -->\n"); - tag = g_strdup_printf ("<img src=\"camel://%s\">\n", uuid); - mail_write_html (stream, tag); - g_free (uuid); - g_free (tag); -} - -static void -handle_vcard (CamelDataWrapper *wrapper, GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - mail_write_html (stream, "\n<!-- vcard below -->\n"); - - /* FIXME: do something here. */ -} - -static void -handle_mime_part (CamelDataWrapper *wrapper, GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - CamelMimePart *mime_part; - CamelDataWrapper *message_contents; - gchar *whole_mime_type; - - g_return_if_fail (CAMEL_IS_MIME_PART (wrapper)); - - mime_part = CAMEL_MIME_PART (wrapper); - message_contents = - camel_medium_get_content_object (CAMEL_MEDIUM (mime_part)); - - g_assert (message_contents); - - mail_write_html (stream, "\n<!-- mime message below -->\n"); - -// mail_write_html (stream, -// "<table width=95% border=1><tr><td>\n\n"); - - /* dispatch the correct handler function for the mime type */ - whole_mime_type = MIME_TYPE_WHOLE (mime_part); - call_handler_function (message_contents, - whole_mime_type, - MIME_TYPE_MAIN (mime_part), - stream, root); - g_free (whole_mime_type); - - /* close up the table we opened */ -// mail_write_html (stream, -// "\n\n</td></tr></table>\n\n"); -} - - -/* called for each body part in a multipart/mixed */ -static void -display_camel_body_part (CamelMimeBodyPart *body_part, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - gchar *whole_mime_type; - - CamelDataWrapper* contents = - camel_medium_get_content_object (CAMEL_MEDIUM (body_part)); - - whole_mime_type = MIME_TYPE_WHOLE (body_part); - call_handler_function (contents, whole_mime_type, - MIME_TYPE_MAIN (body_part), - stream, root); - g_free (whole_mime_type); - - mail_write_html (stream, "\n<hr>\n"); -} - - -/* Our policy here is this: - (1) print text/(plain|html) parts found - (2) print vcards and images inline - (3) treat all other parts as attachments */ -static void -handle_multipart_mixed (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, CamelDataWrapper *root) -{ - CamelMultipart *mp; - int i, nparts; - - g_return_if_fail (CAMEL_IS_MULTIPART (wrapper)); - - mp = CAMEL_MULTIPART (wrapper); - - nparts = camel_multipart_get_number (mp); - for (i = 0; i < nparts; i++) { - CamelMimeBodyPart *body_part = - camel_multipart_get_part (mp, i); - - display_camel_body_part (body_part, stream, root); - } -} - -/* As seen in RFC 2387! */ -/* FIXME: camel doesn't currently set CamelMultipart::parent, so we - * can use it here. - */ -static void -handle_multipart_related (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - CamelMultipart *mp; - CamelMimeBodyPart *body_part; -#if 0 - GMimeContentField *parent_content_type; - const char *start, *cid; - int i, nparts; -#endif - - g_return_if_fail (CAMEL_IS_MULTIPART (wrapper)); - - mp = CAMEL_MULTIPART (wrapper); -#if 0 - parent_content_type = - camel_mime_part_get_content_type ( - camel_multipart_get_parent (mp)); - - start = gmime_content_field_get_parameter (parent_content_type, - "start"); - if (start) { - nparts = camel_multipart_get_number (mp); - for (i = 0; i < nparts; i++) { - CamelMimeBodyPart *body_part = - camel_multipart_get_part (mp, i); - - cid = camel_mime_part_get_content_id ( - CAMEL_MIME_PART (body_part)); - - if (!strcmp (cid, start)) { - display_camel_body_part (body_part, stream, - root); - return; - } - } - - /* Oops. Hrmph. */ - handle_multipart_mixed (wrapper, stream, root); - } -#endif - - /* No start parameter, so it defaults to the first part. */ - body_part = camel_multipart_get_part (mp, 0); - display_camel_body_part (body_part, stream, root); -} - -/* multipart/alternative helper function -- - * Returns NULL if no displayable msg is found - */ -static CamelMimePart * -find_preferred_alternative (CamelMultipart *multipart) -{ - int i, nparts; - CamelMimePart* html_part = NULL; - CamelMimePart* plain_part = NULL; - - /* Find out out many parts are in it. */ - nparts = camel_multipart_get_number (multipart); - - /* FIXME: DO LEAF-LOOKUP HERE FOR OTHER MIME-TYPES!!! */ - - for (i = 0; i < nparts; i++) { - CamelMimeBodyPart *body_part = - camel_multipart_get_part (multipart, i); - - if (strcasecmp (MIME_TYPE_MAIN (body_part), "text") != 0) - continue; - - if (strcasecmp (MIME_TYPE_SUB (body_part), "plain") == 0) - plain_part = CAMEL_MIME_PART (body_part); - else if (strcasecmp (MIME_TYPE_SUB (body_part), "html") == 0) - html_part = CAMEL_MIME_PART (body_part); - } - - if (html_part) - return html_part; - if (plain_part) - return plain_part; - return NULL; -} - -/* The current policy for multipart/alternative is this: - * - * if (we find a text/html body part) - * we print it - * else if (we find a text/plain body part) - * we print it - * else - * we print nothing - */ -static void -handle_multipart_alternative (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - CamelMultipart *multipart = CAMEL_MULTIPART (wrapper); - CamelMimePart *mime_part; - gchar *whole_mime_type; - - mime_part = find_preferred_alternative (multipart); - if (mime_part) { - CamelDataWrapper *contents = - camel_medium_get_content_object ( - CAMEL_MEDIUM (mime_part)); - - whole_mime_type = MIME_TYPE_WHOLE (mime_part); - call_handler_function (contents, whole_mime_type, - MIME_TYPE_MAIN (mime_part), - stream, root); - g_free (whole_mime_type); - } -} - -static void -handle_unknown_type (CamelDataWrapper *wrapper, - GtkHTMLStreamHandle *stream, - CamelDataWrapper *root) -{ - gchar *tag; - char *uid = lookup_unique_id (root, wrapper); - - tag = g_strdup_printf ("<a href=\"camel://%s\">click-me-to-save</a>\n", - uid); - - mail_write_html (stream, tag); -} - - -void -mail_write_html (GtkHTMLStreamHandle *stream, const char *data) -{ - gtk_html_stream_write (stream, data, strlen (data)); -} - -static char * -get_data_wrapper_text (CamelDataWrapper *data) -{ - CamelStream *memstream; - GByteArray *ba; - char *text; - - ba = g_byte_array_new (); - memstream = camel_stream_mem_new_with_byte_array (ba, CAMEL_STREAM_MEM_WRITE); - - camel_data_wrapper_write_to_stream (data, memstream); - text = g_malloc (ba->len + 1); - memcpy (text, ba->data, ba->len); - text[ba->len] = '\0'; - - camel_stream_close (memstream); - return text; -} - -static char * -reply_body (CamelDataWrapper *data, gboolean *html) -{ - CamelMultipart *mp; - CamelMimePart *subpart; - int i, nparts; - char *subtext, *old; - const char *boundary, *disp; - char *text = NULL; - GMimeContentField *mime_type; - - /* We only include text, message, and multipart bodies. */ - mime_type = camel_data_wrapper_get_mime_type_field (data); - - if (strcasecmp (mime_type->type, "message") == 0) - return get_data_wrapper_text (data); - - if (strcasecmp (mime_type->type, "text") == 0) { - *html = !strcasecmp (mime_type->subtype, "html"); - return get_data_wrapper_text (data); - } - - /* If it's not message and it's not text, and it's not - * multipart, we don't want to deal with it. - */ - if (strcasecmp (mime_type->type, "multipart") != 0) - return NULL; - - mp = CAMEL_MULTIPART (data); - - if (strcasecmp (mime_type->subtype, "alternative") == 0) { - /* Pick our favorite alternative and reply to it. */ - - subpart = find_preferred_alternative (mp); - if (!subpart) - return NULL; - - return reply_body (camel_medium_get_content_object (CAMEL_MEDIUM (subpart)), html); - } - - nparts = camel_multipart_get_number (mp); - - /* If any subpart is HTML, pull it out and reply to it by itself. - * (If we supported any other non-plain text types, we'd do the - * same for them here.) - */ - for (i = 0; i < nparts; i++) { - subpart = CAMEL_MIME_PART (camel_multipart_get_part (mp, i)); - - if (strcasecmp (MIME_TYPE_SUB (subpart), "html") == 0) - return reply_body (camel_medium_get_content_object (CAMEL_MEDIUM (subpart)), html); - } - - /* Otherwise, concatenate all the parts that: - * - are text/plain or message - * - are not explicitly tagged with non-inline disposition - */ - boundary = camel_multipart_get_boundary (mp); - for (i = 0; i < nparts; i++) { - subpart = CAMEL_MIME_PART (camel_multipart_get_part (mp, i)); - - disp = camel_mime_part_get_disposition (subpart); - if (disp && strcasecmp (disp, "inline") != 0) - continue; - - subtext = get_data_wrapper_text (data); - if (text) { - old = text; - text = g_strdup_printf ("%s\n--%s\n%s", text, - boundary, subtext); - g_free (subtext); - g_free (old); - } else - text = subtext; - } - - if (!text) - return NULL; - - old = text; - text = g_strdup_printf ("%s\n--%s--\n", text, boundary); - g_free (old); - - return text; -} - -EMsgComposer * -mail_generate_reply (CamelMimeMessage *message, gboolean to_all) -{ - CamelDataWrapper *contents; - char *text, *subject; - EMsgComposer *composer; - gboolean html; - const char *repl_to, *message_id, *references; - GList *to, *cc; - - contents = camel_medium_get_content_object (CAMEL_MEDIUM (message)); - text = reply_body (contents, &html); - - composer = E_MSG_COMPOSER (e_msg_composer_new ()); - - /* Set the quoted reply text. */ - if (text) { - char *repl_text; - - if (html) { - repl_text = g_strdup_printf ("<blockquote><i>\n%s\n" - "</i></blockquote>\n", - text); - } else { - char *s, *d, *quoted_text; - int lines, len; - - /* Count the number of lines in the body. If - * the text ends with a \n, this will be one - * too high, but that's ok. Allocate enough - * space for the text and the "> "s. - */ - for (s = text, lines = 0; s; s = strchr (s + 1, '\n')) - lines++; - quoted_text = g_malloc (strlen (text) + lines * 2); - - s = text; - d = quoted_text; - - /* Copy text to quoted_text line by line, - * prepending "> ". - */ - while (1) { - len = strcspn (s, "\n"); - if (len == 0 && !*s) - break; - sprintf (d, "> %.*s\n", len, s); - s += len; - if (!*s++) - break; - d += len + 3; - } - - /* Now convert that to HTML. */ - repl_text = text_to_html (quoted_text, - strlen (quoted_text), - &len, TRUE, FALSE); - g_free (quoted_text); - } - e_msg_composer_set_body_text (composer, repl_text); - g_free (repl_text); - g_free (text); - } - - /* Set the recipients */ - repl_to = camel_mime_message_get_reply_to (message); - if (!repl_to) - repl_to = camel_mime_message_get_from (message); - to = g_list_append (NULL, repl_to); - - if (to_all) { - const GList *recip; - - recip = camel_mime_message_get_recipients (message, - CAMEL_RECIPIENT_TYPE_TO); - cc = g_list_copy (recip); - - recip = camel_mime_message_get_recipients (message, - CAMEL_RECIPIENT_TYPE_CC); - while (recip) { - cc = g_list_append (cc, recip->data); - recip = recip->next; - } - } else - cc = NULL; - - /* Set the subject of the new message. */ - subject = camel_mime_message_get_subject (message); - if (!subject) - subject = g_strdup (""); - else if (!strncasecmp (subject, "Re: ", 4)) - subject = g_strdup (subject); - else - subject = g_strdup_printf ("Re: %s", subject); - - e_msg_composer_set_headers (composer, to, cc, NULL, subject); - g_list_free (to); - g_list_free (cc); - g_free (subject); - - /* Add In-Reply-To and References. */ - message_id = camel_medium_get_header (CAMEL_MEDIUM (message), - "Message-Id"); - references = camel_medium_get_header (CAMEL_MEDIUM (message), - "References"); - if (message_id) { - e_msg_composer_add_header (composer, "In-Reply-To", - message_id); - if (references) { - char *reply_refs; - reply_refs = g_strdup_printf ("%s %s", references, - message_id); - e_msg_composer_add_header (composer, "References", - reply_refs); - g_free (reply_refs); - } - } else if (references) - e_msg_composer_add_header (composer, "References", references); - - return composer; -} - -/* This is part of the temporary kludge below. */ -#ifndef HAVE_MKSTEMP -#include <fcntl.h> -#include <sys/stat.h> -#endif - -EMsgComposer * -mail_generate_forward (CamelMimeMessage *mime_message, - gboolean forward_as_attachment, - gboolean keep_attachments) -{ - EMsgComposer *composer; - char *tmpfile; - int fd; - CamelStream *stream; - - if (!forward_as_attachment) - g_warning ("Forward as non-attachment not implemented."); - if (!keep_attachments) - g_warning ("Forwarding without attachments not implemented."); - - /* For now, we kludge by writing out a temp file. Later, - * EMsgComposer will support attaching CamelMimeParts directly, - * or something. FIXME. - */ - tmpfile = g_strdup ("/tmp/evolution-kludge-XXXX"); -#ifdef HAVE_MKSTEMP - fd = mkstemp (tmpfile); -#else - if (mktemp (tmpfile)) { - fd = open (tmpfile, O_RDWR | O_CREAT | O_EXCL, - S_IRUSR | S_IWUSR); - } else - fd = -1; -#endif - if (fd == -1) { - g_warning ("Couldn't create temp file for forwarding"); - g_free (tmpfile); - return NULL; - } - - stream = camel_stream_fs_new_with_fd (fd); - camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (mime_message), - stream); - camel_stream_close (stream); - - composer = E_MSG_COMPOSER (e_msg_composer_new ()); - e_msg_composer_attachment_bar_attach (composer->attachment_bar, - tmpfile); - g_free (tmpfile); - - /* FIXME: should we default a subject? */ - - return composer; -} diff --git a/mail/mail-format.h b/mail/mail-format.h deleted file mode 100644 index 22c5f9deb2..0000000000 --- a/mail/mail-format.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Author : - * Matt Loper <matt@helixcode.com> - * - * Copyright 2000, Helix Code, Inc. (http://www.helixcode.com) - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef MAIL_FORMAT_H -#define MAIL_FORMAT_H - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - -#include <gtkhtml/gtkhtml.h> -#include "camel/camel.h" -#include "composer/e-msg-composer.h" - -void mail_format_mime_message (CamelMimeMessage *mime_message, - GtkHTMLStreamHandle *header_stream, - GtkHTMLStreamHandle *body_stream); - -void mail_write_html (GtkHTMLStreamHandle *stream, const char *data); - -EMsgComposer *mail_generate_reply (CamelMimeMessage *mime_message, - gboolean to_all); - -EMsgComposer *mail_generate_forward (CamelMimeMessage *mime_message, - gboolean forward_as_attachment, - gboolean keep_attachments); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif // CAMEL_FORMATTER_H - diff --git a/mail/mail-ops.c b/mail/mail-ops.c deleted file mode 100644 index 81724c4f43..0000000000 --- a/mail/mail-ops.c +++ /dev/null @@ -1,331 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mail-ops.c: callbacks for the mail toolbar/menus */ - -/* - * Author : - * Dan Winship <danw@helixcode.com> - * - * Copyright 2000 Helix Code, Inc. (http://www.helixcode.com) - * - * 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 the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <config.h> -#include <errno.h> -#include <gnome.h> -#include "camel/camel.h" -#include "mail-ops.h" -#include "mail-format.h" -#include "folder-browser.h" -#include "session.h" -#include "e-util/e-setup.h" -#include "composer/e-msg-composer.h" - -#ifndef HAVE_MKSTEMP -#include <fcntl.h> -#include <sys/stat.h> -#endif - -static void -mail_exception_dialog (char *head, CamelException *ex, GtkWindow *window) -{ - char *msg; - - msg = g_strdup_printf ("%s:\n%s", head, - camel_exception_get_description (ex)); - gnome_error_dialog_parented (msg, window); - g_free (msg); -} - -void -fetch_mail (GtkWidget *button, gpointer user_data) -{ - FolderBrowser *fb = FOLDER_BROWSER (user_data); - GtkWindow *window; - CamelException *ex; - CamelStore *store = NULL; - CamelFolder *folder = NULL, *outfolder = NULL; - int nmsgs, i; - CamelMimeMessage *msg = NULL; - char *path, *url = NULL, *provider; - gboolean get_remote; - - window = GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (fb), - GTK_TYPE_WINDOW)); - - /* FIXME: We want a better config solution than this. */ - path = g_strdup_printf ("=%s/config=/mail/get_remote", evolution_dir); - get_remote = gnome_config_get_bool_with_default (path, FALSE); - g_free (path); - path = g_strdup_printf ("=%s/config=/mail/remote_url", evolution_dir); - url = gnome_config_get_string_with_default (path, NULL); - g_free (path); - if (!get_remote || !url) { - if (url) - g_free (url); - gnome_error_dialog_parented ("You have no remote mail source " - "configured", window); - return; - } - - /* FIXME: this should go away when the provider situation is - * improved. - */ - path = g_strdup_printf ("=%s/config=/mail/remote_provider", - evolution_dir); - provider = gnome_config_get_string_with_default (path, NULL); - g_free (path); - if (provider) { - camel_provider_register_as_module (provider); - g_free (provider); - } - - ex = camel_exception_new (); - - /* If fetching mail from an mbox store, safely copy it to a - * temporary store first. - */ - if (!strncmp (url, "mbox:", 5)) { - char *tmp_mbox, *source; - int tmpfd; - - tmp_mbox = g_strdup_printf ("%s/movemail.XXXX", - evolution_folders_dir); -#ifdef HAVE_MKSTEMP - tmpfd = mkstemp (tmp_mbox); -#else - if (mktemp (tmp_mbox)) { - tmpfd = open (tmp_mbox, O_RDWR | O_CREAT | O_EXCL, - S_IRUSR | S_IWUSR); - } else - tmpfd = -1; -#endif - if (tmpfd == -1) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, - "Couldn't create temporary " - "mbox: %s", g_strerror (errno)); - mail_exception_dialog ("Unable to move mail", ex, - window); - goto cleanup; - } - close (tmpfd); - - /* Skip over "mbox://" plus host part (if any) or url. */ - source = strchr (url + 7, '/'); - - switch (camel_movemail (source, tmp_mbox, ex)) { - case -1: - mail_exception_dialog ("Unable to move mail", ex, - window); - /* FALL THROUGH */ - - case 0: - unlink (tmp_mbox); - g_free (tmp_mbox); - goto cleanup; - } - - folder = camel_store_get_folder (default_session->store, - strrchr (tmp_mbox, '/') + 1, - ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) { - mail_exception_dialog ("Unable to move mail", ex, - window); - g_free (tmp_mbox); - goto cleanup; - } - } else { - store = camel_session_get_store (default_session->session, - url, ex); - if (!store) { - mail_exception_dialog ("Unable to get new mail", - ex, window); - goto cleanup; - } - camel_service_connect_with_url (CAMEL_SERVICE (store), - url, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) { - mail_exception_dialog ("Unable to get new mail", - ex, window); - goto cleanup; - } - - folder = camel_store_get_folder (store, "inbox", ex); - if (!folder) { - mail_exception_dialog ("Unable to get new mail", - ex, window); - goto cleanup; - } - } - - camel_folder_open (folder, FOLDER_OPEN_READ, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) { - mail_exception_dialog ("Unable to get new mail", ex, window); - goto cleanup; - } - - nmsgs = camel_folder_get_message_count (folder, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) { - mail_exception_dialog ("Unable to get new mail", ex, window); - goto cleanup; - } - - if (nmsgs == 0) - goto cleanup; - - outfolder = camel_store_get_folder (default_session->store, - "inbox", ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) { - mail_exception_dialog ("Unable to open inbox to store mail", - ex, window); - goto cleanup; - } - camel_folder_open (outfolder, FOLDER_OPEN_WRITE, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) { - mail_exception_dialog ("Unable to open inbox to store mail", - ex, window); - goto cleanup; - } - - for (i = 1; i <= nmsgs; i++) { - msg = camel_folder_get_message_by_number (folder, i, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) { - mail_exception_dialog ("Unable to read message", - ex, window); - goto cleanup; - } - - camel_folder_append_message (outfolder, msg, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) { - mail_exception_dialog ("Unable to write message", - ex, window); - goto cleanup; - } - - camel_folder_delete_message_by_number (folder, i, ex); - if (camel_exception_get_id (ex) != CAMEL_EXCEPTION_NONE) { - mail_exception_dialog ("Unable to delete message", - ex, window); - goto cleanup; - } - } - msg = NULL; - - folder_browser_set_uri (fb, "inbox"); /* FIXME */ - - cleanup: - if (url) - g_free (url); - if (folder) { - if (camel_folder_is_open (folder)) - camel_folder_close (folder, TRUE, ex); - gtk_object_unref (GTK_OBJECT (folder)); - } - if (store) { - camel_service_disconnect (CAMEL_SERVICE (store), ex); - gtk_object_unref (GTK_OBJECT (store)); - } -#if 0 - /* FIXME: we'll want to do this when the rest of the mail - * stuff is refcounting things properly. - */ - if (outfolder) { - if (camel_folder_is_open (outfolder)) - camel_folder_close (outfolder, FALSE, ex); - gtk_object_unref (GTK_OBJECT (outfolder)); - } -#endif - camel_exception_free (ex); - if (msg) - gtk_object_unref (GTK_OBJECT (msg)); -} - - -static void -composer_send_cb (EMsgComposer *composer, gpointer data) -{ - CamelMimeMessage *message; - CamelStream *stream; - int stdout_dup; - - message = e_msg_composer_get_message (composer); - - stdout_dup = dup (1); - stream = camel_stream_fs_new_with_fd (stdout_dup); - camel_data_wrapper_write_to_stream (CAMEL_DATA_WRAPPER (message), - stream); - camel_stream_close (stream); - - gtk_object_unref (GTK_OBJECT (message)); - gtk_object_destroy (GTK_OBJECT (composer)); -} - - -void -send_msg (GtkWidget *widget, gpointer user_data) -{ - GtkWidget *composer; - - composer = e_msg_composer_new (); - - gtk_signal_connect (GTK_OBJECT (composer), "send", - GTK_SIGNAL_FUNC (composer_send_cb), NULL); - gtk_widget_show (composer); -} - - -static void -reply (FolderBrowser *fb, gboolean to_all) -{ - EMsgComposer *composer; - - composer = mail_generate_reply (fb->mail_display->current_message, - to_all); - - gtk_signal_connect (GTK_OBJECT (composer), "send", - GTK_SIGNAL_FUNC (composer_send_cb), NULL); - - gtk_widget_show (GTK_WIDGET (composer)); -} - -void -reply_to_sender (GtkWidget *button, gpointer user_data) -{ - reply (FOLDER_BROWSER (user_data), FALSE); -} - -void -reply_to_all (GtkWidget *button, gpointer user_data) -{ - reply (FOLDER_BROWSER (user_data), TRUE); -} - - -void -forward_msg (GtkWidget *button, gpointer user_data) -{ - FolderBrowser *fb; - EMsgComposer *composer; - - fb = FOLDER_BROWSER (user_data); - composer = mail_generate_forward (fb->mail_display->current_message, - TRUE, TRUE); - - gtk_signal_connect (GTK_OBJECT (composer), "send", - GTK_SIGNAL_FUNC (composer_send_cb), NULL); - - gtk_widget_show (GTK_WIDGET (composer)); -} diff --git a/mail/mail-ops.h b/mail/mail-ops.h deleted file mode 100644 index 86b6ac81ff..0000000000 --- a/mail/mail-ops.h +++ /dev/null @@ -1,5 +0,0 @@ -void fetch_mail (GtkWidget *button, gpointer user_data); -void send_msg (GtkWidget *button, gpointer user_data); -void forward_msg (GtkWidget *button, gpointer user_data); -void reply_to_sender (GtkWidget *button, gpointer user_data); -void reply_to_all (GtkWidget *button, gpointer user_data); diff --git a/mail/mail-sources.c b/mail/mail-sources.c deleted file mode 100644 index 3e5fbaed91..0000000000 --- a/mail/mail-sources.c +++ /dev/null @@ -1,771 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* mail-sources.c: Mail source selection wizard */ - -/* - * Author : - * Dan Winship <danw@helixcode.com> - * - * Copyright 2000 Helix Code, Inc. (http://www.helixcode.com) - * - * 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 the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <sys/stat.h> - -#include <gnome.h> -#include <gtkhtml/gtkhtml.h> - -/* XXX */ -#define default_mail_path "/var/mail" - -struct { - char *protocol, *name, *description, *authname[4], *authproto[4]; - gboolean authpasswd[4]; -} providers[] = { - { "POP3", "Post Office Protocol, version 3", - "For connecting to POP3 servers. Some web mail providers and " - "proprietary email systems also provide POP3 interfaces.", - { "Password/APOP", "Kerberos 4" }, - { NULL, "KERBEROS_V4" }, - { TRUE, FALSE } - }, - { "IMAP", "Internet Mail Access Protocol", - "For connecting to IMAP servers. Allows you to keep all of " - "your mail on the IMAP server so that you can access it from " - "anywhere.", - { "Password/CRAM-MD5", "S/Key", "Kerberos 4", "GSSAPI" }, - { NULL, "SKEY", "KERBEROS_V4", "GSSAPI" }, - { TRUE, TRUE, FALSE, FALSE }, - } -}; -#define nproviders 2 - -struct msinfo { - GtkHTML *html; - GtkWidget *prev, *next; - int page; - - /* Locally-delivered mail. */ - gboolean get_local_mail, default_local_mail_path; - char *local_mail_path; - gboolean use_movemail; - - /* Remotely-delivered mail. */ - gboolean get_remote_mail; - int remote_provider; - char *remote_host, *remote_user, *remote_password; - int remote_auth; - gboolean remember_password; - gboolean copy_local; - - /* Local store. */ - gboolean store_local; - char *local_store_path; -}; - -static void display_intro (struct msinfo *msi); -static int finish_intro (struct msinfo *msi, int direction); -static void display_local (struct msinfo *msi); -static int finish_local (struct msinfo *msi, int direction); -static void display_remote (struct msinfo *msi); -static int finish_remote (struct msinfo *msi, int direction); -static void display_remconf (struct msinfo *msi); -static int finish_remconf (struct msinfo *msi, int direction); - -static struct { - void (*display) (struct msinfo *msi); - int (*finish) (struct msinfo *msi, int direction); -} pages[] = { - { display_intro, finish_intro }, - { display_local, finish_local }, -#if 0 - { display_movemail, finish_movemail }, -#endif - { display_remote, finish_remote }, - { display_remconf, finish_remconf }, - { NULL, NULL } -}; - - -/* Wrappers around gtkhtml */ - -static void -write_html (GtkHTML *html, GtkHTMLStreamHandle handle, const char *text) -{ - gtk_html_write (html, handle, text, strlen (text)); -} - -static GtkHTMLStreamHandle -start_html (GtkHTML *html) -{ - GtkHTMLStreamHandle handle; - - handle = gtk_html_begin (html, ""); - write_html (html, handle, "<body bgcolor=white>\n"); - return handle; -} - -void -end_html (GtkHTML *html, GtkHTMLStreamHandle handle) -{ - write_html (html, handle, "</body>"); - gtk_html_end (html, handle, GTK_HTML_STREAM_OK); -} - - -/* Button callbacks */ - -static void -prev_clicked (GtkButton *button, gpointer data) -{ - struct msinfo *msi = data; - - if (msi->page == 3) - gtk_widget_set_sensitive (msi->next, TRUE); - msi->page = pages[msi->page].finish (data, -1); - pages[msi->page].display (data); - if (msi->page == 0) - gtk_widget_set_sensitive (msi->prev, FALSE); -} - -static void -next_clicked (GtkButton *button, gpointer data) -{ - struct msinfo *msi = data; - - if (msi->page == 0) - gtk_widget_set_sensitive (msi->prev, TRUE); - msi->page = pages[msi->page].finish (data, 1); - pages[msi->page].display (data); - if (msi->page == 3) - gtk_widget_set_sensitive (msi->next, FALSE); -} - -static void -cancel_clicked (GtkButton *button, gpointer data) -{ - exit (1); -} - -static void -object_requested(GtkHTML *html, GtkHTMLEmbedded *eb) -{ - GtkWidget *w; - - w = gtk_object_get_data (GTK_OBJECT(html), eb->classid); - gtk_container_add (GTK_CONTAINER(eb), w); - gtk_widget_show_all (GTK_WIDGET(eb)); -} - - - -int -main (int argc, char **argv) -{ - struct msinfo *msi; - GtkWidget *window, *vbox, *frame, *scrolled, *hbbox; - GtkWidget *cancel; - int page; - - gtk_init (&argc, &argv); - gdk_imlib_init (); - gdk_rgb_init (); - gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); - gtk_widget_set_default_visual (gdk_rgb_get_visual ()); - - msi = g_new (struct msinfo, 1); - - /* Build window */ - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (window), - "Mail Source Configuration"); - gtk_window_set_default_size (GTK_WINDOW (window), 600, 400); - - vbox = gtk_vbox_new (FALSE, 5); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 8); - gtk_container_add (GTK_CONTAINER (window), vbox); - - frame = gtk_frame_new (NULL); - gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); - - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_ALWAYS); - gtk_container_add (GTK_CONTAINER (frame), scrolled); - - msi->html = GTK_HTML (gtk_html_new()); - gtk_html_set_editable (msi->html, FALSE); - gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (msi->html)); - gtk_signal_connect (GTK_OBJECT (msi->html), "object_requested", - GTK_SIGNAL_FUNC (object_requested), NULL); - - hbbox= gtk_hbutton_box_new (); - gtk_button_box_set_layout (GTK_BUTTON_BOX (hbbox), - GTK_BUTTONBOX_END); - gtk_box_pack_end (GTK_BOX (vbox), hbbox, FALSE, FALSE, 0); - - msi->prev = gnome_stock_button (GNOME_STOCK_BUTTON_PREV); - msi->next = gnome_stock_button (GNOME_STOCK_BUTTON_NEXT); - cancel = gnome_stock_button (GNOME_STOCK_BUTTON_CANCEL); - - gtk_box_pack_start (GTK_BOX (hbbox), msi->prev, TRUE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (hbbox), msi->next, TRUE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (hbbox), cancel, TRUE, FALSE, 0); - - GTK_WIDGET_SET_FLAGS (msi->prev, GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (msi->next, GTK_CAN_DEFAULT); - GTK_WIDGET_SET_FLAGS (cancel, GTK_CAN_DEFAULT); - gtk_widget_grab_default (msi->next); - - gtk_signal_connect (GTK_OBJECT (msi->prev), "clicked", - prev_clicked, msi); - gtk_signal_connect (GTK_OBJECT (msi->next), "clicked", - next_clicked, msi); - gtk_signal_connect (GTK_OBJECT (cancel), "clicked", - cancel_clicked, NULL); - - msi->page = 0; - msi->get_local_mail = msi->default_local_mail_path = -1; - msi->use_movemail = -1; - msi->get_remote_mail = msi->store_local = -1; - msi->remember_password = msi->copy_local = -1; - msi->local_mail_path = msi->local_store_path = NULL; - msi->remote_provider = msi->remote_auth = -1; - msi->remote_host = msi->remote_user = msi->remote_password = NULL; - - display_intro (msi); - - gtk_widget_show_all (window); - gtk_main (); - exit (0); -} - -#define intro_text \ - "<h1>Evolution Mail Source Wizard</h1>\n" \ - "<p>Welcome to the Evolution Mail Source Wizard. This will " \ - "help you blah blah blah blah blah.</p>" - -static void -display_intro (struct msinfo *msi) -{ - GtkHTMLStreamHandle handle; - - handle = start_html (msi->html); - write_html (msi->html, handle, intro_text); - end_html (msi->html, handle); -} - -static int -finish_intro (struct msinfo *msi, int direction) -{ - return msi->page + direction; -} - -#define local_text_1 \ - "<h1>Local mail source</h1>\n<hr>\n" \ - "<p>First you need to tell Evolution whether or not you " \ - "receive mail locally, and if so, where.</p>\n" \ - "<p>Your default mail file on this system is <b>" - -#define local_text_2 \ - "</b>.</p>\n" - -#define local_text_3_file \ - "<p>That file exists, so you almost certainly want to use it " \ - "as a mail source.</p>\n" - -#define local_text_3_dir \ - "<p>That directory exists, but you currently have no mail " \ - "there. If you aren't sure whether or not you receive mail " \ - "on this machine, it's safest to leave it selected.</p>\n" - -#define local_text_3_none \ - "<p>However, that directory does not exist.</p>\n" - -#define local_text_label_1 \ - "Don't fetch local mail." - -#define local_text_label_2 \ - "Fetch local mail from the default location." - -#define local_text_label_3 \ - "Fetch local mail from an alternate location:" - -void -display_local (struct msinfo *msi) -{ - GtkHTMLStreamHandle handle; - struct stat st; - char *default_user_mail_path; - GtkWidget *radio, *text; - GSList *group = NULL; - - default_user_mail_path = g_strdup_printf ("%s/%s", default_mail_path, - getenv ("USER")); - - handle = start_html (msi->html); - write_html (msi->html, handle, local_text_1); - write_html (msi->html, handle, default_user_mail_path); - write_html (msi->html, handle, local_text_2); - - if (stat (default_mail_path, &st) == 0) { - if (stat (default_user_mail_path, &st) == 0) - write_html (msi->html, handle, local_text_3_file); - else - write_html (msi->html, handle, local_text_3_dir); - if (msi->get_local_mail == -1) - msi->get_local_mail = TRUE; - } else { - write_html (msi->html, handle, local_text_3_none); - if (msi->get_local_mail == -1) - msi->get_local_mail = FALSE; - } - g_free (default_user_mail_path); - - radio = gtk_radio_button_new_with_label (group, local_text_label_1); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - if (!msi->get_local_mail) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_object_set_data (GTK_OBJECT (msi->html), "local:no", radio); - write_html (msi->html, handle, - "<object classid=\"local:no\"></object><br>\n"); - - radio = gtk_radio_button_new_with_label (group, local_text_label_2); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - if (msi->get_local_mail && msi->default_local_mail_path) - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_object_set_data (GTK_OBJECT (msi->html), "local:default", radio); - write_html (msi->html, handle, - "<object classid=\"local:default\"></object><br>\n"); - - radio = gtk_radio_button_new_with_label (group, local_text_label_3); - text = gtk_entry_new (); - if (msi->get_local_mail && !msi->default_local_mail_path) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_entry_set_text (GTK_ENTRY (text), msi->local_mail_path); - } - gtk_object_set_data (GTK_OBJECT (msi->html), "local:alt", radio); - gtk_object_set_data (GTK_OBJECT (msi->html), "local:text", text); - write_html (msi->html, handle, - "<object classid=\"local:alt\"></object> " - "<object classid=\"local:text\"></object>"); - - end_html (msi->html, handle); -} - -static int -finish_local (struct msinfo *msi, int direction) -{ - GtkWidget *radio, *text; - - radio = gtk_object_get_data (GTK_OBJECT (msi->html), "local:no"); - msi->get_local_mail = - !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)); - - g_free (msi->local_mail_path); - if (!msi->get_local_mail) - msi->local_mail_path = NULL; - else { - radio = gtk_object_get_data (GTK_OBJECT (msi->html), - "local:default"); - msi->default_local_mail_path = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio)); - if (msi->default_local_mail_path) - msi->local_mail_path = NULL; - else { - text = gtk_object_get_data (GTK_OBJECT (msi->html), - "local:text"); - msi->local_mail_path = - g_strdup (gtk_entry_get_text (GTK_ENTRY (text))); - } - } - - return msi->page + direction; -} - -#define remote_text_1 \ - "<h1>Remote mail source</h1>\n<hr>\n<p>Now you need to " \ - "configure a remote mail source, if you have one.</p>\n" \ - "<p>Evolution supports the following protocols for reading " \ - "mail from remote servers:</p>" - -#define remote_text_2 \ - "<p>To add a remote mail source, choose a protocol from " \ - "the list below and click \"Next\".</p>" - -#define remote_text_3_must \ - "<p>You have not configured a local mail source, so you " \ - "must configure a remote one.</p>" - -#define remote_label_none \ - "No remote mail source" - -void -display_remote (struct msinfo *msi) -{ - GtkHTMLStreamHandle handle; - char *table, *item, *button, *nolabel; - GtkWidget *widget; - int i; - GSList *group = NULL; - - handle = start_html (msi->html); - write_html (msi->html, handle, remote_text_1); - - /* Write the table of available providers */ - table = "<blockquote><table border=1>\n"; - write_html (msi->html, handle, table); - for (i = 0; i < nproviders; i++) { - table = g_strdup_printf ("<tr><th width=\"15%%\" " - "rowspan=2 valign=top>%s</th>" - "<td>%s</td></tr>\n" - "<tr><td>%s</td>\n", - providers[i].protocol, - providers[i].name, - providers[i].description); - write_html (msi->html, handle, table); - g_free (table); - } - table = "</table></blockquote>\n"; - write_html (msi->html, handle, table); - - write_html (msi->html, handle, remote_text_2); - if (!msi->get_local_mail) - write_html (msi->html, handle, remote_text_3_must); - - /* Write the list of configurable sources */ - write_html (msi->html, handle, "<blockquote>"); - if (msi->get_local_mail) { - widget = gtk_radio_button_new_with_label (NULL, - remote_label_none); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget)); - gtk_object_set_data (GTK_OBJECT (msi->html), "remote:no", - widget); - write_html (msi->html, handle, - "\n<object classid=\"remote:no\"></object><br>"); - } - - for (i = 0; i < nproviders; i++) { - button = g_strdup_printf ("remote:%s", providers[i].protocol); - widget = gtk_radio_button_new_with_label (group, providers[i].protocol); - if (msi->remote_provider == i) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), - TRUE); - } - group = gtk_radio_button_group (GTK_RADIO_BUTTON (widget)); - gtk_object_set_data (GTK_OBJECT (msi->html), button, widget); - g_free (button); - - button = g_strdup_printf ("\n<object classid=\"remote:%s\">" - "</object><br>", - providers[i].protocol); - write_html (msi->html, handle, button); - g_free (button); - } - write_html (msi->html, handle, "</blockquote>"); - - end_html (msi->html, handle); -} - -static int -finish_remote (struct msinfo *msi, int direction) -{ - GtkToggleButton *radio; - char *button; - int i; - - radio = gtk_object_get_data (GTK_OBJECT (msi->html), "remote:no"); - msi->get_remote_mail = !radio || !gtk_toggle_button_get_active (radio); - if (msi->get_remote_mail) { - for (i = 0; i < nproviders; i++) { - button = g_strdup_printf ("remote:%s", - providers[i].protocol); - radio = gtk_object_get_data (GTK_OBJECT (msi->html), - button); - if (gtk_toggle_button_get_active (radio)) - break; - } - - msi->remote_provider = i; - } else if (direction == 1) - direction = 2; /* Skip remconf page. */ - - return msi->page + direction; -} - -#define remconf_text_title \ - "<h1>Configure a remote mail source: %s</h1><hr>" - -#define remconf_text_host_label "Server name:" -#define remconf_text_user_label "Account name:" -#define remconf_text_path_label "Path to mail on server:" -#define remconf_text_auth_label "Authentication method:" - -#define remconf_text_password \ - "<p>If you would like to have Evolution remember the password " \ - "for this account, enter it below. If you would rather be " \ - "prompted for the password when Evolution needs it, choose " \ - "one of the other options.</p>\n" - -#define remconf_text_password_remember "Remember my password" -#define remconf_text_password_confirm "Enter password again for confirmation" -#define remconf_text_password_once \ - "Prompt me for the password once each Evolution session." -#define remconf_text_password_forget \ - "Prompt me for the password every time it is needed." - -static void -resize_password (GtkWidget *html, GtkAllocation *alloc, gpointer data) -{ - GtkWidget *scrolled; - - scrolled = gtk_object_get_data (GTK_OBJECT (html), "remconf:htmlwin"); - gtk_widget_set_usize (scrolled, alloc->width - 20, 300); -} - -static void -frob_password (GtkMenuItem *menuitem, gpointer data) -{ - struct msinfo *msi = data; - GtkHTML *subhtml; - GtkHTMLStreamHandle handle; - GtkWidget *radio, *table, *text, *label; - GSList *group = NULL; - int id; - - id = GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (menuitem), - "id")); - gtk_object_set_data (GTK_OBJECT (msi->html), "remconf:authproto", - GUINT_TO_POINTER (id)); - subhtml = gtk_object_get_data (GTK_OBJECT (msi->html), "remconf:html"); - handle = start_html (subhtml); - if (providers[msi->remote_provider].authpasswd[id]) { - write_html (subhtml, handle, remconf_text_password); - - table = gtk_table_new (2, 2, FALSE); - radio = gtk_radio_button_new_with_label (NULL, remconf_text_password_remember); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_object_set_data (GTK_OBJECT (subhtml), "sub:remember", - radio); - gtk_table_attach (GTK_TABLE (table), radio, 0, 1, 0, 1, - GTK_FILL, GTK_SHRINK, 0, 0); - text = gtk_entry_new (); - gtk_entry_set_visibility (GTK_ENTRY (text), FALSE); - if (msi->remote_password) - gtk_entry_set_text (GTK_ENTRY (text), msi->remote_password); - gtk_object_set_data (GTK_OBJECT (subhtml), "sub:passwd1", - text); - gtk_table_attach (GTK_TABLE (table), text, 1, 2, 0, 1, - GTK_EXPAND, GTK_SHRINK, 0, 0); - label = gtk_label_new (remconf_text_password_confirm); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT); - gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2, - GTK_SHRINK, GTK_SHRINK, 5, 0); - text = gtk_entry_new (); - gtk_entry_set_visibility (GTK_ENTRY (text), FALSE); - if (msi->remote_password) - gtk_entry_set_text (GTK_ENTRY (text), msi->remote_password); - gtk_object_set_data (GTK_OBJECT (subhtml), "sub:passwd2", - text); - gtk_table_attach (GTK_TABLE (table), text, 1, 2, 1, 2, - GTK_EXPAND, GTK_SHRINK, 0, 0); - - gtk_object_set_data (GTK_OBJECT (subhtml), "sub:table", table); - - write_html (subhtml, handle, "<object classid=\"sub:table\">" - "</object>\n"); - - radio = gtk_radio_button_new_with_label (group, remconf_text_password_once); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_object_set_data (GTK_OBJECT (subhtml), "sub:once", - radio); - write_html (subhtml, handle, "<object classid=\"sub:once\">" - "</object>\n"); - - radio = gtk_radio_button_new_with_label (group, remconf_text_password_forget); - group = gtk_radio_button_group (GTK_RADIO_BUTTON (radio)); - gtk_object_set_data (GTK_OBJECT (subhtml), "sub:forget", - radio); - write_html (subhtml, handle, "<object classid=\"sub:forget\">" - "</object>\n"); - } else { - gtk_object_set_data (GTK_OBJECT (subhtml), "sub:remember", NULL); - gtk_object_set_data (GTK_OBJECT (subhtml), "sub:once", NULL); - gtk_object_set_data (GTK_OBJECT (subhtml), "sub:forget", NULL); - } - end_html (subhtml, handle); -} - -void -display_remconf (struct msinfo *msi) -{ - GtkHTMLStreamHandle handle; - char *text; - int prov = msi->remote_provider; - GtkWidget *widget, *menu, *menuitem, *mi1 = NULL; - GtkWidget *scrolled, *subhtml; - - handle = start_html (msi->html); - - text = g_strdup_printf (remconf_text_title, providers[prov].protocol); - write_html (msi->html, handle, text); - g_free (text); - - write_html (msi->html, handle, "<table>\n"); - - if (1) { - write_html (msi->html, handle, "<tr><td>"); - write_html (msi->html, handle, remconf_text_host_label); - widget = gtk_entry_new (); - if (msi->remote_host) { - gtk_entry_set_text (GTK_ENTRY (widget), - msi->remote_host); - } - gtk_object_set_data (GTK_OBJECT (msi->html), "remconf:host", - widget); - write_html (msi->html, handle, "</td><td><object " - "classid=\"remconf:host\"></object></td></tr>"); - } - - if (1) { - write_html (msi->html, handle, "<tr><td>"); - write_html (msi->html, handle, remconf_text_user_label); - widget = gtk_entry_new (); - if (msi->remote_user) { - gtk_entry_set_text (GTK_ENTRY (widget), - msi->remote_user); - } - gtk_object_set_data (GTK_OBJECT (msi->html), "remconf:user", - widget); - write_html (msi->html, handle, "</td><td><object " - "classid=\"remconf:user\"></object></td></tr>"); - } - - if (0) { - write_html (msi->html, handle, "<tr><td>"); - write_html (msi->html, handle, remconf_text_path_label); - widget = gtk_entry_new (); -#if 0 - if (msi->remote_path) { - gtk_entry_set_text (GTK_ENTRY (widget), - msi->remote_path); - } -#endif - gtk_object_set_data (GTK_OBJECT (msi->html), "remconf:path", - widget); - write_html (msi->html, handle, "</td><td><object " - "classid=\"remconf:path\"></object></td></tr>"); - } - - if (1) { - int i; - - write_html (msi->html, handle, "<tr><td>"); - write_html (msi->html, handle, remconf_text_auth_label); - menu = gtk_menu_new (); - for (i = 0; i < 4 && providers[prov].authname[i]; i++) { - menuitem = gtk_menu_item_new_with_label (providers[prov].authname[i]); - gtk_widget_show (menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - GTK_SIGNAL_FUNC (frob_password), - msi); - gtk_object_set_data (GTK_OBJECT (menuitem), "id", - GUINT_TO_POINTER (i)); - if (!mi1) - mi1 = menuitem; - gtk_menu_append (GTK_MENU (menu), menuitem); - } - widget = gtk_option_menu_new (); - gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (widget), - msi->remote_auth ? - msi->remote_auth : 0); - gtk_object_set_data (GTK_OBJECT (msi->html), "remconf:auth", - widget); - write_html (msi->html, handle, "</td><td><object " - "classid=\"remconf:auth\"></object></td></tr>"); - } - write_html (msi->html, handle, "</table>\n"); - - subhtml = gtk_html_new (); - gtk_html_set_editable (GTK_HTML (subhtml), FALSE); - gtk_signal_connect (GTK_OBJECT (subhtml), "object_requested", - GTK_SIGNAL_FUNC (object_requested), NULL); - gtk_object_set_data (GTK_OBJECT (msi->html), "remconf:html", - subhtml); - frob_password (GTK_MENU_ITEM (mi1), msi); - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_NEVER, GTK_POLICY_NEVER); - gtk_container_add (GTK_CONTAINER (scrolled), subhtml); - gtk_object_set_data (GTK_OBJECT (msi->html), "remconf:htmlwin", - scrolled); - write_html (msi->html, handle, "<object classid=\"remconf:htmlwin\">" - "</object>\n"); - write_html (msi->html, handle, "<p>foo</p>"); - - gtk_signal_connect (GTK_OBJECT (msi->html), "size-allocate", - GTK_SIGNAL_FUNC (resize_password), NULL); - - end_html (msi->html, handle); -} - -static int -finish_remconf (struct msinfo *msi, int direction) -{ - GtkEntry *host, *user, *passwd1, *passwd2; - char *data; - GtkWidget *menu, *menuitem; - GtkObject *subhtml; - GtkToggleButton *radio; - - gtk_signal_disconnect_by_func (GTK_OBJECT (msi->html), - GTK_SIGNAL_FUNC (resize_password), - NULL); - - host = gtk_object_get_data (GTK_OBJECT (msi->html), "remconf:host"); - data = gtk_entry_get_text (GTK_ENTRY (host)); - if (data && *data) - msi->remote_host = g_strdup (data); - - user = gtk_object_get_data (GTK_OBJECT (msi->html), "remconf:user"); - data = gtk_entry_get_text (GTK_ENTRY (user)); - if (data && *data) - msi->remote_user = g_strdup (data); - - msi->remote_auth = GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (msi->html), "remconf:authproto")); - - subhtml = gtk_object_get_data (GTK_OBJECT (msi->html), "remconf:html"); - radio = gtk_object_get_data (subhtml, "sub:remember"); - if (radio && gtk_toggle_button_get_active (radio)) { - passwd1 = gtk_object_get_data (subhtml, "sub:passwd1"); - passwd2 = gtk_object_get_data (subhtml, "sub:passwd2"); - - /* XXX compare */ - data = gtk_entry_get_text (GTK_ENTRY (passwd1)); - printf ("%s\n", data); - if (data && *data) { - msi->remote_password = g_strdup (data); - msi->remember_password = TRUE; - } - } else { - radio = gtk_object_get_data (subhtml, "sub:once"); - msi->remember_password = gtk_toggle_button_get_active (radio); - } - - return msi->page + direction; -} diff --git a/mail/mail-types.h b/mail/mail-types.h deleted file mode 100644 index c5b690563d..0000000000 --- a/mail/mail-types.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Copyright 2000 Helix Code, Inc. (http://www.helixcode.com) - * - * 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 the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef MAIL_TYPES_H -#define MAIL_TYPES_H 1 - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus }*/ - - -typedef struct _FolderBrowser FolderBrowser; -typedef struct _MessageList MessageList; -typedef struct _MailDisplay MailDisplay; - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* MAIL_TYPES_H */ diff --git a/mail/main.c b/mail/main.c deleted file mode 100644 index 953f424a79..0000000000 --- a/mail/main.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * mail-component.c: The core of the mail component - * - * Author: - * Miguel de Icaza (miguel@helixcode.com) - * - * (C) 2000 Helix Code, Inc. - */ -#include <config.h> -#include <gnome.h> -#include <libgnorba/gnorba.h> -#include <bonobo/bonobo-main.h> -#include <glade/glade.h> -#include "e-util/e-gui-utils.h" -#include "e-util/e-cursors.h" -#include "main.h" -#include "session.h" - -CORBA_ORB orb; - -static void -init_bonobo (int argc, char **argv) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - gnome_CORBA_init_with_popt_table ( - "evolution-mail-component", "1.0", - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE){ - e_notice (NULL, GNOME_MESSAGE_BOX_ERROR, - _("Mail Component: I could not initialize Bonobo")); - exit (1); - } - - CORBA_exception_free (&ev); -} - -int -main (int argc, char *argv []) -{ - bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR); - textdomain (PACKAGE); - - init_bonobo (argc, argv); - glade_gnome_init (); - - session_init (); - e_cursors_init (); - - folder_browser_factory_init (); - - bonobo_main (); - - return 0; -} - - - - diff --git a/mail/main.h b/mail/main.h deleted file mode 100644 index 2cb17b5e10..0000000000 --- a/mail/main.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _MAIL_MAIN_H_ -#define _MAIL_MAIN_H_ - -void folder_browser_factory_init (void); - -#endif /* _MAIL_MAIN_H_ */ diff --git a/mail/message-list.c b/mail/message-list.c deleted file mode 100644 index f4988df486..0000000000 --- a/mail/message-list.c +++ /dev/null @@ -1,752 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * message-list.c: Displays the messages. - * Implements CORBA's Evolution::MessageList - * - * Author: - * Miguel de Icaza (miguel@helixcode.com) - * Bertrand Guiheneuf (bg@aful.org) - * - * (C) 2000 Helix Code, Inc. - */ -#include <config.h> -#include <gnome.h> -#include <bonobo/bonobo-main.h> -#include "e-util/e-util.h" -#include "camel/camel-exception.h" -#include <camel/camel-folder.h> -#include "message-list.h" -#include "Mail.h" -#include "widgets/e-table/e-table-header-item.h" -#include "widgets/e-table/e-table-item.h" - -#include "pixmaps.h" - -/* - * Default sizes for the ETable display - * - */ -#define N_CHARS(x) (CHAR_WIDTH * (x)) - -#define COL_ICON_WIDTH 16 -#define COL_CHECK_BOX_WIDTH 16 -#define COL_FROM_WIDTH N_CHARS(24) -#define COL_FROM_WIDTH_MIN 32 -#define COL_SUBJECT_WIDTH N_CHARS(30) -#define COL_SUBJECT_WIDTH_MIN 32 -#define COL_SENT_WIDTH N_CHARS(4) -#define COL_SENT_WIDTH_MIN 1 -#define COL_RECEIVE_WIDTH N_CHARS(20) -#define COL_RECEIVE_WIDTH_MIN 32 -#define COL_TO_WIDTH N_CHARS(24) -#define COL_TO_WIDTH_MIN 32 -#define COL_SIZE_WIDTH N_CHARS(6) -#define COL_SIZE_WIDTH_MIN 32 - -#define PARENT_TYPE (bonobo_object_get_type ()) - -static BonoboObjectClass *message_list_parent_class; -static POA_Evolution_MessageList__vepv evolution_message_list_vepv; - -static void -on_row_selection_cmd (ETable *table, - int row, - gboolean selected, - gpointer user_data); - - - -/* select a message and display it */ -static void -select_msg (MessageList *message_list, gint row) -{ - CamelException ex; - CamelMimeMessage *message = NULL; - - camel_exception_init (&ex); - - if (camel_folder_has_uid_capability (message_list->folder)) { - GPtrArray *msg_info_array; - CamelMessageInfo *msg_info; - - msg_info_array = camel_folder_summary_get_message_info - (message_list->folder, row, 1); - - if (msg_info_array) { - msg_info = msg_info_array->pdata[0]; - - message = camel_folder_get_message_by_uid (message_list->folder, - msg_info->uid, - &ex); - if (camel_exception_get_id (&ex)) { - printf ("Unable to get message: %s\n", - ex.desc?ex.desc:"unknown_reason"); - return; - } - } - - g_ptr_array_free (msg_info_array, TRUE); - - if (message) - mail_display_set_message (message_list->parent_folder_browser->mail_display, - CAMEL_MEDIUM (message)); - } - -} - -/* - * SimpleTableModel::col_count - */ -static int -ml_col_count (ETableModel *etm, void *data) -{ - return COL_LAST; -} - -/* - * SimpleTableModel::row_count - */ -static int -ml_row_count (ETableModel *etm, void *data) -{ - MessageList *message_list = data; - CamelException ex; - int v; - - if (!message_list->folder) { - return 0; - } - - camel_exception_init (&ex); - - v = camel_folder_get_message_count (message_list->folder, &ex); - if (camel_exception_get_id (&ex)) - v = 0; - - /* in the case where no message is available, return 1 - * however, cause we want to be able to show a text */ - return (v ? v:1); - -} - -static void * -ml_value_at (ETableModel *etm, int col, int row, void *data) -{ - static char buffer [10]; - MessageList *message_list = data; - CamelFolder *folder; - GPtrArray *msg_info_array = NULL; - CamelMessageInfo *msg_info; - CamelException ex; - void *retval = NULL; - - camel_exception_init (&ex); - - folder = message_list->folder; - if (!folder) - goto nothing_to_see; - - - /* retrieve the message information array */ - msg_info_array = camel_folder_summary_get_message_info (folder, row, 1); - - /* - * in the case where it is zero message long - * display nothing - */ - if (msg_info_array->len == 0) - goto nothing_to_see; - - msg_info = msg_info_array->pdata[0]; - - - switch (col){ - case COL_ONLINE_STATUS: - retval = GINT_TO_POINTER (0); - break; - - case COL_MESSAGE_STATUS: - retval = GINT_TO_POINTER (1); - break; - - case COL_PRIORITY: - retval = GINT_TO_POINTER (1); - break; - - case COL_ATTACHMENT: - retval = GINT_TO_POINTER (0); - break; - - case COL_FROM: - if (msg_info->from) - retval = msg_info->from; - else - retval = ""; - break; - - case COL_SUBJECT: - if (msg_info->subject) - retval = msg_info->subject; - else - retval = ""; - break; - - case COL_SENT: - retval = "sent"; - break; - - case COL_RECEIVE: - retval = "receive"; - break; - - case COL_TO: - retval = "dudes@server"; - break; - - case COL_SIZE: - if (msg_info->content) { - sprintf (buffer, "%d", msg_info->content->size); - } else { - sprintf (buffer, "0"); - } - retval = buffer; - break; - - default: - g_assert_not_reached (); - } - - g_ptr_array_free (msg_info_array, TRUE); - return retval; - - - nothing_to_see: - /* - * in the case there is nothing to look at, - * notify the user. - */ - if (msg_info_array) - g_ptr_array_free (msg_info_array, TRUE); - if (col == COL_SUBJECT) - return "No item in this view"; - else - return NULL; -} - -static void -ml_set_value_at (ETableModel *etm, int col, int row, const void *value, void *data) -{ -} - -static gboolean -ml_is_cell_editable (ETableModel *etm, int col, int row, void *data) -{ - return FALSE; -} - -static void * -ml_duplicate_value (ETableModel *etm, int col, const void *value, void *data) -{ - switch (col){ - case COL_ONLINE_STATUS: - case COL_MESSAGE_STATUS: - case COL_PRIORITY: - case COL_ATTACHMENT: - return (void *) value; - - case COL_FROM: - case COL_SUBJECT: - case COL_SENT: - case COL_RECEIVE: - case COL_TO: - case COL_SIZE: - return g_strdup (value); - default: - g_assert_not_reached (); - } - return NULL; -} - -static void -ml_free_value (ETableModel *etm, int col, void *value, void *data) -{ - switch (col){ - case COL_ONLINE_STATUS: - case COL_MESSAGE_STATUS: - case COL_PRIORITY: - case COL_ATTACHMENT: - break; - - case COL_FROM: - case COL_SUBJECT: - case COL_SENT: - case COL_RECEIVE: - case COL_TO: - case COL_SIZE: - g_free (value); - break; - default: - g_assert_not_reached (); - } -} - -static void -ml_thaw (ETableModel *etm, void *data) -{ - e_table_model_changed (etm); -} - -static struct { - char **image_base; - GdkPixbuf *pixbuf; -} states_pixmaps [] = { - { envelope_opened_xpm, NULL }, - { envelope_closed_xpm, NULL }, - { empty_xpm, NULL }, - { attachment_xpm, NULL }, - { attachment_header_xpm, NULL }, - { online_status_xpm, NULL }, - { message_status_xpm, NULL }, - { NULL, NULL }, -}; - -static void -message_list_init_images (void) -{ - int i; - - /* - * Only load once, and share - */ - if (states_pixmaps [0].pixbuf) - return; - - for (i = 0; states_pixmaps [i].image_base; i++){ - states_pixmaps [i].pixbuf = gdk_pixbuf_new_from_xpm_data ( - (const char **) states_pixmaps [i].image_base); - } -} - -static void -message_list_init_renderers (MessageList *message_list) -{ - g_assert (message_list); - g_assert (message_list->table_model); - - message_list->render_text = e_cell_text_new ( - message_list->table_model, - NULL, GTK_JUSTIFY_LEFT); - - message_list->render_online_status = e_cell_checkbox_new (); - - /* - * Message status - */ - { - GdkPixbuf *images [2]; - - images [0] = states_pixmaps [0].pixbuf; - images [1] = states_pixmaps [1].pixbuf; - - message_list->render_message_status = e_cell_toggle_new (0, 2, images); - } - - /* - * Attachment - */ - { - GdkPixbuf *images [2]; - - images [0] = states_pixmaps [2].pixbuf; - images [1] = states_pixmaps [3].pixbuf; - - message_list->render_attachment = e_cell_toggle_new (0, 2, images); - } - - /* - * FIXME: We need a real renderer here - */ - message_list->render_priority = e_cell_checkbox_new (); -} - -#define CHAR_WIDTH 10 -static void -message_list_init_header (MessageList *message_list) -{ - int i; - - /* - * FIXME: - * - * Use the font metric to compute this. - */ - - message_list->header_model = e_table_header_new (); - gtk_object_ref (GTK_OBJECT (message_list->header_model)); - gtk_object_sink (GTK_OBJECT (message_list->header_model)); - - message_list->table_cols [COL_ONLINE_STATUS] = - e_table_col_new_with_pixbuf ( - COL_ONLINE_STATUS, states_pixmaps [5].pixbuf, - COL_CHECK_BOX_WIDTH, COL_CHECK_BOX_WIDTH, - message_list->render_online_status, - g_int_compare, FALSE); - - message_list->table_cols [COL_MESSAGE_STATUS] = - e_table_col_new_with_pixbuf ( - COL_MESSAGE_STATUS, states_pixmaps [0].pixbuf, - COL_CHECK_BOX_WIDTH, COL_CHECK_BOX_WIDTH, - message_list->render_message_status, - g_int_compare, FALSE); - - message_list->table_cols [COL_PRIORITY] = - e_table_col_new ( - COL_PRIORITY, _("Priority"), - COL_CHECK_BOX_WIDTH, COL_CHECK_BOX_WIDTH, - message_list->render_priority, - g_int_compare, FALSE); - - message_list->table_cols [COL_ATTACHMENT] = - e_table_col_new_with_pixbuf ( - COL_ATTACHMENT, states_pixmaps [4].pixbuf, - COL_ICON_WIDTH, COL_ICON_WIDTH, - message_list->render_attachment, - g_int_compare, FALSE); - - message_list->table_cols [COL_FROM] = - e_table_col_new ( - COL_FROM, _("From"), - COL_FROM_WIDTH, COL_FROM_WIDTH_MIN, - message_list->render_text, - g_str_compare, TRUE); - - message_list->table_cols [COL_SUBJECT] = - e_table_col_new ( - COL_SUBJECT, _("Subject"), - COL_SUBJECT_WIDTH, COL_SUBJECT_WIDTH_MIN, - message_list->render_text, - g_str_compare, TRUE); - - message_list->table_cols [COL_SENT] = - e_table_col_new ( - COL_SENT, _("Sent"), - COL_SENT_WIDTH, COL_SENT_WIDTH_MIN, - message_list->render_text, - g_str_compare, TRUE); - - message_list->table_cols [COL_RECEIVE] = - e_table_col_new ( - COL_RECEIVE, _("Receive"), - COL_RECEIVE_WIDTH, COL_RECEIVE_WIDTH_MIN, - message_list->render_text, - g_str_compare, TRUE); - - message_list->table_cols [COL_TO] = - e_table_col_new ( - COL_TO, _("To"), - COL_TO_WIDTH, COL_TO_WIDTH_MIN, - message_list->render_text, - g_str_compare, TRUE); - - message_list->table_cols [COL_SIZE] = - e_table_col_new ( - COL_SIZE, _("Size"), - COL_SIZE_WIDTH, COL_SIZE_WIDTH_MIN, - message_list->render_text, - g_str_compare, TRUE); - - /* - * Dummy init: It setups the headers to match the order in which - * they are defined. In the future e-table widget will take care - * of this. - */ - for (i = 0; i < COL_LAST; i++) { - gtk_object_ref (GTK_OBJECT (message_list->table_cols [i])); - e_table_header_add_column (message_list->header_model, - message_list->table_cols [i], i); - } -} - -static char * -message_list_get_layout (MessageList *message_list) -{ - if (0) - return g_strdup ("<ETableSpecification> <columns-shown> <column> 0 </column> <column> 1 </column> <column> 2 </column> <column> 3 </column> <column> 4 </column> <column> 5 </column> <column> 6 </column> <column> 7 </column> <column> 8 </column> <column> 9 </column> </columns-shown> <grouping> <group column=\"4\" ascending=\"1\"> <leaf column=\"5\" ascending=\"1\"/> </group> </grouping> </ETableSpecification>"); - else { - /* Message status, From, Sent, Subject */ - return g_strdup ("<ETableSpecification> <columns-shown> <column> 1 </column> <column> 4 </column> <column> 5 </column> </columns-shown> <grouping> </grouping> </ETableSpecification>"); - } -} - -/* - * GtkObject::init - */ -static void -message_list_init (GtkObject *object) -{ - MessageList *message_list = MESSAGE_LIST (object); - char *spec; - - message_list->table_model = e_table_simple_new ( - ml_col_count, ml_row_count, ml_value_at, - ml_set_value_at, ml_is_cell_editable, ml_duplicate_value, ml_free_value, - ml_thaw, message_list); - - message_list_init_renderers (message_list); - message_list_init_header (message_list); - - /* - * The etable - */ - - spec = message_list_get_layout (message_list); - message_list->etable = e_table_new ( - message_list->header_model, message_list->table_model, spec); - g_free (spec); - - gtk_signal_connect (GTK_OBJECT (message_list->etable), "row_selection", - GTK_SIGNAL_FUNC (on_row_selection_cmd), message_list); - - gtk_widget_show (message_list->etable); - - gtk_object_ref (GTK_OBJECT (message_list->table_model)); - gtk_object_sink (GTK_OBJECT (message_list->table_model)); - - /* - * We do own the Etable, not some widget container - */ - gtk_object_ref (GTK_OBJECT (message_list->etable)); - gtk_object_sink (GTK_OBJECT (message_list->etable)); -} - -static void -message_list_destroy (GtkObject *object) -{ - MessageList *message_list = MESSAGE_LIST (object); - int i; - - - gtk_object_unref (GTK_OBJECT (message_list->table_model)); - gtk_object_unref (GTK_OBJECT (message_list->header_model)); - - /* - * Renderers - */ - gtk_object_unref (GTK_OBJECT (message_list->render_text)); - gtk_object_unref (GTK_OBJECT (message_list->render_online_status)); - gtk_object_unref (GTK_OBJECT (message_list->render_message_status)); - gtk_object_unref (GTK_OBJECT (message_list->render_priority)); - gtk_object_unref (GTK_OBJECT (message_list->render_attachment)); - - gtk_object_unref (GTK_OBJECT (message_list->etable)); - - for (i = 0; i < COL_LAST; i++) - gtk_object_unref (GTK_OBJECT (message_list->table_cols [i])); - - GTK_OBJECT_CLASS (message_list_parent_class)->destroy (object); -} - -/* - * CORBA method: Evolution::MessageList::select_message - */ -static void -MessageList_select_message (PortableServer_Servant _servant, - const CORBA_long message_number, - CORBA_Environment *ev) -{ - printf ("FIXME: select message method\n"); -} - -/* - * CORBA method: Evolution::MessageList::open_message - */ -static void -MessageList_open_message (PortableServer_Servant _servant, - const CORBA_long message_number, - CORBA_Environment *ev) -{ - printf ("FIXME: open message method\n"); -} - -static POA_Evolution_MessageList__epv * -evolution_message_list_get_epv (void) -{ - POA_Evolution_MessageList__epv *epv; - - epv = g_new0 (POA_Evolution_MessageList__epv, 1); - - epv->select_message = MessageList_select_message; - epv->open_message = MessageList_open_message; - - return epv; -} - -static void -message_list_corba_class_init (void) -{ - evolution_message_list_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - evolution_message_list_vepv.Evolution_MessageList_epv = evolution_message_list_get_epv (); -} - -/* - * GtkObjectClass::init - */ -static void -message_list_class_init (GtkObjectClass *object_class) -{ - message_list_parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = message_list_destroy; - - message_list_corba_class_init (); - - message_list_init_images (); -} - -static void -message_list_construct (MessageList *message_list, Evolution_MessageList corba_message_list) -{ - bonobo_object_construct (BONOBO_OBJECT (message_list), corba_message_list); -} - -static Evolution_MessageList -create_corba_message_list (BonoboObject *object) -{ - POA_Evolution_MessageList *servant; - CORBA_Environment ev; - - servant = (POA_Evolution_MessageList *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &evolution_message_list_vepv; - - CORBA_exception_init (&ev); - POA_Evolution_MessageList__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION){ - g_free (servant); - CORBA_exception_free (&ev); - return CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&ev); - return (Evolution_MessageList) bonobo_object_activate_servant (object, servant); -} - -BonoboObject * -message_list_new (FolderBrowser *parent_folder_browser) -{ - Evolution_MessageList corba_object; - MessageList *message_list; - - g_assert (parent_folder_browser); - - message_list = gtk_type_new (message_list_get_type ()); - - corba_object = create_corba_message_list (BONOBO_OBJECT (message_list)); - if (corba_object == CORBA_OBJECT_NIL){ - gtk_object_destroy (GTK_OBJECT (message_list)); - return NULL; - } - - message_list->parent_folder_browser = parent_folder_browser; - - message_list->idle_id = 0; - - message_list_construct (message_list, corba_object); - - return BONOBO_OBJECT (message_list); -} - -void -message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder) -{ - CamelException ex; - gboolean folder_exists; - - g_return_if_fail (message_list != NULL); - g_return_if_fail (camel_folder != NULL); - g_return_if_fail (IS_MESSAGE_LIST (message_list)); - g_return_if_fail (CAMEL_IS_FOLDER (camel_folder)); - g_return_if_fail (camel_folder_has_summary_capability (camel_folder)); - - - camel_exception_init (&ex); - - if (message_list->folder) - gtk_object_unref (GTK_OBJECT (message_list->folder)); - - message_list->folder = camel_folder; - - folder_exists = camel_folder_exists (camel_folder, NULL); - - if (camel_exception_get_id (&ex)) { - printf ("Unable to test for folder existence: %s\n", - ex.desc?ex.desc:"unknown reason"); - return; - } - - if (!folder_exists) { - g_warning ("Folder does not exist, creating it\n"); - /* - if you don't want the directory to be created - automatically here remove this. - */ - camel_folder_create (camel_folder, &ex); - if (camel_exception_get_id (&ex)) { - printf ("Unable to create folder: %s\n", - ex.desc?ex.desc:"unknown_reason"); - return; - } - - } - - - camel_folder_open (camel_folder, FOLDER_OPEN_RW, &ex); - if (camel_exception_get_id (&ex)) { - printf ("Unable to open folder: %s\n", - ex.desc?ex.desc:"unknown_reason"); - return; - } - - gtk_object_ref (GTK_OBJECT (camel_folder)); - - e_table_model_changed (message_list->table_model); - - select_msg (message_list, 0); -} - -GtkWidget * -message_list_get_widget (MessageList *message_list) -{ - return message_list->etable; -} - -E_MAKE_TYPE (message_list, "MessageList", MessageList, message_list_class_init, message_list_init, PARENT_TYPE); - -static gboolean -on_row_selection_idle (gpointer data) -{ - MessageList *message_list = data; - - select_msg (message_list, message_list->row_to_select); - - message_list->idle_id = 0; - return FALSE; -} - -static void -on_row_selection_cmd (ETable *table, - int row, - gboolean selected, - gpointer user_data) -{ - if (selected) { - MessageList *message_list; - - message_list = MESSAGE_LIST (user_data); - - message_list->row_to_select = row; - - if (!message_list->idle_id) - g_idle_add_full (G_PRIORITY_LOW, on_row_selection_idle, message_list, NULL); - } -} - diff --git a/mail/message-list.h b/mail/message-list.h deleted file mode 100644 index d751b784a2..0000000000 --- a/mail/message-list.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _MESSAGE_LIST_H_ -#define _MESSAGE_LIST_H_ - -#include "mail-types.h" -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-object.h> -#include "camel/camel-folder.h" -#include "e-table/e-table.h" -#include "e-table/e-table-simple.h" -#include "e-table/e-cell-text.h" -#include "e-table/e-cell-toggle.h" -#include "e-table/e-cell-checkbox.h" -#include "folder-browser.h" - - -#define MESSAGE_LIST_TYPE (message_list_get_type ()) -#define MESSAGE_LIST(o) (GTK_CHECK_CAST ((o), MESSAGE_LIST_TYPE, MessageList)) -#define MESSAGE_LIST_CLASS(k) (GTK_CHECK_CLASS_CAST((k), MESSAGE_LIST_TYPE, MessageListClass)) -#define IS_MESSAGE_LIST(o) (GTK_CHECK_TYPE ((o), MESSAGE_LIST_TYPE)) -#define IS_MESSAGE_LIST_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), MESSAGE_LIST_TYPE)) - -typedef struct _Renderer Renderer; - - -enum { - COL_ONLINE_STATUS, - COL_MESSAGE_STATUS, - COL_PRIORITY, - COL_ATTACHMENT, - COL_FROM, - COL_SUBJECT, - COL_SENT, - COL_RECEIVE, - COL_TO, - COL_SIZE, - - COL_LAST -}; - -struct _MessageList { - BonoboObject parent; - - /* the folder browser that contains the - * this message list */ - FolderBrowser *parent_folder_browser; - - ETableModel *table_model; - ETableHeader *header_model; - ETableCol *table_cols [COL_LAST]; - - ECell *render_text; - ECell *render_online_status; - ECell *render_message_status; - ECell *render_priority; - ECell *render_attachment; - - GtkWidget *etable; - - CamelFolder *folder; - - /* used by the idle-call to select a row */ - int row_to_select; - guint idle_id; -} ; - -typedef struct { - BonoboObjectClass parent_class; -} MessageListClass; - -GtkType message_list_get_type (void); -BonoboObject *message_list_new (FolderBrowser *parent_folder_browser); -void message_list_set_folder (MessageList *message_list, - CamelFolder *camel_folder); -GtkWidget *message_list_get_widget (MessageList *message_list); - -#endif /* _MESSAGE_LIST_H_ */ diff --git a/mail/pixmaps.h b/mail/pixmaps.h deleted file mode 100644 index f41e3e0086..0000000000 --- a/mail/pixmaps.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef EVOLUTION_PIXMAPS_H -#define EVOLUTION_PIXMAPS_H - -#include "pixmaps/envelope-opened.xpm" -#include "pixmaps/envelope-closed.xpm" -#include "pixmaps/empty.xpm" -#include "pixmaps/attachment.xpm" -#include "pixmaps/attachment-header.xpm" -#include "pixmaps/online-status.xpm" -#include "pixmaps/message-status.xpm" - -#endif /* EVOLUTION_PIXMAPS_H */ - diff --git a/mail/pixmaps/attachment-header.xpm b/mail/pixmaps/attachment-header.xpm deleted file mode 100644 index d3b0f96301..0000000000 --- a/mail/pixmaps/attachment-header.xpm +++ /dev/null @@ -1,22 +0,0 @@ -/* XPM */ -static char * attachment_header_xpm[] = { -"16 16 3 1", -" c None", -". c #000000", -"+ c #FFFFFF", -" ", -" ", -" ", -" .. ", -" + .. ..... ", -" .. .. . ", -" . .. . ", -" .. . .. ", -" . . . ", -" .. . ", -" . .. ", -" . .. ", -" ....... ", -" ", -" ", -" "}; diff --git a/mail/pixmaps/attachment.xpm b/mail/pixmaps/attachment.xpm deleted file mode 100644 index f154cceb18..0000000000 --- a/mail/pixmaps/attachment.xpm +++ /dev/null @@ -1,21 +0,0 @@ -/* XPM */ -static char * attachment_xpm[] = { -"16 16 2 1", -" c None", -". c #000000", -" ", -" .. ", -" . . . ", -" . . .. ", -" . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . . ", -" . . ", -" . . ", -" .. .. ", -" .. .. ", -" .. ", -" ", -" "}; diff --git a/mail/pixmaps/empty.xpm b/mail/pixmaps/empty.xpm deleted file mode 100644 index 93b02c0164..0000000000 --- a/mail/pixmaps/empty.xpm +++ /dev/null @@ -1,21 +0,0 @@ -/* XPM */ -static char * empty_xpm[] = { -"16 16 2 1", -" c None", -". c #FFFFFF", -"................", -"................", -"................", -"................", -"................", -"................", -"................", -"................", -"................", -"................", -"................", -"................", -"................", -"................", -"................", -"................"}; diff --git a/mail/pixmaps/envelope-closed.xpm b/mail/pixmaps/envelope-closed.xpm deleted file mode 100644 index 060b659c78..0000000000 --- a/mail/pixmaps/envelope-closed.xpm +++ /dev/null @@ -1,65 +0,0 @@ -/* XPM */ -static char * envelope_closed_xpm[] = { -"16 16 46 1", -" c None", -". c #000000", -"+ c #837D71", -"@ c #FFFFFF", -"# c #4E4B42", -"$ c #767165", -"% c #FFFEFE", -"& c #FFF4DB", -"* c #FFFEFD", -"= c #F4E9D1", -"- c #625D54", -"; c #D0C7B2", -"> c #767166", -", c #FFFDFA", -"' c #F2E7CF", -") c #666257", -"! c #C8BFAB", -"~ c #736D63", -"{ c #FFFEFC", -"] c #F6EBD3", -"^ c #EEE3CC", -"/ c #FAEFD6", -"( c #918A7C", -"_ c #7E786B", -": c #E0D6C0", -"< c #C7BEAA", -"[ c #FDF2D9", -"} c #8A8476", -"| c #746F63", -"1 c #CEC4B0", -"2 c #8C8678", -"3 c #F9EED5", -"4 c #F1E6CE", -"5 c #F7ECD3", -"6 c #EFE4CD", -"7 c #D1C7B2", -"8 c #555149", -"9 c #CDC4B0", -"0 c #666258", -"a c #C1B8A5", -"b c #C2B9A6", -"c c #C0B7A4", -"d c #C3BAA7", -"e c #C4BBA8", -"f c #CAC1AD", -"g c #4E4B43", -" ", -" ", -" ", -" ", -" ", -" ........... ", -" .+@@@@@@@@@#. ", -" .@$%&@&*&=-;. ", -" .@&>%&,&')'!. ", -" .@&&~{&])&^!. ", -" .@&/()@)_=:<. ", -" .@[}&&)]]|1<. ", -" .@2&^3456789. ", -" .0abbbcddefg. ", -" ........... ", -" "}; diff --git a/mail/pixmaps/envelope-opened.xpm b/mail/pixmaps/envelope-opened.xpm deleted file mode 100644 index 40de0d743d..0000000000 --- a/mail/pixmaps/envelope-opened.xpm +++ /dev/null @@ -1,74 +0,0 @@ -/* XPM */ -static char * envelope_opened_xpm[] = { -"16 16 55 1", -" c None", -". c #000000", -"+ c #F4EDDD", -"@ c #F1EBDB", -"# c #F1EAD8", -"$ c #EAE3CB", -"% c #F4EAD5", -"& c #F1E6CF", -"* c #DDD4BE", -"= c #ECE3CD", -"- c #D3CAB6", -"; c #C1C1C1", -"> c #BDBDBD", -", c #BFBFBF", -"' c #12110F", -") c #FFFFFF", -"! c #514D45", -"~ c #767165", -"{ c #D0C7B2", -"] c #FFF4DB", -"^ c #625D54", -"/ c #565249", -"( c #F2E7CF", -"_ c #C8BFAB", -": c #3B3732", -"< c #837D71", -"[ c #807A6D", -"} c #45423B", -"| c #EEE3CC", -"1 c #FBF0D7", -"2 c #918A7C", -"3 c #7E786B", -"4 c #F4E9D1", -"5 c #E0D6C0", -"6 c #C7BEAA", -"7 c #FDF2D9", -"8 c #6A665B", -"9 c #F6EBD3", -"0 c #656157", -"a c #CEC4B0", -"b c #6D675D", -"c c #F9EED5", -"d c #F1E6CE", -"e c #F7ECD3", -"f c #EFE4CD", -"g c #D1C7B2", -"h c #CDC4B0", -"i c #080707", -"j c #C1B8A5", -"k c #C2B9A6", -"l c #C0B7A4", -"m c #C3BAA7", -"n c #C4BBA8", -"o c #CAC1AD", -"p c #1E1D1A", -" ", -" ", -" ..... ", -" .+@##$. ", -" .%&&&&&*. ", -" .=&&&&&&&-. ", -" ..;>>>>>>>,'. ", -" .)!)))))))~{. ", -" .)]^)))))/(_. ", -" .)]]:<<[}]|_. ", -" .)]12]]]3456. ", -" .)78]]]990a6. ", -" .)b]|cdefg0h. ", -" .ijkkklmmnop. ", -" ........... ", -" "}; diff --git a/mail/pixmaps/message-status.xpm b/mail/pixmaps/message-status.xpm deleted file mode 100644 index a0c4414f3f..0000000000 --- a/mail/pixmaps/message-status.xpm +++ /dev/null @@ -1,22 +0,0 @@ -/* XPM */ -static char * message_status_xpm[] = { -"16 16 3 1", -" c None", -". c #09B0F2", -"+ c #33A8D6", -" ", -" .. ", -" .. ", -" ++++ ", -" ++++ ", -" ++++ ", -" +++++++++++ ", -"..+++++..++++.. ", -"..+++++..++++.. ", -" +++++++++++ ", -" ++++ ", -" ++++ ", -" ++++ ", -" .. ", -" .. ", -" "}; diff --git a/mail/pixmaps/online-status.xpm b/mail/pixmaps/online-status.xpm deleted file mode 100644 index 88009ea480..0000000000 --- a/mail/pixmaps/online-status.xpm +++ /dev/null @@ -1,23 +0,0 @@ -/* XPM */ -static char * online_status_xpm[] = { -"16 16 4 1", -" c None", -". c #000000", -"+ c #9B9B9B", -"@ c #5CE537", -" ", -" . ", -" . ", -" . ", -" . +........+ ", -" . .++++++++. ", -" .. .++++++@+. ", -" ...++++++++. ", -" .. .++++++++. ", -" . .++++++++. ", -" . +........+ ", -" . ", -" . ", -" . ", -" . ", -" "}; diff --git a/mail/session.c b/mail/session.c deleted file mode 100644 index 1005d9cd4e..0000000000 --- a/mail/session.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * session.c: handles the session infomration and resource manipulation - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 2000 Helix Code, Inc. http://www.helixcode.com - */ -#include <config.h> -#include <gnome.h> -#include "session.h" -#include "e-util/e-setup.h" -#include "camel/camel.h" - -SessionStore *default_session; - -static void -request_callback (gchar *string, gpointer data) -{ - char **ans = data; - - if (string) - *ans = g_strdup(string); - else - *ans = NULL; -} - -static char * -evolution_auth_callback (char *prompt, gboolean secret, - CamelService *service, char *item, - CamelException *ex) -{ - GtkWidget *dialog; - char *ans; - - /* XXX look up stored passwords */ - - /* XXX parent window? */ - dialog = gnome_request_dialog (secret, prompt, NULL, 0, - request_callback, &ans, NULL); - if (!dialog) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, - "Could not create dialog box."); - return NULL; - } - if (gnome_dialog_run_and_close (GNOME_DIALOG (dialog)) == -1 || - ans == NULL) { - camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, - "User cancelled query."); - return NULL; - } - - return ans; -} - -static void -session_providers_init (void) -{ - camel_provider_register_as_module (CAMEL_PROVIDERDIR "/libcamelmbox.so"); -} - -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 (); - session_providers_init (); - - init_default_session (); -} - - diff --git a/mail/session.h b/mail/session.h deleted file mode 100644 index 8b870f0383..0000000000 --- a/mail/session.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef EVOLUTION_MAIL_SESSION_H -#define EVOLUTION_MAIL_SESSION_H - -#include <camel/camel-store.h> -#include <camel/camel-session.h> -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; - -#endif /* EVOLUTION_MAIL_SESSION_H */ diff --git a/mail/test-mail.c b/mail/test-mail.c deleted file mode 100644 index 94102da1d3..0000000000 --- a/mail/test-mail.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Tests the mail summary display bonobo component - * - * Author: - * Miguel de Icaza (miguel@kernel.org) - * - * (C) 2000 Helix Code, Inc. - */ -#include <gnome.h> -#include <bonobo.h> -#include <libgnorba/gnorba.h> - -static guint -create_container (void) -{ - GtkWidget *window, *control; - BonoboUIHandler *uih; - - gdk_rgb_init (); - - gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); - gtk_widget_set_default_visual (gdk_rgb_get_visual ()); - - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_widget_set_usize (GTK_WIDGET (window), 640, 480); - gtk_widget_show (GTK_WIDGET (window)); - - uih = bonobo_ui_handler_new (); - control = bonobo_widget_new_control ("control:evolution-mail", - bonobo_object_corba_objref (BONOBO_OBJECT (uih))); - - - if (control == NULL){ - printf ("Could not launch mail control\n"); - exit (1); - } - gtk_container_add (GTK_CONTAINER (window), control); - - gtk_widget_show (window); - gtk_widget_show (control); - - - return FALSE; -} - -int -main (int argc, char *argv []) -{ - CORBA_Environment ev; - CORBA_ORB orb; - - CORBA_exception_init (&ev); - - gnome_CORBA_init ("sample-control-container", "1.0", &argc, argv, 0, &ev); - - CORBA_exception_free (&ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error ("Could not initialize Bonobo\n"); - - - - gtk_idle_add ((GtkFunction) create_container, NULL); - - /* - * Main loop - */ - bonobo_main (); - - return 0; -} |