[pan2: 114/268] TODO : debug references header



commit 069d921d55bb8a8e735082231810c5aeaac4f9f4
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Tue Jul 5 17:25:19 2011 +0200

    TODO : debug references header

 pan/general/debug.cc     |    2 +-
 pan/gui/post-ui.cc       |   20 ++++++++++++++------
 pan/gui/post-ui.h        |    2 +-
 pan/tasks/task-upload.cc |   20 +++++++++++---------
 4 files changed, 27 insertions(+), 17 deletions(-)
---
diff --git a/pan/general/debug.cc b/pan/general/debug.cc
index 2e6cfb4..c6414eb 100644
--- a/pan/general/debug.cc
+++ b/pan/general/debug.cc
@@ -3,6 +3,6 @@
 
 namespace pan
 {
-  bool _debug_flag = false;
+  bool _debug_flag = true;
   bool _debug_verbose_flag = false;
 }
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index bc40853..714fc78 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -831,7 +831,7 @@ PostUI :: send_and_save_now ()
 
   if (_save_file.empty()) return;
 
-  GMimeMessage * message (new_message_from_ui (POSTING));
+  GMimeMessage * message (new_message_from_ui (UPLOADING));
   if (!maybe_post_message (message))
     g_object_unref (G_OBJECT(message));
 }
@@ -1096,12 +1096,20 @@ PostUI :: maybe_post_message (GMimeMessage * message)
       int total = get_total_parts(t->_filename.c_str(), t);
 
       std::string last_mid;
+
+      StringView d;
+      const char * pch = domain.strchr ('@');
+      if (pch != NULL)
+         d = domain.substr (pch+1, NULL);
+      else
+        d = domain;
+
       foreach (std::set<int>, t->_wanted, pit)
       {
         if (custom_mid)
         {
             std::string out;
-            generate_unique_id(domain, *pit,out);
+            generate_unique_id(d, *pit,out);
             n.mid = out;
             n.last_mid = last_mid;
             // set father mid to first part of upload
@@ -1486,7 +1494,7 @@ PostUI :: new_message_from_ui (Mode mode)
   GMimeDataWrapper * content_object = g_mime_data_wrapper_new_with_stream (stream, GMIME_CONTENT_ENCODING_DEFAULT);
   g_object_unref (stream);
   GMimePart * part = g_mime_part_new ();
-  if (_file_queue_empty)
+  if (mode == POSTING || mode == DRAFTING)
     pch = g_strdup_printf ("text/plain; charset=%s", charset.c_str());
   else
     // http://tools.ietf.org/html/rfc2046#section-5.1.3
@@ -2983,7 +2991,7 @@ PostUI :: prompt_user_for_queueable_files (GtkWindow * parent, const Prefs& pref
 {
   const Profile profile (get_current_profile ());
   PostUI::tasks_t tasks;
-  GMimeMessage * tmp (new_message_from_ui (POSTING));
+  GMimeMessage * tmp (new_message_from_ui (UPLOADING));
 
   if (!check_message(profile.posting_server, tmp, true))
   {
@@ -3018,7 +3026,7 @@ PostUI :: prompt_user_for_queueable_files (GtkWindow * parent, const Prefs& pref
         GSList * cur = g_slist_nth (tmp_list,0);
         for (; cur; cur = cur->next)
         {
-          GMimeMessage * msg (new_message_from_ui (POSTING));
+          GMimeMessage * msg (new_message_from_ui (UPLOADING));
 
           //for nzb handling
           Article a;
@@ -3045,7 +3053,7 @@ PostUI :: prompt_user_for_queueable_files (GtkWindow * parent, const Prefs& pref
 
           TaskUpload* tmp = new TaskUpload(std::string((const char*)cur->data),
                             profile.posting_server, _cache,
-                            a, ui, msg,0, TaskUpload::YENC);
+                            a, ui, msg ,0, TaskUpload::YENC);
 
           for (int i=1;i<=ui.total; ++i)
             tmp->_wanted.insert(i);
diff --git a/pan/gui/post-ui.h b/pan/gui/post-ui.h
index 09f5bbf..6cbc40f 100644
--- a/pan/gui/post-ui.h
+++ b/pan/gui/post-ui.h
@@ -174,7 +174,7 @@ namespace pan
       void add_actions (GtkWidget* box);
       void apply_profile_to_body ();
       void apply_profile_to_headers ();
-      enum Mode { DRAFTING, POSTING };
+      enum Mode { DRAFTING, POSTING, UPLOADING };
       GMimeMessage * new_message_from_ui (Mode mode);
       Profile get_current_profile ();
       bool check_message (const Quark& server, GMimeMessage*, bool binpost=false);
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index c3221f1..af19b55 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -92,10 +92,12 @@ TaskUpload :: TaskUpload (const std::string         & filename,
   _queue_pos(0),
   _msg (msg),
   _total_parts(format.total),
-  _save_file(format.save_file),
-  _references(g_mime_object_get_header ((GMimeObject *)msg, "References"))
+  _save_file(format.save_file)
 {
 
+  const char * tmp (g_mime_object_get_header ((GMimeObject *)_msg, "References"));
+  if (tmp) _references = std::string(tmp);
+
   struct stat sb;
   stat(filename.c_str(),&sb);
   _bytes = sb.st_size;
@@ -157,10 +159,11 @@ void
 TaskUpload :: add_reference_to_list(std::string s)
 {
   char buf[4096];
+//  std::cerr<<"references old : "<<_references<<std::endl;
   g_snprintf(buf,sizeof(buf),"%s <%s>", _references.empty()  ? "": _references.c_str() , s.c_str());
-//  mut.lock();
+//  std::cerr<<"references new : "<<buf<<std::endl;
   g_mime_object_set_header ((GMimeObject *)_msg, "References", buf);
-//  mut.unlock;
+//  std::cerr<<"references msg : "<<g_mime_object_get_header((GMimeObject*)_msg,"References")<<std::endl;
 }
 
 void
@@ -173,20 +176,19 @@ TaskUpload :: prepend_headers(GMimeMessage* msg, TaskUpload::Needed * n, std::st
 
     //modify subject
     char buf[2048];
-    g_snprintf(buf, sizeof(buf), "%s - \"%s\" - %s(%03d/%03d)",
+    g_snprintf(buf, sizeof(buf), "%s - \"%s\" - %s(%d/%d)",
                _subject.c_str(),
                _basename.c_str(),
                (_encode_mode==YENC ? " yEnc ":""),
                n->partno, _total_parts);
     g_mime_message_set_subject (msg, buf);
 
-    ///TODO debug
-//    if (!n->last_mid.empty())
-//      add_reference_to_list(n->last_mid);
+    if (!n->last_mid.empty())
+      add_reference_to_list(n->last_mid);
 
     //extract body
-    gboolean unused;
     char * body (g_mime_object_to_string ((GMimeObject *) msg));
+    std::cerr<<"\n"<<body<<"\n--------------------------\n\n";
     out << body << "\n";
     out << d;
     d = out.str();



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