[pan2: 65/268] added user agent header for encoded files



commit 1d4e4fd3d0372a4baa5e2794d48c6341e1a58673
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date:   Mon Jun 13 21:28:30 2011 +0200

    added user agent header for encoded files

 pan/gui/post-ui.cc       |    3 ++-
 pan/tasks/encoder.cc     |    4 +++-
 pan/tasks/encoder.h      |    3 ++-
 pan/tasks/task-upload.cc |    8 +++++++-
 pan/tasks/task-upload.h  |    1 +
 uulib/uudeview.h         |    8 ++++----
 uulib/uuencode.c         |   28 +++++++++++++++++++---------
 7 files changed, 38 insertions(+), 17 deletions(-)
---
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index f89011b..003f926 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -2462,7 +2462,7 @@ gtk_widget_set_tooltip_text (w, _("The email account where mail replies to your
 
   ++row;
   w = _message_id_check = gtk_check_button_new_with_mnemonic (_("Add \"Message-_Id header"));
-  b = _prefs.get_flag (MESSAGE_ID_PREFS_KEY, false) || _prefs.get_flag("upload-enable-custom-mid",false);
+  b = _prefs.get_flag("upload-enable-custom-mid",false);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(w), b);
   g_signal_connect (w, "toggled", G_CALLBACK(message_id_toggled_cb), &_prefs);
   gtk_table_attach (GTK_TABLE(t), w, 0, 2, row, row+1, GTK_FILL, GTK_FILL, 0, 0);
@@ -2785,6 +2785,7 @@ PostUI :: prompt_user_for_queueable_files (GtkWindow * parent, const Prefs& pref
     bool comment1 = _prefs.get_flag("upload-queue-append-subject-enabled",false);
     TaskUpload::UploadInfo ui;
     ui.comment1 = comment1;
+
     // generate domain name for upload if the flag is set
     bool custom_mid(_prefs.get_flag(MESSAGE_ID_PREFS_KEY,false));
     if (custom_mid)
diff --git a/pan/tasks/encoder.cc b/pan/tasks/encoder.cc
index 5c6329f..5aaf84e 100644
--- a/pan/tasks/encoder.cc
+++ b/pan/tasks/encoder.cc
@@ -92,6 +92,7 @@ Encoder :: enqueue (TaskUpload                      * task,
                     std::string                     & groups,
                     std::string                     & subject,
                     std::string                     & author,
+                    std::string                     & agent,
                     std::string                     & format,
                     std::string                       global_mid,
                     const TaskUpload::EncodeMode    & enc)
@@ -106,6 +107,7 @@ Encoder :: enqueue (TaskUpload                      * task,
   this->groups = groups;
   this->subject = subject;
   this->author = author;
+  this->agent = agent;
   this->needed = &task->_needed;
   this->global_mid = global_mid;
   this->cache = cache;
@@ -175,7 +177,7 @@ Encoder :: do_work()
                                (char*)basename.c_str(),0644, cnt, 4000,
                                0, (char*)groups.c_str(),
                                (char*)author.c_str(),
-                               (char*)subject.c_str(), s.empty() ? NULL : (char*)s.c_str(), (char*)format.c_str(), 0);
+                               (char*)subject.c_str(), s.empty() ? NULL : (char*)s.c_str(), (char*)format.c_str(), agent.empty() ? NULL : (char*)agent.c_str(), 0);
 
         if (fp) fclose(fp);
 //        if (res != UURET_CONT && res != UURET_OK) break;
diff --git a/pan/tasks/encoder.h b/pan/tasks/encoder.h
index 5562a96..ca0fe80 100644
--- a/pan/tasks/encoder.h
+++ b/pan/tasks/encoder.h
@@ -69,6 +69,7 @@ namespace pan
                     std::string                     & groups,
                     std::string                     & subject,
                     std::string                     & author,
+                    std::string                     & agent,
                     std::string                     & format,
                     std::string                       global_mid,
                     const TaskUpload::EncodeMode    & enc = TaskUpload::YENC);
@@ -89,7 +90,7 @@ namespace pan
       TaskUpload * task;
       TaskUpload::EncodeMode encode_mode;
       std::string   basename, filename;
-      std::string subject, author, groups, mid, format;
+      std::string subject, author, groups, mid, format, agent;
       EncodeCache * cache;
       TaskUpload::needed_t * needed;
       std::string global_mid;
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 4998d87..295504c 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -62,6 +62,11 @@ namespace
     g_free(freeme);
     return buf;
   }
+
+  const char * get_user_agent () //from post-ui.cc
+  {
+      return "Pan/" PACKAGE_VERSION " (" VERSION_TITLE "; " GIT_REV ")";
+  }
 }
 
 std::string
@@ -103,6 +108,7 @@ TaskUpload :: TaskUpload (const std::string         & filename,
   _all_bytes(0),
   _format(format),
   _save_file(format.save_file),
+  _agent(get_user_agent()),
   _queue_pos(0)
 {
 
@@ -355,7 +361,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, format , _domain, YENC);
+                     groups, _subject, _author, _agent, format , _domain, YENC);
   debug ("encoder thread was free, enqueued work");
 }
 
diff --git a/pan/tasks/task-upload.h b/pan/tasks/task-upload.h
index b4fe01b..0b68e55 100644
--- a/pan/tasks/task-upload.h
+++ b/pan/tasks/task-upload.h
@@ -145,6 +145,7 @@ namespace pan
       std::string _save_file;
       Article::mid_sequence_t _mids;
       int _queue_pos;
+      std::string _agent;
 
     private:
       needed_t       _needed;
diff --git a/uulib/uudeview.h b/uulib/uudeview.h
index 7f56591..4f7e446 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 *, int));
 int	UUEXPORT UUE_PrepPartial	_ANSI_ARGS_((FILE *, FILE *,
 						     char *, int,
 						     char *, int,
 						     int, long, long,
-						     char *, char *, char*, char*, char*, int));
+						     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*,
 						     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*,
 						     int));
 #ifdef __cplusplus
 }
diff --git a/uulib/uuencode.c b/uulib/uuencode.c
index adcf4ff..05da2a3 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, int isemail)
+		char *subject, char* mid, char* format, char* agent, int isemail)
 {
   return UUE_PrepSingleExt (outfile, infile,
 			    infname, encoding,
 			    outfname, filemode,
 			    destination, from,
-			    subject, mid, NULL, format,
+			    subject, mid, NULL, format, agent,
 			    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 *subject, char* mid, char *replyto, char* format, char* agent,
 		   int isemail)
 {
   mimemap *miter=mimetable;
@@ -1569,12 +1569,17 @@ UUE_PrepSingleExt (FILE *outfile, FILE *infile,
 
   fprintf (outfile, "Subject: %s%s", subline, eolstring);
 
-  // pan change (imhotep) : add unique mid for saving the upload queue to hdd
+  // pan change (imhotep) : add unique mid for saving the upload queue to hdd, add user agent
   if (mid)
   {
     fprintf(outfile, "Message-ID: <%s>%s", mid, eolstring);
   }
 
+  if (agent)
+  {
+    fprintf(outfile, "User-Agent: %s%s", agent, eolstring);
+  }
+
 
   if (replyto) {
     fprintf (outfile, "Reply-To: %s%s", replyto, eolstring);
@@ -1604,7 +1609,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 *destination, char *from, char *subject, char* mid, char* format, char* agent,
 		 int isemail)
 {
   return UUE_PrepPartialExt (outfile, infile,
@@ -1612,7 +1617,7 @@ UUE_PrepPartial (FILE *outfile, FILE *infile,
 			     outfname, filemode,
 			     partno, linperfile, filesize,
 			     destination,
-			     from, subject, mid, NULL, format,
+			     from, subject, mid, NULL, format, agent,
 			     isemail);
 }
 
@@ -1622,7 +1627,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 *from, char *subject, char* mid, char *replyto, char* format, char* agent,
 		    int isemail)
 {
   static int numparts, themode;
@@ -1716,7 +1721,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, isemail);
+				from, subject, mid, replyto, format, agent, isemail);
     }
 
     /*
@@ -1767,12 +1772,17 @@ UUE_PrepPartialExt (FILE *outfile, FILE *infile,
 
   fprintf (outfile, "Subject: %s%s", subline, eolstring);
 
-  // pan change (imhotep) : add unique mid for saving the upload queue to hdd
+  // pan change (imhotep) : add unique mid for saving the upload queue to hdd, add user agent
   if (mid)
   {
     fprintf(outfile, "Message-ID: <%s>%s", mid, eolstring);
   }
 
+  if (agent)
+  {
+    fprintf(outfile, "User-Agent: %s%s", agent, eolstring);
+  }
+
   if (replyto) {
     fprintf (outfile, "Reply-To: %s%s", replyto, eolstring);
   }



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