[pan2/testing: 61/279] filequeue debugging, upload works



commit e9173275fd5c95378ed632a553e72d998c1b0f78
Author: Heinrich Mueller <sphemuel stud informatik uni-erlangen de>
Date:   Fri May 27 18:35:34 2011 +0200

    filequeue debugging, upload works

 pan/data/file-queue.cc   |   54 ++++++++++-
 pan/data/file-queue.h    |   17 +++-
 pan/gui/post-ui.cc       |  237 ++++++++++++++++++++++++++++++++++------------
 pan/gui/post-ui.h        |   16 +++
 pan/gui/task-pane.cc     |   13 ++-
 pan/tasks/encoder.cc     |   41 ++++++--
 pan/tasks/encoder.h      |   11 ++-
 pan/tasks/nntp.cc        |   45 ---------
 pan/tasks/nntp.h         |   45 +++++++++
 pan/tasks/task-upload.cc |  131 ++++++++++++++------------
 pan/tasks/task-upload.h  |   14 ++--
 uulib/uudeview.h         |    6 +-
 uulib/uuencode.c         |  163 ++++++++++++++++----------------
 13 files changed, 510 insertions(+), 283 deletions(-)
---
diff --git a/pan/data/file-queue.cc b/pan/data/file-queue.cc
index faf09ca..18a4277 100644
--- a/pan/data/file-queue.cc
+++ b/pan/data/file-queue.cc
@@ -19,6 +19,8 @@
 
 
 #include <algorithm>
+#include <iostream>
+#include <functional>
 
 #include <config.h>
 #include <pan/data/article.h>
@@ -46,17 +48,63 @@ FileQueue :: add (const char* filename,
 {
   static FileData a;
   struct stat sb;
-  a.filename = filename;
-  a.basename = g_path_get_basename(filename);
+  a.filename = std::string(filename);
+  a.basename = std::string(g_path_get_basename(filename));
   stat(filename,&sb);
   a.byte_count = sb.st_size;
-  a.part_in_queue = type == END ? _articles_v.size() : 1;
 
   type == END ?
     _articles_v.push_back(a) :
     _articles_v.push_front(a);
 }
 
+namespace
+{
+  struct FileNameEqual : public std::binary_function
+                         < std::string, std::string,bool >
+
+  {
+    bool operator() (std::string a, std::string b) {return (a==b);}
+  };
+}
+
+void
+FileQueue :: remove(const articles_v& no)
+{
+  articles_const_it it = no.begin();
+  articles_it vit = _articles_v.begin();
+  for ( ; it != no.end(); ++it)
+    for ( ; vit != _articles_v.end(); ++vit)
+      if (vit->filename == it->filename)
+        vit = _articles_v.erase(vit);
+
+}
+
+void
+FileQueue :: move_up(const articles_v& no)
+{
+
+}
+
+void
+FileQueue :: move_down(const articles_v& no)
+{
+
+}
+
+void
+FileQueue :: move_top(const articles_v& no)
+{
+
+//    foreach_const(articles_v, no, it)
+
+}
+
+void
+FileQueue :: move_bottom(const articles_v& no)
+{
+
+}
 
 
 
diff --git a/pan/data/file-queue.h b/pan/data/file-queue.h
index 2c37dbc..04229c7 100644
--- a/pan/data/file-queue.h
+++ b/pan/data/file-queue.h
@@ -46,31 +46,38 @@ namespace pan {
         struct FileData
         {
 
-          const char     * filename;
-          const char     * basename;
+          std::string filename;
+          std::string basename;
           unsigned long    byte_count;
-          unsigned long part_in_queue;
           FileData() {}
         };
 
+        typedef std::list<FileData>::const_iterator articles_const_it;
         typedef std::list<FileData>::iterator articles_it;
         typedef std::list<FileData> articles_v;
 
      size_t size() { return _articles_v.size(); }
      articles_it end() { return _articles_v.end(); }
      articles_it begin() { return _articles_v.begin(); }
+     const articles_v& get_files() const { return _articles_v; }
      bool empty() { return _articles_v.empty(); }
 
-
      public:
       enum InsertType
       { BEGIN, END };
 
     //own
     public:
-      virtual void add (const char* filename,
+      void add (const char* filename,
                   FileQueue::InsertType type);
 
+      void remove(const articles_v& no);
+
+      void move_up(const articles_v& no);
+      void move_down(const articles_v& no);
+      void move_top(const articles_v& no);
+      void move_bottom(const articles_v& no);
+
     private:
       articles_v _articles_v;
   };
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index b569129..5fa21cd 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -369,8 +369,6 @@ bool
 PostUI :: check_message (const Quark& server, GMimeMessage * msg)
 {
 
-  std::cerr<<"check message\n";
-
   MessageCheck :: unique_strings_t errors;
   MessageCheck :: Goodness goodness;
 
@@ -603,20 +601,6 @@ PostUI :: on_progress_finished (Progress&, int status) // posting finished
     else
       maybe_mail_message (message);
   }
-//  else
-//  {
-//    GMimeMessage * message (((TaskUpload*)_upload_task)->get_message ());
-//    const char* g = _upload_task->get_groups();
-//    const char* f = _upload_task->get_filename();
-//    // log server response
-//    if (status == OK) {
-//      g_snprintf(buf, bufsz,_("Error uploading file \"%s\" to group(s) \"%s\" : %s"), f, g, message);
-//      Log :: add_err(buf);
-//    } else {
-//      g_snprintf(buf, bufsz,_("Successfully  uploaded \"%s\" to group(s) \"%s\"."), f, g);
-//      Log :: add_info(buf);
-//    }
-//  }
 }
 
 void
@@ -659,7 +643,7 @@ PostUI :: maybe_post_message (GMimeMessage * message)
   ***  Make sure the message is OK...
   **/
 
-  if (!check_message (server, message))
+  if (!_file_queue_empty && !check_message (server, message))
      return false;
 
   /**
@@ -720,14 +704,18 @@ PostUI :: maybe_post_message (GMimeMessage * message)
     _post_task = new TaskPost (server, message);
     _post_task->add_listener (this);
     _queue.add_task (_post_task, Queue::TOP);
-  } else
+  }
+  else
   {
-    unsigned long i(0);
     FileQueue::articles_it it = _file_queue.begin();
-
-    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), Queue::BOTTOM);
+    GMimeMessage* msg = new_message_from_ui(POSTING);
+    std::string groups = std::string(g_mime_object_get_header ((GMimeObject*)msg, "Newsgroups"));
+    std::string subject= std::string(g_mime_object_get_header ((GMimeObject*)msg, "Subject"));
+    std::string author;
+    profile.get_from_header (author);
+
+    for (; it != _file_queue.end(); ++it) {
+      _queue.add_task (new TaskUpload (*it,profile.posting_server,groups,subject,author), Queue::BOTTOM);
     }
     close_window(true); // dont wait for the upload queue
   }
@@ -1088,7 +1076,10 @@ PostUI :: new_message_from_ui (Mode mode)
   g_object_unref (stream);
   GMimePart * part = g_mime_part_new ();
   //todo ??
-  pch = g_strdup_printf ("text/plain; charset=%s", charset.c_str());
+  if (_file_queue_empty)
+    pch = g_strdup_printf ("text/plain; charset=%s", charset.c_str());
+  else
+    pch = g_strdup_printf ("message/partial; charset=%s", charset.c_str());
 
   GMimeContentType * type = g_mime_content_type_new_from_string (pch);
   g_free (pch);
@@ -1544,11 +1535,6 @@ namespace
     static_cast<PostUI*>(user_data)->apply_profile ();
   }
 
-//  void on_filequeue_changed (GtkWidget*, gpointer data)
-//  {
-//    static_cast<PostUI*>(data)->update_filequeue_tab();
-//  }
-
   typedef std::map <std::string, std::string> str2str_t;
 
   struct SetMessageForeachHeaderData
@@ -1960,7 +1946,111 @@ gtk_widget_set_tooltip_text (w, _("The email account where mail replies to your
   return t;
 }
 
-// todo scroll
+namespace
+{
+  GtkWidget * add_button (GtkWidget   * box,
+                                      const gchar * stock_id,
+                                      GCallback     callback,
+                                      gpointer      user_data)
+  {
+    GtkWidget * w = gtk_button_new_from_stock (stock_id);
+    gtk_button_set_relief (GTK_BUTTON(w), GTK_RELIEF_NONE);
+    if (callback)
+      g_signal_connect (w, "clicked", callback, user_data);
+    gtk_box_pack_start (GTK_BOX(box), w, false, false, 0);
+    return w;
+  }
+}
+
+void
+PostUI :: get_selected_files_foreach (GtkTreeModel *model, GtkTreePath *, GtkTreeIter *iter, gpointer list_g)
+{
+  FileQueue::FileData* file (0);
+  gtk_tree_model_get (model, iter, 0, &file, -1);
+  std::cerr<<"foreach got "<<file->filename.c_str()<<std::endl;
+  static_cast<FileQueue*>(list_g)->add (file->filename.c_str(), FileQueue::END);
+}
+
+FileQueue::articles_v
+PostUI :: get_selected_files () const
+{
+  FileQueue files;
+  GtkTreeView * view (GTK_TREE_VIEW (_filequeue_store));
+  GtkTreeSelection * sel (gtk_tree_view_get_selection (view));
+  gtk_tree_selection_selected_foreach (sel, get_selected_files_foreach, &files);
+  return files.get_files();
+}
+
+void
+PostUI :: remove_files(const FileQueue::articles_v& no)
+{
+  _file_queue.remove(no);
+  update_filequeue_tab();
+}
+
+void
+PostUI :: move_up(const FileQueue::articles_v& no)
+{
+  _file_queue.move_up(no);
+}
+
+void
+PostUI :: move_down(const FileQueue::articles_v& no)
+{
+  _file_queue.move_down(no);
+}
+
+void
+PostUI :: move_top(const FileQueue::articles_v& no)
+{
+  _file_queue.move_top(no);
+}
+
+void
+PostUI :: move_bottom(const FileQueue::articles_v& no)
+{
+  _file_queue.move_bottom(no);
+}
+
+void PostUI :: up_clicked_cb (GtkButton*, PostUI* pane)
+{
+  pane->move_up (pane->get_selected_files());
+}
+void PostUI :: down_clicked_cb (GtkButton*, PostUI* pane)
+{
+  pane->move_down (pane->get_selected_files());
+}
+void PostUI :: top_clicked_cb (GtkButton*, PostUI* pane)
+{
+  pane->move_top (pane->get_selected_files());
+}
+void PostUI :: bottom_clicked_cb (GtkButton*, PostUI* pane)
+{
+  pane->move_bottom (pane->get_selected_files());
+}
+void PostUI :: delete_clicked_cb (GtkButton*, PostUI* pane)
+{
+  pane->remove_files (pane->get_selected_files());
+}
+
+namespace
+{
+  void
+  render_filename (GtkTreeViewColumn * ,
+                   GtkCellRenderer   * renderer,
+                   GtkTreeModel      * model,
+                   GtkTreeIter       * iter,
+                   gpointer)
+  {
+
+    FileQueue::FileData* fd;
+    unsigned int size;
+    gtk_tree_model_get (model, iter, 0, &fd, 1, &size, -1);
+    if (fd)
+      g_object_set (renderer, "text", fd->basename.c_str(), NULL);
+  }
+}
+
 GtkWidget*
 PostUI :: create_filequeue_tab ()
 {
@@ -1968,53 +2058,78 @@ PostUI :: create_filequeue_tab ()
   GtkListStore *list_store;
   GtkTreeIter   iter;
   GtkCellRenderer *renderer;
-
-  GtkWidget * scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-//  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scrolled_window),
-//                                       GTK_SHADOW_IN);
-//  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
-//                                  GTK_POLICY_AUTOMATIC,
-//                                  GTK_POLICY_AUTOMATIC);
-//  gtk_box_pack_start(GTK_BOX(gtk_hbox_new(FALSE,1)),scrolled_window,TRUE,TRUE,2);
-
-  list_store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_UINT);
+  GtkWidget * vbox = gtk_vbox_new (false, 0);
+  GtkWidget * buttons = gtk_hbox_new (false, PAD_SMALL);
+
+  // add button row
+  add_button (buttons, GTK_STOCK_GO_UP, G_CALLBACK(up_clicked_cb), this);
+  add_button (buttons, GTK_STOCK_GOTO_TOP, G_CALLBACK(top_clicked_cb), this);
+  gtk_box_pack_start (GTK_BOX(buttons), gtk_vseparator_new(), 0, 0, 0);
+  add_button (buttons, GTK_STOCK_GO_DOWN, G_CALLBACK(down_clicked_cb), this);
+  add_button (buttons, GTK_STOCK_GOTO_BOTTOM, G_CALLBACK(bottom_clicked_cb), this);
+  gtk_box_pack_start (GTK_BOX(buttons), gtk_vseparator_new(), 0, 0, 0);
+  w = add_button (buttons, GTK_STOCK_DELETE, G_CALLBACK(delete_clicked_cb), this);
+  gtk_widget_set_tooltip_text( w, _("Delete from Queue"));
+  pan_box_pack_start_defaults (GTK_BOX(buttons), gtk_event_box_new());
+
+  gtk_box_pack_start (GTK_BOX(vbox), buttons, false, false, 0);
+  gtk_box_pack_start (GTK_BOX(vbox), gtk_hseparator_new(), false, false, 0);
+
+  list_store = gtk_list_store_new (2, G_TYPE_POINTER, G_TYPE_UINT);
   w = _filequeue_store = gtk_tree_view_new_with_model (GTK_TREE_MODEL(list_store));
 
-//  gtk_container_add (GTK_CONTAINER (scrolled_window), w);
-
   // add columns
+   renderer = gtk_cell_renderer_text_new ();
+  gtk_tree_view_insert_column_with_data_func(
+            GTK_TREE_VIEW(w), 0, (_("Filename")), renderer,
+            render_filename, 0, 0);
   renderer = gtk_cell_renderer_text_new ();
-  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w), -1,   (_("Filename")), renderer,"text", 0,NULL);
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w), -1,   (_("Size (kB)")),renderer,"text", 1,NULL);
+  gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (w), 1,
+                          (_("Size (kB)")),renderer,"text", 1,NULL);
 
+  //set hint and selection
   gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(w),TRUE);
+  GtkTreeSelection * selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (w));
+  gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
 
-  return w;
+  //append scroll window
+  w = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(w), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(w), GTK_SHADOW_IN);
+  gtk_container_add (GTK_CONTAINER(w), _filequeue_store);
+  gtk_box_pack_start (GTK_BOX(vbox), w, true, true, 0);
+
+  return vbox;
 }
 
 void
 PostUI :: update_filequeue_tab()
 {
-  GtkWidget* w = _filequeue_store ;
-  GtkListStore    *store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(w)));
-  GtkTreeIter      iter;
+  GtkWidget    * w    = _filequeue_store ;
+  GtkListStore *store = GTK_LIST_STORE(
+                        gtk_tree_view_get_model(GTK_TREE_VIEW(w)));
+  GtkTreeIter   iter;
 
-    gtk_list_store_clear(store);
+  gtk_list_store_clear(store);
 
-    FileQueue::articles_it it = _file_queue.begin();
+  FileQueue::articles_it it = _file_queue.begin();
 
-    int i(0);
-    for (; it != _file_queue.end(); ++it, ++i )
-    {
-      gtk_list_store_append (store, &iter);
-      gtk_list_store_set (store, &iter,
-                        0, (*it).filename,
-                        1, (*it).byte_count/1024,
-                        -1);
-    }
+  int i(0);
+  FileQueue::FileData* fd(0);
+  for (; it != _file_queue.end(); ++it, ++i )
+  {
+    fd = &(*it);
+    std::cerr<<"updating file "<<fd->basename<<std::endl;
+    gtk_list_store_append (store, &iter);
+    gtk_list_store_set (store, &iter,
+                      0, fd,
+                      1, (*it).byte_count/1024,
+                      -1);
+  }
+
+  std::cerr<<"updated "<<i<<" elements in store.\n";
 
-    _file_queue_empty = (i == 0);
+  _file_queue_empty = (i == 0);
 
 }
 
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index 43b16bf..f43f9e8 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -32,6 +32,7 @@ namespace pan
 {
   class Profiles;
   class TaskPost;
+  class FileQueue;
 
   /**
    * Dialog for posting new messages Pan's GTK GUI.
@@ -158,6 +159,21 @@ namespace pan
       void set_spellcheck_enabled (bool);
       void spawn_editor_dead(char *);
 
+    private:
+      FileQueue::articles_v  get_selected_files () const;
+      static void get_selected_files_foreach (GtkTreeModel*,
+                      GtkTreePath*, GtkTreeIter*, gpointer);
+      void remove_files(const FileQueue::articles_v& no);
+      static void up_clicked_cb      (GtkButton*, PostUI*);
+      static void down_clicked_cb    (GtkButton*, PostUI*);
+      static void top_clicked_cb     (GtkButton*, PostUI*);
+      static void bottom_clicked_cb  (GtkButton*, PostUI*);
+      static void delete_clicked_cb  (GtkButton*, PostUI*);
+
+      void move_up(const FileQueue::articles_v& no);
+      void move_down(const FileQueue::articles_v& no);
+      void move_top(const FileQueue::articles_v& no);
+      void move_bottom(const FileQueue::articles_v& no);
   };
 }
 
diff --git a/pan/gui/task-pane.cc b/pan/gui/task-pane.cc
index 15066e5..ac1d6b5 100644
--- a/pan/gui/task-pane.cc
+++ b/pan/gui/task-pane.cc
@@ -208,11 +208,13 @@ TaskPane :: update_status (const task_states_t& tasks)
   {
     Task * task (*it);
     const Queue::TaskState state (tasks.get_state (task));
-    if (state == Queue::RUNNING || state == Queue::DECODING)
+    if (state == Queue::RUNNING || state == Queue::DECODING
+        || state == Queue::ENCODING)
       ++running_count;
     else if (state == Queue::STOPPED)
       ++stopped_count;
-    else if (state == Queue::QUEUED || state == Queue::QUEUED_FOR_DECODE)
+    else if (state == Queue::QUEUED || state == Queue::QUEUED_FOR_DECODE
+             || state == Queue::QUEUED_FOR_ENCODE)
       ++queued_count;
 
     if (state==Queue::RUNNING || state==Queue::QUEUED)
@@ -225,7 +227,7 @@ TaskPane :: update_status (const task_states_t& tasks)
     g_snprintf (buf, sizeof(buf), _("Pan: Tasks (%d Queued, %d Running, %d Stopped)"), queued_count, running_count, stopped_count);
   else if (running_count || queued_count)
     g_snprintf (buf, sizeof(buf), _("Pan: Tasks (%d Queued, %d Running)"), queued_count, running_count);
-  else 
+  else
     g_snprintf (buf, sizeof(buf), _("Pan: Tasks"));
   gtk_window_set_title (GTK_WINDOW(_root), buf);
 
@@ -314,7 +316,9 @@ namespace
     switch (state) {
       case Queue::RUNNING:  state_str = _("Running"); break;
       case Queue::DECODING: state_str = _("Decoding"); break;
+      case Queue::ENCODING: state_str = _("Encoding"); break;
       case Queue::QUEUED_FOR_DECODE: state_str = _("Queued for Decode"); break;
+      case Queue::QUEUED_FOR_ENCODE: state_str = _("Queued for Encode"); break;
       case Queue::QUEUED:   state_str = _("Queued"); break;
       case Queue::STOPPED:  state_str = _("Stopped"); break;
       case Queue::REMOVING: state_str = _("Removing"); break;
@@ -372,7 +376,8 @@ namespace
     }
 
     char * str (0);
-    if (state == Queue::RUNNING || state == Queue::DECODING)
+    if (state == Queue::RUNNING || state == Queue::DECODING
+        || state == Queue::ENCODING)
       str = g_markup_printf_escaped ("<b>%s</b>\n<small>%s</small>", description.c_str(), status.c_str());
     else
       str = g_markup_printf_escaped ("%s\n<small>%s</small>", description.c_str(), status.c_str());
diff --git a/pan/tasks/encoder.cc b/pan/tasks/encoder.cc
index 01db2f4..9fa41ab 100644
--- a/pan/tasks/encoder.cc
+++ b/pan/tasks/encoder.cc
@@ -55,9 +55,12 @@ Encoder :: ~Encoder()
 ***/
 
 void
-Encoder :: enqueue (TaskUpload                     * task,
-                    const FileQueue::FileData      & file_data,
-                    TaskUpload::EncodeMode           enc)
+Encoder :: enqueue (TaskUpload                * task,
+                    const FileQueue::FileData & file_data,
+                    std::string               & groups,
+                    std::string               & subject,
+                    std::string               & author,
+                    const TaskUpload::EncodeMode    & enc)
 
 {
   disable_progress_update ();
@@ -65,14 +68,18 @@ Encoder :: enqueue (TaskUpload                     * task,
   this->task = task;
   this->file_data = file_data;
   this->encode_mode = encode_mode;
+  this->groups = groups;
+  this->subject = subject;
+  this->author = author;
+
+  std::cerr<<"encoder begin: "<<this->groups<<" "<<this->subject<<" "<<this->author<<" "<<std::endl;
 
-  mark_read = false;
   percent = 0;
   current_file.clear ();
   log_infos.clear();
   log_errors.clear();
 
-  // gentlemen, start your saving...
+  // gentlemen, start your encod'n...
   _worker_pool.push_work (this, task, false);
 }
 
@@ -102,14 +109,30 @@ Encoder :: do_work()
       UUSetMsgCallback (this, uu_log);
       UUSetBusyCallback (this, uu_busy_poll, 100);
 
-      char* basename = g_path_get_basename(file_data.filename);
+      const char* filename = file_data.filename.c_str();
+      const char* basename = g_path_get_basename(file_data.filename.c_str());
+
       g_snprintf(buf,bufsz,"%s/%s.%d", uulib.c_str(), basename, cnt);
       outfile = fopen(buf,"wb");
       while (1) {
-        res = UUEncodePartial (outfile, NULL, (char*)file_data.filename, YENC_ENCODED,
-              buf, NULL, 0, cnt, 4000, &crcptr);
+        /*
+        UUE_PrepPartial (FILE *outfile, FILE *infile,
+        char *infname, int encoding,
+        char *outfname, int filemode,
+        int partno, long linperfile, long filesize,
+        char *destination, char *from, char *subject,
+        int isemail) */
+        res = UUE_PrepPartial (outfile, NULL, (char*)filename,YENC_ENCODED,
+                               (char*)basename,0644, cnt, 4000,
+                               file_data.byte_count, (char*)groups.c_str(),
+                               (char*)author.c_str(), (char*)subject.c_str(),
+                               0);
+
+//        res = UUEncodePartial( outfile, NULL, (char*)file_data.filename.c_str(),
+//                               YENC_ENCODED, (char*)file_data.basename.c_str(), const_cast<char*>("message/partial"),
+//                               0, cnt, 4000, &crcptr);
         if (outfile) fclose(outfile);
-        if (res == UURET_OK || res != UURET_CONT) break;
+        if (res != UURET_CONT) break;
         g_snprintf(buf,bufsz,"%s/%s.%d", uulib.c_str(), basename, ++cnt);
         outfile = fopen(buf,"wb");
       }
diff --git a/pan/tasks/encoder.h b/pan/tasks/encoder.h
index 7a73893..d59b760 100644
--- a/pan/tasks/encoder.h
+++ b/pan/tasks/encoder.h
@@ -58,15 +58,17 @@ namespace pan
 
       typedef std::vector<std::string> strings_t;
 
-      void enqueue (TaskUpload                     * task,
-                    const FileQueue::FileData      & file_data,
-                    TaskUpload::EncodeMode     enc = TaskUpload::YENC);
+      void enqueue (TaskUpload                * task,
+                    const FileQueue::FileData & file_data,
+                    std::string               & groups,
+                    std::string               & subject,
+                    std::string               & author,
+                    const TaskUpload::EncodeMode    & enc = TaskUpload::YENC);
 
     public:
 
       typedef std::list<std::string> log_t;
       log_t log_severe, log_errors, log_infos, file_errors;
-      bool mark_read;
 
     protected: // inherited from WorkerPool::Worker
 
@@ -78,6 +80,7 @@ namespace pan
       TaskUpload * task;
       TaskUpload::EncodeMode encode_mode;
       FileQueue::FileData file_data;
+      std::string subject, author, groups;
 
       // These are set in the worker thread and polled in the main thread.
       Mutex mut;
diff --git a/pan/tasks/nntp.cc b/pan/tasks/nntp.cc
index 38345d7..7a833d9 100644
--- a/pan/tasks/nntp.cc
+++ b/pan/tasks/nntp.cc
@@ -54,51 +54,6 @@ 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)
 {
diff --git a/pan/tasks/nntp.h b/pan/tasks/nntp.h
index cf009c5..3caada9 100644
--- a/pan/tasks/nntp.h
+++ b/pan/tasks/nntp.h
@@ -28,6 +28,51 @@
 #include <pan/tasks/health.h>
 #include <pan/tasks/socket.h>
 
+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
+   };
+}
+
 namespace pan
 {
   /**
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 8d2f7f8..7347d9d 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -61,14 +61,18 @@ namespace
 
 TaskUpload :: TaskUpload ( const FileQueue::FileData & file_data,
                            const Quark               & server,
-                           GMimeMessage              * msg,
+                           std::string                 groups,
+                           std::string                 subject,
+                           std::string                 author,
                            Progress::Listener        * listener,
                            const TaskUpload::EncodeMode  enc):
-  Task ("UPLOAD", get_description(file_data.filename, true)),
+  Task ("UPLOAD", get_description(file_data.filename.c_str(), false)),
   _file_data(file_data),
-  _basename(g_path_get_basename(file_data.filename)),
+  _basename (file_data.basename),
   _server(server),
-  _msg(msg),
+  _groups(groups),
+  _subject (subject),
+  _author(author),
   _encoder(0),
   _encoder_has_run (false),
   _encode_mode(enc)
@@ -87,13 +91,8 @@ TaskUpload :: update_work (void)
     _state.set_need_encoder();
   } else if (_encoder_has_run && !_needed.empty())
   {
-    std::cout<<"need "<<_needed.size()<<std::endl;
-    mut.lock();
-      _cur = *_needed.begin();
-      if (!_needed.empty()) _needed.pop_front();
-    mut.unlock();
+    set_status_va (_("Uploading %s"), _basename.c_str());
     _state.set_need_nntp(_server);
-    set_status_va (_("Uploading %s"), _file_data.basename);
   } else if (_needed.empty())
   {
     _state.set_completed();
@@ -105,48 +104,23 @@ TaskUpload :: update_work (void)
 ****
 ***/
 
-std::string
-TaskUpload :: generate_yenc_headers(const Needed& n)
-{
-  std::stringstream res;
-  const int bufsz = 2048;
-  char buf[bufsz];
-  //modify msg to our needs
-  const char* subject = g_mime_object_get_header ((GMimeObject*)_msg, "Subject");
-  g_snprintf(buf,bufsz, "%s -- \"%s\" (%d/%d) YEnc",
-             subject, _file_data.basename, //_file_data.part_in_queue, _file_data.size(),
-             n.partno, _parts);
-  g_mime_object_set_header((GMimeObject*)_msg,"Subject", buf);
-
-  //append msg to result
-  res << g_mime_object_to_string((GMimeObject *)_msg);
-
-  //append yenc data to result
-  res<<"\r\n";
-
-  std::ifstream in(const_cast<char*>(n.filename.c_str()),  std::ifstream::in);
-  std::string line;
-  if (in.good())
-    std::getline(in, line);
-  int filesize = __yenc_extract_tag_val_int_base( line.c_str(), " size=", 0 );
-  g_snprintf(buf,bufsz,"=ybegin line=128 size=%s name=%s\r\n",
-             filesize, _basename);
-  res<<buf;
-  while (in.good())
-    res << (char) in.get();
-  res<<"\r\n.\r\n";
-  return res.str();
-}
-
 void
 TaskUpload :: use_nntp (NNTP * nntp)
 {
-    std::cerr<<"use nntp\n";
-    if (_needed.empty())
-      update_work();
+    Needed cur;
+      if (!_needed.empty()) {
+        cur = *(_needed.begin());
+      } else {
+        update_work();
+        return;
+      }
 
-    std::string res(generate_yenc_headers(_cur));
-    nntp->post(StringView(res), this);
+    std::stringstream tmp;
+    std::ifstream in(cur.filename.c_str(), std::ifstream::in);
+    while (in.good())
+      tmp << (char) in.get();
+    in.close();
+    nntp->post(StringView(tmp.str()), this);
     update_work ();
 }
 
@@ -157,16 +131,49 @@ TaskUpload :: use_nntp (NNTP * nntp)
 void
 TaskUpload :: on_nntp_line  (NNTP               * nntp,
                               const StringView   & line_in)
-{}
+{
+
+std::cerr<<"line "<<line_in<<std::cerr;
+
+}
 
 void
 TaskUpload :: on_nntp_done  (NNTP             * nntp,
-                              Health             health,
-                              const StringView & response)
+                             Health             health,
+                             const StringView & response)
 {
-  std::cerr<<"nntp done\n";
-  check_in (nntp, health);
-  increment_step(1);
+
+  switch (atoi(response.str))
+  {
+    case NO_POSTING:
+      Log :: add_err(_("Posting failed: No Posts allowed by server."));
+      this->stop();
+      break;
+    case POSTING_FAILED:
+      Log :: add_err_va (_("Posting failed: %s"), response.str);
+      break;
+    case ARTICLE_POSTED_OK:
+      if (_needed.empty())
+        Log :: add_info_va(_("Posting of file %s succesful: %s"),
+                           _file_data.basename.c_str(), response.str);
+      else
+        _needed.pop_front();
+      break;
+    case TOO_MANY_CONNECTIONS: //todo
+    break;
+  }
+
+  switch (health)
+  {
+    case OK:
+      check_in (nntp, health);
+      increment_step(1);
+      break;
+
+    case ERR_NETWORK:
+      _state.set_need_nntp(nntp->_server);
+      break;
+  }
   update_work();
 }
 
@@ -179,7 +186,7 @@ unsigned long
 TaskUpload :: get_bytes_remaining () const
 {
   unsigned long bytes (0);
-  foreach_const (needed_t, _needed, it) // parts not fetched yet...
+  foreach_const (needed_t, _needed, it)
     bytes += it->bytes;
   return bytes;
 }
@@ -194,7 +201,9 @@ TaskUpload :: use_encoder (Encoder* encoder)
   _encoder = encoder;
   init_steps(100);
   _state.set_working();
-  _encoder->enqueue (this, _file_data, YENC);
+
+  std::cerr<<"enqueue: "<<_groups<<" "<<_subject<<" "<<_author<<std::endl;
+  _encoder->enqueue (this, _file_data, _groups, _subject, _author, YENC);
   debug ("encoder thread was free, enqueued work");
 }
 
@@ -224,6 +233,7 @@ TaskUpload :: on_worker_done (bool cancelled)
     foreach_const(Encoder::log_t, _encoder->log_infos, it)
       Log :: add_info(it->c_str());
 
+
     if (!_encoder->log_errors.empty())
       set_error (_encoder->log_errors.front());
 
@@ -234,22 +244,21 @@ TaskUpload :: on_worker_done (bool cancelled)
       _parts = _encoder->parts;
       set_step (100);
       _encoder_has_run = true;
-      /*enqueue all parts into needed_t list.
+      /*enqueue all parts into the global needed_t list.
         update_work will then assign a pointer to the begin
         which will be used for an nntp upload.
         on nntp_done, the list is decreased by one member
        */
       static Needed n;
-      const int bufsz(2048);
-      char buf[bufsz];
+      char buf[2048];
       struct stat sb;
 
       for (int i=1;i<=_parts;i++)
       {
         n.partno = i;
-        g_snprintf(buf,bufsz,"%s/%s.%d",
+        g_snprintf(buf,sizeof(buf),"%s/%s.%d",
                    file::get_uulib_path().c_str(),
-                   _file_data.basename, i);
+                   _basename.c_str(), i);
         n.filename = buf;
         stat(buf, &sb);
         n.bytes = sb.st_size;
diff --git a/pan/tasks/task-upload.h b/pan/tasks/task-upload.h
index 139af7b..171f060 100644
--- a/pan/tasks/task-upload.h
+++ b/pan/tasks/task-upload.h
@@ -57,7 +57,9 @@ namespace pan
 
       TaskUpload ( const FileQueue::FileData & file_data,
                    const Quark               & server,
-                   GMimeMessage              * msg,
+                   std::string                 groups,
+                   std::string                 subject,
+                   std::string                 author,
                    Progress::Listener        * listener=0,
                    TaskUpload::EncodeMode enc     = YENC);
       virtual ~TaskUpload ();
@@ -91,10 +93,10 @@ namespace pan
       friend class Encoder;
       Encoder * _encoder;
       bool _encoder_has_run;
-      FileQueue::FileData _file_data;
-      const char* _basename;
+      const FileQueue::FileData _file_data;
+      const std::string _basename;
       TaskUpload::EncodeMode _encode_mode;
-      GMimeMessage * _msg;
+      std::string _groups, _subject, _author;
       int _parts; // filled in by encoder
       Mutex mut;
 
@@ -107,13 +109,11 @@ namespace pan
       };
       typedef std::deque<Needed> needed_t;
       needed_t _needed;
-      Needed _cur;
-
-      virtual std::string generate_yenc_headers(const Needed& n);
 
       void update_work (void);
   };
 
+// from mime-utils.cc
 namespace
 {
 
diff --git a/uulib/uudeview.h b/uulib/uudeview.h
index 804f58e..5422bf2 100644
--- a/uulib/uudeview.h
+++ b/uulib/uudeview.h
@@ -172,7 +172,7 @@ typedef struct {
   long foffset;			/* file offset -- internal use only        */
   long totsize;			/* file total size -- internal use only    */
 } uuprogress;
-  
+
 
 /*
  * Externally visible Functions
@@ -191,7 +191,7 @@ int	UUEXPORT UUGetOption		_ANSI_ARGS_((int, int *, char *, int));
 int	UUEXPORT UUSetOption		_ANSI_ARGS_((int, int, char *));
 char *	UUEXPORT UUstrerror		_ANSI_ARGS_((int));
 int	UUEXPORT UUSetMsgCallback	_ANSI_ARGS_((void *,
-						     void (*) (void *, 
+						     void (*) (void *,
 							       char *,
 							       int)));
 int	UUEXPORT UUSetBusyCallback	_ANSI_ARGS_((void *,
@@ -213,7 +213,7 @@ int	UUEXPORT UUDecodeToTemp		_ANSI_ARGS_((uulist *));
 int	UUEXPORT UURemoveTemp		_ANSI_ARGS_((uulist *));
 int	UUEXPORT UUDecodeFile		_ANSI_ARGS_((uulist *, char *));
 int	UUEXPORT UUInfoFile		_ANSI_ARGS_((uulist *, void *,
-						     int (*) (void *, 
+						     int (*) (void *,
 							      char *)));
 int	UUEXPORT UUSmerge		_ANSI_ARGS_((int));
 int	UUEXPORT UUCleanUp		_ANSI_ARGS_((void));
diff --git a/uulib/uuencode.c b/uulib/uuencode.c
index a629073..2d985a2 100644
--- a/uulib/uuencode.c
+++ b/uulib/uuencode.c
@@ -57,7 +57,7 @@
 #endif
 #endif
 
-char * uuencode_id = "$Id$";
+char * uuencode_id = "$Id: uuencode.c,v 1.22 2002/04/02 10:04:52 fp Exp $";
 
 #if 0
 /*
@@ -135,7 +135,7 @@ unsigned char UUEncodeTable[64] = {
   'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
   'X', 'Y', 'Z', '[', '\\',']', '^', '_'
 };
-  
+
 
 unsigned char B64EncodeTable[64] = {
   'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
@@ -162,11 +162,11 @@ unsigned char XXEncodeTable[64] = {
 unsigned char BHEncodeTable[64] = {
   '!', '"', '#', '$', '%', '&', '\'', '(',
   ')', '*', '+', ',', '-', '0', '1', '2',
-  '3', '4', '5', '6', '8', '9', '@', 'A', 
-  'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 
-  'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 
-  'S', 'T', 'U', 'V', 'X', 'Y', 'Z', '[', 
-  '`', 'a', 'b', 'c', 'd', 'e', 'f', 'h', 
+  '3', '4', '5', '6', '8', '9', '@', 'A',
+  'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
+  'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R',
+  'S', 'T', 'U', 'V', 'X', 'Y', 'Z', '[',
+  '`', 'a', 'b', 'c', 'd', 'e', 'f', 'h',
   'i', 'j', 'k', 'l', 'm', 'p', 'q', 'r'
 };
 
@@ -242,11 +242,11 @@ char *uuestr_otemp;
  * Encode one part of the data stream
  */
 
-static int 
+static int
 UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc32_t *crc, crc32_t *pcrc)
 {
-  unsigned char *itemp = (unsigned char *) uuestr_itemp;
-  unsigned char *otemp = (unsigned char *) uuestr_otemp;
+  unsigned char *itemp = (char *) uuestr_itemp;
+  unsigned char *otemp = (char *) uuestr_otemp;
   unsigned char *optr, *table, *tptr;
   int index, count;
   long line=0;
@@ -267,12 +267,12 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
 
   if (encoding == PT_ENCODED || encoding == QP_ENCODED) {
     while (!feof (infile) && (linperfile <= 0 || line < linperfile)) {
-      if (_FP_fgets ((char*)itemp, 255, infile) == NULL) {
+      if (_FP_fgets (itemp, 255, infile) == NULL) {
 	break;
       }
 
       itemp[255] = '\0';
-      count = strlen ((char*)itemp);
+      count = strlen (itemp);
 
       llen = 0;
       optr = otemp;
@@ -280,7 +280,7 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
       /*
        * Busy Callback
        */
-      
+
       if (UUBUSYPOLL(ftell(infile)-progress.foffset,progress.fsize)) {
 	UUMessage (uuencode_id, __LINE__, UUMSG_NOTE,
 		   uustring (S_ENCODE_CANCEL));
@@ -292,10 +292,10 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
 	 * If there is a line feed, replace by eolstring
 	 */
 	if (count > 0 && itemp[count-1] == '\n') {
-          const size_t n = strlen ((char*) eolstring);
 	  itemp[--count] = '\0';
 	  if (fwrite (itemp, 1, count, outfile) != count ||
-	      fwrite ((char *) eolstring, 1, n, outfile) != n) {
+	      fwrite ((char *) eolstring, 1,
+		      strlen(eolstring), outfile) != strlen (eolstring)) {
 	    return UURET_IOERR;
 	  }
 	}
@@ -341,7 +341,7 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
 
 	    if (fwrite (otemp, 1, llen, outfile) != llen ||
 		fwrite ((char *) eolstring, 1,
-			strlen((char*)eolstring), outfile) != strlen ((char*)eolstring)) {
+			strlen(eolstring), outfile) != strlen (eolstring)) {
 	      return UURET_IOERR;
 	    }
 
@@ -357,7 +357,7 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
 
 	      if (fwrite (otemp, 1, 3, outfile) != 3 ||
 		  fwrite ((char *) eolstring, 1,
-			  strlen((char*)eolstring), outfile) != strlen ((char*)eolstring)) {
+			  strlen(eolstring), outfile) != strlen (eolstring)) {
 		return UURET_IOERR;
 	      }
 	    }
@@ -386,13 +386,13 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
 
 	    *optr++ = '=';
 	    llen++;
-	    
+
 	    if (fwrite (otemp, 1, llen, outfile) != llen ||
 		fwrite ((char *) eolstring, 1,
-			strlen((char*)eolstring), outfile) != strlen ((char*)eolstring)) {
+			strlen(eolstring), outfile) != strlen (eolstring)) {
 	      return UURET_IOERR;
 	    }
-	    
+
 	    optr = otemp;
 	    llen = 0;
 	  }
@@ -433,7 +433,7 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
       /*
        * Busy Callback
        */
-      
+
       if (UUBUSYPOLL(ftell(infile)-progress.foffset,progress.fsize)) {
 	UUMessage (uuencode_id, __LINE__, UUMSG_NOTE,
 		   uustring (S_ENCODE_CANCEL));
@@ -444,7 +444,7 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
 	if (llen > 127) {
 	  if (fwrite (otemp, 1, llen, outfile) != llen ||
 	      fwrite ((char *) eolstring, 1,
-		      strlen((char*)eolstring), outfile) != strlen ((char*)eolstring)) {
+		      strlen(eolstring), outfile) != strlen (eolstring)) {
 	    return UURET_IOERR;
 	  }
 	  llen = 0;
@@ -490,7 +490,7 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
     if (llen) {
       if (fwrite (otemp, 1, llen, outfile) != llen ||
 	  fwrite ((char *) eolstring, 1,
-		  strlen((char*)eolstring), outfile) != strlen ((char*)eolstring)) {
+		  strlen(eolstring), outfile) != strlen (eolstring)) {
 	return UURET_IOERR;
       }
     }
@@ -563,7 +563,7 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
       if (encoding == B64ENCODED) {
 	if (count - index == 2) {
 	  *optr++ = table[itemp[index] >> 2];
-	  *optr++ = table[((itemp[index  ] & 0x03) << 4) | 
+	  *optr++ = table[((itemp[index  ] & 0x03) << 4) |
 			  ((itemp[index+1] & 0xf0) >> 4)];
 	  *optr++ = table[((itemp[index+1] & 0x0f) << 2)];
 	  *optr++ = '=';
@@ -579,7 +579,7 @@ UUEncodeStream (FILE *outfile, FILE *infile, int encoding, long linperfile, crc3
       else if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
 	if (count - index == 2) {
 	  *optr++ = table[itemp[index] >> 2];
-	  *optr++ = table[((itemp[index  ] & 0x03) << 4) | 
+	  *optr++ = table[((itemp[index  ] & 0x03) << 4) |
 			  ( itemp[index+1] >> 4)];
 	  *optr++ = table[((itemp[index+1] & 0x0f) << 2)];
 	  *optr++ = table[0];
@@ -630,7 +630,7 @@ UUEncodeMulti (FILE *outfile, FILE *infile, char *infname, int encoding,
   crc32_t crc;
   crc32_t *crcptr=NULL;
 
-  if (outfile==NULL || 
+  if (outfile==NULL ||
       (infile == NULL && infname==NULL) ||
       (outfname==NULL && infname==NULL) ||
       (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
@@ -717,7 +717,7 @@ UUEncodeMulti (FILE *outfile, FILE *infile, char *infname, int encoding,
   if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
     fprintf (outfile, "begin %o %s%s",
 	     (themode) ? themode : 0644,
-	     UUFNameFilter ((outfname)?outfname:infname), 
+	     UUFNameFilter ((outfname)?outfname:infname),
 	     eolstring);
   }
   else if (encoding == YENC_ENCODED) {
@@ -725,13 +725,13 @@ UUEncodeMulti (FILE *outfile, FILE *infile, char *infname, int encoding,
     crcptr = &crc;
     if (progress.fsize == -1) {
       fprintf (outfile, "=ybegin line=128 name=%s%s",
-	       UUFNameFilter ((outfname)?outfname:infname), 
+	       UUFNameFilter ((outfname)?outfname:infname),
 	       eolstring);
     }
     else {
       fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s",
 	       progress.fsize,
-	       UUFNameFilter ((outfname)?outfname:infname), 
+	       UUFNameFilter ((outfname)?outfname:infname),
 	       eolstring);
     }
   }
@@ -748,8 +748,8 @@ UUEncodeMulti (FILE *outfile, FILE *infile, char *infname, int encoding,
   }
 
   if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
-    fprintf (outfile, "%c%s",    
-	     (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0], 
+    fprintf (outfile, "%c%s",
+	     (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0],
 	     eolstring);
     fprintf (outfile, "end%s", eolstring);
   }
@@ -793,7 +793,7 @@ UUEncodePartial (FILE *outfile, FILE *infile,
 {
   mimemap *miter=mimetable;
   static FILE *theifile;
-  int themode, numparts=1;
+  int themode, numparts;
   struct stat finfo;
   long thesize;
   char *ptr;
@@ -832,7 +832,7 @@ UUEncodePartial (FILE *outfile, FILE *infile,
       }
       if (linperfile <= 0)
 	numparts = 1;
-      else 
+      else
 	numparts = (int) (((long)finfo.st_size+(linperfile*bpl[encoding]-1))/
 			  (linperfile*bpl[encoding]));
 
@@ -902,7 +902,7 @@ UUEncodePartial (FILE *outfile, FILE *infile,
     }
 
     fprintf (outfile, "%s", eolstring);
-    
+
     /*
      * for the first part of UU or XX messages, print a begin line
      */
@@ -920,33 +920,33 @@ UUEncodePartial (FILE *outfile, FILE *infile,
       if (progress.totsize == -1) {
 	fprintf (outfile, "=ybegin part=%d line=128 name=%s%s",
 		 partno,
-		 UUFNameFilter ((outfname)?outfname:infname), 
+		 UUFNameFilter ((outfname)?outfname:infname),
 		 eolstring);
       }
       else {
 	fprintf (outfile, "=ybegin part=%d line=128 size=%ld name=%s%s",
 		 partno,
 		 progress.totsize,
-		 UUFNameFilter ((outfname)?outfname:infname), 
+		 UUFNameFilter ((outfname)?outfname:infname),
 		 eolstring);
       }
 
-      fprintf (outfile, "=ypart begin=%ld end=%ld%s",
+      fprintf (outfile, "=ypart begin=%d end=%d%s",
 	       (partno-1)*linperfile*128+1,
-	       (partno*linperfile*128) < progress.totsize ? 
+	       (partno*linperfile*128) < progress.totsize ?
 	       (partno*linperfile*128) : progress.totsize,
 	       eolstring);
     }
     else {
       if (progress.totsize == -1) {
 	fprintf (outfile, "=ybegin line=128 name=%s%s",
-		 UUFNameFilter ((outfname)?outfname:infname), 
+		 UUFNameFilter ((outfname)?outfname:infname),
 		 eolstring);
       }
       else {
 	fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s",
 		 progress.totsize,
-		 UUFNameFilter ((outfname)?outfname:infname), 
+		 UUFNameFilter ((outfname)?outfname:infname),
 		 eolstring);
       }
     }
@@ -990,21 +990,21 @@ UUEncodePartial (FILE *outfile, FILE *infile,
 
   if (feof (theifile) &&
       (encoding == UU_ENCODED || encoding == XX_ENCODED)) {
-    fprintf (outfile, "%c%s",    
-	     (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0], 
+    fprintf (outfile, "%c%s",
+	     (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0],
 	     eolstring);
     fprintf (outfile, "end%s", eolstring);
   }
   else if (encoding == YENC_ENCODED) {
     if (numparts != 1) {
-      fprintf (outfile, "=yend size=%ld part=%d pcrc32=%08lx",
-	       (partno*linperfile*128) < progress.totsize ? 
+      fprintf (outfile, "=yend size=%d part=%d pcrc32=%08lx",
+	       (partno*linperfile*128) < progress.totsize ?
 	       linperfile*128 : (progress.totsize-(partno-1)*linperfile*128),
 	       partno,
 	       pcrc);
     }
     else {
-      fprintf (outfile, "=yend size=%ld",
+      fprintf (outfile, "=yend size=%d",
 	       progress.totsize);
     }
     if (feof (theifile))
@@ -1112,7 +1112,7 @@ UUEncodeToStream (FILE *outfile, FILE *infile,
   if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
     fprintf (outfile, "begin %o %s%s",
 	     (themode) ? themode : 0644,
-	     UUFNameFilter ((outfname)?outfname:infname), 
+	     UUFNameFilter ((outfname)?outfname:infname),
 	     eolstring);
   }
   else if (encoding == YENC_ENCODED) {
@@ -1120,13 +1120,13 @@ UUEncodeToStream (FILE *outfile, FILE *infile,
     crcptr = &crc;
     if (progress.fsize == -1) {
       fprintf (outfile, "=ybegin line=128 name=%s%s",
-	       UUFNameFilter ((outfname)?outfname:infname), 
+	       UUFNameFilter ((outfname)?outfname:infname),
 	       eolstring);
     }
     else {
       fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s",
 	       progress.fsize,
-	       UUFNameFilter ((outfname)?outfname:infname), 
+	       UUFNameFilter ((outfname)?outfname:infname),
 	       eolstring);
     }
   }
@@ -1135,7 +1135,7 @@ UUEncodeToStream (FILE *outfile, FILE *infile,
     if (res != UURET_CANCEL) {
       UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
 		 uustring (S_ERR_ENCODING),
-		 UUFNameFilter ((infname)?infname:outfname), 
+		 UUFNameFilter ((infname)?infname:outfname),
 		 (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res));
     }
     progress.action = 0;
@@ -1143,8 +1143,8 @@ UUEncodeToStream (FILE *outfile, FILE *infile,
   }
 
   if (encoding == UU_ENCODED || encoding == XX_ENCODED) {
-    fprintf (outfile, "%c%s",    
-	     (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0], 
+    fprintf (outfile, "%c%s",
+	     (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0],
 	     eolstring);
     fprintf (outfile, "end%s", eolstring);
   }
@@ -1212,7 +1212,7 @@ UUEncodeToFile (FILE *infile, char *infname, int encoding,
       sprintf (oname, "%s", diskname);
     }
     else {
-      len = ((uusavepath)?strlen(uusavepath):0) + strlen (diskname) 
+      len = ((uusavepath)?strlen(uusavepath):0) + strlen (diskname)
 	+ ((uuencodeext)?strlen(uuencodeext):0) + 5;
 
       if ((oname = malloc (len)) == NULL) {
@@ -1224,7 +1224,7 @@ UUEncodeToFile (FILE *infile, char *infname, int encoding,
     }
   }
   else {
-    len = ((uusavepath) ? strlen (uusavepath) : 0) + 
+    len = ((uusavepath) ? strlen (uusavepath) : 0) +
       strlen(UUFNameFilter(infname)) +
 	((uuencodeext)?strlen(uuencodeext):0) + 5;
 
@@ -1234,7 +1234,7 @@ UUEncodeToFile (FILE *infile, char *infname, int encoding,
       return UURET_NOMEM;
     }
     optr = UUFNameFilter (infname);
-    sprintf (oname, "%s%s", 
+    sprintf (oname, "%s%s",
 	     (uusavepath)?uusavepath:"",
 	     (*optr=='.')?optr+1:optr);
   }
@@ -1275,7 +1275,7 @@ UUEncodeToFile (FILE *infile, char *infname, int encoding,
     }
     if (linperfile <= 0)
       numparts = 1;
-    else 
+    else
       numparts = (int) (((long)finfo.st_size + (linperfile*bpl[encoding]-1)) /
 			(linperfile*bpl[encoding]));
 
@@ -1313,7 +1313,7 @@ UUEncodeToFile (FILE *infile, char *infname, int encoding,
      */
     if (progress.numparts==1 && progress.totsize!=-1 && uuencodeext!=NULL)
       strcpy  (optr, uuencodeext);
-    else 
+    else
       sprintf (optr, "%03d", part);
 
     /*
@@ -1380,7 +1380,7 @@ UUEncodeToFile (FILE *infile, char *infname, int encoding,
     if (part==1 && (encoding == UU_ENCODED || encoding == XX_ENCODED)) {
       fprintf (outfile, "begin %o %s%s",
 	       (filemode)?filemode : 0644,
-	       UUFNameFilter ((outfname)?outfname:infname), 
+	       UUFNameFilter ((outfname)?outfname:infname),
 	       eolstring);
     }
     else if (encoding == YENC_ENCODED) {
@@ -1394,33 +1394,33 @@ UUEncodeToFile (FILE *infile, char *infname, int encoding,
 	if (progress.totsize == -1) {
 	  fprintf (outfile, "=ybegin part=%d line=128 name=%s%s",
 		   part,
-		   UUFNameFilter ((outfname)?outfname:infname), 
+		   UUFNameFilter ((outfname)?outfname:infname),
 		   eolstring);
 	}
 	else {
 	  fprintf (outfile, "=ybegin part=%d line=128 size=%ld name=%s%s",
 		   part,
 		   progress.totsize,
-		   UUFNameFilter ((outfname)?outfname:infname), 
+		   UUFNameFilter ((outfname)?outfname:infname),
 		   eolstring);
 	}
 
-	fprintf (outfile, "=ypart begin=%ld end=%ld%s",
+	fprintf (outfile, "=ypart begin=%d end=%d%s",
 		 (part-1)*linperfile*128+1,
-		 (part*linperfile*128) < progress.totsize ? 
+		 (part*linperfile*128) < progress.totsize ?
 		 (part*linperfile*128) : progress.totsize,
 		 eolstring);
       }
       else {
 	if (progress.totsize == -1) {
 	  fprintf (outfile, "=ybegin line=128 name=%s%s",
-		   UUFNameFilter ((outfname)?outfname:infname), 
+		   UUFNameFilter ((outfname)?outfname:infname),
 		   eolstring);
 	}
 	else {
 	  fprintf (outfile, "=ybegin line=128 size=%ld name=%s%s",
 		   progress.totsize,
-		   UUFNameFilter ((outfname)?outfname:infname), 
+		   UUFNameFilter ((outfname)?outfname:infname),
 		   eolstring);
 	}
       }
@@ -1431,7 +1431,7 @@ UUEncodeToFile (FILE *infile, char *infname, int encoding,
       if (res != UURET_CANCEL) {
 	UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
 		   uustring (S_ERR_ENCODING),
-		   UUFNameFilter ((infname)?infname:outfname),	 
+		   UUFNameFilter ((infname)?infname:outfname),
 		   (res==UURET_IOERR)?strerror(uu_errno):UUstrerror (res));
       }
       if (infile==NULL) fclose (theifile);
@@ -1444,25 +1444,25 @@ UUEncodeToFile (FILE *infile, char *infname, int encoding,
 
     if (feof (theifile) &&
 	(encoding == UU_ENCODED || encoding == XX_ENCODED)) {
-      fprintf (outfile, "%c%s",    
-	       (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0], 
+      fprintf (outfile, "%c%s",
+	       (encoding==UU_ENCODED) ? UUEncodeTable[0] : XXEncodeTable[0],
 	       eolstring);
       fprintf (outfile, "end%s", eolstring);
     }
     else if (encoding == YENC_ENCODED) {
       if (numparts != 1) {
-	fprintf (outfile, "=yend size=%ld part=%d pcrc32=%08lx",
-		 (part*linperfile*128) < progress.totsize ? 
+	fprintf (outfile, "=yend size=%d part=%d pcrc32=%08lx",
+		 (part*linperfile*128) < progress.totsize ?
 		 linperfile*128 : (progress.totsize-(part-1)*linperfile*128),
 		 part,
 		 pcrc);
       }
       else {
-	fprintf (outfile, "=yend size=%ld",
+	fprintf (outfile, "=yend size=%d",
 		 progress.totsize);
       }
       if (feof (theifile))
-	fprintf (outfile, " crc32=%08lx", crc); 
+	fprintf (outfile, " crc32=%08lx", crc);
       fprintf (outfile, "%s", eolstring);
     }
 
@@ -1545,15 +1545,15 @@ UUE_PrepSingleExt (FILE *outfile, FILE *infile,
 
   if (encoding == YENC_ENCODED) {
     if (subject)
-      sprintf (subline, "- %s - %s (001/001)", oname, subject);
+      sprintf (subline, "%s \"%s\" (1/1)", subject, oname);
     else
-      sprintf (subline, "- %s - (001/001)", oname);
+      sprintf (subline, "%s (1/1)", oname);
   }
   else {
     if (subject)
-      sprintf (subline, "%s (001/001) - [ %s ]", subject, oname);
+      sprintf (subline, "%s (1/1) - [ %s ]", subject, oname);
     else
-      sprintf (subline, "[ %s ] (001/001)", oname);
+      sprintf (subline, "[ %s ] (1/1)", oname);
   }
 
   if (from) {
@@ -1585,7 +1585,7 @@ UUE_PrepSingleExt (FILE *outfile, FILE *infile,
 
   res = UUEncodeToStream (outfile, infile, infname, encoding,
 			  outfname, filemode);
-  
+
   _FP_free (subline);
   return res;
 }
@@ -1657,7 +1657,7 @@ UUE_PrepPartialExt (FILE *outfile, FILE *infile,
       }
       if (linperfile <= 0)
 	numparts = 1;
-      else 
+      else
 	numparts = (int) (((long)finfo.st_size+(linperfile*bpl[encoding]-1))/
 			  (linperfile*bpl[encoding]));
 
@@ -1725,23 +1725,24 @@ UUE_PrepPartialExt (FILE *outfile, FILE *infile,
   }
 
 
+  /* 1.3 draft: [Comment1] "filename" yEnc (partnum/numparts) [size] [Comment2] */
   if (encoding == YENC_ENCODED) {
     if (partno == 1)
       crc = crc32(0L, Z_NULL, 0);
     crcptr = &crc;
     if (subject)
-      sprintf (subline, "- %s - %s (%03d/%03d)", oname, subject,
+      sprintf (subline, "%s \"%s\" (%d/%d)", subject, oname,
 	       partno, numparts);
     else
-      sprintf (subline, "- %s - (%03d/%03d)", oname,
+      sprintf (subline, "%s (%d/%d)", oname,
 	       partno, numparts);
   }
   else {
     if (subject)
-      sprintf (subline, "%s (%03d/%03d) - [ %s ]", 
+      sprintf (subline, "%s (%d/%d) - [ %s ]",
 	       subject, partno, numparts, oname);
     else
-      sprintf (subline, "[ %s ] (%03d/%03d)",
+      sprintf (subline, "[ %s ] (%d/%d)",
 	       oname, partno, numparts);
   }
 
@@ -1768,7 +1769,7 @@ UUE_PrepPartialExt (FILE *outfile, FILE *infile,
     fprintf (outfile, "\tid=\"%s\"%s",
 	     mimeid, eolstring);
   }
-    
+
   fprintf (outfile, "%s", eolstring);
 
   res = UUEncodePartial (outfile, theifile,



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