[pan2/testing: 46/279] intermediate commit
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 46/279] intermediate commit
- Date: Sat, 3 Dec 2011 22:28:24 +0000 (UTC)
commit 0af62466e3086537dfcc03fb8d283fc0fc22919a
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Wed May 25 08:44:35 2011 +0200
intermediate commit
pan/data/file-queue.cc | 49 ++++------------
pan/data/file-queue.h | 48 +++-------------
pan/gui/post-ui.cc | 6 +-
pan/gui/server-ui.cc | 22 +++++++-
pan/tasks/Makefile.am | 4 +-
pan/tasks/nntp.cc | 52 ++++++++++++++++-
pan/tasks/nntp.h | 52 +----------------
pan/tasks/queue.cc | 13 +----
pan/tasks/task-xover.cc | 125 ++++++------------------------------------
pan/tasks/task-xover.h | 12 ----
pan/tasks/task-xzver-test.cc | 114 ++++++++++++++++++++++++++++++++++++++
pan/tasks/task-xzver-test.h | 61 ++++++++++++++++++++
12 files changed, 294 insertions(+), 264 deletions(-)
---
diff --git a/pan/data/file-queue.cc b/pan/data/file-queue.cc
index fd6c6e6..8225cc5 100644
--- a/pan/data/file-queue.cc
+++ b/pan/data/file-queue.cc
@@ -26,6 +26,11 @@
#include <pan/data/xref.h>
#include <pan/tasks/nntp.h>
#include <pan/tasks/task.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
#include "file-queue.h"
using namespace pan;
@@ -35,49 +40,21 @@ FileQueue :: ~FileQueue ()
FileQueue :: FileQueue() {}
-Article::PartState
-FileQueue :: get_part_state () const {
- return COMPLETE;
-}
-
void
-FileQueue :: add (const StringView & subject,
- const StringView & author,
- const StringView & filename,
- const unsigned long byte_count,
- const unsigned long line_count,
+FileQueue :: add (const char* filename,
FileQueue::InsertType type)
{
static FileData a;
- a.subject = subject;
- a.author = author;
+ struct stat sb;
a.filename = filename;
- a.byte_count = byte_count;
- a.line_count = line_count;
- a.article.is_binary = true;
- a.article.set_part_count (1); // decoder has to determine that later on
-// const FileData* new_article = &a;
-// type == FileQueue::END ?
- _articles_v.push_back(a);
-// _articles_v.push_front(a);
+ stat(filename,&sb);
+ a.byte_count = sb.st_size;
+
+ type == FileQueue::END ?
+ _articles_v.push_back(a) :
+ _articles_v.push_front(a);
}
-//void
-//FileQueue :: delete_single(const FileData* s)
-//{
-// std::set<const FileData*>::iterator it = _articles_v.find(s);
-// _articles_v.erase(it);
-//}
-//
-//void
-//FileQueue :: delete_range(const Article* a, const Article* b)
-//{
-//
-// articles_it a_it = _articles_v.find(a);
-// articles_it b_it = _articles_v.find(b);
-// if (a==b ) delete_single(a);
-// _articles_v.erase ( a_it, b_it );
-//}
diff --git a/pan/data/file-queue.h b/pan/data/file-queue.h
index 1b8ab36..87c1ae7 100644
--- a/pan/data/file-queue.h
+++ b/pan/data/file-queue.h
@@ -36,7 +36,7 @@
namespace pan {
- class FileQueue: public Article
+ class FileQueue
{
public:
@@ -45,42 +45,29 @@ namespace pan {
struct FileData
{
- StringView subject;
- StringView author;
- StringView filename;
- unsigned long byte_count;
- unsigned long line_count;
- Article article;
+
+ const char * filename;
+ unsigned long byte_count;
FileData() {}
};
- typedef std::vector<FileData>::iterator articles_it;
- typedef std::vector<FileData> articles_v;
+ typedef std::list<FileData>::iterator articles_it;
+ typedef std::list<FileData> articles_v;
articles_it end() { return _articles_v.end(); }
articles_it begin() { return _articles_v.begin(); }
- FileData get_front() { return _articles_v[0]; }
- FileData get_at(int i) { return _articles_v[(i<0 || i>_articles_v.size()) ? 0 : i]; }
bool empty() { return _articles_v.empty(); }
- articles_v& v() { return _articles_v; }
public:
enum InsertType
{ BEGIN, END };
- // article
- public:
- PartState get_part_state () const;
//own
public:
- void add (const StringView & subject,
- const StringView & author,
- const StringView & filename,
- const unsigned long byte_count,
- const unsigned long line_count,
- FileQueue::InsertType type);
+ virtual void add (const char* filename,
+ FileQueue::InsertType type);
private:
articles_v _articles_v;
@@ -88,22 +75,3 @@ namespace pan {
}
#endif
-
-// todo
-//void
-//TaskPane :: get_selected_tasks_foreach (GtkTreeModel *model, GtkTreePath *, GtkTreeIter *iter, gpointer list_g)
-//{
-// Task * task (0);
-// gtk_tree_model_get (model, iter, COL_TASK_POINTER, &task, -1);
-// static_cast<tasks_t*>(list_g)->push_back (task);
-//}
-//
-//tasks_t
-//TaskPane :: get_selected_tasks () const
-//{
-// tasks_t tasks;
-// GtkTreeView * view (GTK_TREE_VIEW (_view));
-// GtkTreeSelection * sel (gtk_tree_view_get_selection (view));
-// gtk_tree_selection_selected_foreach (sel, get_selected_tasks_foreach, &tasks);
-// return tasks;
-//}
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 4271798..2c408e2 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -728,7 +728,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
for (; it != _file_queue.end(); it, ++it, ++i) {
GMimeMessage* msg = new_message_from_ui(POSTING);
_queue.add_task (new TaskUpload (*it,profile.posting_server,msg
- ,0,TaskUpload::YENC,i),
+ ,0,TaskUpload::YENC),
Queue::BOTTOM);
}
//dbg
@@ -2010,8 +2010,8 @@ PostUI :: update_filequeue_tab()
{
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- 0, (*it)->basename,
- 1, (*it)->byte_count,
+ 0, (*it).filename,
+ 1, (*it).byte_count/1024,
-1);
}
diff --git a/pan/gui/server-ui.cc b/pan/gui/server-ui.cc
index ffca9d9..fbaba9f 100644
--- a/pan/gui/server-ui.cc
+++ b/pan/gui/server-ui.cc
@@ -91,7 +91,7 @@ namespace
d->server = server;
- int port(119), max_conn(4), age(31*3), rank(1);
+ int port(119), max_conn(4), age(31*3), rank(1), xzver(0);
std::string addr, user, pass;
if (!server.empty()) {
d->data.get_server_addr (server, addr, port);
@@ -99,6 +99,7 @@ namespace
age = d->data.get_server_article_expiration_age (server);
rank = d->data.get_server_rank (server);
max_conn = d->data.get_server_limits (server);
+ xzver = d->data.get_server_xzver_support(server);
}
pan_entry_set_text (d->address_entry, addr);
@@ -131,6 +132,18 @@ namespace
break;
}
} while (gtk_tree_model_iter_next(model, &iter));
+
+ // set the xzver combo
+ combo = GTK_COMBO_BOX (d->xzver_compression_combo);
+ model = gtk_combo_box_get_model (combo);
+ if (gtk_tree_model_get_iter_first(model, &iter)) do {
+ int that;
+ gtk_tree_model_get (model, &iter, 1, &that, -1);
+ if (that == xzver) {
+ gtk_combo_box_set_active_iter (combo, &iter);
+ break;
+ }
+ } while (gtk_tree_model_iter_next(model, &iter));
}
void
@@ -159,6 +172,11 @@ namespace
combo = GTK_COMBO_BOX (d->rank_combo);
if (gtk_combo_box_get_active_iter (combo, &iter))
gtk_tree_model_get (gtk_combo_box_get_model(combo), &iter, 1, &rank, -1);
+ int xzver (1);
+ combo = GTK_COMBO_BOX (d->xzver_compression_combo);
+ if (gtk_combo_box_get_active_iter (combo, &iter))
+ gtk_tree_model_get (gtk_combo_box_get_model(combo), &iter, 1, &xzver, -1);
+
const char * err_msg (0);
if (addr.empty())
err_msg = _("Please specify the server's address.");
@@ -180,6 +198,8 @@ namespace
d->data.set_server_limits (d->server, max_conn);
d->data.set_server_article_expiration_age (d->server, age);
d->data.set_server_rank (d->server, rank);
+ d->data.set_server_xzver_support(d->server, xzver);
+ d->data.save_server_info(d->server);
d->queue.upkeep ();
}
}
diff --git a/pan/tasks/Makefile.am b/pan/tasks/Makefile.am
index fb621d3..5609f40 100644
--- a/pan/tasks/Makefile.am
+++ b/pan/tasks/Makefile.am
@@ -10,7 +10,7 @@ libtasks_a_SOURCES = \
task-groups.cc \
task-post.cc \
task-xover.cc \
- task-xzver.cc \
+ task-xzver-test.cc \
task-upload.cc \
nntp.cc \
nzb.cc \
@@ -34,7 +34,7 @@ noinst_HEADERS = \
task-upload.h \
task-weak-ordering.h \
task-xover.h \
- task-xzver.h \
+ task-xzver-test.h \
nntp.h \
nzb.h \
queue.h \
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index 45891f2..38345d7 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -54,6 +54,51 @@ namespace
}
};
+namespace
+{
+ enum
+ {
+ AUTH_REQUIRED = 480,
+ AUTH_NEED_MORE = 381,
+ AUTH_ACCEPTED = 281,
+ AUTH_REJECTED = 482,
+
+ SERVER_READY = 200,
+ SERVER_READY_NO_POSTING = 201,
+ SERVER_READY_STREAMING_OK = 203,
+
+ GOODBYE = 205,
+
+ GROUP_RESPONSE = 211,
+ GROUP_NONEXISTENT = 411,
+
+ INFORMATION_FOLLOWS = 215,
+
+ XOVER_FOLLOWS = 224,
+ XOVER_NO_ARTICLES = 420,
+
+ ARTICLE_FOLLOWS = 220,
+
+ NEWGROUPS_FOLLOWS = 231,
+
+ ARTICLE_POSTED_OK = 240,
+ SEND_ARTICLE_NOW = 340,
+ NO_POSTING = 440,
+ POSTING_FAILED = 441,
+
+ TOO_MANY_CONNECTIONS = 400,
+
+ NO_GROUP_SELECTED = 412,
+ NO_SUCH_ARTICLE_NUMBER = 423,
+ NO_SUCH_ARTICLE = 430,
+
+ ERROR_CMD_NOT_UNDERSTOOD = 500,
+ ERROR_CMD_NOT_SUPPORTED = 501,
+ NO_PERMISSION = 502,
+ FEATURE_NOT_SUPPORTED = 503
+ };
+}
+
void
NNTP :: fire_done_func (Health health, const StringView& response)
{
@@ -179,7 +224,7 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
case XOVER_FOLLOWS:
if (_listener)
- _listener->on_xover_follows (this, line);
+ _listener->on_xover_follows(this, line);
case ARTICLE_FOLLOWS:
case NEWGROUPS_FOLLOWS:
case INFORMATION_FOLLOWS:
@@ -191,7 +236,7 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
case NO_GROUP_SELECTED:
case ERROR_CMD_NOT_UNDERSTOOD:
if (_listener)
- _listener->on_cmd_not_understood (this, line);
+ _listener->on_what(this, line);
case ERROR_CMD_NOT_SUPPORTED:
case NO_PERMISSION:
case FEATURE_NOT_SUPPORTED: {
@@ -242,7 +287,7 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
switch (state) {
case CMD_FAIL: fire_done_func (ERR_COMMAND, line); more = false; break;
case CMD_DONE: if (_commands.empty()) fire_done_func (OK, line); more = false; break;
- case CMD_MORE: more = true; break; // keep listening for more on this command
+ case CMD_MORE: more = true; break; // keep listining for more on this command
case CMD_NEXT: more = false; break; // no more responses on this command; wait for next...
case CMD_RETRY: fire_done_func (ERR_NETWORK, line); more = false; break;
default: abort(); break;
@@ -332,6 +377,7 @@ NNTP :: xover (const Quark & group,
write_next_command ();
}
+
void
NNTP :: list_newsgroups (Listener * l)
{
diff --git a/pan/tasks/nntp.h b/pan/tasks/nntp.h
index 57796e8..cf009c5 100644
--- a/pan/tasks/nntp.h
+++ b/pan/tasks/nntp.h
@@ -38,49 +38,6 @@ namespace pan
class NNTP: private Socket::Listener
{
public:
- enum ResponseType
- {
- AUTH_REQUIRED = 480,
- AUTH_NEED_MORE = 381,
- AUTH_ACCEPTED = 281,
- AUTH_REJECTED = 482,
-
- SERVER_READY = 200,
- SERVER_READY_NO_POSTING = 201,
- SERVER_READY_STREAMING_OK = 203,
-
- GOODBYE = 205,
-
- GROUP_RESPONSE = 211,
- GROUP_NONEXISTENT = 411,
-
- INFORMATION_FOLLOWS = 215,
-
- XOVER_FOLLOWS = 224,
- XOVER_NO_ARTICLES = 420,
-
- ARTICLE_FOLLOWS = 220,
-
- NEWGROUPS_FOLLOWS = 231,
-
- ARTICLE_POSTED_OK = 240,
- SEND_ARTICLE_NOW = 340,
- NO_POSTING = 440,
- POSTING_FAILED = 441,
-
- TOO_MANY_CONNECTIONS = 400,
-
- NO_GROUP_SELECTED = 412,
- NO_SUCH_ARTICLE_NUMBER = 423,
- NO_SUCH_ARTICLE = 430,
-
- ERROR_CMD_NOT_UNDERSTOOD = 500,
- ERROR_CMD_NOT_SUPPORTED = 501,
- NO_PERMISSION = 502,
- FEATURE_NOT_SUPPORTED = 503
- };
-
- public:
/**
* Base class for objects that listen for NNTP events.
@@ -132,13 +89,12 @@ namespace pan
uint64_t low UNUSED,
uint64_t high UNUSED) {}
+ virtual void on_xover_follows (NNTP * nntp UNUSED,
+ const StringView & line UNUSED) {}
- //both functions are implemented for xzver testing(!)
- virtual void on_xover_follows (NNTP * nntp UNUSED,
- const StringView & line UNUSED) {}
- virtual void on_cmd_not_understood (NNTP * nntp UNUSED,
- const StringView & line UNUSED) {}
+ virtual void on_what (NNTP * nntp UNUSED,
+ const StringView & line UNUSED) {}
};
diff --git a/pan/tasks/queue.cc b/pan/tasks/queue.cc
index d4ee76f..ce9de63 100644
--- a/pan/tasks/queue.cc
+++ b/pan/tasks/queue.cc
@@ -550,9 +550,6 @@ Queue :: task_is_active (const Task * task) const
if (task && task==_decoder_task)
return true;
- if (task && task==_encoder_task)
- return true;
-
bool task_has_nntp (false);
foreach_const (nntp_to_task_t, _nntp_to_task, it)
if ((task_has_nntp = task==it->second))
@@ -602,17 +599,13 @@ Queue :: get_all_task_states (task_states_t& setme)
setme.tasks.reserve(_tasks.size());
std::vector<Task *> & need_decode = setme._need_decode.get_container();
- std::vector<Task *> & need_encode = setme._need_encode.get_container();
- need_decode.clear(); need_encode.clear();
+ need_decode.clear();
need_decode.reserve(setme.tasks.capacity());
- need_encode.reserve(setme.tasks.capacity());
foreach(TaskSet, _tasks, it) {
setme.tasks.push_back(*it);
if ((*it)->get_state()._work == Task::NEED_DECODER)
need_decode.push_back(*it);
- if ((*it)->get_state()._work == Task::NEED_ENCODER)
- need_encode.push_back(*it);
}
setme._need_decode.sort();
@@ -634,7 +627,6 @@ Queue :: get_all_task_states (task_states_t& setme)
running.insert (running.end(), tmp.begin(), tmp.end());
setme._decoding = _decoder_task;
- setme._encoding = _encoder_task;
}
void
@@ -686,7 +678,6 @@ Queue :: check_in (Decoder* decoder UNUSED, Task* task)
{
// take care of our decoder counting...
_decoder_task = 0;
- _encoder_task = 0;
// notify the listeners if the task isn't active anymore...
if (!task_is_active (task))
@@ -707,7 +698,7 @@ Queue :: check_in (Decoder* decoder UNUSED, Task* task)
}
void
-Queue :: check_in (Encoder* encoder UNUSED, Task* task)
+Queue :: check_in (Encoder* decoder UNUSED, Task* task)
{
// take care of our decoder counting...
_encoder_task = 0;
diff --git a/pan/tasks/task-xover.cc b/pan/tasks/task-xover.cc
index a3a4b80..40b292f 100644
--- a/pan/tasks/task-xover.cc
+++ b/pan/tasks/task-xover.cc
@@ -17,18 +17,12 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-int cnt = 0; //dbg
-
#include <config.h>
#include <cassert>
#include <cerrno>
extern "C" {
- #include <stdio.h>
- #define PROTOTYPES
- #include <uulib/uudeview.h>
#include <glib/gi18n.h>
#include <gmime/gmime-utils.h>
- #include <zlib.h>
}
#include <pan/general/debug.h>
#include <pan/general/macros.h>
@@ -37,7 +31,6 @@ extern "C" {
#include <pan/data/data.h>
#include "nntp.h"
#include "task-xover.h"
-#include "task-xzver.h"
using namespace pan;
@@ -82,38 +75,6 @@ namespace
snprintf (buf, sizeof(buf), _("Sampling headers for \"%s\""), group.c_str());
return std::string (buf);
}
-
- void decompress(const Quark& server, std::string stream)
- {
- char buf[512];
- int res(UURET_OK);
- const char* server_string = server.to_string().c_str();
- const char* uulib_dir = (file :: get_pan_uulib_dir()).c_str();
-
- g_snprintf(buf,512,"%s/%s.%s", uulib_dir, "headers.gz.yenc",server_string);
- std::ofstream out(buf);
-
- out << "=ybegin line=128 size=-1 name=headers.gz\r\n";
- out<< stream;
- out << "\r\n=yend crc=FFFFFFFF\r\n.\r\n";
- out.flush();
- out.close();
- UULoadFile (NULL, 0, 0);
- g_snprintf(buf,512,"%s/%s.%s", uulib_dir, "headers.gz",server_string);
- if ((res=UUDecodeFile(UUGetFileListItem (0), buf))==UURET_OK) {
- gzFile zf = gzopen(buf,"rb");
- g_snprintf(buf,512,"%s/%s.%s", uulib_dir, "headers",server_string);
- std::ofstream gz_buf(buf);
- int res_gz(0);
- while (1)
- {
- if ((res_gz=gzread(zf,buf,512))<=0) break;
- gz_buf<<buf;
- }
- gzclose(zf);
- gz_buf.close();
- }
- }
}
TaskXOver :: TaskXOver (Data & data,
@@ -131,23 +92,18 @@ TaskXOver :: TaskXOver (Data & data,
_bytes_so_far (0),
_parts_so_far (0ul),
_articles_so_far (0ul),
- _total_minitasks (0),
- _need_decompress (0ul)
+ _total_minitasks (0)
{
+ debug ("ctor for " << group);
// add a ``GROUP'' MiniTask for each server that has this group
// initialize the _high lookup table to boundaries
const MiniTask group_minitask (MiniTask::GROUP);
quarks_t servers;
- _data.group_get_servers (group, _servers);
-
- //dbg
- servers = _servers;
-
+ _data.group_get_servers (group, servers);
foreach_const (quarks_t, servers, it)
if (_data.get_server_limits(*it))
{
- if(_data.get_server_xzver_support(*it)==1) std::cerr<<"xzver support on server"<<*it<<std::endl;
_server_to_minitasks[*it].push_front (group_minitask);
_high[*it] = data.get_xover_high (group, *it);
}
@@ -172,9 +128,7 @@ void
TaskXOver :: use_nntp (NNTP* nntp)
{
const Quark& server (nntp->_server);
-
- // test for compression
- const bool compression (_data.get_server_xzver_support(server) == 1);
+ debug ("got an nntp from " << nntp->_server);
// if this is the first nntp we've gotten, ref the xover data
if (!_group_xover_is_reffed) {
@@ -202,10 +156,7 @@ TaskXOver :: use_nntp (NNTP* nntp)
case MiniTask::XOVER:
debug ("XOVER " << mt._low << '-' << mt._high << " to " << server);
_last_xover_number[nntp] = mt._low;
- if (!compression)
- nntp->xover (_group, mt._low, mt._high, this);
- else
- nntp->xzver (_group, mt._low, mt._high, this);
+ nntp->xover (_group, mt._low, mt._high, this);
break;
default:
assert (0);
@@ -225,16 +176,13 @@ TaskXOver :: on_nntp_group (NNTP * nntp,
uint64_t low,
uint64_t high)
{
- const Quark& server (nntp->_server);
-
- // test for compression
- const bool compression (_data.get_server_xzver_support(server) == 1);
+ const Quark& servername (nntp->_server);
// new connections can tickle this...
- if (_servers_that_got_xover_minitasks.count(server))
+ if (_servers_that_got_xover_minitasks.count(servername))
return;
- _servers_that_got_xover_minitasks.insert (server);
+ _servers_that_got_xover_minitasks.insert (servername);
debug ("got GROUP result from " << nntp->_server << " (" << nntp << "): "
<< " qty " << qty
@@ -262,24 +210,14 @@ TaskXOver :: on_nntp_group (NNTP * nntp,
{
//std::cerr << LINE_ID << " okay, I'll try to get articles in [" << l << "..." << h << ']' << std::endl;
add_steps (h-l);
-
- int INCREMENT(0);
-
- if (!compression)
- INCREMENT = 1000;
- else
- INCREMENT = 10000;
-
- MiniTasks_t& minitasks (_server_to_minitasks[server]);
+ const int INCREMENT (1000);
+ MiniTasks_t& minitasks (_server_to_minitasks[servername]);
for (uint64_t m=l; m<=h; m+=INCREMENT) {
MiniTask mt (MiniTask::XOVER, m, m+INCREMENT);
- debug ("adding MiniTask for " << server << ": xover [" << mt._low << '-' << mt._high << ']');
+ debug ("adding MiniTask for " << servername << ": xover [" << mt._low << '-' << mt._high << ']');
minitasks.push_front (mt);
++_total_minitasks;
}
- // give server its stream
-
-
}
else
{
@@ -329,25 +267,6 @@ void
TaskXOver :: on_nntp_line (NNTP * nntp,
const StringView & line)
{
- const bool compression (_data.get_server_xzver_support(nntp->_server) == 1);
- if (!compression)
- on_nntp_line_process(nntp,line);
- else {
- _streams[nntp->_server] += line.str;
- _bytes_so_far += line.len;
-
- // emit a status update
- uint64_t& prev = _last_xover_number[nntp];
- increment_step (1);
- if (!(_parts_so_far % 500))
- set_status_va (_("%s (%lu parts, %lu articles)"), _short_group_name.c_str(), _parts_so_far, _articles_so_far);
- }
-}
-
-void
-TaskXOver :: on_nntp_line_process (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());
@@ -429,12 +348,11 @@ TaskXOver :: on_nntp_line_process (NNTP * nntp,
void
TaskXOver :: on_nntp_done (NNTP * nntp,
Health health,
- const StringView & response)
+ const StringView & response UNUSED)
{
-
- std::cerr<<"nntp done on server "<<nntp->_server<<std::endl;
- update_work (true);
- check_in (nntp, health);
+ //std::cerr << LINE_ID << " nntp " << nntp->_server << " (" << nntp << ") done; checking in. health==" << health << std::endl;
+ update_work (true);
+ check_in (nntp, health);
}
void
@@ -444,8 +362,6 @@ TaskXOver :: update_work (bool subtract_one_from_nntp_count)
if (subtract_one_from_nntp_count)
--nntp_count;
- std::cerr<<"update work "<<std::endl;
-
// find any servers we still need
quarks_t servers;
foreach_const (server_to_minitasks_t, _server_to_minitasks, it)
@@ -459,20 +375,14 @@ TaskXOver :: update_work (bool subtract_one_from_nntp_count)
else if (nntp_count)
_state.set_working ();
else {
- foreach_const (stream_t, _streams, it)
- {
- decompress(it->first, it->second);
-// feed_lines(_stream);
- }
- _state.set_completed ();
- set_finished (OK);
+ _state.set_completed ();
+ set_finished (OK);
}
}
unsigned long
TaskXOver :: get_bytes_remaining () const
{
- return 0ul;
unsigned int minitasks_left (0);
foreach_const (server_to_minitasks_t, _server_to_minitasks, it)
minitasks_left += it->second.size();
@@ -481,6 +391,5 @@ TaskXOver :: get_bytes_remaining () const
if (percent_done < 0.1) // impossible to estimate
return 0;
const unsigned long total_bytes = (unsigned long)(_bytes_so_far / percent_done);
- std::cerr<<std::endl<<"bytes remaining: "<<total_bytes - _bytes_so_far<<", percent: "<<percent_done<<std::endl;
return total_bytes - _bytes_so_far;
}
diff --git a/pan/tasks/task-xover.h b/pan/tasks/task-xover.h
index 8b63163..8701808 100644
--- a/pan/tasks/task-xover.h
+++ b/pan/tasks/task-xover.h
@@ -22,15 +22,10 @@
#include <map>
#include <vector>
-#include <sstream>
-#include <iostream>
-#include <fstream>
-#include <pan/general/log.h>
#include <pan/data/data.h>
#include <pan/tasks/task.h>
#include <pan/tasks/nntp.h>
-#include <pan/general/file-util.h>
namespace pan
{
@@ -53,7 +48,6 @@ namespace pan
private: // NNTP::Listener
virtual void on_nntp_line (NNTP*, const StringView&);
- virtual void on_nntp_line_process (NNTP*, const StringView&);
virtual void on_nntp_done (NNTP*, Health, const StringView&);
virtual void on_nntp_group (NNTP*, const Quark&, unsigned long, uint64_t, uint64_t);
@@ -67,9 +61,7 @@ namespace pan
};
typedef std::deque<MiniTask> MiniTasks_t;
typedef std::map<Quark,MiniTasks_t> server_to_minitasks_t;
- typedef std::map<Quark,std::string> stream_t;
server_to_minitasks_t _server_to_minitasks;
- stream_t _streams;
private: // implementation
Data& _data;
@@ -88,10 +80,6 @@ namespace pan
unsigned long _parts_so_far;
unsigned long _articles_so_far;
unsigned long _total_minitasks;
- unsigned long _need_decompress;
- std::stringstream _stream;
- quarks_t _servers; // dbg
-
};
}
diff --git a/pan/tasks/task-xzver-test.cc b/pan/tasks/task-xzver-test.cc
new file mode 100644
index 0000000..7411339
--- /dev/null
+++ b/pan/tasks/task-xzver-test.cc
@@ -0,0 +1,114 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Pan - A Newsreader for Gtk+
+ * Copyright (C) 2002-2006 Charles Kerr <charles rebelbase com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <config.h>
+#include <cassert>
+#include <cerrno>
+extern "C" {
+ #include <glib/gi18n.h>
+ #include <gmime/gmime-utils.h>
+}
+#include <pan/general/debug.h>
+#include <pan/general/macros.h>
+#include <pan/general/messages.h>
+#include <pan/general/utf8-utils.h>
+#include <pan/data/data.h>
+#include "nntp.h"
+#include "task-xzver-test.h"
+
+using namespace pan;
+
+namespace
+{
+ std::string get_description (void)
+ {
+ char buf[1024];
+ snprintf (buf, sizeof(buf), _("Testing for XZVER Header compression on current server ...."));
+ return std::string (buf);
+ }
+}
+
+TaskXZVerTest :: TaskXZVerTest (Data & data,
+ const Quark & server) :
+ Task("XOVER", get_description()),
+ _data (data),
+ _server (server)
+{
+ _state.set_need_nntp(_server);
+}
+
+TaskXZVerTest :: ~TaskXZVerTest ()
+{}
+
+void
+TaskXZVerTest :: use_nntp (NNTP* nntp)
+{
+ nntp->group (Quark("alt.binaries.test"), this);
+}
+
+/***
+****
+***/
+
+void
+TaskXZVerTest :: on_nntp_group (NNTP * nntp,
+ const Quark & group,
+ unsigned long qty,
+ uint64_t low,
+ uint64_t high)
+{
+ nntp->xzver(group, high-100, high,this);
+}
+
+void
+TaskXZVerTest :: on_nntp_line (NNTP * nntp,
+ const StringView & line)
+{}
+
+void
+TaskXZVerTest :: on_what (NNTP * nntp,
+ const StringView & line)
+{
+ _state.set_completed ();
+ set_finished (OK);
+ check_in (nntp, OK);
+ _data.set_server_xzver_support(nntp->_server,0);
+}
+
+void
+TaskXZVerTest :: on_xover_follows (NNTP * nntp,
+ const StringView & line)
+{
+ _state.set_completed ();
+ set_finished (OK);
+ check_in (nntp, OK);
+ _data.set_server_xzver_support(nntp->_server,1);
+}
+
+
+void
+TaskXZVerTest :: on_nntp_done (NNTP * nntp,
+ Health health,
+ const StringView & response UNUSED)
+{
+ _state.set_completed ();
+ set_finished (OK);
+ check_in (nntp, health);
+}
+
diff --git a/pan/tasks/task-xzver-test.h b/pan/tasks/task-xzver-test.h
new file mode 100644
index 0000000..662fd15
--- /dev/null
+++ b/pan/tasks/task-xzver-test.h
@@ -0,0 +1,61 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Pan - A Newsreader for Gtk+
+ * Copyright (C) 2002-2006 Charles Kerr <charles rebelbase com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __TASK_XZVER_TEST_H__
+#define __TASK_XZVER_TEST_H__
+
+#include <map>
+#include <vector>
+
+#include <pan/data/data.h>
+#include <pan/tasks/task.h>
+#include <pan/tasks/nntp.h>
+
+namespace pan
+{
+ /**
+ * Task for downloading a some or all of a newsgroups' headers
+ * @ingroup tasks
+ */
+ class TaskXZVerTest: public Task, private NNTP::Listener
+ {
+ public: // life cycle
+ TaskXZVerTest (Data& data, const Quark& server);
+ virtual ~TaskXZVerTest ();
+
+ public: // task subclass
+ virtual unsigned long get_bytes_remaining () const { return 0ul;}
+
+ protected: // task subclass
+ virtual void use_nntp (NNTP * nntp);
+
+ private: // NNTP::Listener
+ virtual void on_nntp_line (NNTP*, const StringView&);
+ virtual void on_xover_follows (NNTP*, const StringView&);
+ virtual void on_what (NNTP*, const StringView&);
+ virtual void on_nntp_done (NNTP*, Health, const StringView&);
+ virtual void on_nntp_group (NNTP*, const Quark&, unsigned long, uint64_t, uint64_t);
+
+ private: // implementation
+ Data& _data;
+ const Quark _server;
+ };
+}
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]