[pan2: 25/68] Bug424083: additional info for about & User-Agent



commit ff3e20d5e96788b67d098ed37b3359e8e639b63a
Author: K. Haley <haleykd users sf net>
Date:   Thu Mar 25 22:24:31 2010 -0600

    Bug424083: additional info for about & User-Agent
    
    This patch adds the git branch & hash and platform to the About
    dialog box as well as the User-Agent header when posting.  The
    use of this info in the header is controlled by the
    user-agent-extra-info preference which defaults to false.

 configure.in       |   13 ++++++++++++-
 pan/gui/gui.cc     |    2 +-
 pan/gui/post-ui.cc |   10 +++++++++-
 3 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/configure.in b/configure.in
index 8f806f2..24e89f0 100644
--- a/configure.in
+++ b/configure.in
@@ -5,6 +5,15 @@ AC_DEFINE(VERSION_REVISION,0,[Revision part of version number])
 AC_DEFINE(VERSION_TITLE,["House of Butterflies"],[Release Name])
 AC_PREREQ(2.54)
 
+GIT_BRANCH=`git --git-dir=$srcdir/.git symbolic-ref HEAD 2> /dev/null | awk -F/ '{print $NF}'`
+GIT_HASH=`git --git-dir=$srcdir/.git log -1 --pretty=format:%h`
+if test -z $GIT_BRANCH; then
+  GIT_REV="GIT $GIT_HASH"
+else
+  GIT_REV="GIT $GIT_BRANCH $GIT_HASH"
+fi
+AC_DEFINE_UNQUOTED([GIT_REV],["$GIT_REV"],[Git branch and hash])
+
 AM_CONFIG_HEADER(config.h)
 AC_CONFIG_SRCDIR(pan/general/quark.cc)
 
@@ -80,9 +89,11 @@ ac_cv_lkstrftime=yes
 ],ac_cv_lkstrftime=no,ac_cv_lkstrftime=no)
 AC_MSG_RESULT($ac_cv_lkstrftime)
 
+AC_CANONICAL_HOST
+
+AC_DEFINE_UNQUOTED([PLATFORM_INFO],["$host"],[uname cpu-vendor-platformbuild])
 
 dnl windows-specific stuff.
-AC_CANONICAL_HOST
 win32="no"
 case $host_os in
 
diff --git a/pan/gui/gui.cc b/pan/gui/gui.cc
index e64a830..b96b2ca 100644
--- a/pan/gui/gui.cc
+++ b/pan/gui/gui.cc
@@ -1237,7 +1237,7 @@ void GUI :: do_about_pan ()
   GtkAboutDialog * w (GTK_ABOUT_DIALOG (gtk_about_dialog_new ()));
   gtk_about_dialog_set_program_name (w, _("Pan"));
   gtk_about_dialog_set_version (w, PACKAGE_VERSION);
-  gtk_about_dialog_set_comments (w, VERSION_TITLE);
+  gtk_about_dialog_set_comments (w, VERSION_TITLE " (" GIT_REV "; " PLATFORM_INFO ")");
   gtk_about_dialog_set_copyright (w, _("Copyright © 2002-2007 Charles Kerr"));
   gtk_about_dialog_set_website (w, "http://pan.rebelbase.com/";);
   gtk_about_dialog_set_logo (w, logo);
diff --git a/pan/gui/post-ui.cc b/pan/gui/post-ui.cc
index f8f7ce6..ebe94f1 100644
--- a/pan/gui/post-ui.cc
+++ b/pan/gui/post-ui.cc
@@ -57,6 +57,7 @@ using namespace pan;
 
 #define USER_AGENT_PREFS_KEY "add-user-agent-header-when-posting"
 #define MESSAGE_ID_PREFS_KEY "add-message-id-header-when-posting"
+#define USER_AGENT_EXTRA_PREFS_KEY "user-agent-extra-info"
 
 namespace
 {
@@ -851,9 +852,14 @@ PostUI :: open_draft ()
 
 namespace
 {
+  bool ua_extra=false;
+
   const char * get_user_agent ()
   {
-    return "Pan/" PACKAGE_VERSION " (" VERSION_TITLE ")";
+    if (ua_extra)
+      return "Pan/" PACKAGE_VERSION " (" VERSION_TITLE "; " GIT_REV "; " PLATFORM_INFO ")";
+    else
+      return "Pan/" PACKAGE_VERSION " (" VERSION_TITLE ")";
   }
 
   bool header_has_dedicated_entry (const StringView& name)
@@ -1856,6 +1862,8 @@ PostUI :: PostUI (GtkWindow    * parent,
   g_assert (profiles.has_profiles());
   g_return_if_fail (message != 0);
 
+  ua_extra = prefs.get_flag(USER_AGENT_EXTRA_PREFS_KEY, false);
+
   // create the window
   _root = gtk_window_new (GTK_WINDOW_TOPLEVEL);
   g_signal_connect (_root, "delete-event", G_CALLBACK(delete_event_cb), this);



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