aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-format.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-07-26 12:13:42 +0800
committerDan Winship <danw@src.gnome.org>2000-07-26 12:13:42 +0800
commit570714db1d6ad5e16d3687814c39582c7e8382fe (patch)
tree39f4f6e0eb3bcc1f4af51ec6875d89cefac4dc5c /mail/mail-format.c
parent365ff1ed49929193406e993c14dca1584d7025a6 (diff)
downloadgsoc2013-evolution-570714db1d6ad5e16d3687814c39582c7e8382fe.tar
gsoc2013-evolution-570714db1d6ad5e16d3687814c39582c7e8382fe.tar.gz
gsoc2013-evolution-570714db1d6ad5e16d3687814c39582c7e8382fe.tar.bz2
gsoc2013-evolution-570714db1d6ad5e16d3687814c39582c7e8382fe.tar.lz
gsoc2013-evolution-570714db1d6ad5e16d3687814c39582c7e8382fe.tar.xz
gsoc2013-evolution-570714db1d6ad5e16d3687814c39582c7e8382fe.tar.zst
gsoc2013-evolution-570714db1d6ad5e16d3687814c39582c7e8382fe.zip
Update for OAF and for external apps as well as components.
* mail-format.c (lookup_handler): Update for OAF and for external apps as well as components. (handle_via_external): Handler to set up for data that can be displayed by an external application. * mail-display.c (on_link_clicked, etc): Refactor the save_data() code and add launch_external() as a handler for x-evolution-external URLs. (embeddable_destroy_cb): Remove this, since it seems like it's all wrong. (on_object_requested): Update for OAF, and fix some bugs. svn path=/trunk/; revision=4343
Diffstat (limited to 'mail/mail-format.c')
-rw-r--r--mail/mail-format.c81
1 files changed, 65 insertions, 16 deletions
diff --git a/mail/mail-format.c b/mail/mail-format.c
index 93049a7aa0..582068042c 100644
--- a/mail/mail-format.c
+++ b/mail/mail-format.c
@@ -30,6 +30,7 @@
#include "e-util/e-setup.h" /*for evolution_dir*/
#include <libgnome/libgnome.h>
#include <libgnomevfs/gnome-vfs-mime-info.h>
+#include <libgnomevfs/gnome-vfs-mime-handlers.h>
#include <ctype.h> /* for isprint */
#include <string.h> /* for strstr */
@@ -84,6 +85,9 @@ static gboolean handle_unknown_type (CamelMimePart *part,
static gboolean handle_via_bonobo (CamelMimePart *part,
const char *mime_type,
struct mail_format_data *mfd);
+static gboolean handle_via_external (CamelMimePart *part,
+ const char *mime_type,
+ struct mail_format_data *mfd);
/* writes the header info for a mime message into an html stream */
static void write_headers (CamelMimeMessage *message,
@@ -229,8 +233,8 @@ static mime_handler_fn
lookup_handler (const char *mime_type, gboolean *generic)
{
mime_handler_fn handler_function;
- const char *whole_goad_id, *generic_goad_id;
char *mime_type_main;
+ GnomeVFSMimeAction *action;
if (mime_function_table == NULL)
setup_function_table ();
@@ -242,10 +246,10 @@ lookup_handler (const char *mime_type, gboolean *generic)
/* OK. There are 6 possibilities, which we try in this order:
* 1) full match in the main table
* 2) partial match in the main table
- * 3) full match in bonobo
+ * 3) full match in gnome_vfs_mime_*
* 4) full match in the fallback table
* 5) partial match in the fallback table
- * 6) partial match in bonobo
+ * 6) partial match in gnome_vfs_mime_*
*
* Of these, 1-4 are considered exact matches, and 5 and 6 are
* considered generic.
@@ -271,20 +275,24 @@ lookup_handler (const char *mime_type, gboolean *generic)
return handler_function;
}
- whole_goad_id = gnome_vfs_mime_get_value (mime_type, "bonobo-goad-id");
- generic_goad_id = gnome_vfs_mime_get_value (mime_type_main,
- "bonobo-goad-id");
+/* FIXME: Remove this #ifdef after gnome-vfs 0.3 is released */
+#ifdef HAVE_GNOME_VFS_MIME_GET_DEFAULT_ACTION_WITHOUT_FALLBACK
+ action = gnome_vfs_mime_get_default_action_without_fallback (mime_type);
+ if (action) {
+ if (action->action_type == GNOME_VFS_MIME_ACTION_TYPE_COMPONENT)
+ handler_function = handle_via_bonobo;
+ else
+ handler_function = handle_via_external;
- if (whole_goad_id && (!generic_goad_id ||
- strcmp (whole_goad_id, generic_goad_id) != 0)) {
/* Optimize this for the next time through. */
g_hash_table_insert (mime_function_table,
- g_strdup (mime_type),
- handle_via_bonobo);
+ g_strdup (mime_type), handler_function);
g_free (mime_type_main);
+ gnome_vfs_mime_action_free (action);
*generic = FALSE;
- return handle_via_bonobo;
+ return handler_function;
}
+#endif
handler_function = g_hash_table_lookup (mime_fallback_table,
mime_type);
@@ -293,8 +301,17 @@ lookup_handler (const char *mime_type, gboolean *generic)
else {
handler_function = g_hash_table_lookup (mime_fallback_table,
mime_type_main);
- if (!handler_function && generic_goad_id)
- handler_function = handle_via_bonobo;
+ if (!handler_function) {
+ action = gnome_vfs_mime_get_default_action (mime_type_main);
+ if (action) {
+ if (action->action_type ==
+ GNOME_VFS_MIME_ACTION_TYPE_COMPONENT)
+ handler_function = handle_via_bonobo;
+ else
+ handler_function = handle_via_external;
+ gnome_vfs_mime_action_free (action);
+ }
+ }
*generic = TRUE;
}
@@ -902,14 +919,19 @@ static const char *
get_url_for_icon (const char *icon_name, struct mail_format_data *mfd)
{
static GHashTable *icons;
- char *icon_path = gnome_pixmap_file (icon_name), buf[1024], *url;
+ char *icon_path, buf[1024], *url;
GByteArray *ba;
if (!icons)
icons = g_hash_table_new (g_str_hash, g_str_equal);
- if (!icon_path)
- return "file:///dev/null";
+ if (*icon_name == '/')
+ icon_path = g_strdup (icon_name);
+ else {
+ icon_path = gnome_pixmap_file (icon_name);
+ if (!icon_path)
+ return "file:///dev/null";
+ }
ba = g_hash_table_lookup (icons, icon_path);
if (!ba) {
@@ -1215,6 +1237,33 @@ handle_via_bonobo (CamelMimePart *part, const char *mime_type,
return TRUE;
}
+static gboolean
+handle_via_external (CamelMimePart *part, const char *mime_type,
+ struct mail_format_data *mfd)
+{
+ GnomeVFSMimeApplication *app;
+ const char *desc, *icon;
+ char *action, *url;
+
+ app = gnome_vfs_mime_get_default_application (mime_type);
+ g_return_val_if_fail (app != NULL, FALSE);
+
+ desc = gnome_vfs_mime_get_value (mime_type, "description");
+ icon = gnome_vfs_mime_get_value (mime_type, "icon-filename");
+ if (!icon)
+ icon = "gnome-unknown.png";
+ action = g_strdup_printf ("open the file in %s", app->name);
+ url = g_strdup_printf ("x-evolution-external:%s", app->command);
+ g_hash_table_insert (mfd->urls, url, part);
+
+ handle_mystery (part, mfd, url, icon, desc, action);
+
+ g_free (action);
+
+ return TRUE;
+}
+
+
static char *
reply_body (CamelDataWrapper *data, gboolean want_plain, gboolean *is_html)
{