firefox-kde.patch
changeset 398 937669e1c537
parent 367 3fabd9f66322
child 399 20f8b5f0aea6
equal deleted inserted replaced
395:492d540dd2ac 398:937669e1c537
  1268  
  1268  
  1269 diff --git a/browser/components/shell/src/nsKDEShellService.cpp b/browser/components/shell/src/nsKDEShellService.cpp
  1269 diff --git a/browser/components/shell/src/nsKDEShellService.cpp b/browser/components/shell/src/nsKDEShellService.cpp
  1270 new file mode 100644
  1270 new file mode 100644
  1271 --- /dev/null
  1271 --- /dev/null
  1272 +++ b/browser/components/shell/src/nsKDEShellService.cpp
  1272 +++ b/browser/components/shell/src/nsKDEShellService.cpp
  1273 @@ -0,0 +1,193 @@
  1273 @@ -0,0 +1,257 @@
  1274 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  1274 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  1275 +/* ***** BEGIN LICENSE BLOCK *****
  1275 +/* ***** BEGIN LICENSE BLOCK *****
  1276 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  1276 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  1277 + *
  1277 + *
  1278 + * The contents of this file are subject to the Mozilla Public License Version
  1278 + * The contents of this file are subject to the Mozilla Public License Version
  1314 +#include "nsIPrefService.h"
  1314 +#include "nsIPrefService.h"
  1315 +#include "nsIProcess.h"
  1315 +#include "nsIProcess.h"
  1316 +#include "nsILocalFile.h"
  1316 +#include "nsILocalFile.h"
  1317 +#include "nsServiceManagerUtils.h"
  1317 +#include "nsServiceManagerUtils.h"
  1318 +#include "nsComponentManagerUtils.h"
  1318 +#include "nsComponentManagerUtils.h"
       
  1319 +#include "nsIMutableArray.h"
       
  1320 +#include "nsISupportsPrimitives.h"
       
  1321 +#include "nsArrayUtils.h"
  1319 +
  1322 +
  1320 +nsresult
  1323 +nsresult
  1321 +nsKDEShellService::Init()
  1324 +nsKDEShellService::Init()
  1322 +    {
  1325 +    {
  1323 +    if( !nsKDEUtils::kdeSupport())
  1326 +    if( !nsKDEUtils::kdeSupport())
  1329 +
  1332 +
  1330 +NS_IMETHODIMP
  1333 +NS_IMETHODIMP
  1331 +nsKDEShellService::IsDefaultBrowser(bool aStartupCheck,
  1334 +nsKDEShellService::IsDefaultBrowser(bool aStartupCheck,
  1332 +                                    bool* aIsDefaultBrowser)
  1335 +                                    bool* aIsDefaultBrowser)
  1333 +    {
  1336 +    {
  1334 +    *aIsDefaultBrowser = PR_FALSE;
  1337 +    *aIsDefaultBrowser = false;
  1335 +    if (aStartupCheck)
  1338 +    if (aStartupCheck)
  1336 +        mCheckedThisSession = PR_TRUE;
  1339 +        mCheckedThisSession = true;
  1337 +    nsTArray<nsCString> command;
  1340 +
  1338 +    command.AppendElement( NS_LITERAL_CSTRING( "ISDEFAULTBROWSER" ));
  1341 +    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
       
  1342 +    if (!command)
       
  1343 +        return NS_ERROR_FAILURE;
       
  1344 +
       
  1345 +    nsCOMPtr<nsISupportsCString> str = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
       
  1346 +    if (!str)
       
  1347 +        return NS_ERROR_FAILURE;
       
  1348 +
       
  1349 +    str->SetData( NS_LITERAL_CSTRING( "ISDEFAULTBROWSER" ));
       
  1350 +    command->AppendElement( str, false );
       
  1351 +
  1339 +    if( nsKDEUtils::command( command ))
  1352 +    if( nsKDEUtils::command( command ))
  1340 +        *aIsDefaultBrowser = PR_TRUE;
  1353 +        *aIsDefaultBrowser = true;
  1341 +    return NS_OK;
  1354 +    return NS_OK;
  1342 +    }
  1355 +    }
  1343 +
  1356 +
  1344 +NS_IMETHODIMP
  1357 +NS_IMETHODIMP
  1345 +nsKDEShellService::SetDefaultBrowser(bool aClaimAllTypes,
  1358 +nsKDEShellService::SetDefaultBrowser(bool aClaimAllTypes,
  1346 +                                     bool aForAllUsers)
  1359 +                                     bool aForAllUsers)
  1347 +    {
  1360 +    {
  1348 +    nsTArray<nsCString> command;
  1361 +    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
  1349 +    command.AppendElement( NS_LITERAL_CSTRING( "SETDEFAULTBROWSER" ));
  1362 +    if (!command)
  1350 +    command.AppendElement( aClaimAllTypes ? NS_LITERAL_CSTRING( "ALLTYPES" ) : NS_LITERAL_CSTRING( "NORMAL" ));
  1363 +        return NS_ERROR_FAILURE;
       
  1364 +
       
  1365 +    nsCOMPtr<nsISupportsCString> cmdstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
       
  1366 +    nsCOMPtr<nsISupportsCString> paramstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
       
  1367 +    if (!cmdstr || !paramstr)
       
  1368 +        return NS_ERROR_FAILURE;
       
  1369 +
       
  1370 +    cmdstr->SetData( NS_LITERAL_CSTRING( "SETDEFAULTBROWSER" ));
       
  1371 +    command->AppendElement( cmdstr, false );
       
  1372 +
       
  1373 +    paramstr->SetData( aClaimAllTypes ? NS_LITERAL_CSTRING( "ALLTYPES" ) : NS_LITERAL_CSTRING( "NORMAL" ));
       
  1374 +    command->AppendElement( paramstr, false );
       
  1375 +
  1351 +    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  1376 +    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  1352 +    }
  1377 +    }
  1353 +
  1378 +
  1354 +NS_IMETHODIMP
  1379 +NS_IMETHODIMP
  1355 +nsKDEShellService::GetShouldCheckDefaultBrowser(bool* aResult)
  1380 +nsKDEShellService::GetShouldCheckDefaultBrowser(bool* aResult)
  1356 +{
  1381 +{
  1357 +  // If we've already checked, the browser has been started and this is a
  1382 +  // If we've already checked, the browser has been started and this is a
  1358 +  // new window open, and we don't want to check again.
  1383 +  // new window open, and we don't want to check again.
  1359 +  if (mCheckedThisSession) {
  1384 +  if (mCheckedThisSession) {
  1360 +    *aResult = PR_FALSE;
  1385 +    *aResult = false;
  1361 +    return NS_OK;
  1386 +    return NS_OK;
  1362 +  }
  1387 +  }
  1363 +
  1388 +
  1364 +  nsCOMPtr<nsIPrefBranch> prefs;
  1389 +  nsCOMPtr<nsIPrefBranch> prefs;
  1365 +  nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
  1390 +  nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
  1385 +
  1410 +
  1386 +  return NS_OK;
  1411 +  return NS_OK;
  1387 +}
  1412 +}
  1388 +
  1413 +
  1389 +NS_IMETHODIMP
  1414 +NS_IMETHODIMP
  1390 +nsKDEShellService::SetDesktopBackground(nsIDOMElement* aElement, 
  1415 +nsKDEShellService::SetDesktopBackground(nsIDOMElement* aElement,
  1391 +                                          PRInt32 aPosition)
  1416 +                                          PRInt32 aPosition)
  1392 +    {
  1417 +    {
  1393 +    return NS_ERROR_NOT_IMPLEMENTED;
  1418 +    return NS_ERROR_NOT_IMPLEMENTED;
  1394 +    }
  1419 +    }
  1395 +
  1420 +
  1406 +    }
  1431 +    }
  1407 +
  1432 +
  1408 +NS_IMETHODIMP
  1433 +NS_IMETHODIMP
  1409 +nsKDEShellService::OpenApplication(PRInt32 aApplication)
  1434 +nsKDEShellService::OpenApplication(PRInt32 aApplication)
  1410 +    {
  1435 +    {
  1411 +    nsTArray<nsCString> command;
  1436 +    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
       
  1437 +    if (!command)
       
  1438 +        return NS_ERROR_FAILURE;
       
  1439 +
       
  1440 +    nsCOMPtr<nsISupportsCString> str = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
       
  1441 +    if (!str)
       
  1442 +        return NS_ERROR_FAILURE;
       
  1443 +
  1412 +    if( aApplication == APPLICATION_MAIL )
  1444 +    if( aApplication == APPLICATION_MAIL )
  1413 +        command.AppendElement( NS_LITERAL_CSTRING( "OPENMAIL" ));
  1445 +        str->SetData( NS_LITERAL_CSTRING( "OPENMAIL" ));
  1414 +    else if( aApplication == APPLICATION_NEWS )
  1446 +    else if( aApplication == APPLICATION_NEWS )
  1415 +        command.AppendElement( NS_LITERAL_CSTRING( "OPENNEWS" ));
  1447 +        str->SetData( NS_LITERAL_CSTRING( "OPENNEWS" ));
  1416 +    else
  1448 +    else
  1417 +        return NS_ERROR_NOT_IMPLEMENTED;
  1449 +        return NS_ERROR_NOT_IMPLEMENTED;
       
  1450 +
       
  1451 +    command->AppendElement( str, false );
  1418 +    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  1452 +    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  1419 +    }
  1453 +    }
  1420 +
  1454 +
  1421 +NS_IMETHODIMP
  1455 +NS_IMETHODIMP
  1422 +nsKDEShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const nsACString& aURI)
  1456 +nsKDEShellService::OpenApplicationWithURI(nsILocalFile* aApplication, const nsACString& aURI)
  1423 +    {
  1457 +    {
  1424 +    nsTArray<nsCString> command;
  1458 +    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
  1425 +    command.AppendElement( NS_LITERAL_CSTRING( "RUN" ));
  1459 +    if (!command)
  1426 +    nsCString app;
  1460 +        return NS_ERROR_FAILURE;
       
  1461 +
       
  1462 +    nsCOMPtr<nsISupportsCString> cmdstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
       
  1463 +    nsCOMPtr<nsISupportsCString> appstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
       
  1464 +    nsCOMPtr<nsISupportsCString> uristr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
       
  1465 +    if (!cmdstr || !appstr || !uristr)
       
  1466 +        return NS_ERROR_FAILURE;
       
  1467 +
       
  1468 +    cmdstr->SetData( NS_LITERAL_CSTRING( "RUN" ));
       
  1469 +    command->AppendElement( cmdstr, false );
       
  1470 +    nsCAutoString app;
  1427 +    nsresult rv = aApplication->GetNativePath( app );
  1471 +    nsresult rv = aApplication->GetNativePath( app );
  1428 +    NS_ENSURE_SUCCESS( rv, rv );
  1472 +    NS_ENSURE_SUCCESS( rv, rv );
  1429 +    command.AppendElement( app );
  1473 +    appstr->SetData( app );
  1430 +    command.AppendElement( aURI );
  1474 +    command->AppendElement( appstr, false );
       
  1475 +    uristr->SetData( aURI );
       
  1476 +    command->AppendElement( uristr, false );
  1431 +    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  1477 +    return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
  1432 +    }
  1478 +    }
  1433 +
  1479 +
  1434 +NS_IMETHODIMP
  1480 +NS_IMETHODIMP
  1435 +nsKDEShellService::GetDefaultFeedReader(nsILocalFile** _retval)
  1481 +nsKDEShellService::GetDefaultFeedReader(nsILocalFile** _retval)
  1436 +    {
  1482 +    {
  1437 +    *_retval = nsnull;
  1483 +    *_retval = nsnull;
  1438 +
  1484 +
  1439 +    nsTArray<nsCString> command;
  1485 +    nsCOMPtr<nsIMutableArray> command = do_CreateInstance( NS_ARRAY_CONTRACTID );
  1440 +    command.AppendElement( NS_LITERAL_CSTRING( "GETDEFAULTFEEDREADER" ));
  1486 +    if( !command )
  1441 +    nsTArray<nsCString> output;
       
  1442 +    if( !nsKDEUtils::command( command, &output ) || output.Length() != 1 )
       
  1443 +        return NS_ERROR_FAILURE;
  1487 +        return NS_ERROR_FAILURE;
  1444 +
  1488 +
  1445 +    nsCString path;
  1489 +    nsCOMPtr<nsISupportsCString> str = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
  1446 +    path = output[ 0 ];
  1490 +    if( !str )
       
  1491 +        return NS_ERROR_FAILURE;
       
  1492 +
       
  1493 +    str->SetData( NS_LITERAL_CSTRING( "GETDEFAULTFEEDREADER" ));
       
  1494 +    command->AppendElement( str, false );
       
  1495 +
       
  1496 +    nsCOMPtr<nsIArray> output;
       
  1497 +    if( !nsKDEUtils::command( command, getter_AddRefs( output ) ) )
       
  1498 +        return NS_ERROR_FAILURE;
       
  1499 +
       
  1500 +    PRUint32 length;
       
  1501 +    output->GetLength( &length );
       
  1502 +    if( length != 1 )
       
  1503 +        return NS_ERROR_FAILURE;
       
  1504 +
       
  1505 +    nsCOMPtr<nsISupportsCString> resstr = do_QueryElementAt( output, 0 );
       
  1506 +    if( !resstr )
       
  1507 +        return NS_ERROR_FAILURE;
       
  1508 +
       
  1509 +    nsCAutoString path;
       
  1510 +    resstr->GetData( path );
  1447 +    if (path.IsEmpty())
  1511 +    if (path.IsEmpty())
  1448 +        return NS_ERROR_FAILURE;
  1512 +        return NS_ERROR_FAILURE;
  1449 +
  1513 +
  1450 +    nsresult rv;
  1514 +    nsresult rv;
  1451 +    nsCOMPtr<nsILocalFile> defaultReader =
  1515 +    nsCOMPtr<nsILocalFile> defaultReader =