Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 493722 | Differences between
and this patch

Collapse All | Expand All

(-)a/modules/libpref/src/Makefile.in (+1 lines)
Lines 49-62 endif Link Here
49
# Optimizer bug with GCC 3.2.2 on OS/2
49
# Optimizer bug with GCC 3.2.2 on OS/2
50
ifeq ($(OS_ARCH), OS2)
50
ifeq ($(OS_ARCH), OS2)
51
nsPrefService.$(OBJ_SUFFIX): nsPrefService.cpp
51
nsPrefService.$(OBJ_SUFFIX): nsPrefService.cpp
52
	$(REPORT_BUILD)
52
	$(REPORT_BUILD)
53
	@$(MAKE_DEPS_AUTO_CXX)
53
	@$(MAKE_DEPS_AUTO_CXX)
54
	$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS:-O2=-O1) $(_VPATH_SRCS)
54
	$(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS:-O2=-O1) $(_VPATH_SRCS)
55
endif
55
endif
56
56
57
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
57
58
58
greprefs.js: $(grepref_files)
59
greprefs.js: $(grepref_files)
59
	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $^ > $@
60
	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $^ > $@
60
61
61
libs:: greprefs.js
62
libs:: greprefs.js
62
	$(INSTALL) $^ $(DIST)/bin/
63
	$(INSTALL) $^ $(DIST)/bin/
(-)a/modules/libpref/src/Preferences.cpp (-1 / +32 lines)
Lines 23-38 Link Here
23
#include "nsIStringEnumerator.h"
23
#include "nsIStringEnumerator.h"
24
#include "nsIZipReader.h"
24
#include "nsIZipReader.h"
25
#include "nsPrefBranch.h"
25
#include "nsPrefBranch.h"
26
#include "nsXPIDLString.h"
26
#include "nsXPIDLString.h"
27
#include "nsCRT.h"
27
#include "nsCRT.h"
28
#include "nsCOMArray.h"
28
#include "nsCOMArray.h"
29
#include "nsXPCOMCID.h"
29
#include "nsXPCOMCID.h"
30
#include "nsAutoPtr.h"
30
#include "nsAutoPtr.h"
31
#include "nsKDEUtils.h"
31
32
32
#include "nsQuickSort.h"
33
#include "nsQuickSort.h"
33
#include "pldhash.h"
34
#include "pldhash.h"
34
35
35
#include "prefapi.h"
36
#include "prefapi.h"
36
#include "prefread.h"
37
#include "prefread.h"
37
#include "prefapi_private_data.h"
38
#include "prefapi_private_data.h"
38
39
Lines 972-987 pref_LoadPrefsInDir(nsIFile* aDir, char Link Here
972
973
973
static nsresult pref_LoadPrefsInDirList(const char *listId)
974
static nsresult pref_LoadPrefsInDirList(const char *listId)
974
{
975
{
975
  nsresult rv;
976
  nsresult rv;
976
  nsCOMPtr<nsIProperties> dirSvc(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
977
  nsCOMPtr<nsIProperties> dirSvc(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
977
  if (NS_FAILED(rv))
978
  if (NS_FAILED(rv))
978
    return rv;
979
    return rv;
979
980
981
  // make sure we load these special files after all the others
982
  static const char* specialFiles[] = {
983
#if defined(XP_UNIX)
984
    ""
985
#endif
986
  };
987
988
  if (nsKDEUtils::kdeSession()) {
989
    for(int i = 0;
990
        i < NS_ARRAY_LENGTH(specialFiles);
991
        ++i ) {
992
      if (*specialFiles[ i ] == '\0') {
993
        specialFiles[ i ] = "kde.js";
994
        break;
995
      }
996
    }
997
  }
998
980
  nsCOMPtr<nsISimpleEnumerator> list;
999
  nsCOMPtr<nsISimpleEnumerator> list;
981
  dirSvc->Get(listId,
1000
  dirSvc->Get(listId,
982
              NS_GET_IID(nsISimpleEnumerator),
1001
              NS_GET_IID(nsISimpleEnumerator),
983
              getter_AddRefs(list));
1002
              getter_AddRefs(list));
984
  if (!list)
1003
  if (!list)
985
    return NS_OK;
1004
    return NS_OK;
986
1005
987
  bool hasMore;
1006
  bool hasMore;
Lines 997-1013 static nsresult pref_LoadPrefsInDirList( Link Here
997
1016
998
    nsAutoCString leaf;
1017
    nsAutoCString leaf;
999
    path->GetNativeLeafName(leaf);
1018
    path->GetNativeLeafName(leaf);
1000
1019
1001
    // Do we care if a file provided by this process fails to load?
1020
    // Do we care if a file provided by this process fails to load?
1002
    if (Substring(leaf, leaf.Length() - 4).Equals(NS_LITERAL_CSTRING(".xpi")))
1021
    if (Substring(leaf, leaf.Length() - 4).Equals(NS_LITERAL_CSTRING(".xpi")))
1003
      ReadExtensionPrefs(path);
1022
      ReadExtensionPrefs(path);
1004
    else
1023
    else
1005
      pref_LoadPrefsInDir(path, nullptr, 0);
1024
      pref_LoadPrefsInDir(path, specialFiles, NS_ARRAY_LENGTH(specialFiles));
1006
  }
1025
  }
1007
  return NS_OK;
1026
  return NS_OK;
1008
}
1027
}
1009
1028
1010
static nsresult pref_ReadPrefFromJar(nsZipArchive* jarReader, const char *name)
1029
static nsresult pref_ReadPrefFromJar(nsZipArchive* jarReader, const char *name)
1011
{
1030
{
1012
  nsZipItemPtr<char> manifest(jarReader, name, true);
1031
  nsZipItemPtr<char> manifest(jarReader, name, true);
1013
  NS_ENSURE_TRUE(manifest.Buffer(), NS_ERROR_NOT_AVAILABLE);
1032
  NS_ENSURE_TRUE(manifest.Buffer(), NS_ERROR_NOT_AVAILABLE);
Lines 1101-1128 static nsresult pref_InitInitialObjects( Link Here
1101
  /* these pref file names should not be used: we process them after all other application pref files for backwards compatibility */
1120
  /* these pref file names should not be used: we process them after all other application pref files for backwards compatibility */
1102
  static const char* specialFiles[] = {
1121
  static const char* specialFiles[] = {
1103
#if defined(XP_MACOSX)
1122
#if defined(XP_MACOSX)
1104
    "macprefs.js"
1123
    "macprefs.js"
1105
#elif defined(XP_WIN)
1124
#elif defined(XP_WIN)
1106
    "winpref.js"
1125
    "winpref.js"
1107
#elif defined(XP_UNIX)
1126
#elif defined(XP_UNIX)
1108
    "unix.js"
1127
    "unix.js"
1128
    , "" // placeholder for KDE  (empty is otherwise harmless)
1109
#if defined(VMS)
1129
#if defined(VMS)
1110
    , "openvms.js"
1130
    , "openvms.js"
1111
#elif defined(_AIX)
1131
#elif defined(_AIX)
1112
    , "aix.js"
1132
    , "aix.js"
1113
#endif
1133
#endif
1114
#elif defined(XP_OS2)
1134
#elif defined(XP_OS2)
1115
    "os2pref.js"
1135
    "os2pref.js"
1116
#elif defined(XP_BEOS)
1136
#elif defined(XP_BEOS)
1117
    "beos.js"
1137
    "beos.js"
1118
#endif
1138
#endif
1119
  };
1139
  };
1120
1140
1141
  if(nsKDEUtils::kdeSession()) { // TODO what if some setup actually requires the helper?
1142
    for(int i = 0;
1143
        i < NS_ARRAY_LENGTH(specialFiles);
1144
        ++i ) {
1145
      if( *specialFiles[ i ] == '\0' ) {
1146
        specialFiles[ i ] = "kde.js";
1147
        break;
1148
      }
1149
    }
1150
  }
1151
1121
  rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, ArrayLength(specialFiles));
1152
  rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, ArrayLength(specialFiles));
1122
  if (NS_FAILED(rv))
1153
  if (NS_FAILED(rv))
1123
    NS_WARNING("Error parsing application default preferences.");
1154
    NS_WARNING("Error parsing application default preferences.");
1124
1155
1125
  // Load jar:$app/omni.jar!/defaults/preferences/*.js
1156
  // Load jar:$app/omni.jar!/defaults/preferences/*.js
1126
  // or jar:$gre/omni.jar!/defaults/preferences/*.js.
1157
  // or jar:$gre/omni.jar!/defaults/preferences/*.js.
1127
  nsRefPtr<nsZipArchive> appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
1158
  nsRefPtr<nsZipArchive> appJarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::APP);
1128
  // GetReader(mozilla::Omnijar::APP) returns null when $app == $gre, in which
1159
  // GetReader(mozilla::Omnijar::APP) returns null when $app == $gre, in which
(-)a/python/mozbuild/mozpack/chrome/flags.py (+1 lines)
Lines 208-223 class Flags(OrderedDict): Link Here
208
        'platformversion': VersionFlag,
208
        'platformversion': VersionFlag,
209
        'contentaccessible': Flag,
209
        'contentaccessible': Flag,
210
        'os': StringFlag,
210
        'os': StringFlag,
211
        'osversion': VersionFlag,
211
        'osversion': VersionFlag,
212
        'abi': StringFlag,
212
        'abi': StringFlag,
213
        'platform': Flag,
213
        'platform': Flag,
214
        'xpcnativewrappers': Flag,
214
        'xpcnativewrappers': Flag,
215
        'tablet': Flag,
215
        'tablet': Flag,
216
	'desktop': StringFlag,
216
    }
217
    }
217
    RE = re.compile(r'([!<>=]+)')
218
    RE = re.compile(r'([!<>=]+)')
218
219
219
    def __init__(self, *flags):
220
    def __init__(self, *flags):
220
        '''
221
        '''
221
        Initialize a set of flags given in string form.
222
        Initialize a set of flags given in string form.
222
           flags = Flags('contentaccessible=yes', 'appversion>=3.5')
223
           flags = Flags('contentaccessible=yes', 'appversion>=3.5')
223
        '''
224
        '''
(-)a/python/mozbuild/mozpack/chrome/manifest.py (+1 lines)
Lines 30-45 class ManifestEntry(object): Link Here
30
    allowed_flags = [
30
    allowed_flags = [
31
        'application',
31
        'application',
32
        'platformversion',
32
        'platformversion',
33
        'os',
33
        'os',
34
        'osversion',
34
        'osversion',
35
        'abi',
35
        'abi',
36
        'xpcnativewrappers',
36
        'xpcnativewrappers',
37
        'tablet',
37
        'tablet',
38
	'desktop',
38
    ]
39
    ]
39
40
40
    def __init__(self, base, *flags):
41
    def __init__(self, base, *flags):
41
        '''
42
        '''
42
        Initialize a manifest entry with the given base path and flags.
43
        Initialize a manifest entry with the given base path and flags.
43
        '''
44
        '''
44
        self.base = base
45
        self.base = base
45
        self.flags = Flags(*flags)
46
        self.flags = Flags(*flags)
(-)a/toolkit/components/downloads/Makefile.in (+2 lines)
Lines 23-31 ifndef MOZ_SUITE Link Here
23
DISABLED_EXTRA_COMPONENTS = \
23
DISABLED_EXTRA_COMPONENTS = \
24
  nsDownloadManagerUI.js \
24
  nsDownloadManagerUI.js \
25
  nsDownloadManagerUI.manifest \
25
  nsDownloadManagerUI.manifest \
26
  $(NULL)
26
  $(NULL)
27
endif
27
endif
28
28
29
include $(topsrcdir)/config/rules.mk
29
include $(topsrcdir)/config/rules.mk
30
30
31
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
32
31
CXXFLAGS += $(TK_CFLAGS)
33
CXXFLAGS += $(TK_CFLAGS)
(-)a/toolkit/components/downloads/nsDownloadManager.cpp (-1 / +15 lines)
Lines 38-53 Link Here
38
38
39
#ifdef XP_WIN
39
#ifdef XP_WIN
40
#include <shlobj.h>
40
#include <shlobj.h>
41
#ifdef DOWNLOAD_SCANNER
41
#ifdef DOWNLOAD_SCANNER
42
#include "nsDownloadScanner.h"
42
#include "nsDownloadScanner.h"
43
#endif
43
#endif
44
#endif
44
#endif
45
45
46
#if defined(XP_UNIX) && !defined(XP_MACOSX)
47
#include "nsKDEUtils.h"
48
#endif
49
46
#ifdef XP_MACOSX
50
#ifdef XP_MACOSX
47
#include <CoreFoundation/CoreFoundation.h>
51
#include <CoreFoundation/CoreFoundation.h>
48
#endif
52
#endif
49
53
50
#ifdef MOZ_WIDGET_ANDROID
54
#ifdef MOZ_WIDGET_ANDROID
51
#include "AndroidBridge.h"
55
#include "AndroidBridge.h"
52
#endif
56
#endif
53
57
Lines 2609-2624 nsDownload::SetState(DownloadState aStat Link Here
2609
      nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
2613
      nsCOMPtr<nsIPrefBranch> pref(do_GetService(NS_PREFSERVICE_CONTRACTID));
2610
2614
2611
      // Master pref to control this function.
2615
      // Master pref to control this function.
2612
      bool showTaskbarAlert = true;
2616
      bool showTaskbarAlert = true;
2613
      if (pref)
2617
      if (pref)
2614
        pref->GetBoolPref(PREF_BDM_SHOWALERTONCOMPLETE, &showTaskbarAlert);
2618
        pref->GetBoolPref(PREF_BDM_SHOWALERTONCOMPLETE, &showTaskbarAlert);
2615
2619
2616
      if (showTaskbarAlert) {
2620
      if (showTaskbarAlert) {
2621
        if( nsKDEUtils::kdeSupport()) {
2622
          nsTArray<nsCString> command;
2623
          command.AppendElement( NS_LITERAL_CSTRING( "DOWNLOADFINISHED" ));
2624
          nsAutoString displayName;
2625
          GetDisplayName( displayName );
2626
          command.AppendElement( nsAutoCString( ToNewUTF8String( displayName )));
2627
          nsKDEUtils::command( command );
2628
        } else {
2629
        // begin non-KDE block
2617
        int32_t alertInterval = 2000;
2630
        int32_t alertInterval = 2000;
2618
        if (pref)
2631
        if (pref)
2619
          pref->GetIntPref(PREF_BDM_SHOWALERTINTERVAL, &alertInterval);
2632
          pref->GetIntPref(PREF_BDM_SHOWALERTINTERVAL, &alertInterval);
2620
2633
2621
        int64_t alertIntervalUSec = alertInterval * PR_USEC_PER_MSEC;
2634
        int64_t alertIntervalUSec = alertInterval * PR_USEC_PER_MSEC;
2622
        int64_t goat = PR_Now() - mStartTime;
2635
        int64_t goat = PR_Now() - mStartTime;
2623
        showTaskbarAlert = goat > alertIntervalUSec;
2636
        showTaskbarAlert = goat > alertIntervalUSec;
2624
2637
Lines 2645-2663 nsDownload::SetState(DownloadState aStat Link Here
2645
              // retention policy, there's no reason to make the text clickable
2658
              // retention policy, there's no reason to make the text clickable
2646
              // because if it is, they'll click open the download manager and
2659
              // because if it is, they'll click open the download manager and
2647
              // the items they downloaded will have been removed.
2660
              // the items they downloaded will have been removed.
2648
              alerts->ShowAlertNotification(
2661
              alerts->ShowAlertNotification(
2649
                  NS_LITERAL_STRING(DOWNLOAD_MANAGER_ALERT_ICON), title,
2662
                  NS_LITERAL_STRING(DOWNLOAD_MANAGER_ALERT_ICON), title,
2650
                  message, !removeWhenDone,
2663
                  message, !removeWhenDone,
2651
                  mPrivate ? NS_LITERAL_STRING("private") : NS_LITERAL_STRING("non-private"),
2664
                  mPrivate ? NS_LITERAL_STRING("private") : NS_LITERAL_STRING("non-private"),
2652
                  mDownloadManager, EmptyString(), NS_LITERAL_STRING("auto"), EmptyString());
2665
                  mDownloadManager, EmptyString(), NS_LITERAL_STRING("auto"), EmptyString());
2653
            }
2666
          }
2654
        }
2667
        }
2655
      }
2668
      }
2669
      }
2656
2670
2657
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GTK2)
2671
#if defined(XP_WIN) || defined(XP_MACOSX) || defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GTK2)
2658
      nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mTarget);
2672
      nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mTarget);
2659
      nsCOMPtr<nsIFile> file;
2673
      nsCOMPtr<nsIFile> file;
2660
      nsAutoString path;
2674
      nsAutoString path;
2661
2675
2662
      if (fileURL &&
2676
      if (fileURL &&
2663
          NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) &&
2677
          NS_SUCCEEDED(fileURL->GetFile(getter_AddRefs(file))) &&
(-)a/toolkit/content/jar.mn (+4 lines)
Lines 50-78 toolkit.jar: Link Here
50
   content/global/viewZoomOverlay.js          (viewZoomOverlay.js)
50
   content/global/viewZoomOverlay.js          (viewZoomOverlay.js)
51
*+ content/global/bindings/autocomplete.xml    (widgets/autocomplete.xml)
51
*+ content/global/bindings/autocomplete.xml    (widgets/autocomplete.xml)
52
   content/global/bindings/browser.xml         (widgets/browser.xml)
52
   content/global/bindings/browser.xml         (widgets/browser.xml)
53
   content/global/bindings/button.xml          (widgets/button.xml)
53
   content/global/bindings/button.xml          (widgets/button.xml)
54
   content/global/bindings/checkbox.xml        (widgets/checkbox.xml)
54
   content/global/bindings/checkbox.xml        (widgets/checkbox.xml)
55
   content/global/bindings/colorpicker.xml     (widgets/colorpicker.xml)
55
   content/global/bindings/colorpicker.xml     (widgets/colorpicker.xml)
56
   content/global/bindings/datetimepicker.xml  (widgets/datetimepicker.xml)
56
   content/global/bindings/datetimepicker.xml  (widgets/datetimepicker.xml)
57
*+ content/global/bindings/dialog.xml          (widgets/dialog.xml)
57
*+ content/global/bindings/dialog.xml          (widgets/dialog.xml)
58
*+ content/global/bindings/dialog-kde.xml      (widgets/dialog-kde.xml)
59
% override chrome://global/content/bindings/dialog.xml chrome://global/content/bindings/dialog-kde.xml desktop=kde
58
   content/global/bindings/editor.xml          (widgets/editor.xml)
60
   content/global/bindings/editor.xml          (widgets/editor.xml)
59
   content/global/bindings/expander.xml        (widgets/expander.xml)
61
   content/global/bindings/expander.xml        (widgets/expander.xml)
60
*  content/global/bindings/filefield.xml       (widgets/filefield.xml)
62
*  content/global/bindings/filefield.xml       (widgets/filefield.xml)
61
*+ content/global/bindings/findbar.xml         (widgets/findbar.xml)
63
*+ content/global/bindings/findbar.xml         (widgets/findbar.xml)
62
   content/global/bindings/general.xml         (widgets/general.xml)
64
   content/global/bindings/general.xml         (widgets/general.xml)
63
   content/global/bindings/groupbox.xml        (widgets/groupbox.xml)
65
   content/global/bindings/groupbox.xml        (widgets/groupbox.xml)
64
*+ content/global/bindings/listbox.xml         (widgets/listbox.xml)
66
*+ content/global/bindings/listbox.xml         (widgets/listbox.xml)
65
   content/global/bindings/menu.xml            (widgets/menu.xml)
67
   content/global/bindings/menu.xml            (widgets/menu.xml)
66
   content/global/bindings/menulist.xml        (widgets/menulist.xml)
68
   content/global/bindings/menulist.xml        (widgets/menulist.xml)
67
   content/global/bindings/notification.xml    (widgets/notification.xml)
69
   content/global/bindings/notification.xml    (widgets/notification.xml)
68
   content/global/bindings/numberbox.xml       (widgets/numberbox.xml)
70
   content/global/bindings/numberbox.xml       (widgets/numberbox.xml)
69
   content/global/bindings/popup.xml           (widgets/popup.xml)
71
   content/global/bindings/popup.xml           (widgets/popup.xml)
70
*+ content/global/bindings/preferences.xml     (widgets/preferences.xml)
72
*+ content/global/bindings/preferences.xml     (widgets/preferences.xml)
73
*+ content/global/bindings/preferences-kde.xml (widgets/preferences-kde.xml)
74
% override chrome://global/content/bindings/preferences.xml chrome://global/content/bindings/preferences-kde.xml desktop=kde
71
   content/global/bindings/progressmeter.xml   (widgets/progressmeter.xml)
75
   content/global/bindings/progressmeter.xml   (widgets/progressmeter.xml)
72
   content/global/bindings/radio.xml           (widgets/radio.xml)
76
   content/global/bindings/radio.xml           (widgets/radio.xml)
73
   content/global/bindings/remote-browser.xml  (widgets/remote-browser.xml)
77
   content/global/bindings/remote-browser.xml  (widgets/remote-browser.xml)
74
   content/global/bindings/resizer.xml         (widgets/resizer.xml)
78
   content/global/bindings/resizer.xml         (widgets/resizer.xml)
75
   content/global/bindings/richlistbox.xml     (widgets/richlistbox.xml)
79
   content/global/bindings/richlistbox.xml     (widgets/richlistbox.xml)
76
   content/global/bindings/scale.xml           (widgets/scale.xml)
80
   content/global/bindings/scale.xml           (widgets/scale.xml)
77
   content/global/bindings/scrollbar.xml       (widgets/scrollbar.xml)
81
   content/global/bindings/scrollbar.xml       (widgets/scrollbar.xml)
78
   content/global/bindings/scrollbox.xml       (widgets/scrollbox.xml)
82
   content/global/bindings/scrollbox.xml       (widgets/scrollbox.xml)
(-)a/toolkit/content/widgets/dialog-kde.xml (+451 lines)
Line 0 Link Here
1
<?xml version="1.0"?>
2
<!-- This Source Code Form is subject to the terms of the Mozilla Public
3
   - License, v. 2.0. If a copy of the MPL was not distributed with this
4
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
5
6
7
<bindings id="dialogBindings"
8
          xmlns="http://www.mozilla.org/xbl"
9
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
10
          xmlns:xbl="http://www.mozilla.org/xbl">
11
  
12
  <binding id="dialog" extends="chrome://global/content/bindings/general.xml#root-element">
13
    <resources>
14
      <stylesheet src="chrome://global/skin/dialog.css"/>
15
    </resources>
16
    <content>
17
      <xul:vbox class="box-inherit dialog-content-box" flex="1">
18
        <children/>
19
      </xul:vbox>
20
          
21
      <xul:hbox class="dialog-button-box" anonid="buttons"
22
                xbl:inherits="pack=buttonpack,align=buttonalign,dir=buttondir,orient=buttonorient"
23
#ifdef XP_UNIX_GNOME
24
                >
25
        <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
26
        <xul:button dlgtype="help" class="dialog-button" hidden="true"/>
27
        <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
28
        <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
29
        <xul:spacer anonid="spacer" flex="1"/>
30
        <xul:button dlgtype="cancel" class="dialog-button"/>
31
        <xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
32
#elif XP_UNIX
33
                pack="end">
34
	<xul:button dlgtype="help" class="dialog-button" hidden="true"/>
35
	<xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
36
	<xul:spacer anonid="spacer" flex="1" hidden="true"/>
37
	<xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
38
	<xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
39
	<xul:button dlgtype="cancel" class="dialog-button"/>
40
	<xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
41
#else
42
                pack="end">
43
        <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
44
        <xul:spacer anonid="spacer" flex="1" hidden="true"/>
45
        <xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
46
        <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
47
        <xul:button dlgtype="cancel" class="dialog-button"/>
48
        <xul:button dlgtype="help" class="dialog-button" hidden="true"/>
49
        <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
50
#endif
51
      </xul:hbox>
52
    </content>
53
54
    <implementation>
55
      <field name="_mStrBundle">null</field>
56
      <field name="_closeHandler">(function(event) {
57
        if (!document.documentElement.cancelDialog())
58
          event.preventDefault();
59
      })</field>
60
61
      <property name="buttons"
62
                onget="return this.getAttribute('buttons');"
63
                onset="this._configureButtons(val); return val;"/>
64
65
      <property name="defaultButton">
66
        <getter>
67
        <![CDATA[
68
          if (this.hasAttribute("defaultButton"))
69
            return this.getAttribute("defaultButton");
70
          else // default to the accept button
71
            return "accept";
72
        ]]>
73
        </getter>
74
        <setter>
75
        <![CDATA[
76
          this._setDefaultButton(val);
77
          return val;
78
        ]]>
79
        </setter>
80
      </property>
81
82
      <method name="acceptDialog">
83
        <body>
84
        <![CDATA[
85
          return this._doButtonCommand("accept");
86
        ]]>
87
        </body>
88
      </method>
89
      
90
      <method name="cancelDialog">
91
        <body>
92
        <![CDATA[
93
          return this._doButtonCommand("cancel");
94
        ]]>
95
        </body>
96
      </method>
97
      
98
      <method name="getButton">
99
        <parameter name="aDlgType"/>
100
        <body>
101
        <![CDATA[
102
          return this._buttons[aDlgType];
103
        ]]>
104
        </body>
105
      </method>
106
107
      <method name="moveToAlertPosition">
108
        <body>
109
        <![CDATA[
110
          // hack. we need this so the window has something like its final size
111
          if (window.outerWidth == 1) {
112
            dump("Trying to position a sizeless window; caller should have called sizeToContent() or sizeTo(). See bug 75649.\n");
113
            sizeToContent();
114
          }
115
116
          var xOffset = (opener.outerWidth - window.outerWidth) / 2;
117
          var yOffset = opener.outerHeight / 5;
118
119
          var newX = opener.screenX + xOffset;
120
          var newY = opener.screenY + yOffset;
121
122
          // ensure the window is fully onscreen (if smaller than the screen)
123
          if (newX < screen.availLeft)
124
            newX = screen.availLeft + 20;
125
          if ((newX + window.outerWidth) > (screen.availLeft + screen.availWidth))
126
            newX = (screen.availLeft + screen.availWidth) - window.outerWidth - 20;
127
128
          if (newY < screen.availTop)
129
            newY = screen.availTop + 20;
130
          if ((newY + window.outerHeight) > (screen.availTop + screen.availHeight))
131
            newY = (screen.availTop + screen.availHeight) - window.outerHeight - 60;
132
133
          window.moveTo( newX, newY );
134
        ]]>
135
        </body>
136
      </method>
137
138
      <method name="centerWindowOnScreen">
139
        <body>
140
        <![CDATA[
141
          var xOffset = screen.availWidth/2 - window.outerWidth/2;
142
          var yOffset = screen.availHeight/2 - window.outerHeight/2; //(opener.outerHeight *2)/10;
143
  
144
          xOffset = xOffset > 0 ? xOffset : 0;
145
          yOffset = yOffset > 0 ? yOffset : 0;
146
          window.moveTo(xOffset, yOffset);
147
        ]]>
148
        </body>
149
      </method>
150
151
      <constructor>
152
      <![CDATA[
153
        this._configureButtons(this.buttons);
154
155
        // listen for when window is closed via native close buttons
156
        window.addEventListener("close", this._closeHandler, false);
157
158
        // for things that we need to initialize after onload fires
159
        window.addEventListener("load", this.postLoadInit, false);
160
161
        window.moveToAlertPosition = this.moveToAlertPosition;
162
        window.centerWindowOnScreen = this.centerWindowOnScreen;
163
      ]]>
164
      </constructor>
165
166
      <method name="postLoadInit">
167
        <parameter name="aEvent"/>
168
        <body>
169
        <![CDATA[
170
          function focusInit() {
171
            const dialog = document.documentElement;
172
            const defaultButton = dialog.getButton(dialog.defaultButton);
173
            // give focus to the first focusable element in the dialog
174
            if (!document.commandDispatcher.focusedElement) {
175
              document.commandDispatcher.advanceFocusIntoSubtree(dialog);
176
177
              var focusedElt = document.commandDispatcher.focusedElement;
178
              if (focusedElt) {
179
                var initialFocusedElt = focusedElt;
180
                while (focusedElt.localName == "tab" ||
181
                       focusedElt.getAttribute("noinitialfocus") == "true") {
182
                  document.commandDispatcher.advanceFocusIntoSubtree(focusedElt);
183
                  focusedElt = document.commandDispatcher.focusedElement;
184
                  if (focusedElt == initialFocusedElt)
185
                    break;
186
                }
187
188
                if (initialFocusedElt.localName == "tab") {
189
                  if (focusedElt.hasAttribute("dlgtype")) {
190
                    // We don't want to focus on anonymous OK, Cancel, etc. buttons,
191
                    // so return focus to the tab itself
192
                    initialFocusedElt.focus();
193
                  }
194
                }
195
#ifndef XP_MACOSX
196
                else if (focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton) {
197
                  defaultButton.focus();
198
                }
199
#endif
200
              }
201
            }
202
203
            try {
204
              if (defaultButton)
205
                window.notifyDefaultButtonLoaded(defaultButton);
206
            } catch (e) { }
207
          }
208
209
          // Give focus after onload completes, see bug 103197.
210
          setTimeout(focusInit, 0);
211
        ]]>
212
        </body>
213
      </method>                
214
215
      <property name="mStrBundle">
216
        <getter>
217
        <![CDATA[
218
          if (!this._mStrBundle) {
219
            // need to create string bundle manually instead of using <xul:stringbundle/>
220
            // see bug 63370 for details
221
            this._mStrBundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
222
                                         .getService(Components.interfaces.nsIStringBundleService)
223
                                         .createBundle("chrome://global/locale/dialog.properties");
224
          }
225
          return this._mStrBundle;
226
        ]]></getter>
227
      </property>
228
      
229
      <method name="_configureButtons">
230
        <parameter name="aButtons"/>
231
        <body>
232
        <![CDATA[
233
          // by default, get all the anonymous button elements
234
          var buttons = {};
235
          this._buttons = buttons;
236
          buttons.accept = document.getAnonymousElementByAttribute(this, "dlgtype", "accept");
237
          buttons.cancel = document.getAnonymousElementByAttribute(this, "dlgtype", "cancel");
238
          buttons.extra1 = document.getAnonymousElementByAttribute(this, "dlgtype", "extra1");
239
          buttons.extra2 = document.getAnonymousElementByAttribute(this, "dlgtype", "extra2");
240
          buttons.help = document.getAnonymousElementByAttribute(this, "dlgtype", "help");
241
          buttons.disclosure = document.getAnonymousElementByAttribute(this, "dlgtype", "disclosure");
242
243
          // look for any overriding explicit button elements
244
          var exBtns = this.getElementsByAttribute("dlgtype", "*");
245
          var dlgtype;
246
          var i;
247
          for (i = 0; i < exBtns.length; ++i) {
248
            dlgtype = exBtns[i].getAttribute("dlgtype");
249
            buttons[dlgtype].hidden = true; // hide the anonymous button
250
            buttons[dlgtype] = exBtns[i];
251
          }
252
253
          // add the label and oncommand handler to each button
254
          for (dlgtype in buttons) {
255
            var button = buttons[dlgtype];
256
            button.addEventListener("command", this._handleButtonCommand, true);
257
258
            // don't override custom labels with pre-defined labels on explicit buttons
259
            if (!button.hasAttribute("label")) {
260
              // dialog attributes override the default labels in dialog.properties
261
              if (this.hasAttribute("buttonlabel"+dlgtype)) {
262
                button.setAttribute("label", this.getAttribute("buttonlabel"+dlgtype));
263
                if (this.hasAttribute("buttonaccesskey"+dlgtype))
264
                  button.setAttribute("accesskey", this.getAttribute("buttonaccesskey"+dlgtype));
265
              } else if (dlgtype != "extra1" && dlgtype != "extra2") {
266
                button.setAttribute("label", this.mStrBundle.GetStringFromName("button-"+dlgtype));
267
                var accessKey = this.mStrBundle.GetStringFromName("accesskey-"+dlgtype);
268
                if (accessKey)
269
                  button.setAttribute("accesskey", accessKey);
270
              }
271
            }
272
            // allow specifying alternate icons in the dialog header
273
            if (!button.hasAttribute("icon")) {
274
              // if there's an icon specified, use that
275
              if (this.hasAttribute("buttonicon"+dlgtype))
276
                button.setAttribute("icon", this.getAttribute("buttonicon"+dlgtype));
277
              // otherwise set defaults
278
              else
279
                switch (dlgtype) {
280
                  case "accept":
281
                    button.setAttribute("icon","accept");
282
                    break;
283
                  case "cancel":
284
                    button.setAttribute("icon","cancel");
285
                    break;
286
                  case "disclosure":
287
                    button.setAttribute("icon","properties");
288
                    break;
289
                  case "help":
290
                    button.setAttribute("icon","help");
291
                    break;
292
                  default:
293
                    break;
294
                }
295
            }
296
          }
297
298
          // ensure that hitting enter triggers the default button command
299
          this.defaultButton = this.defaultButton;
300
          
301
          // if there is a special button configuration, use it
302
          if (aButtons) {
303
            // expect a comma delimited list of dlgtype values
304
            var list = aButtons.split(",");
305
306
            // mark shown dlgtypes as true
307
            var shown = { accept: false, cancel: false, help: false,
308
                          disclosure: false, extra1: false, extra2: false };
309
            for (i = 0; i < list.length; ++i)
310
              shown[list[i].replace(/ /g, "")] = true;
311
312
            // hide/show the buttons we want
313
            for (dlgtype in buttons) 
314
              buttons[dlgtype].hidden = !shown[dlgtype];
315
316
#ifdef XP_WIN
317
#           show the spacer on Windows only when the extra2 button is present
318
            var spacer = document.getAnonymousElementByAttribute(this, "anonid", "spacer");
319
            spacer.removeAttribute("hidden");
320
            spacer.setAttribute("flex", shown["extra2"]?"1":"0");
321
#endif
322
323
          }
324
        ]]>
325
        </body>
326
      </method>
327
328
      <method name="_setDefaultButton">
329
        <parameter name="aNewDefault"/>
330
        <body>
331
        <![CDATA[
332
          // remove the default attribute from the previous default button, if any
333
          var oldDefaultButton = this.getButton(this.defaultButton);
334
          if (oldDefaultButton)
335
            oldDefaultButton.removeAttribute("default");
336
337
          var newDefaultButton = this.getButton(aNewDefault);
338
          if (newDefaultButton) {
339
            this.setAttribute("defaultButton", aNewDefault);
340
            newDefaultButton.setAttribute("default", "true");
341
          }
342
          else {
343
            this.setAttribute("defaultButton", "none");
344
            if (aNewDefault != "none")
345
              dump("invalid new default button: " +  aNewDefault + ", assuming: none\n");
346
          }
347
        ]]>
348
        </body>
349
      </method>
350
351
      <method name="_handleButtonCommand">
352
        <parameter name="aEvent"/>
353
        <body>
354
        <![CDATA[
355
          return document.documentElement._doButtonCommand(
356
                                        aEvent.target.getAttribute("dlgtype"));
357
        ]]>
358
        </body>
359
      </method>
360
      
361
      <method name="_doButtonCommand">
362
        <parameter name="aDlgType"/>
363
        <body>
364
        <![CDATA[
365
          var button = this.getButton(aDlgType);
366
          if (!button.disabled) {
367
            var noCancel = this._fireButtonEvent(aDlgType);
368
            if (noCancel) {
369
              if (aDlgType == "accept" || aDlgType == "cancel")
370
                window.close();
371
            }
372
            return noCancel;
373
          }
374
          return true;
375
        ]]>
376
        </body>
377
      </method>
378
      
379
      <method name="_fireButtonEvent">
380
        <parameter name="aDlgType"/>
381
        <body>
382
        <![CDATA[
383
          var event = document.createEvent("Events");
384
          event.initEvent("dialog"+aDlgType, true, true);
385
          
386
          // handle dom event handlers
387
          var noCancel = this.dispatchEvent(event);
388
          
389
          // handle any xml attribute event handlers
390
          var handler = this.getAttribute("ondialog"+aDlgType);
391
          if (handler != "") {
392
            var fn = new Function("event", handler);
393
            var returned = fn(event);
394
            if (returned == false)
395
              noCancel = false;
396
          }
397
          
398
          return noCancel;
399
        ]]>
400
        </body>
401
      </method>
402
403
      <method name="_hitEnter">
404
        <parameter name="evt"/>
405
        <body>
406
        <![CDATA[
407
          if (evt.defaultPrevented)
408
            return;
409
410
          var btn = this.getButton(this.defaultButton);
411
          if (btn)
412
            this._doButtonCommand(this.defaultButton);
413
        ]]>
414
        </body>
415
      </method>
416
417
    </implementation>
418
    
419
    <handlers>
420
      <handler event="keypress" keycode="VK_ENTER"
421
               group="system" action="this._hitEnter(event);"/>
422
      <handler event="keypress" keycode="VK_RETURN"
423
               group="system" action="this._hitEnter(event);"/>
424
      <handler event="keypress" keycode="VK_ESCAPE" group="system">
425
        if (!event.defaultPrevented)
426
          this.cancelDialog();
427
      </handler>
428
#ifdef XP_MACOSX
429
      <handler event="keypress" key="." modifiers="meta" phase="capturing" action="this.cancelDialog();"/>
430
#else
431
      <handler event="focus" phase="capturing">
432
        var btn = this.getButton(this.defaultButton);
433
        if (btn)
434
          btn.setAttribute("default", event.originalTarget == btn || !(event.originalTarget instanceof Components.interfaces.nsIDOMXULButtonElement));
435
      </handler>
436
#endif
437
    </handlers>
438
439
  </binding>
440
441
  <binding id="dialogheader">
442
    <resources>
443
      <stylesheet src="chrome://global/skin/dialog.css"/>
444
    </resources>
445
    <content>
446
      <xul:label class="dialogheader-title" xbl:inherits="value=title,crop" crop="right" flex="1"/>
447
      <xul:label class="dialogheader-description" xbl:inherits="value=description"/>
448
    </content>
449
  </binding>
450
451
</bindings>
(-)a/toolkit/content/widgets/preferences-kde.xml (+1339 lines)
Line 0 Link Here
1
<?xml version="1.0"?>
2
3
<!DOCTYPE bindings [
4
  <!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
5
  %preferencesDTD;
6
  <!ENTITY % globalKeysDTD SYSTEM "chrome://global/locale/globalKeys.dtd">
7
  %globalKeysDTD;
8
]>
9
10
<bindings id="preferencesBindings"
11
          xmlns="http://www.mozilla.org/xbl"
12
          xmlns:xbl="http://www.mozilla.org/xbl"
13
          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
14
15
#
16
# = Preferences Window Framework
17
#
18
#   The syntax for use looks something like:
19
#
20
#   <prefwindow>
21
#     <prefpane id="prefPaneA">
22
#       <preferences>
23
#         <preference id="preference1" name="app.preference1" type="bool" onchange="foo();"/>
24
#         <preference id="preference2" name="app.preference2" type="bool" useDefault="true"/>
25
#       </preferences>
26
#       <checkbox label="Preference" preference="preference1"/>
27
#     </prefpane>
28
#   </prefwindow>
29
#
30
31
  <binding id="preferences">
32
    <implementation implements="nsIObserver">
33
      <method name="observe">
34
        <parameter name="aSubject"/>
35
        <parameter name="aTopic"/>
36
        <parameter name="aData"/>
37
        <body>
38
        <![CDATA[
39
          for (var i = 0; i < this.childNodes.length; ++i) {
40
            var preference = this.childNodes[i];
41
            if (preference.name == aData) {
42
              preference.value = preference.valueFromPreferences;
43
            }
44
          }
45
        ]]>
46
        </body>
47
      </method>
48
      
49
      <method name="fireChangedEvent">
50
        <parameter name="aPreference"/>
51
        <body>
52
        <![CDATA[
53
          // Value changed, synthesize an event
54
          try {
55
            var event = document.createEvent("Events");
56
            event.initEvent("change", true, true);
57
            aPreference.dispatchEvent(event);
58
          }
59
          catch (e) {
60
            Components.utils.reportError(e);
61
          }
62
        ]]>
63
        </body>
64
      </method>
65
      
66
      <field name="service">
67
        Components.classes["@mozilla.org/preferences-service;1"]
68
                  .getService(Components.interfaces.nsIPrefService);
69
      </field>
70
      <field name="rootBranch">
71
        Components.classes["@mozilla.org/preferences-service;1"]
72
                  .getService(Components.interfaces.nsIPrefBranch);
73
      </field>
74
      <field name="defaultBranch">
75
        this.service.getDefaultBranch("");
76
      </field>
77
      <field name="rootBranchInternal">
78
        Components.classes["@mozilla.org/preferences-service;1"]
79
                  .getService(Components.interfaces.nsIPrefBranchInternal);
80
      </field>
81
      <property name="type" readonly="true">
82
        <getter>
83
          <![CDATA[
84
            return document.documentElement.type || "";
85
          ]]>
86
        </getter>
87
      </property>
88
      <property name="instantApply" readonly="true">
89
        <getter>
90
          <![CDATA[
91
            var doc = document.documentElement;
92
            return this.type == "child" ? doc.instantApply
93
                                        : doc.instantApply || this.rootBranch.getBoolPref("browser.preferences.instantApply");
94
          ]]>
95
        </getter>
96
      </property>
97
    </implementation>
98
  </binding>
99
100
  <binding id="preference">
101
    <implementation>
102
      <constructor>
103
      <![CDATA[
104
        // if the element has been inserted without the name attribute set,
105
        // we have nothing to do here
106
        if (!this.name)
107
          return;
108
109
        this.preferences.rootBranchInternal
110
            .addObserver(this.name, this.preferences, false);
111
        // In non-instant apply mode, we must try and use the last saved state
112
        // from any previous opens of a child dialog instead of the value from
113
        // preferences, to pick up any edits a user may have made. 
114
        if (this.preferences.type == "child" && 
115
            !this.instantApply && window.opener) {
116
          var pdoc = window.opener.document;
117
118
          // Try to find a preference element for the same preference.
119
          var preference = null;
120
          var parentPreferences = pdoc.getElementsByTagName("preferences");
121
          for (var k = 0; (k < parentPreferences.length && !preference); ++k) {
122
            var parentPrefs = parentPreferences[k]
123
                                    .getElementsByAttribute("name", this.name);
124
            for (var l = 0; (l < parentPrefs.length && !preference); ++l) {
125
              if (parentPrefs[l].localName == "preference")
126
                preference = parentPrefs[l];
127
            }
128
          }
129
          this._setValue(preference ? preference.value 
130
                                    : this.valueFromPreferences, false);
131
        }
132
        else
133
          this._setValue(this.valueFromPreferences, false);
134
      ]]>
135
      </constructor>
136
      <destructor>
137
        this.preferences.rootBranchInternal
138
            .removeObserver(this.name, this.preferences);
139
      </destructor>
140
      
141
      <property name="instantApply">
142
        <getter>
143
          return this.getAttribute("instantApply") == "true" || this.preferences.instantApply;
144
        </getter>
145
      </property>
146
147
      <property name="preferences" onget="return this.parentNode"/>
148
      <property name="name" onget="return this.getAttribute('name');">
149
        <setter>
150
          if (val == this.name)
151
            return val;
152
            
153
          this.preferences.rootBranchInternal
154
              .removeObserver(this.name, this.preferences);
155
          this.setAttribute('name', val);
156
          this.preferences.rootBranchInternal
157
              .addObserver(val, this.preferences, false);
158
              
159
          return val;
160
        </setter>
161
      </property>
162
      <property name="type" onget="return this.getAttribute('type');"
163
                            onset="this.setAttribute('type', val); return val;"/>
164
      <property name="inverted" onget="return this.getAttribute('inverted') == 'true';"
165
                                onset="this.setAttribute('inverted', val); return val;"/>
166
      <property name="readonly" onget="return this.getAttribute('readonly') == 'true';"
167
                                onset="this.setAttribute('readonly', val); return val;"/>
168
169
      <field name="_value">null</field>
170
      <method name="_setValue">
171
        <parameter name="aValue"/>
172
        <parameter name="aUpdate"/>
173
        <body>
174
        <![CDATA[
175
          if (aUpdate && this.value !== aValue) {
176
            this._value = aValue;
177
            if (this.instantApply)
178
              this.valueFromPreferences = aValue;
179
            this.preferences.fireChangedEvent(this);
180
          }
181
          else if (!aUpdate) {
182
            this._value = aValue;
183
            this.updateElements();
184
          }
185
          return aValue;
186
        ]]>
187
        </body>
188
      </method>
189
      <property name="value" onget="return this._value" onset="return this._setValue(val, true);"/>
190
      
191
      <property name="locked">
192
        <getter>
193
          return this.preferences.rootBranch.prefIsLocked(this.name);
194
        </getter>
195
      </property>
196
      
197
      <property name="disabled">
198
        <getter>
199
          return this.getAttribute("disabled") == "true";
200
        </getter>
201
        <setter>
202
        <![CDATA[
203
          if (val) 
204
            this.setAttribute("disabled", "true");
205
          else
206
            this.removeAttribute("disabled");
207
208
          if (!this.id)
209
            return val;
210
211
          var elements = document.getElementsByAttribute("preference", this.id);
212
          for (var i = 0; i < elements.length; ++i) {
213
            elements[i].disabled = val;
214
            
215
            var labels = document.getElementsByAttribute("control", elements[i].id);
216
            for (var j = 0; j < labels.length; ++j)
217
              labels[j].disabled = val;
218
          }
219
            
220
          return val;
221
        ]]>
222
        </setter>
223
      </property>
224
      
225
      <property name="tabIndex">
226
        <getter>
227
          return parseInt(this.getAttribute("tabindex"));
228
        </getter>
229
        <setter>
230
        <![CDATA[
231
          if (val) 
232
            this.setAttribute("tabindex", val);
233
          else
234
            this.removeAttribute("tabindex");
235
236
          if (!this.id)
237
            return val;
238
239
          var elements = document.getElementsByAttribute("preference", this.id);
240
          for (var i = 0; i < elements.length; ++i) {
241
            elements[i].tabIndex = val;
242
            
243
            var labels = document.getElementsByAttribute("control", elements[i].id);
244
            for (var j = 0; j < labels.length; ++j)
245
              labels[j].tabIndex = val;
246
          }
247
            
248
          return val;
249
        ]]>
250
        </setter>
251
      </property>
252
253
      <property name="hasUserValue">
254
        <getter>
255
        <![CDATA[
256
          return this.preferences.rootBranch.prefHasUserValue(this.name) &&
257
                 this.value !== undefined;
258
        ]]>
259
        </getter>
260
      </property>
261
      
262
      <method name="reset">
263
        <body>
264
          // defer reset until preference update
265
          this.value = undefined;
266
        </body>
267
      </method>
268
269
      <field name="_useDefault">false</field>      
270
      <property name="defaultValue">
271
        <getter>
272
        <![CDATA[
273
          this._useDefault = true;
274
          var val = this.valueFromPreferences;
275
          this._useDefault = false;
276
          return val;
277
        ]]>
278
        </getter>
279
      </property>
280
      
281
      <property name="_branch">
282
        <getter>
283
          return this._useDefault ? this.preferences.defaultBranch : this.preferences.rootBranch;
284
        </getter>
285
      </property>
286
      
287
      <field name="batching">false</field>
288
      
289
      <method name="_reportUnknownType">
290
        <body>
291
        <![CDATA[
292
          var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
293
                                         .getService(Components.interfaces.nsIConsoleService);
294
          var msg = "<preference> with id='" + this.id + "' and name='" + 
295
                    this.name + "' has unknown type '" + this.type + "'.";
296
          consoleService.logStringMessage(msg);
297
        ]]>
298
        </body>
299
      </method>
300
      
301
      <property name="valueFromPreferences">
302
        <getter>
303
        <![CDATA[
304
          try {
305
            // Force a resync of value with preferences.
306
            switch (this.type) {
307
            case "int":
308
              return this._branch.getIntPref(this.name);
309
            case "bool":
310
              var val = this._branch.getBoolPref(this.name);
311
              return this.inverted ? !val : val;
312
            case "wstring":
313
              return this._branch
314
                         .getComplexValue(this.name, Components.interfaces.nsIPrefLocalizedString)
315
                         .data;
316
            case "string":
317
            case "unichar":
318
              return this._branch
319
                         .getComplexValue(this.name, Components.interfaces.nsISupportsString)
320
                         .data;
321
            case "fontname":
322
              var family = this._branch
323
                               .getComplexValue(this.name, Components.interfaces.nsISupportsString)
324
                               .data;
325
              var fontEnumerator = Components.classes["@mozilla.org/gfx/fontenumerator;1"]
326
                                             .createInstance(Components.interfaces.nsIFontEnumerator);
327
              return fontEnumerator.getStandardFamilyName(family);
328
            case "file":
329
              var f = this._branch
330
                          .getComplexValue(this.name, Components.interfaces.nsILocalFile);
331
              return f;
332
            default:
333
              this._reportUnknownType();
334
            }
335
          }
336
          catch (e) { }
337
          return null;
338
        ]]>
339
        </getter>
340
        <setter>
341
        <![CDATA[
342
          // Exit early if nothing to do.
343
          if (this.readonly || this.valueFromPreferences == val)
344
            return val;
345
346
          // The special value undefined means 'reset preference to default'.
347
          if (val === undefined) {
348
            this.preferences.rootBranch.clearUserPref(this.name);
349
            return val;
350
          }
351
352
          // Force a resync of preferences with value.
353
          switch (this.type) {
354
          case "int":
355
            this.preferences.rootBranch.setIntPref(this.name, val);
356
            break;
357
          case "bool":
358
            this.preferences.rootBranch.setBoolPref(this.name, this.inverted ? !val : val);
359
            break;
360
          case "wstring":
361
            var pls = Components.classes["@mozilla.org/pref-localizedstring;1"]
362
                                .createInstance(Components.interfaces.nsIPrefLocalizedString);
363
            pls.data = val;
364
            this.preferences.rootBranch
365
                .setComplexValue(this.name, Components.interfaces.nsIPrefLocalizedString, pls);
366
            break;
367
          case "string":
368
          case "unichar":
369
          case "fontname":
370
            var iss = Components.classes["@mozilla.org/supports-string;1"]
371
                                .createInstance(Components.interfaces.nsISupportsString);
372
            iss.data = val;
373
            this.preferences.rootBranch
374
                .setComplexValue(this.name, Components.interfaces.nsISupportsString, iss);
375
            break;
376
          case "file":
377
            var lf;
378
            if (typeof(val) == "string") {
379
              lf = Components.classes["@mozilla.org/file/local;1"]
380
                             .createInstance(Components.interfaces.nsILocalFile);
381
              lf.persistentDescriptor = val;
382
              if (!lf.exists())
383
                lf.initWithPath(val);
384
            }
385
            else 
386
              lf = val.QueryInterface(Components.interfaces.nsILocalFile);
387
            this.preferences.rootBranch
388
                .setComplexValue(this.name, Components.interfaces.nsILocalFile, lf);
389
            break;
390
          default:
391
            this._reportUnknownType();
392
          }
393
          if (!this.batching)
394
            this.preferences.service.savePrefFile(null);
395
          return val;
396
        ]]>
397
        </setter>
398
      </property>
399
      
400
      <method name="setElementValue">
401
        <parameter name="aElement"/>
402
        <body>
403
        <![CDATA[
404
          if (this.locked)
405
            aElement.disabled = true;
406
407
          if (!this.isElementEditable(aElement))
408
            return;
409
410
          var rv = undefined;
411
          if (aElement.hasAttribute("onsyncfrompreference")) {
412
            // Value changed, synthesize an event
413
            try {
414
              var event = document.createEvent("Events");
415
              event.initEvent("syncfrompreference", true, true);
416
              var f = new Function ("event", 
417
                                    aElement.getAttribute("onsyncfrompreference"));
418
              rv = f.call(aElement, event);
419
            }
420
            catch (e) {
421
              Components.utils.reportError(e);
422
            }
423
          }
424
          var val = rv !== undefined ? rv : (this.instantApply ? this.valueFromPreferences : this.value);
425
          // if the preference is marked for reset, show default value in UI
426
          if (val === undefined)
427
            val = this.defaultValue;
428
429
          /**
430
           * Initialize a UI element property with a value. Handles the case 
431
           * where an element has not yet had a XBL binding attached for it and
432
           * the property setter does not yet exist by setting the same attribute
433
           * on the XUL element using DOM apis and assuming the element's 
434
           * constructor or property getters appropriately handle this state. 
435
           */
436
          function setValue(element, attribute, value) {
437
            if (attribute in element) 
438
              element[attribute] = value;
439
            else
440
              element.setAttribute(attribute, value);
441
          }
442
          if (aElement.localName == "checkbox" ||
443
              aElement.localName == "listitem")
444
            setValue(aElement, "checked", val);
445
          else if (aElement.localName == "colorpicker")
446
            setValue(aElement, "color", val);
447
          else if (aElement.localName == "textbox") {
448
            // XXXmano Bug 303998: Avoid a caret placement issue if either the
449
            // preference observer or its setter calls updateElements as a result
450
            // of the input event handler.
451
            if (aElement.value !== val)
452
              setValue(aElement, "value", val);
453
          }
454
          else
455
            setValue(aElement, "value", val);
456
        ]]>
457
        </body>
458
      </method>
459
460
      <method name="getElementValue">
461
        <parameter name="aElement"/>
462
        <body>
463
        <![CDATA[
464
          if (aElement.hasAttribute("onsynctopreference")) {
465
            // Value changed, synthesize an event
466
            try {
467
              var event = document.createEvent("Events");
468
              event.initEvent("synctopreference", true, true);
469
              var f = new Function ("event", 
470
                                    aElement.getAttribute("onsynctopreference"));
471
              var rv = f.call(aElement, event);
472
              if (rv !== undefined) 
473
                return rv;
474
            }
475
            catch (e) {
476
              Components.utils.reportError(e);
477
            }
478
          }
479
          
480
          /**
481
           * Read the value of an attribute from an element, assuming the 
482
           * attribute is a property on the element's node API. If the property
483
           * is not present in the API, then assume its value is contained in
484
           * an attribute, as is the case before a binding has been attached.
485
           */
486
          function getValue(element, attribute) {
487
            if (attribute in element)
488
              return element[attribute];
489
            return element.getAttribute(attribute);
490
          }
491
          if (aElement.localName == "checkbox" ||
492
              aElement.localName == "listitem")
493
            var value = getValue(aElement, "checked");
494
          else if (aElement.localName == "colorpicker")
495
            value = getValue(aElement, "color");
496
          else
497
            value = getValue(aElement, "value");
498
499
          switch (this.type) {
500
          case "int":
501
            return parseInt(value, 10) || 0;
502
          case "bool":
503
            return typeof(value) == "boolean" ? value : value == "true";
504
          }
505
          return value;
506
        ]]>
507
        </body>
508
      </method>
509
      
510
      <method name="isElementEditable">
511
        <parameter name="aElement"/>
512
        <body>
513
        <![CDATA[
514
          switch (aElement.localName) {
515
          case "checkbox":
516
          case "colorpicker":
517
          case "radiogroup":
518
          case "textbox":
519
          case "listitem":
520
          case "listbox":
521
          case "menulist":
522
            return true;
523
          }
524
          return aElement.getAttribute("preference-editable") == "true";
525
        ]]> 
526
        </body>
527
      </method>
528
      
529
      <method name="updateElements">
530
        <body>
531
        <![CDATA[
532
          if (!this.id)
533
            return;
534
535
          // This "change" event handler tracks changes made to preferences by 
536
          // sources other than the user in this window. 
537
          var elements = document.getElementsByAttribute("preference", this.id);
538
          for (var i = 0; i < elements.length; ++i) 
539
            this.setElementValue(elements[i]);
540
        ]]>
541
        </body>
542
      </method>
543
    </implementation>
544
    
545
    <handlers>
546
      <handler event="change">
547
        this.updateElements();
548
      </handler>
549
    </handlers>
550
  </binding>
551
552
  <binding id="prefwindow"
553
           extends="chrome://global/content/bindings/dialog.xml#dialog">
554
    <resources>
555
      <stylesheet src="chrome://global/skin/preferences.css"/>
556
    </resources>
557
    <content dlgbuttons="accept,cancel" persist="lastSelected screenX screenY"
558
             closebuttonlabel="&preferencesCloseButton.label;"
559
             closebuttonaccesskey="&preferencesCloseButton.accesskey;"
560
             role="dialog"
561
#ifdef XP_WIN
562
             title="&preferencesDefaultTitleWin.title;">
563
#else
564
             title="&preferencesDefaultTitleMac.title;">
565
#endif
566
      <xul:windowdragbox orient="vertical">
567
        <xul:radiogroup anonid="selector" orient="horizontal" class="paneSelector chromeclass-toolbar"
568
                        role="listbox"/> <!-- Expose to accessibility APIs as a listbox -->
569
      </xul:windowdragbox>
570
      <xul:hbox flex="1" class="paneDeckContainer">
571
        <xul:deck anonid="paneDeck" flex="1">
572
          <children includes="prefpane"/>
573
        </xul:deck>
574
      </xul:hbox>
575
      <xul:hbox anonid="dlg-buttons" class="prefWindow-dlgbuttons"
576
#ifdef XP_UNIX_GNOME
577
                >
578
        <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
579
        <xul:button dlgtype="help" class="dialog-button" hidden="true" icon="help"/>
580
        <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
581
        <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
582
        <xul:spacer anonid="spacer" flex="1"/>
583
        <xul:button dlgtype="cancel" class="dialog-button" icon="cancel"/>
584
        <xul:button dlgtype="accept" class="dialog-button" icon="accept"/>
585
#elif XP_UNIX
586
                pack="end">
587
	<xul:button dlgtype="help" class="dialog-button" hidden="true" icon="help"/>
588
	<xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
589
	<xul:spacer anonid="spacer" flex="1"/>
590
	<xul:button dlgtype="accept" class="dialog-button" icon="accept"/>
591
	<xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
592
	<xul:button dlgtype="cancel" class="dialog-button" icon="cancel"/>
593
	<xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
594
#else
595
                pack="end">
596
        <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
597
        <xul:spacer anonid="spacer" flex="1"/>
598
        <xul:button dlgtype="accept" class="dialog-button" icon="accept"/>
599
        <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
600
        <xul:button dlgtype="cancel" class="dialog-button" icon="cancel"/>
601
        <xul:button dlgtype="help" class="dialog-button" hidden="true" icon="help"/>
602
        <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
603
#endif
604
      </xul:hbox>
605
      <xul:hbox>
606
        <children/>
607
      </xul:hbox>
608
    </content>
609
    <implementation implements="nsITimerCallback">
610
      <constructor>
611
      <![CDATA[
612
        if (this.type != "child") {
613
          var psvc = Components.classes["@mozilla.org/preferences-service;1"]
614
                               .getService(Components.interfaces.nsIPrefBranch);
615
          this.instantApply = psvc.getBoolPref("browser.preferences.instantApply");
616
          if (this.instantApply) {
617
            var docElt = document.documentElement;
618
            var acceptButton = docElt.getButton("accept");
619
            acceptButton.hidden = true;
620
            var cancelButton  = docElt.getButton("cancel");
621
#ifdef XP_MACOSX
622
            // no buttons on Mac except Help
623
            cancelButton.hidden = true;
624
            // Also, don't fire onDialogAccept on enter
625
            acceptButton.disabled = true;
626
#else
627
            // morph the Cancel button into the Close button
628
            cancelButton.setAttribute ("icon", "close");
629
            cancelButton.label = docElt.getAttribute("closebuttonlabel");
630
            cancelButton.accesskey = docElt.getAttribute("closebuttonaccesskey");
631
#endif
632
          }
633
        }
634
        this.setAttribute("animated", this._shouldAnimate ? "true" : "false");
635
        var panes = this.preferencePanes;
636
637
        var lastPane = null;
638
        if (this.lastSelected) {
639
          lastPane = document.getElementById(this.lastSelected);
640
          if (!lastPane) {
641
            this.lastSelected = "";
642
          }
643
        }
644
645
        var paneToLoad;
646
        if ("arguments" in window && window.arguments[0] && document.getElementById(window.arguments[0]) && document.getElementById(window.arguments[0]).nodeName == "prefpane") {
647
          paneToLoad = document.getElementById(window.arguments[0]);
648
          this.lastSelected = paneToLoad.id;
649
        }
650
        else if (lastPane)
651
          paneToLoad = lastPane;
652
        else
653
          paneToLoad = panes[0];
654
655
        for (var i = 0; i < panes.length; ++i) {
656
          this._makePaneButton(panes[i]);
657
          if (panes[i].loaded) {
658
            // Inline pane content, fire load event to force initialization.
659
            this._fireEvent("paneload", panes[i]);
660
          }
661
        }
662
        this.showPane(paneToLoad);
663
664
        if (panes.length == 1)
665
          this._selector.setAttribute("collapsed", "true");
666
      ]]>
667
      </constructor>
668
669
      <destructor>
670
      <![CDATA[
671
        // Release timers to avoid reference cycles.
672
        if (this._animateTimer) {
673
          this._animateTimer.cancel();
674
          this._animateTimer = null;
675
        }
676
        if (this._fadeTimer) {
677
          this._fadeTimer.cancel();
678
          this._fadeTimer = null;
679
        }
680
      ]]>
681
      </destructor>
682
683
      <field name="instantApply">false</field>
684
      
685
      <property name="preferencePanes"
686
                onget="return this.getElementsByTagName('prefpane');"/>
687
688
      <property name="type" onget="return this.getAttribute('type');"/>
689
      <property name="_paneDeck"
690
                onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'paneDeck');"/>
691
      <property name="_paneDeckContainer"
692
                onget="return document.getAnonymousElementByAttribute(this, 'class', 'paneDeckContainer');"/>
693
      <property name="_selector"
694
                onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'selector');"/>
695
      <property name="lastSelected" 
696
                onget="return this.getAttribute('lastSelected');">
697
        <setter>
698
          this.setAttribute("lastSelected", val); 
699
          document.persist(this.id, "lastSelected");
700
          return val;
701
        </setter>          
702
      </property>
703
      <property name="currentPane"
704
                onset="return this._currentPane = val;">
705
        <getter>
706
          if (!this._currentPane)
707
            this._currentPane = this.preferencePanes[0];
708
          
709
          return this._currentPane;
710
        </getter> 
711
      </property>
712
      <field name="_currentPane">null</field>
713
      
714
      
715
      <method name="_makePaneButton">
716
        <parameter name="aPaneElement"/>
717
        <body>
718
        <![CDATA[
719
          var radio = document.createElement("radio");
720
          radio.setAttribute("pane", aPaneElement.id);
721
          radio.setAttribute("label", aPaneElement.label);
722
          // Expose preference group choice to accessibility APIs as an unchecked list item
723
          // The parent group is exposed to accessibility APIs as a list
724
          if (aPaneElement.image)
725
            radio.setAttribute("src", aPaneElement.image);
726
          radio.style.listStyleImage = aPaneElement.style.listStyleImage;
727
          this._selector.appendChild(radio);
728
          return radio;
729
        ]]>
730
        </body>
731
      </method>
732
733
      <method name="showPane">
734
        <parameter name="aPaneElement"/>
735
        <body>
736
        <![CDATA[
737
          if (!aPaneElement)
738
            return;
739
740
          this._selector.selectedItem = document.getAnonymousElementByAttribute(this, "pane", aPaneElement.id);
741
          if (!aPaneElement.loaded) {
742
            function OverlayLoadObserver(aPane)
743
            {
744
              this._pane = aPane;
745
            }
746
            OverlayLoadObserver.prototype = { 
747
              _outer: this,
748
              observe: function (aSubject, aTopic, aData) 
749
              {
750
                this._pane.loaded = true;
751
                this._outer._fireEvent("paneload", this._pane);
752
                this._outer._selectPane(this._pane);
753
              }
754
            };
755
            
756
            var obs = new OverlayLoadObserver(aPaneElement);
757
            document.loadOverlay(aPaneElement.src, obs);
758
          }
759
          else
760
            this._selectPane(aPaneElement);
761
        ]]>
762
        </body>
763
      </method>
764
      
765
      <method name="_fireEvent">
766
        <parameter name="aEventName"/>
767
        <parameter name="aTarget"/>
768
        <body>
769
        <![CDATA[
770
          // Panel loaded, synthesize a load event. 
771
          try {
772
            var event = document.createEvent("Events");
773
            event.initEvent(aEventName, true, true);
774
            var cancel = !aTarget.dispatchEvent(event);
775
            if (aTarget.hasAttribute("on" + aEventName)) {
776
              var fn = new Function ("event", aTarget.getAttribute("on" + aEventName));
777
              var rv = fn.call(aTarget, event);
778
              if (rv == false)
779
                cancel = true;
780
            }
781
            return !cancel;  
782
          }
783
          catch (e) { 
784
            Components.utils.reportError(e);
785
          }
786
          return false;
787
        ]]>
788
        </body>
789
      </method>
790
      
791
      <field name="_initialized">false</field>
792
      <method name="_selectPane">
793
        <parameter name="aPaneElement"/>
794
        <body>
795
        <![CDATA[
796
#ifdef XP_MACOSX
797
          var paneTitle = aPaneElement.label;
798
          if (paneTitle != "")
799
            document.title = paneTitle;
800
#endif
801
          var helpButton = document.documentElement.getButton("help");
802
          if (aPaneElement.helpTopic)
803
            helpButton.hidden = false;
804
          else
805
            helpButton.hidden = true;
806
807
          // Find this pane's index in the deck and set the deck's 
808
          // selectedIndex to that value to switch to it.
809
          var prefpanes = this.preferencePanes;
810
          for (var i = 0; i < prefpanes.length; ++i) {
811
            if (prefpanes[i] == aPaneElement) {
812
              this._paneDeck.selectedIndex = i;
813
              
814
              if (this.type != "child") {
815
                if (aPaneElement.hasAttribute("flex") && this._shouldAnimate &&
816
                    prefpanes.length > 1)
817
                  aPaneElement.removeAttribute("flex");
818
                // Calling sizeToContent after the first prefpane is loaded
819
                // will size the windows contents so style information is
820
                // available to calculate correct sizing.
821
                if (!this._initialized && prefpanes.length > 1) {
822
                  if (this._shouldAnimate)
823
                    this.style.minHeight = 0;
824
                  window.sizeToContent();
825
                }
826
827
                var oldPane = this.lastSelected ? document.getElementById(this.lastSelected) : this.preferencePanes[0];
828
                oldPane.selected = !(aPaneElement.selected = true);
829
                this.lastSelected = aPaneElement.id;
830
                this.currentPane = aPaneElement;
831
                this._initialized = true;
832
833
                // Only animate if we've switched between prefpanes
834
                if (this._shouldAnimate && oldPane.id != aPaneElement.id) {
835
                  aPaneElement.style.opacity = 0.0;
836
                  this.animate(oldPane, aPaneElement);
837
                }
838
                else if (!this._shouldAnimate && prefpanes.length > 1) {
839
                  var targetHeight = parseInt(window.getComputedStyle(this._paneDeckContainer, "").height);
840
                  var verticalPadding = parseInt(window.getComputedStyle(aPaneElement, "").paddingTop);
841
                  verticalPadding += parseInt(window.getComputedStyle(aPaneElement, "").paddingBottom);
842
                  if (aPaneElement.contentHeight > targetHeight - verticalPadding) {
843
                    // To workaround the bottom border of a groupbox from being
844
                    // cutoff an hbox with a class of bottomBox may enclose it.
845
                    // This needs to include its padding to resize properly.
846
                    // See bug 394433
847
                    var bottomPadding = 0;
848
                    var bottomBox = aPaneElement.getElementsByAttribute("class", "bottomBox")[0];
849
                    if (bottomBox)
850
                      bottomPadding = parseInt(window.getComputedStyle(bottomBox, "").paddingBottom);
851
                    window.innerHeight += bottomPadding + verticalPadding + aPaneElement.contentHeight - targetHeight;
852
                  }
853
854
                  // XXX rstrong - extend the contents of the prefpane to
855
                  // prevent elements from being cutoff (see bug 349098).
856
                  if (aPaneElement.contentHeight + verticalPadding < targetHeight)
857
                    aPaneElement._content.style.height = targetHeight - verticalPadding + "px";
858
                }
859
              }
860
              break;
861
            }
862
          }
863
        ]]>
864
        </body>
865
      </method>
866
      
867
      <property name="_shouldAnimate">
868
        <getter>
869
        <![CDATA[
870
          var psvc = Components.classes["@mozilla.org/preferences-service;1"]
871
                               .getService(Components.interfaces.nsIPrefBranch);
872
#ifdef XP_MACOSX
873
          var animate = true;
874
#else
875
          var animate = false;
876
#endif
877
          try {
878
            animate = psvc.getBoolPref("browser.preferences.animateFadeIn");
879
          }
880
          catch (e) { }
881
          return animate;
882
        ]]>
883
        </getter>
884
      </property>
885
      
886
      <method name="animate">
887
        <parameter name="aOldPane"/>
888
        <parameter name="aNewPane"/>
889
        <body>
890
        <![CDATA[
891
          // if we are already resizing, use currentHeight
892
          var oldHeight = this._currentHeight ? this._currentHeight : aOldPane.contentHeight;
893
          
894
          this._multiplier = aNewPane.contentHeight > oldHeight ? 1 : -1;
895
          var sizeDelta = Math.abs(oldHeight - aNewPane.contentHeight);
896
          this._animateRemainder = sizeDelta % this._animateIncrement;
897
898
          this._setUpAnimationTimer(oldHeight);
899
        ]]>
900
        </body>
901
      </method>
902
      
903
      <property name="_sizeIncrement">
904
        <getter>
905
        <![CDATA[
906
          var lastSelectedPane = document.getElementById(this.lastSelected);
907
          var increment = this._animateIncrement * this._multiplier;
908
          var newHeight = this._currentHeight + increment;
909
          if ((this._multiplier > 0 && this._currentHeight >= lastSelectedPane.contentHeight) ||
910
              (this._multiplier < 0 && this._currentHeight <= lastSelectedPane.contentHeight))
911
            return 0;
912
          
913
          if ((this._multiplier > 0 && newHeight > lastSelectedPane.contentHeight) ||
914
              (this._multiplier < 0 && newHeight < lastSelectedPane.contentHeight))
915
            increment = this._animateRemainder * this._multiplier;
916
          return increment;
917
        ]]>
918
        </getter>
919
      </property>
920
      
921
      <method name="notify">
922
        <parameter name="aTimer"/>
923
        <body>
924
        <![CDATA[
925
          if (!document)
926
            aTimer.cancel();
927
          
928
          if (aTimer == this._animateTimer) {
929
            var increment = this._sizeIncrement;
930
            if (increment != 0) {
931
              window.innerHeight += increment;
932
              this._currentHeight += increment;
933
            }
934
            else {
935
              aTimer.cancel();
936
              this._setUpFadeTimer();
937
            }
938
          } else if (aTimer == this._fadeTimer) {
939
            var elt = document.getElementById(this.lastSelected);
940
            var newOpacity = parseFloat(window.getComputedStyle(elt, "").opacity) + this._fadeIncrement;
941
            if (newOpacity < 1.0)
942
              elt.style.opacity = newOpacity;
943
            else {
944
              aTimer.cancel();
945
              elt.style.opacity = 1.0;
946
            }
947
          }
948
        ]]>
949
        </body>
950
      </method>
951
      
952
      <method name="_setUpAnimationTimer">
953
        <parameter name="aStartHeight"/>
954
        <body>
955
        <![CDATA[
956
          if (!this._animateTimer) 
957
            this._animateTimer = Components.classes["@mozilla.org/timer;1"]
958
                                           .createInstance(Components.interfaces.nsITimer);
959
          else
960
            this._animateTimer.cancel();
961
          this._currentHeight = aStartHeight;
962
          
963
          this._animateTimer.initWithCallback(this, this._animateDelay, 
964
                                              Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
965
        ]]>
966
        </body>
967
      </method>
968
      
969
      <method name="_setUpFadeTimer">
970
        <body>
971
        <![CDATA[
972
          if (!this._fadeTimer) 
973
            this._fadeTimer = Components.classes["@mozilla.org/timer;1"]
974
                                        .createInstance(Components.interfaces.nsITimer);
975
          else
976
            this._fadeTimer.cancel();
977
          
978
          this._fadeTimer.initWithCallback(this, this._fadeDelay, 
979
                                           Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
980
        ]]>
981
        </body>
982
      </method>
983
      
984
      <field name="_animateTimer">null</field>
985
      <field name="_fadeTimer">null</field>
986
      <field name="_animateDelay">15</field>
987
      <field name="_animateIncrement">40</field>
988
      <field name="_fadeDelay">5</field>
989
      <field name="_fadeIncrement">0.40</field>
990
      <field name="_animateRemainder">0</field>
991
      <field name="_currentHeight">0</field>
992
      <field name="_multiplier">0</field>
993
994
      <method name="addPane">
995
        <parameter name="aPaneElement"/>
996
        <body>
997
        <![CDATA[
998
          this.appendChild(aPaneElement);
999
          
1000
          // Set up pane button
1001
          this._makePaneButton(aPaneElement);
1002
        ]]>
1003
        </body>
1004
      </method>
1005
      
1006
      <method name="openSubDialog">
1007
        <parameter name="aURL"/>
1008
        <parameter name="aFeatures"/>
1009
        <parameter name="aParams"/>
1010
        <body>
1011
          return openDialog(aURL, "", "modal,centerscreen,resizable=no" + (aFeatures != "" ? ("," + aFeatures) : ""), aParams);
1012
        </body>
1013
      </method>
1014
      
1015
      <method name="openWindow">
1016
        <parameter name="aWindowType"/>
1017
        <parameter name="aURL"/>
1018
        <parameter name="aFeatures"/>
1019
        <parameter name="aParams"/>
1020
        <body>
1021
        <![CDATA[
1022
          var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
1023
                             .getService(Components.interfaces.nsIWindowMediator);
1024
          var win = aWindowType ? wm.getMostRecentWindow(aWindowType) : null;
1025
          if (win) {
1026
            if ("initWithParams" in win)
1027
              win.initWithParams(aParams);
1028
            win.focus();
1029
          }
1030
          else {
1031
            var features = "resizable,dialog=no,centerscreen" + (aFeatures != "" ? ("," + aFeatures) : "");
1032
            var parentWindow = (this.instantApply || !window.opener || window.opener.closed) ? window : window.opener;
1033
            win = parentWindow.openDialog(aURL, "_blank", features, aParams);
1034
          }
1035
          return win;
1036
        ]]>
1037
        </body>
1038
      </method>
1039
    </implementation>
1040
    <handlers>
1041
      <handler event="dialogaccept">
1042
      <![CDATA[
1043
        if (!this._fireEvent("beforeaccept", this)) 
1044
          return;
1045
        
1046
        if (this.type == "child" && window.opener) {
1047
          var psvc = Components.classes["@mozilla.org/preferences-service;1"]
1048
                               .getService(Components.interfaces.nsIPrefBranch);
1049
          var instantApply = psvc.getBoolPref("browser.preferences.instantApply");
1050
          if (instantApply) {
1051
            var panes = this.preferencePanes;
1052
            for (var i = 0; i < panes.length; ++i)
1053
              panes[i].writePreferences(true);
1054
          }
1055
          else {
1056
            // Clone all the preferences elements from the child document and
1057
            // insert them into the pane collection of the parent. 
1058
            var pdoc = window.opener.document;
1059
            if (pdoc.documentElement.localName == "prefwindow") {
1060
              var currentPane = pdoc.documentElement.currentPane;
1061
              var id = window.location.href + "#childprefs";
1062
              var childPrefs = pdoc.getElementById(id);
1063
              if (!childPrefs) {
1064
                var childPrefs = pdoc.createElement("preferences");
1065
                currentPane.appendChild(childPrefs);
1066
                childPrefs.id = id;
1067
              }
1068
              var panes = this.preferencePanes;
1069
              for (var i = 0; i < panes.length; ++i) {
1070
                var preferences = panes[i].preferences;
1071
                for (var j = 0; j < preferences.length; ++j) {
1072
                  // Try to find a preference element for the same preference.
1073
                  var preference = null;
1074
                  var parentPreferences = pdoc.getElementsByTagName("preferences");
1075
                  for (var k = 0; (k < parentPreferences.length && !preference); ++k) {
1076
                    var parentPrefs = parentPreferences[k]
1077
                                         .getElementsByAttribute("name", preferences[j].name);
1078
                    for (var l = 0; (l < parentPrefs.length && !preference); ++l) {
1079
                      if (parentPrefs[l].localName == "preference")
1080
                        preference = parentPrefs[l];
1081
                    }
1082
                  }
1083
                  if (!preference) {
1084
                    // No matching preference in the parent window.
1085
                    preference = pdoc.createElement("preference");
1086
                    childPrefs.appendChild(preference);
1087
                    preference.name     = preferences[j].name;
1088
                    preference.type     = preferences[j].type;
1089
                    preference.inverted = preferences[j].inverted;
1090
                    preference.readonly = preferences[j].readonly;
1091
                    preference.disabled = preferences[j].disabled;
1092
                  }
1093
                  preference.value = preferences[j].value;
1094
                }
1095
              }
1096
            }
1097
          }
1098
        }
1099
        else {
1100
          var panes = this.preferencePanes;
1101
          for (var i = 0; i < panes.length; ++i)
1102
            panes[i].writePreferences(false);
1103
1104
          var psvc = Components.classes["@mozilla.org/preferences-service;1"]
1105
                               .getService(Components.interfaces.nsIPrefService);
1106
          psvc.savePrefFile(null);
1107
        }
1108
      ]]>
1109
      </handler>
1110
      <handler event="command">
1111
        if (event.originalTarget.hasAttribute("pane")) {
1112
          var pane = document.getElementById(event.originalTarget.getAttribute("pane"));
1113
          this.showPane(pane);
1114
        }
1115
      </handler>
1116
1117
      <handler event="keypress" key="&windowClose.key;" modifiers="accel" phase="capturing">
1118
      <![CDATA[
1119
        if (this.instantApply)
1120
          window.close();
1121
        event.stopPropagation();
1122
        event.preventDefault();
1123
      ]]>
1124
      </handler>
1125
1126
      <handler event="keypress"
1127
#ifdef XP_MACOSX
1128
               key="&openHelpMac.commandkey;" modifiers="accel"
1129
#else
1130
               keycode="&openHelp.commandkey;"
1131
#endif
1132
               phase="capturing">
1133
      <![CDATA[
1134
        var helpButton = this.getButton("help");
1135
        if (helpButton.disabled || helpButton.hidden)
1136
          return;
1137
        this._fireEvent("dialoghelp", this);
1138
        event.stopPropagation();
1139
        event.preventDefault();
1140
      ]]>
1141
      </handler>
1142
    </handlers>
1143
  </binding>
1144
  
1145
  <binding id="prefpane">
1146
    <resources>
1147
      <stylesheet src="chrome://global/skin/preferences.css"/>
1148
    </resources>
1149
    <content>
1150
      <xul:vbox class="content-box" xbl:inherits="flex">
1151
        <children/>
1152
      </xul:vbox>
1153
    </content>
1154
    <implementation>
1155
      <method name="writePreferences">
1156
        <parameter name="aFlushToDisk"/>
1157
        <body>
1158
        <![CDATA[
1159
          // Write all values to preferences.
1160
          var preferences = this.preferences;
1161
          for (var i = 0; i < preferences.length; ++i) {
1162
            var preference = preferences[i];
1163
            preference.batching = true;
1164
            preference.valueFromPreferences = preference.value;
1165
            preference.batching = false;
1166
          }
1167
          if (aFlushToDisk) {
1168
            var psvc = Components.classes["@mozilla.org/preferences-service;1"]
1169
                                 .getService(Components.interfaces.nsIPrefService);
1170
            psvc.savePrefFile(null);
1171
          }
1172
        ]]>
1173
        </body>
1174
      </method>
1175
      
1176
      <property name="src" 
1177
                onget="return this.getAttribute('src');"
1178
                onset="this.setAttribute('src', val); return val;"/>
1179
      <property name="selected" 
1180
                onget="return this.getAttribute('selected') == 'true';"
1181
                onset="this.setAttribute('selected', val); return val;"/>
1182
      <property name="image" 
1183
                onget="return this.getAttribute('image');"
1184
                onset="this.setAttribute('image', val); return val;"/>
1185
      <property name="label" 
1186
                onget="return this.getAttribute('label');"
1187
                onset="this.setAttribute('label', val); return val;"/>
1188
      
1189
      <property name="preferenceElements"
1190
                onget="return this.getElementsByAttribute('preference', '*');"/>
1191
      <property name="preferences"
1192
                onget="return this.getElementsByTagName('preference');"/>
1193
1194
      <property name="helpTopic">
1195
        <getter>
1196
        <![CDATA[
1197
          // if there are tabs, and the selected tab provides a helpTopic, return that
1198
          var box = this.getElementsByTagName("tabbox");
1199
          if (box[0]) {
1200
            var tab = box[0].selectedTab;
1201
            if (tab && tab.hasAttribute("helpTopic"))
1202
              return tab.getAttribute("helpTopic");
1203
          }
1204
1205
          // otherwise, return the helpTopic of the current panel
1206
          return this.getAttribute("helpTopic");
1207
        ]]>
1208
        </getter>
1209
      </property>
1210
1211
      <field name="_loaded">false</field>
1212
      <property name="loaded" 
1213
                onget="return !this.src ? true : this._loaded;"
1214
                onset="this._loaded = val; return val;"/>
1215
      
1216
      <method name="preferenceForElement">
1217
        <parameter name="aElement"/>
1218
        <body>
1219
          return document.getElementById(aElement.getAttribute("preference"));
1220
        </body>
1221
      </method>
1222
      
1223
      <method name="getPreferenceElement">
1224
        <parameter name="aStartElement"/>
1225
        <body>
1226
        <![CDATA[
1227
          var temp = aStartElement;
1228
          while (temp && temp.nodeType == Node.ELEMENT_NODE && 
1229
                 !temp.hasAttribute("preference"))
1230
            temp = temp.parentNode;
1231
          return temp.nodeType == Node.ELEMENT_NODE ? temp : aStartElement;
1232
        ]]>
1233
        </body>
1234
      </method>
1235
      
1236
      <method name="userChangedValue">
1237
        <parameter name="aElement"/>
1238
        <body>
1239
        <![CDATA[
1240
          var element = this.getPreferenceElement(aElement);
1241
          if (element.hasAttribute("preference")) {
1242
            var preference = document.getElementById(element.getAttribute("preference"));
1243
            var prefVal = preference.getElementValue(element);
1244
            preference.value = prefVal;
1245
          }
1246
        ]]>
1247
        </body>
1248
      </method>
1249
      
1250
      <property name="contentHeight">
1251
        <getter>
1252
          var targetHeight = parseInt(window.getComputedStyle(this._content, "").height);
1253
          targetHeight += parseInt(window.getComputedStyle(this._content, "").marginTop);
1254
          targetHeight += parseInt(window.getComputedStyle(this._content, "").marginBottom);
1255
          return targetHeight;
1256
        </getter>
1257
      </property>
1258
      <field name="_content">
1259
        document.getAnonymousElementByAttribute(this, "class", "content-box");
1260
      </field>
1261
    </implementation>
1262
    <handlers>
1263
      <handler event="command">
1264
        // This "command" event handler tracks changes made to preferences by 
1265
        // the user in this window.
1266
        if (event.sourceEvent)
1267
          event = event.sourceEvent;
1268
        this.userChangedValue(event.target);
1269
      </handler>
1270
      <handler event="select">
1271
        // This "select" event handler tracks changes made to colorpicker 
1272
        // preferences by the user in this window.
1273
        if (event.target.localName == "colorpicker") 
1274
          this.userChangedValue(event.target);
1275
      </handler>
1276
      <handler event="change">
1277
        // This "change" event handler tracks changes made to preferences by 
1278
        // the user in this window. 
1279
        this.userChangedValue(event.target);
1280
      </handler>
1281
      <handler event="input">
1282
        // This "input" event handler tracks changes made to preferences by 
1283
        // the user in this window.
1284
        this.userChangedValue(event.target);
1285
      </handler>
1286
      <handler event="paneload">
1287
      <![CDATA[
1288
        // Initialize all values from preferences.
1289
        var elements = this.preferenceElements;
1290
        for (var i = 0; i < elements.length; ++i) {
1291
          try {
1292
            var preference = this.preferenceForElement(elements[i]);
1293
            preference.setElementValue(elements[i]);
1294
          }
1295
          catch (e) {
1296
            dump("*** No preference found for " + elements[i].getAttribute("preference") + "\n");
1297
          }
1298
        }
1299
      ]]>      
1300
      </handler>
1301
    </handlers>
1302
  </binding>
1303
          
1304
  <binding id="panebutton" extends="chrome://global/content/bindings/radio.xml#radio">
1305
    <resources>
1306
      <stylesheet src="chrome://global/skin/preferences.css"/>
1307
    </resources>
1308
    <content>
1309
      <xul:image class="paneButtonIcon" xbl:inherits="src"/>
1310
      <xul:label class="paneButtonLabel" xbl:inherits="value=label"/>
1311
    </content>
1312
    <implementation implements="nsIAccessible">
1313
      <property name="accessibleType" readonly="true">
1314
        <getter>
1315
          <![CDATA[
1316
            return Components.interfaces.nsIAccessibleProvider.XULListitem;
1317
          ]]>
1318
        </getter>
1319
      </property>
1320
    </implementation>
1321
  </binding>
1322
1323
</bindings>
1324
1325
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
1326
# This Source Code Form is subject to the terms of the Mozilla Public
1327
# License, v. 2.0. If a copy of the MPL was not distributed with this
1328
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
1329
1330
#
1331
# This is PrefWindow 6. The Code Could Well Be Ready, Are You?
1332
#
1333
#    Historical References:
1334
#    PrefWindow V   (February 1, 2003)
1335
#    PrefWindow IV  (April 24, 2000)
1336
#    PrefWindow III (January 6, 2000)
1337
#    PrefWindow II  (???)
1338
#    PrefWindow I   (June 4, 1999)
1339
#
(-)a/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp (+32 lines)
Lines 14-29 Link Here
14
#include "prenv.h"
14
#include "prenv.h"
15
#include "nsPrintfCString.h"
15
#include "nsPrintfCString.h"
16
#include "nsNetUtil.h"
16
#include "nsNetUtil.h"
17
#include "nsISupportsPrimitives.h"
17
#include "nsISupportsPrimitives.h"
18
#include "nsIGSettingsService.h"
18
#include "nsIGSettingsService.h"
19
#include "nsInterfaceHashtable.h"
19
#include "nsInterfaceHashtable.h"
20
#include "mozilla/Attributes.h"
20
#include "mozilla/Attributes.h"
21
#include "nsIURI.h"
21
#include "nsIURI.h"
22
#include "nsVoidArray.h"
23
#include "nsKDEUtils.h"
22
24
23
class nsUnixSystemProxySettings MOZ_FINAL : public nsISystemProxySettings {
25
class nsUnixSystemProxySettings MOZ_FINAL : public nsISystemProxySettings {
24
public:
26
public:
25
  NS_DECL_ISUPPORTS
27
  NS_DECL_ISUPPORTS
26
  NS_DECL_NSISYSTEMPROXYSETTINGS
28
  NS_DECL_NSISYSTEMPROXYSETTINGS
27
29
28
  nsUnixSystemProxySettings() {}
30
  nsUnixSystemProxySettings() {}
29
  nsresult Init();
31
  nsresult Init();
Lines 35-50 private: Link Here
35
  nsCOMPtr<nsIGSettingsService> mGSettings;
37
  nsCOMPtr<nsIGSettingsService> mGSettings;
36
  nsCOMPtr<nsIGSettingsCollection> mProxySettings;
38
  nsCOMPtr<nsIGSettingsCollection> mProxySettings;
37
  nsInterfaceHashtable<nsCStringHashKey, nsIGSettingsCollection> mSchemeProxySettings;
39
  nsInterfaceHashtable<nsCStringHashKey, nsIGSettingsCollection> mSchemeProxySettings;
38
  bool IsProxyMode(const char* aMode);
40
  bool IsProxyMode(const char* aMode);
39
  nsresult SetProxyResultFromGConf(const char* aKeyBase, const char* aType, nsACString& aResult);
41
  nsresult SetProxyResultFromGConf(const char* aKeyBase, const char* aType, nsACString& aResult);
40
  nsresult GetProxyFromGConf(const nsACString& aScheme, const nsACString& aHost, int32_t aPort, nsACString& aResult);
42
  nsresult GetProxyFromGConf(const nsACString& aScheme, const nsACString& aHost, int32_t aPort, nsACString& aResult);
41
  nsresult GetProxyFromGSettings(const nsACString& aScheme, const nsACString& aHost, int32_t aPort, nsACString& aResult);
43
  nsresult GetProxyFromGSettings(const nsACString& aScheme, const nsACString& aHost, int32_t aPort, nsACString& aResult);
42
  nsresult SetProxyResultFromGSettings(const char* aKeyBase, const char* aType, nsACString& aResult);
44
  nsresult SetProxyResultFromGSettings(const char* aKeyBase, const char* aType, nsACString& aResult);
45
  nsresult GetProxyFromKDE(const nsACString& aScheme, const nsACString& aHost, PRInt32 aPort, nsACString& aResult);
43
};
46
};
44
47
45
NS_IMPL_ISUPPORTS1(nsUnixSystemProxySettings, nsISystemProxySettings)
48
NS_IMPL_ISUPPORTS1(nsUnixSystemProxySettings, nsISystemProxySettings)
46
49
47
NS_IMETHODIMP
50
NS_IMETHODIMP
48
nsUnixSystemProxySettings::GetMainThreadOnly(bool *aMainThreadOnly)
51
nsUnixSystemProxySettings::GetMainThreadOnly(bool *aMainThreadOnly)
49
{
52
{
50
  // dbus prevents us from being threadsafe, but this routine should not block anyhow
53
  // dbus prevents us from being threadsafe, but this routine should not block anyhow
Lines 496-511 nsUnixSystemProxySettings::GetProxyFromG Link Here
496
499
497
nsresult
500
nsresult
498
nsUnixSystemProxySettings::GetProxyForURI(const nsACString & aSpec,
501
nsUnixSystemProxySettings::GetProxyForURI(const nsACString & aSpec,
499
                                          const nsACString & aScheme,
502
                                          const nsACString & aScheme,
500
                                          const nsACString & aHost,
503
                                          const nsACString & aHost,
501
                                          const int32_t      aPort,
504
                                          const int32_t      aPort,
502
                                          nsACString & aResult)
505
                                          nsACString & aResult)
503
{
506
{
507
  if (nsKDEUtils::kdeSupport())
508
    return GetProxyFromKDE(aScheme, aHost, aPort, aResult);
509
504
  if (mProxySettings) {
510
  if (mProxySettings) {
505
    nsresult rv = GetProxyFromGSettings(aScheme, aHost, aPort, aResult);
511
    nsresult rv = GetProxyFromGSettings(aScheme, aHost, aPort, aResult);
506
    if (NS_SUCCEEDED(rv))
512
    if (NS_SUCCEEDED(rv))
507
      return rv;
513
      return rv;
508
  }
514
  }
509
  if (mGConf)
515
  if (mGConf)
510
    return GetProxyFromGConf(aScheme, aHost, aPort, aResult);
516
    return GetProxyFromGConf(aScheme, aHost, aPort, aResult);
511
517
Lines 531-538 static const mozilla::Module::ContractID Link Here
531
537
532
static const mozilla::Module kUnixProxyModule = {
538
static const mozilla::Module kUnixProxyModule = {
533
  mozilla::Module::kVersion,
539
  mozilla::Module::kVersion,
534
  kUnixProxyCIDs,
540
  kUnixProxyCIDs,
535
  kUnixProxyContracts
541
  kUnixProxyContracts
536
};
542
};
537
543
538
NSMODULE_DEFN(nsUnixProxyModule) = &kUnixProxyModule;
544
NSMODULE_DEFN(nsUnixProxyModule) = &kUnixProxyModule;
545
546
nsresult
547
nsUnixSystemProxySettings::GetProxyFromKDE(const nsACString& aScheme,
548
                                           const nsACString& aHost,
549
                                           PRInt32 aPort,
550
                                           nsACString& aResult)
551
{
552
  nsAutoCString url;
553
  url = aScheme;
554
  url += "://";
555
  url += aHost;
556
  if( aPort >= 0 )
557
  {
558
    url += ":";
559
    url += nsPrintfCString("%d", aPort);
560
  }
561
  nsTArray<nsCString> command;
562
  command.AppendElement( NS_LITERAL_CSTRING( "GETPROXY" ));
563
  command.AppendElement( url );
564
  nsTArray<nsCString> result;
565
  if( !nsKDEUtils::command( command, &result ) || result.Length() != 1 )
566
    return NS_ERROR_FAILURE;
567
  aResult = result[0];
568
  return NS_OK;
569
}
570
(-)a/toolkit/xre/moz.build (+2 lines)
Lines 38-55 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'qt Link Here
38
        'nsNativeAppSupportQt.cpp',
38
        'nsNativeAppSupportQt.cpp',
39
        'nsQAppInstance.cpp',
39
        'nsQAppInstance.cpp',
40
    ]
40
    ]
41
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'os2':
41
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'os2':
42
    CPP_SOURCES += [
42
    CPP_SOURCES += [
43
        'nsNativeAppSupportOS2.cpp',
43
        'nsNativeAppSupportOS2.cpp',
44
    ]
44
    ]
45
elif CONFIG['MOZ_ENABLE_GTK']:
45
elif CONFIG['MOZ_ENABLE_GTK']:
46
    EXPORTS += ['nsKDEUtils.h']
46
    CPP_SOURCES += [
47
    CPP_SOURCES += [
47
        'nsNativeAppSupportUnix.cpp',
48
        'nsNativeAppSupportUnix.cpp',
49
	'nsKDEUtils.cpp'
48
    ]
50
    ]
49
else:
51
else:
50
    CPP_SOURCES += [
52
    CPP_SOURCES += [
51
        'nsNativeAppSupportDefault.cpp',
53
        'nsNativeAppSupportDefault.cpp',
52
    ]
54
    ]
53
55
54
if CONFIG['MOZ_X11']:
56
if CONFIG['MOZ_X11']:
55
    CPP_SOURCES += [
57
    CPP_SOURCES += [
(-)a/toolkit/xre/nsKDEUtils.cpp (+339 lines)
Line 0 Link Here
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsKDEUtils.h"
7
#include "nsIWidget.h"
8
#include "nsISupportsPrimitives.h"
9
#include "nsIMutableArray.h"
10
#include "nsComponentManagerUtils.h"
11
#include "nsArrayUtils.h"
12
13
#include <gtk/gtk.h>
14
15
#include <limits.h>
16
#include <stdio.h>
17
#include <sys/wait.h>
18
#include <sys/resource.h>
19
#include <unistd.h>
20
#include <X11/Xlib.h>
21
22
//#define DEBUG_KDE
23
#ifdef DEBUG_KDE
24
#define KMOZILLAHELPER "kmozillahelper"
25
#else
26
// not need for lib64, it's a binary
27
#define KMOZILLAHELPER "/usr/lib/mozilla/kmozillahelper"
28
#endif
29
30
#define KMOZILLAHELPER_VERSION 6
31
#define MAKE_STR2( n ) #n
32
#define MAKE_STR( n ) MAKE_STR2( n )
33
34
static bool getKdeSession()
35
    {
36
    Display* dpy = XOpenDisplay( NULL );
37
    if( dpy == NULL )
38
        return false;
39
    Atom kde_full_session = XInternAtom( dpy, "KDE_FULL_SESSION", True );
40
    bool kde = false;
41
    if( kde_full_session != None )
42
        {
43
        int cnt;
44
        if( Atom* props = XListProperties( dpy, DefaultRootWindow( dpy ), &cnt ))
45
            {
46
            for( int i = 0;
47
                 i < cnt;
48
                 ++i )
49
                {
50
                if( props[ i ] == kde_full_session )
51
                    {
52
                    kde = true;
53
#ifdef DEBUG_KDE
54
                    fprintf( stderr, "KDE SESSION %d\n", kde );
55
#endif
56
                    break;
57
                    }
58
                }
59
            XFree( props );
60
            }
61
        }
62
    XCloseDisplay( dpy );
63
    return kde;
64
    }
65
66
static bool getKdeSupport()
67
    {
68
    nsTArray<nsCString> command;
69
    command.AppendElement( NS_LITERAL_CSTRING( "CHECK" ));
70
    command.AppendElement( NS_LITERAL_CSTRING( MAKE_STR( KMOZILLAHELPER_VERSION )));
71
    bool kde = nsKDEUtils::command( command );
72
#ifdef DEBUG_KDE
73
    fprintf( stderr, "KDE RUNNING %d\n", kde );
74
#endif
75
    return kde;
76
    }
77
78
nsKDEUtils::nsKDEUtils()
79
    : commandFile( NULL )
80
    , replyFile( NULL )
81
    {
82
    }
83
84
nsKDEUtils::~nsKDEUtils()
85
    {
86
//    closeHelper(); not actually useful, exiting will close the fd too
87
    }
88
89
nsKDEUtils* nsKDEUtils::self()
90
    {
91
    static nsKDEUtils s;
92
    return &s;
93
    }
94
95
static bool helperRunning = false;
96
static bool helperFailed = false;
97
98
bool nsKDEUtils::kdeSession()
99
    {
100
    static bool session = getKdeSession();
101
    return session;
102
    }
103
104
bool nsKDEUtils::kdeSupport()
105
    {
106
    static bool support = kdeSession() && getKdeSupport();
107
    return support && helperRunning;
108
    }
109
110
struct nsKDECommandData
111
    {
112
    FILE* file;
113
    nsTArray<nsCString>* output;
114
    GMainLoop* loop;
115
    bool success;
116
    };
117
118
static gboolean kdeReadFunc( GIOChannel*, GIOCondition, gpointer data )
119
    {
120
    nsKDECommandData* p = static_cast< nsKDECommandData* >( data );
121
    char buf[ 8192 ]; // TODO big enough
122
    bool command_done = false;
123
    bool command_failed = false;
124
    while( !command_done && !command_failed && fgets( buf, 8192, p->file ) != NULL )
125
        { // TODO what if the kernel splits a line into two chunks?
126
//#ifdef DEBUG_KDE
127
//        fprintf( stderr, "READ: %s %d\n", buf, feof( p->file ));
128
//#endif
129
        if( char* eol = strchr( buf, '\n' ))
130
            *eol = '\0';
131
        command_done = ( strcmp( buf, "\\1" ) == 0 );
132
        command_failed = ( strcmp( buf, "\\0" ) == 0 );
133
        nsAutoCString line( buf );
134
        line.ReplaceSubstring( "\\n", "\n" );
135
        line.ReplaceSubstring( "\\" "\\", "\\" ); //  \\ -> \ , i.e. unescape
136
        if( p->output && !( command_done || command_failed ))
137
            p->output->AppendElement( nsCString( buf )); // TODO utf8?
138
        }
139
    bool quit = false;
140
    if( feof( p->file ) || command_failed )
141
        {
142
        quit = true;
143
        p->success = false;
144
        }
145
    if( command_done )
146
        { // reading one reply finished
147
        quit = true;
148
        p->success = true;
149
        }
150
    if( quit )
151
        {
152
        if( p->loop )
153
            g_main_loop_quit( p->loop );
154
        return FALSE;
155
        }
156
    return TRUE;
157
    }
158
159
bool nsKDEUtils::command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output )
160
    {
161
    return self()->internalCommand( command, NULL, false, output );
162
    }
163
164
bool nsKDEUtils::command( nsIArray* command, nsIArray** output)
165
    {
166
    nsTArray<nsCString> in;
167
    PRUint32 length;
168
    command->GetLength( &length );
169
    for ( PRUint32 i = 0; i < length; i++ )
170
        {
171
        nsCOMPtr<nsISupportsCString> str = do_QueryElementAt( command, i );
172
        if( str )
173
            {
174
            nsAutoCString s;
175
            str->GetData( s );
176
            in.AppendElement( s );
177
            }
178
        }
179
180
    nsTArray<nsCString> out;
181
    bool ret = self()->internalCommand( in, NULL, false, &out );
182
183
    if ( !output ) return ret;
184
185
    nsCOMPtr<nsIMutableArray> result = do_CreateInstance( NS_ARRAY_CONTRACTID );
186
    if ( !result ) return false;
187
188
    for ( PRUint32 i = 0; i < out.Length(); i++ )
189
        {
190
        nsCOMPtr<nsISupportsCString> rstr = do_CreateInstance( NS_SUPPORTS_CSTRING_CONTRACTID );
191
        if ( !rstr ) return false;
192
193
        rstr->SetData( out[i] );
194
        result->AppendElement( rstr, false );
195
        }
196
197
    NS_ADDREF( *output = result);
198
    return ret;
199
    }
200
201
202
bool nsKDEUtils::commandBlockUi( const nsTArray<nsCString>& command, const GtkWindow* parent, nsTArray<nsCString>* output )
203
    {
204
    return self()->internalCommand( command, parent, true, output );
205
    }
206
207
bool nsKDEUtils::internalCommand( const nsTArray<nsCString>& command, const GtkWindow* parent, bool blockUi,
208
    nsTArray<nsCString>* output )
209
    {
210
    if( !startHelper())
211
        return false;
212
    feedCommand( command );
213
    // do not store the data in 'this' but in extra structure, just in case there
214
    // is reentrancy (can there be? the event loop is re-entered)
215
    nsKDECommandData data;
216
    data.file = replyFile;
217
    data.output = output;
218
    data.success = false;
219
    if( blockUi )
220
        {
221
        data.loop = g_main_loop_new( NULL, FALSE );
222
        GtkWidget* window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
223
        if( parent && parent->group )
224
            gtk_window_group_add_window( parent->group, GTK_WINDOW( window ));
225
        gtk_widget_realize( window );
226
        gtk_widget_set_sensitive( window, TRUE );
227
        gtk_grab_add( window );
228
        GIOChannel* channel = g_io_channel_unix_new( fileno( data.file ));
229
        g_io_add_watch( channel, static_cast< GIOCondition >( G_IO_IN | G_IO_ERR | G_IO_HUP ), kdeReadFunc, &data );
230
        g_io_channel_unref( channel );
231
        g_main_loop_run( data.loop );
232
        g_main_loop_unref( data.loop );
233
        gtk_grab_remove( window );
234
        gtk_widget_destroy( window );
235
        }
236
    else
237
        {
238
        data.loop = NULL;
239
        while( kdeReadFunc( NULL, static_cast< GIOCondition >( 0 ), &data ))
240
            ;
241
        }
242
    return data.success;
243
    }
244
245
bool nsKDEUtils::startHelper()
246
    {
247
    if( helperRunning )
248
        return true;
249
    if( helperFailed )
250
        return false;
251
    helperFailed = true;
252
    int fdcommand[ 2 ];
253
    int fdreply[ 2 ];
254
    if( pipe( fdcommand ) < 0 )
255
        return false;
256
    if( pipe( fdreply ) < 0 )
257
        {
258
        close( fdcommand[ 0 ] );
259
        close( fdcommand[ 1 ] );
260
        return false;
261
        }
262
    char* args[ 2 ] = { const_cast< char* >( KMOZILLAHELPER ), NULL };
263
    switch( fork())
264
        {
265
        case -1:
266
            {
267
            close( fdcommand[ 0 ] );
268
            close( fdcommand[ 1 ] );
269
            close( fdreply[ 0 ] );
270
            close( fdreply[ 1 ] );
271
            return false;
272
            }
273
        case 0: // child
274
            {
275
            if( dup2( fdcommand[ 0 ], STDIN_FILENO ) < 0 )
276
                _exit( 1 );
277
            if( dup2( fdreply[ 1 ], STDOUT_FILENO ) < 0 )
278
                _exit( 1 );
279
            int maxfd = 1024; // close all other fds
280
            struct rlimit rl;
281
            if( getrlimit( RLIMIT_NOFILE, &rl ) == 0 )
282
                maxfd = rl.rlim_max;
283
            for( int i = 3;
284
                 i < maxfd;
285
                 ++i )
286
                close( i );
287
#ifdef DEBUG_KDE
288
            execvp( KMOZILLAHELPER, args );
289
#else
290
            execv( KMOZILLAHELPER, args );
291
#endif
292
            _exit( 1 ); // failed
293
            }
294
        default: // parent
295
            {
296
            commandFile = fdopen( fdcommand[ 1 ], "w" );
297
            replyFile = fdopen( fdreply[ 0 ], "r" );
298
            close( fdcommand[ 0 ] );
299
            close( fdreply[ 1 ] );
300
            if( commandFile == NULL || replyFile == NULL )
301
                {
302
                closeHelper();
303
                return false;
304
                }
305
            // ok, helper ready, getKdeRunning() will check if it works
306
            }
307
        }
308
    helperFailed = false;
309
    helperRunning = true;
310
    return true;
311
    }
312
313
void nsKDEUtils::closeHelper()
314
    {
315
    if( commandFile != NULL )
316
        fclose( commandFile ); // this will also make the helper quit
317
    if( replyFile != NULL )
318
        fclose( replyFile );
319
    helperRunning = false;
320
    }
321
322
void nsKDEUtils::feedCommand( const nsTArray<nsCString>& command )
323
    {
324
    for( int i = 0;
325
         i < command.Length();
326
         ++i )
327
        {
328
        nsCString line = command[ i ];
329
        line.ReplaceSubstring( "\\", "\\" "\\" ); // \ -> \\ , i.e. escape
330
        line.ReplaceSubstring( "\n", "\\n" );
331
#ifdef DEBUG_KDE
332
        fprintf( stderr, "COMM: %s\n", line.get());
333
#endif
334
        fputs( line.get(), commandFile );
335
        fputs( "\n", commandFile );
336
        }
337
    fputs( "\\E\n", commandFile ); // done as \E, so it cannot happen in normal data
338
    fflush( commandFile );
339
    }
(-)a/toolkit/xre/nsKDEUtils.h (+48 lines)
Line 0 Link Here
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#ifndef nsKDEUtils_h__
7
#define nsKDEUtils_h__
8
9
#include "nsStringGlue.h"
10
#include "nsTArray.h"
11
#include <stdio.h>
12
13
typedef struct _GtkWindow GtkWindow;
14
15
class nsIArray;
16
17
class NS_EXPORT nsKDEUtils
18
    {
19
    public:
20
        /* Returns true if running inside a KDE session (regardless of whether there is KDE
21
           support available for Firefox). This should be used e.g. when determining
22
           dialog button order but not for code that requires the KDE support. */
23
        static bool kdeSession();
24
        /* Returns true if running inside a KDE session and KDE support is available
25
           for Firefox. This should be used everywhere where the external helper is needed. */
26
        static bool kdeSupport();
27
        /* Executes the given helper command, returns true if helper returned success. */
28
        static bool command( const nsTArray<nsCString>& command, nsTArray<nsCString>* output = NULL );
29
        static bool command( nsIArray* command, nsIArray** output = NULL );
30
        /* Like command(), but additionally blocks the parent widget like if there was
31
           a modal dialog shown and enters the event loop (i.e. there are still paint updates,
32
           this is for commands that take long). */
33
        static bool commandBlockUi( const nsTArray<nsCString>& command, const GtkWindow* parent, nsTArray<nsCString>* output = NULL );
34
35
    private:
36
        nsKDEUtils();
37
        ~nsKDEUtils();
38
        static nsKDEUtils* self();
39
        bool startHelper();
40
        void closeHelper();
41
        void feedCommand( const nsTArray<nsCString>& command );
42
        bool internalCommand( const nsTArray<nsCString>& command, const GtkWindow* parent, bool isParent,
43
            nsTArray<nsCString>* output );
44
        FILE* commandFile;
45
        FILE* replyFile;
46
    };
47
48
#endif // nsKDEUtils
(-)a/uriloader/exthandler/Makefile.in (+1 lines)
Lines 86-94 EXTRA_COMPONENTS = \ Link Here
86
# we don't want the shared lib, but we want to force the creation of a static lib.
86
# we don't want the shared lib, but we want to force the creation of a static lib.
87
FORCE_STATIC_LIB = 1
87
FORCE_STATIC_LIB = 1
88
include $(topsrcdir)/config/config.mk
88
include $(topsrcdir)/config/config.mk
89
include $(topsrcdir)/ipc/chromium/chromium-config.mk
89
include $(topsrcdir)/ipc/chromium/chromium-config.mk
90
include $(topsrcdir)/config/rules.mk
90
include $(topsrcdir)/config/rules.mk
91
91
92
ifneq (,$(filter qt gtk2 gtk3, $(MOZ_WIDGET_TOOLKIT)))
92
ifneq (,$(filter qt gtk2 gtk3, $(MOZ_WIDGET_TOOLKIT)))
93
CXXFLAGS += $(TK_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS)
93
CXXFLAGS += $(TK_CFLAGS) $(MOZ_DBUS_GLIB_CFLAGS)
94
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
94
endif
95
endif
(-)a/uriloader/exthandler/moz.build (+2 lines)
Lines 68-83 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'coco Link Here
68
    pass
68
    pass
69
else:
69
else:
70
    CPP_SOURCES += [
70
    CPP_SOURCES += [
71
        'nsOSHelperAppService.cpp',
71
        'nsOSHelperAppService.cpp',
72
    ]
72
    ]
73
73
74
if CONFIG['MOZ_ENABLE_GTK']:
74
if CONFIG['MOZ_ENABLE_GTK']:
75
    CPP_SOURCES += [
75
    CPP_SOURCES += [
76
        'nsCommonRegistry.cpp',
77
	'nsKDERegistry.cpp',
76
        'nsGNOMERegistry.cpp',
78
        'nsGNOMERegistry.cpp',
77
        'nsMIMEInfoUnix.cpp',
79
        'nsMIMEInfoUnix.cpp',
78
    ]
80
    ]
79
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
81
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
80
    CPP_SOURCES += [
82
    CPP_SOURCES += [
81
        'nsMIMEInfoAndroid.cpp',
83
        'nsMIMEInfoAndroid.cpp',
82
        'nsAndroidHandlerApp.cpp',
84
        'nsAndroidHandlerApp.cpp',
83
        'nsExternalSharingAppService.cpp',
85
        'nsExternalSharingAppService.cpp',
(-)a/uriloader/exthandler/unix/nsCommonRegistry.cpp (+54 lines)
Line 0 Link Here
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsCommonRegistry.h"
7
8
#include "nsGNOMERegistry.h"
9
#include "nsKDERegistry.h"
10
#include "nsString.h"
11
#include "nsVoidArray.h"
12
#include "nsKDEUtils.h"
13
14
/* static */ bool
15
nsCommonRegistry::HandlerExists(const char *aProtocolScheme)
16
{
17
    if( nsKDEUtils::kdeSupport())
18
        return nsKDERegistry::HandlerExists( aProtocolScheme );
19
    return nsGNOMERegistry::HandlerExists( aProtocolScheme );
20
}
21
22
/* static */ nsresult
23
nsCommonRegistry::LoadURL(nsIURI *aURL)
24
{
25
    if( nsKDEUtils::kdeSupport())
26
        return nsKDERegistry::LoadURL( aURL );
27
    return nsGNOMERegistry::LoadURL( aURL );
28
}
29
30
/* static */ void
31
nsCommonRegistry::GetAppDescForScheme(const nsACString& aScheme,
32
                                     nsAString& aDesc)
33
{
34
    if( nsKDEUtils::kdeSupport())
35
        return nsKDERegistry::GetAppDescForScheme( aScheme, aDesc );
36
    return nsGNOMERegistry::GetAppDescForScheme( aScheme, aDesc );
37
}
38
39
40
/* static */ already_AddRefed<nsMIMEInfoBase>
41
nsCommonRegistry::GetFromExtension(const nsACString& aFileExt)
42
{
43
    if( nsKDEUtils::kdeSupport())
44
        return nsKDERegistry::GetFromExtension( aFileExt );
45
    return nsGNOMERegistry::GetFromExtension( aFileExt );
46
}
47
48
/* static */ already_AddRefed<nsMIMEInfoBase>
49
nsCommonRegistry::GetFromType(const nsACString& aMIMEType)
50
{
51
    if( nsKDEUtils::kdeSupport())
52
        return nsKDERegistry::GetFromType( aMIMEType );
53
    return nsGNOMERegistry::GetFromType( aMIMEType );
54
}
(-)a/uriloader/exthandler/unix/nsCommonRegistry.h (+23 lines)
Line 0 Link Here
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#include "nsIURI.h"
6
#include "nsCOMPtr.h"
7
8
class nsMIMEInfoBase;
9
10
class nsCommonRegistry
11
{
12
 public:
13
  static bool HandlerExists(const char *aProtocolScheme);
14
15
  static nsresult LoadURL(nsIURI *aURL);
16
17
  static void GetAppDescForScheme(const nsACString& aScheme,
18
                                  nsAString& aDesc);
19
20
  static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsACString& aFileExt);
21
22
  static already_AddRefed<nsMIMEInfoBase> GetFromType(const nsACString& aMIMEType);
23
};
(-)a/uriloader/exthandler/unix/nsKDERegistry.cpp (+88 lines)
Line 0 Link Here
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6
#include "nsKDERegistry.h"
7
#include "prlink.h"
8
#include "prmem.h"
9
#include "nsString.h"
10
#include "nsILocalFile.h"
11
#include "nsMIMEInfoUnix.h"
12
#include "nsAutoPtr.h"
13
#include "nsKDEUtils.h"
14
15
/* static */ bool
16
nsKDERegistry::HandlerExists(const char *aProtocolScheme)
17
{
18
    nsTArray<nsCString> command;
19
    command.AppendElement( NS_LITERAL_CSTRING( "HANDLEREXISTS" ));
20
    command.AppendElement( nsAutoCString( aProtocolScheme ));
21
    return nsKDEUtils::command( command );
22
}
23
24
/* static */ nsresult
25
nsKDERegistry::LoadURL(nsIURI *aURL)
26
{
27
    nsTArray<nsCString> command;
28
    command.AppendElement( NS_LITERAL_CSTRING( "OPEN" ));
29
    nsCString url;
30
    aURL->GetSpec( url );
31
    command.AppendElement( url );
32
    bool rv = nsKDEUtils::command( command );
33
    if (!rv)
34
      return NS_ERROR_FAILURE;
35
36
    return NS_OK;
37
}
38
39
/* static */ void
40
nsKDERegistry::GetAppDescForScheme(const nsACString& aScheme,
41
                                     nsAString& aDesc)
42
{
43
    nsTArray<nsCString> command;
44
    command.AppendElement( NS_LITERAL_CSTRING( "GETAPPDESCFORSCHEME" ));
45
    command.AppendElement( aScheme );
46
    nsTArray<nsCString> output;
47
    if( nsKDEUtils::command( command, &output ) && output.Length() == 1 )
48
        CopyUTF8toUTF16( output[ 0 ], aDesc );
49
}
50
51
52
/* static */ already_AddRefed<nsMIMEInfoBase>
53
nsKDERegistry::GetFromExtension(const nsACString& aFileExt)
54
{
55
    NS_ASSERTION(aFileExt[0] != '.', "aFileExt shouldn't start with a dot");
56
    nsTArray<nsCString> command;
57
    command.AppendElement( NS_LITERAL_CSTRING( "GETFROMEXTENSION" ));
58
    command.AppendElement( aFileExt );
59
    return GetFromHelper( command );
60
}
61
62
/* static */ already_AddRefed<nsMIMEInfoBase>
63
nsKDERegistry::GetFromType(const nsACString& aMIMEType)
64
{
65
    nsTArray<nsCString> command;
66
    command.AppendElement( NS_LITERAL_CSTRING( "GETFROMTYPE" ));
67
    command.AppendElement( aMIMEType );
68
    return GetFromHelper( command );
69
}
70
71
/* static */ already_AddRefed<nsMIMEInfoBase>
72
nsKDERegistry::GetFromHelper(const nsTArray<nsCString>& command)
73
{
74
    nsTArray<nsCString> output;
75
    if( nsKDEUtils::command( command, &output ) && output.Length() == 3 )
76
        {
77
        nsCString mimetype = output[ 0 ];
78
        nsRefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix( mimetype );
79
        NS_ENSURE_TRUE(mimeInfo, nullptr);
80
        nsCString description = output[ 1 ];
81
        mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description));
82
        nsCString handlerAppName = output[ 2 ];
83
        mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(handlerAppName));
84
        mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
85
        return mimeInfo.forget();
86
        }
87
    return nullptr;
88
}
(-)a/uriloader/exthandler/unix/nsKDERegistry.h (+29 lines)
Line 0 Link Here
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#include "nsIURI.h"
6
#include "nsCOMPtr.h"
7
#include "nsTArray.h"
8
9
class nsMIMEInfoBase;
10
class nsAutoCString;
11
class nsCString;
12
13
class nsKDERegistry
14
{
15
 public:
16
  static bool HandlerExists(const char *aProtocolScheme);
17
18
  static nsresult LoadURL(nsIURI *aURL);
19
20
  static void GetAppDescForScheme(const nsACString& aScheme,
21
                                  nsAString& aDesc);
22
23
  static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsACString& aFileExt);
24
25
  static already_AddRefed<nsMIMEInfoBase> GetFromType(const nsACString& aMIMEType);
26
 private:
27
  static already_AddRefed<nsMIMEInfoBase> GetFromHelper(const nsTArray<nsCString>& command);
28
29
};
(-)a/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp (-5 / +25 lines)
Lines 16-45 Link Here
16
#include <QString>
16
#include <QString>
17
#if (MOZ_ENABLE_CONTENTACTION)
17
#if (MOZ_ENABLE_CONTENTACTION)
18
#include <contentaction/contentaction.h>
18
#include <contentaction/contentaction.h>
19
#include "nsContentHandlerApp.h"
19
#include "nsContentHandlerApp.h"
20
#endif
20
#endif
21
#endif
21
#endif
22
22
23
#include "nsMIMEInfoUnix.h"
23
#include "nsMIMEInfoUnix.h"
24
#include "nsGNOMERegistry.h"
24
#include "nsCommonRegistry.h"
25
#include "nsIGIOService.h"
25
#include "nsIGIOService.h"
26
#include "nsNetCID.h"
26
#include "nsNetCID.h"
27
#include "nsIIOService.h"
27
#include "nsIIOService.h"
28
#include "nsIGnomeVFSService.h"
28
#include "nsIGnomeVFSService.h"
29
#include "nsAutoPtr.h"
29
#include "nsAutoPtr.h"
30
#ifdef MOZ_ENABLE_DBUS
30
#ifdef MOZ_ENABLE_DBUS
31
#include "nsDBusHandlerApp.h"
31
#include "nsDBusHandlerApp.h"
32
#endif
32
#endif
33
#if defined(XP_UNIX) && !defined(XP_MACOSX)
34
#include "nsKDEUtils.h"
35
#endif
33
36
34
nsresult
37
nsresult
35
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
38
nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
36
{
39
{
37
  nsresult rv = nsGNOMERegistry::LoadURL(aURI);
40
  nsresult rv = nsCommonRegistry::LoadURL(aURI);
38
41
39
#if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
42
#if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
40
  if (NS_FAILED(rv)){
43
  if (NS_FAILED(rv)){
41
    HildonURIAction *action = hildon_uri_get_default_action(mSchemeOrType.get(), nullptr);
44
    HildonURIAction *action = hildon_uri_get_default_action(mSchemeOrType.get(), nullptr);
42
    if (action) {
45
    if (action) {
43
      nsAutoCString spec;
46
      nsAutoCString spec;
44
      aURI->GetAsciiSpec(spec);
47
      aURI->GetAsciiSpec(spec);
45
      if (hildon_uri_open(spec.get(), action, nullptr))
48
      if (hildon_uri_open(spec.get(), action, nullptr))
Lines 67-88 nsMIMEInfoUnix::GetHasDefaultHandler(boo Link Here
67
{
70
{
68
  // if mDefaultApplication is set, it means the application has been set from
71
  // if mDefaultApplication is set, it means the application has been set from
69
  // either /etc/mailcap or ${HOME}/.mailcap, in which case we don't want to
72
  // either /etc/mailcap or ${HOME}/.mailcap, in which case we don't want to
70
  // give the GNOME answer.
73
  // give the GNOME answer.
71
  if (mDefaultApplication)
74
  if (mDefaultApplication)
72
    return nsMIMEInfoImpl::GetHasDefaultHandler(_retval);
75
    return nsMIMEInfoImpl::GetHasDefaultHandler(_retval);
73
76
74
  *_retval = false;
77
  *_retval = false;
75
  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mSchemeOrType);
78
  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromType(mSchemeOrType);
76
  if (!mimeInfo) {
79
  if (!mimeInfo) {
77
    nsAutoCString ext;
80
    nsAutoCString ext;
78
    nsresult rv = GetPrimaryExtension(ext);
81
    nsresult rv = GetPrimaryExtension(ext);
79
    if (NS_SUCCEEDED(rv)) {
82
    if (NS_SUCCEEDED(rv)) {
80
      mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
83
      mimeInfo = nsCommonRegistry::GetFromExtension(ext);
81
    }
84
    }
82
  }
85
  }
83
  if (mimeInfo)
86
  if (mimeInfo)
84
    *_retval = true;
87
    *_retval = true;
85
88
86
  if (*_retval)
89
  if (*_retval)
87
    return NS_OK;
90
    return NS_OK;
88
91
Lines 130-145 nsMIMEInfoUnix::LaunchDefaultWithFile(ns Link Here
130
    ContentAction::Action::defaultActionForFile(uri, QString(mSchemeOrType.get()));
133
    ContentAction::Action::defaultActionForFile(uri, QString(mSchemeOrType.get()));
131
  if (action.isValid()) {
134
  if (action.isValid()) {
132
    action.trigger();
135
    action.trigger();
133
    return NS_OK;
136
    return NS_OK;
134
  }
137
  }
135
  return NS_ERROR_FAILURE;
138
  return NS_ERROR_FAILURE;
136
#endif
139
#endif
137
140
141
  if( nsKDEUtils::kdeSupport()) {
142
    bool supports;
143
    if( NS_SUCCEEDED( GetHasDefaultHandler( &supports )) && supports ) {
144
      nsTArray<nsCString> command;
145
      command.AppendElement( NS_LITERAL_CSTRING( "OPEN" ));
146
      command.AppendElement( nativePath );
147
      command.AppendElement( NS_LITERAL_CSTRING( "MIMETYPE" ));
148
      command.AppendElement( mSchemeOrType );
149
      if( nsKDEUtils::command( command ))
150
        return NS_OK;
151
    }
152
    if (!mDefaultApplication)
153
      return NS_ERROR_FILE_NOT_FOUND;
154
155
    return LaunchWithIProcess(mDefaultApplication, nativePath);
156
  }
157
138
  nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
158
  nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
139
  nsAutoCString uriSpec;
159
  nsAutoCString uriSpec;
140
  if (giovfs) {
160
  if (giovfs) {
141
    // nsGIOMimeApp->Launch wants a URI string instead of local file
161
    // nsGIOMimeApp->Launch wants a URI string instead of local file
142
    nsresult rv;
162
    nsresult rv;
143
    nsCOMPtr<nsIIOService> ioservice = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
163
    nsCOMPtr<nsIIOService> ioservice = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
144
    NS_ENSURE_SUCCESS(rv, rv);
164
    NS_ENSURE_SUCCESS(rv, rv);
145
    nsCOMPtr<nsIURI> uri;
165
    nsCOMPtr<nsIURI> uri;
Lines 157-173 nsMIMEInfoUnix::LaunchDefaultWithFile(ns Link Here
157
    /* Fallback to GnomeVFS */
177
    /* Fallback to GnomeVFS */
158
    nsCOMPtr<nsIGnomeVFSMimeApp> app;
178
    nsCOMPtr<nsIGnomeVFSMimeApp> app;
159
    if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
179
    if (NS_SUCCEEDED(gnomevfs->GetAppForMimeType(mSchemeOrType, getter_AddRefs(app))) && app)
160
      return app->Launch(nativePath);
180
      return app->Launch(nativePath);
161
  }
181
  }
162
182
163
  // If we haven't got an app we try to get a valid one by searching for the
183
  // If we haven't got an app we try to get a valid one by searching for the
164
  // extension mapped type
184
  // extension mapped type
165
  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath);
185
  nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromExtension(nativePath);
166
  if (mimeInfo) {
186
  if (mimeInfo) {
167
    nsAutoCString type;
187
    nsAutoCString type;
168
    mimeInfo->GetType(type);
188
    mimeInfo->GetType(type);
169
    if (giovfs) {
189
    if (giovfs) {
170
      nsCOMPtr<nsIGIOMimeApp> app;
190
      nsCOMPtr<nsIGIOMimeApp> app;
171
      if (NS_SUCCEEDED(giovfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
191
      if (NS_SUCCEEDED(giovfs->GetAppForMimeType(type, getter_AddRefs(app))) && app)
172
        return app->Launch(uriSpec);
192
        return app->Launch(uriSpec);
173
    } else if (gnomevfs) {
193
    } else if (gnomevfs) {
(-)a/uriloader/exthandler/unix/nsOSHelperAppService.cpp (-5 / +5 lines)
Lines 10-26 Link Here
10
#if defined(MOZ_ENABLE_CONTENTACTION)
10
#if defined(MOZ_ENABLE_CONTENTACTION)
11
#include <contentaction/contentaction.h>
11
#include <contentaction/contentaction.h>
12
#include <QString>
12
#include <QString>
13
#endif
13
#endif
14
14
15
#include "nsOSHelperAppService.h"
15
#include "nsOSHelperAppService.h"
16
#include "nsMIMEInfoUnix.h"
16
#include "nsMIMEInfoUnix.h"
17
#ifdef MOZ_WIDGET_GTK
17
#ifdef MOZ_WIDGET_GTK
18
#include "nsGNOMERegistry.h"
18
#include "nsCommonRegistry.h"
19
#endif
19
#endif
20
#include "nsISupports.h"
20
#include "nsISupports.h"
21
#include "nsString.h"
21
#include "nsString.h"
22
#include "nsReadableUtils.h"
22
#include "nsReadableUtils.h"
23
#include "nsUnicharUtils.h"
23
#include "nsUnicharUtils.h"
24
#include "nsXPIDLString.h"
24
#include "nsXPIDLString.h"
25
#include "nsIURL.h"
25
#include "nsIURL.h"
26
#include "nsIFileStreams.h"
26
#include "nsIFileStreams.h"
Lines 1157-1185 nsresult nsOSHelperAppService::OSProtoco Link Here
1157
    ContentAction::Action::defaultActionForScheme(QString(aProtocolScheme) + ':');
1157
    ContentAction::Action::defaultActionForScheme(QString(aProtocolScheme) + ':');
1158
1158
1159
  if (action.isValid())
1159
  if (action.isValid())
1160
    *aHandlerExists = true;
1160
    *aHandlerExists = true;
1161
#endif
1161
#endif
1162
1162
1163
#ifdef MOZ_WIDGET_GTK
1163
#ifdef MOZ_WIDGET_GTK
1164
  // Check the GConf registry for a protocol handler
1164
  // Check the GConf registry for a protocol handler
1165
  *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
1165
  *aHandlerExists = nsCommonRegistry::HandlerExists(aProtocolScheme);
1166
#if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
1166
#if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
1167
  *aHandlerExists = nsMIMEInfoUnix::HandlerExists(aProtocolScheme);
1167
  *aHandlerExists = nsMIMEInfoUnix::HandlerExists(aProtocolScheme);
1168
#endif
1168
#endif
1169
#endif
1169
#endif
1170
1170
1171
  return NS_OK;
1171
  return NS_OK;
1172
}
1172
}
1173
1173
1174
NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsAString& _retval)
1174
NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsAString& _retval)
1175
{
1175
{
1176
#ifdef MOZ_WIDGET_GTK
1176
#ifdef MOZ_WIDGET_GTK
1177
  nsGNOMERegistry::GetAppDescForScheme(aScheme, _retval);
1177
  nsCommonRegistry::GetAppDescForScheme(aScheme, _retval);
1178
  return _retval.IsEmpty() ? NS_ERROR_NOT_AVAILABLE : NS_OK;
1178
  return _retval.IsEmpty() ? NS_ERROR_NOT_AVAILABLE : NS_OK;
1179
#else
1179
#else
1180
  return NS_ERROR_NOT_AVAILABLE;
1180
  return NS_ERROR_NOT_AVAILABLE;
1181
#endif
1181
#endif
1182
}
1182
}
1183
1183
1184
nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformAppPath, nsIFile ** aFile)
1184
nsresult nsOSHelperAppService::GetFileTokenForPath(const PRUnichar * platformAppPath, nsIFile ** aFile)
1185
{
1185
{
Lines 1266-1282 nsOSHelperAppService::GetFromExtension(c Link Here
1266
                                         mime_types_description,
1266
                                         mime_types_description,
1267
                                         true);
1267
                                         true);
1268
1268
1269
  if (NS_FAILED(rv) || majorType.IsEmpty()) {
1269
  if (NS_FAILED(rv) || majorType.IsEmpty()) {
1270
    
1270
    
1271
#ifdef MOZ_WIDGET_GTK
1271
#ifdef MOZ_WIDGET_GTK
1272
    LOG(("Looking in GNOME registry\n"));
1272
    LOG(("Looking in GNOME registry\n"));
1273
    nsRefPtr<nsMIMEInfoBase> gnomeInfo =
1273
    nsRefPtr<nsMIMEInfoBase> gnomeInfo =
1274
      nsGNOMERegistry::GetFromExtension(aFileExt);
1274
      nsCommonRegistry::GetFromExtension(aFileExt);
1275
    if (gnomeInfo) {
1275
    if (gnomeInfo) {
1276
      LOG(("Got MIMEInfo from GNOME registry\n"));
1276
      LOG(("Got MIMEInfo from GNOME registry\n"));
1277
      return gnomeInfo.forget();
1277
      return gnomeInfo.forget();
1278
    }
1278
    }
1279
#endif
1279
#endif
1280
1280
1281
    rv = LookUpTypeAndDescription(NS_ConvertUTF8toUTF16(aFileExt),
1281
    rv = LookUpTypeAndDescription(NS_ConvertUTF8toUTF16(aFileExt),
1282
                                  majorType,
1282
                                  majorType,
Lines 1389-1405 nsOSHelperAppService::GetFromType(const Link Here
1389
#ifdef MOZ_WIDGET_GTK
1389
#ifdef MOZ_WIDGET_GTK
1390
  nsRefPtr<nsMIMEInfoBase> gnomeInfo;
1390
  nsRefPtr<nsMIMEInfoBase> gnomeInfo;
1391
  if (handler.IsEmpty()) {
1391
  if (handler.IsEmpty()) {
1392
    // No useful data yet.  Check the GNOME registry.  Unfortunately, newer
1392
    // No useful data yet.  Check the GNOME registry.  Unfortunately, newer
1393
    // GNOME versions no longer have type-to-extension mappings, so we might
1393
    // GNOME versions no longer have type-to-extension mappings, so we might
1394
    // get back a MIMEInfo without any extensions set.  In that case we'll have
1394
    // get back a MIMEInfo without any extensions set.  In that case we'll have
1395
    // to look in our mime.types files for the extensions.    
1395
    // to look in our mime.types files for the extensions.    
1396
    LOG(("Looking in GNOME registry\n"));
1396
    LOG(("Looking in GNOME registry\n"));
1397
    gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType);
1397
    gnomeInfo = nsCommonRegistry::GetFromType(aMIMEType);
1398
    if (gnomeInfo && gnomeInfo->HasExtensions()) {
1398
    if (gnomeInfo && gnomeInfo->HasExtensions()) {
1399
      LOG(("Got MIMEInfo from GNOME registry, and it has extensions set\n"));
1399
      LOG(("Got MIMEInfo from GNOME registry, and it has extensions set\n"));
1400
      return gnomeInfo.forget();
1400
      return gnomeInfo.forget();
1401
    }
1401
    }
1402
  }
1402
  }
1403
#endif
1403
#endif
1404
1404
1405
  // Now look up our extensions
1405
  // Now look up our extensions
(-)a/widget/gtk2/Makefile.in (+3 lines)
Lines 67-77 DEFINES += -DCAIRO_GFX -DMOZ_APP_NAME=' Link Here
67
67
68
INCLUDES	+= \
68
INCLUDES	+= \
69
		-I$(srcdir)/../xpwidgets \
69
		-I$(srcdir)/../xpwidgets \
70
		-I$(srcdir)/../shared \
70
		-I$(srcdir)/../shared \
71
		-I$(topsrcdir)/layout/generic \
71
		-I$(topsrcdir)/layout/generic \
72
		-I$(topsrcdir)/layout/xul/base/src \
72
		-I$(topsrcdir)/layout/xul/base/src \
73
		-I$(topsrcdir)/other-licenses/atk-1.0 \
73
		-I$(topsrcdir)/other-licenses/atk-1.0 \
74
		$(NULL)
74
		$(NULL)
75
76
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
77
75
ifdef MOZ_X11
78
ifdef MOZ_X11
76
INCLUDES   	+= -I$(srcdir)/../shared/x11
79
INCLUDES   	+= -I$(srcdir)/../shared/x11
77
endif
80
endif
(-)a/widget/gtk2/nsFilePicker.cpp (-1 / +248 lines)
Lines 1-31 Link Here
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* This Source Code Form is subject to the terms of the Mozilla Public
2
/* This Source Code Form is subject to the terms of the Mozilla Public
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * License, v. 2.0. If a copy of the MPL was not distributed with this
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
5
6
#include "mozilla/Util.h"
6
#include "mozilla/Util.h"
7
7
8
#include <gtk/gtk.h>
8
#include <gtk/gtk.h>
9
#include <gdk/gdkx.h>
9
10
10
#include "nsIFileURL.h"
11
#include "nsIFileURL.h"
11
#include "nsIURI.h"
12
#include "nsIURI.h"
12
#include "nsIWidget.h"
13
#include "nsIWidget.h"
13
#include "nsIFile.h"
14
#include "nsIFile.h"
14
#include "nsIStringBundle.h"
15
#include "nsIStringBundle.h"
15
16
16
#include "nsArrayEnumerator.h"
17
#include "nsArrayEnumerator.h"
17
#include "nsMemory.h"
18
#include "nsMemory.h"
18
#include "nsEnumeratorUtils.h"
19
#include "nsEnumeratorUtils.h"
19
#include "nsNetUtil.h"
20
#include "nsNetUtil.h"
20
#include "nsReadableUtils.h"
21
#include "nsReadableUtils.h"
21
#include "mozcontainer.h"
22
#include "mozcontainer.h"
22
23
23
#include "nsFilePicker.h"
24
#include "nsFilePicker.h"
25
#include "nsKDEUtils.h"
24
26
25
#if (MOZ_PLATFORM_MAEMO == 5)
27
#if (MOZ_PLATFORM_MAEMO == 5)
26
#include <hildon-fm-2/hildon/hildon-file-chooser-dialog.h>
28
#include <hildon-fm-2/hildon/hildon-file-chooser-dialog.h>
27
#endif
29
#endif
28
30
29
using namespace mozilla;
31
using namespace mozilla;
30
32
31
#define MAX_PREVIEW_SIZE 180
33
#define MAX_PREVIEW_SIZE 180
Lines 242-258 nsFilePicker::AppendFilters(int32_t aFil Link Here
242
  return nsBaseFilePicker::AppendFilters(aFilterMask);
244
  return nsBaseFilePicker::AppendFilters(aFilterMask);
243
}
245
}
244
246
245
NS_IMETHODIMP
247
NS_IMETHODIMP
246
nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
248
nsFilePicker::AppendFilter(const nsAString& aTitle, const nsAString& aFilter)
247
{
249
{
248
  if (aFilter.EqualsLiteral("..apps")) {
250
  if (aFilter.EqualsLiteral("..apps")) {
249
    // No platform specific thing we can do here, really....
251
    // No platform specific thing we can do here, really....
250
    return NS_OK;
252
    // Unless it's KDE.
253
    if( mMode != modeOpen || !nsKDEUtils::kdeSupport())
254
      return NS_OK;
251
  }
255
  }
252
256
253
  nsAutoCString filter, name;
257
  nsAutoCString filter, name;
254
  CopyUTF16toUTF8(aFilter, filter);
258
  CopyUTF16toUTF8(aFilter, filter);
255
  CopyUTF16toUTF8(aTitle, name);
259
  CopyUTF16toUTF8(aTitle, name);
256
260
257
  mFilters.AppendElement(filter);
261
  mFilters.AppendElement(filter);
258
  mFilterNames.AppendElement(name);
262
  mFilterNames.AppendElement(name);
Lines 366-381 nsFilePicker::Show(int16_t *aReturn) Link Here
366
370
367
NS_IMETHODIMP
371
NS_IMETHODIMP
368
nsFilePicker::Open(nsIFilePickerShownCallback *aCallback)
372
nsFilePicker::Open(nsIFilePickerShownCallback *aCallback)
369
{
373
{
370
  // Can't show two dialogs concurrently with the same filepicker
374
  // Can't show two dialogs concurrently with the same filepicker
371
  if (mRunning)
375
  if (mRunning)
372
    return NS_ERROR_NOT_AVAILABLE;
376
    return NS_ERROR_NOT_AVAILABLE;
373
377
378
  // KDE file picker is not handled via callback
379
  if( nsKDEUtils::kdeSupport()) {
380
    int16_t result;
381
    mCallback = aCallback;
382
    mRunning = true;
383
    kdeFileDialog(&result);
384
    if (mCallback) {
385
      mCallback->Done(result);
386
      mCallback = nullptr;
387
    } else {
388
      mResult = result;
389
    }
390
    mRunning = false;
391
    return NS_OK;
392
  }
393
374
  nsXPIDLCString title;
394
  nsXPIDLCString title;
375
  title.Adopt(ToNewUTF8String(mTitle));
395
  title.Adopt(ToNewUTF8String(mTitle));
376
396
377
  GtkWindow *parent_widget =
397
  GtkWindow *parent_widget =
378
    GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
398
    GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET));
379
399
380
  GtkFileChooserAction action = GetGtkFileChooserAction(mMode);
400
  GtkFileChooserAction action = GetGtkFileChooserAction(mMode);
381
  const gchar *accept_button = (action == GTK_FILE_CHOOSER_ACTION_SAVE)
401
  const gchar *accept_button = (action == GTK_FILE_CHOOSER_ACTION_SAVE)
Lines 567-574 nsFilePicker::Done(GtkWidget* file_choos Link Here
567
  if (mCallback) {
587
  if (mCallback) {
568
    mCallback->Done(result);
588
    mCallback->Done(result);
569
    mCallback = nullptr;
589
    mCallback = nullptr;
570
  } else {
590
  } else {
571
    mResult = result;
591
    mResult = result;
572
  }
592
  }
573
  NS_RELEASE_THIS();
593
  NS_RELEASE_THIS();
574
}
594
}
595
596
nsCString nsFilePicker::kdeMakeFilter( int index )
597
    {
598
    nsCString buf = mFilters[ index ];
599
    for( PRUint32 i = 0;
600
         i < buf.Length();
601
         ++i )
602
        if( buf[ i ] == ';' ) // KDE separates just using spaces
603
            buf.SetCharAt( ' ', i );
604
    if (!mFilterNames[index].IsEmpty())
605
        {
606
        buf += "|";
607
        buf += mFilterNames[index].get();
608
        }
609
    return buf;
610
    }
611
612
static PRInt32 windowToXid( nsIWidget* widget )
613
    {
614
    GtkWindow *parent_widget = GTK_WINDOW(widget->GetNativeData(NS_NATIVE_SHELLWIDGET));
615
    GdkWindow* gdk_window = gtk_widget_get_window( gtk_widget_get_toplevel( GTK_WIDGET( parent_widget )));
616
    return GDK_WINDOW_XID( gdk_window );
617
    }
618
619
NS_IMETHODIMP nsFilePicker::kdeFileDialog(PRInt16 *aReturn)
620
    {
621
    NS_ENSURE_ARG_POINTER(aReturn);
622
623
    if( mMode == modeOpen && mFilters.Length() == 1 && mFilters[ 0 ].EqualsLiteral( "..apps" ))
624
        return kdeAppsDialog( aReturn );
625
626
    nsXPIDLCString title;
627
    title.Adopt(ToNewUTF8String(mTitle));
628
629
    const char* arg = NULL;
630
    if( mAllowURLs )
631
        {
632
        switch( mMode )
633
            {
634
            case nsIFilePicker::modeOpen:
635
            case nsIFilePicker::modeOpenMultiple:
636
                arg = "GETOPENURL";
637
                break;
638
            case nsIFilePicker::modeSave:
639
                arg = "GETSAVEURL";
640
                break;
641
            case nsIFilePicker::modeGetFolder:
642
                arg = "GETDIRECTORYURL";
643
                break;
644
            }
645
        }
646
    else
647
        {
648
        switch( mMode )
649
            {
650
            case nsIFilePicker::modeOpen:
651
            case nsIFilePicker::modeOpenMultiple:
652
                arg = "GETOPENFILENAME";
653
                break;
654
            case nsIFilePicker::modeSave:
655
                arg = "GETSAVEFILENAME";
656
                break;
657
            case nsIFilePicker::modeGetFolder:
658
                arg = "GETDIRECTORYFILENAME";
659
                break;
660
            }
661
        }
662
663
  nsAutoCString directory;
664
  if (mDisplayDirectory) {
665
    mDisplayDirectory->GetNativePath(directory);
666
  } else if (mPrevDisplayDirectory) {
667
    mPrevDisplayDirectory->GetNativePath(directory);
668
  }
669
670
    nsAutoCString startdir;
671
  if (!directory.IsEmpty()) {
672
    startdir = directory;
673
  }
674
  if (mMode == nsIFilePicker::modeSave) {
675
    if( !startdir.IsEmpty())
676
      {
677
      startdir += "/";
678
      startdir += ToNewUTF8String(mDefault);
679
      }
680
    else
681
      startdir = ToNewUTF8String(mDefault);
682
  }
683
  if( startdir.IsEmpty())
684
      startdir = ".";
685
686
    nsAutoCString filters;
687
    PRInt32 count = mFilters.Length();
688
    if( count == 0 ) //just in case
689
        filters = "*";
690
    else
691
        {
692
        filters = kdeMakeFilter( 0 );
693
        for (PRInt32 i = 1; i < count; ++i)
694
            {
695
            filters += "\n";
696
            filters += kdeMakeFilter( i );
697
            }
698
        }
699
700
    nsTArray<nsCString> command;
701
    command.AppendElement( nsAutoCString( arg ));
702
    command.AppendElement( startdir );
703
    if( mMode != nsIFilePicker::modeGetFolder )
704
        {
705
        command.AppendElement( filters );
706
        nsAutoCString selected;
707
        selected.AppendInt( mSelectedType );
708
        command.AppendElement( selected );
709
        }
710
    command.AppendElement( title );
711
    if( mMode == nsIFilePicker::modeOpenMultiple )
712
        command.AppendElement( NS_LITERAL_CSTRING( "MULTIPLE" ));
713
    if( PRInt32 xid = windowToXid( mParentWidget ))
714
        {
715
        command.AppendElement( NS_LITERAL_CSTRING( "PARENT" ));
716
        nsAutoCString parent;
717
        parent.AppendInt( xid );
718
        command.AppendElement( parent );
719
        }
720
721
    nsTArray<nsCString> output;
722
    if( nsKDEUtils::commandBlockUi( command, GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET)), &output ))
723
        {
724
        *aReturn = nsIFilePicker::returnOK;
725
        mFiles.Clear();
726
        if( mMode != nsIFilePicker::modeGetFolder )
727
            {
728
            mSelectedType = atoi( output[ 0 ].get());
729
            output.RemoveElementAt( 0 );
730
            }
731
        if (mMode == nsIFilePicker::modeOpenMultiple)
732
            {
733
            mFileURL.Truncate();
734
            PRUint32 count = output.Length();
735
            for( PRUint32 i = 0;
736
                 i < count;
737
                 ++i )
738
                {
739
                nsCOMPtr<nsIFile> localfile;
740
                nsresult rv = NS_NewNativeLocalFile( output[ i ],
741
                                      PR_FALSE,
742
                                      getter_AddRefs(localfile));
743
                if (NS_SUCCEEDED(rv))
744
                    mFiles.AppendObject(localfile);
745
                }
746
            }
747
        else
748
            {
749
            if( output.Length() == 0 )
750
                mFileURL = nsCString();
751
            else if( mAllowURLs )
752
                mFileURL = output[ 0 ];
753
            else // GetFile() actually requires it to be url even for local files :-/
754
                {
755
                mFileURL = nsCString( "file://" );
756
                mFileURL.Append( output[ 0 ] );
757
                }
758
            }
759
  // Remember last used directory.
760
  nsCOMPtr<nsIFile> file;
761
  GetFile(getter_AddRefs(file));
762
  if (file) {
763
    nsCOMPtr<nsIFile> dir;
764
    file->GetParent(getter_AddRefs(dir));
765
    nsCOMPtr<nsIFile> localDir(do_QueryInterface(dir));
766
    if (localDir) {
767
      localDir.swap(mPrevDisplayDirectory);
768
    }
769
  }
770
        if (mMode == nsIFilePicker::modeSave)
771
            {
772
            nsCOMPtr<nsIFile> file;
773
            GetFile(getter_AddRefs(file));
774
            if (file)
775
                {
776
                bool exists = false;
777
                file->Exists(&exists);
778
                if (exists) // TODO do overwrite check in the helper app
779
                    *aReturn = nsIFilePicker::returnReplace;
780
                }
781
            }
782
        }
783
    else
784
        {
785
        *aReturn = nsIFilePicker::returnCancel;
786
        }
787
    return NS_OK;
788
    }
789
790
791
NS_IMETHODIMP nsFilePicker::kdeAppsDialog(PRInt16 *aReturn)
792
    {
793
    NS_ENSURE_ARG_POINTER(aReturn);
794
795
    nsXPIDLCString title;
796
    title.Adopt(ToNewUTF8String(mTitle));
797
798
    nsTArray<nsCString> command;
799
    command.AppendElement( NS_LITERAL_CSTRING( "APPSDIALOG" ));
800
    command.AppendElement( title );
801
    if( PRInt32 xid = windowToXid( mParentWidget ))
802
        {
803
        command.AppendElement( NS_LITERAL_CSTRING( "PARENT" ));
804
        nsAutoCString parent;
805
        parent.AppendInt( xid );
806
        command.AppendElement( parent );
807
        }
808
809
    nsTArray<nsCString> output;
810
    if( nsKDEUtils::commandBlockUi( command, GTK_WINDOW(mParentWidget->GetNativeData(NS_NATIVE_SHELLWIDGET)), &output ))
811
        {
812
        *aReturn = nsIFilePicker::returnOK;
813
        mFileURL = output.Length() > 0 ? output[ 0 ] : nsCString();
814
        }
815
    else
816
        {
817
        *aReturn = nsIFilePicker::returnCancel;
818
        }
819
    return NS_OK;
820
    }
821
(-)a/widget/gtk2/nsFilePicker.h (+6 lines)
Lines 67-77 protected: Link Here
67
  nsString  mDefault;
67
  nsString  mDefault;
68
  nsString  mDefaultExtension;
68
  nsString  mDefaultExtension;
69
69
70
  nsTArray<nsCString> mFilters;
70
  nsTArray<nsCString> mFilters;
71
  nsTArray<nsCString> mFilterNames;
71
  nsTArray<nsCString> mFilterNames;
72
72
73
private:
73
private:
74
  static nsIFile *mPrevDisplayDirectory;
74
  static nsIFile *mPrevDisplayDirectory;
75
76
  bool kdeRunning();
77
  bool getKdeRunning();
78
  NS_IMETHODIMP kdeFileDialog(PRInt16 *aReturn);
79
  NS_IMETHODIMP kdeAppsDialog(PRInt16 *aReturn);
80
  nsCString kdeMakeFilter( int index );
75
};
81
};
76
82
77
#endif
83
#endif
(-)a/xpcom/components/Makefile.in (+1 lines)
Lines 28-36 LOCAL_INCLUDES = \ Link Here
28
FORCE_STATIC_LIB = 1
28
FORCE_STATIC_LIB = 1
29
29
30
include $(topsrcdir)/config/rules.mk
30
include $(topsrcdir)/config/rules.mk
31
31
32
DEFINES	+= -D_IMPL_NS_COM
32
DEFINES	+= -D_IMPL_NS_COM
33
33
34
ifdef MOZ_WIDGET_GTK
34
ifdef MOZ_WIDGET_GTK
35
CXXFLAGS        += $(TK_CFLAGS)
35
CXXFLAGS        += $(TK_CFLAGS)
36
LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
36
endif
37
endif
(-)a/xpcom/components/ManifestParser.cpp (+10 lines)
Lines 30-45 Link Here
30
#include "nsTextFormatter.h"
30
#include "nsTextFormatter.h"
31
#include "nsVersionComparator.h"
31
#include "nsVersionComparator.h"
32
#include "nsXPCOMCIDInternal.h"
32
#include "nsXPCOMCIDInternal.h"
33
33
34
#include "nsIConsoleService.h"
34
#include "nsIConsoleService.h"
35
#include "nsIScriptError.h"
35
#include "nsIScriptError.h"
36
#include "nsIXULAppInfo.h"
36
#include "nsIXULAppInfo.h"
37
#include "nsIXULRuntime.h"
37
#include "nsIXULRuntime.h"
38
#include "nsKDEUtils.h"
38
39
39
using namespace mozilla;
40
using namespace mozilla;
40
41
41
struct ManifestDirective
42
struct ManifestDirective
42
{
43
{
43
  const char* directive;
44
  const char* directive;
44
  int argc;
45
  int argc;
45
46
Lines 397-412 ParseManifest(NSLocationType type, FileL Link Here
397
  NS_NAMED_LITERAL_STRING(kPlatform, "platform");
398
  NS_NAMED_LITERAL_STRING(kPlatform, "platform");
398
  NS_NAMED_LITERAL_STRING(kContentAccessible, "contentaccessible");
399
  NS_NAMED_LITERAL_STRING(kContentAccessible, "contentaccessible");
399
  NS_NAMED_LITERAL_STRING(kApplication, "application");
400
  NS_NAMED_LITERAL_STRING(kApplication, "application");
400
  NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
401
  NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
401
  NS_NAMED_LITERAL_STRING(kGeckoVersion, "platformversion");
402
  NS_NAMED_LITERAL_STRING(kGeckoVersion, "platformversion");
402
  NS_NAMED_LITERAL_STRING(kOs, "os");
403
  NS_NAMED_LITERAL_STRING(kOs, "os");
403
  NS_NAMED_LITERAL_STRING(kOsVersion, "osversion");
404
  NS_NAMED_LITERAL_STRING(kOsVersion, "osversion");
404
  NS_NAMED_LITERAL_STRING(kABI, "abi");
405
  NS_NAMED_LITERAL_STRING(kABI, "abi");
406
  NS_NAMED_LITERAL_STRING(kDesktop, "desktop");
405
#if defined(MOZ_WIDGET_ANDROID)
407
#if defined(MOZ_WIDGET_ANDROID)
406
  NS_NAMED_LITERAL_STRING(kTablet, "tablet");
408
  NS_NAMED_LITERAL_STRING(kTablet, "tablet");
407
#endif
409
#endif
408
410
409
  // Obsolete
411
  // Obsolete
410
  NS_NAMED_LITERAL_STRING(kXPCNativeWrappers, "xpcnativewrappers");
412
  NS_NAMED_LITERAL_STRING(kXPCNativeWrappers, "xpcnativewrappers");
411
413
412
  nsAutoString appID;
414
  nsAutoString appID;
Lines 444-484 ParseManifest(NSLocationType type, FileL Link Here
444
        CopyUTF8toUTF16(s, abi);
446
        CopyUTF8toUTF16(s, abi);
445
        abi.Insert(PRUnichar('_'), 0);
447
        abi.Insert(PRUnichar('_'), 0);
446
        abi.Insert(osTarget, 0);
448
        abi.Insert(osTarget, 0);
447
      }
449
      }
448
    }
450
    }
449
  }
451
  }
450
452
451
  nsAutoString osVersion;
453
  nsAutoString osVersion;
454
  nsAutoString desktop;
452
#if defined(XP_WIN)
455
#if defined(XP_WIN)
453
  OSVERSIONINFO info = { sizeof(OSVERSIONINFO) };
456
  OSVERSIONINFO info = { sizeof(OSVERSIONINFO) };
454
  if (GetVersionEx(&info)) {
457
  if (GetVersionEx(&info)) {
455
    nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
458
    nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
456
                                         info.dwMajorVersion,
459
                                         info.dwMajorVersion,
457
                                         info.dwMinorVersion);
460
                                         info.dwMinorVersion);
458
  }
461
  }
462
  desktop = NS_LITERAL_STRING("win");
459
#elif defined(MOZ_WIDGET_COCOA)
463
#elif defined(MOZ_WIDGET_COCOA)
460
  SInt32 majorVersion, minorVersion;
464
  SInt32 majorVersion, minorVersion;
461
  if ((Gestalt(gestaltSystemVersionMajor, &majorVersion) == noErr) &&
465
  if ((Gestalt(gestaltSystemVersionMajor, &majorVersion) == noErr) &&
462
      (Gestalt(gestaltSystemVersionMinor, &minorVersion) == noErr)) {
466
      (Gestalt(gestaltSystemVersionMinor, &minorVersion) == noErr)) {
463
    nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
467
    nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
464
                                         majorVersion,
468
                                         majorVersion,
465
                                         minorVersion);
469
                                         minorVersion);
466
  }
470
  }
471
  desktop = NS_LITERAL_STRING("macosx");
467
#elif defined(MOZ_WIDGET_GTK)
472
#elif defined(MOZ_WIDGET_GTK)
468
  nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
473
  nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
469
                                       gtk_major_version,
474
                                       gtk_major_version,
470
                                       gtk_minor_version);
475
                                       gtk_minor_version);
476
  desktop = nsKDEUtils::kdeSession() ? NS_LITERAL_STRING("kde") : NS_LITERAL_STRING("gnome");
471
#elif defined(MOZ_WIDGET_ANDROID)
477
#elif defined(MOZ_WIDGET_ANDROID)
472
  bool isTablet = false;
478
  bool isTablet = false;
473
  if (mozilla::AndroidBridge::Bridge()) {
479
  if (mozilla::AndroidBridge::Bridge()) {
474
    mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", osVersion);
480
    mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION", "RELEASE", osVersion);
475
    isTablet = mozilla::AndroidBridge::Bridge()->IsTablet();
481
    isTablet = mozilla::AndroidBridge::Bridge()->IsTablet();
476
  }
482
  }
483
  desktop = NS_LITERAL_STRING("android");
477
#endif
484
#endif
478
485
479
  // Because contracts must be registered after CIDs, we save and process them
486
  // Because contracts must be registered after CIDs, we save and process them
480
  // at the end.
487
  // at the end.
481
  nsTArray<CachedDirective> contracts;
488
  nsTArray<CachedDirective> contracts;
482
489
483
  char *token;
490
  char *token;
484
  char *newline = buf;
491
  char *newline = buf;
Lines 560-583 ParseManifest(NSLocationType type, FileL Link Here
560
    TriState stOsVersion = eUnspecified;
567
    TriState stOsVersion = eUnspecified;
561
    TriState stOs = eUnspecified;
568
    TriState stOs = eUnspecified;
562
    TriState stABI = eUnspecified;
569
    TriState stABI = eUnspecified;
563
#if defined(MOZ_WIDGET_ANDROID)
570
#if defined(MOZ_WIDGET_ANDROID)
564
    TriState stTablet = eUnspecified;
571
    TriState stTablet = eUnspecified;
565
#endif
572
#endif
566
    bool platform = false;
573
    bool platform = false;
567
    bool contentAccessible = false;
574
    bool contentAccessible = false;
575
    TriState stDesktop = eUnspecified;
568
576
569
    while (NULL != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) && ok) {
577
    while (NULL != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) && ok) {
570
      ToLowerCase(token);
578
      ToLowerCase(token);
571
      NS_ConvertASCIItoUTF16 wtoken(token);
579
      NS_ConvertASCIItoUTF16 wtoken(token);
572
580
573
      if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
581
      if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
574
          CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
582
          CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
575
          CheckStringFlag(kABI, wtoken, abi, stABI) ||
583
          CheckStringFlag(kABI, wtoken, abi, stABI) ||
584
          CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
576
          CheckVersionFlag(kOsVersion, wtoken, osVersion, stOsVersion) ||
585
          CheckVersionFlag(kOsVersion, wtoken, osVersion, stOsVersion) ||
577
          CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion) ||
586
          CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion) ||
578
          CheckVersionFlag(kGeckoVersion, wtoken, geckoVersion, stGeckoVersion))
587
          CheckVersionFlag(kGeckoVersion, wtoken, geckoVersion, stGeckoVersion))
579
        continue;
588
        continue;
580
589
581
#if defined(MOZ_WIDGET_ANDROID)
590
#if defined(MOZ_WIDGET_ANDROID)
582
      bool tablet = false;
591
      bool tablet = false;
583
      if (CheckFlag(kTablet, wtoken, tablet)) {
592
      if (CheckFlag(kTablet, wtoken, tablet)) {
Lines 606-621 ParseManifest(NSLocationType type, FileL Link Here
606
    }
615
    }
607
616
608
    if (!ok ||
617
    if (!ok ||
609
        stApp == eBad ||
618
        stApp == eBad ||
610
        stAppVersion == eBad ||
619
        stAppVersion == eBad ||
611
        stGeckoVersion == eBad ||
620
        stGeckoVersion == eBad ||
612
        stOs == eBad ||
621
        stOs == eBad ||
613
        stOsVersion == eBad ||
622
        stOsVersion == eBad ||
623
        stDesktop == eBad ||
614
#ifdef MOZ_WIDGET_ANDROID
624
#ifdef MOZ_WIDGET_ANDROID
615
        stTablet == eBad ||
625
        stTablet == eBad ||
616
#endif
626
#endif
617
        stABI == eBad)
627
        stABI == eBad)
618
      continue;
628
      continue;
619
629
620
    if (directive->regfunc) {
630
    if (directive->regfunc) {
621
      if (GeckoProcessType_Default != XRE_GetProcessType())
631
      if (GeckoProcessType_Default != XRE_GetProcessType())
(-)a/xpcom/io/Makefile.in (-1 / +1 lines)
Lines 43-59 include $(topsrcdir)/ipc/chromium/chromi Link Here
43
DEFINES		+= -D_IMPL_NS_COM
43
DEFINES		+= -D_IMPL_NS_COM
44
44
45
ifeq ($(OS_ARCH),Linux)
45
ifeq ($(OS_ARCH),Linux)
46
ifneq (,$(findstring lib64,$(libdir)))
46
ifneq (,$(findstring lib64,$(libdir)))
47
DEFINES     += -DHAVE_USR_LIB64_DIR
47
DEFINES     += -DHAVE_USR_LIB64_DIR
48
endif
48
endif
49
endif
49
endif
50
50
51
LOCAL_INCLUDES	+= -I..
51
LOCAL_INCLUDES	+= -I.. -I$(topsrcdir)/toolkit/xre
52
52
53
ifeq ($(MOZ_PLATFORM_MAEMO),5)
53
ifeq ($(MOZ_PLATFORM_MAEMO),5)
54
CFLAGS          += $(MOZ_DBUS_CFLAGS)
54
CFLAGS          += $(MOZ_DBUS_CFLAGS)
55
CXXFLAGS        += $(MOZ_DBUS_CFLAGS)
55
CXXFLAGS        += $(MOZ_DBUS_CFLAGS)
56
endif
56
endif
57
57
58
ifdef MOZ_PLATFORM_MAEMO
58
ifdef MOZ_PLATFORM_MAEMO
59
CFLAGS          += $(MOZ_PLATFORM_MAEMO_CFLAGS) $(MOZ_QT_CFLAGS)
59
CFLAGS          += $(MOZ_PLATFORM_MAEMO_CFLAGS) $(MOZ_QT_CFLAGS)
(-)a/xpcom/io/nsLocalFileUnix.cpp (-14 / +29 lines)
Lines 50-65 Link Here
50
#include "prproces.h"
50
#include "prproces.h"
51
#include "nsIDirectoryEnumerator.h"
51
#include "nsIDirectoryEnumerator.h"
52
#include "nsISimpleEnumerator.h"
52
#include "nsISimpleEnumerator.h"
53
#include "private/pprio.h"
53
#include "private/pprio.h"
54
54
55
#ifdef MOZ_WIDGET_GTK
55
#ifdef MOZ_WIDGET_GTK
56
#include "nsIGIOService.h"
56
#include "nsIGIOService.h"
57
#include "nsIGnomeVFSService.h"
57
#include "nsIGnomeVFSService.h"
58
#include "nsKDEUtils.h"
58
#endif
59
#endif
59
60
60
#ifdef MOZ_WIDGET_COCOA
61
#ifdef MOZ_WIDGET_COCOA
61
#include <Carbon/Carbon.h>
62
#include <Carbon/Carbon.h>
62
#include "CocoaFileUtils.h"
63
#include "CocoaFileUtils.h"
63
#include "prmem.h"
64
#include "prmem.h"
64
#include "plbase64.h"
65
#include "plbase64.h"
65
66
Lines 1753-1796 nsLocalFile::SetPersistentDescriptor(con Link Here
1753
    return InitWithNativePath(aPersistentDescriptor);
1754
    return InitWithNativePath(aPersistentDescriptor);
1754
#endif
1755
#endif
1755
}
1756
}
1756
1757
1757
NS_IMETHODIMP
1758
NS_IMETHODIMP
1758
nsLocalFile::Reveal()
1759
nsLocalFile::Reveal()
1759
{
1760
{
1760
#ifdef MOZ_WIDGET_GTK
1761
#ifdef MOZ_WIDGET_GTK
1761
    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
1762
    nsAutoCString url;
1762
    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
1763
    if (!giovfs && !gnomevfs)
1764
        return NS_ERROR_FAILURE;
1765
1766
    bool isDirectory;
1763
    bool isDirectory;
1767
    if (NS_FAILED(IsDirectory(&isDirectory)))
1764
    if (NS_FAILED(IsDirectory(&isDirectory)))
1768
        return NS_ERROR_FAILURE;
1765
        return NS_ERROR_FAILURE;
1769
1766
1770
    if (isDirectory) {
1767
    if (isDirectory) {
1771
        if (giovfs)
1768
        url = mPath;
1772
            return giovfs->ShowURIForInput(mPath);
1773
        else 
1774
            /* Fallback to GnomeVFS */
1775
            return gnomevfs->ShowURIForInput(mPath);
1776
    } else {
1769
    } else {
1777
        nsCOMPtr<nsIFile> parentDir;
1770
        nsCOMPtr<nsIFile> parentDir;
1778
        nsAutoCString dirPath;
1771
        nsAutoCString dirPath;
1779
        if (NS_FAILED(GetParent(getter_AddRefs(parentDir))))
1772
        if (NS_FAILED(GetParent(getter_AddRefs(parentDir))))
1780
            return NS_ERROR_FAILURE;
1773
            return NS_ERROR_FAILURE;
1781
        if (NS_FAILED(parentDir->GetNativePath(dirPath)))
1774
        if (NS_FAILED(parentDir->GetNativePath(dirPath)))
1782
            return NS_ERROR_FAILURE;
1775
            return NS_ERROR_FAILURE;
1783
1776
1784
        if (giovfs)
1777
        url = dirPath;
1785
            return giovfs->ShowURIForInput(dirPath);
1786
        else 
1787
            return gnomevfs->ShowURIForInput(dirPath);        
1788
    }
1778
    }
1779
1780
    if(nsKDEUtils::kdeSupport()) {
1781
      nsTArray<nsCString> command;
1782
      command.AppendElement( NS_LITERAL_CSTRING("REVEAL") );
1783
      command.AppendElement( mPath );
1784
      return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
1785
    }
1786
1787
    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
1788
    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
1789
    if (!giovfs && !gnomevfs)
1790
      return NS_ERROR_FAILURE;
1791
1792
    if (giovfs)
1793
      return giovfs->ShowURIForInput(url);
1794
    else
1795
      return gnomevfs->ShowURIForInput(url);
1796
1789
#elif defined(MOZ_WIDGET_COCOA)
1797
#elif defined(MOZ_WIDGET_COCOA)
1790
    CFURLRef url;
1798
    CFURLRef url;
1791
    if (NS_SUCCEEDED(GetCFURL(&url))) {
1799
    if (NS_SUCCEEDED(GetCFURL(&url))) {
1792
      nsresult rv = CocoaFileUtils::RevealFileInFinder(url);
1800
      nsresult rv = CocoaFileUtils::RevealFileInFinder(url);
1793
      ::CFRelease(url);
1801
      ::CFRelease(url);
1794
      return rv;
1802
      return rv;
1795
    }
1803
    }
1796
    return NS_ERROR_FAILURE;
1804
    return NS_ERROR_FAILURE;
Lines 1816-1831 nsLocalFile::Launch() Link Here
1816
1824
1817
    if (nullptr == connection)
1825
    if (nullptr == connection)
1818
      return NS_ERROR_FAILURE;
1826
      return NS_ERROR_FAILURE;
1819
1827
1820
    if (hildon_mime_open_file(connection, mPath.get()) != kHILDON_SUCCESS)
1828
    if (hildon_mime_open_file(connection, mPath.get()) != kHILDON_SUCCESS)
1821
      return NS_ERROR_FAILURE;
1829
      return NS_ERROR_FAILURE;
1822
    return NS_OK;
1830
    return NS_OK;
1823
#else
1831
#else
1832
    if( nsKDEUtils::kdeSupport()) {
1833
      nsTArray<nsCString> command;
1834
      command.AppendElement( NS_LITERAL_CSTRING("OPEN") );
1835
      command.AppendElement( mPath );
1836
      return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
1837
    }
1838
1824
    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
1839
    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
1825
    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
1840
    nsCOMPtr<nsIGnomeVFSService> gnomevfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
1826
    if (giovfs) {
1841
    if (giovfs) {
1827
      return giovfs->ShowURIForInput(mPath);
1842
      return giovfs->ShowURIForInput(mPath);
1828
    } else if (gnomevfs) {
1843
    } else if (gnomevfs) {
1829
      /* GnomeVFS fallback */
1844
      /* GnomeVFS fallback */
1830
      return gnomevfs->ShowURIForInput(mPath);
1845
      return gnomevfs->ShowURIForInput(mPath);
1831
    }
1846
    }

Return to bug 493722