mozilla-kde.patch
changeset 127 4c86470ed796
parent 64 7bb1edb78dd5
child 153 46ee28dc7145
--- a/mozilla-kde.patch	Wed Aug 11 12:17:17 2010 +0200
+++ b/mozilla-kde.patch	Thu Aug 12 08:55:47 2010 +0200
@@ -1,405 +1,7 @@
-diff --git a/chrome/src/Makefile.in b/chrome/src/Makefile.in
---- a/chrome/src/Makefile.in
-+++ b/chrome/src/Makefile.in
-@@ -81,16 +81,17 @@ CPPSRCS		= \
- 
- EXTRA_DSO_LDOPTS = \
-                 $(MOZ_UNICHARUTIL_LIBS) \
-                 $(MOZ_COMPONENT_LIBS) \
-                 $(NULL)
- 
- ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
- EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS)
-+LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
- endif
- 
- ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
- EXTRA_DSO_LDOPTS += $(TK_LIBS)
- endif
- 
- include $(topsrcdir)/config/rules.mk
- 
-diff --git a/chrome/src/nsChromeRegistry.cpp b/chrome/src/nsChromeRegistry.cpp
---- a/chrome/src/nsChromeRegistry.cpp
-+++ b/chrome/src/nsChromeRegistry.cpp
-@@ -109,16 +109,17 @@
- #include "nsIStyleSheet.h"
- #include "nsISupportsArray.h"
- #include "nsIVersionComparator.h"
- #include "nsIWindowMediator.h"
- #include "nsIXPConnect.h"
- #include "nsIXULAppInfo.h"
- #include "nsIXULRuntime.h"
- #include "nsPresShellIterator.h"
-+#include "nsKDEUtils.h"
- 
- #define UILOCALE_CMD_LINE_ARG "UILocale"
- 
- #define MATCH_OS_LOCALE_PREF "intl.locale.matchOS"
- #define SELECTED_LOCALE_PREF "general.useragent.locale"
- #define SELECTED_SKIN_PREF   "general.skins.selectedSkin"
- 
- static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
-@@ -1608,16 +1609,17 @@ nsChromeRegistry::ProcessManifestBuffer(
- 
-   NS_NAMED_LITERAL_STRING(kPlatform, "platform");
-   NS_NAMED_LITERAL_STRING(kXPCNativeWrappers, "xpcnativewrappers");
-   NS_NAMED_LITERAL_STRING(kContentAccessible, "contentaccessible");
-   NS_NAMED_LITERAL_STRING(kApplication, "application");
-   NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
-   NS_NAMED_LITERAL_STRING(kOs, "os");
-   NS_NAMED_LITERAL_STRING(kOsVersion, "osversion");
-+  NS_NAMED_LITERAL_STRING(kDesktop, "desktop");
- 
-   nsCOMPtr<nsIIOService> io (do_GetIOService());
-   if (!io) return NS_ERROR_FAILURE;
- 
-   nsCOMPtr<nsIProtocolHandler> ph;
-   rv = io->GetProtocolHandler("resource", getter_AddRefs(ph));
-   NS_ENSURE_SUCCESS(rv, rv);
-   
-@@ -1651,35 +1653,39 @@ nsChromeRegistry::ProcessManifestBuffer(
-       if (NS_SUCCEEDED(rv)) {
-         CopyUTF8toUTF16(s, osTarget);
-         ToLowerCase(osTarget);
-       }
-     }
-   }
-   
-   nsAutoString osVersion;
-+  nsAutoString desktop;
- #if defined(XP_WIN)
-   OSVERSIONINFO info = { sizeof(OSVERSIONINFO) };
-   if (GetVersionEx(&info)) {
-     nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
-                                          info.dwMajorVersion,
-                                          info.dwMinorVersion);
-   }
-+  desktop = NS_LITERAL_STRING("win");
- #elif defined(XP_MACOSX)
-   long majorVersion, minorVersion;
-   if ((Gestalt(gestaltSystemVersionMajor, &majorVersion) == noErr) &&
-       (Gestalt(gestaltSystemVersionMinor, &minorVersion) == noErr)) {
-     nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
-                                          majorVersion,
-                                          minorVersion);
-   }
-+  desktop = NS_LITERAL_STRING("macosx");
- #elif defined(MOZ_WIDGET_GTK2)
-   nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
-                                        gtk_major_version,
-                                        gtk_minor_version);
-+  desktop = nsKDEUtils::kdeSession() ? NS_LITERAL_STRING("kde") : NS_LITERAL_STRING("gnome"); // TODO others?
- #endif
- 
-   char *token;
-   char *newline = buf;
-   PRUint32 line = 0;
- 
-   // outer loop tokenizes by newline
-   while (nsnull != (token = nsCRT::strtok(newline, kNewlines, &newline))) {
-@@ -1713,41 +1719,43 @@ nsChromeRegistry::ProcessManifestBuffer(
- 
-       PRBool platform = PR_FALSE;
-       PRBool xpcNativeWrappers = PR_TRUE;
-       PRBool contentAccessible = PR_FALSE;
-       TriState stAppVersion = eUnspecified;
-       TriState stApp = eUnspecified;
-       TriState stOsVersion = eUnspecified;
-       TriState stOs = eUnspecified;
-+      TriState stDesktop = eUnspecified;
- 
-       PRBool badFlag = PR_FALSE;
- 
-       while (nsnull != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
-              !badFlag) {
-         NS_ConvertASCIItoUTF16 wtoken(token);
-         ToLowerCase(wtoken);
- 
-         if (CheckFlag(kPlatform, wtoken, platform) ||
-             CheckFlag(kXPCNativeWrappers, wtoken, xpcNativeWrappers) ||
-             CheckFlag(kContentAccessible, wtoken, contentAccessible) ||
-             CheckStringFlag(kApplication, wtoken, appID, stApp) ||
-             CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
-+            CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
-             CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
-             CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
-           continue;
- 
-         LogMessageWithContext(manifestURI, line, nsIScriptError::warningFlag,
-                               "Warning: Unrecognized chrome registration modifier '%s'.",
-                               token);
-         badFlag = PR_TRUE;
-       }
- 
-       if (badFlag || stApp == eBad || stAppVersion == eBad || 
--          stOs == eBad || stOsVersion == eBad)
-+          stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
-         continue;
- 
-       nsCOMPtr<nsIURI> resolved;
-       rv = io->NewURI(nsDependentCString(uri), nsnull, manifestURI,
-                       getter_AddRefs(resolved));
-       if (NS_FAILED(rv))
-         continue;
- 
-@@ -1798,38 +1806,40 @@ nsChromeRegistry::ProcessManifestBuffer(
-       }
- 
-       EnsureLowerCase(package);
- 
-       TriState stAppVersion = eUnspecified;
-       TriState stApp = eUnspecified;
-       TriState stOs = eUnspecified;
-       TriState stOsVersion = eUnspecified;
-+      TriState stDesktop = eUnspecified;
- 
-       PRBool badFlag = PR_FALSE;
- 
-       while (nsnull != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
-              !badFlag) {
-         NS_ConvertASCIItoUTF16 wtoken(token);
-         ToLowerCase(wtoken);
- 
-         if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
-             CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
-+            CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
-             CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
-             CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
-           continue;
- 
-         LogMessageWithContext(manifestURI, line, nsIScriptError::warningFlag,
-                               "Warning: Unrecognized chrome registration modifier '%s'.",
-                               token);
-         badFlag = PR_TRUE;
-       }
- 
-       if (badFlag || stApp == eBad || stAppVersion == eBad ||
--          stOs == eBad || stOsVersion == eBad)
-+          stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
-         continue;
- 
-       nsCOMPtr<nsIURI> resolved;
-       rv = io->NewURI(nsDependentCString(uri), nsnull, manifestURI,
-                       getter_AddRefs(resolved));
-       if (NS_FAILED(rv))
-         continue;
- 
-@@ -1860,38 +1870,40 @@ nsChromeRegistry::ProcessManifestBuffer(
-       }
- 
-       EnsureLowerCase(package);
- 
-       TriState stAppVersion = eUnspecified;
-       TriState stApp = eUnspecified;
-       TriState stOs = eUnspecified;
-       TriState stOsVersion = eUnspecified;
-+      TriState stDesktop = eUnspecified;
- 
-       PRBool badFlag = PR_FALSE;
- 
-       while (nsnull != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
-              !badFlag) {
-         NS_ConvertASCIItoUTF16 wtoken(token);
-         ToLowerCase(wtoken);
- 
-         if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
-             CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
-+            CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
-             CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
-             CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
-           continue;
- 
-         LogMessageWithContext(manifestURI, line, nsIScriptError::warningFlag,
-                               "Warning: Unrecognized chrome registration modifier '%s'.",
-                               token);
-         badFlag = PR_TRUE;
-       }
- 
-       if (badFlag || stApp == eBad || stAppVersion == eBad ||
--          stOs == eBad || stOsVersion == eBad)
-+          stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
-         continue;
- 
-       nsCOMPtr<nsIURI> resolved;
-       rv = io->NewURI(nsDependentCString(uri), nsnull, manifestURI,
-                       getter_AddRefs(resolved));
-       if (NS_FAILED(rv))
-         continue;
- 
-@@ -1924,38 +1936,40 @@ nsChromeRegistry::ProcessManifestBuffer(
-                               "Warning: malformed chrome overlay instruction.");
-         continue;
-       }
- 
-       TriState stAppVersion = eUnspecified;
-       TriState stApp = eUnspecified;
-       TriState stOs = eUnspecified;
-       TriState stOsVersion = eUnspecified;
-+      TriState stDesktop = eUnspecified;
- 
-       PRBool badFlag = PR_FALSE;
- 
-       while (nsnull != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
-              !badFlag) {
-         NS_ConvertASCIItoUTF16 wtoken(token);
-         ToLowerCase(wtoken);
- 
-         if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
-             CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
-+            CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
-             CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
-             CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
-           continue;
- 
-         LogMessageWithContext(manifestURI, line, nsIScriptError::warningFlag,
-                               "Warning: Unrecognized chrome registration modifier '%s'.",
-                               token);
-         badFlag = PR_TRUE;
-       }
- 
-       if (badFlag || stApp == eBad || stAppVersion == eBad ||
--          stOs == eBad || stOsVersion == eBad)
-+          stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
-         continue;
- 
-       nsCOMPtr<nsIURI> baseuri, overlayuri;
-       rv  = io->NewURI(nsDependentCString(base), nsnull, nsnull,
-                        getter_AddRefs(baseuri));
-       rv |= io->NewURI(nsDependentCString(overlay), nsnull, nsnull,
-                        getter_AddRefs(overlayuri));
-       if (NS_FAILED(rv)) {
-@@ -1980,38 +1994,40 @@ nsChromeRegistry::ProcessManifestBuffer(
-                               "Warning: malformed chrome style instruction.");
-         continue;
-       }
- 
-       TriState stAppVersion = eUnspecified;
-       TriState stApp = eUnspecified;
-       TriState stOs = eUnspecified;
-       TriState stOsVersion = eUnspecified;
-+      TriState stDesktop = eUnspecified;
- 
-       PRBool badFlag = PR_FALSE;
- 
-       while (nsnull != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
-              !badFlag) {
-         NS_ConvertASCIItoUTF16 wtoken(token);
-         ToLowerCase(wtoken);
- 
-         if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
-             CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
-+            CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
-             CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
-             CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
-           continue;
- 
-         LogMessageWithContext(manifestURI, line, nsIScriptError::warningFlag,
-                               "Warning: Unrecognized chrome registration modifier '%s'.",
-                               token);
-         badFlag = PR_TRUE;
-       }
- 
-       if (badFlag || stApp == eBad || stAppVersion == eBad ||
--          stOs == eBad || stOsVersion == eBad)
-+          stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
-         continue;
- 
-       nsCOMPtr<nsIURI> baseuri, overlayuri;
-       rv  = io->NewURI(nsDependentCString(base), nsnull, nsnull,
-                       getter_AddRefs(baseuri));
-       rv |= io->NewURI(nsDependentCString(overlay), nsnull, nsnull,
-                        getter_AddRefs(overlayuri));
-       if (NS_FAILED(rv))
-@@ -2040,38 +2056,40 @@ nsChromeRegistry::ProcessManifestBuffer(
-                               "Warning: malformed chrome override instruction.");
-         continue;
-       }
- 
-       TriState stAppVersion = eUnspecified;
-       TriState stApp = eUnspecified;
-       TriState stOs = eUnspecified;
-       TriState stOsVersion = eUnspecified;
-+      TriState stDesktop = eUnspecified;
- 
-       PRBool badFlag = PR_FALSE;
- 
-       while (nsnull != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
-              !badFlag) {
-         NS_ConvertASCIItoUTF16 wtoken(token);
-         ToLowerCase(wtoken);
- 
-         if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
-             CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
-+            CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
-             CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
-             CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
-           continue;
- 
-         LogMessageWithContext(manifestURI, line, nsIScriptError::warningFlag,
-                               "Warning: Unrecognized chrome registration modifier '%s'.",
-                               token);
-         badFlag = PR_TRUE;
-       }
- 
-       if (badFlag || stApp == eBad || stAppVersion == eBad ||
--          stOs == eBad || stOsVersion == eBad)
-+          stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
-         continue;
- 
-       nsCOMPtr<nsIURI> chromeuri, resolveduri;
-       rv  = io->NewURI(nsDependentCString(chrome), nsnull, nsnull,
-                       getter_AddRefs(chromeuri));
-       rv |= io->NewURI(nsDependentCString(resolved), nsnull, manifestURI,
-                        getter_AddRefs(resolveduri));
-       if (NS_FAILED(rv))
-@@ -2102,38 +2120,40 @@ nsChromeRegistry::ProcessManifestBuffer(
-       }
- 
-       EnsureLowerCase(package);
- 
-       TriState stAppVersion = eUnspecified;
-       TriState stApp = eUnspecified;
-       TriState stOsVersion = eUnspecified;
-       TriState stOs = eUnspecified;
-+      TriState stDesktop = eUnspecified;
- 
-       PRBool badFlag = PR_FALSE;
- 
-       while (nsnull != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) &&
-              !badFlag) {
-         NS_ConvertASCIItoUTF16 wtoken(token);
-         ToLowerCase(wtoken);
- 
-         if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
-             CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
-+            CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
-             CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
-             CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
-           continue;
- 
-         LogMessageWithContext(manifestURI, line, nsIScriptError::warningFlag,
-                               "Warning: Unrecognized chrome registration modifier '%s'.",
-                               token);
-         badFlag = PR_TRUE;
-       }
- 
-       if (badFlag || stApp == eBad || stAppVersion == eBad || 
--          stOs == eBad || stOsVersion == eBad)
-+          stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
-         continue;
-       
-       nsDependentCString host(package);
- 
-       PRBool exists;
-       rv = rph->HasSubstitution(host, &exists);
-       NS_ENSURE_SUCCESS(rv, rv);
-       if (exists) {
 diff --git a/modules/libpref/src/Makefile.in b/modules/libpref/src/Makefile.in
 --- a/modules/libpref/src/Makefile.in
 +++ b/modules/libpref/src/Makefile.in
-@@ -97,8 +97,10 @@ GARBAGE		+= $(addprefix $(DIST)/bin/defa
- 
+@@ -90,14 +90,16 @@ GREPREF_FILES = $(topsrcdir)/netwerk/bas
  # Optimizer bug with GCC 3.2.2 on OS/2
  ifeq ($(OS_ARCH), OS2)
  nsPrefService.$(OBJ_SUFFIX): nsPrefService.cpp
@@ -407,12 +9,19 @@
  	@$(MAKE_DEPS_AUTO_CXX)
  	$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS:-O2=-O1) $(_VPATH_SRCS)
  endif
+ 
++LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
 +
-+LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
+ 
+ greprefs.js: $(GREPREF_FILES)
+ 	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $^ > $@
+ 
+ libs:: greprefs.js
+ 	$(INSTALL) $^ $(DIST)/bin/
 diff --git a/modules/libpref/src/nsPrefService.cpp b/modules/libpref/src/nsPrefService.cpp
 --- a/modules/libpref/src/nsPrefService.cpp
 +++ b/modules/libpref/src/nsPrefService.cpp
-@@ -47,16 +47,17 @@
+@@ -51,16 +51,17 @@
  #include "nsILocalFile.h"
  #include "nsIObserverService.h"
  #include "nsPrefBranch.h"
@@ -430,55 +39,21 @@
  #include "prefapi.h"
  #include "prefread.h"
  #include "prefapi_private_data.h"
-@@ -610,17 +611,18 @@ pref_LoadPrefsInDir(nsIFile* aDir, char 
-         rv = rv2;
-       }
-     }
-   }
- 
-   return rv;
- }
- 
--static nsresult pref_LoadPrefsInDirList(const char *listId)
-+static nsresult pref_LoadPrefsInDirList(const char *listId,
-+    char const *const *aSpecialFiles = NULL, PRUint32 aSpecialFilesCount = 0)
- {
-   nsresult rv;
-   nsCOMPtr<nsIProperties> dirSvc(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
-   if (NS_FAILED(rv)) return rv;
- 
-   nsCOMPtr<nsISimpleEnumerator> dirList;
-   dirSvc->Get(listId,
-               NS_GET_IID(nsISimpleEnumerator),
-@@ -629,17 +631,17 @@ static nsresult pref_LoadPrefsInDirList(
-     PRBool hasMore;
-     while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore) {
-       nsCOMPtr<nsISupports> elem;
-       dirList->GetNext(getter_AddRefs(elem));
-       if (elem) {
-         nsCOMPtr<nsIFile> dir = do_QueryInterface(elem);
-         if (dir) {
-           // Do we care if a file provided by this process fails to load?
--          pref_LoadPrefsInDir(dir, nsnull, 0); 
-+          pref_LoadPrefsInDir(dir, aSpecialFiles, aSpecialFilesCount); 
-         }
-       }
-     }
-   }
-   return NS_OK;
- }
- 
- //----------------------------------------------------------------------------------------
-@@ -680,29 +682,41 @@ static nsresult pref_InitInitialObjects(
+@@ -718,28 +719,40 @@ static nsresult pref_InitDefaults()
+   /* these pref file names should not be used: we process them after all other application pref files for backwards compatibility */
+   static const char* specialFiles[] = {
+ #if defined(XP_MAC) || defined(XP_MACOSX)
+       "macprefs.js"
+ #elif defined(XP_WIN)
+       "winpref.js"
+ #elif defined(XP_UNIX)
+       "unix.js"
++      , "" // placeholder for KDE  (empty is otherwise harmless)
  #if defined(VMS)
        , "openvms.js"
  #elif defined(_AIX)
        , "aix.js"
  #endif
- #if defined(MOZ_WIDGET_PHOTON)
- 	  , "photon.js"
- #endif		 
-+      , "" // placeholder for KDE  (empty is otherwise harmless)
  #elif defined(XP_OS2)
        "os2pref.js"
  #elif defined(XP_BEOS)
@@ -486,37 +61,30 @@
  #endif
    };
  
-+  if( nsKDEUtils::kdeSession()) { // TODO what if some setup actually requires the helper?
-+      for( int i = 0;
-+           i < NS_ARRAY_LENGTH(specialFiles);
-+           ++i ) {
-+          if( *specialFiles[ i ] == '\0' ) {
-+              specialFiles[ i ] = "kde.js";
-+              break;
-+          }
++  if(nsKDEUtils::kdeSession()) { // TODO what if some setup actually requires the helper?
++    for( int i = 0;
++         i < NS_ARRAY_LENGTH(specialFiles);
++         ++i ) {
++      if( *specialFiles[ i ] == '\0' ) {
++        specialFiles[ i ] = "kde.js";
++        break;
 +      }
++    }
 +  }
-+      
++
    rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, NS_ARRAY_LENGTH(specialFiles));
    if (NS_FAILED(rv)) {
      NS_WARNING("Error parsing application default preferences.");
    }
  
--  rv = pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST);
-+  rv = pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST, specialFiles, NS_ARRAY_LENGTH(specialFiles));
-   NS_ENSURE_SUCCESS(rv, rv);
+   return NS_OK;
+ }
  
-   NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
-                                 nsnull, NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID);
- 
-   nsCOMPtr<nsIObserverService> observerService = 
-     do_GetService("@mozilla.org/observer-service;1", &rv);
-   
 diff --git a/toolkit/components/downloads/src/Makefile.in b/toolkit/components/downloads/src/Makefile.in
 --- a/toolkit/components/downloads/src/Makefile.in
 +++ b/toolkit/components/downloads/src/Makefile.in
-@@ -92,8 +92,9 @@ EXTRA_COMPONENTS = \
-   nsDownloadManagerUI.js \
+@@ -71,8 +71,9 @@ EXTRA_COMPONENTS = \
+   nsDownloadManagerUI.manifest \
    $(NULL)
  endif
  
@@ -528,7 +96,7 @@
 diff --git a/toolkit/components/downloads/src/nsDownloadManager.cpp b/toolkit/components/downloads/src/nsDownloadManager.cpp
 --- a/toolkit/components/downloads/src/nsDownloadManager.cpp
 +++ b/toolkit/components/downloads/src/nsDownloadManager.cpp
-@@ -71,16 +71,20 @@
+@@ -76,16 +76,20 @@
  
  #if defined(XP_WIN) && !defined(WINCE)
  #include <shlobj.h>
@@ -541,15 +109,15 @@
 +#include "nsKDEUtils.h"
 +#endif
 +
+ #ifdef XP_MACOSX
+ #include <CoreFoundation/CoreFoundation.h>
+ #endif
+ 
  #define DOWNLOAD_MANAGER_BUNDLE "chrome://mozapps/locale/downloads/downloads.properties"
  #define DOWNLOAD_MANAGER_ALERT_ICON "chrome://mozapps/skin/downloads/downloadIcon.png"
  #define PREF_BDM_SHOWALERTONCOMPLETE "browser.download.manager.showAlertOnComplete"
  #define PREF_BDM_SHOWALERTINTERVAL "browser.download.manager.showAlertInterval"
- #define PREF_BDM_RETENTION "browser.download.manager.retention"
- #define PREF_BDM_QUITBEHAVIOR "browser.download.manager.quitBehavior"
- #define PREF_BDM_ADDTORECENTDOCS "browser.download.manager.addToRecentDocs"
- #define PREF_BDM_SCANWHENDONE "browser.download.manager.scanWhenDone"
-@@ -2158,16 +2162,25 @@ nsDownload::SetState(DownloadState aStat
+@@ -2193,16 +2197,25 @@ nsDownload::SetState(DownloadState aStat
        nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
  
        // Master pref to control this function.
@@ -575,7 +143,7 @@
          PRInt64 goat = PR_Now() - mStartTime;
          showTaskbarAlert = goat > alertIntervalUSec;
  
-@@ -2193,16 +2206,17 @@ nsDownload::SetState(DownloadState aStat
+@@ -2228,16 +2241,17 @@ nsDownload::SetState(DownloadState aStat
                // because if it is, they'll click open the download manager and
                // the items they downloaded will have been removed.
                alerts->ShowAlertNotification(
@@ -586,17 +154,17 @@
          }
 +        } // end non-KDE block
        }
- #if defined(XP_WIN) && !defined(WINCE)
+ 
        nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mTarget);
-       nsCOMPtr<nsIFile> file;
-       nsAutoString path;
+       if (fileURL) {
+         nsCOMPtr<nsIFile> file;
+         if (NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) && file ) {
  
-       if (fileURL &&
-           NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) &&
+ #if (defined(XP_WIN) && !defined(WINCE)) || defined(XP_MACOSX)
 diff --git a/toolkit/content/jar.mn b/toolkit/content/jar.mn
 --- a/toolkit/content/jar.mn
 +++ b/toolkit/content/jar.mn
-@@ -44,29 +44,33 @@ toolkit.jar:
+@@ -40,29 +40,33 @@ toolkit.jar:
  *+ content/global/viewZoomOverlay.js          (viewZoomOverlay.js)
  *+ content/global/bindings/autocomplete.xml    (widgets/autocomplete.xml)
  *+ content/global/bindings/browser.xml         (widgets/browser.xml)
@@ -634,7 +202,7 @@
 new file mode 100644
 --- /dev/null
 +++ b/toolkit/content/widgets/dialog-kde.xml
-@@ -0,0 +1,445 @@
+@@ -0,0 +1,447 @@
 +<?xml version="1.0"?>
 +
 +<bindings id="dialogBindings"
@@ -664,13 +232,13 @@
 +        <xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
 +#elif XP_UNIX
 +                pack="end">
-+        <xul:button dlgtype="help" class="dialog-button" hidden="true"/>
-+        <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
-+        <xul:spacer anonid="spacer" flex="1" hidden="true"/>
-+        <xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
-+        <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
-+        <xul:button dlgtype="cancel" class="dialog-button"/>
-+        <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
++	<xul:button dlgtype="help" class="dialog-button" hidden="true"/>
++	<xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
++	<xul:spacer anonid="spacer" flex="1" hidden="true"/>
++	<xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
++	<xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
++	<xul:button dlgtype="cancel" class="dialog-button"/>
++	<xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
 +#else
 +                pack="end">
 +        <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
@@ -808,27 +376,29 @@
 +              document.commandDispatcher.advanceFocusIntoSubtree(dialog);
 +
 +              var focusedElt = document.commandDispatcher.focusedElement;
-+              var initialFocusedElt = focusedElt;
-+              while (focusedElt.localName == "tab" ||
-+                     focusedElt.getAttribute("noinitialfocus") == "true") {
-+                document.commandDispatcher.advanceFocusIntoSubtree(focusedElt);
-+                focusedElt = document.commandDispatcher.focusedElement;
-+                if (focusedElt == initialFocusedElt)
-+                  break;
-+              }
++              if (focusedElt) {
++                var initialFocusedElt = focusedElt;
++                while (focusedElt.localName == "tab" ||
++                       focusedElt.getAttribute("noinitialfocus") == "true") {
++                  document.commandDispatcher.advanceFocusIntoSubtree(focusedElt);
++                  focusedElt = document.commandDispatcher.focusedElement;
++                  if (focusedElt == initialFocusedElt)
++                    break;
++                }
 +
-+              if (initialFocusedElt.localName == "tab") {
-+                if (focusedElt.hasAttribute("dlgtype")) {
-+                  // We don't want to focus on anonymous OK, Cancel, etc. buttons,
-+                  // so return focus to the tab itself
-+                  initialFocusedElt.focus();
++                if (initialFocusedElt.localName == "tab") {
++                  if (focusedElt.hasAttribute("dlgtype")) {
++                    // We don't want to focus on anonymous OK, Cancel, etc. buttons,
++                    // so return focus to the tab itself
++                    initialFocusedElt.focus();
++                  }
 +                }
++#ifndef XP_MACOSX
++                else if (focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton) {
++                  defaultButton.focus();
++                }
++#endif
 +              }
-+#ifndef XP_MACOSX
-+              else if (focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton) {
-+                defaultButton.focus();
-+              }
-+#endif
 +            }
 +
 +            try {
@@ -1671,13 +1241,13 @@
 +        <xul:button dlgtype="accept" class="dialog-button" icon="accept"/>
 +#elif XP_UNIX
 +                pack="end">
-+        <xul:button dlgtype="help" class="dialog-button" hidden="true" icon="help"/>
-+        <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
-+        <xul:spacer anonid="spacer" flex="1"/>
-+        <xul:button dlgtype="accept" class="dialog-button" icon="accept"/>
-+        <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
-+        <xul:button dlgtype="cancel" class="dialog-button" icon="cancel"/>
-+        <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
++	<xul:button dlgtype="help" class="dialog-button" hidden="true" icon="help"/>
++	<xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
++	<xul:spacer anonid="spacer" flex="1"/>
++	<xul:button dlgtype="accept" class="dialog-button" icon="accept"/>
++	<xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
++	<xul:button dlgtype="cancel" class="dialog-button" icon="cancel"/>
++	<xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
 +#else
 +                pack="end">
 +        <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
@@ -2456,28 +2026,6 @@
 +#    PrefWindow II  (???)
 +#    PrefWindow I   (June 4, 1999)
 +#
-diff --git a/toolkit/system/unixproxy/Makefile.in b/toolkit/system/unixproxy/Makefile.in
---- a/toolkit/system/unixproxy/Makefile.in
-+++ b/toolkit/system/unixproxy/Makefile.in
-@@ -54,16 +54,18 @@ LIBXUL_LIBRARY  = 1
- 
- REQUIRES = \
-         xpcom \
-         string \
-         necko \
-         mozgnome \
-         $(NULL)
- 
-+LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
-+
- EXTRA_DSO_LDOPTS += \
-                $(MOZ_LIBPROXY_LIBS) \
-                $(MOZ_COMPONENT_LIBS) \
-                $(NULL)
- 
- ifdef MOZ_ENABLE_LIBPROXY
- 
- CPPSRCS = \
 diff --git a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
 --- a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
 +++ b/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp
@@ -2537,63 +2085,10 @@
  
  #define NS_UNIXSYSTEMPROXYSERVICE_CID  /* 0fa3158c-d5a7-43de-9181-a285e74cf1d4 */\
       { 0x0fa3158c, 0xd5a7, 0x43de, \
-@@ -427,8 +433,33 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsUn
- static const nsModuleComponentInfo components[] = {
-   { "Unix System Proxy Settings Service",
-     NS_UNIXSYSTEMPROXYSERVICE_CID,
-     NS_SYSTEMPROXYSETTINGS_CONTRACTID,
-     nsUnixSystemProxySettingsConstructor }
- };
- 
- NS_IMPL_NSGETMODULE(nsUnixProxyModule, components)
-+
-+nsresult
-+nsUnixSystemProxySettings::GetProxyFromKDE(const nsACString& aScheme,
-+                                             const nsACString& aHost,
-+                                             PRInt32 aPort,
-+                                             nsACString& aResult)
-+{
-+  nsCAutoString url;
-+  url = aScheme;
-+  url += "://";
-+  url += aHost;
-+  if( aPort >= 0 )
-+      {
-+      url += ":";
-+      url += nsPrintfCString("%d", aPort);
-+      }
-+  nsCStringArray command;
-+  command.AppendCString( NS_LITERAL_CSTRING( "GETPROXY" ));
-+  command.AppendCString( url );
-+  nsCStringArray result;
-+  if( !nsKDEUtils::command( command, &result ) || result.Count() != 1 )
-+      return NS_ERROR_FAILURE;
-+  aResult = *result[ 0 ];
-+  return NS_OK;
-+}
 diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in
 --- a/toolkit/xre/Makefile.in
 +++ b/toolkit/xre/Makefile.in
-@@ -42,16 +42,18 @@ srcdir		= @srcdir@
- VPATH		= @srcdir@
- 
- include $(DEPTH)/config/autoconf.mk
- 
- MODULE = xulapp
- LIBRARY_NAME = xulapp_s
- LIBXUL_LIBRARY = 1
- 
-+EXPORTS = nsKDEUtils.h
-+
- REQUIRES = \
- 	appcomps \
- 	toolkitcomps \
- 	appshell \
- 	chrome \
- 	content \
- 	docshell \
- 	dom \
-@@ -133,17 +135,17 @@ CMMSRCS = nsNativeAppSupportCocoa.mm
+@@ -95,17 +95,18 @@ CMMSRCS = nsNativeAppSupportCocoa.mm
  else
  ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
  CPPSRCS += nsNativeAppSupportOS2.cpp
@@ -2604,14 +2099,15 @@
  ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 -CPPSRCS += nsNativeAppSupportUnix.cpp
 +CPPSRCS += nsNativeAppSupportUnix.cpp nsKDEUtils.cpp
++EXPORTS += nsKDEUtils.h
  else
- CPPSRCS += nsNativeAppSupportDefault.cpp
- endif
- endif
- endif
- endif
- endif
- 
+ ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
+ CPPSRCS += nsNativeAppSupportQt.cpp
+ CPPSRCS += nsQAppInstance.cpp
+ EXPORTS += nsQAppInstance.h
+ ifdef MOZ_ENABLE_MEEGOTOUCH
+ MOCSRCS += moc_MozMeegoAppService.cpp
+ CPPSRCS += moc_MozMeegoAppService.cpp
 diff --git a/toolkit/xre/nsKDEUtils.cpp b/toolkit/xre/nsKDEUtils.cpp
 new file mode 100644
 --- /dev/null
@@ -3036,7 +2532,7 @@
 diff --git a/uriloader/exthandler/Makefile.in b/uriloader/exthandler/Makefile.in
 --- a/uriloader/exthandler/Makefile.in
 +++ b/uriloader/exthandler/Makefile.in
-@@ -102,18 +102,19 @@ CMMSRCS	= nsOSHelperAppService.mm \
+@@ -85,18 +85,19 @@ CMMSRCS	= nsOSHelperAppService.mm \
  			$(NULL)
  else
  OSHELPER	= nsOSHelperAppService.cpp
@@ -3051,12 +2547,12 @@
 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
  endif
  
- ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
- OSHELPER += nsGNOMERegistry.cpp
- OSHELPER += nsMIMEInfoUnix.cpp
+ ifeq ($(MOZ_WIDGET_TOOLKIT),android)
+ OSHELPER += nsMIMEInfoAndroid.cpp
+ OSHELPER += nsAndroidHandlerApp.cpp
  endif
  
- ifeq ($(MOZ_WIDGET_TOOLKIT),beos)
+ ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
 diff --git a/uriloader/exthandler/unix/nsCommonRegistry.cpp b/uriloader/exthandler/unix/nsCommonRegistry.cpp
 new file mode 100644
 --- /dev/null
@@ -3403,17 +2899,18 @@
 diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
 --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
 +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
-@@ -40,27 +40,30 @@
- #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
- #include <glib.h>
- #include <hildon-uri.h>
- #include <hildon-mime.h>
- #include <libosso.h>
+@@ -48,28 +48,31 @@
+ #include <QDesktopServices>
+ #include <QUrl>
+ #include <QString>
+ #include <contentaction/contentaction.h>
+ #include "nsContentHandlerApp.h"
  #endif
  
  #include "nsMIMEInfoUnix.h"
 -#include "nsGNOMERegistry.h"
 +#include "nsCommonRegistry.h"
+ #include "nsIGIOService.h"
  #include "nsIGnomeVFSService.h"
  #include "nsAutoPtr.h"
  #ifdef MOZ_ENABLE_DBUS
@@ -3428,16 +2925,16 @@
  {
 -  nsresult rv = nsGNOMERegistry::LoadURL(aURI);
 +  nsresult rv = nsCommonRegistry::LoadURL(aURI);
+ 
  #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
    if (NS_FAILED(rv)){
-     HildonURIAction *action = hildon_uri_get_default_action(mType.get(), nsnull);
+     HildonURIAction *action = hildon_uri_get_default_action(mSchemeOrType.get(), nsnull);
      if (action) {
        nsCAutoString spec;
        aURI->GetAsciiSpec(spec);
        if (hildon_uri_open(spec.get(), action, nsnull))
-         rv = NS_OK;
-@@ -70,21 +73,21 @@ nsMIMEInfoUnix::LoadUriInternal(nsIURI *
- #endif
+@@ -91,22 +94,22 @@ nsMIMEInfoUnix::LoadUriInternal(nsIURI *
+ 
    return rv;
  }
  
@@ -3445,28 +2942,29 @@
  nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
  {
    *_retval = PR_FALSE;
--  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mType);
-+  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromType(mType);
+-  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mSchemeOrType);
++  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromType(mSchemeOrType);
    if (!mimeInfo) {
      nsCAutoString ext;
-     GetPrimaryExtension(ext);
--    mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
-+    mimeInfo = nsCommonRegistry::GetFromExtension(ext);
+     nsresult rv = GetPrimaryExtension(ext);
+     if (NS_SUCCEEDED(rv)) {
+-      mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
++      mimeInfo = nsCommonRegistry::GetFromExtension(ext);
+     }
    }
- 
    if (mimeInfo)
      *_retval = PR_TRUE;
  
    if (*_retval)
      return NS_OK;
  
-@@ -107,25 +110,42 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
-   nsCAutoString nativePath;
-   aFile->GetNativePath(nativePath);
- 
- #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
-   if(NS_SUCCEEDED(LaunchDefaultWithDBus(PromiseFlatCString(nativePath).get())))
+@@ -149,32 +152,49 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
+     ContentAction::Action::defaultActionForFile(uri, QString(mSchemeOrType.get()));
+   if (action.isValid()) {
+     action.trigger();
      return NS_OK;
+   }
+   return NS_ERROR_FAILURE;
  #endif
  
 +  if( nsKDEUtils::kdeSupport()) {
@@ -3476,7 +2974,7 @@
 +      command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
 +      command.AppendCString( nativePath );
 +      command.AppendCString( NS_LITERAL_CSTRING( "MIMETYPE" ));
-+      command.AppendCString( mType );
++      command.AppendCString( mSchemeOrType );
 +      if( nsKDEUtils::command( command ))
 +        return NS_OK;
 +    }
@@ -3486,32 +2984,39 @@
 +    return LaunchWithIProcess(mDefaultApplication, nativePath);
 +  }
 +
-   nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
-   if (vfs) {
-     nsCOMPtr<nsIGnomeVFSMimeApp> app;
-     if (NS_SUCCEEDED(vfs->GetAppForMimeType(mType, getter_AddRefs(app))) && app)
+   nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
+   nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
+   if (giovfs) {
+     nsCOMPtr<nsIGIOMimeApp> app;
+     if (NS_SUCCEEDED(giovfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
        return app->Launch(nativePath);
- 
-     // If we haven't got an app we try to get a valid one by searching for the
-     // extension mapped type
--    nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath);
-+    nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromExtension(nativePath);
-     if (mimeInfo) {
-       nsCAutoString type;
-       mimeInfo->GetType(type);
-       if (NS_SUCCEEDED(vfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
-         return app->Launch(nativePath);
-     }
+   } else if (gnomevfs) {
+     /* Fallback to GnomeVFS */
+     nsCOMPtr<nsIGnomeVFSMimeApp> app;
+     if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
+       return app->Launch(nativePath);
    }
  
+   // If we haven't got an app we try to get a valid one by searching for the
+   // extension mapped type
+-  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath);
++  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromExtension(nativePath);
+   if (mimeInfo) {
+     nsCAutoString type;
+     mimeInfo->GetType(type);
+     if (giovfs) {
+       nsCOMPtr<nsIGIOMimeApp> app;
+       if (NS_SUCCEEDED(giovfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
+         return app->Launch(nativePath);
+     } else if (gnomevfs) {
 diff --git a/uriloader/exthandler/unix/nsOSHelperAppService.cpp b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
 --- a/uriloader/exthandler/unix/nsOSHelperAppService.cpp
 +++ b/uriloader/exthandler/unix/nsOSHelperAppService.cpp
-@@ -39,17 +39,17 @@
-  * ***** END LICENSE BLOCK ***** */
- 
- #include <sys/types.h>
- #include <sys/stat.h>
+@@ -44,17 +44,17 @@
+ #if (MOZ_PLATFORM_MAEMO == 6)
+ #include <contentaction/contentaction.h>
+ #include <QString>
+ #endif
  
  #include "nsOSHelperAppService.h"
  #include "nsMIMEInfoUnix.h"
@@ -3526,18 +3031,18 @@
  #include "nsXPIDLString.h"
  #include "nsIURL.h"
  #include "nsIFileStreams.h"
-@@ -1205,29 +1205,29 @@ nsOSHelperAppService::GetHandlerAndDescr
- nsresult nsOSHelperAppService::OSProtocolHandlerExists(const char * aProtocolScheme, PRBool * aHandlerExists)
- {
-   LOG(("-- nsOSHelperAppService::OSProtocolHandlerExists for '%s'\n",
-        aProtocolScheme));
-   *aHandlerExists = PR_FALSE;
+@@ -1219,29 +1219,29 @@ nsresult nsOSHelperAppService::OSProtoco
+     ContentAction::Action::defaultActionForScheme(QString(aProtocolScheme) + ':');
+ 
+   if (action.isValid())
+     *aHandlerExists = PR_TRUE;
+ #endif
  
  #ifdef MOZ_WIDGET_GTK2
    // Check the GConf registry for a protocol handler
 -  *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
 +  *aHandlerExists = nsCommonRegistry::HandlerExists(aProtocolScheme);
- #ifdef MOZ_PLATFORM_MAEMO
+ #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
    *aHandlerExists = nsMIMEInfoUnix::HandlerExists(aProtocolScheme);
  #endif
  #endif
@@ -3558,7 +3063,7 @@
  
  nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformAppPath, nsIFile ** aFile)
  {
-@@ -1313,17 +1313,17 @@ nsOSHelperAppService::GetFromExtension(c
+@@ -1327,17 +1327,17 @@ nsOSHelperAppService::GetFromExtension(c
                                           minorType,
                                           mime_types_description,
                                           PR_TRUE);
@@ -3577,7 +3082,7 @@
  
      rv = LookUpTypeAndDescription(NS_ConvertUTF8toUTF16(aFileExt),
                                    majorType,
-@@ -1439,17 +1439,17 @@ nsOSHelperAppService::GetFromType(const 
+@@ -1453,17 +1453,17 @@ nsOSHelperAppService::GetFromType(const 
  #ifdef MOZ_WIDGET_GTK2
    nsMIMEInfoBase *gnomeInfo = nsnull;
    if (handler.IsEmpty()) {
@@ -3599,13 +3104,13 @@
 diff --git a/widget/src/gtk2/Makefile.in b/widget/src/gtk2/Makefile.in
 --- a/widget/src/gtk2/Makefile.in
 +++ b/widget/src/gtk2/Makefile.in
-@@ -185,8 +185,11 @@ EXTRA_DSO_LDOPTS += -lgfxpsshar
- endif
+@@ -156,8 +156,11 @@ endif
  
+ DEFINES		+= -DCAIRO_GFX
  
- DEFINES		+=
  INCLUDES	+= \
  		-I$(srcdir)/../xpwidgets \
+ 		-I$(srcdir)/../shared \
  		-I$(topsrcdir)/other-licenses/atk-1.0 \
  		$(NULL)
 +
@@ -3947,10 +3452,150 @@
  };
  
  #endif
+diff --git a/xpcom/components/Makefile.in b/xpcom/components/Makefile.in
+--- a/xpcom/components/Makefile.in
++++ b/xpcom/components/Makefile.in
+@@ -98,10 +98,11 @@ 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)))
++LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
+ CXXFLAGS += $(MOZ_GTK2_CFLAGS)
+ endif
+diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp
+--- a/xpcom/components/ManifestParser.cpp
++++ b/xpcom/components/ManifestParser.cpp
+@@ -55,16 +55,17 @@
+ #include "nsTextFormatter.h"
+ #include "nsVersionComparator.h"
+ #include "nsXPCOMCIDInternal.h"
+ 
+ #include "nsIConsoleService.h"
+ #include "nsIScriptError.h"
+ #include "nsIXULAppInfo.h"
+ #include "nsIXULRuntime.h"
++#include "nsKDEUtils.h"
+ 
+ struct ManifestDirective
+ {
+   const char* directive;
+   int argc;
+ 
+   // Some directives should only be delivered for NS_COMPONENT_LOCATION
+   // manifests.
+@@ -422,16 +423,17 @@ ParseManifestCommon(NSLocationType aType
+ 
+   NS_NAMED_LITERAL_STRING(kPlatform, "platform");
+   NS_NAMED_LITERAL_STRING(kContentAccessible, "contentaccessible");
+   NS_NAMED_LITERAL_STRING(kApplication, "application");
+   NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
+   NS_NAMED_LITERAL_STRING(kOs, "os");
+   NS_NAMED_LITERAL_STRING(kOsVersion, "osversion");
+   NS_NAMED_LITERAL_STRING(kABI, "abi");
++  NS_NAMED_LITERAL_STRING(kDesktop, "desktop");
+ 
+   // Obsolete
+   NS_NAMED_LITERAL_STRING(kXPCNativeWrappers, "xpcnativewrappers");
+ 
+   nsAutoString appID;
+   nsAutoString appVersion;
+   nsAutoString osTarget;
+   nsAutoString abi;
+@@ -461,35 +463,39 @@ ParseManifestCommon(NSLocationType aType
+         CopyUTF8toUTF16(s, abi);
+         abi.Insert(PRUnichar('_'), 0);
+         abi.Insert(osTarget, 0);
+       }
+     }
+   }
+ 
+   nsAutoString osVersion;
++  nsAutoString desktop;
+ #if defined(XP_WIN)
+   OSVERSIONINFO info = { sizeof(OSVERSIONINFO) };
+   if (GetVersionEx(&info)) {
+     nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
+                                          info.dwMajorVersion,
+                                          info.dwMinorVersion);
+   }
++  desktop = NS_LITERAL_STRING("win");
+ #elif defined(XP_MACOSX)
+   SInt32 majorVersion, minorVersion;
+   if ((Gestalt(gestaltSystemVersionMajor, &majorVersion) == noErr) &&
+       (Gestalt(gestaltSystemVersionMinor, &minorVersion) == noErr)) {
+     nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
+                                          majorVersion,
+                                          minorVersion);
+   }
++  desktop = NS_LITERAL_STRING("macosx");
+ #elif defined(MOZ_WIDGET_GTK2)
+   nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
+                                        gtk_major_version,
+                                        gtk_minor_version);
++  desktop = nsKDEUtils::kdeSession() ? NS_LITERAL_STRING("kde") : NS_LITERAL_STRING("gnome");
+ #endif
+ 
+   // Because contracts must be registered after CIDs, we save and process them
+   // at the end.
+   nsTArray<CachedDirective> contracts;
+ 
+   char *token;
+   char *newline = buf;
+@@ -558,24 +564,26 @@ ParseManifestCommon(NSLocationType aType
+     bool ok = true;
+     TriState stAppVersion = eUnspecified;
+     TriState stApp = eUnspecified;
+     TriState stOsVersion = eUnspecified;
+     TriState stOs = eUnspecified;
+     TriState stABI = eUnspecified;
+     bool platform = false;
+     bool contentAccessible = false;
++    TriState stDesktop = eUnspecified;
+ 
+     while (NULL != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) && ok) {
+       ToLowerCase(token);
+       NS_ConvertASCIItoUTF16 wtoken(token);
+ 
+       if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
+           CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
+           CheckStringFlag(kABI, wtoken, abi, stABI) ||
++          CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
+           CheckVersionFlag(kOsVersion, wtoken, osVersion, stOsVersion) ||
+           CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion))
+         continue;
+ 
+       if (directive->contentflags &&
+           (CheckFlag(kPlatform, wtoken, platform) ||
+            CheckFlag(kContentAccessible, wtoken, contentAccessible)))
+         continue;
+@@ -594,16 +602,17 @@ ParseManifestCommon(NSLocationType aType
+       ok = false;
+     }
+ 
+     if (!ok ||
+         stApp == eBad ||
+         stAppVersion == eBad ||
+         stOs == eBad ||
+         stOsVersion == eBad ||
++        stDesktop == eBad ||
+         stABI == eBad)
+       continue;
+ 
+     if (directive->regfunc) {
+ #ifdef MOZ_IPC
+       if (GeckoProcessType_Default != XRE_GetProcessType())
+         continue;
+ #endif
 diff --git a/xpcom/io/Makefile.in b/xpcom/io/Makefile.in
 --- a/xpcom/io/Makefile.in
 +++ b/xpcom/io/Makefile.in
-@@ -195,14 +195,15 @@ DEFINES		+= -D_IMPL_NS_COM
+@@ -191,17 +191,17 @@ include $(topsrcdir)/config/rules.mk
+ DEFINES		+= -D_IMPL_NS_COM
  
  ifeq ($(OS_ARCH),Linux)
  ifneq (,$(findstring lib64,$(libdir)))
@@ -3958,36 +3603,38 @@
  endif
  endif
  
- LOCAL_INCLUDES	= -I..
-+LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
+-LOCAL_INCLUDES	= -I..
++LOCAL_INCLUDES	= -I.. -I$(topsrcdir)/toolkit/xre
  
- ifeq ($(MOZ_PLATFORM_MAEMO), 5)
- CFLAGS          += $(MOZ_DBUS_GLIB_CFLAGS) $(MOZ_PLATFORM_MAEMO_CFLAGS)
- CXXFLAGS        += $(MOZ_DBUS_GLIB_CFLAGS) $(MOZ_PLATFORM_MAEMO_CFLAGS)
+ ifeq ($(MOZ_PLATFORM_MAEMO),5)
+ CFLAGS          += $(MOZ_DBUS_CFLAGS)
+ CXXFLAGS        += $(MOZ_DBUS_CFLAGS)
  endif
  
+ ifdef MOZ_PLATFORM_MAEMO
+ CFLAGS          += $(MOZ_PLATFORM_MAEMO_CFLAGS)
 diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp
 --- a/xpcom/io/nsLocalFileUnix.cpp
 +++ b/xpcom/io/nsLocalFileUnix.cpp
-@@ -79,16 +79,17 @@
- #include "nsXPIDLString.h"
+@@ -91,16 +91,17 @@
  #include "prproces.h"
  #include "nsIDirectoryEnumerator.h"
  #include "nsISimpleEnumerator.h"
  #include "nsITimelineService.h"
  
  #ifdef MOZ_WIDGET_GTK2
+ #include "nsIGIOService.h"
  #include "nsIGnomeVFSService.h"
 +#include "nsKDEUtils.h"
  #endif
  
- #if (MOZ_PLATFORM_MAEMO == 5)
- #include <glib.h>
- #include <hildon-uri.h>
- #include <hildon-mime.h>
- #include <libosso.h>
- #endif
-@@ -1627,36 +1628,46 @@ nsLocalFile::Launch()
+ #ifdef XP_MACOSX
+ #include <Carbon/Carbon.h>
+ #include "CocoaFileUtils.h"
+ #include "prmem.h"
+ #include "plbase64.h"
+ 
+@@ -1818,44 +1819,50 @@ nsLocalFile::Launch()
  
      return NS_OK;
  }
@@ -3996,8 +3643,9 @@
  nsLocalFile::Reveal()
  {
  #ifdef MOZ_WIDGET_GTK2
--    nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
--    if (!vfs)
+-    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
+-    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
+-    if (!giovfs && !gnomevfs)
 -        return NS_ERROR_FAILURE;
 -
 +    nsCAutoString url;
@@ -4006,7 +3654,11 @@
          return NS_ERROR_FAILURE;
  
      if (isDirectory) {
--        return vfs->ShowURIForInput(mPath);
+-        if (giovfs)
+-            return giovfs->ShowURIForInput(mPath);
+-        else 
+-            /* Fallback to GnomeVFS */
+-            return gnomevfs->ShowURIForInput(mPath);
 +        url = mPath;
      } else {
          nsCOMPtr<nsIFile> parentDir;
@@ -4016,31 +3668,38 @@
          if (NS_FAILED(parentDir->GetNativePath(dirPath)))
              return NS_ERROR_FAILURE;
  
--        return vfs->ShowURIForInput(dirPath);
+-        if (giovfs)
+-            return giovfs->ShowURIForInput(dirPath);
+-        else 
+-            return gnomevfs->ShowURIForInput(dirPath);        
 +        url = dirPath;
      }
 +
-+    if( nsKDEUtils::kdeSupport()) {
-+        nsCStringArray command;
-+        command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
-+        command.AppendCString( url );
-+        return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
++    if(nsKDEUtils::kdeSupport()) {
++      nsCStringArray command;
++      command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
++      command.AppendCString( url );
++      return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
 +    }
 +
-+    nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
-+    if (!vfs)
-+        return NS_ERROR_FAILURE;
-+    return vfs->ShowURIForInput(url);
++    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
++    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
++    if (!giovfs && !gnomevfs)
++      return NS_ERROR_FAILURE;
 +
- #else
++    if (giovfs)
++      return giovfs->ShowURIForInput(url);
++    else
++      return gnomevfs->ShowURIForInput(url);
+ #elif defined(XP_MACOSX)
+     CFURLRef url;
+     if (NS_SUCCEEDED(GetCFURL(&url))) {
+       nsresult rv = CocoaFileUtils::RevealFileInFinder(url);
+       ::CFRelease(url);
+       return rv;
+     }
      return NS_ERROR_FAILURE;
- #endif
- }
- 
- NS_IMETHODIMP
- nsLocalFile::Launch()
- {
-@@ -1674,16 +1685,23 @@ nsLocalFile::Launch()
+@@ -1881,16 +1888,23 @@ nsLocalFile::Launch()
  
      if (nsnull == connection)
        return NS_ERROR_FAILURE;
@@ -4056,11 +3715,11 @@
 +      return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
 +    }
 +
-     nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
-     if (!vfs)
-         return NS_ERROR_FAILURE;
- 
-     return vfs->ShowURIForInput(mPath);
- #endif
- #else
-     return NS_ERROR_FAILURE;
+     nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
+     nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
+     if (giovfs) {
+       return giovfs->ShowURIForInput(mPath);
+     } else if (gnomevfs) {
+       /* GnomeVFS fallback */
+       return gnomevfs->ShowURIForInput(mPath);
+     }