+ if (uri) {
+
+ GnomeVFSHandle *handle = NULL;
+ GnomeVFSResult result;
+
+ result = gnome_vfs_open (&handle, uri, GNOME_VFS_OPEN_READ);
+ if (result == GNOME_VFS_OK) {
+ TnyMimePart *mime_part;
+ TnyStream *stream;
+ const gchar *mime_type = NULL;
+ gchar *basename;
+ gchar *content_id;
+ GnomeVFSFileInfo info;
+
+ if (gnome_vfs_get_file_info_from_handle (handle, &info, GNOME_VFS_FILE_INFO_GET_MIME_TYPE) == GNOME_VFS_OK)
+ mime_type = gnome_vfs_file_info_get_mime_type (&info);
+ mime_part = tny_platform_factory_new_mime_part
+ (modest_runtime_get_platform_factory ());
+ stream = TNY_STREAM (tny_vfs_stream_new (handle));
+
+ tny_mime_part_construct_from_stream (mime_part, stream, mime_type);
+
+ content_id = g_strdup_printf ("%d", priv->last_cid);
+ tny_mime_part_set_content_id (mime_part, content_id);
+ g_free (content_id);
+ priv->last_cid++;
+
+ basename = g_path_get_basename (filename);
+ tny_mime_part_set_filename (mime_part, basename);
+ g_free (basename);
+
+ priv->attachments = g_list_prepend (priv->attachments, mime_part);
+ modest_attachments_view_add_attachment (MODEST_ATTACHMENTS_VIEW (priv->attachments_view),
+ mime_part);
+ gtk_widget_set_no_show_all (priv->attachments_caption, FALSE);
+ gtk_widget_show_all (priv->attachments_caption);
+ }
+ g_free (filename);
+ }
+}
+
+void
+modest_msg_edit_window_attach_file_noninteractive (
+ ModestMsgEditWindow *window,
+ gchar *filename)
+{
+
+ ModestMsgEditWindowPrivate *priv;
+
+ priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
+