|
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 |
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; |
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 + |