[pan2/testing: 132/279] implemented autosave for drafts, should work ...
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 132/279] implemented autosave for drafts, should work ...
- Date: Sat, 3 Dec 2011 22:33:16 +0000 (UTC)
commit e829719cdc4ce15cca0dc4827db00463cf1fc029
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Wed Jun 29 13:27:54 2011 +0200
implemented autosave for drafts, should work ...
pan/gui/post-ui.cc | 35 ++++++++++++++++-------------------
pan/tasks/task-upload.cc | 23 +++++------------------
2 files changed, 21 insertions(+), 37 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index aaf033d..6d1b690 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -1292,9 +1292,7 @@ PostUI :: open_draft ()
void
PostUI :: import_draft (const char* fn)
{
- std::string& draft_filename (get_draft_filename ());
- char * draft = g_build_filename (draft_filename.c_str(), "autosave", NULL);
-
+ const char * draft = fn;
std::string txt;
if (file :: get_text_file_contents (draft, txt))
{
@@ -1308,7 +1306,6 @@ PostUI :: import_draft (const char* fn)
g_object_unref (G_OBJECT(parser));
g_object_unref (G_OBJECT(stream));
}
- g_free (draft);
}
namespace
@@ -2039,17 +2036,17 @@ void
PostUI :: body_view_realized_cb (GtkWidget*, gpointer self_gpointer)
{
PostUI * self = static_cast<PostUI*>(self_gpointer);
- self->set_wrap_mode (self->_prefs.get_flag ("compose-wrap-enabled", true));
- self->set_message (self->_message);
- self->_unchanged_body = self->get_body ();
/* import old draft from autosave file */
-// struct stat sb;
-// char *buf = g_build_filename(get_draft_filename().c_str(), "autosave", NULL);
-// if (stat (buf, &sb)==0)
-// self->import_draft(buf);
-// self->open_draft();
-// g_free(buf);
+ struct stat sb;
+ char *buf = g_build_filename(get_draft_filename().c_str(), "autosave", NULL);
+ if (stat (buf, &sb)==0)
+ self->import_draft(buf);
+ g_free(buf);
+
+ self->set_wrap_mode (self->_prefs.get_flag ("compose-wrap-enabled", false));
+ self->set_message (self->_message);
+ self->_unchanged_body = self->get_body ();
if (self->_prefs.get_flag ("always-run-editor", false))
self->spawn_editor ();
@@ -2728,23 +2725,23 @@ gboolean
PostUI::draft_save_cb(gpointer ptr)
{
PostUI *data = static_cast<PostUI*>(ptr);
-// data->in_newsrc_cb = true;
if (!data) return true;
GMimeMessage * msg = data->new_message_from_ui (DRAFTING);
std::string& draft_filename (get_draft_filename ());
char * filename = g_build_filename (draft_filename.c_str(), "autosave", NULL);
std::ofstream o (filename);
- char * pch = g_mime_object_to_string ((GMimeObject *) msg);
- o << pch;
+ gboolean unused;
+ char * headers (g_mime_object_get_headers ((GMimeObject *) msg));
+ o << headers;
+ const std::string body (data->get_body ());
+ o << body;
o.close ();
- g_free (pch);
g_object_unref (msg);
g_free(filename);
-// data->in_newsrc_cb = false;
- data->_unchanged_body = data->get_body ();
+ data->_unchanged_body = body;
data->_draft_autosave_idle_tag = 0;
return false;
}
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 508d2c1..ee5ee3f 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -121,8 +121,6 @@ TaskUpload :: build_needed_tasks()
}
-static bool inited(false);
-
void
TaskUpload :: update_work (NNTP* checkin_pending)
{
@@ -144,22 +142,8 @@ TaskUpload :: update_work (NNTP* checkin_pending)
{
_state.set_working();
}
- else if ((_encoder_has_run && !_needed.empty()) || !_msg)
+ else if ((_encoder_has_run && !_needed.empty()))
{
- if (_msg && !inited)
- {
-
- std::string data;
- foreach (needed_t, _needed, nit)
- {
- Needed& n (nit->second);
- _cache.get_data(data,n.message_id.c_str());
- prepend_headers(_msg,&n, data);
- /* update cache file */
- _cache.update_file (data,n.message_id.c_str());
- }
- inited = true;
- }
_state.set_need_nntp(_server);
}
else if (_needed.empty())
@@ -220,7 +204,10 @@ TaskUpload :: use_nntp (NNTP * nntp)
set_status_va (_("Uploading %s - Part %d of %d"), _basename.c_str(), needed->partno, _total_parts);
std::string data;
- _cache.get_data(data,needed->message_id.c_str());
+ _cache.get_data(data,needed->message_id.c_str());
+ prepend_headers(_msg,needed, data);
+ /* update cache file */
+// _cache.update_file (data,needed->message_id.c_str());
nntp->post(StringView(data), this);
update_work ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]