#include "../modest-tny-transport-actions.h"
#include "../modest-text-utils.h"
+#include "../modest-tny-msg-actions.h"
#define MODEST_GLADE PREFIX "/share/modest/glade/modest.glade"
#define MODEST_GLADE_MAIN_WIN "main"
static void register_toolbar_callbacks (ModestUI *modest_ui);
+static void reply_to_msg (ModestUI *modest_ui, TnyMsgHeaderIface *header,
+ ModestTnyMsgView *msg_view);
/* list my signals */
enum {
ModestWindowMgr *modest_window_mgr;
TnyAccountStoreIface *account_store;
- GtkWindow *main_window;
+ GtkWindow *main_window;
GladeXML *glade_xml;
modest_main_window_folder_tree (ModestAccountMgr *modest_acc_mgr,
TnyAccountStoreIface *account_store)
{
- GtkTreeViewColumn *column;
- GtkCellRenderer *renderer = gtk_cell_renderer_text_new ();
GtkWidget *folder_tree;
folder_tree = GTK_WIDGET(modest_tny_folder_tree_view_new (account_store));
g_warning ("could not create folder list");
return NULL;
}
-
- column = gtk_tree_view_column_new_with_attributes(_("All Mail Folders"),
- renderer,"text",
- TNY_ACCOUNT_TREE_MODEL_NAME_COLUMN,
- NULL);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW(folder_tree), column);
-
- column = gtk_tree_view_column_new_with_attributes(_("Unread"),
- renderer, "text",
- TNY_ACCOUNT_TREE_MODEL_UNREAD_COLUMN,
- NULL);
- gtk_tree_view_column_set_resizable (column, TRUE);
- gtk_tree_view_append_column (GTK_TREE_VIEW(folder_tree), column);
-
-
- gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(folder_tree), TRUE);
- gtk_tree_view_set_headers_clickable (GTK_TREE_VIEW(folder_tree), TRUE);
-
+
return folder_tree;
}
modest_ui_show_edit_window (modest_ui, "", "", "", "", "", NULL);
}
-
-static gchar *
-modest_ui_quote_msg(const TnyMsgIface *src, const gchar *from, time_t sent_date)
-{
- GList *parts;
- TnyMsgMimePartIface *part;
- TnyStreamIface* stream;
- TnyTextBufferStream *dest;
- TnyMsgMimePartIface *body = NULL;
- GtkTextBuffer *buf;
- gint limit = 76; /* TODO: make configurable */
- gchar *quoted;
-
- buf = gtk_text_buffer_new(NULL);
- dest = tny_text_buffer_stream_new(buf);
-
- /* is the warning in this line due to a bug in tinymail? */
- parts = (GList*) tny_msg_iface_get_parts (src);
-
- while (parts) {
- /* TODO: maybe we'd like to quote more than one part? */
- TnyMsgMimePartIface *part =
- TNY_MSG_MIME_PART_IFACE(parts->data);
- if (tny_msg_mime_part_iface_content_type_is (part, "text/plain")) {
- body = part;
- break;
- }
- parts = parts->next;
- }
- if (!body) {
- return NULL;
- }
- buf = gtk_text_buffer_new (NULL);
- stream = TNY_STREAM_IFACE(tny_text_buffer_stream_new (buf));
-
- tny_stream_iface_reset (stream);
- tny_msg_mime_part_iface_decode_to_stream (body, stream);
- tny_stream_iface_reset (stream);
-
- quoted = modest_text_utils_quote (buf, from, sent_date, limit);
-
- g_object_unref(stream);
- g_object_unref(buf);
- return quoted;
-}
-
static void
-modest_ui_reply_to_msg (ModestUI *modest_ui, TnyMsgHeaderIface *header,
+reply_to_msg (ModestUI *modest_ui, TnyMsgHeaderIface *header,
ModestTnyMsgView *msg_view) {
const TnyMsgIface *msg;
const TnyMsgFolderIface *folder;
GString *re_sub;
const gchar *subject, *from;
- gchar *quoted;
+ gchar *unquoted, *quoted;
time_t sent_date;
+ gint line_limit = 76;
- quoted = "";
- if (header) {
- folder = tny_msg_header_iface_get_folder (TNY_MSG_HEADER_IFACE(header));
- if (!folder) {
- g_warning ("cannot find folder");
- return;
- }
-
- msg = tny_msg_folder_iface_get_message (TNY_MSG_FOLDER_IFACE(folder), header);
- if (!msg) {
- g_warning ("cannot find msg");
- return;
- }
- subject = tny_msg_header_iface_get_subject(header);
- re_sub = g_string_new(subject);
- g_string_prepend(re_sub, "Re: ");
- /* FIXME: honor replyto, cc */
- from = tny_msg_header_iface_get_from(header);
- sent_date = tny_msg_header_iface_get_date_sent(header);
- quoted = modest_ui_quote_msg(msg, from, sent_date);
- } else {
+ if (!header) {
g_warning("no header");
return;
}
+ folder = tny_msg_header_iface_get_folder (TNY_MSG_HEADER_IFACE(header));
+ if (!folder) {
+ g_warning ("cannot find folder");
+ return;
+ }
+ msg = tny_msg_folder_iface_get_message (TNY_MSG_FOLDER_IFACE(folder), header);
+ if (!msg) {
+ g_warning ("cannot find msg");
+ return;
+ }
+ subject = tny_msg_header_iface_get_subject(header);
+ re_sub = g_string_new(subject);
+ g_string_prepend(re_sub, "Re: ");
+ /* FIXME: honor replyto, cc */
+ from = tny_msg_header_iface_get_from(header);
+ sent_date = tny_msg_header_iface_get_date_sent(header);
+
+ unquoted = modest_tny_msg_view_get_selected_text(msg_view);
+ quoted = modest_tny_msg_actions_quote(msg, from, sent_date, line_limit, unquoted);
+
modest_ui_show_edit_window (modest_ui, from, /* cc */ "", /* bcc */ "", re_sub->str, quoted, NULL);
g_free(quoted);
+ g_free(unquoted);
g_string_free(re_sub, TRUE);
}
TNY_MSG_HEADER_LIST_MODEL_INSTANCE_COLUMN,
&header, -1);
- modest_ui_reply_to_msg (modest_ui, header, msg_view);
+ reply_to_msg (modest_ui, header, msg_view);
}
ModestTnyTransportActions *actions;
ModestUIPrivate *priv;
GtkWidget *to_entry, *subject_entry, *body_view;
- const gchar *to, *subject;
+ const gchar *to, *subject, *email_from;
gchar *body;
GtkTextIter start, end;
GtkTextBuffer *buf;
TnyAccountStoreIface *account_store;
const GList *transport_accounts;
TnyTransportAccountIface *transport_account;
+ ModestConf *conf;
+ ModestAccountMgr *acc_mgr;
g_return_if_fail (modest_ui);
gtk_text_buffer_get_bounds (buf, &start, &end);
body = gtk_text_buffer_get_text (buf, &start, &end, FALSE);
- g_message ("sending %s ==> %s", subject, to);
+ /* FIXME: HACK! */
+ conf = MODEST_CONF(modest_conf_new());
+ acc_mgr = MODEST_ACCOUNT_MGR(modest_account_mgr_new (conf));
+ if (!acc_mgr) {
+ g_warning ("failed to instantiate account mgr");
+ return;
+ }
+ email_from = modest_account_mgr_get_identity_string(acc_mgr, "myidentity", MODEST_ACCOUNT_EMAIL, NULL);
+ /* end HACK */
+
+ g_message("sending \"%s\" %s ==> %s", subject, email_from, to);
modest_tny_transport_actions_send_message (actions,
transport_account,
- "dirk-jan.binnema@nokia.com",
+ email_from,
to, "", "", subject,
body);
g_free (body);