/[packages]/cauldron/xulrunner/current/SOURCES/xulrunner-1.9.2-kde-integration.patch
ViewVC logotype

Contents of /cauldron/xulrunner/current/SOURCES/xulrunner-1.9.2-kde-integration.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 18113 - (show annotations) (download)
Fri Jan 14 23:22:39 2011 UTC (13 years, 3 months ago) by dmorgan
File size: 132226 byte(s)
imported package xulrunner
1 --- mozilla-1.9.2/chrome/src/Makefile.in.kde-integration 2010-07-22 23:54:44.000000000 +0200
2 +++ mozilla-1.9.2/chrome/src/Makefile.in 2010-07-25 09:24:07.000000000 +0200
3 @@ -86,6 +86,7 @@
4
5 ifneq (,$(filter gtk2,$(MOZ_WIDGET_TOOLKIT)))
6 EXTRA_DSO_LDOPTS += $(MOZ_GTK2_LIBS)
7 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
8 endif
9
10 ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
11 --- mozilla-1.9.2/chrome/src/nsChromeRegistry.cpp.kde-integration 2010-07-22 23:54:44.000000000 +0200
12 +++ mozilla-1.9.2/chrome/src/nsChromeRegistry.cpp 2010-07-25 09:24:07.000000000 +0200
13 @@ -114,6 +114,7 @@
14 #include "nsIXULAppInfo.h"
15 #include "nsIXULRuntime.h"
16 #include "nsPresShellIterator.h"
17 +#include "nsKDEUtils.h"
18
19 #define UILOCALE_CMD_LINE_ARG "UILocale"
20
21 @@ -1613,6 +1614,7 @@
22 NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
23 NS_NAMED_LITERAL_STRING(kOs, "os");
24 NS_NAMED_LITERAL_STRING(kOsVersion, "osversion");
25 + NS_NAMED_LITERAL_STRING(kDesktop, "desktop");
26
27 nsCOMPtr<nsIIOService> io (do_GetIOService());
28 if (!io) return NS_ERROR_FAILURE;
29 @@ -1656,6 +1658,7 @@
30 }
31
32 nsAutoString osVersion;
33 + nsAutoString desktop;
34 #if defined(XP_WIN)
35 OSVERSIONINFO info = { sizeof(OSVERSIONINFO) };
36 if (GetVersionEx(&info)) {
37 @@ -1663,6 +1666,7 @@
38 info.dwMajorVersion,
39 info.dwMinorVersion);
40 }
41 + desktop = NS_LITERAL_STRING("win");
42 #elif defined(XP_MACOSX)
43 long majorVersion, minorVersion;
44 if ((Gestalt(gestaltSystemVersionMajor, &majorVersion) == noErr) &&
45 @@ -1671,10 +1675,12 @@
46 majorVersion,
47 minorVersion);
48 }
49 + desktop = NS_LITERAL_STRING("macosx");
50 #elif defined(MOZ_WIDGET_GTK2)
51 nsTextFormatter::ssprintf(osVersion, NS_LITERAL_STRING("%ld.%ld").get(),
52 gtk_major_version,
53 gtk_minor_version);
54 + desktop = nsKDEUtils::kdeSession() ? NS_LITERAL_STRING("kde") : NS_LITERAL_STRING("gnome"); // TODO others?
55 #endif
56
57 char *token;
58 @@ -1718,6 +1724,7 @@
59 TriState stApp = eUnspecified;
60 TriState stOsVersion = eUnspecified;
61 TriState stOs = eUnspecified;
62 + TriState stDesktop = eUnspecified;
63
64 PRBool badFlag = PR_FALSE;
65
66 @@ -1731,6 +1738,7 @@
67 CheckFlag(kContentAccessible, wtoken, contentAccessible) ||
68 CheckStringFlag(kApplication, wtoken, appID, stApp) ||
69 CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
70 + CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
71 CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
72 CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
73 continue;
74 @@ -1742,7 +1750,7 @@
75 }
76
77 if (badFlag || stApp == eBad || stAppVersion == eBad ||
78 - stOs == eBad || stOsVersion == eBad)
79 + stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
80 continue;
81
82 nsCOMPtr<nsIURI> resolved;
83 @@ -1803,6 +1811,7 @@
84 TriState stApp = eUnspecified;
85 TriState stOs = eUnspecified;
86 TriState stOsVersion = eUnspecified;
87 + TriState stDesktop = eUnspecified;
88
89 PRBool badFlag = PR_FALSE;
90
91 @@ -1813,6 +1822,7 @@
92
93 if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
94 CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
95 + CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
96 CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
97 CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
98 continue;
99 @@ -1824,7 +1834,7 @@
100 }
101
102 if (badFlag || stApp == eBad || stAppVersion == eBad ||
103 - stOs == eBad || stOsVersion == eBad)
104 + stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
105 continue;
106
107 nsCOMPtr<nsIURI> resolved;
108 @@ -1865,6 +1875,7 @@
109 TriState stApp = eUnspecified;
110 TriState stOs = eUnspecified;
111 TriState stOsVersion = eUnspecified;
112 + TriState stDesktop = eUnspecified;
113
114 PRBool badFlag = PR_FALSE;
115
116 @@ -1875,6 +1886,7 @@
117
118 if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
119 CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
120 + CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
121 CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
122 CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
123 continue;
124 @@ -1886,7 +1898,7 @@
125 }
126
127 if (badFlag || stApp == eBad || stAppVersion == eBad ||
128 - stOs == eBad || stOsVersion == eBad)
129 + stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
130 continue;
131
132 nsCOMPtr<nsIURI> resolved;
133 @@ -1929,6 +1941,7 @@
134 TriState stApp = eUnspecified;
135 TriState stOs = eUnspecified;
136 TriState stOsVersion = eUnspecified;
137 + TriState stDesktop = eUnspecified;
138
139 PRBool badFlag = PR_FALSE;
140
141 @@ -1939,6 +1952,7 @@
142
143 if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
144 CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
145 + CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
146 CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
147 CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
148 continue;
149 @@ -1950,7 +1964,7 @@
150 }
151
152 if (badFlag || stApp == eBad || stAppVersion == eBad ||
153 - stOs == eBad || stOsVersion == eBad)
154 + stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
155 continue;
156
157 nsCOMPtr<nsIURI> baseuri, overlayuri;
158 @@ -1985,6 +1999,7 @@
159 TriState stApp = eUnspecified;
160 TriState stOs = eUnspecified;
161 TriState stOsVersion = eUnspecified;
162 + TriState stDesktop = eUnspecified;
163
164 PRBool badFlag = PR_FALSE;
165
166 @@ -1995,6 +2010,7 @@
167
168 if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
169 CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
170 + CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
171 CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
172 CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
173 continue;
174 @@ -2006,7 +2022,7 @@
175 }
176
177 if (badFlag || stApp == eBad || stAppVersion == eBad ||
178 - stOs == eBad || stOsVersion == eBad)
179 + stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
180 continue;
181
182 nsCOMPtr<nsIURI> baseuri, overlayuri;
183 @@ -2045,6 +2061,7 @@
184 TriState stApp = eUnspecified;
185 TriState stOs = eUnspecified;
186 TriState stOsVersion = eUnspecified;
187 + TriState stDesktop = eUnspecified;
188
189 PRBool badFlag = PR_FALSE;
190
191 @@ -2055,6 +2072,7 @@
192
193 if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
194 CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
195 + CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
196 CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
197 CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
198 continue;
199 @@ -2066,7 +2084,7 @@
200 }
201
202 if (badFlag || stApp == eBad || stAppVersion == eBad ||
203 - stOs == eBad || stOsVersion == eBad)
204 + stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
205 continue;
206
207 nsCOMPtr<nsIURI> chromeuri, resolveduri;
208 @@ -2107,6 +2125,7 @@
209 TriState stApp = eUnspecified;
210 TriState stOsVersion = eUnspecified;
211 TriState stOs = eUnspecified;
212 + TriState stDesktop = eUnspecified;
213
214 PRBool badFlag = PR_FALSE;
215
216 @@ -2117,6 +2136,7 @@
217
218 if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
219 CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
220 + CheckStringFlag(kDesktop, wtoken, desktop, stDesktop) ||
221 CheckVersionFlag(kOsVersion, wtoken, osVersion, vc, stOsVersion) ||
222 CheckVersionFlag(kAppVersion, wtoken, appVersion, vc, stAppVersion))
223 continue;
224 @@ -2128,7 +2148,7 @@
225 }
226
227 if (badFlag || stApp == eBad || stAppVersion == eBad ||
228 - stOs == eBad || stOsVersion == eBad)
229 + stOs == eBad || stOsVersion == eBad || stDesktop == eBad)
230 continue;
231
232 nsDependentCString host(package);
233 --- mozilla-1.9.2/modules/libpref/src/Makefile.in.kde-integration 2010-07-22 23:55:10.000000000 +0200
234 +++ mozilla-1.9.2/modules/libpref/src/Makefile.in 2010-07-25 09:24:07.000000000 +0200
235 @@ -102,3 +102,5 @@
236 @$(MAKE_DEPS_AUTO_CXX)
237 $(ELOG) $(CCC) $(OUTOPTION)$@ -c $(COMPILE_CXXFLAGS:-O2=-O1) $(_VPATH_SRCS)
238 endif
239 +
240 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
241 --- mozilla-1.9.2/modules/libpref/src/nsPrefService.cpp.kde-integration 2010-07-22 23:55:10.000000000 +0200
242 +++ mozilla-1.9.2/modules/libpref/src/nsPrefService.cpp 2010-07-25 09:24:07.000000000 +0200
243 @@ -52,6 +52,7 @@
244 #include "nsCOMArray.h"
245 #include "nsXPCOMCID.h"
246 #include "nsAutoPtr.h"
247 +#include "nsKDEUtils.h"
248
249 #include "nsQuickSort.h"
250 #include "prmem.h"
251 @@ -615,7 +616,8 @@
252 return rv;
253 }
254
255 -static nsresult pref_LoadPrefsInDirList(const char *listId)
256 +static nsresult pref_LoadPrefsInDirList(const char *listId,
257 + char const *const *aSpecialFiles = NULL, PRUint32 aSpecialFilesCount = 0)
258 {
259 nsresult rv;
260 nsCOMPtr<nsIProperties> dirSvc(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv));
261 @@ -634,7 +636,7 @@
262 nsCOMPtr<nsIFile> dir = do_QueryInterface(elem);
263 if (dir) {
264 // Do we care if a file provided by this process fails to load?
265 - pref_LoadPrefsInDir(dir, nsnull, 0);
266 + pref_LoadPrefsInDir(dir, aSpecialFiles, aSpecialFilesCount);
267 }
268 }
269 }
270 @@ -685,6 +687,7 @@
271 #if defined(MOZ_WIDGET_PHOTON)
272 , "photon.js"
273 #endif
274 + , "" // placeholder for KDE (empty is otherwise harmless)
275 #elif defined(XP_OS2)
276 "os2pref.js"
277 #elif defined(XP_BEOS)
278 @@ -692,12 +695,23 @@
279 #endif
280 };
281
282 + if( nsKDEUtils::kdeSession()) { // TODO what if some setup actually requires the helper?
283 + for( int i = 0;
284 + i < NS_ARRAY_LENGTH(specialFiles);
285 + ++i ) {
286 + if( *specialFiles[ i ] == '\0' ) {
287 + specialFiles[ i ] = "kde.js";
288 + break;
289 + }
290 + }
291 + }
292 +
293 rv = pref_LoadPrefsInDir(defaultPrefDir, specialFiles, NS_ARRAY_LENGTH(specialFiles));
294 if (NS_FAILED(rv)) {
295 NS_WARNING("Error parsing application default preferences.");
296 }
297
298 - rv = pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST);
299 + rv = pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST, specialFiles, NS_ARRAY_LENGTH(specialFiles));
300 NS_ENSURE_SUCCESS(rv, rv);
301
302 NS_CreateServicesFromCategory(NS_PREFSERVICE_APPDEFAULTS_TOPIC_ID,
303 --- mozilla-1.9.2/toolkit/components/downloads/src/Makefile.in.kde-integration 2010-07-22 23:55:21.000000000 +0200
304 +++ mozilla-1.9.2/toolkit/components/downloads/src/Makefile.in 2010-07-25 09:24:07.000000000 +0200
305 @@ -97,3 +97,4 @@
306
307 EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
308
309 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
310 --- mozilla-1.9.2/toolkit/components/downloads/src/nsDownloadManager.cpp.kde-integration 2010-07-22 23:55:22.000000000 +0200
311 +++ mozilla-1.9.2/toolkit/components/downloads/src/nsDownloadManager.cpp 2010-07-25 09:24:07.000000000 +0200
312 @@ -76,6 +76,10 @@
313 #endif
314 #endif
315
316 +#if defined(XP_UNIX) && !defined(XP_MACOSX)
317 +#include "nsKDEUtils.h"
318 +#endif
319 +
320 #ifdef XP_MACOSX
321 #include <CoreFoundation/CoreFoundation.h>
322 #endif
323 @@ -2165,6 +2169,15 @@
324 pref->GetBoolPref(PREF_BDM_SHOWALERTONCOMPLETE, &showTaskbarAlert);
325
326 if (showTaskbarAlert) {
327 + if( nsKDEUtils::kdeSupport()) {
328 + nsCStringArray command;
329 + command.AppendCString( NS_LITERAL_CSTRING( "DOWNLOADFINISHED" ));
330 + nsAutoString displayName;
331 + GetDisplayName( displayName );
332 + command.AppendCString( nsCAutoString( ToNewUTF8String( displayName )));
333 + nsKDEUtils::command( command );
334 + } else {
335 + // begin non-KDE block
336 PRInt32 alertInterval = 2000;
337 if (pref)
338 pref->GetIntPref(PREF_BDM_SHOWALERTINTERVAL, &alertInterval);
339 @@ -2200,6 +2213,7 @@
340 EmptyString());
341 }
342 }
343 + } // end non-KDE block
344 }
345 #if (defined(XP_WIN) && !defined(WINCE)) || defined(XP_MACOSX)
346 nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mTarget);
347 --- mozilla-1.9.2/toolkit/content/jar.mn.kde-integration 2010-07-22 23:55:22.000000000 +0200
348 +++ mozilla-1.9.2/toolkit/content/jar.mn 2010-07-25 09:24:07.000000000 +0200
349 @@ -49,6 +49,8 @@
350 *+ content/global/bindings/colorpicker.xml (widgets/colorpicker.xml)
351 *+ content/global/bindings/datetimepicker.xml (widgets/datetimepicker.xml)
352 *+ content/global/bindings/dialog.xml (widgets/dialog.xml)
353 +*+ content/global/bindings/dialog-kde.xml (widgets/dialog-kde.xml)
354 +% override chrome://global/content/bindings/dialog.xml chrome://global/content/bindings/dialog-kde.xml desktop=kde
355 *+ content/global/bindings/editor.xml (widgets/editor.xml)
356 * content/global/bindings/expander.xml (widgets/expander.xml)
357 * content/global/bindings/filefield.xml (widgets/filefield.xml)
358 @@ -62,6 +64,8 @@
359 *+ content/global/bindings/numberbox.xml (widgets/numberbox.xml)
360 *+ content/global/bindings/popup.xml (widgets/popup.xml)
361 *+ content/global/bindings/preferences.xml (widgets/preferences.xml)
362 +*+ content/global/bindings/preferences-kde.xml (widgets/preferences-kde.xml)
363 +% override chrome://global/content/bindings/preferences.xml chrome://global/content/bindings/preferences-kde.xml desktop=kde
364 *+ content/global/bindings/progressmeter.xml (widgets/progressmeter.xml)
365 *+ content/global/bindings/radio.xml (widgets/radio.xml)
366 *+ content/global/bindings/resizer.xml (widgets/resizer.xml)
367 --- mozilla-1.9.2/toolkit/content/widgets/dialog-kde.xml.kde-integration 2010-07-25 09:24:07.000000000 +0200
368 +++ mozilla-1.9.2/toolkit/content/widgets/dialog-kde.xml 2010-07-25 09:24:07.000000000 +0200
369 @@ -0,0 +1,445 @@
370 +<?xml version="1.0"?>
371 +
372 +<bindings id="dialogBindings"
373 + xmlns="http://www.mozilla.org/xbl"
374 + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
375 + xmlns:xbl="http://www.mozilla.org/xbl">
376 +
377 + <binding id="dialog" extends="chrome://global/content/bindings/general.xml#root-element">
378 + <resources>
379 + <stylesheet src="chrome://global/skin/dialog.css"/>
380 + </resources>
381 + <content>
382 + <xul:vbox class="box-inherit dialog-content-box" flex="1">
383 + <children/>
384 + </xul:vbox>
385 +
386 + <xul:hbox class="dialog-button-box" anonid="buttons"
387 + xbl:inherits="pack=buttonpack,align=buttonalign,dir=buttondir,orient=buttonorient"
388 +#ifdef XP_UNIX_GNOME
389 + >
390 + <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
391 + <xul:button dlgtype="help" class="dialog-button" hidden="true"/>
392 + <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
393 + <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
394 + <xul:spacer anonid="spacer" flex="1"/>
395 + <xul:button dlgtype="cancel" class="dialog-button"/>
396 + <xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
397 +#elif XP_UNIX
398 + pack="end">
399 + <xul:button dlgtype="help" class="dialog-button" hidden="true"/>
400 + <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
401 + <xul:spacer anonid="spacer" flex="1" hidden="true"/>
402 + <xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
403 + <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
404 + <xul:button dlgtype="cancel" class="dialog-button"/>
405 + <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
406 +#else
407 + pack="end">
408 + <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
409 + <xul:spacer anonid="spacer" flex="1" hidden="true"/>
410 + <xul:button dlgtype="accept" class="dialog-button" xbl:inherits="disabled=buttondisabledaccept"/>
411 + <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
412 + <xul:button dlgtype="cancel" class="dialog-button"/>
413 + <xul:button dlgtype="help" class="dialog-button" hidden="true"/>
414 + <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
415 +#endif
416 + </xul:hbox>
417 + </content>
418 +
419 + <implementation>
420 + <field name="_mStrBundle">null</field>
421 + <field name="_closeHandler">(function(event) {
422 + if (!document.documentElement.cancelDialog())
423 + event.preventDefault();
424 + })</field>
425 +
426 + <property name="buttons"
427 + onget="return this.getAttribute('buttons');"
428 + onset="this._configureButtons(val); return val;"/>
429 +
430 + <property name="defaultButton">
431 + <getter>
432 + <![CDATA[
433 + if (this.hasAttribute("defaultButton"))
434 + return this.getAttribute("defaultButton");
435 + else // default to the accept button
436 + return "accept";
437 + ]]>
438 + </getter>
439 + <setter>
440 + <![CDATA[
441 + this._setDefaultButton(val);
442 + return val;
443 + ]]>
444 + </setter>
445 + </property>
446 +
447 + <method name="acceptDialog">
448 + <body>
449 + <![CDATA[
450 + return this._doButtonCommand("accept");
451 + ]]>
452 + </body>
453 + </method>
454 +
455 + <method name="cancelDialog">
456 + <body>
457 + <![CDATA[
458 + return this._doButtonCommand("cancel");
459 + ]]>
460 + </body>
461 + </method>
462 +
463 + <method name="getButton">
464 + <parameter name="aDlgType"/>
465 + <body>
466 + <![CDATA[
467 + return this._buttons[aDlgType];
468 + ]]>
469 + </body>
470 + </method>
471 +
472 + <method name="moveToAlertPosition">
473 + <body>
474 + <![CDATA[
475 + // hack. we need this so the window has something like its final size
476 + if (window.outerWidth == 1) {
477 + dump("Trying to position a sizeless window; caller should have called sizeToContent() or sizeTo(). See bug 75649.\n");
478 + sizeToContent();
479 + }
480 +
481 + var xOffset = (opener.outerWidth - window.outerWidth) / 2;
482 + var yOffset = opener.outerHeight / 5;
483 +
484 + var newX = opener.screenX + xOffset;
485 + var newY = opener.screenY + yOffset;
486 +
487 + // ensure the window is fully onscreen (if smaller than the screen)
488 + if (newX < screen.availLeft)
489 + newX = screen.availLeft + 20;
490 + if ((newX + window.outerWidth) > (screen.availLeft + screen.availWidth))
491 + newX = (screen.availLeft + screen.availWidth) - window.outerWidth - 20;
492 +
493 + if (newY < screen.availTop)
494 + newY = screen.availTop + 20;
495 + if ((newY + window.outerHeight) > (screen.availTop + screen.availHeight))
496 + newY = (screen.availTop + screen.availHeight) - window.outerHeight - 60;
497 +
498 + window.moveTo( newX, newY );
499 + ]]>
500 + </body>
501 + </method>
502 +
503 + <method name="centerWindowOnScreen">
504 + <body>
505 + <![CDATA[
506 + var xOffset = screen.availWidth/2 - window.outerWidth/2;
507 + var yOffset = screen.availHeight/2 - window.outerHeight/2; //(opener.outerHeight *2)/10;
508 +
509 + xOffset = xOffset > 0 ? xOffset : 0;
510 + yOffset = yOffset > 0 ? yOffset : 0;
511 + window.moveTo(xOffset, yOffset);
512 + ]]>
513 + </body>
514 + </method>
515 +
516 + <constructor>
517 + <![CDATA[
518 + this._configureButtons(this.buttons);
519 +
520 + // listen for when window is closed via native close buttons
521 + window.addEventListener("close", this._closeHandler, false);
522 +
523 + // for things that we need to initialize after onload fires
524 + window.addEventListener("load", this.postLoadInit, false);
525 +
526 + window.moveToAlertPosition = this.moveToAlertPosition;
527 + window.centerWindowOnScreen = this.centerWindowOnScreen;
528 + ]]>
529 + </constructor>
530 +
531 + <method name="postLoadInit">
532 + <parameter name="aEvent"/>
533 + <body>
534 + <![CDATA[
535 + function focusInit() {
536 + const dialog = document.documentElement;
537 + const defaultButton = dialog.getButton(dialog.defaultButton);
538 + // give focus to the first focusable element in the dialog
539 + if (!document.commandDispatcher.focusedElement) {
540 + document.commandDispatcher.advanceFocusIntoSubtree(dialog);
541 +
542 + var focusedElt = document.commandDispatcher.focusedElement;
543 + var initialFocusedElt = focusedElt;
544 + while (focusedElt.localName == "tab" ||
545 + focusedElt.getAttribute("noinitialfocus") == "true") {
546 + document.commandDispatcher.advanceFocusIntoSubtree(focusedElt);
547 + focusedElt = document.commandDispatcher.focusedElement;
548 + if (focusedElt == initialFocusedElt)
549 + break;
550 + }
551 +
552 + if (initialFocusedElt.localName == "tab") {
553 + if (focusedElt.hasAttribute("dlgtype")) {
554 + // We don't want to focus on anonymous OK, Cancel, etc. buttons,
555 + // so return focus to the tab itself
556 + initialFocusedElt.focus();
557 + }
558 + }
559 +#ifndef XP_MACOSX
560 + else if (focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton) {
561 + defaultButton.focus();
562 + }
563 +#endif
564 + }
565 +
566 + try {
567 + if (defaultButton)
568 + window.notifyDefaultButtonLoaded(defaultButton);
569 + } catch (e) { }
570 + }
571 +
572 + // Give focus after onload completes, see bug 103197.
573 + setTimeout(focusInit, 0);
574 + ]]>
575 + </body>
576 + </method>
577 +
578 + <property name="mStrBundle">
579 + <getter>
580 + <![CDATA[
581 + if (!this._mStrBundle) {
582 + // need to create string bundle manually instead of using <xul:stringbundle/>
583 + // see bug 63370 for details
584 + this._mStrBundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
585 + .getService(Components.interfaces.nsIStringBundleService)
586 + .createBundle("chrome://global/locale/dialog.properties");
587 + }
588 + return this._mStrBundle;
589 + ]]></getter>
590 + </property>
591 +
592 + <method name="_configureButtons">
593 + <parameter name="aButtons"/>
594 + <body>
595 + <![CDATA[
596 + // by default, get all the anonymous button elements
597 + var buttons = {};
598 + this._buttons = buttons;
599 + buttons.accept = document.getAnonymousElementByAttribute(this, "dlgtype", "accept");
600 + buttons.cancel = document.getAnonymousElementByAttribute(this, "dlgtype", "cancel");
601 + buttons.extra1 = document.getAnonymousElementByAttribute(this, "dlgtype", "extra1");
602 + buttons.extra2 = document.getAnonymousElementByAttribute(this, "dlgtype", "extra2");
603 + buttons.help = document.getAnonymousElementByAttribute(this, "dlgtype", "help");
604 + buttons.disclosure = document.getAnonymousElementByAttribute(this, "dlgtype", "disclosure");
605 +
606 + // look for any overriding explicit button elements
607 + var exBtns = this.getElementsByAttribute("dlgtype", "*");
608 + var dlgtype;
609 + var i;
610 + for (i = 0; i < exBtns.length; ++i) {
611 + dlgtype = exBtns[i].getAttribute("dlgtype");
612 + buttons[dlgtype].hidden = true; // hide the anonymous button
613 + buttons[dlgtype] = exBtns[i];
614 + }
615 +
616 + // add the label and oncommand handler to each button
617 + for (dlgtype in buttons) {
618 + var button = buttons[dlgtype];
619 + button.addEventListener("command", this._handleButtonCommand, true);
620 +
621 + // don't override custom labels with pre-defined labels on explicit buttons
622 + if (!button.hasAttribute("label")) {
623 + // dialog attributes override the default labels in dialog.properties
624 + if (this.hasAttribute("buttonlabel"+dlgtype)) {
625 + button.setAttribute("label", this.getAttribute("buttonlabel"+dlgtype));
626 + if (this.hasAttribute("buttonaccesskey"+dlgtype))
627 + button.setAttribute("accesskey", this.getAttribute("buttonaccesskey"+dlgtype));
628 + } else if (dlgtype != "extra1" && dlgtype != "extra2") {
629 + button.setAttribute("label", this.mStrBundle.GetStringFromName("button-"+dlgtype));
630 + var accessKey = this.mStrBundle.GetStringFromName("accesskey-"+dlgtype);
631 + if (accessKey)
632 + button.setAttribute("accesskey", accessKey);
633 + }
634 + }
635 + // allow specifying alternate icons in the dialog header
636 + if (!button.hasAttribute("icon")) {
637 + // if there's an icon specified, use that
638 + if (this.hasAttribute("buttonicon"+dlgtype))
639 + button.setAttribute("icon", this.getAttribute("buttonicon"+dlgtype));
640 + // otherwise set defaults
641 + else
642 + switch (dlgtype) {
643 + case "accept":
644 + button.setAttribute("icon","accept");
645 + break;
646 + case "cancel":
647 + button.setAttribute("icon","cancel");
648 + break;
649 + case "disclosue":
650 + button.setAttribute("icon","properties");
651 + break;
652 + case "help":
653 + button.setAttribute("icon","help");
654 + break;
655 + default:
656 + break;
657 + }
658 + }
659 + }
660 +
661 + // ensure that hitting enter triggers the default button command
662 + this.defaultButton = this.defaultButton;
663 +
664 + // if there is a special button configuration, use it
665 + if (aButtons) {
666 + // expect a comma delimited list of dlgtype values
667 + var list = aButtons.split(",");
668 +
669 + // mark shown dlgtypes as true
670 + var shown = { accept: false, cancel: false, help: false,
671 + disclosure: false, extra1: false, extra2: false };
672 + for (i = 0; i < list.length; ++i)
673 + shown[list[i].replace(/ /g, "")] = true;
674 +
675 + // hide/show the buttons we want
676 + for (dlgtype in buttons)
677 + buttons[dlgtype].hidden = !shown[dlgtype];
678 +
679 +#ifdef XP_WIN
680 +# show the spacer on Windows only when the extra2 button is present
681 + var spacer = document.getAnonymousElementByAttribute(this, "anonid", "spacer");
682 + spacer.removeAttribute("hidden");
683 + spacer.setAttribute("flex", shown["extra2"]?"1":"0");
684 +#endif
685 +
686 + }
687 + ]]>
688 + </body>
689 + </method>
690 +
691 + <method name="_setDefaultButton">
692 + <parameter name="aNewDefault"/>
693 + <body>
694 + <![CDATA[
695 + // remove the default attribute from the previous default button, if any
696 + var oldDefaultButton = this.getButton(this.defaultButton);
697 + if (oldDefaultButton)
698 + oldDefaultButton.removeAttribute("default");
699 +
700 + var newDefaultButton = this.getButton(aNewDefault);
701 + if (newDefaultButton) {
702 + this.setAttribute("defaultButton", aNewDefault);
703 + newDefaultButton.setAttribute("default", "true");
704 + }
705 + else {
706 + this.setAttribute("defaultButton", "none");
707 + if (aNewDefault != "none")
708 + dump("invalid new default button: " + aNewDefault + ", assuming: none\n");
709 + }
710 + ]]>
711 + </body>
712 + </method>
713 +
714 + <method name="_handleButtonCommand">
715 + <parameter name="aEvent"/>
716 + <body>
717 + <![CDATA[
718 + return document.documentElement._doButtonCommand(
719 + aEvent.target.getAttribute("dlgtype"));
720 + ]]>
721 + </body>
722 + </method>
723 +
724 + <method name="_doButtonCommand">
725 + <parameter name="aDlgType"/>
726 + <body>
727 + <![CDATA[
728 + var button = this.getButton(aDlgType);
729 + if (!button.disabled) {
730 + var noCancel = this._fireButtonEvent(aDlgType);
731 + if (noCancel) {
732 + if (aDlgType == "accept" || aDlgType == "cancel")
733 + window.close();
734 + }
735 + return noCancel;
736 + }
737 + return true;
738 + ]]>
739 + </body>
740 + </method>
741 +
742 + <method name="_fireButtonEvent">
743 + <parameter name="aDlgType"/>
744 + <body>
745 + <![CDATA[
746 + var event = document.createEvent("Events");
747 + event.initEvent("dialog"+aDlgType, true, true);
748 +
749 + // handle dom event handlers
750 + var noCancel = this.dispatchEvent(event);
751 +
752 + // handle any xml attribute event handlers
753 + var handler = this.getAttribute("ondialog"+aDlgType);
754 + if (handler != "") {
755 + var fn = new Function("event", handler);
756 + var returned = fn(event);
757 + if (returned == false)
758 + noCancel = false;
759 + }
760 +
761 + return noCancel;
762 + ]]>
763 + </body>
764 + </method>
765 +
766 + <method name="_hitEnter">
767 + <parameter name="evt"/>
768 + <body>
769 + <![CDATA[
770 + if (evt.getPreventDefault())
771 + return;
772 +
773 + var btn = this.getButton(this.defaultButton);
774 + if (btn)
775 + this._doButtonCommand(this.defaultButton);
776 + ]]>
777 + </body>
778 + </method>
779 +
780 + </implementation>
781 +
782 + <handlers>
783 + <handler event="keypress" keycode="VK_ENTER"
784 + group="system" action="this._hitEnter(event);"/>
785 + <handler event="keypress" keycode="VK_RETURN"
786 + group="system" action="this._hitEnter(event);"/>
787 + <handler event="keypress" keycode="VK_ESCAPE" group="system">
788 + if (!event.getPreventDefault())
789 + this.cancelDialog();
790 + </handler>
791 +#ifdef XP_MACOSX
792 + <handler event="keypress" key="." modifiers="meta" phase="capturing" action="this.cancelDialog();"/>
793 +#else
794 + <handler event="focus" phase="capturing">
795 + var btn = this.getButton(this.defaultButton);
796 + if (btn)
797 + btn.setAttribute("default", event.originalTarget == btn || !(event.originalTarget instanceof Components.interfaces.nsIDOMXULButtonElement));
798 + </handler>
799 +#endif
800 + </handlers>
801 +
802 + </binding>
803 +
804 + <binding id="dialogheader">
805 + <resources>
806 + <stylesheet src="chrome://global/skin/dialog.css"/>
807 + </resources>
808 + <content>
809 + <xul:label class="dialogheader-title" xbl:inherits="value=title,crop" crop="right" flex="1"/>
810 + <xul:label class="dialogheader-description" xbl:inherits="value=description"/>
811 + </content>
812 + </binding>
813 +
814 +</bindings>
815 --- mozilla-1.9.2/toolkit/content/widgets/preferences-kde.xml.kde-integration 2010-07-25 09:24:07.000000000 +0200
816 +++ mozilla-1.9.2/toolkit/content/widgets/preferences-kde.xml 2010-07-25 09:24:07.000000000 +0200
817 @@ -0,0 +1,1371 @@
818 +<?xml version="1.0"?>
819 +
820 +<!DOCTYPE bindings [
821 + <!ENTITY % preferencesDTD SYSTEM "chrome://global/locale/preferences.dtd">
822 + %preferencesDTD;
823 + <!ENTITY % globalKeysDTD SYSTEM "chrome://global/locale/globalKeys.dtd">
824 + %globalKeysDTD;
825 +]>
826 +
827 +<bindings id="preferencesBindings"
828 + xmlns="http://www.mozilla.org/xbl"
829 + xmlns:xbl="http://www.mozilla.org/xbl"
830 + xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
831 +
832 +#
833 +# = Preferences Window Framework
834 +#
835 +# The syntax for use looks something like:
836 +#
837 +# <prefwindow>
838 +# <prefpane id="prefPaneA">
839 +# <preferences>
840 +# <preference id="preference1" name="app.preference1" type="bool" onchange="foo();"/>
841 +# <preference id="preference2" name="app.preference2" type="bool" useDefault="true"/>
842 +# </preferences>
843 +# <checkbox label="Preference" preference="preference1"/>
844 +# </prefpane>
845 +# </prefwindow>
846 +#
847 +
848 + <binding id="preferences">
849 + <implementation implements="nsIObserver">
850 + <method name="observe">
851 + <parameter name="aSubject"/>
852 + <parameter name="aTopic"/>
853 + <parameter name="aData"/>
854 + <body>
855 + <![CDATA[
856 + for (var i = 0; i < this.childNodes.length; ++i) {
857 + var preference = this.childNodes[i];
858 + if (preference.name == aData) {
859 + preference.value = preference.valueFromPreferences;
860 + }
861 + }
862 + ]]>
863 + </body>
864 + </method>
865 +
866 + <method name="fireChangedEvent">
867 + <parameter name="aPreference"/>
868 + <body>
869 + <![CDATA[
870 + // Value changed, synthesize an event
871 + try {
872 + var event = document.createEvent("Events");
873 + event.initEvent("change", true, true);
874 + aPreference.dispatchEvent(event);
875 + }
876 + catch (e) {
877 + Components.utils.reportError(e);
878 + }
879 + ]]>
880 + </body>
881 + </method>
882 +
883 + <field name="service">
884 + Components.classes["@mozilla.org/preferences-service;1"]
885 + .getService(Components.interfaces.nsIPrefService);
886 + </field>
887 + <field name="rootBranch">
888 + Components.classes["@mozilla.org/preferences-service;1"]
889 + .getService(Components.interfaces.nsIPrefBranch);
890 + </field>
891 + <field name="defaultBranch">
892 + this.service.getDefaultBranch("");
893 + </field>
894 + <field name="rootBranchInternal">
895 + Components.classes["@mozilla.org/preferences-service;1"]
896 + .getService(Components.interfaces.nsIPrefBranchInternal);
897 + </field>
898 + <property name="type" readonly="true">
899 + <getter>
900 + <![CDATA[
901 + return document.documentElement.type || "";
902 + ]]>
903 + </getter>
904 + </property>
905 + <property name="instantApply" readonly="true">
906 + <getter>
907 + <![CDATA[
908 + var doc = document.documentElement;
909 + return this.type == "child" ? doc.instantApply
910 + : doc.instantApply || this.rootBranch.getBoolPref("browser.preferences.instantApply");
911 + ]]>
912 + </getter>
913 + </property>
914 + </implementation>
915 + </binding>
916 +
917 + <binding id="preference">
918 + <implementation>
919 + <constructor>
920 + <![CDATA[
921 + // if the element has been inserted without the name attribute set,
922 + // we have nothing to do here
923 + if (!this.name)
924 + return;
925 +
926 + this.preferences.rootBranchInternal
927 + .addObserver(this.name, this.preferences, false);
928 + // In non-instant apply mode, we must try and use the last saved state
929 + // from any previous opens of a child dialog instead of the value from
930 + // preferences, to pick up any edits a user may have made.
931 + if (this.preferences.type == "child" &&
932 + !this.instantApply && window.opener) {
933 + var pdoc = window.opener.document;
934 +
935 + // Try to find a preference element for the same preference.
936 + var preference = null;
937 + var parentPreferences = pdoc.getElementsByTagName("preferences");
938 + for (var k = 0; (k < parentPreferences.length && !preference); ++k) {
939 + var parentPrefs = parentPreferences[k]
940 + .getElementsByAttribute("name", this.name);
941 + for (var l = 0; (l < parentPrefs.length && !preference); ++l) {
942 + if (parentPrefs[l].localName == "preference")
943 + preference = parentPrefs[l];
944 + }
945 + }
946 + this._setValue(preference ? preference.value
947 + : this.valueFromPreferences, false);
948 + }
949 + else
950 + this._setValue(this.valueFromPreferences, false);
951 + ]]>
952 + </constructor>
953 + <destructor>
954 + this.preferences.rootBranchInternal
955 + .removeObserver(this.name, this.preferences);
956 + </destructor>
957 +
958 + <property name="instantApply">
959 + <getter>
960 + return this.getAttribute("instantApply") == "true" || this.preferences.instantApply;
961 + </getter>
962 + </property>
963 +
964 + <property name="preferences" onget="return this.parentNode"/>
965 + <property name="name" onget="return this.getAttribute('name');">
966 + <setter>
967 + if (val == this.name)
968 + return val;
969 +
970 + this.preferences.rootBranchInternal
971 + .removeObserver(this.name, this.preferences);
972 + this.setAttribute('name', val);
973 + this.preferences.rootBranchInternal
974 + .addObserver(val, this.preferences, false);
975 +
976 + return val;
977 + </setter>
978 + </property>
979 + <property name="type" onget="return this.getAttribute('type');"
980 + onset="this.setAttribute('type', val); return val;"/>
981 + <property name="inverted" onget="return this.getAttribute('inverted') == 'true';"
982 + onset="this.setAttribute('inverted', val); return val;"/>
983 + <property name="readonly" onget="return this.getAttribute('readonly') == 'true';"
984 + onset="this.setAttribute('readonly', val); return val;"/>
985 +
986 + <field name="_value">null</field>
987 + <method name="_setValue">
988 + <parameter name="aValue"/>
989 + <parameter name="aUpdate"/>
990 + <body>
991 + <![CDATA[
992 + if (aUpdate && this.value !== aValue) {
993 + this._value = aValue;
994 + if (this.instantApply)
995 + this.valueFromPreferences = aValue;
996 + this.preferences.fireChangedEvent(this);
997 + }
998 + else if (!aUpdate) {
999 + this._value = aValue;
1000 + this.updateElements();
1001 + }
1002 + return aValue;
1003 + ]]>
1004 + </body>
1005 + </method>
1006 + <property name="value" onget="return this._value" onset="return this._setValue(val, true);"/>
1007 +
1008 + <property name="locked">
1009 + <getter>
1010 + return this.preferences.rootBranch.prefIsLocked(this.name);
1011 + </getter>
1012 + </property>
1013 +
1014 + <property name="disabled">
1015 + <getter>
1016 + return this.getAttribute("disabled") == "true";
1017 + </getter>
1018 + <setter>
1019 + <![CDATA[
1020 + if (val)
1021 + this.setAttribute("disabled", "true");
1022 + else
1023 + this.removeAttribute("disabled");
1024 +
1025 + if (!this.id)
1026 + return val;
1027 +
1028 + var elements = document.getElementsByAttribute("preference", this.id);
1029 + for (var i = 0; i < elements.length; ++i) {
1030 + elements[i].disabled = val;
1031 +
1032 + var labels = document.getElementsByAttribute("control", elements[i].id);
1033 + for (var j = 0; j < labels.length; ++j)
1034 + labels[j].disabled = val;
1035 + }
1036 +
1037 + return val;
1038 + ]]>
1039 + </setter>
1040 + </property>
1041 +
1042 + <property name="tabIndex">
1043 + <getter>
1044 + return parseInt(this.getAttribute("tabindex"));
1045 + </getter>
1046 + <setter>
1047 + <![CDATA[
1048 + if (val)
1049 + this.setAttribute("tabindex", val);
1050 + else
1051 + this.removeAttribute("tabindex");
1052 +
1053 + if (!this.id)
1054 + return val;
1055 +
1056 + var elements = document.getElementsByAttribute("preference", this.id);
1057 + for (var i = 0; i < elements.length; ++i) {
1058 + elements[i].tabIndex = val;
1059 +
1060 + var labels = document.getElementsByAttribute("control", elements[i].id);
1061 + for (var j = 0; j < labels.length; ++j)
1062 + labels[j].tabIndex = val;
1063 + }
1064 +
1065 + return val;
1066 + ]]>
1067 + </setter>
1068 + </property>
1069 +
1070 + <property name="hasUserValue">
1071 + <getter>
1072 + <![CDATA[
1073 + return this.preferences.rootBranch.prefHasUserValue(this.name) &&
1074 + this.value !== undefined;
1075 + ]]>
1076 + </getter>
1077 + </property>
1078 +
1079 + <method name="reset">
1080 + <body>
1081 + // defer reset until preference update
1082 + this.value = undefined;
1083 + </body>
1084 + </method>
1085 +
1086 + <field name="_useDefault">false</field>
1087 + <property name="defaultValue">
1088 + <getter>
1089 + <![CDATA[
1090 + this._useDefault = true;
1091 + var val = this.valueFromPreferences;
1092 + this._useDefault = false;
1093 + return val;
1094 + ]]>
1095 + </getter>
1096 + </property>
1097 +
1098 + <property name="_branch">
1099 + <getter>
1100 + return this._useDefault ? this.preferences.defaultBranch : this.preferences.rootBranch;
1101 + </getter>
1102 + </property>
1103 +
1104 + <field name="batching">false</field>
1105 +
1106 + <method name="_reportUnknownType">
1107 + <body>
1108 + <![CDATA[
1109 + var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
1110 + .getService(Components.interfaces.nsIConsoleService);
1111 + var msg = "<preference> with id='" + this.id + "' and name='" +
1112 + this.name + "' has unknown type '" + this.type + "'.";
1113 + consoleService.logStringMessage(msg);
1114 + ]]>
1115 + </body>
1116 + </method>
1117 +
1118 + <property name="valueFromPreferences">
1119 + <getter>
1120 + <![CDATA[
1121 + try {
1122 + // Force a resync of value with preferences.
1123 + switch (this.type) {
1124 + case "int":
1125 + return this._branch.getIntPref(this.name);
1126 + case "bool":
1127 + var val = this._branch.getBoolPref(this.name);
1128 + return this.inverted ? !val : val;
1129 + case "wstring":
1130 + return this._branch
1131 + .getComplexValue(this.name, Components.interfaces.nsIPrefLocalizedString)
1132 + .data;
1133 + case "string":
1134 + case "unichar":
1135 + return this._branch
1136 + .getComplexValue(this.name, Components.interfaces.nsISupportsString)
1137 + .data;
1138 + case "fontname":
1139 + var family = this._branch
1140 + .getComplexValue(this.name, Components.interfaces.nsISupportsString)
1141 + .data;
1142 + var fontEnumerator = Components.classes["@mozilla.org/gfx/fontenumerator;1"]
1143 + .createInstance(Components.interfaces.nsIFontEnumerator);
1144 + return fontEnumerator.getStandardFamilyName(family);
1145 + case "file":
1146 + var f = this._branch
1147 + .getComplexValue(this.name, Components.interfaces.nsILocalFile);
1148 + return f;
1149 + default:
1150 + this._reportUnknownType();
1151 + }
1152 + }
1153 + catch (e) { }
1154 + return null;
1155 + ]]>
1156 + </getter>
1157 + <setter>
1158 + <![CDATA[
1159 + // Exit early if nothing to do.
1160 + if (this.readonly || this.valueFromPreferences == val)
1161 + return val;
1162 +
1163 + // The special value undefined means 'reset preference to default'.
1164 + if (val === undefined) {
1165 + this.preferences.rootBranch.clearUserPref(this.name);
1166 + return val;
1167 + }
1168 +
1169 + // Force a resync of preferences with value.
1170 + switch (this.type) {
1171 + case "int":
1172 + this.preferences.rootBranch.setIntPref(this.name, val);
1173 + break;
1174 + case "bool":
1175 + this.preferences.rootBranch.setBoolPref(this.name, this.inverted ? !val : val);
1176 + break;
1177 + case "wstring":
1178 + var pls = Components.classes["@mozilla.org/pref-localizedstring;1"]
1179 + .createInstance(Components.interfaces.nsIPrefLocalizedString);
1180 + pls.data = val;
1181 + this.preferences.rootBranch
1182 + .setComplexValue(this.name, Components.interfaces.nsIPrefLocalizedString, pls);
1183 + break;
1184 + case "string":
1185 + case "unichar":
1186 + case "fontname":
1187 + var iss = Components.classes["@mozilla.org/supports-string;1"]
1188 + .createInstance(Components.interfaces.nsISupportsString);
1189 + iss.data = val;
1190 + this.preferences.rootBranch
1191 + .setComplexValue(this.name, Components.interfaces.nsISupportsString, iss);
1192 + break;
1193 + case "file":
1194 + var lf;
1195 + if (typeof(val) == "string") {
1196 + lf = Components.classes["@mozilla.org/file/local;1"]
1197 + .createInstance(Components.interfaces.nsILocalFile);
1198 + lf.persistentDescriptor = val;
1199 + if (!lf.exists())
1200 + lf.initWithPath(val);
1201 + }
1202 + else
1203 + lf = val.QueryInterface(Components.interfaces.nsILocalFile);
1204 + this.preferences.rootBranch
1205 + .setComplexValue(this.name, Components.interfaces.nsILocalFile, lf);
1206 + break;
1207 + default:
1208 + this._reportUnknownType();
1209 + }
1210 + if (!this.batching)
1211 + this.preferences.service.savePrefFile(null);
1212 + return val;
1213 + ]]>
1214 + </setter>
1215 + </property>
1216 +
1217 + <method name="setElementValue">
1218 + <parameter name="aElement"/>
1219 + <body>
1220 + <![CDATA[
1221 + if (this.locked)
1222 + aElement.disabled = true;
1223 +
1224 + if (!this.isElementEditable(aElement))
1225 + return;
1226 +
1227 + var rv = undefined;
1228 + if (aElement.hasAttribute("onsyncfrompreference")) {
1229 + // Value changed, synthesize an event
1230 + try {
1231 + var event = document.createEvent("Events");
1232 + event.initEvent("syncfrompreference", true, true);
1233 + var f = new Function ("event",
1234 + aElement.getAttribute("onsyncfrompreference"));
1235 + rv = f.call(aElement, event);
1236 + }
1237 + catch (e) {
1238 + Components.utils.reportError(e);
1239 + }
1240 + }
1241 + var val = rv !== undefined ? rv : (this.instantApply ? this.valueFromPreferences : this.value);
1242 + // if the preference is marked for reset, show default value in UI
1243 + if (val === undefined)
1244 + val = this.defaultValue;
1245 +
1246 + /**
1247 + * Initialize a UI element property with a value. Handles the case
1248 + * where an element has not yet had a XBL binding attached for it and
1249 + * the property setter does not yet exist by setting the same attribute
1250 + * on the XUL element using DOM apis and assuming the element's
1251 + * constructor or property getters appropriately handle this state.
1252 + */
1253 + function setValue(element, attribute, value) {
1254 + if (attribute in element)
1255 + element[attribute] = value;
1256 + else
1257 + element.setAttribute(attribute, value);
1258 + }
1259 + if (aElement.localName == "checkbox" ||
1260 + aElement.localName == "listitem")
1261 + setValue(aElement, "checked", val);
1262 + else if (aElement.localName == "colorpicker")
1263 + setValue(aElement, "color", val);
1264 + else if (aElement.localName == "textbox") {
1265 + // XXXmano Bug 303998: Avoid a caret placement issue if either the
1266 + // preference observer or its setter calls updateElements as a result
1267 + // of the input event handler.
1268 + if (aElement.value !== val)
1269 + setValue(aElement, "value", val);
1270 + }
1271 + else
1272 + setValue(aElement, "value", val);
1273 + ]]>
1274 + </body>
1275 + </method>
1276 +
1277 + <method name="getElementValue">
1278 + <parameter name="aElement"/>
1279 + <body>
1280 + <![CDATA[
1281 + if (aElement.hasAttribute("onsynctopreference")) {
1282 + // Value changed, synthesize an event
1283 + try {
1284 + var event = document.createEvent("Events");
1285 + event.initEvent("synctopreference", true, true);
1286 + var f = new Function ("event",
1287 + aElement.getAttribute("onsynctopreference"));
1288 + var rv = f.call(aElement, event);
1289 + if (rv !== undefined)
1290 + return rv;
1291 + }
1292 + catch (e) {
1293 + Components.utils.reportError(e);
1294 + }
1295 + }
1296 +
1297 + /**
1298 + * Read the value of an attribute from an element, assuming the
1299 + * attribute is a property on the element's node API. If the property
1300 + * is not present in the API, then assume its value is contained in
1301 + * an attribute, as is the case before a binding has been attached.
1302 + */
1303 + function getValue(element, attribute) {
1304 + if (attribute in element)
1305 + return element[attribute];
1306 + return element.getAttribute(attribute);
1307 + }
1308 + if (aElement.localName == "checkbox" ||
1309 + aElement.localName == "listitem")
1310 + var value = getValue(aElement, "checked");
1311 + else if (aElement.localName == "colorpicker")
1312 + value = getValue(aElement, "color");
1313 + else
1314 + value = getValue(aElement, "value");
1315 +
1316 + switch (this.type) {
1317 + case "int":
1318 + return parseInt(value, 10) || 0;
1319 + case "bool":
1320 + return typeof(value) == "boolean" ? value : value == "true";
1321 + }
1322 + return value;
1323 + ]]>
1324 + </body>
1325 + </method>
1326 +
1327 + <method name="isElementEditable">
1328 + <parameter name="aElement"/>
1329 + <body>
1330 + <![CDATA[
1331 + switch (aElement.localName) {
1332 + case "checkbox":
1333 + case "colorpicker":
1334 + case "radiogroup":
1335 + case "textbox":
1336 + case "listitem":
1337 + case "listbox":
1338 + case "menulist":
1339 + return true;
1340 + }
1341 + return aElement.getAttribute("preference-editable") == "true";
1342 + ]]>
1343 + </body>
1344 + </method>
1345 +
1346 + <method name="updateElements">
1347 + <body>
1348 + <![CDATA[
1349 + if (!this.id)
1350 + return;
1351 +
1352 + // This "change" event handler tracks changes made to preferences by
1353 + // sources other than the user in this window.
1354 + var elements = document.getElementsByAttribute("preference", this.id);
1355 + for (var i = 0; i < elements.length; ++i)
1356 + this.setElementValue(elements[i]);
1357 + ]]>
1358 + </body>
1359 + </method>
1360 + </implementation>
1361 +
1362 + <handlers>
1363 + <handler event="change">
1364 + this.updateElements();
1365 + </handler>
1366 + </handlers>
1367 + </binding>
1368 +
1369 + <binding id="prefwindow"
1370 + extends="chrome://global/content/bindings/dialog.xml#dialog">
1371 + <resources>
1372 + <stylesheet src="chrome://global/skin/preferences.css"/>
1373 + </resources>
1374 + <content dlgbuttons="accept,cancel" persist="lastSelected screenX screenY"
1375 + closebuttonlabel="&preferencesCloseButton.label;"
1376 + closebuttonaccesskey="&preferencesCloseButton.accesskey;"
1377 + role="dialog"
1378 +#ifdef XP_WIN
1379 + title="&preferencesDefaultTitleWin.title;">
1380 +#else
1381 + title="&preferencesDefaultTitleMac.title;">
1382 +#endif
1383 + <xul:windowdragbox orient="vertical">
1384 + <xul:radiogroup anonid="selector" orient="horizontal" class="paneSelector chromeclass-toolbar"
1385 + role="listbox"/> <!-- Expose to accessibility APIs as a listbox -->
1386 + </xul:windowdragbox>
1387 + <xul:hbox flex="1" class="paneDeckContainer">
1388 + <xul:deck anonid="paneDeck" flex="1">
1389 + <children includes="prefpane"/>
1390 + </xul:deck>
1391 + </xul:hbox>
1392 + <xul:hbox anonid="dlg-buttons" class="prefWindow-dlgbuttons"
1393 +#ifdef XP_UNIX_GNOME
1394 + >
1395 + <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
1396 + <xul:button dlgtype="help" class="dialog-button" hidden="true" icon="help"/>
1397 + <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
1398 + <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
1399 + <xul:spacer anonid="spacer" flex="1"/>
1400 + <xul:button dlgtype="cancel" class="dialog-button" icon="cancel"/>
1401 + <xul:button dlgtype="accept" class="dialog-button" icon="accept"/>
1402 +#elif XP_UNIX
1403 + pack="end">
1404 + <xul:button dlgtype="help" class="dialog-button" hidden="true" icon="help"/>
1405 + <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
1406 + <xul:spacer anonid="spacer" flex="1"/>
1407 + <xul:button dlgtype="accept" class="dialog-button" icon="accept"/>
1408 + <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
1409 + <xul:button dlgtype="cancel" class="dialog-button" icon="cancel"/>
1410 + <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
1411 +#else
1412 + pack="end">
1413 + <xul:button dlgtype="extra2" class="dialog-button" hidden="true"/>
1414 + <xul:spacer anonid="spacer" flex="1"/>
1415 + <xul:button dlgtype="accept" class="dialog-button" icon="accept"/>
1416 + <xul:button dlgtype="extra1" class="dialog-button" hidden="true"/>
1417 + <xul:button dlgtype="cancel" class="dialog-button" icon="cancel"/>
1418 + <xul:button dlgtype="help" class="dialog-button" hidden="true" icon="help"/>
1419 + <xul:button dlgtype="disclosure" class="dialog-button" hidden="true"/>
1420 +#endif
1421 + </xul:hbox>
1422 + <xul:hbox>
1423 + <children/>
1424 + </xul:hbox>
1425 + </content>
1426 + <implementation implements="nsITimerCallback">
1427 + <constructor>
1428 + <![CDATA[
1429 + if (this.type != "child") {
1430 + var psvc = Components.classes["@mozilla.org/preferences-service;1"]
1431 + .getService(Components.interfaces.nsIPrefBranch);
1432 + this.instantApply = psvc.getBoolPref("browser.preferences.instantApply");
1433 + if (this.instantApply) {
1434 + var docElt = document.documentElement;
1435 + var acceptButton = docElt.getButton("accept");
1436 + acceptButton.hidden = true;
1437 + var cancelButton = docElt.getButton("cancel");
1438 +#ifdef XP_MACOSX
1439 + // no buttons on Mac except Help
1440 + cancelButton.hidden = true;
1441 + // Also, don't fire onDialogAccept on enter
1442 + acceptButton.disabled = true;
1443 +#else
1444 + // morph the Cancel button into the Close button
1445 + cancelButton.setAttribute ("icon", "close");
1446 + cancelButton.label = docElt.getAttribute("closebuttonlabel");
1447 + cancelButton.accesskey = docElt.getAttribute("closebuttonaccesskey");
1448 +#endif
1449 + }
1450 + }
1451 + this.setAttribute("animated", this._shouldAnimate ? "true" : "false");
1452 + var panes = this.preferencePanes;
1453 +
1454 + var lastPane = null;
1455 + if (this.lastSelected) {
1456 + lastPane = document.getElementById(this.lastSelected);
1457 + if (!lastPane) {
1458 + this.lastSelected = null;
1459 + }
1460 + }
1461 +
1462 + var paneToLoad;
1463 + if ("arguments" in window && window.arguments[0] && document.getElementById(window.arguments[0]) && document.getElementById(window.arguments[0]).nodeName == "prefpane") {
1464 + paneToLoad = document.getElementById(window.arguments[0]);
1465 + this.lastSelected = paneToLoad.id;
1466 + }
1467 + else if (lastPane)
1468 + paneToLoad = lastPane;
1469 + else
1470 + paneToLoad = panes[0];
1471 +
1472 + for (var i = 0; i < panes.length; ++i) {
1473 + this._makePaneButton(panes[i]);
1474 + if (panes[i].loaded) {
1475 + // Inline pane content, fire load event to force initialization.
1476 + this._fireEvent("paneload", panes[i]);
1477 + }
1478 + }
1479 + this.showPane(paneToLoad);
1480 +
1481 + if (panes.length == 1)
1482 + this._selector.setAttribute("collapsed", "true");
1483 + ]]>
1484 + </constructor>
1485 +
1486 + <destructor>
1487 + <![CDATA[
1488 + // Release timers to avoid reference cycles.
1489 + if (this._animateTimer) {
1490 + this._animateTimer.cancel();
1491 + this._animateTimer = null;
1492 + }
1493 + if (this._fadeTimer) {
1494 + this._fadeTimer.cancel();
1495 + this._fadeTimer = null;
1496 + }
1497 + ]]>
1498 + </destructor>
1499 +
1500 + <field name="instantApply">false</field>
1501 +
1502 + <property name="preferencePanes"
1503 + onget="return this.getElementsByTagName('prefpane');"/>
1504 +
1505 + <property name="type" onget="return this.getAttribute('type');"/>
1506 + <property name="_paneDeck"
1507 + onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'paneDeck');"/>
1508 + <property name="_paneDeckContainer"
1509 + onget="return document.getAnonymousElementByAttribute(this, 'class', 'paneDeckContainer');"/>
1510 + <property name="_selector"
1511 + onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'selector');"/>
1512 + <property name="lastSelected"
1513 + onget="return this.getAttribute('lastSelected');">
1514 + <setter>
1515 + this.setAttribute("lastSelected", val);
1516 + document.persist(this.id, "lastSelected");
1517 + return val;
1518 + </setter>
1519 + </property>
1520 + <property name="currentPane"
1521 + onset="return this._currentPane = val;">
1522 + <getter>
1523 + if (!this._currentPane)
1524 + this._currentPane = this.preferencePanes[0];
1525 +
1526 + return this._currentPane;
1527 + </getter>
1528 + </property>
1529 + <field name="_currentPane">null</field>
1530 +
1531 +
1532 + <method name="_makePaneButton">
1533 + <parameter name="aPaneElement"/>
1534 + <body>
1535 + <![CDATA[
1536 + var radio = document.createElement("radio");
1537 + radio.setAttribute("pane", aPaneElement.id);
1538 + radio.setAttribute("label", aPaneElement.label);
1539 + // Expose preference group choice to accessibility APIs as an unchecked list item
1540 + // The parent group is exposed to accessibility APIs as a list
1541 + if (aPaneElement.image)
1542 + radio.setAttribute("src", aPaneElement.image);
1543 + radio.style.listStyleImage = aPaneElement.style.listStyleImage;
1544 + this._selector.appendChild(radio);
1545 + return radio;
1546 + ]]>
1547 + </body>
1548 + </method>
1549 +
1550 + <method name="showPane">
1551 + <parameter name="aPaneElement"/>
1552 + <body>
1553 + <![CDATA[
1554 + if (!aPaneElement)
1555 + return;
1556 +
1557 + this._selector.selectedItem = document.getAnonymousElementByAttribute(this, "pane", aPaneElement.id);
1558 + if (!aPaneElement.loaded) {
1559 + function OverlayLoadObserver(aPane)
1560 + {
1561 + this._pane = aPane;
1562 + }
1563 + OverlayLoadObserver.prototype = {
1564 + _outer: this,
1565 + observe: function (aSubject, aTopic, aData)
1566 + {
1567 + this._pane.loaded = true;
1568 + this._outer._fireEvent("paneload", this._pane);
1569 + this._outer._selectPane(this._pane);
1570 + }
1571 + };
1572 +
1573 + var obs = new OverlayLoadObserver(aPaneElement);
1574 + document.loadOverlay(aPaneElement.src, obs);
1575 + }
1576 + else
1577 + this._selectPane(aPaneElement);
1578 + ]]>
1579 + </body>
1580 + </method>
1581 +
1582 + <method name="_fireEvent">
1583 + <parameter name="aEventName"/>
1584 + <parameter name="aTarget"/>
1585 + <body>
1586 + <![CDATA[
1587 + // Panel loaded, synthesize a load event.
1588 + try {
1589 + var event = document.createEvent("Events");
1590 + event.initEvent(aEventName, true, true);
1591 + var cancel = !aTarget.dispatchEvent(event);
1592 + if (aTarget.hasAttribute("on" + aEventName)) {
1593 + var fn = new Function ("event", aTarget.getAttribute("on" + aEventName));
1594 + var rv = fn.call(aTarget, event);
1595 + if (rv == false)
1596 + cancel = true;
1597 + }
1598 + return !cancel;
1599 + }
1600 + catch (e) {
1601 + Components.utils.reportError(e);
1602 + }
1603 + return false;
1604 + ]]>
1605 + </body>
1606 + </method>
1607 +
1608 + <field name="_initialized">false</field>
1609 + <method name="_selectPane">
1610 + <parameter name="aPaneElement"/>
1611 + <body>
1612 + <![CDATA[
1613 +#ifdef XP_MACOSX
1614 + var paneTitle = aPaneElement.label;
1615 + if (paneTitle != "")
1616 + document.title = paneTitle;
1617 +#endif
1618 + var helpButton = document.documentElement.getButton("help");
1619 + if (aPaneElement.helpTopic)
1620 + helpButton.hidden = false;
1621 + else
1622 + helpButton.hidden = true;
1623 +
1624 + // Find this pane's index in the deck and set the deck's
1625 + // selectedIndex to that value to switch to it.
1626 + var prefpanes = this.preferencePanes;
1627 + for (var i = 0; i < prefpanes.length; ++i) {
1628 + if (prefpanes[i] == aPaneElement) {
1629 + this._paneDeck.selectedIndex = i;
1630 +
1631 + if (this.type != "child") {
1632 + if (aPaneElement.hasAttribute("flex") && this._shouldAnimate &&
1633 + prefpanes.length > 1)
1634 + aPaneElement.removeAttribute("flex");
1635 + // Calling sizeToContent after the first prefpane is loaded
1636 + // will size the windows contents so style information is
1637 + // available to calculate correct sizing.
1638 + if (!this._initialized && prefpanes.length > 1) {
1639 + if (this._shouldAnimate)
1640 + this.style.minHeight = 0;
1641 + window.sizeToContent();
1642 + }
1643 +
1644 + var oldPane = this.lastSelected ? document.getElementById(this.lastSelected) : this.preferencePanes[0];
1645 + oldPane.selected = !(aPaneElement.selected = true);
1646 + this.lastSelected = aPaneElement.id;
1647 + this.currentPane = aPaneElement;
1648 + this._initialized = true;
1649 +
1650 + // Only animate if we've switched between prefpanes
1651 + if (this._shouldAnimate && oldPane.id != aPaneElement.id) {
1652 + aPaneElement.style.opacity = 0.0;
1653 + this.animate(oldPane, aPaneElement);
1654 + }
1655 + else if (!this._shouldAnimate && prefpanes.length > 1) {
1656 + var targetHeight = parseInt(window.getComputedStyle(this._paneDeckContainer, "").height);
1657 + var verticalPadding = parseInt(window.getComputedStyle(aPaneElement, "").paddingTop);
1658 + verticalPadding += parseInt(window.getComputedStyle(aPaneElement, "").paddingBottom);
1659 + if (aPaneElement.contentHeight > targetHeight - verticalPadding) {
1660 + // To workaround the bottom border of a groupbox from being
1661 + // cutoff an hbox with a class of bottomBox may enclose it.
1662 + // This needs to include its padding to resize properly.
1663 + // See bug 394433
1664 + var bottomPadding = 0;
1665 + var bottomBox = aPaneElement.getElementsByAttribute("class", "bottomBox")[0];
1666 + if (bottomBox)
1667 + bottomPadding = parseInt(window.getComputedStyle(bottomBox, "").paddingBottom);
1668 + window.innerHeight += bottomPadding + verticalPadding + aPaneElement.contentHeight - targetHeight;
1669 + }
1670 +
1671 + // XXX rstrong - extend the contents of the prefpane to
1672 + // prevent elements from being cutoff (see bug 349098).
1673 + if (aPaneElement.contentHeight + verticalPadding < targetHeight)
1674 + aPaneElement._content.style.height = targetHeight - verticalPadding + "px";
1675 + }
1676 + }
1677 + break;
1678 + }
1679 + }
1680 + ]]>
1681 + </body>
1682 + </method>
1683 +
1684 + <property name="_shouldAnimate">
1685 + <getter>
1686 + <![CDATA[
1687 + var psvc = Components.classes["@mozilla.org/preferences-service;1"]
1688 + .getService(Components.interfaces.nsIPrefBranch);
1689 +#ifdef XP_MACOSX
1690 + var animate = true;
1691 +#else
1692 + var animate = false;
1693 +#endif
1694 + try {
1695 + animate = psvc.getBoolPref("browser.preferences.animateFadeIn");
1696 + }
1697 + catch (e) { }
1698 + return animate;
1699 + ]]>
1700 + </getter>
1701 + </property>
1702 +
1703 + <method name="animate">
1704 + <parameter name="aOldPane"/>
1705 + <parameter name="aNewPane"/>
1706 + <body>
1707 + <![CDATA[
1708 + // if we are already resizing, use currentHeight
1709 + var oldHeight = this._currentHeight ? this._currentHeight : aOldPane.contentHeight;
1710 +
1711 + this._multiplier = aNewPane.contentHeight > oldHeight ? 1 : -1;
1712 + var sizeDelta = Math.abs(oldHeight - aNewPane.contentHeight);
1713 + this._animateRemainder = sizeDelta % this._animateIncrement;
1714 +
1715 + this._setUpAnimationTimer(oldHeight);
1716 + ]]>
1717 + </body>
1718 + </method>
1719 +
1720 + <property name="_sizeIncrement">
1721 + <getter>
1722 + <![CDATA[
1723 + var lastSelectedPane = document.getElementById(this.lastSelected);
1724 + var increment = this._animateIncrement * this._multiplier;
1725 + var newHeight = this._currentHeight + increment;
1726 + if ((this._multiplier > 0 && this._currentHeight >= lastSelectedPane.contentHeight) ||
1727 + (this._multiplier < 0 && this._currentHeight <= lastSelectedPane.contentHeight))
1728 + return 0;
1729 +
1730 + if ((this._multiplier > 0 && newHeight > lastSelectedPane.contentHeight) ||
1731 + (this._multiplier < 0 && newHeight < lastSelectedPane.contentHeight))
1732 + increment = this._animateRemainder * this._multiplier;
1733 + return increment;
1734 + ]]>
1735 + </getter>
1736 + </property>
1737 +
1738 + <method name="notify">
1739 + <parameter name="aTimer"/>
1740 + <body>
1741 + <![CDATA[
1742 + if (!document)
1743 + aTimer.cancel();
1744 +
1745 + if (aTimer == this._animateTimer) {
1746 + var increment = this._sizeIncrement;
1747 + if (increment != 0) {
1748 + window.innerHeight += increment;
1749 + this._currentHeight += increment;
1750 + }
1751 + else {
1752 + aTimer.cancel();
1753 + this._setUpFadeTimer();
1754 + }
1755 + } else if (aTimer == this._fadeTimer) {
1756 + var elt = document.getElementById(this.lastSelected);
1757 + var newOpacity = parseFloat(window.getComputedStyle(elt, "").opacity) + this._fadeIncrement;
1758 + if (newOpacity < 1.0)
1759 + elt.style.opacity = newOpacity;
1760 + else {
1761 + aTimer.cancel();
1762 + elt.style.opacity = 1.0;
1763 + }
1764 + }
1765 + ]]>
1766 + </body>
1767 + </method>
1768 +
1769 + <method name="_setUpAnimationTimer">
1770 + <parameter name="aStartHeight"/>
1771 + <body>
1772 + <![CDATA[
1773 + if (!this._animateTimer)
1774 + this._animateTimer = Components.classes["@mozilla.org/timer;1"]
1775 + .createInstance(Components.interfaces.nsITimer);
1776 + else
1777 + this._animateTimer.cancel();
1778 + this._currentHeight = aStartHeight;
1779 +
1780 + this._animateTimer.initWithCallback(this, this._animateDelay,
1781 + Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
1782 + ]]>
1783 + </body>
1784 + </method>
1785 +
1786 + <method name="_setUpFadeTimer">
1787 + <body>
1788 + <![CDATA[
1789 + if (!this._fadeTimer)
1790 + this._fadeTimer = Components.classes["@mozilla.org/timer;1"]
1791 + .createInstance(Components.interfaces.nsITimer);
1792 + else
1793 + this._fadeTimer.cancel();
1794 +
1795 + this._fadeTimer.initWithCallback(this, this._fadeDelay,
1796 + Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
1797 + ]]>
1798 + </body>
1799 + </method>
1800 +
1801 + <field name="_animateTimer">null</field>
1802 + <field name="_fadeTimer">null</field>
1803 + <field name="_animateDelay">15</field>
1804 + <field name="_animateIncrement">40</field>
1805 + <field name="_fadeDelay">5</field>
1806 + <field name="_fadeIncrement">0.40</field>
1807 + <field name="_animateRemainder">0</field>
1808 + <field name="_currentHeight">0</field>
1809 + <field name="_multiplier">0</field>
1810 +
1811 + <method name="addPane">
1812 + <parameter name="aPaneElement"/>
1813 + <body>
1814 + <![CDATA[
1815 + this.appendChild(aPaneElement);
1816 +
1817 + // Set up pane button
1818 + this._makePaneButton(aPaneElement);
1819 + ]]>
1820 + </body>
1821 + </method>
1822 +
1823 + <method name="openSubDialog">
1824 + <parameter name="aURL"/>
1825 + <parameter name="aFeatures"/>
1826 + <parameter name="aParams"/>
1827 + <body>
1828 + return openDialog(aURL, "", "modal,centerscreen,resizable=no" + (aFeatures != "" ? ("," + aFeatures) : ""), aParams);
1829 + </body>
1830 + </method>
1831 +
1832 + <method name="openWindow">
1833 + <parameter name="aWindowType"/>
1834 + <parameter name="aURL"/>
1835 + <parameter name="aFeatures"/>
1836 + <parameter name="aParams"/>
1837 + <body>
1838 + <![CDATA[
1839 + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
1840 + .getService(Components.interfaces.nsIWindowMediator);
1841 + var win = aWindowType ? wm.getMostRecentWindow(aWindowType) : null;
1842 + if (win) {
1843 + if ("initWithParams" in win)
1844 + win.initWithParams(aParams);
1845 + win.focus();
1846 + }
1847 + else {
1848 + var features = "resizable,dialog=no,centerscreen" + (aFeatures != "" ? ("," + aFeatures) : "");
1849 + var parentWindow = (this.instantApply || !window.opener || window.opener.closed) ? window : window.opener;
1850 + win = parentWindow.openDialog(aURL, "_blank", features, aParams);
1851 + }
1852 + return win;
1853 + ]]>
1854 + </body>
1855 + </method>
1856 + </implementation>
1857 + <handlers>
1858 + <handler event="dialogaccept">
1859 + <![CDATA[
1860 + if (!this._fireEvent("beforeaccept", this))
1861 + return;
1862 +
1863 + if (this.type == "child" && window.opener) {
1864 + var psvc = Components.classes["@mozilla.org/preferences-service;1"]
1865 + .getService(Components.interfaces.nsIPrefBranch);
1866 + var instantApply = psvc.getBoolPref("browser.preferences.instantApply");
1867 + if (instantApply) {
1868 + var panes = this.preferencePanes;
1869 + for (var i = 0; i < panes.length; ++i)
1870 + panes[i].writePreferences(true);
1871 + }
1872 + else {
1873 + // Clone all the preferences elements from the child document and
1874 + // insert them into the pane collection of the parent.
1875 + var pdoc = window.opener.document;
1876 + if (pdoc.documentElement.localName == "prefwindow") {
1877 + var currentPane = pdoc.documentElement.currentPane;
1878 + var id = window.location.href + "#childprefs";
1879 + var childPrefs = pdoc.getElementById(id);
1880 + if (!childPrefs) {
1881 + var childPrefs = pdoc.createElement("preferences");
1882 + currentPane.appendChild(childPrefs);
1883 + childPrefs.id = id;
1884 + }
1885 + var panes = this.preferencePanes;
1886 + for (var i = 0; i < panes.length; ++i) {
1887 + var preferences = panes[i].preferences;
1888 + for (var j = 0; j < preferences.length; ++j) {
1889 + // Try to find a preference element for the same preference.
1890 + var preference = null;
1891 + var parentPreferences = pdoc.getElementsByTagName("preferences");
1892 + for (var k = 0; (k < parentPreferences.length && !preference); ++k) {
1893 + var parentPrefs = parentPreferences[k]
1894 + .getElementsByAttribute("name", preferences[j].name);
1895 + for (var l = 0; (l < parentPrefs.length && !preference); ++l) {
1896 + if (parentPrefs[l].localName == "preference")
1897 + preference = parentPrefs[l];
1898 + }
1899 + }
1900 + if (!preference) {
1901 + // No matching preference in the parent window.
1902 + preference = pdoc.createElement("preference");
1903 + childPrefs.appendChild(preference);
1904 + preference.name = preferences[j].name;
1905 + preference.type = preferences[j].type;
1906 + preference.inverted = preferences[j].inverted;
1907 + preference.readonly = preferences[j].readonly;
1908 + preference.disabled = preferences[j].disabled;
1909 + }
1910 + preference.value = preferences[j].value;
1911 + }
1912 + }
1913 + }
1914 + }
1915 + }
1916 + else {
1917 + var panes = this.preferencePanes;
1918 + for (var i = 0; i < panes.length; ++i)
1919 + panes[i].writePreferences(false);
1920 +
1921 + var psvc = Components.classes["@mozilla.org/preferences-service;1"]
1922 + .getService(Components.interfaces.nsIPrefService);
1923 + psvc.savePrefFile(null);
1924 + }
1925 + ]]>
1926 + </handler>
1927 + <handler event="command">
1928 + if (event.originalTarget.hasAttribute("pane")) {
1929 + var pane = document.getElementById(event.originalTarget.getAttribute("pane"));
1930 + this.showPane(pane);
1931 + }
1932 + </handler>
1933 +
1934 + <handler event="keypress" key="&windowClose.key;" modifiers="accel" phase="capturing">
1935 + <![CDATA[
1936 + if (this.instantApply)
1937 + window.close();
1938 + event.stopPropagation();
1939 + event.preventDefault();
1940 + ]]>
1941 + </handler>
1942 +
1943 + <handler event="keypress"
1944 +#ifdef XP_MACOSX
1945 + key="&openHelpMac.commandkey;" modifiers="accel"
1946 +#else
1947 + keycode="&openHelp.commandkey;"
1948 +#endif
1949 + phase="capturing">
1950 + <![CDATA[
1951 + var helpButton = this.getButton("help");
1952 + if (helpButton.disabled || helpButton.hidden)
1953 + return;
1954 + this._fireEvent("dialoghelp", this);
1955 + event.stopPropagation();
1956 + event.preventDefault();
1957 + ]]>
1958 + </handler>
1959 + </handlers>
1960 + </binding>
1961 +
1962 + <binding id="prefpane">
1963 + <resources>
1964 + <stylesheet src="chrome://global/skin/preferences.css"/>
1965 + </resources>
1966 + <content>
1967 + <xul:vbox class="content-box" xbl:inherits="flex">
1968 + <children/>
1969 + </xul:vbox>
1970 + </content>
1971 + <implementation>
1972 + <method name="writePreferences">
1973 + <parameter name="aFlushToDisk"/>
1974 + <body>
1975 + <![CDATA[
1976 + // Write all values to preferences.
1977 + var preferences = this.preferences;
1978 + for (var i = 0; i < preferences.length; ++i) {
1979 + var preference = preferences[i];
1980 + preference.batching = true;
1981 + preference.valueFromPreferences = preference.value;
1982 + preference.batching = false;
1983 + }
1984 + if (aFlushToDisk) {
1985 + var psvc = Components.classes["@mozilla.org/preferences-service;1"]
1986 + .getService(Components.interfaces.nsIPrefService);
1987 + psvc.savePrefFile(null);
1988 + }
1989 + ]]>
1990 + </body>
1991 + </method>
1992 +
1993 + <property name="src"
1994 + onget="return this.getAttribute('src');"
1995 + onset="this.setAttribute('src', val); return val;"/>
1996 + <property name="selected"
1997 + onget="return this.getAttribute('selected') == 'true';"
1998 + onset="this.setAttribute('selected', val); return val;"/>
1999 + <property name="image"
2000 + onget="return this.getAttribute('image');"
2001 + onset="this.setAttribute('image', val); return val;"/>
2002 + <property name="label"
2003 + onget="return this.getAttribute('label');"
2004 + onset="this.setAttribute('label', val); return val;"/>
2005 +
2006 + <property name="preferenceElements"
2007 + onget="return this.getElementsByAttribute('preference', '*');"/>
2008 + <property name="preferences"
2009 + onget="return this.getElementsByTagName('preference');"/>
2010 +
2011 + <property name="helpTopic">
2012 + <getter>
2013 + <![CDATA[
2014 + // if there are tabs, and the selected tab provides a helpTopic, return that
2015 + var box = this.getElementsByTagName("tabbox");
2016 + if (box[0]) {
2017 + var tab = box[0].selectedTab;
2018 + if (tab && tab.hasAttribute("helpTopic"))
2019 + return tab.getAttribute("helpTopic");
2020 + }
2021 +
2022 + // otherwise, return the helpTopic of the current panel
2023 + return this.getAttribute("helpTopic");
2024 + ]]>
2025 + </getter>
2026 + </property>
2027 +
2028 + <field name="_loaded">false</field>
2029 + <property name="loaded"
2030 + onget="return !this.src ? true : this._loaded;"
2031 + onset="this._loaded = val; return val;"/>
2032 +
2033 + <method name="preferenceForElement">
2034 + <parameter name="aElement"/>
2035 + <body>
2036 + return document.getElementById(aElement.getAttribute("preference"));
2037 + </body>
2038 + </method>
2039 +
2040 + <method name="getPreferenceElement">
2041 + <parameter name="aStartElement"/>
2042 + <body>
2043 + <![CDATA[
2044 + var temp = aStartElement;
2045 + while (temp && temp.nodeType == Node.ELEMENT_NODE &&
2046 + !temp.hasAttribute("preference"))
2047 + temp = temp.parentNode;
2048 + return temp.nodeType == Node.ELEMENT_NODE ? temp : aStartElement;
2049 + ]]>
2050 + </body>
2051 + </method>
2052 +
2053 + <method name="userChangedValue">
2054 + <parameter name="aElement"/>
2055 + <body>
2056 + <![CDATA[
2057 + var element = this.getPreferenceElement(aElement);
2058 + if (element.hasAttribute("preference")) {
2059 + var preference = document.getElementById(element.getAttribute("preference"));
2060 + var prefVal = preference.getElementValue(element);
2061 + preference.value = prefVal;
2062 + }
2063 + ]]>
2064 + </body>
2065 + </method>
2066 +
2067 + <property name="contentHeight">
2068 + <getter>
2069 + var targetHeight = parseInt(window.getComputedStyle(this._content, "").height);
2070 + targetHeight += parseInt(window.getComputedStyle(this._content, "").marginTop);
2071 + targetHeight += parseInt(window.getComputedStyle(this._content, "").marginBottom);
2072 + return targetHeight;
2073 + </getter>
2074 + </property>
2075 + <field name="_content">
2076 + document.getAnonymousElementByAttribute(this, "class", "content-box");
2077 + </field>
2078 + </implementation>
2079 + <handlers>
2080 + <handler event="command">
2081 + // This "command" event handler tracks changes made to preferences by
2082 + // the user in this window.
2083 + this.userChangedValue(event.target);
2084 + </handler>
2085 + <handler event="select">
2086 + // This "select" event handler tracks changes made to colorpicker
2087 + // preferences by the user in this window.
2088 + if (event.target.localName == "colorpicker")
2089 + this.userChangedValue(event.target);
2090 + </handler>
2091 + <handler event="change">
2092 + // This "change" event handler tracks changes made to preferences by
2093 + // the user in this window.
2094 + this.userChangedValue(event.target);
2095 + </handler>
2096 + <handler event="input">
2097 + // This "input" event handler tracks changes made to preferences by
2098 + // the user in this window.
2099 + this.userChangedValue(event.target);
2100 + </handler>
2101 + <handler event="paneload">
2102 + <![CDATA[
2103 + // Initialize all values from preferences.
2104 + var elements = this.preferenceElements;
2105 + for (var i = 0; i < elements.length; ++i) {
2106 + try {
2107 + var preference = this.preferenceForElement(elements[i]);
2108 + preference.setElementValue(elements[i]);
2109 + }
2110 + catch (e) {
2111 + dump("*** No preference found for " + elements[i].getAttribute("preference") + "\n");
2112 + }
2113 + }
2114 + ]]>
2115 + </handler>
2116 + </handlers>
2117 + </binding>
2118 +
2119 + <binding id="panebutton" extends="chrome://global/content/bindings/radio.xml#radio">
2120 + <resources>
2121 + <stylesheet src="chrome://global/skin/preferences.css"/>
2122 + </resources>
2123 + <content>
2124 + <xul:image class="paneButtonIcon" xbl:inherits="src"/>
2125 + <xul:label class="paneButtonLabel" xbl:inherits="value=label"/>
2126 + </content>
2127 + <implementation implements="nsIAccessible">
2128 + <property name="accessibleType" readonly="true">
2129 + <getter>
2130 + <![CDATA[
2131 + return Components.interfaces.nsIAccessibleProvider.XULListitem;
2132 + ]]>
2133 + </getter>
2134 + </property>
2135 + </implementation>
2136 + </binding>
2137 +
2138 +</bindings>
2139 +
2140 +# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2141 +# ***** BEGIN LICENSE BLOCK *****
2142 +# Version: MPL 1.1/GPL 2.0/LGPL 2.1
2143 +#
2144 +# The contents of this file are subject to the Mozilla Public License Version
2145 +# 1.1 (the "License"); you may not use this file except in compliance with
2146 +# the License. You may obtain a copy of the License at
2147 +# http://www.mozilla.org/MPL/
2148 +#
2149 +# Software distributed under the License is distributed on an "AS IS" basis,
2150 +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2151 +# for the specific language governing rights and limitations under the
2152 +# License.
2153 +#
2154 +# The Original Code is the Preferences System.
2155 +#
2156 +# The Initial Developer of the Original Code is
2157 +# Ben Goodger.
2158 +# Portions created by the Initial Developer are Copyright (C) 2005
2159 +# the Initial Developer. All Rights Reserved.
2160 +#
2161 +# Contributor(s):
2162 +# Ben Goodger <ben@mozilla.org>
2163 +# Josh Aas <josh@mozilla.com>
2164 +#
2165 +# Alternatively, the contents of this file may be used under the terms of
2166 +# either the GNU General Public License Version 2 or later (the "GPL"), or
2167 +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2168 +# in which case the provisions of the GPL or the LGPL are applicable instead
2169 +# of those above. If you wish to allow use of your version of this file only
2170 +# under the terms of either the GPL or the LGPL, and not to allow others to
2171 +# use your version of this file under the terms of the MPL, indicate your
2172 +# decision by deleting the provisions above and replace them with the notice
2173 +# and other provisions required by the GPL or the LGPL. If you do not delete
2174 +# the provisions above, a recipient may use your version of this file under
2175 +# the terms of any one of the MPL, the GPL or the LGPL.
2176 +#
2177 +# ***** END LICENSE BLOCK *****
2178 +
2179 +#
2180 +# This is PrefWindow 6. The Code Could Well Be Ready, Are You?
2181 +#
2182 +# Historical References:
2183 +# PrefWindow V (February 1, 2003)
2184 +# PrefWindow IV (April 24, 2000)
2185 +# PrefWindow III (January 6, 2000)
2186 +# PrefWindow II (???)
2187 +# PrefWindow I (June 4, 1999)
2188 +#
2189 --- mozilla-1.9.2/toolkit/system/unixproxy/Makefile.in.kde-integration 2010-07-22 23:55:23.000000000 +0200
2190 +++ mozilla-1.9.2/toolkit/system/unixproxy/Makefile.in 2010-07-25 09:25:13.000000000 +0200
2191 @@ -58,6 +58,8 @@
2192 mozgnome \
2193 $(NULL)
2194
2195 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
2196 +
2197 EXTRA_DSO_LDOPTS += $(MOZ_COMPONENT_LIBS)
2198
2199 CPPSRCS = \
2200 --- mozilla-1.9.2/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp.kde-integration 2010-07-25 09:24:07.000000000 +0200
2201 +++ mozilla-1.9.2/toolkit/system/unixproxy/nsUnixSystemProxySettings.cpp 2010-07-25 09:24:07.000000000 +0200
2202 @@ -49,6 +49,8 @@
2203 #include "nsPrintfCString.h"
2204 #include "nsNetUtil.h"
2205 #include "nsISupportsPrimitives.h"
2206 +#include "nsVoidArray.h"
2207 +#include "nsKDEUtils.h"
2208
2209 class nsUnixSystemProxySettings : public nsISystemProxySettings {
2210 public:
2211 @@ -65,6 +67,7 @@
2212 PRBool IsProxyMode(const char* aMode);
2213 nsresult SetProxyResultFromGConf(const char* aKeyBase, const char* aType, nsACString& aResult);
2214 nsresult GetProxyFromGConf(const nsACString& aScheme, const nsACString& aHost, PRInt32 aPort, nsACString& aResult);
2215 + nsresult GetProxyFromKDE(const nsACString& aScheme, const nsACString& aHost, PRInt32 aPort, nsACString& aResult);
2216 };
2217
2218 NS_IMPL_ISUPPORTS1(nsUnixSystemProxySettings, nsISystemProxySettings)
2219 @@ -412,6 +415,9 @@
2220 rv = aURI->GetPort(&port);
2221 NS_ENSURE_SUCCESS(rv, rv);
2222
2223 + if( nsKDEUtils::kdeSupport())
2224 + return GetProxyFromKDE( scheme, host, port, aResult );
2225 +
2226 if (!mGConf)
2227 return GetProxyFromEnvironment(scheme, host, port, aResult);
2228
2229 @@ -432,3 +438,28 @@
2230 };
2231
2232 NS_IMPL_NSGETMODULE(nsUnixProxyModule, components)
2233 +
2234 +nsresult
2235 +nsUnixSystemProxySettings::GetProxyFromKDE(const nsACString& aScheme,
2236 + const nsACString& aHost,
2237 + PRInt32 aPort,
2238 + nsACString& aResult)
2239 +{
2240 + nsCAutoString url;
2241 + url = aScheme;
2242 + url += "://";
2243 + url += aHost;
2244 + if( aPort >= 0 )
2245 + {
2246 + url += ":";
2247 + url += nsPrintfCString("%d", aPort);
2248 + }
2249 + nsCStringArray command;
2250 + command.AppendCString( NS_LITERAL_CSTRING( "GETPROXY" ));
2251 + command.AppendCString( url );
2252 + nsCStringArray result;
2253 + if( !nsKDEUtils::command( command, &result ) || result.Count() != 1 )
2254 + return NS_ERROR_FAILURE;
2255 + aResult = *result[ 0 ];
2256 + return NS_OK;
2257 +}
2258 --- mozilla-1.9.2/toolkit/xre/Makefile.in.kde-integration 2010-07-22 23:55:23.000000000 +0200
2259 +++ mozilla-1.9.2/toolkit/xre/Makefile.in 2010-07-25 09:24:07.000000000 +0200
2260 @@ -47,6 +47,8 @@
2261 LIBRARY_NAME = xulapp_s
2262 LIBXUL_LIBRARY = 1
2263
2264 +EXPORTS = nsKDEUtils.h
2265 +
2266 REQUIRES = \
2267 appcomps \
2268 toolkitcomps \
2269 @@ -138,7 +140,7 @@
2270 CPPSRCS += nsNativeAppSupportBeOS.cpp
2271 else
2272 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
2273 -CPPSRCS += nsNativeAppSupportUnix.cpp
2274 +CPPSRCS += nsNativeAppSupportUnix.cpp nsKDEUtils.cpp
2275 else
2276 CPPSRCS += nsNativeAppSupportDefault.cpp
2277 endif
2278 --- mozilla-1.9.2/toolkit/xre/nsKDEUtils.cpp.kde-integration 2010-07-25 09:24:07.000000000 +0200
2279 +++ mozilla-1.9.2/toolkit/xre/nsKDEUtils.cpp 2010-07-25 09:24:07.000000000 +0200
2280 @@ -0,0 +1,334 @@
2281 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2282 +/* ***** BEGIN LICENSE BLOCK *****
2283 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2284 + *
2285 + * The contents of this file are subject to the Mozilla Public License Version
2286 + * 1.1 (the "License"); you may not use this file except in compliance with
2287 + * the License. You may obtain a copy of the License at
2288 + * http://www.mozilla.org/MPL/
2289 + *
2290 + * Software distributed under the License is distributed on an "AS IS" basis,
2291 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2292 + * for the specific language governing rights and limitations under the
2293 + * License.
2294 + *
2295 + * The Original Code is Unix Native App Support.
2296 + *
2297 + * The Initial Developer of the Original Code is
2298 + * Mozilla Corporation.
2299 + * Portions created by the Initial Developer are Copyright (C) 2007
2300 + * the Initial Developer. All Rights Reserved.
2301 + *
2302 + * Contributor(s):
2303 + *
2304 + * Alternatively, the contents of this file may be used under the terms of
2305 + * either the GNU General Public License Version 2 or later (the "GPL"), or
2306 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2307 + * in which case the provisions of the GPL or the LGPL are applicable instead
2308 + * of those above. If you wish to allow use of your version of this file only
2309 + * under the terms of either the GPL or the LGPL, and not to allow others to
2310 + * use your version of this file under the terms of the MPL, indicate your
2311 + * decision by deleting the provisions above and replace them with the notice
2312 + * and other provisions required by the GPL or the LGPL. If you do not delete
2313 + * the provisions above, a recipient may use your version of this file under
2314 + * the terms of any one of the MPL, the GPL or the LGPL.
2315 + *
2316 + * ***** END LICENSE BLOCK ***** */
2317 +
2318 +#include "nsKDEUtils.h"
2319 +#include "nsIWidget.h"
2320 +
2321 +#include <gtk/gtk.h>
2322 +
2323 +#include <limits.h>
2324 +#include <stdio.h>
2325 +#include <sys/wait.h>
2326 +#include <unistd.h>
2327 +#include <X11/Xlib.h>
2328 +
2329 +//#define DEBUG_KDE
2330 +#ifdef DEBUG_KDE
2331 +#define KMOZILLAHELPER "kmozillahelper"
2332 +#else
2333 +// not need for lib64, it's a binary
2334 +#define KMOZILLAHELPER "/usr/lib/mozilla/kmozillahelper"
2335 +#endif
2336 +
2337 +#define KMOZILLAHELPER_VERSION 6
2338 +#define MAKE_STR2( n ) #n
2339 +#define MAKE_STR( n ) MAKE_STR2( n )
2340 +
2341 +static bool getKdeSession()
2342 + {
2343 + Display* dpy = XOpenDisplay( NULL );
2344 + if( dpy == NULL )
2345 + return false;
2346 + Atom kde_full_session = XInternAtom( dpy, "KDE_FULL_SESSION", True );
2347 + bool kde = false;
2348 + if( kde_full_session != None )
2349 + {
2350 + int cnt;
2351 + if( Atom* props = XListProperties( dpy, DefaultRootWindow( dpy ), &cnt ))
2352 + {
2353 + for( int i = 0;
2354 + i < cnt;
2355 + ++i )
2356 + {
2357 + if( props[ i ] == kde_full_session )
2358 + {
2359 + kde = true;
2360 +#ifdef DEBUG_KDE
2361 + fprintf( stderr, "KDE SESSION %d\n", kde );
2362 +#endif
2363 + break;
2364 + }
2365 + }
2366 + XFree( props );
2367 + }
2368 + }
2369 + XCloseDisplay( dpy );
2370 + return kde;
2371 + }
2372 +
2373 +static bool getKdeSupport()
2374 + {
2375 + nsCStringArray command;
2376 + command.AppendCString( NS_LITERAL_CSTRING( "CHECK" ));
2377 + command.AppendCString( NS_LITERAL_CSTRING( MAKE_STR( KMOZILLAHELPER_VERSION )));
2378 + bool kde = nsKDEUtils::command( command );
2379 +#ifdef DEBUG_KDE
2380 + fprintf( stderr, "KDE RUNNING %d\n", kde );
2381 +#endif
2382 + return kde;
2383 + }
2384 +
2385 +nsKDEUtils::nsKDEUtils()
2386 + : commandFile( NULL )
2387 + , replyFile( NULL )
2388 + {
2389 + }
2390 +
2391 +nsKDEUtils::~nsKDEUtils()
2392 + {
2393 +// closeHelper(); not actually useful, exiting will close the fd too
2394 + }
2395 +
2396 +nsKDEUtils* nsKDEUtils::self()
2397 + {
2398 + static nsKDEUtils s;
2399 + return &s;
2400 + }
2401 +
2402 +static bool helperRunning = false;
2403 +static bool helperFailed = false;
2404 +
2405 +bool nsKDEUtils::kdeSession()
2406 + {
2407 + static bool session = getKdeSession();
2408 + return session;
2409 + }
2410 +
2411 +bool nsKDEUtils::kdeSupport()
2412 + {
2413 + static bool support = kdeSession() && getKdeSupport();
2414 + return support && helperRunning;
2415 + }
2416 +
2417 +struct nsKDECommandData
2418 + {
2419 + FILE* file;
2420 + nsCStringArray* output;
2421 + GMainLoop* loop;
2422 + bool success;
2423 + };
2424 +
2425 +static gboolean kdeReadFunc( GIOChannel*, GIOCondition, gpointer data )
2426 + {
2427 + nsKDECommandData* p = static_cast< nsKDECommandData* >( data );
2428 + char buf[ 8192 ]; // TODO big enough
2429 + bool command_done = false;
2430 + bool command_failed = false;
2431 + while( !command_done && !command_failed && fgets( buf, 8192, p->file ) != NULL )
2432 + { // TODO what if the kernel splits a line into two chunks?
2433 +//#ifdef DEBUG_KDE
2434 +// fprintf( stderr, "READ: %s %d\n", buf, feof( p->file ));
2435 +//#endif
2436 + if( char* eol = strchr( buf, '\n' ))
2437 + *eol = '\0';
2438 + command_done = ( strcmp( buf, "\\1" ) == 0 );
2439 + command_failed = ( strcmp( buf, "\\0" ) == 0 );
2440 + nsCAutoString line( buf );
2441 + line.ReplaceSubstring( "\\n", "\n" );
2442 + line.ReplaceSubstring( "\\" "\\", "\\" ); // \\ -> \ , i.e. unescape
2443 + if( p->output && !( command_done || command_failed ))
2444 + p->output->AppendCString( nsCString( buf )); // TODO utf8?
2445 + }
2446 + bool quit = false;
2447 + if( feof( p->file ) || command_failed )
2448 + {
2449 + quit = true;
2450 + p->success = false;
2451 + }
2452 + if( command_done )
2453 + { // reading one reply finished
2454 + quit = true;
2455 + p->success = true;
2456 + }
2457 + if( quit )
2458 + {
2459 + if( p->loop )
2460 + g_main_loop_quit( p->loop );
2461 + return FALSE;
2462 + }
2463 + return TRUE;
2464 + }
2465 +
2466 +bool nsKDEUtils::command( const nsCStringArray& command, nsCStringArray* output )
2467 + {
2468 + return self()->internalCommand( command, NULL, false, output );
2469 + }
2470 +
2471 +bool nsKDEUtils::commandBlockUi( const nsCStringArray& command, const GtkWindow* parent, nsCStringArray* output )
2472 + {
2473 + return self()->internalCommand( command, parent, true, output );
2474 + }
2475 +
2476 +bool nsKDEUtils::internalCommand( const nsCStringArray& command, const GtkWindow* parent, bool blockUi,
2477 + nsCStringArray* output )
2478 + {
2479 + if( !startHelper())
2480 + return false;
2481 + // if Gtk has meanwhile gotten a grab (bnc#555202, somehow the file dialog
2482 + // is called with a delay), then do not do anything, as this app would keep
2483 + // the grabs but block waiting for the helper, which would be unable to do
2484 + // anything because of the grab
2485 + if( blockUi && gdk_pointer_is_grabbed())
2486 + return false;
2487 + feedCommand( command );
2488 + // do not store the data in 'this' but in extra structure, just in case there
2489 + // is reentrancy (can there be? the event loop is re-entered)
2490 + nsKDECommandData data;
2491 + data.file = replyFile;
2492 + data.output = output;
2493 + data.success = false;
2494 + if( blockUi )
2495 + {
2496 + data.loop = g_main_loop_new( NULL, FALSE );
2497 + GtkWidget* window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
2498 + if( parent && parent->group )
2499 + gtk_window_group_add_window( parent->group, GTK_WINDOW( window ));
2500 + gtk_widget_realize( window );
2501 + gtk_widget_set_sensitive( window, TRUE );
2502 + gtk_grab_add( window );
2503 + GIOChannel* channel = g_io_channel_unix_new( fileno( data.file ));
2504 + g_io_add_watch( channel, static_cast< GIOCondition >( G_IO_IN | G_IO_ERR | G_IO_HUP ), kdeReadFunc, &data );
2505 + g_io_channel_unref( channel );
2506 + g_main_loop_run( data.loop );
2507 + g_main_loop_unref( data.loop );
2508 + gtk_grab_remove( window );
2509 + gtk_widget_destroy( window );
2510 + }
2511 + else
2512 + {
2513 + data.loop = NULL;
2514 + while( kdeReadFunc( NULL, static_cast< GIOCondition >( 0 ), &data ))
2515 + ;
2516 + }
2517 + return data.success;
2518 + }
2519 +
2520 +bool nsKDEUtils::startHelper()
2521 + {
2522 + if( helperRunning )
2523 + return true;
2524 + if( helperFailed )
2525 + return false;
2526 + helperFailed = true;
2527 + int fdcommand[ 2 ];
2528 + int fdreply[ 2 ];
2529 + if( pipe( fdcommand ) < 0 )
2530 + return false;
2531 + if( pipe( fdreply ) < 0 )
2532 + {
2533 + close( fdcommand[ 0 ] );
2534 + close( fdcommand[ 1 ] );
2535 + return false;
2536 + }
2537 + char* args[ 2 ] = { const_cast< char* >( KMOZILLAHELPER ), NULL };
2538 + switch( fork())
2539 + {
2540 + case -1:
2541 + {
2542 + close( fdcommand[ 0 ] );
2543 + close( fdcommand[ 1 ] );
2544 + close( fdreply[ 0 ] );
2545 + close( fdreply[ 1 ] );
2546 + return false;
2547 + }
2548 + case 0: // child
2549 + {
2550 + if( dup2( fdcommand[ 0 ], STDIN_FILENO ) < 0 )
2551 + _exit( 1 );
2552 + if( dup2( fdreply[ 1 ], STDOUT_FILENO ) < 0 )
2553 + _exit( 1 );
2554 + int maxfd = 1024; // close all other fds
2555 + struct rlimit rl;
2556 + if( getrlimit( RLIMIT_NOFILE, &rl ) == 0 )
2557 + maxfd = rl.rlim_max;
2558 + for( int i = 3;
2559 + i < maxfd;
2560 + ++i )
2561 + close( i );
2562 +#ifdef DEBUG_KDE
2563 + execvp( KMOZILLAHELPER, args );
2564 +#else
2565 + execv( KMOZILLAHELPER, args );
2566 +#endif
2567 + _exit( 1 ); // failed
2568 + }
2569 + default: // parent
2570 + {
2571 + commandFile = fdopen( fdcommand[ 1 ], "w" );
2572 + replyFile = fdopen( fdreply[ 0 ], "r" );
2573 + close( fdcommand[ 0 ] );
2574 + close( fdreply[ 1 ] );
2575 + if( commandFile == NULL || replyFile == NULL )
2576 + {
2577 + closeHelper();
2578 + return false;
2579 + }
2580 + // ok, helper ready, getKdeRunning() will check if it works
2581 + }
2582 + }
2583 + helperFailed = false;
2584 + helperRunning = true;
2585 + return true;
2586 + }
2587 +
2588 +void nsKDEUtils::closeHelper()
2589 + {
2590 + if( commandFile != NULL )
2591 + fclose( commandFile ); // this will also make the helper quit
2592 + if( replyFile != NULL )
2593 + fclose( replyFile );
2594 + helperRunning = false;
2595 + }
2596 +
2597 +void nsKDEUtils::feedCommand( const nsCStringArray& command )
2598 + {
2599 + for( int i = 0;
2600 + i < command.Count();
2601 + ++i )
2602 + {
2603 + nsCString line = *command[ i ];
2604 + line.ReplaceSubstring( "\\", "\\" "\\" ); // \ -> \\ , i.e. escape
2605 + line.ReplaceSubstring( "\n", "\\n" );
2606 +#ifdef DEBUG_KDE
2607 + fprintf( stderr, "COMM: %s\n", line.get());
2608 +#endif
2609 + fputs( line.get(), commandFile );
2610 + fputs( "\n", commandFile );
2611 + }
2612 + fputs( "\\E\n", commandFile ); // done as \E, so it cannot happen in normal data
2613 + fflush( commandFile );
2614 + }
2615 --- mozilla-1.9.2/toolkit/xre/nsKDEUtils.h.kde-integration 2010-07-25 09:24:07.000000000 +0200
2616 +++ mozilla-1.9.2/toolkit/xre/nsKDEUtils.h 2010-07-25 09:24:07.000000000 +0200
2617 @@ -0,0 +1,77 @@
2618 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2619 + *
2620 + * ***** BEGIN LICENSE BLOCK *****
2621 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2622 + *
2623 + * The contents of this file are subject to the Mozilla Public License Version
2624 + * 1.1 (the "License"); you may not use this file except in compliance with
2625 + * the License. You may obtain a copy of the License at
2626 + * http://www.mozilla.org/MPL/
2627 + *
2628 + * Software distributed under the License is distributed on an "AS IS" basis,
2629 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2630 + * for the specific language governing rights and limitations under the
2631 + * License.
2632 + *
2633 + * The Original Code is Mozilla Communicator client code.
2634 + *
2635 + * The Initial Developer of the Original Code is
2636 + * Netscape Communications Corporation.
2637 + * Portions created by the Initial Developer are Copyright (C) 1998
2638 + * the Initial Developer. All Rights Reserved.
2639 + *
2640 + * Contributor(s):
2641 + *
2642 + * Alternatively, the contents of this file may be used under the terms of
2643 + * either of the GNU General Public License Version 2 or later (the "GPL"),
2644 + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2645 + * in which case the provisions of the GPL or the LGPL are applicable instead
2646 + * of those above. If you wish to allow use of your version of this file only
2647 + * under the terms of either the GPL or the LGPL, and not to allow others to
2648 + * use your version of this file under the terms of the MPL, indicate your
2649 + * decision by deleting the provisions above and replace them with the notice
2650 + * and other provisions required by the GPL or the LGPL. If you do not delete
2651 + * the provisions above, a recipient may use your version of this file under
2652 + * the terms of any one of the MPL, the GPL or the LGPL.
2653 + *
2654 + * ***** END LICENSE BLOCK ***** */
2655 +
2656 +#ifndef nsKDEUtils_h__
2657 +#define nsKDEUtils_h__
2658 +
2659 +#include "nsStringGlue.h"
2660 +#include "nsVoidArray.h"
2661 +#include <stdio.h>
2662 +
2663 +typedef struct _GtkWindow GtkWindow;
2664 +
2665 +class NS_EXPORT nsKDEUtils
2666 + {
2667 + public:
2668 + /* Returns true if running inside a KDE session (regardless of whether there is KDE
2669 + support available for Firefox). This should be used e.g. when determining
2670 + dialog button order but not for code that requires the KDE support. */
2671 + static bool kdeSession();
2672 + /* Returns true if running inside a KDE session and KDE support is available
2673 + for Firefox. This should be used everywhere where the external helper is needed. */
2674 + static bool kdeSupport();
2675 + /* Executes the given helper command, returns true if helper returned success. */
2676 + static bool command( const nsCStringArray& command, nsCStringArray* output = NULL );
2677 + /* Like command(), but additionally blocks the parent widget like if there was
2678 + a modal dialog shown and enters the event loop (i.e. there are still paint updates,
2679 + this is for commands that take long). */
2680 + static bool commandBlockUi( const nsCStringArray& command, const GtkWindow* parent, nsCStringArray* output = NULL );
2681 + private:
2682 + nsKDEUtils();
2683 + ~nsKDEUtils();
2684 + static nsKDEUtils* self();
2685 + bool startHelper();
2686 + void closeHelper();
2687 + void feedCommand( const nsCStringArray& command );
2688 + bool internalCommand( const nsCStringArray& command, const GtkWindow* parent, bool isParent,
2689 + nsCStringArray* output );
2690 + FILE* commandFile;
2691 + FILE* replyFile;
2692 + };
2693 +
2694 +#endif // nsKDEUtils
2695 --- mozilla-1.9.2/uriloader/exthandler/Makefile.in.kde-integration 2010-07-22 23:55:23.000000000 +0200
2696 +++ mozilla-1.9.2/uriloader/exthandler/Makefile.in 2010-07-25 09:24:07.000000000 +0200
2697 @@ -107,8 +107,9 @@
2698 LOCAL_INCLUDES = -I$(srcdir)
2699
2700 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
2701 -OSHELPER += nsGNOMERegistry.cpp
2702 +OSHELPER += nsCommonRegistry.cpp nsGNOMERegistry.cpp nsKDERegistry.cpp
2703 OSHELPER += nsMIMEInfoUnix.cpp
2704 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
2705 endif
2706
2707 ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
2708 --- mozilla-1.9.2/uriloader/exthandler/unix/nsCommonRegistry.cpp.kde-integration 2010-07-25 09:24:07.000000000 +0200
2709 +++ mozilla-1.9.2/uriloader/exthandler/unix/nsCommonRegistry.cpp 2010-07-25 09:24:07.000000000 +0200
2710 @@ -0,0 +1,87 @@
2711 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2712 +/* ***** BEGIN LICENSE BLOCK *****
2713 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2714 + *
2715 + * The contents of this file are subject to the Mozilla Public License Version
2716 + * 1.1 (the "License"); you may not use this file except in compliance with
2717 + * the License. You may obtain a copy of the License at
2718 + * http://www.mozilla.org/MPL/
2719 + *
2720 + * Software distributed under the License is distributed on an "AS IS" basis,
2721 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2722 + * for the specific language governing rights and limitations under the
2723 + * License.
2724 + *
2725 + * The Original Code is the GNOME helper app implementation.
2726 + *
2727 + * The Initial Developer of the Original Code is
2728 + * IBM Corporation.
2729 + * Portions created by the Initial Developer are Copyright (C) 2003
2730 + * the Initial Developer. All Rights Reserved.
2731 + *
2732 + * Contributor(s):
2733 + * Brian Ryner <bryner@brianryner.com> (Original Author)
2734 + *
2735 + * Alternatively, the contents of this file may be used under the terms of
2736 + * either the GNU General Public License Version 2 or later (the "GPL"), or
2737 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2738 + * in which case the provisions of the GPL or the LGPL are applicable instead
2739 + * of those above. If you wish to allow use of your version of this file only
2740 + * under the terms of either the GPL or the LGPL, and not to allow others to
2741 + * use your version of this file under the terms of the MPL, indicate your
2742 + * decision by deleting the provisions above and replace them with the notice
2743 + * and other provisions required by the GPL or the LGPL. If you do not delete
2744 + * the provisions above, a recipient may use your version of this file under
2745 + * the terms of any one of the MPL, the GPL or the LGPL.
2746 + *
2747 + * ***** END LICENSE BLOCK ***** */
2748 +
2749 +#include "nsCommonRegistry.h"
2750 +
2751 +#include "nsGNOMERegistry.h"
2752 +#include "nsKDERegistry.h"
2753 +#include "nsString.h"
2754 +#include "nsVoidArray.h"
2755 +#include "nsKDEUtils.h"
2756 +
2757 +/* static */ PRBool
2758 +nsCommonRegistry::HandlerExists(const char *aProtocolScheme)
2759 +{
2760 + if( nsKDEUtils::kdeSupport())
2761 + return nsKDERegistry::HandlerExists( aProtocolScheme );
2762 + return nsGNOMERegistry::HandlerExists( aProtocolScheme );
2763 +}
2764 +
2765 +/* static */ nsresult
2766 +nsCommonRegistry::LoadURL(nsIURI *aURL)
2767 +{
2768 + if( nsKDEUtils::kdeSupport())
2769 + return nsKDERegistry::LoadURL( aURL );
2770 + return nsGNOMERegistry::LoadURL( aURL );
2771 +}
2772 +
2773 +/* static */ void
2774 +nsCommonRegistry::GetAppDescForScheme(const nsACString& aScheme,
2775 + nsAString& aDesc)
2776 +{
2777 + if( nsKDEUtils::kdeSupport())
2778 + return nsKDERegistry::GetAppDescForScheme( aScheme, aDesc );
2779 + return nsGNOMERegistry::GetAppDescForScheme( aScheme, aDesc );
2780 +}
2781 +
2782 +
2783 +/* static */ already_AddRefed<nsMIMEInfoBase>
2784 +nsCommonRegistry::GetFromExtension(const nsACString& aFileExt)
2785 +{
2786 + if( nsKDEUtils::kdeSupport())
2787 + return nsKDERegistry::GetFromExtension( aFileExt );
2788 + return nsGNOMERegistry::GetFromExtension( aFileExt );
2789 +}
2790 +
2791 +/* static */ already_AddRefed<nsMIMEInfoBase>
2792 +nsCommonRegistry::GetFromType(const nsACString& aMIMEType)
2793 +{
2794 + if( nsKDEUtils::kdeSupport())
2795 + return nsKDERegistry::GetFromType( aMIMEType );
2796 + return nsGNOMERegistry::GetFromType( aMIMEType );
2797 +}
2798 --- mozilla-1.9.2/uriloader/exthandler/unix/nsCommonRegistry.h.kde-integration 2010-07-25 09:24:07.000000000 +0200
2799 +++ mozilla-1.9.2/uriloader/exthandler/unix/nsCommonRegistry.h 2010-07-25 09:24:07.000000000 +0200
2800 @@ -0,0 +1,56 @@
2801 +/* ***** BEGIN LICENSE BLOCK *****
2802 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2803 + *
2804 + * The contents of this file are subject to the Mozilla Public License Version
2805 + * 1.1 (the "License"); you may not use this file except in compliance with
2806 + * the License. You may obtain a copy of the License at
2807 + * http://www.mozilla.org/MPL/
2808 + *
2809 + * Software distributed under the License is distributed on an "AS IS" basis,
2810 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2811 + * for the specific language governing rights and limitations under the
2812 + * License.
2813 + *
2814 + * The Original Code is the GNOME helper app implementation.
2815 + *
2816 + * The Initial Developer of the Original Code is
2817 + * IBM Corporation.
2818 + * Portions created by the Initial Developer are Copyright (C) 2003
2819 + * the Initial Developer. All Rights Reserved.
2820 + *
2821 + * Contributor(s):
2822 + * Brian Ryner <bryner@brianryner.com> (Original Author)
2823 + *
2824 + * Alternatively, the contents of this file may be used under the terms of
2825 + * either the GNU General Public License Version 2 or later (the "GPL"), or
2826 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2827 + * in which case the provisions of the GPL or the LGPL are applicable instead
2828 + * of those above. If you wish to allow use of your version of this file only
2829 + * under the terms of either the GPL or the LGPL, and not to allow others to
2830 + * use your version of this file under the terms of the MPL, indicate your
2831 + * decision by deleting the provisions above and replace them with the notice
2832 + * and other provisions required by the GPL or the LGPL. If you do not delete
2833 + * the provisions above, a recipient may use your version of this file under
2834 + * the terms of any one of the MPL, the GPL or the LGPL.
2835 + *
2836 + * ***** END LICENSE BLOCK ***** */
2837 +
2838 +#include "nsIURI.h"
2839 +#include "nsCOMPtr.h"
2840 +
2841 +class nsMIMEInfoBase;
2842 +
2843 +class nsCommonRegistry
2844 +{
2845 + public:
2846 + static PRBool HandlerExists(const char *aProtocolScheme);
2847 +
2848 + static nsresult LoadURL(nsIURI *aURL);
2849 +
2850 + static void GetAppDescForScheme(const nsACString& aScheme,
2851 + nsAString& aDesc);
2852 +
2853 + static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsACString& aFileExt);
2854 +
2855 + static already_AddRefed<nsMIMEInfoBase> GetFromType(const nsACString& aMIMEType);
2856 +};
2857 --- mozilla-1.9.2/uriloader/exthandler/unix/nsKDERegistry.cpp.kde-integration 2010-07-25 09:24:07.000000000 +0200
2858 +++ mozilla-1.9.2/uriloader/exthandler/unix/nsKDERegistry.cpp 2010-07-25 09:24:07.000000000 +0200
2859 @@ -0,0 +1,119 @@
2860 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2861 +/* ***** BEGIN LICENSE BLOCK *****
2862 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2863 + *
2864 + * The contents of this file are subject to the Mozilla Public License Version
2865 + * 1.1 (the "License"); you may not use this file except in compliance with
2866 + * the License. You may obtain a copy of the License at
2867 + * http://www.mozilla.org/MPL/
2868 + *
2869 + * Software distributed under the License is distributed on an "AS IS" basis,
2870 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2871 + * for the specific language governing rights and limitations under the
2872 + * License.
2873 + *
2874 + * The Original Code is the GNOME helper app implementation.
2875 + *
2876 + * The Initial Developer of the Original Code is
2877 + * IBM Corporation.
2878 + * Portions created by the Initial Developer are Copyright (C) 2003
2879 + * the Initial Developer. All Rights Reserved.
2880 + *
2881 + * Contributor(s):
2882 + * Brian Ryner <bryner@brianryner.com> (Original Author)
2883 + *
2884 + * Alternatively, the contents of this file may be used under the terms of
2885 + * either the GNU General Public License Version 2 or later (the "GPL"), or
2886 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
2887 + * in which case the provisions of the GPL or the LGPL are applicable instead
2888 + * of those above. If you wish to allow use of your version of this file only
2889 + * under the terms of either the GPL or the LGPL, and not to allow others to
2890 + * use your version of this file under the terms of the MPL, indicate your
2891 + * decision by deleting the provisions above and replace them with the notice
2892 + * and other provisions required by the GPL or the LGPL. If you do not delete
2893 + * the provisions above, a recipient may use your version of this file under
2894 + * the terms of any one of the MPL, the GPL or the LGPL.
2895 + *
2896 + * ***** END LICENSE BLOCK ***** */
2897 +
2898 +#include "nsKDERegistry.h"
2899 +#include "prlink.h"
2900 +#include "prmem.h"
2901 +#include "nsString.h"
2902 +#include "nsILocalFile.h"
2903 +#include "nsMIMEInfoUnix.h"
2904 +#include "nsAutoPtr.h"
2905 +#include "nsKDEUtils.h"
2906 +
2907 +/* static */ PRBool
2908 +nsKDERegistry::HandlerExists(const char *aProtocolScheme)
2909 +{
2910 + nsCStringArray command;
2911 + command.AppendCString( NS_LITERAL_CSTRING( "HANDLEREXISTS" ));
2912 + command.AppendCString( nsCAutoString( aProtocolScheme ));
2913 + return nsKDEUtils::command( command );
2914 +}
2915 +
2916 +/* static */ nsresult
2917 +nsKDERegistry::LoadURL(nsIURI *aURL)
2918 +{
2919 + nsCStringArray command;
2920 + command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
2921 + nsCString url;
2922 + aURL->GetSpec( url );
2923 + command.AppendCString( url );
2924 + return nsKDEUtils::command( command );
2925 +}
2926 +
2927 +/* static */ void
2928 +nsKDERegistry::GetAppDescForScheme(const nsACString& aScheme,
2929 + nsAString& aDesc)
2930 +{
2931 + nsCStringArray command;
2932 + command.AppendCString( NS_LITERAL_CSTRING( "GETAPPDESCFORSCHEME" ));
2933 + command.AppendCString( aScheme );
2934 + nsCStringArray output;
2935 + if( nsKDEUtils::command( command, &output ) && output.Count() == 1 )
2936 + CopyUTF8toUTF16( *output[ 0 ], aDesc );
2937 +}
2938 +
2939 +
2940 +/* static */ already_AddRefed<nsMIMEInfoBase>
2941 +nsKDERegistry::GetFromExtension(const nsACString& aFileExt)
2942 +{
2943 + NS_ASSERTION(aFileExt[0] != '.', "aFileExt shouldn't start with a dot");
2944 + nsCStringArray command;
2945 + command.AppendCString( NS_LITERAL_CSTRING( "GETFROMEXTENSION" ));
2946 + command.AppendCString( aFileExt );
2947 + return GetFromHelper( command );
2948 +}
2949 +
2950 +/* static */ already_AddRefed<nsMIMEInfoBase>
2951 +nsKDERegistry::GetFromType(const nsACString& aMIMEType)
2952 +{
2953 + nsCStringArray command;
2954 + command.AppendCString( NS_LITERAL_CSTRING( "GETFROMTYPE" ));
2955 + command.AppendCString( aMIMEType );
2956 + return GetFromHelper( command );
2957 +}
2958 +
2959 +/* static */ already_AddRefed<nsMIMEInfoBase>
2960 +nsKDERegistry::GetFromHelper(const nsCStringArray& command)
2961 +{
2962 + nsCStringArray output;
2963 + if( nsKDEUtils::command( command, &output ) && output.Count() == 3 )
2964 + {
2965 + nsCString mimetype = *output[ 0 ];
2966 + nsRefPtr<nsMIMEInfoUnix> mimeInfo = new nsMIMEInfoUnix( mimetype );
2967 + NS_ENSURE_TRUE(mimeInfo, nsnull);
2968 + nsCString description = *output[ 1 ];
2969 + mimeInfo->SetDescription(NS_ConvertUTF8toUTF16(description));
2970 + nsCString handlerAppName = *output[ 2 ];
2971 + mimeInfo->SetDefaultDescription(NS_ConvertUTF8toUTF16(handlerAppName));
2972 + mimeInfo->SetPreferredAction(nsIMIMEInfo::useSystemDefault);
2973 + nsMIMEInfoBase* retval;
2974 + NS_ADDREF((retval = mimeInfo));
2975 + return retval;
2976 + }
2977 + return nsnull;
2978 +}
2979 --- mozilla-1.9.2/uriloader/exthandler/unix/nsKDERegistry.h.kde-integration 2010-07-25 09:24:07.000000000 +0200
2980 +++ mozilla-1.9.2/uriloader/exthandler/unix/nsKDERegistry.h 2010-07-25 09:24:07.000000000 +0200
2981 @@ -0,0 +1,61 @@
2982 +/* ***** BEGIN LICENSE BLOCK *****
2983 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2984 + *
2985 + * The contents of this file are subject to the Mozilla Public License Version
2986 + * 1.1 (the "License"); you may not use this file except in compliance with
2987 + * the License. You may obtain a copy of the License at
2988 + * http://www.mozilla.org/MPL/
2989 + *
2990 + * Software distributed under the License is distributed on an "AS IS" basis,
2991 + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
2992 + * for the specific language governing rights and limitations under the
2993 + * License.
2994 + *
2995 + * The Original Code is the GNOME helper app implementation.
2996 + *
2997 + * The Initial Developer of the Original Code is
2998 + * IBM Corporation.
2999 + * Portions created by the Initial Developer are Copyright (C) 2003
3000 + * the Initial Developer. All Rights Reserved.
3001 + *
3002 + * Contributor(s):
3003 + * Brian Ryner <bryner@brianryner.com> (Original Author)
3004 + *
3005 + * Alternatively, the contents of this file may be used under the terms of
3006 + * either the GNU General Public License Version 2 or later (the "GPL"), or
3007 + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
3008 + * in which case the provisions of the GPL or the LGPL are applicable instead
3009 + * of those above. If you wish to allow use of your version of this file only
3010 + * under the terms of either the GPL or the LGPL, and not to allow others to
3011 + * use your version of this file under the terms of the MPL, indicate your
3012 + * decision by deleting the provisions above and replace them with the notice
3013 + * and other provisions required by the GPL or the LGPL. If you do not delete
3014 + * the provisions above, a recipient may use your version of this file under
3015 + * the terms of any one of the MPL, the GPL or the LGPL.
3016 + *
3017 + * ***** END LICENSE BLOCK ***** */
3018 +
3019 +#include "nsIURI.h"
3020 +#include "nsCOMPtr.h"
3021 +
3022 +class nsMIMEInfoBase;
3023 +class nsCAutoString;
3024 +class nsCStringArray;
3025 +
3026 +class nsKDERegistry
3027 +{
3028 + public:
3029 + static PRBool HandlerExists(const char *aProtocolScheme);
3030 +
3031 + static nsresult LoadURL(nsIURI *aURL);
3032 +
3033 + static void GetAppDescForScheme(const nsACString& aScheme,
3034 + nsAString& aDesc);
3035 +
3036 + static already_AddRefed<nsMIMEInfoBase> GetFromExtension(const nsACString& aFileExt);
3037 +
3038 + static already_AddRefed<nsMIMEInfoBase> GetFromType(const nsACString& aMIMEType);
3039 + private:
3040 + static already_AddRefed<nsMIMEInfoBase> GetFromHelper(const nsCStringArray& command);
3041 +
3042 +};
3043 --- mozilla-1.9.2/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp.kde-integration 2010-07-25 09:24:07.000000000 +0200
3044 +++ mozilla-1.9.2/uriloader/exthandler/unix/nsMIMEInfoUnix.cpp 2010-07-25 09:24:07.000000000 +0200
3045 @@ -45,17 +45,20 @@
3046 #endif
3047
3048 #include "nsMIMEInfoUnix.h"
3049 -#include "nsGNOMERegistry.h"
3050 +#include "nsCommonRegistry.h"
3051 #include "nsIGnomeVFSService.h"
3052 #include "nsAutoPtr.h"
3053 #ifdef MOZ_ENABLE_DBUS
3054 #include "nsDBusHandlerApp.h"
3055 #endif
3056 +#if defined(XP_UNIX) && !defined(XP_MACOSX)
3057 +#include "nsKDEUtils.h"
3058 +#endif
3059
3060 nsresult
3061 nsMIMEInfoUnix::LoadUriInternal(nsIURI * aURI)
3062 {
3063 - nsresult rv = nsGNOMERegistry::LoadURL(aURI);
3064 + nsresult rv = nsCommonRegistry::LoadURL(aURI);
3065 #if (MOZ_PLATFORM_MAEMO == 5) && defined (MOZ_ENABLE_GNOMEVFS)
3066 if (NS_FAILED(rv)){
3067 HildonURIAction *action = hildon_uri_get_default_action(mType.get(), nsnull);
3068 @@ -75,11 +78,11 @@
3069 nsMIMEInfoUnix::GetHasDefaultHandler(PRBool *_retval)
3070 {
3071 *_retval = PR_FALSE;
3072 - nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromType(mType);
3073 + nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromType(mType);
3074 if (!mimeInfo) {
3075 nsCAutoString ext;
3076 GetPrimaryExtension(ext);
3077 - mimeInfo = nsGNOMERegistry::GetFromExtension(ext);
3078 + mimeInfo = nsCommonRegistry::GetFromExtension(ext);
3079 }
3080
3081 if (mimeInfo)
3082 @@ -112,6 +115,23 @@
3083 return NS_OK;
3084 #endif
3085
3086 + if( nsKDEUtils::kdeSupport()) {
3087 + PRBool supports;
3088 + if( NS_SUCCEEDED( GetHasDefaultHandler( &supports )) && supports ) {
3089 + nsCStringArray command;
3090 + command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
3091 + command.AppendCString( nativePath );
3092 + command.AppendCString( NS_LITERAL_CSTRING( "MIMETYPE" ));
3093 + command.AppendCString( mType );
3094 + if( nsKDEUtils::command( command ))
3095 + return NS_OK;
3096 + }
3097 + if (!mDefaultApplication)
3098 + return NS_ERROR_FILE_NOT_FOUND;
3099 +
3100 + return LaunchWithIProcess(mDefaultApplication, nativePath);
3101 + }
3102 +
3103 nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
3104 if (vfs) {
3105 nsCOMPtr<nsIGnomeVFSMimeApp> app;
3106 @@ -120,7 +140,7 @@
3107
3108 // If we haven't got an app we try to get a valid one by searching for the
3109 // extension mapped type
3110 - nsRefPtr<nsMIMEInfoBase> mimeInfo = nsGNOMERegistry::GetFromExtension(nativePath);
3111 + nsRefPtr<nsMIMEInfoBase> mimeInfo = nsCommonRegistry::GetFromExtension(nativePath);
3112 if (mimeInfo) {
3113 nsCAutoString type;
3114 mimeInfo->GetType(type);
3115 --- mozilla-1.9.2/uriloader/exthandler/unix/nsOSHelperAppService.cpp.kde-integration 2010-07-25 09:24:07.000000000 +0200
3116 +++ mozilla-1.9.2/uriloader/exthandler/unix/nsOSHelperAppService.cpp 2010-07-25 09:24:07.000000000 +0200
3117 @@ -44,7 +44,7 @@
3118 #include "nsOSHelperAppService.h"
3119 #include "nsMIMEInfoUnix.h"
3120 #ifdef MOZ_WIDGET_GTK2
3121 -#include "nsGNOMERegistry.h"
3122 +#include "nsCommonRegistry.h"
3123 #endif
3124 #include "nsISupports.h"
3125 #include "nsString.h"
3126 @@ -1210,7 +1210,7 @@
3127
3128 #ifdef MOZ_WIDGET_GTK2
3129 // Check the GConf registry for a protocol handler
3130 - *aHandlerExists = nsGNOMERegistry::HandlerExists(aProtocolScheme);
3131 + *aHandlerExists = nsCommonRegistry::HandlerExists(aProtocolScheme);
3132 #ifdef MOZ_PLATFORM_MAEMO
3133 *aHandlerExists = nsMIMEInfoUnix::HandlerExists(aProtocolScheme);
3134 #endif
3135 @@ -1222,7 +1222,7 @@
3136 NS_IMETHODIMP nsOSHelperAppService::GetApplicationDescription(const nsACString& aScheme, nsAString& _retval)
3137 {
3138 #ifdef MOZ_WIDGET_GTK2
3139 - nsGNOMERegistry::GetAppDescForScheme(aScheme, _retval);
3140 + nsCommonRegistry::GetAppDescForScheme(aScheme, _retval);
3141 return _retval.IsEmpty() ? NS_ERROR_NOT_AVAILABLE : NS_OK;
3142 #else
3143 return NS_ERROR_NOT_AVAILABLE;
3144 @@ -1318,7 +1318,7 @@
3145
3146 #ifdef MOZ_WIDGET_GTK2
3147 LOG(("Looking in GNOME registry\n"));
3148 - nsMIMEInfoBase *gnomeInfo = nsGNOMERegistry::GetFromExtension(aFileExt).get();
3149 + nsMIMEInfoBase *gnomeInfo = nsCommonRegistry::GetFromExtension(aFileExt).get();
3150 if (gnomeInfo) {
3151 LOG(("Got MIMEInfo from GNOME registry\n"));
3152 return gnomeInfo;
3153 @@ -1444,7 +1444,7 @@
3154 // get back a MIMEInfo without any extensions set. In that case we'll have
3155 // to look in our mime.types files for the extensions.
3156 LOG(("Looking in GNOME registry\n"));
3157 - gnomeInfo = nsGNOMERegistry::GetFromType(aMIMEType).get();
3158 + gnomeInfo = nsCommonRegistry::GetFromType(aMIMEType).get();
3159 if (gnomeInfo && gnomeInfo->HasExtensions()) {
3160 LOG(("Got MIMEInfo from GNOME registry, and it has extensions set\n"));
3161 return gnomeInfo;
3162 --- mozilla-1.9.2/widget/src/gtk2/Makefile.in.kde-integration 2010-07-22 23:55:24.000000000 +0200
3163 +++ mozilla-1.9.2/widget/src/gtk2/Makefile.in 2010-07-25 09:24:07.000000000 +0200
3164 @@ -190,3 +190,6 @@
3165 -I$(srcdir)/../xpwidgets \
3166 -I$(topsrcdir)/other-licenses/atk-1.0 \
3167 $(NULL)
3168 +
3169 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
3170 +
3171 --- mozilla-1.9.2/widget/src/gtk2/nsFilePicker.cpp.kde-integration 2010-07-25 09:24:07.000000000 +0200
3172 +++ mozilla-1.9.2/widget/src/gtk2/nsFilePicker.cpp 2010-07-25 09:24:07.000000000 +0200
3173 @@ -36,6 +36,7 @@
3174 * ***** END LICENSE BLOCK ***** */
3175
3176 #include <gtk/gtk.h>
3177 +#include <gdk/gdkx.h>
3178
3179 #include "nsIFileURL.h"
3180 #include "nsIURI.h"
3181 @@ -55,6 +56,7 @@
3182
3183 #include "nsFilePicker.h"
3184 #include "nsAccessibilityHelper.h"
3185 +#include "nsKDEUtils.h"
3186
3187 #ifdef MOZ_PLATFORM_MAEMO
3188 #include <hildon-fm-2/hildon/hildon-file-chooser-dialog.h>
3189 @@ -275,7 +277,9 @@
3190 {
3191 if (aFilter.EqualsLiteral("..apps")) {
3192 // No platform specific thing we can do here, really....
3193 - return NS_OK;
3194 + // Unless it's KDE.
3195 + if( mMode != modeOpen || !nsKDEUtils::kdeSupport())
3196 + return NS_OK;
3197 }
3198
3199 nsCAutoString filter, name;
3200 @@ -424,6 +428,9 @@
3201 NS_IMETHODIMP
3202 nsFilePicker::Show(PRInt16 *aReturn)
3203 {
3204 + if( nsKDEUtils::kdeSupport())
3205 + return kdeFileDialog( aReturn );
3206 +
3207 NS_ENSURE_ARG_POINTER(aReturn);
3208
3209 nsXPIDLCString title;
3210 @@ -574,3 +581,229 @@
3211
3212 return NS_OK;
3213 }
3214 +
3215 +nsCString nsFilePicker::kdeMakeFilter( int index )
3216 + {
3217 + nsCString buf = mFilters[ index ];
3218 + for( PRUint32 i = 0;
3219 + i < buf.Length();
3220 + ++i )
3221 + if( buf[ i ] == ';' ) // KDE separates just using spaces
3222 + buf.SetCharAt( ' ', i );
3223 + if (!mFilterNames[index].IsEmpty())
3224 + {
3225 + buf += "|";
3226 + buf += mFilterNames[index].get();
3227 + }
3228 + return buf;
3229 + }
3230 +
3231 +static PRInt32 windowToXid( nsIWidget* widget )
3232 + {
3233 + GtkWindow *parent_widget = get_gtk_window_for_nsiwidget( widget );
3234 + GdkWindow* gdk_window = gtk_widget_get_window( gtk_widget_get_toplevel( GTK_WIDGET( parent_widget )));
3235 + return GDK_WINDOW_XID( gdk_window );
3236 + }
3237 +
3238 +NS_IMETHODIMP nsFilePicker::kdeFileDialog(PRInt16 *aReturn)
3239 + {
3240 + NS_ENSURE_ARG_POINTER(aReturn);
3241 +
3242 + if( mMode == modeOpen && mFilters.Length() == 1 && mFilters[ 0 ].EqualsLiteral( "..apps" ))
3243 + return kdeAppsDialog( aReturn );
3244 +
3245 + nsXPIDLCString title;
3246 + title.Adopt(ToNewUTF8String(mTitle));
3247 +
3248 + const char* arg = NULL;
3249 + if( mAllowURLs )
3250 + {
3251 + switch( mMode )
3252 + {
3253 + case nsIFilePicker::modeOpen:
3254 + case nsIFilePicker::modeOpenMultiple:
3255 + arg = "GETOPENURL";
3256 + break;
3257 + case nsIFilePicker::modeSave:
3258 + arg = "GETSAVEURL";
3259 + break;
3260 + case nsIFilePicker::modeGetFolder:
3261 + arg = "GETDIRECTORYURL";
3262 + break;
3263 + }
3264 + }
3265 + else
3266 + {
3267 + switch( mMode )
3268 + {
3269 + case nsIFilePicker::modeOpen:
3270 + case nsIFilePicker::modeOpenMultiple:
3271 + arg = "GETOPENFILENAME";
3272 + break;
3273 + case nsIFilePicker::modeSave:
3274 + arg = "GETSAVEFILENAME";
3275 + break;
3276 + case nsIFilePicker::modeGetFolder:
3277 + arg = "GETDIRECTORYFILENAME";
3278 + break;
3279 + }
3280 + }
3281 +
3282 + nsCAutoString directory;
3283 + if (mDisplayDirectory) {
3284 + mDisplayDirectory->GetNativePath(directory);
3285 + } else if (mPrevDisplayDirectory) {
3286 + mPrevDisplayDirectory->GetNativePath(directory);
3287 + }
3288 +
3289 + nsCAutoString startdir;
3290 + if (!directory.IsEmpty()) {
3291 + startdir = directory;
3292 + }
3293 + if (mMode == nsIFilePicker::modeSave) {
3294 + if( !startdir.IsEmpty())
3295 + {
3296 + startdir += "/";
3297 + startdir += ToNewUTF8String(mDefault);
3298 + }
3299 + else
3300 + startdir = ToNewUTF8String(mDefault);
3301 + }
3302 + if( startdir.IsEmpty())
3303 + startdir = ".";
3304 +
3305 + nsCAutoString filters;
3306 + PRInt32 count = mFilters.Length();
3307 + if( count == 0 ) //just in case
3308 + filters = "*";
3309 + else
3310 + {
3311 + filters = kdeMakeFilter( 0 );
3312 + for (PRInt32 i = 1; i < count; ++i)
3313 + {
3314 + filters += "\n";
3315 + filters += kdeMakeFilter( i );
3316 + }
3317 + }
3318 +
3319 + nsCStringArray command;
3320 + command.AppendCString( nsCAutoString( arg ));
3321 + command.AppendCString( startdir );
3322 + if( mMode != nsIFilePicker::modeGetFolder )
3323 + {
3324 + command.AppendCString( filters );
3325 + nsCAutoString selected;
3326 + selected.AppendInt( mSelectedType );
3327 + command.AppendCString( selected );
3328 + }
3329 + command.AppendCString( title );
3330 + if( mMode == nsIFilePicker::modeOpenMultiple )
3331 + command.AppendCString( NS_LITERAL_CSTRING( "MULTIPLE" ));
3332 + if( PRInt32 xid = windowToXid( mParentWidget ))
3333 + {
3334 + command.AppendCString( NS_LITERAL_CSTRING( "PARENT" ));
3335 + nsCAutoString parent;
3336 + parent.AppendInt( xid );
3337 + command.AppendCString( parent );
3338 + }
3339 +
3340 + nsCStringArray output;
3341 + if( nsKDEUtils::commandBlockUi( command, get_gtk_window_for_nsiwidget( mParentWidget ), &output ))
3342 + {
3343 + *aReturn = nsIFilePicker::returnOK;
3344 + mFiles.Clear();
3345 + if( mMode != nsIFilePicker::modeGetFolder )
3346 + {
3347 + mSelectedType = atoi( output[ 0 ]->get());
3348 + output.RemoveCStringAt( 0 );
3349 + }
3350 + if (mMode == nsIFilePicker::modeOpenMultiple)
3351 + {
3352 + mFileURL.Truncate();
3353 + PRUint32 count = output.Count();
3354 + for( PRUint32 i = 0;
3355 + i < count;
3356 + ++i )
3357 + {
3358 + nsCOMPtr<nsILocalFile> localfile;
3359 + nsresult rv = NS_NewNativeLocalFile( *output[ i ],
3360 + PR_FALSE,
3361 + getter_AddRefs(localfile));
3362 + if (NS_SUCCEEDED(rv))
3363 + mFiles.AppendObject(localfile);
3364 + }
3365 + }
3366 + else
3367 + {
3368 + if( output.Count() == 0 )
3369 + mFileURL = nsCString();
3370 + else if( mAllowURLs )
3371 + mFileURL = *output[ 0 ];
3372 + else // GetFile() actually requires it to be url even for local files :-/
3373 + {
3374 + mFileURL = nsCString( "file://" );
3375 + mFileURL.Append( *output[ 0 ] );
3376 + }
3377 + }
3378 + // Remember last used directory.
3379 + nsCOMPtr<nsILocalFile> file;
3380 + GetFile(getter_AddRefs(file));
3381 + if (file) {
3382 + nsCOMPtr<nsIFile> dir;
3383 + file->GetParent(getter_AddRefs(dir));
3384 + nsCOMPtr<nsILocalFile> localDir(do_QueryInterface(dir));
3385 + if (localDir) {
3386 + localDir.swap(mPrevDisplayDirectory);
3387 + }
3388 + }
3389 + if (mMode == nsIFilePicker::modeSave)
3390 + {
3391 + nsCOMPtr<nsILocalFile> file;
3392 + GetFile(getter_AddRefs(file));
3393 + if (file)
3394 + {
3395 + PRBool exists = PR_FALSE;
3396 + file->Exists(&exists);
3397 + if (exists) // TODO do overwrite check in the helper app
3398 + *aReturn = nsIFilePicker::returnReplace;
3399 + }
3400 + }
3401 + }
3402 + else
3403 + {
3404 + *aReturn = nsIFilePicker::returnCancel;
3405 + }
3406 + return NS_OK;
3407 + }
3408 +
3409 +
3410 +NS_IMETHODIMP nsFilePicker::kdeAppsDialog(PRInt16 *aReturn)
3411 + {
3412 + NS_ENSURE_ARG_POINTER(aReturn);
3413 +
3414 + nsXPIDLCString title;
3415 + title.Adopt(ToNewUTF8String(mTitle));
3416 +
3417 + nsCStringArray command;
3418 + command.AppendCString( NS_LITERAL_CSTRING( "APPSDIALOG" ));
3419 + command.AppendCString( title );
3420 + if( PRInt32 xid = windowToXid( mParentWidget ))
3421 + {
3422 + command.AppendCString( NS_LITERAL_CSTRING( "PARENT" ));
3423 + nsCAutoString parent;
3424 + parent.AppendInt( xid );
3425 + command.AppendCString( parent );
3426 + }
3427 +
3428 + nsCStringArray output;
3429 + if( nsKDEUtils::commandBlockUi( command, get_gtk_window_for_nsiwidget( mParentWidget ), &output ))
3430 + {
3431 + *aReturn = nsIFilePicker::returnOK;
3432 + mFileURL = output.Count() > 0 ? *output[ 0 ] : nsCString();
3433 + }
3434 + else
3435 + {
3436 + *aReturn = nsIFilePicker::returnCancel;
3437 + }
3438 + return NS_OK;
3439 + }
3440 --- mozilla-1.9.2/widget/src/gtk2/nsFilePicker.h.kde-integration 2010-07-22 23:55:24.000000000 +0200
3441 +++ mozilla-1.9.2/widget/src/gtk2/nsFilePicker.h 2010-07-25 09:24:07.000000000 +0200
3442 @@ -94,6 +94,12 @@
3443
3444 private:
3445 static nsILocalFile *mPrevDisplayDirectory;
3446 +
3447 + bool kdeRunning();
3448 + bool getKdeRunning();
3449 + NS_IMETHODIMP kdeFileDialog(PRInt16 *aReturn);
3450 + NS_IMETHODIMP kdeAppsDialog(PRInt16 *aReturn);
3451 + nsCString kdeMakeFilter( int index );
3452 };
3453
3454 #endif
3455 --- mozilla-1.9.2/xpcom/io/Makefile.in.kde-integration 2010-07-22 23:55:24.000000000 +0200
3456 +++ mozilla-1.9.2/xpcom/io/Makefile.in 2010-07-25 09:24:07.000000000 +0200
3457 @@ -200,6 +200,7 @@
3458 endif
3459
3460 LOCAL_INCLUDES = -I..
3461 +LOCAL_INCLUDES += -I$(topsrcdir)/toolkit/xre
3462
3463 ifeq ($(MOZ_PLATFORM_MAEMO), 5)
3464 CFLAGS += $(MOZ_DBUS_GLIB_CFLAGS) $(MOZ_PLATFORM_MAEMO_CFLAGS)
3465 --- mozilla-1.9.2/xpcom/io/nsLocalFileUnix.cpp.kde-integration 2010-07-22 23:55:24.000000000 +0200
3466 +++ mozilla-1.9.2/xpcom/io/nsLocalFileUnix.cpp 2010-07-25 09:24:07.000000000 +0200
3467 @@ -84,6 +84,7 @@
3468
3469 #ifdef MOZ_WIDGET_GTK2
3470 #include "nsIGnomeVFSService.h"
3471 +#include "nsKDEUtils.h"
3472 #endif
3473
3474 #if (MOZ_PLATFORM_MAEMO == 5)
3475 @@ -1632,16 +1633,13 @@
3476 nsLocalFile::Reveal()
3477 {
3478 #ifdef MOZ_WIDGET_GTK2
3479 - nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
3480 - if (!vfs)
3481 - return NS_ERROR_FAILURE;
3482 -
3483 + nsCAutoString url;
3484 PRBool isDirectory;
3485 if (NS_FAILED(IsDirectory(&isDirectory)))
3486 return NS_ERROR_FAILURE;
3487
3488 if (isDirectory) {
3489 - return vfs->ShowURIForInput(mPath);
3490 + url = mPath;
3491 } else {
3492 nsCOMPtr<nsIFile> parentDir;
3493 nsCAutoString dirPath;
3494 @@ -1650,8 +1648,21 @@
3495 if (NS_FAILED(parentDir->GetNativePath(dirPath)))
3496 return NS_ERROR_FAILURE;
3497
3498 - return vfs->ShowURIForInput(dirPath);
3499 + url = dirPath;
3500 }
3501 +
3502 + if( nsKDEUtils::kdeSupport()) {
3503 + nsCStringArray command;
3504 + command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
3505 + command.AppendCString( url );
3506 + return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
3507 + }
3508 +
3509 + nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
3510 + if (!vfs)
3511 + return NS_ERROR_FAILURE;
3512 + return vfs->ShowURIForInput(url);
3513 +
3514 #else
3515 return NS_ERROR_FAILURE;
3516 #endif
3517 @@ -1679,6 +1690,13 @@
3518 return NS_ERROR_FAILURE;
3519 return NS_OK;
3520 #else
3521 + if( nsKDEUtils::kdeSupport()) {
3522 + nsCStringArray command;
3523 + command.AppendCString( NS_LITERAL_CSTRING( "OPEN" ));
3524 + command.AppendCString( mPath );
3525 + return nsKDEUtils::command( command ) ? NS_OK : NS_ERROR_FAILURE;
3526 + }
3527 +
3528 nsCOMPtr<nsIGnomeVFSService> vfs = do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
3529 if (!vfs)
3530 return NS_ERROR_FAILURE;

  ViewVC Help
Powered by ViewVC 1.1.30