[pan2: 137/268] some fixes
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2: 137/268] some fixes
- Date: Mon, 2 Jan 2012 15:49:31 +0000 (UTC)
commit 4598db7b483d93c02ba853fc1a2353df3c004b4c
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Tue Jul 19 17:33:20 2011 +0200
some fixes
pan/general/progress.cc | 2 ++
pan/gui/post-ui.cc | 19 ++++++++-----------
pan/gui/prefs-ui.cc | 2 +-
pan/tasks/encoder.cc | 1 +
pan/tasks/task-upload.cc | 29 ++++++++++++++---------------
pan/tasks/task-upload.h | 1 -
6 files changed, 26 insertions(+), 28 deletions(-)
---
diff --git a/pan/general/progress.cc b/pan/general/progress.cc
index a01a9e5..4bbcc4c 100644
--- a/pan/general/progress.cc
+++ b/pan/general/progress.cc
@@ -56,10 +56,12 @@ Progress :: fire_status (const StringView& msg) {
}
void
Progress :: add_listener (Listener * l) {
+ if (!l) return;
_listeners.insert (l);
}
void
Progress :: remove_listener (Listener * l) {
+ if (!l) return;
_listeners.erase (l);
}
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 1b71f9c..1e094f8 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -86,8 +86,8 @@ PostUI :: generate_unique_id (StringView& mid, int cnt, std::string& s)
// delimit
out<< '@';
// add domain
- out << mid;
- //std::cerr << "rng : "<<out.str()<<std::endl;
+ out << (mid.empty() ? "nospam.com" : mid);
+// std::cerr << "rng : "<<out.str()<<std::endl;
s = out.str();
}
@@ -928,7 +928,6 @@ void
PostUI :: on_progress_finished (Progress&, int status) // posting finished
{
- std::cerr<<"status "<<status<<std::endl;
if (status==-1) { --_running_uploads; return; }
if (_file_queue_empty)
@@ -1079,13 +1078,12 @@ PostUI :: maybe_post_message (GMimeMessage * message)
int cnt(0);
char buf[2048];
struct stat sb;
- _running_uploads = tasks.size();
+ _running_uploads = tasks.size()+1;
- // generate domain name for upload if the flag is set
- bool custom_mid(_prefs.get_flag(MESSAGE_ID_PREFS_KEY,false));
+ // generate domain name for upload if the flag is set / a save-file is set
+ bool custom_mid(_prefs.get_flag(MESSAGE_ID_PREFS_KEY,false) || !_save_file.empty());
std::string d;
- if (custom_mid)
- d = !profile.fqdn.empty()
+ d = !profile.fqdn.empty()
? GNKSA::generate_message_id (profile.fqdn)
: GNKSA::generate_message_id_from_email_address (profile.address);
StringView d2(d);
@@ -1099,7 +1097,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
std::string last_mid;
std::string first_mid;
- // dummy taskupload for master article without attachment, dbg!!
+ // master article, other attach
const Profile profile (get_current_profile ());
std::string out;
generate_unique_id(domain, 1,out);
@@ -1127,7 +1125,6 @@ PostUI :: maybe_post_message (GMimeMessage * message)
// generate domain for rng numbers
int total = get_total_parts(t->_filename.c_str());
- std::cerr<<"total of "<<t->_filename<<" : "<<total<<std::endl;
foreach (std::set<int>, t->_wanted, pit)
{
@@ -1136,6 +1133,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
std::string out;
generate_unique_id(domain, *pit,out);
n.mid = out;
+ std::cerr<<"rng "<<out<<std::endl;
if (first_mid.empty()) first_mid = out;
}
@@ -3075,7 +3073,6 @@ PostUI :: prompt_user_for_queueable_files (GtkWindow * parent, const Prefs& pref
struct stat sb;
// yEnc encoding is the default, user can change that with popup-menu
ui.total = get_total_parts((const char*)cur->data);
- std::cerr<<"ui total "<<ui.total<<" "<<(const char*)cur->data<<" "<<get_total_parts((const char*)cur->data)<<std::endl;
TaskUpload* tmp = new TaskUpload(std::string((const char*)cur->data),
profile.posting_server, _cache,
a, ui, msg ,0, TaskUpload::YENC, TaskUpload::BULK );
diff --git a/pan/gui/prefs-ui.cc b/pan/gui/prefs-ui.cc
index cdeeb52..2200cf3 100644
--- a/pan/gui/prefs-ui.cc
+++ b/pan/gui/prefs-ui.cc
@@ -696,7 +696,7 @@ PrefsDialog :: PrefsDialog (Prefs& prefs, GtkWindow* parent):
HIG :: workarea_add_section_spacer (t, row, 4);
// 16 MiB blocks max, 512 kb min
w = new_spin_button ("upload-option-kbpf", 512, 1024*16, prefs);
- l = gtk_label_new(_("Default KB per File (for Encoder)"));
+ l = gtk_label_new(_("Default KB per File (for Encoder). "));
gtk_misc_set_alignment (GTK_MISC(l), 0.0, 0.5);
HIG::workarea_add_row (t, &row, w, l);
diff --git a/pan/tasks/encoder.cc b/pan/tasks/encoder.cc
index 1e17282..bfeb49a 100644
--- a/pan/tasks/encoder.cc
+++ b/pan/tasks/encoder.cc
@@ -150,6 +150,7 @@ Encoder :: do_work()
continue;
}
+// std::cerr<<"encode "<<kbpf*1024<<" bytes, "<<kbpf<<" kb \n";
res = UUEncodePartial_byFSize (fp, NULL, (char*)filename.c_str(), enc , (char*)basename.c_str(), 0, 0, cnt, kbpf*1024 ,&crc);
if (fp) fclose(fp);
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index dc2d927..f4c7ec6 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -188,9 +188,9 @@ TaskUpload :: prepend_headers(GMimeMessage* msg, TaskUpload::Needed * n, std::st
//modify references header
std::string mids(_references);
- mids += " <" + _first_mid + "> ";
- if (_first_mid != n->last_mid && !_first) mids += "<" + n->last_mid + ">";
- g_mime_object_set_header ((GMimeObject *) msg, "References", mids.c_str());
+ if (!_first_mid.empty()) mids += " <" + _first_mid + "> ";
+ if (_first_mid != n->last_mid && !_first && !n->last_mid.empty()) mids += "<" + n->last_mid + ">";
+ if (!mids.empty()) g_mime_object_set_header ((GMimeObject *) msg, "References", mids.c_str());
char * all;
if (_first && _queue_pos==-1)
@@ -201,15 +201,10 @@ TaskUpload :: prepend_headers(GMimeMessage* msg, TaskUpload::Needed * n, std::st
out << d;
d = out.str();
- if (_first && _queue_pos==0) g_free(all);
+ if (_first && _queue_pos==-1) g_free(all);
if (_first) _first = !_first;
}
-GMimeObject *
-TaskUpload :: get_body(Needed* n)
-{
- return 0;
-}
void
TaskUpload :: use_nntp (NNTP * nntp)
@@ -234,10 +229,13 @@ TaskUpload :: use_nntp (NNTP * nntp)
{
needed->nntp = nntp;
- set_status_va (_("Uploading %s - Part %d of %d"), _basename.c_str(), needed->partno, _total_parts);
+ if (_queue_pos != -1)
+ set_status_va (_("Uploading %s - Part %d of %d"), _basename.c_str(), needed->partno, _total_parts);
+ else
+ set_status_va (_("Uploading %s - Part %d of %d"), _basename.c_str(), 1, _total_parts);
std::string data;
- _cache.get_data(data,needed->message_id.c_str());
+ if (_queue_pos != -1) _cache.get_data(data,needed->message_id.c_str());
prepend_headers(_msg,needed, data);
nntp->post(StringView(data), this);
@@ -266,22 +264,23 @@ TaskUpload :: on_nntp_done (NNTP * nntp,
bool found(false);
bool post_ok(false);
+ if (!nntp ) std::cerr<<"nntp error!\n";
+
needed_t::iterator it;
for (it=_needed.begin(); it!=_needed.end(); ++it)
if (it->second.nntp == nntp) {
- found=true;
+ found = true;
break;
}
- if (!found) return;
+ if (!found) goto _end;
if (_queue_pos == -1) { _needed.erase(it); goto _end; }
switch (health)
{
case OK:
- std::cerr<<"OK "<<_queue_pos<<std::endl;
- increment_step(it->second.bytes);
+ increment_step(it->second.bytes); /// DBG
_needed.erase (it);
post_ok = true;
break;
diff --git a/pan/tasks/task-upload.h b/pan/tasks/task-upload.h
index adbf3b0..319dcf4 100644
--- a/pan/tasks/task-upload.h
+++ b/pan/tasks/task-upload.h
@@ -196,7 +196,6 @@ namespace pan
std::set<int> _wanted;
GMimeMessage * _msg;
void prepend_headers(GMimeMessage* msg, TaskUpload::Needed * n, std::string& d);
- GMimeObject * get_body(Needed* n);
void add_reference_to_list(std::string s);
bool _first;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]