Bug 418131 - "Need a way to detect GTK+ version so we don't break users on major update" [p=ventnor.bugzilla@yahoo.com.au (Michael Ventnor) r=bsmedberg sr=dveditz a=blocking-firefox3+]
authorreed@reedloden.com
Fri, 14 Mar 2008 08:42:34 -0700
changeset 13071 71a73815eab45969981d03021681d7ec26ba6b9b
parent 13070 f78fd5a9c306459508756ccc10f1895ec58cd182
child 13072 a3b59ede99945600a0db9ec9c50b5965ae54bae3
push id1
push userbsmedberg@mozilla.com
push dateThu, 20 Mar 2008 16:49:24 +0000
treeherdermozilla-central@61007906a1f8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, dveditz, blocking-firefox3
bugs418131
milestone1.9b5pre
Bug 418131 - "Need a way to detect GTK+ version so we don't break users on major update" [p=ventnor.bugzilla@yahoo.com.au (Michael Ventnor) r=bsmedberg sr=dveditz a=blocking-firefox3+]
toolkit/mozapps/update/src/nsUpdateService.js.in
xpcom/base/Makefile.in
xpcom/base/nsSystemInfo.cpp
xpcom/build/Makefile.in
--- a/toolkit/mozapps/update/src/nsUpdateService.js.in
+++ b/toolkit/mozapps/update/src/nsUpdateService.js.in
@@ -1017,28 +1017,36 @@ function UpdateService() {
   // Not all builds have a known ABI
   try {
     gABI = gApp.XPCOMABI;
   }
   catch (e) {
     LOG("UpdateService", "XPCOM ABI unknown: updates are not possible.");
   }
 
+  var osVersion;
+  var sysInfo = Components.classes["@mozilla.org/system-info;1"]
+                          .getService(Components.interfaces.nsIPropertyBag2);
   try {
-    var sysInfo =
-      Components.classes["@mozilla.org/system-info;1"]
-                .getService(Components.interfaces.nsIPropertyBag2);
-
-    gOSVersion = encodeURIComponent(sysInfo.getProperty("name") + " " +
-                                    sysInfo.getProperty("version"));
+    osVersion = sysInfo.getProperty("name") + " " + sysInfo.getProperty("version");
   }
   catch (e) {
     LOG("UpdateService", "OS Version unknown: updates are not possible.");
   }
 
+  if (osVersion) {
+    try {
+      osVersion += " (" + sysInfo.getProperty("secondaryLibrary") + ")";
+    }
+    catch (e) {
+      // Not all platforms have a secondary widget library, so an error is nothing to worry about.
+    }
+    gOSVersion = encodeURIComponent(osVersion);
+  }
+
 #ifdef XP_MACOSX
   // Mac universal build should report a different ABI than either macppc
   // or mactel.
   var macutils = Components.classes["@mozilla.org/xpcom/mac-utils;1"]
                            .getService(Components.interfaces.nsIMacUtils);
 
   if (macutils.isUniversalBinary)
     gABI = "Universal-gcc3";
--- a/xpcom/base/Makefile.in
+++ b/xpcom/base/Makefile.in
@@ -143,8 +143,12 @@ FORCE_STATIC_LIB = 1
 
 # Force use of PIC
 FORCE_USE_PIC	= 1
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES		+= -D_IMPL_NS_COM
 
+ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
+CXXFLAGS        += $(MOZ_GTK2_CFLAGS)
+endif
+
--- a/xpcom/base/nsSystemInfo.cpp
+++ b/xpcom/base/nsSystemInfo.cpp
@@ -34,16 +34,21 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsSystemInfo.h"
 #include "prsystem.h"
 #include "nsString.h"
+#include "prprf.h"
+
+#ifdef MOZ_WIDGET_GTK2
+#include <gtk/gtk.h>
+#endif
 
 nsSystemInfo::nsSystemInfo()
 {
 }
 
 nsSystemInfo::~nsSystemInfo()
 {
 }
@@ -69,12 +74,23 @@ nsSystemInfo::Init()
       if (PR_GetSystemInfo(items[i].cmd, buf, sizeof(buf)) == PR_SUCCESS) {
         rv = SetPropertyAsACString(NS_ConvertASCIItoUTF16(items[i].name),
                                    nsDependentCString(buf));
         NS_ENSURE_SUCCESS(rv,rv);
       }
       else
         NS_WARNING("PR_GetSystemInfo failed");
     }
+
+#ifdef MOZ_WIDGET_GTK2
+    // This must be done here because NSPR can only separate OS's when compiled, not libraries.
+    char* gtkver = PR_smprintf("GTK %u.%u.%u", gtk_major_version, gtk_minor_version, gtk_micro_version);
+    if (gtkver) {
+      rv = SetPropertyAsACString(NS_ConvertASCIItoUTF16("secondaryLibrary"),
+                                 nsDependentCString(gtkver));
+      PR_smprintf_free(gtkver);
+      NS_ENSURE_SUCCESS(rv, rv);
+    }
+#endif
    
     return NS_OK;
 }
 
--- a/xpcom/build/Makefile.in
+++ b/xpcom/build/Makefile.in
@@ -181,16 +181,20 @@ EXTRA_DSO_LDOPTS += \
   $(TK_LIBS) \
   $(NULL)
 endif
 
 ifeq ($(OS_ARCH),BeOS)
 EXTRA_DSO_LDOPTS += -lbe
 endif
 
+ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
+EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS)
+endif
+
 ifeq ($(OS_ARCH),WINNT)
 EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME,shell32 ole32 uuid version)
 ifneq (,$(MOZ_DEBUG)$(NS_TRACE_MALLOC))
 EXTRA_DSO_LDOPTS += $(call EXPAND_LIBNAME,imagehlp)
 endif
 endif # WINNT
 
 export:: $(XPCOM_GLUE_SRC_CSRCS) $(XPCOM_GLUE_SRC_CPPSRCS) $(XPCOM_GLUENS_SRC_CPPSRCS)