mozilla-kde.patch
changeset 367 3fabd9f66322
parent 356 30a00f382aed
child 368 8891dd9439a1
equal deleted inserted replaced
366:15d0aa5d4b63 367:3fabd9f66322
    19  libs:: greprefs.js
    19  libs:: greprefs.js
    20  	$(INSTALL) $^ $(DIST)/bin/
    20  	$(INSTALL) $^ $(DIST)/bin/
    21 diff --git a/modules/libpref/src/Preferences.cpp b/modules/libpref/src/Preferences.cpp
    21 diff --git a/modules/libpref/src/Preferences.cpp b/modules/libpref/src/Preferences.cpp
    22 --- a/modules/libpref/src/Preferences.cpp
    22 --- a/modules/libpref/src/Preferences.cpp
    23 +++ b/modules/libpref/src/Preferences.cpp
    23 +++ b/modules/libpref/src/Preferences.cpp
    24 @@ -53,16 +53,17 @@
    24 @@ -56,16 +56,17 @@
    25  #include "nsIStringEnumerator.h"
    25  #include "nsIStringEnumerator.h"
    26  #include "nsIZipReader.h"
    26  #include "nsIZipReader.h"
    27  #include "nsPrefBranch.h"
    27  #include "nsPrefBranch.h"
    28  #include "nsXPIDLString.h"
    28  #include "nsXPIDLString.h"
    29  #include "nsCRT.h"
    29  #include "nsCRT.h"
    37  #include "pldhash.h"
    37  #include "pldhash.h"
    38  
    38  
    39  #include "prefapi.h"
    39  #include "prefapi.h"
    40  #include "prefread.h"
    40  #include "prefread.h"
    41  #include "prefapi_private_data.h"
    41  #include "prefapi_private_data.h"
    42 @@ -956,30 +957,48 @@ pref_LoadPrefsInDir(nsIFile* aDir, char 
    42 @@ -935,30 +936,48 @@ pref_LoadPrefsInDir(nsIFile* aDir, char 
    43  }
    43  }
    44  
    44  
    45  static nsresult pref_LoadPrefsInDirList(const char *listId)
    45  static nsresult pref_LoadPrefsInDirList(const char *listId)
    46  {
    46  {
    47    nsresult rv;
    47    nsresult rv;
    69    nsCOMPtr<nsISimpleEnumerator> dirList;
    69    nsCOMPtr<nsISimpleEnumerator> dirList;
    70    dirSvc->Get(listId,
    70    dirSvc->Get(listId,
    71                NS_GET_IID(nsISimpleEnumerator),
    71                NS_GET_IID(nsISimpleEnumerator),
    72                getter_AddRefs(dirList));
    72                getter_AddRefs(dirList));
    73    if (dirList) {
    73    if (dirList) {
    74      PRBool hasMore;
    74      bool hasMore;
    75      while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore) {
    75      while (NS_SUCCEEDED(dirList->HasMoreElements(&hasMore)) && hasMore) {
    76        nsCOMPtr<nsISupports> elem;
    76        nsCOMPtr<nsISupports> elem;
    77        dirList->GetNext(getter_AddRefs(elem));
    77        dirList->GetNext(getter_AddRefs(elem));
    78        if (elem) {
    78        if (elem) {
    79          nsCOMPtr<nsIFile> dir = do_QueryInterface(elem);
    79          nsCOMPtr<nsIFile> dir = do_QueryInterface(elem);
    87    }
    87    }
    88    return NS_OK;
    88    return NS_OK;
    89  }
    89  }
    90  
    90  
    91  static nsresult pref_ReadPrefFromJar(nsZipArchive* jarReader, const char *name)
    91  static nsresult pref_ReadPrefFromJar(nsZipArchive* jarReader, const char *name)
    92 @@ -1072,28 +1091,40 @@ static nsresult pref_InitInitialObjects(
    92 @@ -1051,28 +1070,40 @@ static nsresult pref_InitInitialObjects(
    93    /* these pref file names should not be used: we process them after all other application pref files for backwards compatibility */
    93    /* these pref file names should not be used: we process them after all other application pref files for backwards compatibility */
    94    static const char* specialFiles[] = {
    94    static const char* specialFiles[] = {
    95  #if defined(XP_MACOSX)
    95  #if defined(XP_MACOSX)
    96      "macprefs.js"
    96      "macprefs.js"
    97  #elif defined(XP_WIN)
    97  #elif defined(XP_WIN)
   110      "beos.js"
   110      "beos.js"
   111  #endif
   111  #endif
   112    };
   112    };
   113  
   113  
   114 +  if(nsKDEUtils::kdeSession()) { // TODO what if some setup actually requires the helper?
   114 +  if(nsKDEUtils::kdeSession()) { // TODO what if some setup actually requires the helper?
   115 +    for( int i = 0;
   115 +    for(int i = 0;
   116 +        i < NS_ARRAY_LENGTH(specialFiles);
   116 +        i < NS_ARRAY_LENGTH(specialFiles);
   117 +        ++i ) {
   117 +        ++i ) {
   118 +      if( *specialFiles[ i ] == '\0' ) {
   118 +      if( *specialFiles[ i ] == '\0' ) {
   119 +        specialFiles[ i ] = "kde.js";
   119 +        specialFiles[ i ] = "kde.js";
   120 +        break;
   120 +        break;
   121 +      }
   121 +      }
   122 +    }
   122 +    }
   123 +  }
   123 +  }
   124 +
   124 +
   125    rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, NS_ARRAY_LENGTH(specialFiles));
   125    rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, ArrayLength(specialFiles));
   126    if (NS_FAILED(rv))
   126    if (NS_FAILED(rv))
   127      NS_WARNING("Error parsing application default preferences.");
   127      NS_WARNING("Error parsing application default preferences.");
   128  
   128  
   129    // Load jar:$app/omni.jar!/defaults/preferences/*.js
   129    // Load jar:$app/omni.jar!/defaults/preferences/*.js
   130    nsZipArchive *appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
   130    nsZipArchive *appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
   145 +
   145 +
   146 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
   146 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
   147 diff --git a/toolkit/components/downloads/nsDownloadManager.cpp b/toolkit/components/downloads/nsDownloadManager.cpp
   147 diff --git a/toolkit/components/downloads/nsDownloadManager.cpp b/toolkit/components/downloads/nsDownloadManager.cpp
   148 --- a/toolkit/components/downloads/nsDownloadManager.cpp
   148 --- a/toolkit/components/downloads/nsDownloadManager.cpp
   149 +++ b/toolkit/components/downloads/nsDownloadManager.cpp
   149 +++ b/toolkit/components/downloads/nsDownloadManager.cpp
   150 @@ -71,16 +71,20 @@
   150 @@ -74,16 +74,20 @@
   151  
   151  
   152  #ifdef XP_WIN
   152  #ifdef XP_WIN
   153  #include <shlobj.h>
   153  #include <shlobj.h>
   154  #ifdef DOWNLOAD_SCANNER
   154  #ifdef DOWNLOAD_SCANNER
   155  #include "nsDownloadScanner.h"
   155  #include "nsDownloadScanner.h"
   166  
   166  
   167  #ifdef ANDROID
   167  #ifdef ANDROID
   168  #include "AndroidBridge.h"
   168  #include "AndroidBridge.h"
   169  #endif
   169  #endif
   170  
   170  
   171 @@ -2203,16 +2207,25 @@ nsDownload::SetState(DownloadState aStat
   171 @@ -2214,16 +2218,25 @@ nsDownload::SetState(DownloadState aStat
   172        nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
   172        nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
   173  
   173  
   174        // Master pref to control this function.
   174        // Master pref to control this function.
   175        PRBool showTaskbarAlert = PR_TRUE;
   175        bool showTaskbarAlert = true;
   176        if (pref)
   176        if (pref)
   177          pref->GetBoolPref(PREF_BDM_SHOWALERTONCOMPLETE, &showTaskbarAlert);
   177          pref->GetBoolPref(PREF_BDM_SHOWALERTONCOMPLETE, &showTaskbarAlert);
   178  
   178  
   179        if (showTaskbarAlert) {
   179        if (showTaskbarAlert) {
   180 +        if( nsKDEUtils::kdeSupport()) {
   180 +        if( nsKDEUtils::kdeSupport()) {
   181 +            nsCStringArray command;
   181 +          nsTArray<nsCString> command;
   182 +            command.AppendCString( NS_LITERAL_CSTRING( "DOWNLOADFINISHED" ));
   182 +          command.AppendElement( NS_LITERAL_CSTRING( "DOWNLOADFINISHED" ));
   183 +            nsAutoString displayName;
   183 +          nsAutoString displayName;
   184 +            GetDisplayName( displayName );
   184 +          GetDisplayName( displayName );
   185 +            command.AppendCString( nsCAutoString( ToNewUTF8String( displayName )));
   185 +          command.AppendElement( nsCAutoString( ToNewUTF8String( displayName )));
   186 +            nsKDEUtils::command( command );
   186 +          nsKDEUtils::command( command );
   187 +        } else {
   187 +        } else {
   188 +        // begin non-KDE block
   188 +        // begin non-KDE block
   189          PRInt32 alertInterval = 2000;
   189          PRInt32 alertInterval = 2000;
   190          if (pref)
   190          if (pref)
   191            pref->GetIntPref(PREF_BDM_SHOWALERTINTERVAL, &alertInterval);
   191            pref->GetIntPref(PREF_BDM_SHOWALERTINTERVAL, &alertInterval);
   192  
   192  
   193          PRInt64 alertIntervalUSec = alertInterval * PR_USEC_PER_MSEC;
   193          PRInt64 alertIntervalUSec = alertInterval * PR_USEC_PER_MSEC;
   194          PRInt64 goat = PR_Now() - mStartTime;
   194          PRInt64 goat = PR_Now() - mStartTime;
   195          showTaskbarAlert = goat > alertIntervalUSec;
   195          showTaskbarAlert = goat > alertIntervalUSec;
   196  
   196  
   197 @@ -2236,19 +2249,20 @@ nsDownload::SetState(DownloadState aStat
   197 @@ -2247,19 +2260,20 @@ nsDownload::SetState(DownloadState aStat
   198                // If downloads are automatically removed per the user's
   198                // If downloads are automatically removed per the user's
   199                // retention policy, there's no reason to make the text clickable
   199                // retention policy, there's no reason to make the text clickable
   200                // because if it is, they'll click open the download manager and
   200                // because if it is, they'll click open the download manager and
   201                // the items they downloaded will have been removed.
   201                // the items they downloaded will have been removed.
   202                alerts->ShowAlertNotification(
   202                alerts->ShowAlertNotification(
  2108  
  2108  
  2109  private:
  2109  private:
  2110    ~nsUnixSystemProxySettings() {}
  2110    ~nsUnixSystemProxySettings() {}
  2111    
  2111    
  2112    nsCOMPtr<nsIGConfService> mGConf;
  2112    nsCOMPtr<nsIGConfService> mGConf;
  2113    PRBool IsProxyMode(const char* aMode);
  2113    bool IsProxyMode(const char* aMode);
  2114    nsresult SetProxyResultFromGConf(const char* aKeyBase, const char* aType, nsACString& aResult);
  2114    nsresult SetProxyResultFromGConf(const char* aKeyBase, const char* aType, nsACString& aResult);
  2115    nsresult GetProxyFromGConf(const nsACString& aScheme, const nsACString& aHost, PRInt32 aPort, nsACString& aResult);
  2115    nsresult GetProxyFromGConf(const nsACString& aScheme, const nsACString& aHost, PRInt32 aPort, nsACString& aResult);
  2116 +  nsresult GetProxyFromKDE(const nsACString& aScheme, const nsACString& aHost, PRInt32 aPort, nsACString& aResult);
  2116 +  nsresult GetProxyFromKDE(const nsACString& aScheme, const nsACString& aHost, PRInt32 aPort, nsACString& aResult);
  2117  };
  2117  };
  2118  
  2118  
  2119  NS_IMPL_ISUPPORTS1(nsUnixSystemProxySettings, nsISystemProxySettings)
  2119  NS_IMPL_ISUPPORTS1(nsUnixSystemProxySettings, nsISystemProxySettings)
  2120  
  2120  
  2121  nsresult
  2121  nsresult
  2122  nsUnixSystemProxySettings::Init()
  2122  nsUnixSystemProxySettings::Init()
  2123  {
  2123  {
  2124    // If this is a GNOME session, load gconf and try to use its preferences.
  2124    mGConf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
  2125 @@ -407,16 +410,19 @@ nsUnixSystemProxySettings::GetProxyForUR
  2125 @@ -408,16 +411,19 @@ nsUnixSystemProxySettings::GetProxyForUR
  2126    nsCAutoString host;
  2126    nsCAutoString host;
  2127    rv = aURI->GetHost(host);
  2127    rv = aURI->GetHost(host);
  2128    NS_ENSURE_SUCCESS(rv, rv);
  2128    NS_ENSURE_SUCCESS(rv, rv);
  2129  
  2129  
  2130    PRInt32 port;
  2130    PRInt32 port;
  2140    return GetProxyFromGConf(scheme, host, port, aResult);
  2140    return GetProxyFromGConf(scheme, host, port, aResult);
  2141  }
  2141  }
  2142  
  2142  
  2143  #define NS_UNIXSYSTEMPROXYSERVICE_CID  /* 0fa3158c-d5a7-43de-9181-a285e74cf1d4 */\
  2143  #define NS_UNIXSYSTEMPROXYSERVICE_CID  /* 0fa3158c-d5a7-43de-9181-a285e74cf1d4 */\
  2144       { 0x0fa3158c, 0xd5a7, 0x43de, \
  2144       { 0x0fa3158c, 0xd5a7, 0x43de, \
  2145 @@ -437,8 +443,34 @@ static const mozilla::Module::ContractID
  2145 @@ -438,8 +444,34 @@ static const mozilla::Module::ContractID
  2146  
  2146  
  2147  static const mozilla::Module kUnixProxyModule = {
  2147  static const mozilla::Module kUnixProxyModule = {
  2148    mozilla::Module::kVersion,
  2148    mozilla::Module::kVersion,
  2149    kUnixProxyCIDs,
  2149    kUnixProxyCIDs,
  2150    kUnixProxyContracts
  2150    kUnixProxyContracts
  2165 +  if( aPort >= 0 )
  2165 +  if( aPort >= 0 )
  2166 +  {
  2166 +  {
  2167 +    url += ":";
  2167 +    url += ":";
  2168 +    url += nsPrintfCString("%d", aPort);
  2168 +    url += nsPrintfCString("%d", aPort);
  2169 +  }
  2169 +  }
  2170 +  nsCStringArray command;
  2170 +  nsTArray<nsCString> command;
  2171 +  command.AppendCString( NS_LITERAL_CSTRING( "GETPROXY" ));
  2171 +  command.AppendElement( NS_LITERAL_CSTRING( "GETPROXY" ));
  2172 +  command.AppendCString( url );
  2172 +  command.AppendElement( url );
  2173 +  nsCStringArray result;
  2173 +  nsTArray<nsCString> result;
  2174 +  if( !nsKDEUtils::command( command, &result ) || result.Count() != 1 )
  2174 +  if( !nsKDEUtils::command( command, &result ) || result.Count() != 1 )
  2175 +    return NS_ERROR_FAILURE;
  2175 +    return NS_ERROR_FAILURE;
  2176 +  aResult = *result[ 0 ];
  2176 +  aResult = *result[ 0 ];
  2177 +  return NS_OK;
  2177 +  return NS_OK;
  2178 +}
  2178 +}
  2179 +
  2179 +
  2180 diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in
  2180 diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in
  2181 --- a/toolkit/xre/Makefile.in
  2181 --- a/toolkit/xre/Makefile.in
  2182 +++ b/toolkit/xre/Makefile.in
  2182 +++ b/toolkit/xre/Makefile.in
  2183 @@ -94,17 +94,18 @@ EXPORTS = nsWindowsDllInterceptor.h
  2183 @@ -95,17 +95,18 @@ else
  2184  else
       
  2185  ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
  2184  ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
  2186  CMMSRCS = nsNativeAppSupportCocoa.mm
  2185  CMMSRCS = nsNativeAppSupportCocoa.mm
       
  2186  EXPORTS = MacQuirks.h
  2187  else
  2187  else
  2188  ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
  2188  ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
  2189  CPPSRCS += nsNativeAppSupportOS2.cpp
  2189  CPPSRCS += nsNativeAppSupportOS2.cpp
  2190  else
  2190  else
  2191  ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
  2191  ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
  2193 +CPPSRCS += nsNativeAppSupportUnix.cpp nsKDEUtils.cpp
  2193 +CPPSRCS += nsNativeAppSupportUnix.cpp nsKDEUtils.cpp
  2194 +EXPORTS += nsKDEUtils.h
  2194 +EXPORTS += nsKDEUtils.h
  2195  else
  2195  else
  2196  ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
  2196  ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
  2197  MOCSRCS += moc_nsNativeAppSupportQt.cpp
  2197  MOCSRCS += moc_nsNativeAppSupportQt.cpp
  2198    $(NULL)
       
  2199  CPPSRCS += $(MOCSRCS)
  2198  CPPSRCS += $(MOCSRCS)
  2200  CPPSRCS += nsNativeAppSupportQt.cpp
  2199  CPPSRCS += nsNativeAppSupportQt.cpp
  2201  CPPSRCS += nsQAppInstance.cpp
  2200  CPPSRCS += nsQAppInstance.cpp
  2202  EXPORTS += nsQAppInstance.h
  2201  EXPORTS += nsQAppInstance.h
       
  2202  else
  2203 diff --git a/toolkit/xre/nsKDEUtils.cpp b/toolkit/xre/nsKDEUtils.cpp
  2203 diff --git a/toolkit/xre/nsKDEUtils.cpp b/toolkit/xre/nsKDEUtils.cpp
  2204 new file mode 100644
  2204 new file mode 100644
  2205 --- /dev/null
  2205 --- /dev/null
  2206 +++ b/toolkit/xre/nsKDEUtils.cpp
  2206 +++ b/toolkit/xre/nsKDEUtils.cpp
  2207 @@ -0,0 +1,328 @@
  2207 @@ -0,0 +1,330 @@
  2208 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2208 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2209 +/* ***** BEGIN LICENSE BLOCK *****
  2209 +/* ***** BEGIN LICENSE BLOCK *****
  2210 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2210 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2211 + *
  2211 + *
  2212 + * The contents of this file are subject to the Mozilla Public License Version
  2212 + * The contents of this file are subject to the Mozilla Public License Version
  2297 +    return kde;
  2297 +    return kde;
  2298 +    }
  2298 +    }
  2299 +
  2299 +
  2300 +static bool getKdeSupport()
  2300 +static bool getKdeSupport()
  2301 +    {
  2301 +    {
  2302 +    nsCStringArray command;
  2302 +    nsTArray<nsCString> command;
  2303 +    command.AppendCString( NS_LITERAL_CSTRING( "CHECK" ));
  2303 +    command.AppendElement( NS_LITERAL_CSTRING( "CHECK" ));
  2304 +    command.AppendCString( NS_LITERAL_CSTRING( MAKE_STR( KMOZILLAHELPER_VERSION )));
  2304 +    command.AppendElement( NS_LITERAL_CSTRING( MAKE_STR( KMOZILLAHELPER_VERSION )));
  2305 +    bool kde = nsKDEUtils::command( command );
  2305 +    bool kde = nsKDEUtils::command( command.get() );
  2306 +#ifdef DEBUG_KDE
  2306 +#ifdef DEBUG_KDE
  2307 +    fprintf( stderr, "KDE RUNNING %d\n", kde );
  2307 +    fprintf( stderr, "KDE RUNNING %d\n", kde );
  2308 +#endif
  2308 +#endif
  2309 +    return kde;
  2309 +    return kde;
  2310 +    }
  2310 +    }
  2342 +    }
  2342 +    }
  2343 +
  2343 +
  2344 +struct nsKDECommandData
  2344 +struct nsKDECommandData
  2345 +    {
  2345 +    {
  2346 +    FILE* file;
  2346 +    FILE* file;
  2347 +    nsCStringArray* output;
  2347 +    nsTArray<nsCString>* output;
  2348 +    GMainLoop* loop;
  2348 +    GMainLoop* loop;
  2349 +    bool success;
  2349 +    bool success;
  2350 +    };
  2350 +    };
  2351 +
  2351 +
  2352 +static gboolean kdeReadFunc( GIOChannel*, GIOCondition, gpointer data )
  2352 +static gboolean kdeReadFunc( GIOChannel*, GIOCondition, gpointer data )
  2366 +        command_failed = ( strcmp( buf, "\\0" ) == 0 );
  2366 +        command_failed = ( strcmp( buf, "\\0" ) == 0 );
  2367 +        nsCAutoString line( buf );
  2367 +        nsCAutoString line( buf );
  2368 +        line.ReplaceSubstring( "\\n", "\n" );
  2368 +        line.ReplaceSubstring( "\\n", "\n" );
  2369 +        line.ReplaceSubstring( "\\" "\\", "\\" ); //  \\ -> \ , i.e. unescape
  2369 +        line.ReplaceSubstring( "\\" "\\", "\\" ); //  \\ -> \ , i.e. unescape
  2370 +        if( p->output && !( command_done || command_failed ))
  2370 +        if( p->output && !( command_done || command_failed ))
  2371 +            p->output->AppendCString( nsCString( buf )); // TODO utf8?
  2371 +            p->output->AppendElement( nsCString( buf )); // TODO utf8?
  2372 +        }
  2372 +        }
  2373 +    bool quit = false;
  2373 +    bool quit = false;
  2374 +    if( feof( p->file ) || command_failed )
  2374 +    if( feof( p->file ) || command_failed )
  2375 +        {
  2375 +        {
  2376 +        quit = true;
  2376 +        quit = true;
  2388 +        return FALSE;
  2388 +        return FALSE;
  2389 +        }
  2389 +        }
  2390 +    return TRUE;
  2390 +    return TRUE;
  2391 +    }
  2391 +    }
  2392 +
  2392 +
  2393 +bool nsKDEUtils::command( const nsCStringArray& command, nsCStringArray* output )
  2393 +bool nsKDEUtils::command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output )
  2394 +    {
  2394 +    {
  2395 +    return self()->internalCommand( command, NULL, false, output );
  2395 +    return self()->internalCommand( command, NULL, false, output );
  2396 +    }
  2396 +    }
  2397 +
  2397 +
  2398 +bool nsKDEUtils::commandBlockUi( const nsCStringArray& command, const GtkWindow* parent, nsCStringArray* output )
  2398 +bool nsKDEUtils::commandBlockUi( const nsTArray<nsCString>& command, const GtkWindow* parent, nsTArray<nsCString>* output )
  2399 +    {
  2399 +    {
  2400 +    return self()->internalCommand( command, parent, true, output );
  2400 +    return self()->internalCommand( command, parent, true, output );
  2401 +    }
  2401 +    }
  2402 +
  2402 +
  2403 +bool nsKDEUtils::internalCommand( const nsCStringArray& command, const GtkWindow* parent, bool blockUi,
  2403 +bool nsKDEUtils::internalCommand( const nsTArray<nsCString>& command, const GtkWindow* parent, bool blockUi,
  2404 +    nsCStringArray* output )
  2404 +    nsTArray<nsCString>* output )
  2405 +    {
  2405 +    {
       
  2406 +    nsCString internal_command;
       
  2407 +    internal_command.AssignLiteral(command);
  2406 +    if( !startHelper())
  2408 +    if( !startHelper())
  2407 +        return false;
  2409 +        return false;
  2408 +    feedCommand( command );
  2410 +    feedCommand(internal_command);
  2409 +    // do not store the data in 'this' but in extra structure, just in case there
  2411 +    // do not store the data in 'this' but in extra structure, just in case there
  2410 +    // is reentrancy (can there be? the event loop is re-entered)
  2412 +    // is reentrancy (can there be? the event loop is re-entered)
  2411 +    nsKDECommandData data;
  2413 +    nsKDECommandData data;
  2412 +    data.file = replyFile;
  2414 +    data.file = replyFile;
  2413 +    data.output = output;
  2415 +    data.output = output;
  2513 +    if( replyFile != NULL )
  2515 +    if( replyFile != NULL )
  2514 +        fclose( replyFile );
  2516 +        fclose( replyFile );
  2515 +    helperRunning = false;
  2517 +    helperRunning = false;
  2516 +    }
  2518 +    }
  2517 +
  2519 +
  2518 +void nsKDEUtils::feedCommand( const nsCStringArray& command )
  2520 +void nsKDEUtils::feedCommand( const nsTArray<nsCString>& command )
  2519 +    {
  2521 +    {
  2520 +    for( int i = 0;
  2522 +    for( int i = 0;
  2521 +         i < command.Count();
  2523 +         i < command.Length();
  2522 +         ++i )
  2524 +         ++i )
  2523 +        {
  2525 +        {
  2524 +        nsCString line = *command[ i ];
  2526 +        nsCString line = command[ i ];
  2525 +        line.ReplaceSubstring( "\\", "\\" "\\" ); // \ -> \\ , i.e. escape
  2527 +        line.ReplaceSubstring( "\\", "\\" "\\" ); // \ -> \\ , i.e. escape
  2526 +        line.ReplaceSubstring( "\n", "\\n" );
  2528 +        line.ReplaceSubstring( "\n", "\\n" );
  2527 +#ifdef DEBUG_KDE
  2529 +#ifdef DEBUG_KDE
  2528 +        fprintf( stderr, "COMM: %s\n", line.get());
  2530 +        fprintf( stderr, "COMM: %s\n", line.get());
  2529 +#endif
  2531 +#endif
  2535 +    }
  2537 +    }
  2536 diff --git a/toolkit/xre/nsKDEUtils.h b/toolkit/xre/nsKDEUtils.h
  2538 diff --git a/toolkit/xre/nsKDEUtils.h b/toolkit/xre/nsKDEUtils.h
  2537 new file mode 100644
  2539 new file mode 100644
  2538 --- /dev/null
  2540 --- /dev/null
  2539 +++ b/toolkit/xre/nsKDEUtils.h
  2541 +++ b/toolkit/xre/nsKDEUtils.h
  2540 @@ -0,0 +1,77 @@
  2542 @@ -0,0 +1,78 @@
  2541 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2543 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2542 + *
  2544 + *
  2543 + * ***** BEGIN LICENSE BLOCK *****
  2545 + * ***** BEGIN LICENSE BLOCK *****
  2544 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2546 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2545 + *
  2547 + *
  2578 +
  2580 +
  2579 +#ifndef nsKDEUtils_h__
  2581 +#ifndef nsKDEUtils_h__
  2580 +#define nsKDEUtils_h__
  2582 +#define nsKDEUtils_h__
  2581 +
  2583 +
  2582 +#include "nsStringGlue.h"
  2584 +#include "nsStringGlue.h"
  2583 +#include "nsVoidArray.h"
  2585 +#include "nsTArray.h"
  2584 +#include <stdio.h>
  2586 +#include <stdio.h>
  2585 +
  2587 +
  2586 +typedef struct _GtkWindow GtkWindow;
  2588 +typedef struct _GtkWindow GtkWindow;
  2587 +
  2589 +
  2588 +class NS_EXPORT nsKDEUtils
  2590 +class NS_EXPORT nsKDEUtils
  2594 +        static bool kdeSession();
  2596 +        static bool kdeSession();
  2595 +        /* Returns true if running inside a KDE session and KDE support is available
  2597 +        /* Returns true if running inside a KDE session and KDE support is available
  2596 +           for Firefox. This should be used everywhere where the external helper is needed. */
  2598 +           for Firefox. This should be used everywhere where the external helper is needed. */
  2597 +        static bool kdeSupport();
  2599 +        static bool kdeSupport();
  2598 +        /* Executes the given helper command, returns true if helper returned success. */
  2600 +        /* Executes the given helper command, returns true if helper returned success. */
  2599 +        static bool command( const nsCStringArray& command, nsCStringArray* output = NULL );
  2601 +        static bool command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output = NULL );
  2600 +        /* Like command(), but additionally blocks the parent widget like if there was
  2602 +        /* Like command(), but additionally blocks the parent widget like if there was
  2601 +           a modal dialog shown and enters the event loop (i.e. there are still paint updates,
  2603 +           a modal dialog shown and enters the event loop (i.e. there are still paint updates,
  2602 +           this is for commands that take long). */
  2604 +           this is for commands that take long). */
  2603 +        static bool commandBlockUi( const nsCStringArray& command, const GtkWindow* parent, nsCStringArray* output = NULL );
  2605 +        static bool commandBlockUi( const nsTArray<nsCString>& command, const GtkWindow* parent, nsTArray<nsCString>* output = NULL );
       
  2606 +
  2604 +    private:
  2607 +    private:
  2605 +        nsKDEUtils();
  2608 +        nsKDEUtils();
  2606 +        ~nsKDEUtils();
  2609 +        ~nsKDEUtils();
  2607 +        static nsKDEUtils* self();
  2610 +        static nsKDEUtils* self();
  2608 +        bool startHelper();
  2611 +        bool startHelper();
  2609 +        void closeHelper();
  2612 +        void closeHelper();
  2610 +        void feedCommand( const nsCStringArray& command );
  2613 +        void feedCommand( const nsTArray<nsCString>& command );
  2611 +        bool internalCommand( const nsCStringArray& command, const GtkWindow* parent, bool isParent,
  2614 +        bool internalCommand( const nsTArray<nsCString>& command, const GtkWindow* parent, bool isParent,
  2612 +            nsCStringArray* output );
  2615 +            nsTArray<nsCString>* output );
  2613 +        FILE* commandFile;
  2616 +        FILE* commandFile;
  2614 +        FILE* replyFile;
  2617 +        FILE* replyFile;
  2615 +    };
  2618 +    };
  2616 +
  2619 +
  2617 +#endif // nsKDEUtils
  2620 +#endif // nsKDEUtils
  2845 +#include "nsKDEUtils.h"
  2848 +#include "nsKDEUtils.h"
  2846 +
  2849 +
  2847 +/* static */ PRBool
  2850 +/* static */ PRBool
  2848 +nsKDERegistry::HandlerExists(const char *aProtocolScheme)
  2851 +nsKDERegistry::HandlerExists(const char *aProtocolScheme)
  2849 +{
  2852 +{
  2850 +    nsCStringArray command;
  2853 +    nsTArray<nsCString> command;
  2851 +    command.AppendCString( NS_LITERAL_CSTRING( "HANDLEREXISTS" ));
  2854 +    command.AppendElement( NS_LITERAL_CSTRING( "HANDLEREXISTS" ));
  2852 +    command.AppendCString( nsCAutoString( aProtocolScheme ));
  2855 +    command.AppendElement( nsCAutoString( aProtocolScheme ));
  2853 +    return nsKDEUtils::command( command );
  2856 +    return nsKDEUtils::command( command );
  2854 +}
  2857 +}
  2855 +
  2858 +
  2856 +/* static */ nsresult
  2859 +/* static */ nsresult
  2857 +nsKDERegistry::LoadURL(nsIURI *aURL)
  2860 +nsKDERegistry::LoadURL(nsIURI *aURL)
  2858 +{
  2861 +{
  2859 +    nsCStringArray command;
  2862 +    nsTArray<nsCString> command;
  2860 +    command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
  2863 +    command.AppendElement( NS_LITERAL_CSTRING( "OPEN" ));
  2861 +    nsCString url;
  2864 +    nsCString url;
  2862 +    aURL->GetSpec( url );
  2865 +    aURL->GetSpec( url );
  2863 +    command.AppendCString( url );
  2866 +    command.AppendElement( url );
  2864 +    return nsKDEUtils::command( command );
  2867 +    return nsKDEUtils::command( command );
  2865 +}
  2868 +}
  2866 +
  2869 +
  2867 +/* static */ void
  2870 +/* static */ void
  2868 +nsKDERegistry::GetAppDescForScheme(const nsACString& aScheme,
  2871 +nsKDERegistry::GetAppDescForScheme(const nsACString& aScheme,
  2869 +                                     nsAString& aDesc)
  2872 +                                     nsAString& aDesc)
  2870 +{
  2873 +{
  2871 +    nsCStringArray command;
  2874 +    nsTArray<nsCString> command;
  2872 +    command.AppendCString( NS_LITERAL_CSTRING( "GETAPPDESCFORSCHEME" ));
  2875 +    command.AppendElement( NS_LITERAL_CSTRING( "GETAPPDESCFORSCHEME" ));
  2873 +    command.AppendCString( aScheme );
  2876 +    command.AppendElement( aScheme );
  2874 +    nsCStringArray output;
  2877 +    nsTArray<nsCString> output;
  2875 +    if( nsKDEUtils::command( command, &output ) && output.Count() == 1 )
  2878 +    if( nsKDEUtils::command( command, &output ) && output.Length() == 1 )
  2876 +        CopyUTF8toUTF16( *output[ 0 ], aDesc );
  2879 +        CopyUTF8toUTF16( output[ 0 ], aDesc );
  2877 +}
  2880 +}
  2878 +
  2881 +
  2879 +
  2882 +
  2880 +/* static */ already_AddRefed<nsMIMEInfoBase>
  2883 +/* static */ already_AddRefed<nsMIMEInfoBase>
  2881 +nsKDERegistry::GetFromExtension(const nsACString& aFileExt)
  2884 +nsKDERegistry::GetFromExtension(const nsACString& aFileExt)
  2882 +{
  2885 +{
  2883 +    NS_ASSERTION(aFileExt[0] != '.', "aFileExt shouldn't start with a dot");
  2886 +    NS_ASSERTION(aFileExt[0] != '.', "aFileExt shouldn't start with a dot");
  2884 +    nsCStringArray command;
  2887 +    nsTArray<nsCString> command;
  2885 +    command.AppendCString( NS_LITERAL_CSTRING( "GETFROMEXTENSION" ));
  2888 +    command.AppendElement( NS_LITERAL_CSTRING( "GETFROMEXTENSION" ));
  2886 +    command.AppendCString( aFileExt );
  2889 +    command.AppendElement( aFileExt );
  2887 +    return GetFromHelper( command );
  2890 +    return GetFromHelper( command );
  2888 +}
  2891 +}
  2889 +
  2892 +
  2890 +/* static */ already_AddRefed<nsMIMEInfoBase>
  2893 +/* static */ already_AddRefed<nsMIMEInfoBase>
  2891 +nsKDERegistry::GetFromType(const nsACString& aMIMEType)
  2894 +nsKDERegistry::GetFromType(const nsACString& aMIMEType)
  2892 +{
  2895 +{
  2893 +    nsCStringArray command;
  2896 +    nsTArray<nsCString> command;
  2894 +    command.AppendCString( NS_LITERAL_CSTRING( "GETFROMTYPE" ));
  2897 +    command.AppendElement( NS_LITERAL_CSTRING( "GETFROMTYPE" ));
  2895 +    command.AppendCString( aMIMEType );
  2898 +    command.AppendElement( aMIMEType );
  2896 +    return GetFromHelper( command );
  2899 +    return GetFromHelper( command );
  2897 +}
  2900 +}
  2898 +
  2901 +
  2899 +/* static */ already_AddRefed<nsMIMEInfoBase>
  2902 +/* static */ already_AddRefed<nsMIMEInfoBase>
  2900 +nsKDERegistry::GetFromHelper(const nsCStringArray& command)
  2903 +nsKDERegistry::GetFromHelper(const nsTArray<nsCString>& command)
  2901 +{
  2904 +{
  2902 +    nsCStringArray output;
  2905 +    nsTArray<nsCString> output;
  2903 +    if( nsKDEUtils::command( command, &output ) && output.Count() == 3 )
  2906 +    if( nsKDEUtils::command( command, &output ) && output.Length() == 3 )
  2904 +        {
  2907 +        {
  2905 +        nsCString mimetype = *output[ 0 ];
  2908 +        nsCString mimetype = output[ 0 ];
  2906 +        nsRefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix( mimetype );
  2909 +        nsRefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix( mimetype );
  2907 +        NS_ENSURE_TRUE(mimeInfo, nsnull);
  2910 +        NS_ENSURE_TRUE(mimeInfo, nsnull);
  2908 +        nsCString description = *output[ 1 ];
  2911 +        nsCString description = output[ 1 ];
  2909 +        mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description));
  2912 +        mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description));
  2910 +        nsCString handlerAppName = *output[ 2 ];
  2913 +        nsCString handlerAppName = output[ 2 ];
  2911 +        mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(handlerAppName));
  2914 +        mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(handlerAppName));
  2912 +        mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
  2915 +        mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
  2913 +        nsMIMEInfoBase* retval;
  2916 +        nsMIMEInfoBase* retval;
  2914 +        NS_ADDREF((retval = mimeInfo));
  2917 +        NS_ADDREF((retval = mimeInfo));
  2915 +        return retval;
  2918 +        return retval;
  2918 +}
  2921 +}
  2919 diff --git a/uriloader/exthandler/unix/nsKDERegistry.h b/uriloader/exthandler/unix/nsKDERegistry.h
  2922 diff --git a/uriloader/exthandler/unix/nsKDERegistry.h b/uriloader/exthandler/unix/nsKDERegistry.h
  2920 new file mode 100644
  2923 new file mode 100644
  2921 --- /dev/null
  2924 --- /dev/null
  2922 +++ b/uriloader/exthandler/unix/nsKDERegistry.h
  2925 +++ b/uriloader/exthandler/unix/nsKDERegistry.h
  2923 @@ -0,0 +1,61 @@
  2926 @@ -0,0 +1,62 @@
  2924 +/* ***** BEGIN LICENSE BLOCK *****
  2927 +/* ***** BEGIN LICENSE BLOCK *****
  2925 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2928 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2926 + *
  2929 + *
  2927 + * The contents of this file are subject to the Mozilla Public License Version
  2930 + * The contents of this file are subject to the Mozilla Public License Version
  2928 + * 1.1 (the "License"); you may not use this file except in compliance with
  2931 + * 1.1 (the "License"); you may not use this file except in compliance with
  2958 + *
  2961 + *
  2959 + * ***** END LICENSE BLOCK ***** */
  2962 + * ***** END LICENSE BLOCK ***** */
  2960 +
  2963 +
  2961 +#include "nsIURI.h"
  2964 +#include "nsIURI.h"
  2962 +#include "nsCOMPtr.h"
  2965 +#include "nsCOMPtr.h"
       
  2966 +#include "nsTArray.h"
  2963 +
  2967 +
  2964 +class nsMIMEInfoBase;
  2968 +class nsMIMEInfoBase;
  2965 +class nsCAutoString;
  2969 +class nsCAutoString;
  2966 +class nsCStringArray;
  2970 +class nsCString;
  2967 +
  2971 +
  2968 +class nsKDERegistry
  2972 +class nsKDERegistry
  2969 +{
  2973 +{
  2970 + public:
  2974 + public:
  2971 +  static PRBool HandlerExists(const char *aProtocolScheme);
  2975 +  static PRBool HandlerExists(const char *aProtocolScheme);
  2977 +
  2981 +
  2978 +  static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsACString& aFileExt);
  2982 +  static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsACString& aFileExt);
  2979 +
  2983 +
  2980 +  static already_AddRefed<nsMIMEInfoBase> GetFromType(const nsACString& aMIMEType);
  2984 +  static already_AddRefed<nsMIMEInfoBase> GetFromType(const nsACString& aMIMEType);
  2981 + private:
  2985 + private:
  2982 +  static already_AddRefed<nsMIMEInfoBase> GetFromHelper(const nsCStringArray& command);
  2986 +  static already_AddRefed<nsMIMEInfoBase> GetFromHelper(const nsTArray<nsCString>& command);
  2983 +
  2987 +
  2984 +};
  2988 +};
  2985 diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
  2989 diff --git a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
  2986 --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
  2990 --- a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
  2987 +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
  2991 +++ b/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp
  3025  
  3029  
  3026    return rv;
  3030    return rv;
  3027  }
  3031  }
  3028  
  3032  
  3029  NS_IMETHODIMP
  3033  NS_IMETHODIMP
  3030  nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
  3034  nsMIMEInfoUnix::GetHasDefaultHandler(bool *_retval)
  3031  {
  3035  {
  3032    *_retval = PR_FALSE;
  3036    *_retval = false;
  3033 -  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mSchemeOrType);
  3037 -  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mSchemeOrType);
  3034 +  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromType(mSchemeOrType);
  3038 +  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromType(mSchemeOrType);
  3035    if (!mimeInfo) {
  3039    if (!mimeInfo) {
  3036      nsCAutoString ext;
  3040      nsCAutoString ext;
  3037      nsresult rv = GetPrimaryExtension(ext);
  3041      nsresult rv = GetPrimaryExtension(ext);
  3039 -      mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
  3043 -      mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
  3040 +      mimeInfo = nsCommonRegistry::GetFromExtension(ext);
  3044 +      mimeInfo = nsCommonRegistry::GetFromExtension(ext);
  3041      }
  3045      }
  3042    }
  3046    }
  3043    if (mimeInfo)
  3047    if (mimeInfo)
  3044      *_retval = PR_TRUE;
  3048      *_retval = true;
  3045  
  3049  
  3046    if (*_retval)
  3050    if (*_retval)
  3047      return NS_OK;
  3051      return NS_OK;
  3048  
  3052  
  3049 @@ -153,16 +156,33 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
  3053 @@ -153,16 +156,33 @@ nsMIMEInfoUnix::LaunchDefaultWithFile(ns
  3054    }
  3058    }
  3055    return NS_ERROR_FAILURE;
  3059    return NS_ERROR_FAILURE;
  3056  #endif
  3060  #endif
  3057  
  3061  
  3058 +  if( nsKDEUtils::kdeSupport()) {
  3062 +  if( nsKDEUtils::kdeSupport()) {
  3059 +    PRBool supports;
  3063 +    bool supports;
  3060 +    if( NS_SUCCEEDED( GetHasDefaultHandler( &supports )) && supports ) {
  3064 +    if( NS_SUCCEEDED( GetHasDefaultHandler( &supports )) && supports ) {
  3061 +      nsCStringArray command;
  3065 +      nsTArray<nsCString> command;
  3062 +      command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
  3066 +      command.AppendElement( NS_LITERAL_CSTRING( "OPEN" ));
  3063 +      command.AppendCString( nativePath );
  3067 +      command.AppendElement( nativePath );
  3064 +      command.AppendCString( NS_LITERAL_CSTRING( "MIMETYPE" ));
  3068 +      command.AppendElement( NS_LITERAL_CSTRING( "MIMETYPE" ));
  3065 +      command.AppendCString( mSchemeOrType );
  3069 +      command.AppendElement( mSchemeOrType );
  3066 +      if( nsKDEUtils::command( command ))
  3070 +      if( nsKDEUtils::command( command ))
  3067 +        return NS_OK;
  3071 +        return NS_OK;
  3068 +    }
  3072 +    }
  3069 +    if (!mDefaultApplication)
  3073 +    if (!mDefaultApplication)
  3070 +      return NS_ERROR_FILE_NOT_FOUND;
  3074 +      return NS_ERROR_FILE_NOT_FOUND;
  3123  #include "nsIFileStreams.h"
  3127  #include "nsIFileStreams.h"
  3124 @@ -1191,29 +1191,29 @@ nsresult nsOSHelperAppService::OSProtoco
  3128 @@ -1191,29 +1191,29 @@ nsresult nsOSHelperAppService::OSProtoco
  3125      ContentAction::Action::defaultActionForScheme(QString(aProtocolScheme) + ':');
  3129      ContentAction::Action::defaultActionForScheme(QString(aProtocolScheme) + ':');
  3126  
  3130  
  3127    if (action.isValid())
  3131    if (action.isValid())
  3128      *aHandlerExists = PR_TRUE;
  3132      *aHandlerExists = true;
  3129  #endif
  3133  #endif
  3130  
  3134  
  3131  #ifdef MOZ_WIDGET_GTK2
  3135  #ifdef MOZ_WIDGET_GTK2
  3132    // Check the GConf registry for a protocol handler
  3136    // Check the GConf registry for a protocol handler
  3133 -  *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
  3137 -  *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
  3154  nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformAppPath, nsIFile ** aFile)
  3158  nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformAppPath, nsIFile ** aFile)
  3155  {
  3159  {
  3156 @@ -1299,17 +1299,17 @@ nsOSHelperAppService::GetFromExtension(c
  3160 @@ -1299,17 +1299,17 @@ nsOSHelperAppService::GetFromExtension(c
  3157                                           minorType,
  3161                                           minorType,
  3158                                           mime_types_description,
  3162                                           mime_types_description,
  3159                                           PR_TRUE);
  3163                                           true);
  3160  
  3164  
  3161    if (NS_FAILED(rv) || majorType.IsEmpty()) {
  3165    if (NS_FAILED(rv) || majorType.IsEmpty()) {
  3162      
  3166      
  3163  #ifdef MOZ_WIDGET_GTK2
  3167  #ifdef MOZ_WIDGET_GTK2
  3164      LOG(("Looking in GNOME registry\n"));
  3168      LOG(("Looking in GNOME registry\n"));
  3210  INCLUDES   	+= -I$(srcdir)/../shared/x11
  3214  INCLUDES   	+= -I$(srcdir)/../shared/x11
  3211  endif
  3215  endif
  3212 diff --git a/widget/src/gtk2/nsFilePicker.cpp b/widget/src/gtk2/nsFilePicker.cpp
  3216 diff --git a/widget/src/gtk2/nsFilePicker.cpp b/widget/src/gtk2/nsFilePicker.cpp
  3213 --- a/widget/src/gtk2/nsFilePicker.cpp
  3217 --- a/widget/src/gtk2/nsFilePicker.cpp
  3214 +++ b/widget/src/gtk2/nsFilePicker.cpp
  3218 +++ b/widget/src/gtk2/nsFilePicker.cpp
  3215 @@ -31,16 +31,17 @@
  3219 @@ -33,16 +33,17 @@
  3216   * decision by deleting the provisions above and replace them with the notice
       
  3217   * and other provisions required by the GPL or the LGPL. If you do not delete
       
  3218   * the provisions above, a recipient may use your version of this file under
  3220   * the provisions above, a recipient may use your version of this file under
  3219   * the terms of any one of the MPL, the GPL or the LGPL.
  3221   * the terms of any one of the MPL, the GPL or the LGPL.
  3220   *
  3222   *
  3221   * ***** END LICENSE BLOCK ***** */
  3223   * ***** END LICENSE BLOCK ***** */
       
  3224  
       
  3225  #include "mozilla/Util.h"
  3222  
  3226  
  3223  #include <gtk/gtk.h>
  3227  #include <gtk/gtk.h>
  3224 +#include <gdk/gdkx.h>
  3228 +#include <gdk/gdkx.h>
  3225  
  3229  
  3226  #include "nsIFileURL.h"
  3230  #include "nsIFileURL.h"
  3228  #include "nsIWidget.h"
  3232  #include "nsIWidget.h"
  3229  #include "nsILocalFile.h"
  3233  #include "nsILocalFile.h"
  3230  #include "nsIStringBundle.h"
  3234  #include "nsIStringBundle.h"
  3231  
  3235  
  3232  #include "nsArrayEnumerator.h"
  3236  #include "nsArrayEnumerator.h"
  3233 @@ -49,16 +50,17 @@
  3237 @@ -51,16 +52,17 @@
  3234  #include "nsNetUtil.h"
  3238  #include "nsNetUtil.h"
  3235  #include "nsReadableUtils.h"
  3239  #include "nsReadableUtils.h"
  3236  #include "mozcontainer.h"
  3240  #include "mozcontainer.h"
  3237  
  3241  
  3238  #include "prmem.h"
  3242  #include "prmem.h"
  3243  
  3247  
  3244  #if (MOZ_PLATFORM_MAEMO == 5)
  3248  #if (MOZ_PLATFORM_MAEMO == 5)
  3245  #include <hildon-fm-2/hildon/hildon-file-chooser-dialog.h>
  3249  #include <hildon-fm-2/hildon/hildon-file-chooser-dialog.h>
  3246  #endif
  3250  #endif
  3247  
  3251  
       
  3252  using namespace mozilla;
       
  3253  
  3248  #define MAX_PREVIEW_SIZE 180
  3254  #define MAX_PREVIEW_SIZE 180
  3249  
  3255 @@ -285,17 +287,19 @@ nsFilePicker::AppendFilters(PRInt32 aFil
  3250  nsILocalFile *nsFilePicker::mPrevDisplayDirectory = nsnull;
       
  3251 @@ -281,17 +283,19 @@ nsFilePicker::AppendFilters(PRInt32 aFil
       
  3252    return nsBaseFilePicker::AppendFilters(aFilterMask);
  3256    return nsBaseFilePicker::AppendFilters(aFilterMask);
  3253  }
  3257  }
  3254  
  3258  
  3255  NS_IMETHODIMP
  3259  NS_IMETHODIMP
  3256  nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
  3260  nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
  3267    CopyUTF16toUTF8(aFilter, filter);
  3271    CopyUTF16toUTF8(aFilter, filter);
  3268    CopyUTF16toUTF8(aTitle, name);
  3272    CopyUTF16toUTF8(aTitle, name);
  3269  
  3273  
  3270    mFilters.AppendElement(filter);
  3274    mFilters.AppendElement(filter);
  3271    mFilterNames.AppendElement(name);
  3275    mFilterNames.AppendElement(name);
  3272 @@ -429,16 +433,19 @@ confirm_overwrite_file(GtkWidget *parent
  3276 @@ -433,16 +437,19 @@ confirm_overwrite_file(GtkWidget *parent
  3273    gtk_widget_destroy(dialog);
  3277    gtk_widget_destroy(dialog);
  3274  
  3278  
  3275    return result;
  3279    return result;
  3276  }
  3280  }
  3277  
  3281  
  3287    title.Adopt(ToNewUTF8String(mTitle));
  3291    title.Adopt(ToNewUTF8String(mTitle));
  3288  
  3292  
  3289    GtkWindow *parent_widget = get_gtk_window_for_nsiwidget(mParentWidget);
  3293    GtkWindow *parent_widget = get_gtk_window_for_nsiwidget(mParentWidget);
  3290  
  3294  
  3291    GtkFileChooserAction action = GetGtkFileChooserAction(mMode);
  3295    GtkFileChooserAction action = GetGtkFileChooserAction(mMode);
  3292 @@ -579,8 +586,234 @@ nsFilePicker::Show(PRInt16 *aReturn)
  3296 @@ -583,8 +590,234 @@ nsFilePicker::Show(PRInt16 *aReturn)
  3293      *aReturn = nsIFilePicker::returnCancel;
  3297      *aReturn = nsIFilePicker::returnCancel;
  3294      break;
  3298      break;
  3295    }
  3299    }
  3296  
  3300  
  3297    gtk_widget_destroy(file_chooser);
  3301    gtk_widget_destroy(file_chooser);
  3401 +            filters += "\n";
  3405 +            filters += "\n";
  3402 +            filters += kdeMakeFilter( i );
  3406 +            filters += kdeMakeFilter( i );
  3403 +            }
  3407 +            }
  3404 +        }
  3408 +        }
  3405 +
  3409 +
  3406 +    nsCStringArray command;
  3410 +    nsTArray<nsCString> command;
  3407 +    command.AppendCString( nsCAutoString( arg ));
  3411 +    command.AppendElement( nsCAutoString( arg ));
  3408 +    command.AppendCString( startdir );
  3412 +    command.AppendElement( startdir );
  3409 +    if( mMode != nsIFilePicker::modeGetFolder )
  3413 +    if( mMode != nsIFilePicker::modeGetFolder )
  3410 +        {
  3414 +        {
  3411 +        command.AppendCString( filters );
  3415 +        command.AppendElement( filters );
  3412 +        nsCAutoString selected;
  3416 +        nsCAutoString selected;
  3413 +        selected.AppendInt( mSelectedType );
  3417 +        selected.AppendInt( mSelectedType );
  3414 +        command.AppendCString( selected );
  3418 +        command.AppendElement( selected );
  3415 +        }
  3419 +        }
  3416 +    command.AppendCString( title );
  3420 +    command.AppendElement( title );
  3417 +    if( mMode == nsIFilePicker::modeOpenMultiple )
  3421 +    if( mMode == nsIFilePicker::modeOpenMultiple )
  3418 +        command.AppendCString( NS_LITERAL_CSTRING( "MULTIPLE" ));
  3422 +        command.AppendElement( NS_LITERAL_CSTRING( "MULTIPLE" ));
  3419 +    if( PRInt32 xid = windowToXid( mParentWidget ))
  3423 +    if( PRInt32 xid = windowToXid( mParentWidget ))
  3420 +        {
  3424 +        {
  3421 +        command.AppendCString( NS_LITERAL_CSTRING( "PARENT" ));
  3425 +        command.AppendElement( NS_LITERAL_CSTRING( "PARENT" ));
  3422 +        nsCAutoString parent;
  3426 +        nsCAutoString parent;
  3423 +        parent.AppendInt( xid );
  3427 +        parent.AppendInt( xid );
  3424 +        command.AppendCString( parent );
  3428 +        command.AppendElement( parent );
  3425 +        }
  3429 +        }
  3426 +
  3430 +
  3427 +    nsCStringArray output;
  3431 +    nsTArray<nsCString> output;
  3428 +    if( nsKDEUtils::commandBlockUi( command, get_gtk_window_for_nsiwidget( mParentWidget ), &output ))
  3432 +    if( nsKDEUtils::commandBlockUi( command, get_gtk_window_for_nsiwidget( mParentWidget ), &output ))
  3429 +        {
  3433 +        {
  3430 +        *aReturn = nsIFilePicker::returnOK;
  3434 +        *aReturn = nsIFilePicker::returnOK;
  3431 +        mFiles.Clear();
  3435 +        mFiles.Clear();
  3432 +        if( mMode != nsIFilePicker::modeGetFolder )
  3436 +        if( mMode != nsIFilePicker::modeGetFolder )
  3433 +            {
  3437 +            {
  3434 +            mSelectedType = atoi( output[ 0 ]->get());
  3438 +            mSelectedType = atoi( output[ 0 ].get());
  3435 +            output.RemoveCStringAt( 0 );
  3439 +            output.RemoveElementAt( 0 );
  3436 +            }
  3440 +            }
  3437 +        if (mMode == nsIFilePicker::modeOpenMultiple)
  3441 +        if (mMode == nsIFilePicker::modeOpenMultiple)
  3438 +            {
  3442 +            {
  3439 +            mFileURL.Truncate();
  3443 +            mFileURL.Truncate();
  3440 +            PRUint32 count = output.Count();
  3444 +            PRUint32 count = output.Length();
  3441 +            for( PRUint32 i = 0;
  3445 +            for( PRUint32 i = 0;
  3442 +                 i < count;
  3446 +                 i < count;
  3443 +                 ++i )
  3447 +                 ++i )
  3444 +                {
  3448 +                {
  3445 +                nsCOMPtr<nsILocalFile> localfile;
  3449 +                nsCOMPtr<nsILocalFile> localfile;
  3446 +                nsresult rv = NS_NewNativeLocalFile( *output[ i ],
  3450 +                nsresult rv = NS_NewNativeLocalFile( output[ i ],
  3447 +                                      PR_FALSE,
  3451 +                                      PR_FALSE,
  3448 +                                      getter_AddRefs(localfile));
  3452 +                                      getter_AddRefs(localfile));
  3449 +                if (NS_SUCCEEDED(rv))
  3453 +                if (NS_SUCCEEDED(rv))
  3450 +                    mFiles.AppendObject(localfile);
  3454 +                    mFiles.AppendObject(localfile);
  3451 +                }
  3455 +                }
  3452 +            }
  3456 +            }
  3453 +        else
  3457 +        else
  3454 +            {
  3458 +            {
  3455 +            if( output.Count() == 0 )
  3459 +            if( output.Length() == 0 )
  3456 +                mFileURL = nsCString();
  3460 +                mFileURL = nsCString();
  3457 +            else if( mAllowURLs )
  3461 +            else if( mAllowURLs )
  3458 +                mFileURL = *output[ 0 ];
  3462 +                mFileURL = output[ 0 ];
  3459 +            else // GetFile() actually requires it to be url even for local files :-/
  3463 +            else // GetFile() actually requires it to be url even for local files :-/
  3460 +                {
  3464 +                {
  3461 +                mFileURL = nsCString( "file://" );
  3465 +                mFileURL = nsCString( "file://" );
  3462 +                mFileURL.Append( *output[ 0 ] );
  3466 +                mFileURL.Append( output[ 0 ] );
  3463 +                }
  3467 +                }
  3464 +            }
  3468 +            }
  3465 +  // Remember last used directory.
  3469 +  // Remember last used directory.
  3466 +  nsCOMPtr<nsILocalFile> file;
  3470 +  nsCOMPtr<nsILocalFile> file;
  3467 +  GetFile(getter_AddRefs(file));
  3471 +  GetFile(getter_AddRefs(file));
  3477 +            {
  3481 +            {
  3478 +            nsCOMPtr<nsILocalFile> file;
  3482 +            nsCOMPtr<nsILocalFile> file;
  3479 +            GetFile(getter_AddRefs(file));
  3483 +            GetFile(getter_AddRefs(file));
  3480 +            if (file)
  3484 +            if (file)
  3481 +                {
  3485 +                {
  3482 +                PRBool exists = PR_FALSE;
  3486 +                bool exists = false;
  3483 +                file->Exists(&exists);
  3487 +                file->Exists(&exists);
  3484 +                if (exists) // TODO do overwrite check in the helper app
  3488 +                if (exists) // TODO do overwrite check in the helper app
  3485 +                    *aReturn = nsIFilePicker::returnReplace;
  3489 +                    *aReturn = nsIFilePicker::returnReplace;
  3486 +                }
  3490 +                }
  3487 +            }
  3491 +            }
  3499 +    NS_ENSURE_ARG_POINTER(aReturn);
  3503 +    NS_ENSURE_ARG_POINTER(aReturn);
  3500 +
  3504 +
  3501 +    nsXPIDLCString title;
  3505 +    nsXPIDLCString title;
  3502 +    title.Adopt(ToNewUTF8String(mTitle));
  3506 +    title.Adopt(ToNewUTF8String(mTitle));
  3503 +
  3507 +
  3504 +    nsCStringArray command;
  3508 +    nsTArray<nsCString> command;
  3505 +    command.AppendCString( NS_LITERAL_CSTRING( "APPSDIALOG" ));
  3509 +    command.AppendElement( NS_LITERAL_CSTRING( "APPSDIALOG" ));
  3506 +    command.AppendCString( title );
  3510 +    command.AppendElement( title );
  3507 +    if( PRInt32 xid = windowToXid( mParentWidget ))
  3511 +    if( PRInt32 xid = windowToXid( mParentWidget ))
  3508 +        {
  3512 +        {
  3509 +        command.AppendCString( NS_LITERAL_CSTRING( "PARENT" ));
  3513 +        command.AppendElement( NS_LITERAL_CSTRING( "PARENT" ));
  3510 +        nsCAutoString parent;
  3514 +        nsCAutoString parent;
  3511 +        parent.AppendInt( xid );
  3515 +        parent.AppendInt( xid );
  3512 +        command.AppendCString( parent );
  3516 +        command.AppendElement( parent );
  3513 +        }
  3517 +        }
  3514 +
  3518 +
  3515 +    nsCStringArray output;
  3519 +    nsTArray<nsCString> output;
  3516 +    if( nsKDEUtils::commandBlockUi( command, get_gtk_window_for_nsiwidget( mParentWidget ), &output ))
  3520 +    if( nsKDEUtils::commandBlockUi( command, get_gtk_window_for_nsiwidget( mParentWidget ), &output ))
  3517 +        {
  3521 +        {
  3518 +        *aReturn = nsIFilePicker::returnOK;
  3522 +        *aReturn = nsIFilePicker::returnOK;
  3519 +        mFileURL = output.Count() > 0 ? *output[ 0 ] : nsCString();
  3523 +        mFileURL = output.Length() > 0 ? output[ 0 ] : nsCString();
  3520 +        }
  3524 +        }
  3521 +    else
  3525 +    else
  3522 +        {
  3526 +        {
  3523 +        *aReturn = nsIFilePicker::returnCancel;
  3527 +        *aReturn = nsIFilePicker::returnCancel;
  3524 +        }
  3528 +        }
  3561  CXXFLAGS += $(MOZ_GTK2_CFLAGS)
  3565  CXXFLAGS += $(MOZ_GTK2_CFLAGS)
  3562  endif
  3566  endif
  3563 diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp
  3567 diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp
  3564 --- a/xpcom/components/ManifestParser.cpp
  3568 --- a/xpcom/components/ManifestParser.cpp
  3565 +++ b/xpcom/components/ManifestParser.cpp
  3569 +++ b/xpcom/components/ManifestParser.cpp
  3566 @@ -60,16 +60,17 @@
  3570 @@ -62,16 +62,17 @@
  3567  #include "nsTextFormatter.h"
  3571  #include "nsTextFormatter.h"
  3568  #include "nsVersionComparator.h"
  3572  #include "nsVersionComparator.h"
  3569  #include "nsXPCOMCIDInternal.h"
  3573  #include "nsXPCOMCIDInternal.h"
  3570  
  3574  
  3571  #include "nsIConsoleService.h"
  3575  #include "nsIConsoleService.h"
  3572  #include "nsIScriptError.h"
  3576  #include "nsIScriptError.h"
  3573  #include "nsIXULAppInfo.h"
  3577  #include "nsIXULAppInfo.h"
  3574  #include "nsIXULRuntime.h"
  3578  #include "nsIXULRuntime.h"
  3575 +#include "nsKDEUtils.h"
  3579 +#include "nsKDEUtils.h"
  3576  
  3580  
       
  3581  using namespace mozilla;
       
  3582  
  3577  struct ManifestDirective
  3583  struct ManifestDirective
  3578  {
  3584  {
  3579    const char* directive;
  3585    const char* directive;
  3580    int argc;
  3586    int argc;
  3581  
  3587  
  3582    // Some directives should only be delivered for NS_COMPONENT_LOCATION
  3588 @@ -434,16 +435,17 @@ ParseManifestCommon(NSLocationType aType
  3583    // manifests.
       
  3584 @@ -430,16 +431,17 @@ ParseManifestCommon(NSLocationType aType
       
  3585    NS_NAMED_LITERAL_STRING(kPlatform, "platform");
  3589    NS_NAMED_LITERAL_STRING(kPlatform, "platform");
  3586    NS_NAMED_LITERAL_STRING(kContentAccessible, "contentaccessible");
  3590    NS_NAMED_LITERAL_STRING(kContentAccessible, "contentaccessible");
  3587    NS_NAMED_LITERAL_STRING(kApplication, "application");
  3591    NS_NAMED_LITERAL_STRING(kApplication, "application");
  3588    NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
  3592    NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
  3589    NS_NAMED_LITERAL_STRING(kGeckoVersion, "platformversion");
  3593    NS_NAMED_LITERAL_STRING(kGeckoVersion, "platformversion");
  3597  
  3601  
  3598    nsAutoString appID;
  3602    nsAutoString appID;
  3599    nsAutoString appVersion;
  3603    nsAutoString appVersion;
  3600    nsAutoString geckoVersion;
  3604    nsAutoString geckoVersion;
  3601    nsAutoString osTarget;
  3605    nsAutoString osTarget;
  3602 @@ -474,39 +476,44 @@ ParseManifestCommon(NSLocationType aType
  3606 @@ -478,39 +480,44 @@ ParseManifestCommon(NSLocationType aType
  3603          CopyUTF8toUTF16(s, abi);
  3607          CopyUTF8toUTF16(s, abi);
  3604          abi.Insert(PRUnichar('_'), 0);
  3608          abi.Insert(PRUnichar('_'), 0);
  3605          abi.Insert(osTarget, 0);
  3609          abi.Insert(osTarget, 0);
  3606        }
  3610        }
  3607      }
  3611      }
  3642    // at the end.
  3646    // at the end.
  3643    nsTArray<CachedDirective> contracts;
  3647    nsTArray<CachedDirective> contracts;
  3644  
  3648  
  3645    char *token;
  3649    char *token;
  3646    char *newline = buf;
  3650    char *newline = buf;
  3647 @@ -585,24 +592,26 @@ ParseManifestCommon(NSLocationType aType
  3651 @@ -589,24 +596,26 @@ ParseManifestCommon(NSLocationType aType
  3648      TriState stAppVersion = eUnspecified;
  3652      TriState stAppVersion = eUnspecified;
  3649      TriState stGeckoVersion = eUnspecified;
  3653      TriState stGeckoVersion = eUnspecified;
  3650      TriState stApp = eUnspecified;
  3654      TriState stApp = eUnspecified;
  3651      TriState stOsVersion = eUnspecified;
  3655      TriState stOsVersion = eUnspecified;
  3652      TriState stOs = eUnspecified;
  3656      TriState stOs = eUnspecified;
  3669          continue;
  3673          continue;
  3670  
  3674  
  3671        if (directive->contentflags &&
  3675        if (directive->contentflags &&
  3672            (CheckFlag(kPlatform, wtoken, platform) ||
  3676            (CheckFlag(kPlatform, wtoken, platform) ||
  3673             CheckFlag(kContentAccessible, wtoken, contentAccessible)))
  3677             CheckFlag(kContentAccessible, wtoken, contentAccessible)))
  3674 @@ -623,16 +632,17 @@ ParseManifestCommon(NSLocationType aType
  3678 @@ -627,16 +636,17 @@ ParseManifestCommon(NSLocationType aType
  3675      }
  3679      }
  3676  
  3680  
  3677      if (!ok ||
  3681      if (!ok ||
  3678          stApp == eBad ||
  3682          stApp == eBad ||
  3679          stAppVersion == eBad ||
  3683          stAppVersion == eBad ||
  3712  ifdef MOZ_PLATFORM_MAEMO
  3716  ifdef MOZ_PLATFORM_MAEMO
  3713  CFLAGS          += $(MOZ_PLATFORM_MAEMO_CFLAGS) $(MOZ_QT_CFLAGS)
  3717  CFLAGS          += $(MOZ_PLATFORM_MAEMO_CFLAGS) $(MOZ_QT_CFLAGS)
  3714 diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp
  3718 diff --git a/xpcom/io/nsLocalFileUnix.cpp b/xpcom/io/nsLocalFileUnix.cpp
  3715 --- a/xpcom/io/nsLocalFileUnix.cpp
  3719 --- a/xpcom/io/nsLocalFileUnix.cpp
  3716 +++ b/xpcom/io/nsLocalFileUnix.cpp
  3720 +++ b/xpcom/io/nsLocalFileUnix.cpp
  3717 @@ -87,16 +87,17 @@
  3721 @@ -90,16 +90,17 @@
  3718  #include "nsXPIDLString.h"
       
  3719  #include "prproces.h"
  3722  #include "prproces.h"
  3720  #include "nsIDirectoryEnumerator.h"
  3723  #include "nsIDirectoryEnumerator.h"
  3721  #include "nsISimpleEnumerator.h"
  3724  #include "nsISimpleEnumerator.h"
       
  3725  #include "private/pprio.h"
  3722  
  3726  
  3723  #ifdef MOZ_WIDGET_GTK2
  3727  #ifdef MOZ_WIDGET_GTK2
  3724  #include "nsIGIOService.h"
  3728  #include "nsIGIOService.h"
  3725  #include "nsIGnomeVFSService.h"
  3729  #include "nsIGnomeVFSService.h"
  3726 +#include "nsKDEUtils.h"
  3730 +#include "nsKDEUtils.h"
  3727  #endif
  3731  #endif
  3728  
  3732  
  3729  #ifdef XP_MACOSX
  3733  #ifdef MOZ_WIDGET_COCOA
  3730  #include <Carbon/Carbon.h>
  3734  #include <Carbon/Carbon.h>
  3731  #include "CocoaFileUtils.h"
  3735  #include "CocoaFileUtils.h"
  3732  #include "prmem.h"
  3736  #include "prmem.h"
  3733  #include "plbase64.h"
  3737  #include "plbase64.h"
  3734  
  3738  
  3735 @@ -1785,44 +1786,50 @@ nsLocalFile::SetPersistentDescriptor(con
  3739 @@ -1795,44 +1796,51 @@ nsLocalFile::SetPersistentDescriptor(con
  3736      return InitWithNativePath(aPersistentDescriptor);
  3740      return InitWithNativePath(aPersistentDescriptor);
  3737  #endif
  3741  #endif
  3738  }
  3742  }
  3739  
  3743  
  3740  NS_IMETHODIMP
  3744  NS_IMETHODIMP
  3745 -    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
  3749 -    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
  3746 -    if (!giovfs && !gnomevfs)
  3750 -    if (!giovfs && !gnomevfs)
  3747 -        return NS_ERROR_FAILURE;
  3751 -        return NS_ERROR_FAILURE;
  3748 -
  3752 -
  3749 +    nsCAutoString url;
  3753 +    nsCAutoString url;
  3750      PRBool isDirectory;
  3754      bool isDirectory;
  3751      if (NS_FAILED(IsDirectory(&isDirectory)))
  3755      if (NS_FAILED(IsDirectory(&isDirectory)))
  3752          return NS_ERROR_FAILURE;
  3756          return NS_ERROR_FAILURE;
  3753  
  3757  
  3754      if (isDirectory) {
  3758      if (isDirectory) {
  3755 -        if (giovfs)
  3759 -        if (giovfs)
  3772 -            return gnomevfs->ShowURIForInput(dirPath);        
  3776 -            return gnomevfs->ShowURIForInput(dirPath);        
  3773 +        url = dirPath;
  3777 +        url = dirPath;
  3774      }
  3778      }
  3775 +
  3779 +
  3776 +    if(nsKDEUtils::kdeSupport()) {
  3780 +    if(nsKDEUtils::kdeSupport()) {
  3777 +      nsCStringArray command;
  3781 +      nsTArray<nsCString> command;
  3778 +      command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
  3782 +      command.AppendElement( NS_LITERAL_CSTRING("OPEN") );
  3779 +      command.AppendCString( url );
  3783 +      command.AppendElement( url );
  3780 +      return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  3784 +      return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  3781 +    }
  3785 +    }
  3782 +
  3786 +
  3783 +    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  3787 +    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  3784 +    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
  3788 +    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
  3787 +
  3791 +
  3788 +    if (giovfs)
  3792 +    if (giovfs)
  3789 +      return giovfs->ShowURIForInput(url);
  3793 +      return giovfs->ShowURIForInput(url);
  3790 +    else
  3794 +    else
  3791 +      return gnomevfs->ShowURIForInput(url);
  3795 +      return gnomevfs->ShowURIForInput(url);
  3792  #elif defined(XP_MACOSX)
  3796 +
       
  3797  #elif defined(MOZ_WIDGET_COCOA)
  3793      CFURLRef url;
  3798      CFURLRef url;
  3794      if (NS_SUCCEEDED(GetCFURL(&url))) {
  3799      if (NS_SUCCEEDED(GetCFURL(&url))) {
  3795        nsresult rv = CocoaFileUtils::RevealFileInFinder(url);
  3800        nsresult rv = CocoaFileUtils::RevealFileInFinder(url);
  3796        ::CFRelease(url);
  3801        ::CFRelease(url);
  3797        return rv;
  3802        return rv;
  3798      }
  3803      }
  3799      return NS_ERROR_FAILURE;
  3804      return NS_ERROR_FAILURE;
  3800 @@ -1848,16 +1855,23 @@ nsLocalFile::Launch()
  3805 @@ -1858,16 +1866,23 @@ nsLocalFile::Launch()
  3801  
  3806  
  3802      if (nsnull == connection)
  3807      if (nsnull == connection)
  3803        return NS_ERROR_FAILURE;
  3808        return NS_ERROR_FAILURE;
  3804  
  3809  
  3805      if (hildon_mime_open_file(connection, mPath.get()) != kHILDON_SUCCESS)
  3810      if (hildon_mime_open_file(connection, mPath.get()) != kHILDON_SUCCESS)
  3806        return NS_ERROR_FAILURE;
  3811        return NS_ERROR_FAILURE;
  3807      return NS_OK;
  3812      return NS_OK;
  3808  #else
  3813  #else
  3809 +    if( nsKDEUtils::kdeSupport()) {
  3814 +    if( nsKDEUtils::kdeSupport()) {
  3810 +      nsCStringArray command;
  3815 +      nsTArray<nsCString> command;
  3811 +      command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
  3816 +      command.AppendElement( NS_LITERAL_CSTRING("OPEN") );
  3812 +      command.AppendCString( mPath );
  3817 +      command.AppendElement( mPath );
  3813 +      return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  3818 +      return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  3814 +    }
  3819 +    }
  3815 +
  3820 +
  3816      nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  3821      nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  3817      nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
  3822      nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);