[pan2: 62/268] fully working for me, please debug and send bug reports to me.



commit 20c88902a47cbe5abc9f69937c62a821fdb491b5
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Mon Jun 13 18:12:33 2011 +0200

    fully working for me, please debug and send bug reports to me.

 pan/gui/post-ui.cc             |   65 +++++++++++++++++++++++++++++++--------
 pan/gui/post-ui.h              |   13 ++++----
 pan/tasks/encoder.cc           |   14 ++++----
 pan/tasks/encoder.h            |    4 +-
 pan/tasks/nntp.cc              |   26 ++--------------
 pan/tasks/nntp.h               |   34 +-------------------
 pan/tasks/nzb.cc               |   17 +++-------
 pan/tasks/task-upload.cc       |   22 ++++----------
 pan/tasks/task-upload.h        |    7 ++--
 pan/tasks/task-xover.cc        |   56 +---------------------------------
 pan/tasks/task-xover.h         |    7 ----
 pan/usenet-utils/mime-utils.cc |   28 -----------------
 pan/usenet-utils/mime-utils.h  |   29 ++++++++++++++++++
 13 files changed, 117 insertions(+), 205 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 6022a43..f89011b 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -542,7 +542,7 @@ namespace
 void
 PostUI :: close_window (bool flag)
 {
-  bool destroy_flag (false || flag);
+  bool destroy_flag (flag);
 
   if (get_body() == _unchanged_body)
     destroy_flag = true;
@@ -769,7 +769,6 @@ PostUI :: send_and_save_now ()
 
   _save_file.clear();
   _save_file = prompt_user_for_upload_nzb_dir (GTK_WINDOW (gtk_widget_get_toplevel(_root)), _prefs);
-  // update all tasks in queue with save file
   foreach (tasks_t, tasks, it)
     (*it)->_save_file = _save_file;
 
@@ -868,16 +867,38 @@ void
 PostUI :: on_progress_finished (Progress&, int status) // posting finished
 {
 
-  ///Listener for taskupload??
-
-  _post_task->remove_listener (this);
-  gtk_widget_destroy (_post_dialog);
-
-  GMimeMessage * message (_post_task->get_message ());
+  if (_file_queue_empty)
+  {
+    _post_task->remove_listener (this);
+    GMimeMessage * message (_post_task->get_message ());
     if (status != OK) // error posting.. stop.
       done_sending_message (message, false);
     else
       maybe_mail_message (message);
+    gtk_widget_destroy (_post_dialog);
+  } else
+  {
+    if (!_save_file.empty())
+    {
+//      mut.lock();
+        int no = status;
+        std::cerr<<"saving to file "<<_save_file<<" from upload no. "<<no<<std::endl;
+        TaskUpload * ptr = _upload_queue[no];
+        std::cerr<<"saving to file (mutex) "<<_save_file<<std::endl;
+        if (ptr) NZB :: upload_list_to_xml_file (_out, ptr->_upload_list);
+        --_running_uploads;
+        std::cerr<<"running uploads now : "<<_running_uploads<<"\n";
+        if (_running_uploads==0 )
+        {
+          _out << "</nzb>\n";
+          _out.close();
+          close_window(true);
+        }
+//      mut.unlock();
+    }
+
+  }
+
 }
 
 void
@@ -892,6 +913,7 @@ PostUI :: on_progress_error (Progress&, const StringView& message)
   gtk_widget_show (d);
 }
 
+
 bool
 PostUI :: maybe_post_message (GMimeMessage * message)
 {
@@ -982,15 +1004,28 @@ PostUI :: maybe_post_message (GMimeMessage * message)
     _post_task->add_listener (this);
     _queue.add_task (_post_task, Queue::TOP);
   } else {
+
+    if (!_save_file.empty())
+    {
+      _out.open(_save_file.c_str(), std::fstream::out | std::fstream::app);
+      _out << "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
+      << "<!DOCTYPE nzb PUBLIC \"-//newzBin//DTD NZB 1.0//EN\" \"http://www.newzbin.com/DTD/nzb/nzb-1.0.dtd\";>\n"
+      << "<nzb xmlns=\"http://www.newzbin.com/DTD/2003/nzb\";>\n";
+    }
+
     PostUI::tasks_t tasks;
     _upload_queue.get_all_tasks(tasks);
+    int cnt(0);
+    _running_uploads = tasks.size();
+
     foreach (PostUI::tasks_t, tasks, it)
     {
+      (*it)->_queue_pos = cnt++;
       _queue.add_task (*it, Queue::BOTTOM);
-//      (*it)->add_listener(this);
-//      _upload_listeners.insert(*it);
+      (*it)->add_listener(this);
+      _upload_listeners.push_back(*it);
     }
-     close_window(true); // dont wait for the upload queue
+    gtk_widget_hide (_root); // dont wait for the upload queue
   }
 
   /**
@@ -2534,7 +2569,7 @@ PostUI :: select_parts ()
 
   if (!_upload_ptr) return;
 
-  _total_parts = (int) (((long)_upload_ptr->get_byte_count() + (4000*128-1)) / (4000*128));
+  _total_parts = (int) (((long)_upload_ptr->get_byte_count() + (4000*YENC_HALF_LINE_LEN-1)) / (4000*YENC_HALF_LINE_LEN));
 
   GtkWidget * w;
   GtkTreeIter iter;
@@ -2612,7 +2647,8 @@ PostUI :: PostUI (GtkWindow    * parent,
   _group_entry_changed_idle_tag (0),
   _file_queue_empty(true),
   _upload_ptr(0),
-  _total_parts(0)
+  _total_parts(0),
+  _running_uploads(0)
 {
 
   _upload_queue.add_listener (this);
@@ -2763,7 +2799,8 @@ PostUI :: prompt_user_for_queueable_files (GtkWindow * parent, const Prefs& pref
 		  a.subject = subject;
 		  a.author = author;
       stat ((const char*)cur->data,&sb);
-      int total = (int) (((long)sb.st_size + (4000*128-1)) / (4000*128));
+      int total = (int) (((long)sb.st_size + (YENC_LINES_PER_FILE*YENC_HALF_LINE_LEN-1)) /
+                          (YENC_LINES_PER_FILE*YENC_HALF_LINE_LEN));
 
       char* basename = g_path_get_basename((const char*)cur->data);
       TaskUpload::needed_t import;
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index 1629c05..35f28e9 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -27,7 +27,6 @@
 #include <pan/tasks/upload-queue.h>
 #include <pan/usenet-utils/text-massager.h>
 #include <pan/data/encode-cache.h>
-//#include <pan/tasks/upload-queue.h>
 #include "group-prefs.h"
 
 namespace pan
@@ -37,8 +36,6 @@ namespace pan
   class UploadQueue;
   class Queue;
 
-
-
   /**
    * Dialog for posting new messages Pan's GTK GUI.
    * @ingroup GUI
@@ -113,6 +110,9 @@ namespace pan
       virtual void on_progress_finished (Progress&, int status);
       virtual void on_progress_error (Progress&, const StringView&);
 
+      virtual void on_progress_step (Progress&, int p) {}
+      virtual void on_progress_status (Progress&, const StringView& s) {}
+
     private:
       Data& _data;
       Queue& _queue;
@@ -146,8 +146,7 @@ namespace pan
       std::string _current_signature;
       GtkWidget * _post_dialog;
       TaskPost * _post_task;
-      std::set<TaskUpload*> _upload_listeners;
-      std::vector<Article*> _uploaded;
+      std::vector<TaskUpload*> _upload_listeners;
       typedef std::map<std::string, std::string> str2str_t;
       str2str_t _hidden_headers;
       str2str_t _profile_headers;
@@ -221,7 +220,9 @@ namespace pan
     private:
       TaskUpload* upload_ptr() { return _upload_ptr; }
       UploadQueue _upload_queue;
-
+      Mutex mut;
+      int _running_uploads;
+      std::ofstream _out;
   };
 }
 
diff --git a/pan/tasks/encoder.cc b/pan/tasks/encoder.cc
index 9447c3c..5c6329f 100644
--- a/pan/tasks/encoder.cc
+++ b/pan/tasks/encoder.cc
@@ -86,7 +86,7 @@ Encoder :: ~Encoder()
 void
 Encoder :: enqueue (TaskUpload                      * task,
                     EncodeCache                     * cache,
-                    Article                           article,
+                    Article                         * article,
                     std::string                     & filename,
                     std::string                     & basename,
                     std::string                     & groups,
@@ -149,14 +149,14 @@ Encoder :: do_work()
       PartBatch batch;
       batch.init(StringView(basename), needed->size(), 0);
       int cnt(1);
-      Article* tmp = new Article(article);
+      Article* tmp = article;
 
       /* build real subject line */
       g_snprintf(buf, sizeof(buf), "\"%s\" - %s (/%03d)", basename.c_str(), subject.c_str(), needed->size());
       tmp->subject = buf;
 
       char cachename[4096];
-      for (TaskUpload::needed_t::iterator it = needed->begin(); it != needed->end(); ++it, it, ++cnt)
+      for (TaskUpload::needed_t::iterator it = needed->begin(); it != needed->end(); ++it, ++cnt)
       {
         FILE * fp = cache->get_fp_from_mid(it->second.message_id);
         if (!fp)
@@ -178,13 +178,14 @@ Encoder :: do_work()
                                (char*)subject.c_str(), s.empty() ? NULL : (char*)s.c_str(), (char*)format.c_str(), 0);
 
         if (fp) fclose(fp);
+//        if (res != UURET_CONT && res != UURET_OK) break;
         cache->finalize(it->second.message_id);
-        if (res != UURET_CONT) break;
         cache->get_filename(cachename, Quark(it->second.message_id));
         stat (cachename, &sb);
         it->second.bytes  = sb.st_size;
         task->_all_bytes += sb.st_size;
         batch.add_part(cnt, StringView(s), sb.st_size);
+        if (res != UURET_CONT) break;
       }
 
       if (res != UURET_OK && res != UURET_CONT)
@@ -199,7 +200,6 @@ Encoder :: do_work()
         log_errors.push_back(buf); // log error
       } else
       { // prepare article for upload list
-        batch.add_part(cnt, StringView(s), sb.st_size);
         tmp->set_parts(batch);
         task->_upload_list.push_back(tmp);
       }
@@ -281,8 +281,8 @@ Encoder :: progress_update_timer_func (gpointer decoder)
   if (!task || self->was_cancelled()) return false;
 
   self->mut.lock();
-  const double percent (self->percent);
-  const std::string f (content_to_utf8 (self->current_file));
+    const double percent (self->percent);
+    const std::string f (content_to_utf8 (self->current_file));
   self->mut.unlock();
 
   task->set_step(int(percent));
diff --git a/pan/tasks/encoder.h b/pan/tasks/encoder.h
index d2fc199..5562a96 100644
--- a/pan/tasks/encoder.h
+++ b/pan/tasks/encoder.h
@@ -63,7 +63,7 @@ namespace pan
 
       void enqueue (TaskUpload                      * task,
                     EncodeCache                     * cache,
-                    Article                           article,
+                    Article                         * article,
                     std::string                     & filename,
                     std::string                     & basename,
                     std::string                     & groups,
@@ -93,7 +93,7 @@ namespace pan
       EncodeCache * cache;
       TaskUpload::needed_t * needed;
       std::string global_mid;
-      Article article;
+      Article * article;
       MTRand mtrand;
 
       void generate_unique_id (StringView& mid, int cnt, std::string& s);
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index 59edf26..2b6da4c 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -78,7 +78,7 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
    StringView line (line_in);
 
    // strip off trailing \r\n
-   if (line.len>=2 && line.str[line.len-2]=='\r' && line.str[line.len-1]=='\n' && !_xzver)
+   if (line.len>=2 && line.str[line.len-2]=='\r' && line.str[line.len-1]=='\n')
      line.truncate (line.len-2);
 
 //    std::cerr <<"_nntp_response_text: " << _nntp_response_text<<std::endl;
@@ -93,7 +93,7 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
       {
          state = CMD_MORE;
 
-         if (line.len>=2 && line.str[0]=='.' && line.str[1]=='.' && !_xzver) // rfc 977: 2.4.1
+         if (line.len>=2 && line.str[0]=='.' && line.str[1]=='.') // rfc 977: 2.4.1
             line.rtruncate (line.len-1);
 
          assert (_listener != 0);
@@ -184,9 +184,6 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
          break;
 
       case XOVER_FOLLOWS:
-        if (_listener)
-          _listener->on_xover_follows(this, line);
-        if (line.strstr("compressed")) _xzver = true;
       case ARTICLE_FOLLOWS:
       case NEWGROUPS_FOLLOWS:
       case INFORMATION_FOLLOWS:
@@ -246,7 +243,7 @@ NNTP :: on_socket_response (Socket * sock UNUSED, const StringView& line_in)
    bool more;
    switch (state) {
       case CMD_FAIL: fire_done_func (ERR_COMMAND, line); more = false; break;
-      case CMD_DONE: _xzver = false; if (_commands.empty()) fire_done_func (OK, 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 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;
@@ -305,28 +302,11 @@ NNTP :: help (Listener * l)
 }
 
 void
-NNTP :: xzver (const Quark   & group,
-               uint64_t        low,
-               uint64_t        high,
-               Listener      * l)
-{
-   _listener = l;
-
-   if (group != _group)
-      _commands.push_back (build_command ("GROUP %s\r\n", group.c_str()));
-
-   _commands.push_back (build_command ("XZVER %"G_GUINT64_FORMAT"-%"G_GUINT64_FORMAT"\r\n", low, high));
-
-   write_next_command ();
-}
-
-void
 NNTP :: xover (const Quark   & group,
                uint64_t        low,
                uint64_t        high,
                Listener      * l)
 {
-  _xzver = false;
    _listener = l;
 
    if (group != _group)
diff --git a/pan/tasks/nntp.h b/pan/tasks/nntp.h
index 5cd9fd0..c913600 100644
--- a/pan/tasks/nntp.h
+++ b/pan/tasks/nntp.h
@@ -135,14 +135,6 @@ namespace pan
                                     uint64_t             low           UNUSED,
                                     uint64_t             high          UNUSED) {}
 
-        // for xzver-test
-        virtual void on_xover_follows  (NNTP               * nntp UNUSED,
-                                        const StringView   & line UNUSED) {}
-
-
-        virtual void on_what        (NNTP               * nntp UNUSED,
-                                    const StringView    & line UNUSED) {}
-
        };
 
       public:
@@ -157,10 +149,8 @@ namespace pan
           _listener(0),
           _username(username),
           _password(password),
-          _nntp_response_text(false),
-          _xzver(false)
-       {
-       }
+          _nntp_response_text(false)
+       {}
 
        virtual ~NNTP ()
        {
@@ -196,24 +186,6 @@ namespace pan
                              Listener           * l);
 
       /**
-       * Executes an XZVER command: "XZVER low-high"
-       *
-       * If successful, this will invoke Listener::on_nntp_line()
-       * for each article header line we get back.
-       *
-       * Listener::on_nntp_done() will be called whether the
-       * command is successful or not.
-       *
-       * The lines are zlib-compressed and then yenc-encoded,
-       * so we decode the file on HDD and uncompress it.
-       * After that, the file is fed back to Listener::on_nntp_line()
-       */
-      void xzver            (const Quark   & group,
-                             uint64_t        low,
-                             uint64_t        high,
-                             Listener      * l);
-
-      /**
        * Executes a LIST command: "LIST"
        *
        * If successful, this will invoke Listener::on_nntp_line()
@@ -339,8 +311,6 @@ namespace pan
       virtual void on_socket_error (Socket*);
       virtual void on_socket_abort (Socket*);
 
-      bool _xzver;
-
     public:
 
       /**
diff --git a/pan/tasks/nzb.cc b/pan/tasks/nzb.cc
index 0ffca03..62f38c5 100644
--- a/pan/tasks/nzb.cc
+++ b/pan/tasks/nzb.cc
@@ -336,8 +336,8 @@ NZB :: nzb_to_xml (std::ostream             & out,
         // serialize this part
         out << indent(depth)
             << "<segment" << " bytes=\"" << it.bytes() << '"'
-                          << " number=\"" << it.number() << '"'
-                          << ">";
+            << " number=\"" << it.number() << '"'
+            << ">";
         escaped(out, mid);
         out  << "</segment>\n";
       }
@@ -382,8 +382,8 @@ NZB :: nzb_to_xml (std::ostream             & out,
       {
         out << indent(depth)
             << "<part" << " bytes=\"" << it->second.bytes << '"'
-                          << " number=\"" << it->second.partno << '"'
-                          << ">";
+            << " number=\"" << it->second.partno << '"'
+            << ">";
         escaped(out, it->second.message_id);
         out  << "</part>\n";
       }
@@ -403,11 +403,6 @@ NZB :: upload_list_to_xml_file (std::ostream& out,
 {
 int depth (0);
 
-  out << "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
-      << "<!DOCTYPE nzb PUBLIC \"-//newzBin//DTD NZB 1.0//EN\" \"http://www.newzbin.com/DTD/nzb/nzb-1.0.dtd\";>\n"
-      << indent(depth++)
-      << "<nzb xmlns=\"http://www.newzbin.com/DTD/2003/nzb\";>\n";
-
   foreach_const (std::vector<Article*>, tasks, it)
   {
     Article * task (dynamic_cast<Article*>(*it));
@@ -432,7 +427,7 @@ int depth (0);
     out << indent(depth++) << "<segments>\n";
     for (Article::part_iterator it(a.pbegin()), end(a.pend()); it!=end; ++it)
     {
-      std::string mid = it.mid ();
+      std::string mid  = it.mid ();
 
       // remove the surrounding < > as per nzb spec
       if (mid.size()>=2 && mid[0]=='<') {
@@ -451,8 +446,6 @@ int depth (0);
     out << indent(--depth) << "</segments>\n";
     out << indent(--depth) << "</file>\n";
   }
-
-  out << indent(--depth) << "</nzb>\n";
   return out;
 }
 
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 9394606..1b09efb 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -100,13 +100,11 @@ TaskUpload :: TaskUpload (const std::string         & filename,
   _encoder(0),
   _encoder_has_run (false),
   _encode_mode(enc),
-  _lines_per_file(4000),
   _all_bytes(0),
   _format(format),
-  _save_file(format.save_file)
+  _save_file(format.save_file),
+  _queue_pos(0)
 {
-  if (listener != 0)
-    add_listener (listener);
 
   if (!format.domain.empty())  _domain = get_domain(StringView(format.domain)) ;
 
@@ -126,7 +124,8 @@ void
 TaskUpload :: build_needed_tasks(bool imported)
 {
 
-  _total_parts = (int) (((long)get_byte_count() + (4000*128-1)) / (4000*128));
+  _total_parts = (int) (((long)get_byte_count() + (YENC_LINES_PER_FILE*YENC_HALF_LINE_LEN-1)) /
+                        (YENC_LINES_PER_FILE*YENC_HALF_LINE_LEN));
   int cnt(1);
 
   quarks_t groups;
@@ -166,7 +165,7 @@ TaskUpload :: update_work (NNTP* checkin_pending)
   } else if (_needed.empty())
   {
     _state.set_completed();
-    set_finished(OK);
+    set_finished(_queue_pos);
   }
 }
 
@@ -355,7 +354,7 @@ TaskUpload :: use_encoder (Encoder* encoder)
   format_s << "\"%s\""; // will be filled in by uuencode
   format_s << " (%d/%d) yEnc";     // will be filled in by uuencode
   std::string format(format_s.str());
-  _encoder->enqueue (this, &_cache, _article, _filename, _basename,
+  _encoder->enqueue (this, &_cache, &_article, _filename, _basename,
                      groups, _subject, _author, format , _domain, YENC);
   debug ("encoder thread was free, enqueued work");
 }
@@ -411,13 +410,4 @@ TaskUpload :: ~TaskUpload ()
 
   _cache.release(_mids);
   _cache.resize();
-
-  ///TODO properly enclose all tasks in nzb tags (listener needed ...(??) )
-//  if (!_save_file.empty())
-//  {
-//     std::cerr<<"saving to file "<<_save_file<<std::endl;
-//     std::ofstream out(_save_file.c_str(), std::fstream::out | std::fstream::app);
-//     NZB :: upload_list_to_xml_file (out, _upload_list);
-//     out.close();
-//  }
 }
diff --git a/pan/tasks/task-upload.h b/pan/tasks/task-upload.h
index 4c2924d..b4fe01b 100644
--- a/pan/tasks/task-upload.h
+++ b/pan/tasks/task-upload.h
@@ -44,8 +44,8 @@ namespace pan
    * @ingroup tasks
    */
   class TaskUpload: public Task,
-                     private NNTP::Listener,
-                     private WorkerPool::Worker::Listener
+                    private NNTP::Listener,
+                    private WorkerPool::Worker::Listener
   {
     public:
 
@@ -128,7 +128,6 @@ namespace pan
       friend class NZB;
       Encoder * _encoder;
       bool _encoder_has_run;
-      int _lines_per_file;
       std::string _filename;
       std::string _basename;
       TaskUpload::EncodeMode _encode_mode;
@@ -137,7 +136,6 @@ namespace pan
       UploadInfo _format;
       int _total_parts, _needed_parts;
       unsigned long _bytes;
-      Mutex mut;
       EncodeCache& _cache;
       std::deque<Log::Entry> _logfile;   // for intermediate updates
       Article _article;
@@ -146,6 +144,7 @@ namespace pan
       std::vector<Article*> _upload_list;
       std::string _save_file;
       Article::mid_sequence_t _mids;
+      int _queue_pos;
 
     private:
       needed_t       _needed;
diff --git a/pan/tasks/task-xover.cc b/pan/tasks/task-xover.cc
index f6a59f0..6f6a04a 100644
--- a/pan/tasks/task-xover.cc
+++ b/pan/tasks/task-xover.cc
@@ -99,13 +99,9 @@ TaskXOver :: TaskXOver (Data         & data,
   _bytes_so_far (0),
   _parts_so_far (0ul),
   _articles_so_far (0ul),
-  _total_minitasks (0),
-  _xzver(false),
-  _cache(data.get_cache())
+  _total_minitasks (0)
 {
 
-  _header_file.open("/home/imhotep/headers", std::ios::out | std::ios::binary);
-
   debug ("ctor for " << group);
 
   // add a ``GROUP'' MiniTask for each server that has this group
@@ -168,10 +164,7 @@ TaskXOver :: use_nntp (NNTP* nntp)
       case MiniTask::XOVER:
         debug ("XOVER " << mt._low << '-' << mt._high << " to " << server);
         _last_xover_number[nntp] = mt._low;
-//        if (_xzver)
-//          nntp->xzver (_group, mt._low, mt._high, this);
-//        else
-          nntp->xover (_group, mt._low, mt._high, this);
+        nntp->xover (_group, mt._low, mt._high, this);
         break;
       default:
         assert (0);
@@ -282,18 +275,6 @@ void
 TaskXOver :: on_nntp_line         (NNTP               * nntp,
                                    const StringView   & line)
 {
-//  if (!_xzver)
-//  {
-    on_nntp_line_process(nntp, line);
-//  } else
-//  _header_file<<line<<"\r\n";
-
-}
-
-void
-TaskXOver :: on_nntp_line_process (NNTP               * nntp,
-                                   const StringView   & line)
-{
 
   pan_return_if_fail (nntp != 0);
   pan_return_if_fail (!nntp->_server.empty());
@@ -378,41 +359,8 @@ TaskXOver :: on_nntp_done (NNTP              * nntp,
                            Health              health,
                            const StringView  & response UNUSED)
 {
-
-//  _header_file.close();
-
-
-  // step 1 : decode
-//  int res = UUInitialize();
-//  std::cerr<<"uulib : "<<UUstrerror(res)<<std::endl;
-//  res = UULoadFileWithPartNo (const_cast<char*>("/home/imhotep/headers"), 0, 0, -1);
-//  std::cerr<<"uulib : "<<UUstrerror(res)<<std::endl;
-//  res = UUDecodeFile (UUGetFileListItem (0), "/home/imhotep/headers_decoded");
-//  std::cerr<<"uulib : "<<UUstrerror(res)<<std::endl;
-//  res = UUDecodeFile (UUGetFileListItem (1), "/home/imhotep/headers_decoded");
-//  std::cerr<<"uulib : "<<UUstrerror(res)<<std::endl;
-//  UUCleanUp();
-//
-//  // step 2 : decompress
-//  igzstream in("/home/imhotep/headers_decoded");
-//  char c;
-//  std::ofstream out("/home/imhotep/headers_decomp", std::ifstream::out);
-//  while ( in.get(c))
-//    out << c;
-//  out.close();
-//
-//  // step 3 : feed to on_nntp_line
-//  std::ifstream ready("/home/imhotep/headers_decomp", std::ifstream::in);
-//  char buf[2048];
-//  while (ready.good())
-//  {
-//    ready.getline(buf,sizeof(buf));
-//    on_nntp_line_process (nntp, StringView(buf));
-//  }
-
   update_work (true);
   check_in (nntp, health);
-
 }
 
 void
diff --git a/pan/tasks/task-xover.h b/pan/tasks/task-xover.h
index f38b675..f9f0047 100644
--- a/pan/tasks/task-xover.h
+++ b/pan/tasks/task-xover.h
@@ -51,7 +51,6 @@ namespace pan
 
     private: // NNTP::Listener
       void on_nntp_line_process (NNTP*, const StringView&);
-//      void on_xover_follows (NNTP*, const StringView& line) { std::cerr<<line<<std::endl; }
       virtual void on_nntp_line (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);
@@ -61,7 +60,6 @@ namespace pan
         enum Type { GROUP, XOVER };
         Type _type;
         uint64_t _low, _high;
-//        std::stringstream buf;
         MiniTask (Type type, uint64_t low=0ul, uint64_t high=0ul):
           _type(type), _low(low), _high(high) {}
       };
@@ -86,11 +84,6 @@ namespace pan
       unsigned long _parts_so_far;
       unsigned long _articles_so_far;
       unsigned long _total_minitasks;
-      bool _xzver;
-      std::stringstream _headers;
-      std::ofstream _header_file;
-
-      ArticleCache& _cache;
   };
 }
 
diff --git a/pan/usenet-utils/mime-utils.cc b/pan/usenet-utils/mime-utils.cc
index c2d7d17..a2a0f6c 100644
--- a/pan/usenet-utils/mime-utils.cc
+++ b/pan/usenet-utils/mime-utils.cc
@@ -38,34 +38,6 @@ extern "C"
 
 using namespace pan;
 
-/***
-**** YENC
-***/
-
-#define YENC_MARKER_BEGIN      "=ybegin"
-#define YENC_MARKER_BEGIN_LEN  7
-#define YENC_MARKER_PART       "=ypart"
-#define YENC_MARKER_PART_LEN   6
-#define YENC_MARKER_END        "=yend"
-#define YENC_MARKER_END_LEN    5
-#define YENC_TAG_PART          " part="
-#define YENC_TAG_LINE          " line="
-#define YENC_TAG_SIZE          " size="
-#define YENC_TAG_NAME          " name="
-#define YENC_TAG_BEGIN         " begin="
-#define YENC_TAG_END           " end="
-#define YENC_TAG_PCRC32                " pcrc32="
-#define YENC_TAG_CRC32         " crc32="
-#define YENC_FULL_LINE_LEN     256
-#define YENC_HALF_LINE_LEN     128
-#define YENC_ESC_NULL          "=@"
-#define YENC_ESC_TAB           "=I"
-#define YENC_ESC_LF            "=J"
-#define YENC_ESC_CR            "=M"
-#define YENC_ESC_ESC           "={"
-#define YENC_SHIFT             42
-#define YENC_QUOTE_SHIFT       64
-
 namespace
 {
    const char*
diff --git a/pan/usenet-utils/mime-utils.h b/pan/usenet-utils/mime-utils.h
index e4e9714..a38d9d8 100644
--- a/pan/usenet-utils/mime-utils.h
+++ b/pan/usenet-utils/mime-utils.h
@@ -27,6 +27,35 @@
 #include <gmime/gmime-message.h>
 #include <pan/general/string-view.h>
 
+/***
+**** YENC
+***/
+
+#define YENC_MARKER_BEGIN      "=ybegin"
+#define YENC_MARKER_BEGIN_LEN  7
+#define YENC_MARKER_PART       "=ypart"
+#define YENC_MARKER_PART_LEN   6
+#define YENC_MARKER_END        "=yend"
+#define YENC_MARKER_END_LEN    5
+#define YENC_TAG_PART          " part="
+#define YENC_TAG_LINE          " line="
+#define YENC_TAG_SIZE          " size="
+#define YENC_TAG_NAME          " name="
+#define YENC_TAG_BEGIN         " begin="
+#define YENC_TAG_END           " end="
+#define YENC_TAG_PCRC32        " pcrc32="
+#define YENC_TAG_CRC32         " crc32="
+#define YENC_FULL_LINE_LEN     256
+#define YENC_HALF_LINE_LEN     128
+#define YENC_LINES_PER_FILE    4000
+#define YENC_ESC_NULL          "=@"
+#define YENC_ESC_TAB           "=I"
+#define YENC_ESC_LF            "=J"
+#define YENC_ESC_CR            "=M"
+#define YENC_ESC_ESC           "={"
+#define YENC_SHIFT             42
+#define YENC_QUOTE_SHIFT       64
+
 namespace pan
 {
   /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]