}
}
-static gchar *get_part_name(MimeInfo *partinfo)
+static const gchar *get_part_name(MimeInfo *partinfo)
{
- gchar *name;
+ const gchar *name;
- name = g_hash_table_lookup(partinfo->parameters, "name");
- if(name == NULL)
+ name = procmime_mimeinfo_get_parameter(partinfo, "filename");
+ if (name == NULL)
+ name = procmime_mimeinfo_get_parameter(partinfo, "name");
+ if (name == NULL)
name = "";
return name;
}
-static gchar *get_part_description(MimeInfo *partinfo)
+static const gchar *get_part_description(MimeInfo *partinfo)
{
if (partinfo->description)
return partinfo->description;
- else if (g_hash_table_lookup(partinfo->parameters, "name") != NULL)
- return g_hash_table_lookup(partinfo->parameters, "name");
else
- return "";
+ return get_part_name(partinfo);
}
static GtkCTreeNode *mimeview_append_part(MimeView *mimeview,
str[COL_MIMETYPE] = content_type;
str[COL_SIZE] = to_human_readable(partinfo->length);
if (prefs_common.attach_desc)
- str[COL_NAME] = get_part_description(partinfo);
+ str[COL_NAME] = (gchar *) get_part_description(partinfo);
else
- str[COL_NAME] = get_part_name(partinfo);
+ str[COL_NAME] = (gchar *) get_part_name(partinfo);
node = gtk_ctree_insert_node(ctree, parent, NULL, str, 0,
NULL, NULL, NULL, NULL,
gint i = 0;
while (curfactory->content_types[i] != NULL) {
- debug_print("%s\n", curfactory->content_types[i]);
if(!fnmatch(curfactory->content_types[i], content_type, FNM_CASEFOLD)) {
+ debug_print("%s\n", curfactory->content_types[i]);
factory = curfactory;
break;
}
MimeViewer *viewer = NULL;
if ((partinfo->type == MIMETYPE_APPLICATION) &&
- (g_strcasecmp(partinfo->subtype, "octet-stream")) &&
- (partinfo->name != NULL)) {
- content_type = procmime_get_mime_type(partinfo->name);
+ (!g_strcasecmp(partinfo->subtype, "octet-stream"))) {
+ const gchar *filename;
+
+ filename = procmime_mimeinfo_get_parameter(partinfo, "filename");
+ if (filename == NULL)
+ filename = procmime_mimeinfo_get_parameter(partinfo, "name");
+ if (filename != NULL)
+ content_type = procmime_get_mime_type(filename);
} else {
content_type = g_strdup_printf("%s/%s", procmime_get_type_str(partinfo->type), partinfo->subtype);
}
static void update_signature_noticeview(MimeView *mimeview, MimeInfo *mimeinfo)
{
- if (privacy_mimeinfo_is_signed(mimeinfo)) {
- gchar *text = NULL, *button_text = NULL;
- GtkSignalFunc func = NULL;
- StockPixmap icon = STOCK_PIXMAP_PRIVACY_SIGNED;
-
- switch (privacy_mimeinfo_get_sig_status(mimeinfo)) {
- case SIGNATURE_UNCHECKED:
- button_text = _("Check");
- func = check_signature_cb;
- icon = STOCK_PIXMAP_PRIVACY_SIGNED;
- break;
- case SIGNATURE_OK:
- button_text = _("Full info");
- func = display_full_info_cb;
- icon = STOCK_PIXMAP_PRIVACY_PASSED;
- break;
- case SIGNATURE_WARN:
- icon = STOCK_PIXMAP_PRIVACY_WARN;
- break;
- case SIGNATURE_INVALID:
- icon = STOCK_PIXMAP_PRIVACY_FAILED;
- break;
- case SIGNATURE_CHECK_FAILED:
- button_text = _("Check again");
- func = check_signature_cb;
- icon = STOCK_PIXMAP_PRIVACY_UNKNOWN;
- default:
- break;
- }
- text = privacy_mimeinfo_sig_info_short(mimeinfo);
- noticeview_set_text(mimeview->siginfoview, text);
- g_free(text);
- noticeview_set_button_text(mimeview->siginfoview, button_text);
- noticeview_set_button_press_callback(
- mimeview->siginfoview,
- func,
- (gpointer) mimeview);
- noticeview_set_icon(mimeview->siginfoview, icon);
- noticeview_show(mimeview->siginfoview);
- } else {
- noticeview_hide(mimeview->siginfoview);
+ gchar *text = NULL, *button_text = NULL;
+ GtkSignalFunc func = NULL;
+ StockPixmap icon = STOCK_PIXMAP_PRIVACY_SIGNED;
+
+ g_return_if_fail(mimeview != NULL);
+ g_return_if_fail(mimeinfo != NULL);
+
+ switch (privacy_mimeinfo_get_sig_status(mimeinfo)) {
+ case SIGNATURE_UNCHECKED:
+ button_text = _("Check");
+ func = check_signature_cb;
+ icon = STOCK_PIXMAP_PRIVACY_SIGNED;
+ break;
+ case SIGNATURE_OK:
+ button_text = _("Full info");
+ func = display_full_info_cb;
+ icon = STOCK_PIXMAP_PRIVACY_PASSED;
+ break;
+ case SIGNATURE_WARN:
+ button_text = _("Full info");
+ func = display_full_info_cb;
+ icon = STOCK_PIXMAP_PRIVACY_WARN;
+ break;
+ case SIGNATURE_INVALID:
+ button_text = _("Full info");
+ func = display_full_info_cb;
+ icon = STOCK_PIXMAP_PRIVACY_FAILED;
+ break;
+ case SIGNATURE_CHECK_FAILED:
+ button_text = _("Check again");
+ func = check_signature_cb;
+ icon = STOCK_PIXMAP_PRIVACY_UNKNOWN;
+ default:
+ break;
}
+ text = privacy_mimeinfo_sig_info_short(mimeinfo);
+ noticeview_set_text(mimeview->siginfoview, text);
+ g_free(text);
+ noticeview_set_button_text(mimeview->siginfoview, button_text);
+ noticeview_set_button_press_callback(
+ mimeview->siginfoview,
+ func,
+ (gpointer) mimeview);
+ noticeview_set_icon(mimeview->siginfoview, icon);
}
static void check_signature_cb(GtkWidget *widget, gpointer user_data)
{
MimeView *mimeview = (MimeView *) user_data;
- MimeInfo *mimeinfo = mimeview_get_selected_part(mimeview);
+ MimeInfo *mimeinfo = mimeview->siginfo;
privacy_mimeinfo_check_signature(mimeinfo);
- update_signature_noticeview(mimeview, mimeinfo);
+ update_signature_noticeview(mimeview, mimeview->siginfo);
}
static void display_full_info_cb(GtkWidget *widget, gpointer user_data)
{
MimeView *mimeview = (MimeView *) user_data;
- MimeInfo *mimeinfo = mimeview_get_selected_part(mimeview);
gchar *siginfo;
-
- siginfo = privacy_mimeinfo_sig_info_full(mimeinfo);
+
+ siginfo = privacy_mimeinfo_sig_info_full(mimeview->siginfo);
textview_set_text(mimeview->textview, siginfo);
g_free(siginfo);
+ noticeview_set_button_text(mimeview->siginfoview, NULL);
+}
+
+static void update_signature_info(MimeView *mimeview, MimeInfo *selected)
+{
+ MimeInfo *siginfo;
+
+ g_return_if_fail(mimeview != NULL);
+ g_return_if_fail(selected != NULL);
+
+ siginfo = selected;
+ while (siginfo != NULL) {
+ if (privacy_mimeinfo_is_signed(siginfo))
+ break;
+ siginfo = procmime_mimeinfo_parent(siginfo);
+ }
+ mimeview->siginfo = siginfo;
+
+ if (siginfo == NULL) {
+ noticeview_hide(mimeview->siginfoview);
+ return;
+ }
+
+ update_signature_noticeview(mimeview, siginfo);
+ noticeview_show(mimeview->siginfoview);
}
static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
mimeview->textview->default_text = FALSE;
- update_signature_noticeview(mimeview, partinfo);
+ update_signature_info(mimeview, partinfo);
if (!mimeview_show_part(mimeview, partinfo)) {
switch (partinfo->type) {
g_return_if_fail(mimeview != NULL);
partinfo = mimeview_get_selected_part(mimeview);
- if (partinfo->filename == NULL && partinfo->name == NULL) return;
+ if (partinfo->disposition == DISPOSITIONTYPE_INLINE) return;
context = gtk_drag_begin(widget, mimeview->target_list,
GDK_ACTION_COPY, button, event);
menu_set_sensitive(mimeview->popupfactory,
"/Display as text", TRUE);
if (partinfo &&
- partinfo->type == MIMETYPE_APPLICATION)
+ partinfo->type == MIMETYPE_APPLICATION &&
+ !g_strcasecmp(partinfo->subtype, "octet-stream"))
menu_set_sensitive(mimeview->popupfactory,
"/Open", FALSE);
else
KEY_PRESS_EVENT_STOP();
mimeview_launch(mimeview);
return TRUE;
+ case GDK_o:
+ BREAK_ON_MODIFIER_KEY();
+ KEY_PRESS_EVENT_STOP();
+ mimeview_open_with(mimeview);
+ return TRUE;
default:
break;
}
partinfo = mimeview_get_selected_part(mimeview);
if (!partinfo) return;
- if (!partinfo->filename && !partinfo->name) return;
- filename = partinfo->filename ? partinfo->filename : partinfo->name;
- filename = g_basename(filename);
+ filename = g_basename(get_part_name(partinfo));
if (*filename == '\0') return;
filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S,
alertpanel_error(_("`%s' is not a directory."),
dirname);
g_free (dirname);
+ dirname = NULL;
return;
}
while (attachment != NULL) {
if (attachment->type != MIMETYPE_MESSAGE &&
attachment->type != MIMETYPE_MULTIPART &&
- (procmime_mimeinfo_get_parameter(attachment, "name") ||
- procmime_mimeinfo_get_parameter(attachment, "filename"))) {
+ attachment->disposition != DISPOSITIONTYPE_INLINE) {
static guint subst_cnt = 1;
gchar *attachdir;
gchar *attachname = g_strdup(get_part_name(attachment));
}
g_return_if_fail(partinfo != NULL);
- if (partname = procmime_mimeinfo_get_parameter(partinfo, "name")) {
+ if ((partname = get_part_name(partinfo)) != NULL) {
Xstrdup_a(defname, partname, return);
subst_for_filename(defname);
}
if (cmdline) {
cmd = cmdline;
def_cmd = NULL;
- } else if (MIMETYPE_APPLICATION == partinfo->type) {
+ } else if (MIMETYPE_APPLICATION == partinfo->type &&
+ !g_strcasecmp(partinfo->subtype, "octet-stream")) {
return;
} else if (MIMETYPE_IMAGE == partinfo->type) {
cmd = prefs_common.mime_image_viewer;
KEY_PRESS_EVENT_STOP();
mimeview_launch(mimeview);
return TRUE;
+ case GDK_o:
+ BREAK_ON_MODIFIER_KEY();
+ KEY_PRESS_EVENT_STOP();
+ mimeview_open_with(mimeview);
+ return TRUE;
default:
break;
}
GtkWidget *vbox;
GtkWidget *button;
gchar *tip;
- gchar *desc = NULL;
+ const gchar *desc = NULL;
StockPixmap stockp;
vbox = mimeview->icon_vbox;