[pan2: 61/268] TODO : * debug taskupload saving (or delete) * properly implement nzb.cc



commit 8966c18c71f1f1fe9af01fabb0de844e5beea96e
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Sun Jun 12 23:04:01 2011 +0200

    TODO :
    * debug taskupload saving (or delete)
    * properly implement nzb.cc

 pan.cbp                   |    2 +
 pan/data/encode-cache.o   |  Bin 837816 -> 837232 bytes
 pan/general/log.h         |    3 +-
 pan/gui/log-ui.cc         |    7 +++-
 pan/gui/post-ui.cc        |   10 +++++-
 pan/gui/post-ui.h         |    2 +-
 pan/tasks/nntp.cc         |    8 ++---
 pan/tasks/task-upload.cc  |   14 ++++---
 pan/tasks/task-xover.cc   |   83 +++++++++++++++++++++-----------------------
 pan/tasks/task-xover.h    |    5 ++-
 pan/tasks/upload-queue.cc |    2 -
 uulib/uulib.c             |   24 ++++++------
 12 files changed, 86 insertions(+), 74 deletions(-)
---
diff --git a/pan.cbp b/pan.cbp
index dda6be6..3dbf346 100644
--- a/pan.cbp
+++ b/pan.cbp
@@ -246,6 +246,8 @@
 		<Unit filename="pan/usenet-utils/gnksa-test.cc" />
 		<Unit filename="pan/usenet-utils/gnksa.cc" />
 		<Unit filename="pan/usenet-utils/gnksa.h" />
+		<Unit filename="pan/usenet-utils/gzstream.cc" />
+		<Unit filename="pan/usenet-utils/gzstream.h" />
 		<Unit filename="pan/usenet-utils/message-check-test.cc" />
 		<Unit filename="pan/usenet-utils/message-check.cc" />
 		<Unit filename="pan/usenet-utils/message-check.h" />
diff --git a/pan/data/encode-cache.o b/pan/data/encode-cache.o
index 49ec3e6..f7f9232 100644
Binary files a/pan/data/encode-cache.o and b/pan/data/encode-cache.o differ
diff --git a/pan/general/log.h b/pan/general/log.h
index 0a34983..fb5edd7 100644
--- a/pan/general/log.h
+++ b/pan/general/log.h
@@ -51,7 +51,8 @@ namespace pan
         Severity severity;
         std::deque<Entry> messages;
         std::string message;
-        Entry() {}
+        bool is_child;
+        Entry() : is_child(false) { }
       };
 
       void add_entry(Entry& e, std::deque<Entry>& list);
diff --git a/pan/gui/log-ui.cc b/pan/gui/log-ui.cc
index 5102312..2a0b5cd 100644
--- a/pan/gui/log-ui.cc
+++ b/pan/gui/log-ui.cc
@@ -154,7 +154,6 @@ namespace
         }
       }
     }
-
     return store;
   }
 }
@@ -198,7 +197,11 @@ namespace
   {
     Log::Entry* log_entry(0);
     gtk_tree_model_get (model, iter, COL_MESSAGE, &log_entry, -1);
-    g_object_set (renderer, "text", log_entry ? log_entry->message.c_str() : "", NULL);
+    bool bold (log_entry->is_child);
+    g_object_set (renderer,
+                  "text", log_entry ? log_entry->message.c_str() : "",
+                  "weight", bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL,
+                  NULL);
   }
 
 
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index bc27c49..6022a43 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -39,6 +39,7 @@ extern "C" {
 #include <pan/usenet-utils/message-check.h>
 #include <pan/usenet-utils/mime-utils.h>
 #include <pan/data/data.h>
+#include <pan/tasks/nzb.h>
 #include <pan/gui/gui.h>
 #include <pan/tasks/task-post.h>
 #include "e-charset-dialog.h"
@@ -866,6 +867,9 @@ PostUI :: maybe_mail_message (GMimeMessage * message)
 void
 PostUI :: on_progress_finished (Progress&, int status) // posting finished
 {
+
+  ///Listener for taskupload??
+
   _post_task->remove_listener (this);
   gtk_widget_destroy (_post_dialog);
 
@@ -874,7 +878,7 @@ PostUI :: on_progress_finished (Progress&, int status) // posting finished
       done_sending_message (message, false);
     else
       maybe_mail_message (message);
-  }
+}
 
 void
 PostUI :: on_progress_error (Progress&, const StringView& message)
@@ -981,7 +985,11 @@ PostUI :: maybe_post_message (GMimeMessage * message)
     PostUI::tasks_t tasks;
     _upload_queue.get_all_tasks(tasks);
     foreach (PostUI::tasks_t, tasks, it)
+    {
       _queue.add_task (*it, Queue::BOTTOM);
+//      (*it)->add_listener(this);
+//      _upload_listeners.insert(*it);
+    }
      close_window(true); // dont wait for the upload queue
   }
 
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index a771832..1629c05 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -146,7 +146,7 @@ namespace pan
       std::string _current_signature;
       GtkWidget * _post_dialog;
       TaskPost * _post_task;
-      TaskUpload* _upload_task;
+      std::set<TaskUpload*> _upload_listeners;
       std::vector<Article*> _uploaded;
       typedef std::map<std::string, std::string> str2str_t;
       str2str_t _hidden_headers;
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index b2faafd..59edf26 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -78,15 +78,14 @@ 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')
-      line.truncate (line.len-2);
+   if (line.len>=2 && line.str[line.len-2]=='\r' && line.str[line.len-1]=='\n' && !_xzver)
+     line.truncate (line.len-2);
 
 //    std::cerr <<"_nntp_response_text: " << _nntp_response_text<<std::endl;
    if (_nntp_response_text)
    {
       if (line.len==1 && line.str[0]=='.') // end-of-list
       {
-        std::cerr<<"line end\n";
          state = CMD_DONE;
          _nntp_response_text = false;
       }
@@ -313,8 +312,6 @@ NNTP :: xzver (const Quark   & group,
 {
    _listener = l;
 
-  std::cerr<<"nntp xzver\n";
-
    if (group != _group)
       _commands.push_back (build_command ("GROUP %s\r\n", group.c_str()));
 
@@ -329,6 +326,7 @@ NNTP :: xover (const Quark   & group,
                uint64_t        high,
                Listener      * l)
 {
+  _xzver = false;
    _listener = l;
 
    if (group != _group)
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 6ba74d9..9394606 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -224,6 +224,7 @@ TaskUpload :: on_nntp_done (NNTP * nntp,
   char buf[4096];
   Log::Entry tmp;
   tmp.date = time(NULL);
+  tmp.is_child = true;
 
   needed_t::iterator it;
   for (it=_needed.begin(); it!=_needed.end(); ++it)
@@ -412,10 +413,11 @@ TaskUpload :: ~TaskUpload ()
   _cache.resize();
 
   ///TODO properly enclose all tasks in nzb tags (listener needed ...(??) )
-  if (!_save_file.empty())
-  {
-     std::ofstream out(_save_file.c_str(), std::fstream::out | std::fstream::app);
-     NZB :: upload_list_to_xml_file (out, _upload_list);
-     out.close();
-  }
+//  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-xover.cc b/pan/tasks/task-xover.cc
index 0b6123b..f6a59f0 100644
--- a/pan/tasks/task-xover.cc
+++ b/pan/tasks/task-xover.cc
@@ -100,10 +100,11 @@ TaskXOver :: TaskXOver (Data         & data,
   _parts_so_far (0ul),
   _articles_so_far (0ul),
   _total_minitasks (0),
-  _xzver(true)
+  _xzver(false),
+  _cache(data.get_cache())
 {
 
-  _header_file.open("/home/imhotep/headers", std::ios::out | std::ios::app | std::ios::binary);
+  _header_file.open("/home/imhotep/headers", std::ios::out | std::ios::binary);
 
   debug ("ctor for " << group);
 
@@ -167,9 +168,9 @@ 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
+//        if (_xzver)
+//          nntp->xzver (_group, mt._low, mt._high, this);
+//        else
           nntp->xover (_group, mt._low, mt._high, this);
         break;
       default:
@@ -283,11 +284,9 @@ TaskXOver :: on_nntp_line         (NNTP               * nntp,
 {
 //  if (!_xzver)
 //  {
-//    on_nntp_line_process(nntp, line);
-//    return;
-//  }
-  // feed lines into header file
-  _header_file<<line;
+    on_nntp_line_process(nntp, line);
+//  } else
+//  _header_file<<line<<"\r\n";
 
 }
 
@@ -380,42 +379,40 @@ TaskXOver :: on_nntp_done (NNTP              * nntp,
                            const StringView  & response UNUSED)
 {
 
-  //std::cerr << LINE_ID << " nntp " << nntp->_server << " (" << nntp << ") done; checking in.  health==" << health << std::endl;
-
-  // step 0 : save sstream to file
-
-  _header_file.close();
-
-  // step 1 : decompress
-//  igzstream in();
+//  _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))
-//    std::cout << c;
-
-  // step 2 : decode
-  int res = UUInitialize();
-  std::cerr<<"uulib : "<<UUstrerror(res)<<std::endl;
-  res = UULoadFileWithPartNo (const_cast<char*>("/home/imhotep/headers_decomp"), 0, 0, 1);
-  std::cerr<<"uulib : "<<UUstrerror(res)<<std::endl;
-  uulist * item = UUGetFileListItem (1);
-  if (!item)
-    std::cerr<<"uulib : failed to get list item"<<std::endl;
-  res = UUDecodeFile (item, (const_cast<char*>("/home/imhotep/headers_ready")));
-  std::cerr<<"uulib : "<<UUstrerror(res)<<std::endl;
-  UUCleanUp();
-
-
-  // step 3 : feed to on_nntp_line
-  std::ifstream ready("/home/imhotep/headers_ready", std::ifstream::in);
-  char buf[2048];
-  while (ready.good())
-  {
-    ready.getline(buf,sizeof(buf));
-    on_nntp_line_process (nntp, StringView(buf));
-  }
+//    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
@@ -438,8 +435,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);
   }
 }
 
diff --git a/pan/tasks/task-xover.h b/pan/tasks/task-xover.h
index 28dd014..f38b675 100644
--- a/pan/tasks/task-xover.h
+++ b/pan/tasks/task-xover.h
@@ -51,7 +51,7 @@ 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; }
+//      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,6 +61,7 @@ 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) {}
       };
@@ -88,6 +89,8 @@ namespace pan
       bool _xzver;
       std::stringstream _headers;
       std::ofstream _header_file;
+
+      ArticleCache& _cache;
   };
 }
 
diff --git a/pan/tasks/upload-queue.cc b/pan/tasks/upload-queue.cc
index 5e26687..ed587bf 100644
--- a/pan/tasks/upload-queue.cc
+++ b/pan/tasks/upload-queue.cc
@@ -95,7 +95,6 @@ UploadQueue :: add_tasks (const tasks_t& tasks, AddMode mode)
 void
 UploadQueue :: remove_tasks (const tasks_t& tasks)
 {
-  std::cerr<<"remove tasks\n";
   foreach_const (tasks_t, tasks, it)
     remove_task (*it);
 }
@@ -103,7 +102,6 @@ UploadQueue :: remove_tasks (const tasks_t& tasks)
 void
 UploadQueue :: remove_task (TaskUpload * task)
 {
-  std::cerr<<"remove task\n";
   const int index (_tasks.index_of (task));
   pan_return_if_fail (index != -1);
   _tasks.remove (index);
diff --git a/uulib/uulib.c b/uulib/uulib.c
index de8add7..2d6816d 100644
--- a/uulib/uulib.c
+++ b/uulib/uulib.c
@@ -84,7 +84,7 @@
 char * uulib_id = "$Id$";
 
 #ifdef SYSTEM_WINDLL
-BOOL _export WINAPI 
+BOOL _export WINAPI
 DllEntryPoint (HINSTANCE hInstance, DWORD seginfo,
 	       LPVOID lpCmdLine)
 {
@@ -574,7 +574,7 @@ UUstrerror (int code)
  */
 
 int UUEXPORT
-UUSetMsgCallback (void *opaque, 
+UUSetMsgCallback (void *opaque,
 		  void (*func) _ANSI_ARGS_((void *, char *, int)))
 {
   uu_MsgCallback = func;
@@ -719,7 +719,7 @@ UULoadFileWithPartNo (char *filename, char *fileid, int delflag, int partno)
     fileid = filename;
 
   while (!feof (datei) && !ferror (datei)) {
-    /* 
+    /*
      * Peek file, or some systems won't detect EOF
      */
     res = fgetc (datei);
@@ -727,7 +727,7 @@ UULoadFileWithPartNo (char *filename, char *fileid, int delflag, int partno)
       break;
     else
       ungetc (res, datei);
-    
+
     if ((loaded = ScanPart (datei, fileid, &sr)) == NULL) {
       if (sr != UURET_NODATA && sr != UURET_OK && sr != UURET_CONT) {
 	UUkillfread (loaded);
@@ -778,7 +778,7 @@ UULoadFileWithPartNo (char *filename, char *fileid, int delflag, int partno)
       if (uu_fast_scanning && sr != UURET_CONT) break;
       continue;
     }
-    
+
     if ((fload = UUPreProcessPart (loaded, &res)) == NULL) {
       /*
        * no useful data found
@@ -808,7 +808,7 @@ UULoadFileWithPartNo (char *filename, char *fileid, int delflag, int partno)
 		 (loaded->end)      ? "end"   : "",
 		 codenames[loaded->uudet]);
     }
-    
+
     if ((res = UUInsertPartToList (fload))) {
       /*
        * couldn't use the data
@@ -915,7 +915,7 @@ UUDecodeFile (uulist *thefile, char *destname)
 
   /*
    * Determine the name of the target file according to the rules:
-   * 
+   *
    * IF (destname!=NULL) THEN filename=destname;
    * ELSE
    *   filename = thefile->filename
@@ -1068,7 +1068,7 @@ UUInfoFile (uulist *thefile, void *opaque,
    */
 
   if (uu_FileCallback) {
-    if ((res = (*uu_FileCallback) (uu_FileCBArg, 
+    if ((res = (*uu_FileCallback) (uu_FileCBArg,
 				   thefile->thisfile->data->sfname,
 				   uugen_fnbuffer,
 				   1)) != UURET_OK)
@@ -1085,7 +1085,7 @@ UUInfoFile (uulist *thefile, void *opaque,
   else {
     if ((inpfile = fopen (thefile->thisfile->data->sfname, "rb")) == NULL) {
       UUMessage (uulib_id, __LINE__, UUMSG_ERROR,
-		 uustring (S_NOT_OPEN_FILE), 
+		 uustring (S_NOT_OPEN_FILE),
 		 thefile->thisfile->data->sfname,
 		 strerror (uu_errno=errno));
       return UURET_IOERR;
@@ -1100,7 +1100,7 @@ UUInfoFile (uulist *thefile, void *opaque,
   fseek (inpfile, thefile->thisfile->data->startpos, SEEK_SET);
   maxpos = thefile->thisfile->data->startpos + thefile->thisfile->data->length;
 
-  while (!feof (inpfile) && 
+  while (!feof (inpfile) &&
 	 (uu_fast_scanning || ftell(inpfile) < maxpos)) {
     if (_FP_fgets (uugen_inbuffer, 511, inpfile) == NULL)
       break;
@@ -1136,7 +1136,7 @@ UUInfoFile (uulist *thefile, void *opaque,
   fclose (inpfile);
 
   if (uu_FileCallback)
-    (*uu_FileCallback) (uu_FileCBArg, 
+    (*uu_FileCallback) (uu_FileCBArg,
 			thefile->thisfile->data->sfname,
 			uugen_fnbuffer, 0);
 
@@ -1145,7 +1145,7 @@ UUInfoFile (uulist *thefile, void *opaque,
 
   return UURET_OK;
 }
-	    
+
 int UUEXPORT
 UURenameFile (uulist *thefile, char *newname)
 {



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