mozilla-kde.patch
changeset 398 937669e1c537
parent 368 8891dd9439a1
child 399 20f8b5f0aea6
equal deleted inserted replaced
395:492d540dd2ac 398:937669e1c537
       
     1 Description: Add KDE integration to Firefox (toolkit parts)
       
     2 Author: Wolfgang Rosenauer <wolfgang@rosenauer.org>
       
     3 Author: Lubos Lunak <lunak@suse.com>
       
     4 Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=140751
       
     5      https://bugzilla.novell.com/show_bug.cgi?id=170055
       
     6 
     1 diff --git a/modules/libpref/src/Makefile.in b/modules/libpref/src/Makefile.in
     7 diff --git a/modules/libpref/src/Makefile.in b/modules/libpref/src/Makefile.in
     2 --- a/modules/libpref/src/Makefile.in
     8 --- a/modules/libpref/src/Makefile.in
     3 +++ b/modules/libpref/src/Makefile.in
     9 +++ b/modules/libpref/src/Makefile.in
     4 @@ -77,14 +77,16 @@ GREPREF_FILES = $(topsrcdir)/netwerk/bas
    10 @@ -77,14 +77,16 @@ GREPREF_FILES = $(topsrcdir)/netwerk/bas
     5  # Optimizer bug with GCC 3.2.2 on OS/2
    11  # Optimizer bug with GCC 3.2.2 on OS/2
  2169 +  }
  2175 +  }
  2170 +  nsTArray<nsCString> command;
  2176 +  nsTArray<nsCString> command;
  2171 +  command.AppendElement( NS_LITERAL_CSTRING( "GETPROXY" ));
  2177 +  command.AppendElement( NS_LITERAL_CSTRING( "GETPROXY" ));
  2172 +  command.AppendElement( url );
  2178 +  command.AppendElement( url );
  2173 +  nsTArray<nsCString> result;
  2179 +  nsTArray<nsCString> result;
  2174 +  if( !nsKDEUtils::command( command, &result ) || result.Count() != 1 )
  2180 +  if( !nsKDEUtils::command( command, &result ) || result.Length() != 1 )
  2175 +    return NS_ERROR_FAILURE;
  2181 +    return NS_ERROR_FAILURE;
  2176 +  aResult = *result[ 0 ];
  2182 +  aResult = result[0];
  2177 +  return NS_OK;
  2183 +  return NS_OK;
  2178 +}
  2184 +}
  2179 +
  2185 +
  2180 diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in
  2186 diff --git a/toolkit/xre/Makefile.in b/toolkit/xre/Makefile.in
  2181 --- a/toolkit/xre/Makefile.in
  2187 --- a/toolkit/xre/Makefile.in
  2202  else
  2208  else
  2203 diff --git a/toolkit/xre/nsKDEUtils.cpp b/toolkit/xre/nsKDEUtils.cpp
  2209 diff --git a/toolkit/xre/nsKDEUtils.cpp b/toolkit/xre/nsKDEUtils.cpp
  2204 new file mode 100644
  2210 new file mode 100644
  2205 --- /dev/null
  2211 --- /dev/null
  2206 +++ b/toolkit/xre/nsKDEUtils.cpp
  2212 +++ b/toolkit/xre/nsKDEUtils.cpp
  2207 @@ -0,0 +1,330 @@
  2213 @@ -0,0 +1,372 @@
  2208 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2214 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2209 +/* ***** BEGIN LICENSE BLOCK *****
  2215 +/* ***** BEGIN LICENSE BLOCK *****
  2210 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2216 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2211 + *
  2217 + *
  2212 + * The contents of this file are subject to the Mozilla Public License Version
  2218 + * The contents of this file are subject to the Mozilla Public License Version
  2242 + *
  2248 + *
  2243 + * ***** END LICENSE BLOCK ***** */
  2249 + * ***** END LICENSE BLOCK ***** */
  2244 +
  2250 +
  2245 +#include "nsKDEUtils.h"
  2251 +#include "nsKDEUtils.h"
  2246 +#include "nsIWidget.h"
  2252 +#include "nsIWidget.h"
       
  2253 +#include "nsISupportsPrimitives.h"
       
  2254 +#include "nsIMutableArray.h"
       
  2255 +#include "nsComponentManagerUtils.h"
       
  2256 +#include "nsArrayUtils.h"
  2247 +
  2257 +
  2248 +#include <gtk/gtk.h>
  2258 +#include <gtk/gtk.h>
  2249 +
  2259 +
  2250 +#include <limits.h>
  2260 +#include <limits.h>
  2251 +#include <stdio.h>
  2261 +#include <stdio.h>
  2300 +static bool getKdeSupport()
  2310 +static bool getKdeSupport()
  2301 +    {
  2311 +    {
  2302 +    nsTArray<nsCString> command;
  2312 +    nsTArray<nsCString> command;
  2303 +    command.AppendElement( NS_LITERAL_CSTRING( "CHECK" ));
  2313 +    command.AppendElement( NS_LITERAL_CSTRING( "CHECK" ));
  2304 +    command.AppendElement( NS_LITERAL_CSTRING( MAKE_STR( KMOZILLAHELPER_VERSION )));
  2314 +    command.AppendElement( NS_LITERAL_CSTRING( MAKE_STR( KMOZILLAHELPER_VERSION )));
  2305 +    bool kde = nsKDEUtils::command( command.get() );
  2315 +    bool kde = nsKDEUtils::command( command );
  2306 +#ifdef DEBUG_KDE
  2316 +#ifdef DEBUG_KDE
  2307 +    fprintf( stderr, "KDE RUNNING %d\n", kde );
  2317 +    fprintf( stderr, "KDE RUNNING %d\n", kde );
  2308 +#endif
  2318 +#endif
  2309 +    return kde;
  2319 +    return kde;
  2310 +    }
  2320 +    }
  2393 +bool nsKDEUtils::command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output )
  2403 +bool nsKDEUtils::command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output )
  2394 +    {
  2404 +    {
  2395 +    return self()->internalCommand( command, NULL, false, output );
  2405 +    return self()->internalCommand( command, NULL, false, output );
  2396 +    }
  2406 +    }
  2397 +
  2407 +
       
  2408 +bool nsKDEUtils::command( nsIArray* command, nsIArray** output)
       
  2409 +    {
       
  2410 +    NS_ENSURE_ARG( command );
       
  2411 +
       
  2412 +    nsTArray<nsCString> in;
       
  2413 +    PRUint32 length;
       
  2414 +    command->GetLength( &length );
       
  2415 +    for ( PRUint32 i = 0; i < length; i++ )
       
  2416 +        {
       
  2417 +        nsCOMPtr<nsISupportsCString> str = do_QueryElementAt( command, i );
       
  2418 +        if( str )
       
  2419 +            {
       
  2420 +            nsCAutoString s;
       
  2421 +            str->GetData( s );
       
  2422 +            in.AppendElement( s );
       
  2423 +            }
       
  2424 +        }
       
  2425 +
       
  2426 +    nsTArray<nsCString> out;
       
  2427 +    bool ret = self()->internalCommand( in, NULL, false, &out );
       
  2428 +
       
  2429 +    if ( !output ) return ret;
       
  2430 +
       
  2431 +    nsCOMPtr<nsIMutableArray> result = do_CreateInstance( NS_ARRAY_CONTRACTID );
       
  2432 +    if ( !result ) return false;
       
  2433 +
       
  2434 +    for ( PRUint32 i = 0; i < out.Length(); i++ )
       
  2435 +        {
       
  2436 +        nsCOMPtr<nsISupportsCString> rstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
       
  2437 +        if ( !rstr ) return false;
       
  2438 +
       
  2439 +        rstr->SetData( out[i] );
       
  2440 +        result->AppendElement( rstr, false );
       
  2441 +        }
       
  2442 +
       
  2443 +    NS_ADDREF( *output = result);
       
  2444 +    return ret;
       
  2445 +    }
       
  2446 +
       
  2447 +
  2398 +bool nsKDEUtils::commandBlockUi( const nsTArray<nsCString>& command, const GtkWindow* parent, nsTArray<nsCString>* output )
  2448 +bool nsKDEUtils::commandBlockUi( const nsTArray<nsCString>& command, const GtkWindow* parent, nsTArray<nsCString>* output )
  2399 +    {
  2449 +    {
  2400 +    return self()->internalCommand( command, parent, true, output );
  2450 +    return self()->internalCommand( command, parent, true, output );
  2401 +    }
  2451 +    }
  2402 +
  2452 +
  2403 +bool nsKDEUtils::internalCommand( const nsTArray<nsCString>& command, const GtkWindow* parent, bool blockUi,
  2453 +bool nsKDEUtils::internalCommand( const nsTArray<nsCString>& command, const GtkWindow* parent, bool blockUi,
  2404 +    nsTArray<nsCString>* output )
  2454 +    nsTArray<nsCString>* output )
  2405 +    {
  2455 +    {
  2406 +    nsCString internal_command;
       
  2407 +    internal_command.AssignLiteral(command);
       
  2408 +    if( !startHelper())
  2456 +    if( !startHelper())
  2409 +        return false;
  2457 +        return false;
  2410 +    feedCommand(internal_command);
  2458 +    feedCommand( command );
  2411 +    // do not store the data in 'this' but in extra structure, just in case there
  2459 +    // do not store the data in 'this' but in extra structure, just in case there
  2412 +    // is reentrancy (can there be? the event loop is re-entered)
  2460 +    // is reentrancy (can there be? the event loop is re-entered)
  2413 +    nsKDECommandData data;
  2461 +    nsKDECommandData data;
  2414 +    data.file = replyFile;
  2462 +    data.file = replyFile;
  2415 +    data.output = output;
  2463 +    data.output = output;
  2537 +    }
  2585 +    }
  2538 diff --git a/toolkit/xre/nsKDEUtils.h b/toolkit/xre/nsKDEUtils.h
  2586 diff --git a/toolkit/xre/nsKDEUtils.h b/toolkit/xre/nsKDEUtils.h
  2539 new file mode 100644
  2587 new file mode 100644
  2540 --- /dev/null
  2588 --- /dev/null
  2541 +++ b/toolkit/xre/nsKDEUtils.h
  2589 +++ b/toolkit/xre/nsKDEUtils.h
  2542 @@ -0,0 +1,78 @@
  2590 @@ -0,0 +1,81 @@
  2543 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2591 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2544 + *
  2592 + *
  2545 + * ***** BEGIN LICENSE BLOCK *****
  2593 + * ***** BEGIN LICENSE BLOCK *****
  2546 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2594 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  2547 + *
  2595 + *
  2584 +#include "nsStringGlue.h"
  2632 +#include "nsStringGlue.h"
  2585 +#include "nsTArray.h"
  2633 +#include "nsTArray.h"
  2586 +#include <stdio.h>
  2634 +#include <stdio.h>
  2587 +
  2635 +
  2588 +typedef struct _GtkWindow GtkWindow;
  2636 +typedef struct _GtkWindow GtkWindow;
       
  2637 +
       
  2638 +class nsIArray;
  2589 +
  2639 +
  2590 +class NS_EXPORT nsKDEUtils
  2640 +class NS_EXPORT nsKDEUtils
  2591 +    {
  2641 +    {
  2592 +    public:
  2642 +    public:
  2593 +        /* Returns true if running inside a KDE session (regardless of whether there is KDE
  2643 +        /* Returns true if running inside a KDE session (regardless of whether there is KDE
  2597 +        /* Returns true if running inside a KDE session and KDE support is available
  2647 +        /* Returns true if running inside a KDE session and KDE support is available
  2598 +           for Firefox. This should be used everywhere where the external helper is needed. */
  2648 +           for Firefox. This should be used everywhere where the external helper is needed. */
  2599 +        static bool kdeSupport();
  2649 +        static bool kdeSupport();
  2600 +        /* Executes the given helper command, returns true if helper returned success. */
  2650 +        /* Executes the given helper command, returns true if helper returned success. */
  2601 +        static bool command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output = NULL );
  2651 +        static bool command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output = NULL );
       
  2652 +        static bool command( nsIArray* command, nsIArray** output = NULL );
  2602 +        /* Like command(), but additionally blocks the parent widget like if there was
  2653 +        /* Like command(), but additionally blocks the parent widget like if there was
  2603 +           a modal dialog shown and enters the event loop (i.e. there are still paint updates,
  2654 +           a modal dialog shown and enters the event loop (i.e. there are still paint updates,
  2604 +           this is for commands that take long). */
  2655 +           this is for commands that take long). */
  2605 +        static bool commandBlockUi( const nsTArray<nsCString>& command, const GtkWindow* parent, nsTArray<nsCString>* output = NULL );
  2656 +        static bool commandBlockUi( const nsTArray<nsCString>& command, const GtkWindow* parent, nsTArray<nsCString>* output = NULL );
  2606 +
  2657 +