[pan2/testing: 157/279] [*] fixed pan bug that didn't handle multi-references correctly. (task-xover.cc) [+] added correct r
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 157/279] [*] fixed pan bug that didn't handle multi-references correctly. (task-xover.cc) [+] added correct r
- Date: Sat, 3 Dec 2011 22:35:22 +0000 (UTC)
commit 1c883deda13efd84905f5206f2d62bb186a78239
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Thu Jul 7 14:47:35 2011 +0200
[*] fixed pan bug that didn't handle multi-references correctly. (task-xover.cc)
[+] added correct references headers
[+] fixed multi-uploads and byte-counting for encoder
pan/data-impl/headers.cc | 2 +-
pan/data-impl/xover.cc | 5 +++--
pan/data/article.cc | 7 +------
pan/gui/body-pane.cc | 31 ++++++++++++++++---------------
pan/tasks/nntp.cc | 1 -
pan/tasks/task-upload.cc | 3 ---
pan/tasks/task-xover.cc | 43 ++++++++++++++++++++++++++++++++-----------
7 files changed, 53 insertions(+), 39 deletions(-)
---
diff --git a/pan/data-impl/headers.cc b/pan/data-impl/headers.cc
index 0fcbc5f..3430352 100644
--- a/pan/data-impl/headers.cc
+++ b/pan/data-impl/headers.cc
@@ -536,7 +536,7 @@ DataImpl :: load_headers (const DataIO & data_io,
// found parts...
part_batch.init (a.message_id, total_part_count, found_part_count);
- std::cerr<<"article "<<a.message_id<<" "<<total_part_count<<" "<<found_part_count<<std::endl;
+// std::cerr<<"article "<<a.message_id<<" "<<total_part_count<<" "<<found_part_count<<std::endl;
for (int i(0), count(found_part_count); i<count; ++i)
{
const bool gotline (in->getline (s));
diff --git a/pan/data-impl/xover.cc b/pan/data-impl/xover.cc
index d5777fc..605ea5a 100644
--- a/pan/data-impl/xover.cc
+++ b/pan/data-impl/xover.cc
@@ -242,7 +242,7 @@ DataImpl :: xover_add (const Quark & server,
return 0;
}
- std::cerr<<"xover add "<<subject<<" "<<author<<" "<<message_id<<" lines "<<line_count<<" bytes "<<byte_count<<std::endl;
+// std::cerr<<"xover add : "<<subject<<" "<<author<<" "<<message_id<<" lines "<<line_count<<" bytes "<<byte_count<<std::endl;
const Article* new_article (0);
h->_dirty = true;
@@ -293,8 +293,9 @@ DataImpl :: xover_add (const Quark & server,
a.author = author;
a.subject = multipart_subject_quark;
a.message_id = art_mid;
- a.is_binary = part_count >= 1;
+ // dbg
a.set_part_count (a.is_binary ? part_count : 1);
+ a.is_binary = part_count >= 1;
a.time_posted = time_posted;
a.xref.insert (server, xref);
load_article (group, &a, references);
diff --git a/pan/data/article.cc b/pan/data/article.cc
index 053c8a6..218957b 100644
--- a/pan/data/article.cc
+++ b/pan/data/article.cc
@@ -38,8 +38,7 @@ Article :: get_part_state () const
part_state = SINGLE;
// someone's posted a followup to a multipart
- ///TODO magic number??
- else if (!is_line_count_ge(4000) && has_reply_leader(subject.to_view()))
+ else if (!is_line_count_ge(250) && has_reply_leader(subject.to_view()))
part_state = SINGLE;
else {
@@ -51,10 +50,6 @@ Article :: get_part_state () const
part_state = total==found ? COMPLETE : INCOMPLETE;
}
- std::cerr<<message_id<<" is "<<(is_binary ? "binary" : "text")<<".\n";
-
-// if (strstr(message_id, "pan.2011")) return SINGLE;
-
return part_state;
}
diff --git a/pan/gui/body-pane.cc b/pan/gui/body-pane.cc
index 8af0082..032f212 100644
--- a/pan/gui/body-pane.cc
+++ b/pan/gui/body-pane.cc
@@ -100,7 +100,7 @@ namespace
PixbufCache& get_pixbuf_cache (gpointer gp) {
static const char * PIXBUF_CACHE ("pixbuf-cache");
- GObject * o (G_OBJECT (gp));
+ GObject * o (G_OBJECT (gp));
PixbufCache *pc ((PixbufCache*) g_object_get_data(o, PIXBUF_CACHE));
if (!pc) {
pc = new PixbufCache ();
@@ -339,8 +339,8 @@ namespace
{
const int begin_offset (gtk_text_iter_get_offset (iter));
- GdkPixbuf * original (0);
- GdkPixbuf * old_scaled (0);
+ GdkPixbuf * original (0);
+ GdkPixbuf * old_scaled (0);
if (!get_pixbuf_at_offset (buf, begin_offset, original, old_scaled))
return;
@@ -559,7 +559,7 @@ namespace
for (;;) {
if (str == line_end)
break;
- else if (text_massager->is_quote_character (g_utf8_get_char (str)))
+ else if (text_massager->is_quote_character (g_utf8_get_char (str)))
++depth;
else if (!g_unichar_isspace(g_utf8_get_char(str)))
break;
@@ -606,7 +606,7 @@ namespace
}
enum TagMode { ADD, REPLACE };
-
+
void
set_section_tag (GtkTextBuffer * buffer,
GtkTextIter * start,
@@ -707,8 +707,8 @@ namespace
int offset (0);
if (GNKSA::find_signature_delimiter (v, offset) != GNKSA::SIG_NONE)
sig_point = v.str + offset;
-
- // colorize the quoted text
+
+ // colorize the quoted text
GtkTextIter mark_end;
std::string last_quote_tag;
bool is_sig (false);
@@ -798,7 +798,7 @@ namespace
}
}
}
-
+
// colorize urls
if (do_urls) {
StringView area;
@@ -838,7 +838,7 @@ namespace
gsize bytesLeft = buffer->len;
guchar * data = buffer->data;
- // ticket #467446 - workaround gdkpixbuf <= 2.12.x's
+ // ticket #467446 - workaround gdkpixbuf <= 2.12.x's
// jpg loader bug (#494667) by feeding the loader in
// smaller chunks
while( bytesLeft > 0 )
@@ -1079,7 +1079,7 @@ BodyPane :: set_text_from_message (GMimeMessage * message)
}
}
}
-
+
s.resize (s.size()-1); // remove trailing linefeed
gtk_label_set_markup (GTK_LABEL(_headers), s.c_str());
@@ -1341,7 +1341,7 @@ BodyPane :: copy_url ()
gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD),
_hover_url.c_str(), _hover_url.size());
}
-
+
void
BodyPane :: populate_popup_cb (GtkTextView *v, GtkMenu *m, gpointer pane)
@@ -1549,7 +1549,7 @@ namespace
}
std::string get_header (GMimeMessage * msg,
- const char * key,
+ const char * key,
const char * fallback_charset_1,
const char * fallback_charset_2)
{
@@ -1652,12 +1652,13 @@ BodyPane :: create_followup_or_reply (bool is_reply)
const char * header = "References";
v = g_mime_object_get_header (_message_obj, header);
val.assign (v.str, v.len);
- if (!val.empty())
- val += ' ';
+// if (!val.empty())
+// val += ' ';
val += "<";
val += g_mime_message_get_message_id (_message);
val += ">";
- val = GNKSA :: trim_references (val);
+ /// DBG, removeme!!
+// val = GNKSA :: trim_references (val);
g_mime_object_append_header (msg_obj, header, val.c_str());
///
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index 385b2aa..2b6da4c 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -449,7 +449,6 @@ NNTP :: post (const StringView & msg,
}
else
{
- std::cerr<<s<<std::endl;
_post = s;
_commands.push_back ("POST\r\n");
write_next_command ();
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index c6c25d9..9c185d2 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -175,7 +175,6 @@ TaskUpload :: prepend_headers(GMimeMessage* msg, TaskUpload::Needed * n, std::st
//extract body
char * body (g_mime_object_to_string ((GMimeObject *) msg));
- std::cerr<<"\n"<<body<<"\n--------------------------\n\n";
out << body << "\n";
out << d;
d = out.str();
@@ -235,8 +234,6 @@ TaskUpload :: on_nntp_done (NNTP * nntp,
tmp.date = time(NULL);
tmp.is_child = true;
- std::cerr<<response<<std::endl;
-
needed_t::iterator it;
for (it=_needed.begin(); it!=_needed.end(); ++it)
if (it->second.nntp == nntp)
diff --git a/pan/tasks/task-xover.cc b/pan/tasks/task-xover.cc
index 40b292f..ceada0d 100644
--- a/pan/tasks/task-xover.cc
+++ b/pan/tasks/task-xover.cc
@@ -21,9 +21,15 @@
#include <cassert>
#include <cerrno>
extern "C" {
+ #define PROTOTYPES
+ #include <stdio.h>
+ #include <uulib/uudeview.h>
#include <glib/gi18n.h>
#include <gmime/gmime-utils.h>
+
}
+#include <fstream>
+#include <iostream>
#include <pan/general/debug.h>
#include <pan/general/macros.h>
#include <pan/general/messages.h>
@@ -94,6 +100,7 @@ TaskXOver :: TaskXOver (Data & data,
_articles_so_far (0ul),
_total_minitasks (0)
{
+
debug ("ctor for " << group);
// add a ``GROUP'' MiniTask for each server that has this group
@@ -264,9 +271,10 @@ namespace
}
void
-TaskXOver :: on_nntp_line (NNTP * nntp,
- const StringView & line)
+TaskXOver :: on_nntp_line (NNTP * nntp,
+ const StringView & line)
{
+
pan_return_if_fail (nntp != 0);
pan_return_if_fail (!nntp->_server.empty());
pan_return_if_fail (!nntp->_group.empty());
@@ -276,15 +284,29 @@ TaskXOver :: on_nntp_line (NNTP * nntp,
unsigned int lines=0u;
unsigned long bytes=0ul;
uint64_t number=0;
- StringView subj, author, date, mid, ref, tmp, xref, l(line);
+ StringView subj, author, date, mid, tmp, xref, l(line);
+ std::string ref;
bool ok = !l.empty();
- ok = ok && l.pop_token (tmp, '\t'); if (ok) number = view_to_ull (tmp);
+ ok = ok && l.pop_token (tmp, '\t'); if (ok) number = view_to_ull (tmp); tmp.clear();
ok = ok && l.pop_token (subj, '\t'); if (ok) subj.trim ();
ok = ok && l.pop_token (author, '\t'); if (ok) author.trim ();
ok = ok && l.pop_token (date, '\t'); if (ok) date.trim ();
ok = ok && l.pop_token (mid, '\t'); if (ok) mid.trim ();
- ok = ok && l.pop_token (ref, '\t'); if (ok) ref.trim ();
- ok = ok && l.pop_token (tmp, '\t'); if (ok) bytes = view_to_ul (tmp);
+
+ // bugfix: handle multiple References correctly.
+ ok = ok && l.pop_token (tmp, '\t');
+ do
+ {
+ if (tmp.empty()) continue;
+ if (tmp.front() == '<')
+ {
+ tmp.trim();
+ ref += tmp;
+ tmp.clear();
+ } else break;
+ } while (ok && l.pop_token (tmp, '\t')) ;
+
+ if (ok) bytes = view_to_ul (tmp); tmp.clear();
ok = ok && l.pop_token (tmp, '\t'); if (ok) lines = view_to_ul (tmp);
ok = ok && l.pop_token (xref, '\t'); if (ok) xref.trim ();
@@ -300,7 +322,7 @@ TaskXOver :: on_nntp_line (NNTP * nntp,
|| date.empty() // missing date
|| mid.empty() // missing mid
|| mid.front()!='<' // corrupt mid
- || (!ref.empty() && ref.front()!='<'))
+ || (!ref.empty() && ref[0] != '<'))
return;
// if news server doesn't provide an xref, fake one
@@ -329,7 +351,7 @@ TaskXOver :: on_nntp_line (NNTP * nntp,
nntp->_server, nntp->_group,
(header_is_nonencoded_utf8(subj) ? subj : header_to_utf8(subj,fallback_charset).c_str()),
(header_is_nonencoded_utf8(author) ? author : header_to_utf8(author,fallback_charset).c_str()),
- time_posted, mid, ref, bytes, lines, xref);
+ time_posted, mid, StringView(ref), bytes, lines, xref);
if (article)
++_articles_so_far;
@@ -350,7 +372,6 @@ TaskXOver :: on_nntp_done (NNTP * nntp,
Health health,
const StringView & response UNUSED)
{
- //std::cerr << LINE_ID << " nntp " << nntp->_server << " (" << nntp << ") done; checking in. health==" << health << std::endl;
update_work (true);
check_in (nntp, health);
}
@@ -375,8 +396,8 @@ TaskXOver :: update_work (bool subtract_one_from_nntp_count)
else if (nntp_count)
_state.set_working ();
else {
- _state.set_completed ();
- set_finished (OK);
+ _state.set_completed();
+ set_finished(OK);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]