[pan2: 83/268] [+] text gets posted with binary uploads



commit 1bd70b7f7a685871c36af245df7a7467310fe2e5
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Tue Jun 28 12:33:33 2011 +0200

    [+] text gets posted with binary uploads

 pan/gui/post-ui.cc       |   15 ++++++---------
 pan/tasks/encoder.cc     |   11 ++++++-----
 pan/tasks/encoder.h      |    2 ++
 pan/tasks/task-upload.cc |    4 +++-
 pan/tasks/task-upload.h  |    5 +++--
 uulib/uudeview.h         |    8 ++++----
 uulib/uuencode.c         |   22 +++++++++++++++-------
 7 files changed, 39 insertions(+), 28 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index 61b7bbc..580e0a3 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -1379,10 +1379,6 @@ 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);
-  /* NOTE (imhotep): Text gets ignored when posting binary data, ATM.
-   * Perhaps this could be changed but I don't really care right now. It would be the same message for all binary files
-   * anyway, so this would be kind of useless...
-   */
   GMimePart * part = g_mime_part_new ();
   pch = g_strdup_printf ("text/plain; charset=%s", charset.c_str());
 
@@ -1900,7 +1896,6 @@ PostUI :: set_message (GMimeMessage * message)
 
   // update subject, newsgroups, to fields
   std::string s = utf8ize (g_mime_message_get_subject (message));
-  std::cerr<<"subject : "<<s<<std::endl;
   gtk_entry_set_text (GTK_ENTRY(_subject_entry), s.c_str());
 
   s = utf8ize (g_mime_object_get_header ((GMimeObject *) message, "Newsgroups"));
@@ -2050,7 +2045,6 @@ gboolean
 PostUI :: body_changed_idle (gpointer ui_gpointer)
 {
   PostUI * ui (static_cast<PostUI*>(ui_gpointer));
-  std::cerr<<"body changed idle "<<ui->_draft_autosave_timeout <<"\n";
 
   ui->_body_changed_idle_tag = 0;
   unsigned int& tag (ui->_draft_autosave_idle_tag);
@@ -2063,7 +2057,6 @@ PostUI :: body_changed_idle (gpointer ui_gpointer)
 void
 PostUI :: body_changed_cb (GtkEditable*, gpointer ui_gpointer)
 {
-  std::cerr<<"body changed cb\n";
   PostUI * ui (static_cast<PostUI*>(ui_gpointer));
   unsigned int& tag (ui->_body_changed_idle_tag);
   if (!tag)
@@ -2708,8 +2701,6 @@ PostUI::draft_save_cb(gpointer ptr)
     std::string& draft_filename (get_draft_filename ());
     char * filename = g_build_filename (draft_filename.c_str(), "autosave", NULL);
 
-    std::cerr<<"auto-saving draft "<<filename<<"\n";
-
     std::ofstream o (filename);
     char * pch = g_mime_object_to_string ((GMimeObject *) msg);
     o << pch;
@@ -2914,6 +2905,12 @@ PostUI :: prompt_user_for_queueable_files (GtkWindow * parent, const Prefs& pref
       ? GNKSA::generate_message_id (profile.fqdn)
       : GNKSA::generate_message_id_from_email_address (profile.address);
 
+    // fill in message text
+    // NOTE: message text is saved on taskupload constructor, and doesn't change thereafter
+    // that means that if the user makes changes on the body buffer, they don't reflect in
+    // the upload!!
+    ui.buf = get_body ();
+
     for (; cur; cur = cur->next)
 	{
 	  Article a;
diff --git a/pan/tasks/encoder.cc b/pan/tasks/encoder.cc
index f131033..21b6733 100644
--- a/pan/tasks/encoder.cc
+++ b/pan/tasks/encoder.cc
@@ -99,6 +99,7 @@ Encoder :: enqueue (TaskUpload                      * task,
                     std::string                     & format,
                     std::string                       global_mid,
                     int                               lpf,
+                    std::string                       buf,
                     const TaskUpload::EncodeMode    & enc)
 
 {
@@ -118,6 +119,7 @@ Encoder :: enqueue (TaskUpload                      * task,
   this->article = article;
   this->format = format;
   this->lpf = lpf;
+  this->buffer = buf;
 
   percent = 0;
   current_file.clear ();
@@ -175,11 +177,12 @@ Encoder :: do_work()
         StringView mid(global_mid);
         if (!global_mid.empty())
           generate_unique_id(mid, cnt, s);
+        std::cerr<<"buffer encode "<<(char*)buffer.c_str()<<std::endl;
         res = UUE_PrepPartial (fp, NULL, (char*)filename.c_str(),YENC_ENCODED,
                                (char*)basename.c_str(),0644, cnt, lpf,
-                               0, (char*)groups.c_str(),
-                               (char*)author.c_str(),
-                               (char*)subject.c_str(), s.empty() ? NULL : (char*)s.c_str(), (char*)format.c_str(), agent.empty() ? NULL : (char*)agent.c_str(), 0);
+                               0, (char*)groups.c_str(), (char*)author.c_str(),
+                               (char*)subject.c_str(), s.empty() ? NULL : (char*)s.c_str(), (char*)format.c_str(),
+                               agent.empty() ? NULL : (char*)agent.c_str(), (char*)buffer.c_str(), 0);
 
         if (fp) fclose(fp);
         if (res != UURET_CONT && res != UURET_OK) break;
@@ -192,8 +195,6 @@ Encoder :: do_work()
         if (res != UURET_CONT) break;
       }
 
-      std::cerr<<"debug "<<needed->size()<<" "<<cnt<<std::endl;
-
       if (res != UURET_OK && res != UURET_CONT)
       {
         g_snprintf(buf, bufsz,
diff --git a/pan/tasks/encoder.h b/pan/tasks/encoder.h
index 9c01158..11d19c4 100644
--- a/pan/tasks/encoder.h
+++ b/pan/tasks/encoder.h
@@ -73,6 +73,7 @@ namespace pan
                     std::string                     & format,
                     std::string                       global_mid,
                     int                               lpf,
+                    std::string                       buf,
                     const TaskUpload::EncodeMode    & enc = TaskUpload::YENC);
 
     public:
@@ -98,6 +99,7 @@ namespace pan
       std::string global_mid;
       Article * article;
       MTRand mtrand;
+      std::string buffer;
 
       void generate_unique_id (StringView& mid, int cnt, std::string& s);
 
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 7960ad1..ced4c0f 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -113,6 +113,8 @@ TaskUpload :: TaskUpload (const std::string         & filename,
   _lpf(format.lpf)
 {
 
+    std::cerr<<"body : "<<format.buf<<std::endl;
+
   if (!format.domain.empty())  _domain = get_domain(StringView(format.domain)) ;
 
   if (!imported.empty())
@@ -364,7 +366,7 @@ TaskUpload :: use_encoder (Encoder* encoder)
   format_s << " (%d/%d) yEnc";     // will be filled in by uuencode
   std::string format(format_s.str());
   _encoder->enqueue (this, &_cache, &_article, _filename, _basename,
-                     groups, _subject, _author, _agent, format, _domain, _lpf, YENC);
+                     groups, _subject, _author, _agent, format, _domain, _lpf, _format.buf, YENC);
   debug ("encoder thread was free, enqueued work");
 }
 
diff --git a/pan/tasks/task-upload.h b/pan/tasks/task-upload.h
index 7094f05..47fc477 100644
--- a/pan/tasks/task-upload.h
+++ b/pan/tasks/task-upload.h
@@ -52,8 +52,9 @@ namespace pan
       struct UploadInfo
       {
         bool comment1;
-        std::string    domain;
-        std::string    save_file;
+        std::string  domain;
+        std::string  save_file;
+        std::string  buf;
         int lpf;
       };
 
diff --git a/uulib/uudeview.h b/uulib/uudeview.h
index 4f7e446..9209f2c 100644
--- a/uulib/uudeview.h
+++ b/uulib/uudeview.h
@@ -237,25 +237,25 @@ int	UUEXPORT UUEncodeToFile		_ANSI_ARGS_((FILE *, char *, int,
 int	UUEXPORT UUE_PrepSingle		_ANSI_ARGS_((FILE *, FILE *,
 						     char *, int,
 						     char *, int,
-						     char *, char *, char*, char*, char*,
+						     char *, char *, char*, char*, char*, char*,
 						     char *, int));
 int	UUEXPORT UUE_PrepPartial	_ANSI_ARGS_((FILE *, FILE *,
 						     char *, int,
 						     char *, int,
 						     int, long, long,
-						     char *, char *, char*, char*, char*, char*, int));
+						     char *, char *, char*, char*, char*, char*, char*, int));
 
 int	UUEXPORT UUE_PrepSingleExt	_ANSI_ARGS_((FILE *, FILE *,
 						     char *, int,
 						     char *, int,
 						     char *, char *,
-						     char *, char *, char*, char*, char*,
+						     char *, char *, char*, char*, char*, char*,
 						     int));
 int	UUEXPORT UUE_PrepPartialExt	_ANSI_ARGS_((FILE *, FILE *,
 						     char *, int,
 						     char *, int,
 						     int, long, long, char *, char*,
-						     char *, char *, char *,char*, char*,
+						     char *, char *, char *,char*, char*, char*,
 						     int));
 #ifdef __cplusplus
 }
diff --git a/uulib/uuencode.c b/uulib/uuencode.c
index f7e4d88..ec0f9d3 100644
--- a/uulib/uuencode.c
+++ b/uulib/uuencode.c
@@ -1491,13 +1491,13 @@ UUE_PrepSingle (FILE *outfile, FILE *infile,
 		char *infname, int encoding,
 		char *outfname, int filemode,
 		char *destination, char *from,
-		char *subject, char* mid, char* format, char* agent, int isemail)
+		char *subject, char* mid, char* format, char* agent, char* buffer, int isemail)
 {
   return UUE_PrepSingleExt (outfile, infile,
 			    infname, encoding,
 			    outfname, filemode,
 			    destination, from,
-			    subject, mid, NULL, format, agent,
+			    subject, mid, NULL, format, agent, buffer,
 			    isemail);
 }
 
@@ -1506,7 +1506,7 @@ UUE_PrepSingleExt (FILE *outfile, FILE *infile,
 		   char *infname, int encoding,
 		   char *outfname, int filemode,
 		   char *destination, char *from,
-		   char *subject, char* mid, char *replyto, char* format, char* agent,
+		   char *subject, char* mid, char *replyto, char* format, char* agent, char* buffer,
 		   int isemail)
 {
   mimemap *miter=mimetable;
@@ -1597,6 +1597,10 @@ UUE_PrepSingleExt (FILE *outfile, FILE *infile,
 
   fprintf (outfile, "%s", eolstring);
 
+  // pan change (imhotep) : add preamble text
+  if (buffer)
+    fprintf (outfile, "%s%s%s%s", eolstring, buffer, eolstring, eolstring);
+
   res = UUEncodeToStream (outfile, infile, infname, encoding,
 			  outfname, filemode);
 
@@ -1609,7 +1613,7 @@ 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, char* mid, char* format, char* agent,
+		 char *destination, char *from, char *subject, char* mid, char* format, char* agent, char* buffer,
 		 int isemail)
 {
   return UUE_PrepPartialExt (outfile, infile,
@@ -1617,7 +1621,7 @@ UUE_PrepPartial (FILE *outfile, FILE *infile,
 			     outfname, filemode,
 			     partno, linperfile, filesize,
 			     destination,
-			     from, subject, mid, NULL, format, agent,
+			     from, subject, mid, NULL, format, agent, buffer,
 			     isemail);
 }
 
@@ -1627,7 +1631,7 @@ UUE_PrepPartialExt (FILE *outfile, FILE *infile,
 		    char *outfname, int filemode,
 		    int partno, long linperfile, long filesize,
 		    char *destination,
-		    char *from, char *subject, char* mid, char *replyto, char* format, char* agent,
+		    char *from, char *subject, char* mid, char *replyto, char* format, char* agent, char* buffer,
 		    int isemail)
 {
   static int numparts, themode;
@@ -1721,7 +1725,7 @@ UUE_PrepPartialExt (FILE *outfile, FILE *infile,
       if (infile==NULL) fclose (theifile);
       return UUE_PrepSingleExt (outfile, infile, infname, encoding,
 				outfname, filemode, destination,
-				from, subject, mid, replyto, format, agent, isemail);
+				from, subject, mid, replyto, format, agent, buffer, isemail);
     }
 
     /*
@@ -1797,6 +1801,10 @@ UUE_PrepPartialExt (FILE *outfile, FILE *infile,
 
   fprintf (outfile, "%s", eolstring);
 
+  // pan change (imhotep) : add preamble text
+  if (buffer)
+    fprintf (outfile, "%s%s%s%s", eolstring, buffer, eolstring, eolstring);
+
   res = UUEncodePartial (outfile, theifile,
 			 infname, encoding,
 			 (outfname)?outfname:infname, NULL,



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