зеркало из https://github.com/mozilla/gecko-dev.git
Implement nsIShellService for GNOME (bug 242254). r=biesi, sr=shaver. Note: set as wallpaper for images that use transparency will be broken until bug 250531 is fixed. This also makes toolkit/ always be pulled in preparation for migrating more code to the new GNOME XPCOM interfaces.
This commit is contained in:
Родитель
65319a64a0
Коммит
56b2b34f2b
|
@ -238,6 +238,10 @@ ifndef MOZ_XUL
|
|||
tier_9_dirs += embedding/minimo/chromelite
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_GTK2
|
||||
tier_9_dirs += toolkit/components/gnome
|
||||
endif
|
||||
|
||||
#
|
||||
# tier 40 - security
|
||||
#
|
||||
|
|
|
@ -1081,6 +1081,12 @@ if [ ! "$SYSTEM_PNG" ]; then
|
|||
MAKEFILES_libimg="$MAKEFILES_libimg modules/libimg/png/Makefile"
|
||||
fi
|
||||
|
||||
MAKEFILES_gnome="
|
||||
toolkit/Makefile
|
||||
toolkit/components/Makefile
|
||||
toolkit/components/gnome/Makefile
|
||||
"
|
||||
|
||||
#
|
||||
# l10n/
|
||||
#
|
||||
|
@ -1487,6 +1493,10 @@ if test -z "$MOZ_XUL"; then
|
|||
add_makefiles "$MAKEFILES_minimo"
|
||||
fi
|
||||
|
||||
if test -n "$MOZ_ENABLE_GTK2"; then
|
||||
add_makefiles "$MAKEFILES_gnome"
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
# Standalone modules go here
|
||||
|
|
|
@ -217,9 +217,8 @@ ifneq (,$(filter-out OS2 WINNT,$(OS_ARCH)))
|
|||
|
||||
firefox:: mozilla.in Makefile.in Makefile $(DEPTH)/config/autoconf.mk
|
||||
cat $< | sed -e "s|%MOZAPPDIR%|$(mozappdir)|" \
|
||||
-e "s|%MOZ_USER_DIR%|.firefox|" \
|
||||
-e "s|%MREDIR%|$(mredir)|" \
|
||||
-e "s|%MOZILLA-BIN%|$(PROGRAM)|g" > $@
|
||||
-e "s|%MOZ_USER_DIR%|.mozilla/firefox|" \
|
||||
-e "s|%MREDIR%|$(mredir)|" > $@
|
||||
chmod +x $@
|
||||
|
||||
libs:: firefox
|
||||
|
@ -238,6 +237,7 @@ ifneq (,$(filter gtk gtk2,$(MOZ_WIDGET_TOOLKIT)))
|
|||
ICON_FILES = \
|
||||
$(DIST)/branding/mozicon50.xpm \
|
||||
$(DIST)/branding/mozicon16.xpm \
|
||||
$(DIST)/branding/document.png \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(ICON_FILES)
|
||||
|
@ -272,6 +272,7 @@ endif
|
|||
ifneq (,$(filter gtk gtk2,$(MOZ_WIDGET_TOOLKIT)))
|
||||
cp $(srcdir)/mozicon16.xpm $(DIST)/branding/mozicon16.xpm
|
||||
cp $(srcdir)/mozicon50.xpm $(DIST)/branding/mozicon50.xpm
|
||||
cp $(srcdir)/document.png $(DIST)/branding/document.png
|
||||
endif
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
|
||||
cp $(srcdir)/default.xpm $(DIST)/branding/default.xpm
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.1 KiB |
|
@ -29,3 +29,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
include $(topsrcdir)/config/config.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifneq (,$(filter windows gtk2, $(MOZ_WIDGET_TOOLKIT)))
|
||||
DEFINES += -DHAVE_SHELL_SERVICE=1
|
||||
endif
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
|
||||
<command id="Browser:SendLink" oncommand="MailIntegration.sendLinkForContent();"/>
|
||||
<command id="Browser:NewMessage" oncommand="MailIntegration.sendMessage('', '');"/>
|
||||
#ifdef XP_WIN
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
<command id="Browser:ReadMail" oncommand="MailIntegration.readMail();"/>
|
||||
<command id="Browser:ReadNews" oncommand="MailIntegration.readNews();"/>
|
||||
#endif
|
||||
|
|
|
@ -512,31 +512,35 @@ function delayedStartup()
|
|||
|
||||
clearObsoletePrefs();
|
||||
|
||||
#ifdef XP_WIN
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
// Perform default browser checking (after window opens).
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
var shouldCheck = shell.shouldCheckDefaultBrowser;
|
||||
if (shouldCheck && !shell.isDefaultBrowser(true)) {
|
||||
var brandBundle = document.getElementById("bundle_brand");
|
||||
var shellBundle = document.getElementById("bundle_shell");
|
||||
|
||||
var brandShortName = brandBundle.getString("brandShortName");
|
||||
var promptTitle = shellBundle.getString("setDefaultBrowserTitle");
|
||||
var promptMessage = shellBundle.getFormattedString("setDefaultBrowserMessage",
|
||||
[brandShortName]);
|
||||
var checkboxLabel = shellBundle.getString("setDefaultBrowserDontAsk");
|
||||
const IPS = Components.interfaces.nsIPromptService;
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(IPS);
|
||||
var checkEveryTime = { value: shouldCheck };
|
||||
var rv = ps.confirmEx(window, promptTitle, promptMessage,
|
||||
(IPS.BUTTON_TITLE_YES * IPS.BUTTON_POS_0) +
|
||||
(IPS.BUTTON_TITLE_NO * IPS.BUTTON_POS_1),
|
||||
null, null, null, checkboxLabel, checkEveryTime);
|
||||
if (rv == 0)
|
||||
shell.setDefaultBrowser(true, false);
|
||||
shell.shouldCheckDefaultBrowser = checkEveryTime.value;
|
||||
var shell = getShellService();
|
||||
if (shell) {
|
||||
var shouldCheck = shell.shouldCheckDefaultBrowser;
|
||||
if (shouldCheck && !shell.isDefaultBrowser(true)) {
|
||||
var brandBundle = document.getElementById("bundle_brand");
|
||||
var shellBundle = document.getElementById("bundle_shell");
|
||||
|
||||
var brandShortName = brandBundle.getString("brandShortName");
|
||||
var promptTitle = shellBundle.getString("setDefaultBrowserTitle");
|
||||
var promptMessage = shellBundle.getFormattedString("setDefaultBrowserMessage",
|
||||
[brandShortName]);
|
||||
var checkboxLabel = shellBundle.getString("setDefaultBrowserDontAsk");
|
||||
const IPS = Components.interfaces.nsIPromptService;
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(IPS);
|
||||
var checkEveryTime = { value: shouldCheck };
|
||||
var rv = ps.confirmEx(window, promptTitle, promptMessage,
|
||||
(IPS.BUTTON_TITLE_YES * IPS.BUTTON_POS_0) +
|
||||
(IPS.BUTTON_TITLE_NO * IPS.BUTTON_POS_1),
|
||||
null, null, null, checkboxLabel, checkEveryTime);
|
||||
if (rv == 0)
|
||||
shell.setDefaultBrowser(true, false);
|
||||
shell.shouldCheckDefaultBrowser = checkEveryTime.value;
|
||||
}
|
||||
} else {
|
||||
// We couldn't get the shell service; go hide the mail toolbar button.
|
||||
document.getElementById("mail-button").hidden = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2972,11 +2976,17 @@ nsContextMenu.prototype = {
|
|||
this.showItem( "context-viewinfo", !( this.inDirList || this.onImage || this.isTextSelected || this.onLink || this.onTextInput ) );
|
||||
|
||||
this.showItem( "context-sep-properties", !( this.inDirList || this.isTextSelected || this.onTextInput ) );
|
||||
// Set As Wallpaper depends on whether an image was clicked on, and only works on Windows.
|
||||
var isWin = navigator.appVersion.indexOf("Windows") != -1;
|
||||
this.showItem( "context-setWallpaper", isWin && this.onImage );
|
||||
// Set As Wallpaper depends on whether an image was clicked on, and only works if we have a shell service.
|
||||
var haveSetWallpaper = false;
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
// Only enable set as wallpaper if we can get the shell service.
|
||||
var shell = getShellService();
|
||||
if (shell)
|
||||
haveSetWallpaper = true;
|
||||
#endif
|
||||
this.showItem( "context-setWallpaper", haveSetWallpaper && this.onImage );
|
||||
|
||||
if( isWin && this.onImage )
|
||||
if( haveSetWallpaper && this.onImage )
|
||||
// Disable the Set As Wallpaper menu item if we're still trying to load the image
|
||||
this.setItemAttr( "context-setWallpaper", "disabled", (("complete" in this.target) && !this.target.complete) ? "true" : null );
|
||||
|
||||
|
@ -4562,25 +4572,26 @@ var MailIntegration = {
|
|||
var extProtocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"].getService(Components.interfaces.nsIExternalProtocolService);
|
||||
if (extProtocolSvc)
|
||||
extProtocolSvc.loadUrl(aURL);
|
||||
#ifdef XP_WIN
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
},
|
||||
|
||||
readMail: function ()
|
||||
{
|
||||
const ss = Components.interfaces.nsIShellService;
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"].getService(ss);
|
||||
shell.openPreferredApplication(ss.APPLICATION_MAIL);
|
||||
var shell = getShellService();
|
||||
if (shell)
|
||||
shell.openPreferredApplication(Components.interfaces.nsIShellService.APPLICATION_MAIL);
|
||||
},
|
||||
|
||||
readNews: function ()
|
||||
{
|
||||
const ss = Components.interfaces.nsIShellService;
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"].getService(Components.interfaces.nsIShellService);
|
||||
shell.openPreferredApplication(ss.APPLICATION_NEWS);
|
||||
var shell = window.getShellService();
|
||||
if (shell)
|
||||
shell.openPreferredApplication(Components.interfaces.nsIShellService.APPLICATION_NEWS);
|
||||
},
|
||||
|
||||
updateUnreadCount: function ()
|
||||
{
|
||||
#ifdef XP_WIN
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIWindowsShellService);
|
||||
var unreadCount = shell.unreadMailCount;
|
||||
|
@ -4591,6 +4602,7 @@ var MailIntegration = {
|
|||
message = gNavigatorBundle.getFormattedString("mailUnreadMenuitem", [unreadCount]);
|
||||
element = document.getElementById("readMailItem");
|
||||
element.setAttribute("label", message);
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@
|
|||
observes="viewHistorySidebar"
|
||||
tooltiptext="&historyButton.tooltip;"/>
|
||||
|
||||
#ifdef XP_WIN
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
<toolbarbutton id="mail-button" type="menu" class="toolbarbutton-1"
|
||||
label="&mailButton.label;" orient="vertical"
|
||||
onmouseover="MailIntegration.updateUnreadCount();"
|
||||
|
|
|
@ -51,10 +51,11 @@
|
|||
title="&setWallpaper.title;"
|
||||
style="width: 299px">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://browser/content/utilityOverlay.js"/>
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
const xulNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
const ISS = Components.interfaces.nsIShellService;
|
||||
var gMode = ISS.BACKGROUND_STRETCH;
|
||||
var gMonitor;
|
||||
var gWidth, gHeight;
|
||||
|
@ -77,10 +78,11 @@
|
|||
}
|
||||
|
||||
function onLoad() {
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIWindowsShellService);
|
||||
var color = 0;
|
||||
var shell = getShellService();
|
||||
if (shell)
|
||||
color = shell.desktopBackgroundColor;
|
||||
gMonitor = document.getElementById("monitor");
|
||||
var color = shell.desktopBackgroundColor;
|
||||
const rMask = 4294901760;
|
||||
const gMask = 65280;
|
||||
const bMask = 255;
|
||||
|
@ -124,15 +126,16 @@
|
|||
|
||||
function onAccept() {
|
||||
var pos = parseInt(document.getElementById("menuPosition").value);
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIWindowsShellService);
|
||||
shell.setDesktopBackground(window.arguments[0], pos);
|
||||
|
||||
var colorpicker = document.getElementById("desktopColor");
|
||||
var r = HexToR(colorpicker.color);
|
||||
var g = HexToG(colorpicker.color);
|
||||
var b = HexToB(colorpicker.color);
|
||||
shell.desktopBackgroundColor = (r << 16) | (g << 8) | b;
|
||||
|
||||
var shell = getShellService();
|
||||
if (shell) {
|
||||
shell.setDesktopBackground(window.arguments[0], pos);
|
||||
shell.desktopBackgroundColor = (r << 16) | (g << 8) | b;
|
||||
}
|
||||
}
|
||||
|
||||
function updatePreviewColor(color) {
|
||||
|
|
|
@ -356,3 +356,13 @@ function gatherTextUnder ( root )
|
|||
text = text.replace( /\s+/g, " " );
|
||||
return text;
|
||||
}
|
||||
|
||||
function getShellService()
|
||||
{
|
||||
var shell = null;
|
||||
try {
|
||||
shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
} catch (e) {}
|
||||
return shell;
|
||||
}
|
||||
|
|
|
@ -55,10 +55,19 @@ endif
|
|||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/$(LIB_PREFIX)bookmarks_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)migration_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter windows mac gtk2, $(MOZ_WIDGET_TOOLKIT)))
|
||||
SHARED_LIBRARY_LIBS += $(DIST)/lib/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX)
|
||||
endif
|
||||
|
||||
# Link to gkgfx for GNOME shell service
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
|
||||
EXTRA_DSO_LIBS += gkgfx
|
||||
endif
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(LIBS_DIR) \
|
||||
$(EXTRA_DSO_LIBS) \
|
||||
$(MOZ_UNICHARUTIL_LIBS) \
|
||||
$(MOZ_XPCOM_OBSOLETE_LIBS) \
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#include "nsWindowsShellService.h"
|
||||
#elif defined(XP_MACOSX)
|
||||
#include "nsMacShellService.h"
|
||||
#else
|
||||
#elif defined(MOZ_WIDGET_GTK2)
|
||||
#include "nsGNOMEShellService.h"
|
||||
#endif
|
||||
#include "nsProfileMigrator.h"
|
||||
|
@ -71,8 +71,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsBookmarksService, Init)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowsShellService)
|
||||
#elif defined(XP_MACOSX)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacShellService)
|
||||
#else
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsGNOMEShellService)
|
||||
#elif defined(MOZ_WIDGET_GTK2)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGNOMEShellService, Init)
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDogbertProfileMigrator)
|
||||
|
@ -107,7 +107,7 @@ static const nsModuleComponentInfo components[] =
|
|||
NS_SHELLSERVICE_CONTRACTID,
|
||||
nsMacShellServiceConstructor },
|
||||
|
||||
#else
|
||||
#elif defined(MOZ_WIDGET_GTK2)
|
||||
{ "Browser Shell Shervice",
|
||||
NS_SHELLSERVICE_CID,
|
||||
NS_SHELLSERVICE_CONTRACTID,
|
||||
|
|
|
@ -28,3 +28,6 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifneq (,$(filter windows gtk2, $(MOZ_WIDGET_TOOLKIT)))
|
||||
DEFINES += -DHAVE_SHELL_SERVICE=1
|
||||
endif
|
||||
|
|
|
@ -99,9 +99,8 @@ function onOK()
|
|||
homeButton.setAttribute("tooltiptext", parent.homepage);
|
||||
}
|
||||
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
if ("shouldBeDefaultBrowser" in parent && parent.shouldBeDefautBrowser)
|
||||
var shell = getShellService();
|
||||
if (shell && "shouldBeDefaultBrowser" in parent && parent.shouldBeDefautBrowser)
|
||||
shell.setDefaultBrowser(true, false);
|
||||
}
|
||||
|
||||
|
@ -119,7 +118,13 @@ function Startup()
|
|||
// prefwindow wasn't opened from a browser window, so no current page
|
||||
useButton.disabled = true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MOZ_WIDGET_GTK2
|
||||
var shell = getShellService();
|
||||
if (!shell)
|
||||
document.getElementById("defaultBrowserPrefs").hidden = true;
|
||||
#endif
|
||||
|
||||
parent.hPrefWindow.registerOKCallbackFunc(onOK);
|
||||
}
|
||||
|
||||
|
@ -211,9 +216,7 @@ function saveFontPrefs()
|
|||
#ifdef XP_WIN
|
||||
function checkNow()
|
||||
{
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
|
||||
var shell = getShellService();
|
||||
var brandBundle = document.getElementById("bundle_brand");
|
||||
var shellBundle = document.getElementById("bundle_shell");
|
||||
var brandShortName = brandBundle.getString("brandShortName");
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
#ifdef XP_WIN
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
#endif
|
||||
|
@ -55,6 +55,7 @@
|
|||
<stringbundle id="bundle_brand" src="chrome://global/locale/brand.properties"/>
|
||||
<stringbundle id="bundle_shell" src="chrome://browser/locale/shellservice.properties"/>
|
||||
<script type="application/x-javascript" src="chrome://browser/content/pref/pref-navigator.js"/>
|
||||
<script type="application/x-javascript" src="chrome://browser/content/utilityOverlay.js"/>
|
||||
|
||||
<!-- homepage specification -->
|
||||
<groupbox>
|
||||
|
@ -94,8 +95,8 @@
|
|||
</hbox>
|
||||
</groupbox>
|
||||
|
||||
#ifdef XP_WIN
|
||||
<groupbox orient="horizontal">
|
||||
#ifdef HAVE_SHELL_SERVICE
|
||||
<groupbox orient="horizontal" id="defaultBrowserPrefs">
|
||||
<caption label="&defaultBrowserGroup.label;"/>
|
||||
<hbox align="center" flex="1">
|
||||
<checkbox id="checkForDefault" prefstring="browser.shell.checkDefaultBrowser"
|
||||
|
|
|
@ -103,5 +103,11 @@ interface nsIShellService : nsISupports
|
|||
*/
|
||||
void openPreferredApplication(in long aApplication);
|
||||
|
||||
/**
|
||||
* The desktop background color, visible when no background image is
|
||||
* used, or if the background image is centered and does not fill the
|
||||
* entire screen. A rgb value, where (r << 16 | g << 8 | b)
|
||||
*/
|
||||
attribute unsigned long desktopBackgroundColor;
|
||||
};
|
||||
|
||||
|
|
|
@ -50,13 +50,6 @@ interface nsIWindowsShellService : nsIShellService
|
|||
*/
|
||||
void restoreFileSettings(in boolean aForAllUsers);
|
||||
|
||||
/**
|
||||
* The desktop background color, visible when no background image is
|
||||
* used, or if the background image is centered and does not fill the
|
||||
* entire screen. A rgb value, where (r << 24 | g << 16 | b)
|
||||
*/
|
||||
attribute unsigned long desktopBackgroundColor;
|
||||
|
||||
/**
|
||||
* The number of unread mail messages for the current user.
|
||||
*
|
||||
|
|
|
@ -44,6 +44,7 @@ REQUIRES = \
|
|||
gfx \
|
||||
locale \
|
||||
pref \
|
||||
strres \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
|
@ -52,7 +53,10 @@ else
|
|||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS = nsMacShellService.cpp
|
||||
else
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT), gtk2)
|
||||
CPPSRCS = nsGNOMEShellService.cpp
|
||||
REQUIRES += mozgnome
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -62,9 +66,11 @@ include $(topsrcdir)/config/rules.mk
|
|||
|
||||
JS_SET_BROWSER_COMPONENT = nsSetDefaultBrowser.js
|
||||
|
||||
CXXFLAGS += $(TK_CFLAGS)
|
||||
|
||||
libs::
|
||||
$(INSTALL) $(srcdir)/$(JS_SET_BROWSER_COMPONENT) $(DIST)/bin/components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)/lib/$(LIBRARY_NAME).lib
|
||||
rm -f $(DIST)/bin/components/$(JS_SET_BROWSER_COMPONENT)
|
||||
rm -f $(DIST)/bin/components/$(JS_SET_BROWSER_COMPONENT)
|
||||
|
|
|
@ -39,18 +39,286 @@
|
|||
#include "nsShellService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "prenv.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIGConfService.h"
|
||||
#include "nsIGnomeVFSService.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "nsColor.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
struct ProtocolAssociation
|
||||
{
|
||||
const char *name;
|
||||
PRBool essential;
|
||||
};
|
||||
|
||||
struct MimeTypeAssociation
|
||||
{
|
||||
const char *mimeType;
|
||||
const char *extensions;
|
||||
};
|
||||
|
||||
static const ProtocolAssociation appProtocols[] = {
|
||||
{ "http", PR_TRUE },
|
||||
{ "https", PR_TRUE },
|
||||
{ "ftp", PR_FALSE },
|
||||
{ "gopher", PR_FALSE },
|
||||
{ "chrome", PR_FALSE }
|
||||
};
|
||||
|
||||
static const MimeTypeAssociation appTypes[] = {
|
||||
{ "text/html", "htm html shtml" },
|
||||
{ "application/xhtml+xml", "xhtml xht" }
|
||||
};
|
||||
|
||||
static const char kDocumentIconPath[] = "firefox-document.png";
|
||||
|
||||
// GConf registry key constants
|
||||
#define DG_BACKGROUND "/desktop/gnome/background"
|
||||
|
||||
static const char kDesktopImageKey[] = DG_BACKGROUND "/picture_filename";
|
||||
static const char kDesktopOptionsKey[] = DG_BACKGROUND "/picture_options";
|
||||
static const char kDesktopDrawBGKey[] = DG_BACKGROUND "/draw_background";
|
||||
static const char kDesktopColorKey[] = DG_BACKGROUND "/primary_color";
|
||||
|
||||
nsresult
|
||||
nsGNOMEShellService::Init()
|
||||
{
|
||||
// GConf and GnomeVFS _must_ be available, or we do not allow
|
||||
// CreateInstance to succeed.
|
||||
|
||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||
nsCOMPtr<nsIGnomeVFSService> vfs =
|
||||
do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
|
||||
|
||||
if (!gconf || !vfs)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
// Check G_BROKEN_FILENAMES. If it's set, then filenames in glib use
|
||||
// the locale encoding. If it's not set, they use UTF-8.
|
||||
mUseLocaleFilenames = PR_GetEnv("G_BROKEN_FILENAMES") != nsnull;
|
||||
|
||||
// Get the path we were launched from.
|
||||
nsCOMPtr<nsICmdLineService> cmdService =
|
||||
do_GetService("@mozilla.org/appshell/commandLineService;1");
|
||||
if (!cmdService)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsXPIDLCString programName;
|
||||
cmdService->GetProgramName(getter_Copies(programName));
|
||||
|
||||
// Make sure we have an absolute pathname.
|
||||
if (programName[0] != '/') {
|
||||
// First search PATH if we were just launched as 'firefox-bin'.
|
||||
// If we were launched as './firefox-bin', this will just return
|
||||
// the original string.
|
||||
|
||||
gchar *appPath = g_find_program_in_path(programName.get());
|
||||
|
||||
// Now resolve it.
|
||||
char resolvedPath[PATH_MAX] = "";
|
||||
if (realpath(appPath, resolvedPath)) {
|
||||
mAppPath.Assign(resolvedPath);
|
||||
}
|
||||
|
||||
g_free(appPath);
|
||||
} else {
|
||||
mAppPath.Assign(programName);
|
||||
}
|
||||
|
||||
// strip "-bin" off of the binary name
|
||||
if (StringEndsWith(mAppPath, NS_LITERAL_CSTRING("-bin")))
|
||||
mAppPath.SetLength(mAppPath.Length() - 4);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsGNOMEShellService, nsIShellService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefaultBrowser)
|
||||
PRBool
|
||||
nsGNOMEShellService::KeyMatchesAppName(const char *aKeyValue) const
|
||||
{
|
||||
|
||||
gchar *commandPath;
|
||||
if (mUseLocaleFilenames) {
|
||||
gchar *nativePath = g_filename_from_utf8(aKeyValue, -1, NULL, NULL, NULL);
|
||||
if (!nativePath) {
|
||||
NS_ERROR("Error converting path to filesystem encoding");
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
commandPath = g_find_program_in_path(nativePath);
|
||||
g_free(nativePath);
|
||||
} else {
|
||||
commandPath = g_find_program_in_path(aKeyValue);
|
||||
}
|
||||
|
||||
if (!commandPath)
|
||||
return PR_FALSE;
|
||||
|
||||
PRBool matches = mAppPath.Equals(commandPath);
|
||||
g_free(commandPath);
|
||||
return matches;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::IsDefaultBrowser(PRBool aStartupCheck,
|
||||
PRBool* aIsDefaultBrowser)
|
||||
{
|
||||
*aIsDefaultBrowser = PR_FALSE;
|
||||
if (aStartupCheck)
|
||||
mCheckedThisSession = PR_TRUE;
|
||||
|
||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||
|
||||
PRBool enabled;
|
||||
nsCAutoString handler;
|
||||
|
||||
for (unsigned int i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
|
||||
if (!appProtocols[i].essential)
|
||||
continue;
|
||||
|
||||
handler.Truncate();
|
||||
gconf->GetAppForProtocol(nsDependentCString(appProtocols[i].name),
|
||||
&enabled, handler);
|
||||
|
||||
// The string will be something of the form: [/path/to/]browser "%s"
|
||||
// We want to remove all of the parameters and get just the binary name.
|
||||
|
||||
gint argc;
|
||||
gchar **argv;
|
||||
|
||||
if (g_shell_parse_argv(handler.get(), &argc, &argv, NULL) && argc > 0) {
|
||||
handler.Assign(argv[0]);
|
||||
g_strfreev(argv);
|
||||
}
|
||||
|
||||
if (!KeyMatchesAppName(handler.get()) || !enabled)
|
||||
return NS_OK; // the handler is disabled or set to another app
|
||||
}
|
||||
|
||||
*aIsDefaultBrowser = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUsers)
|
||||
nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
|
||||
PRBool aForAllUsers)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (aForAllUsers)
|
||||
NS_WARNING("Setting the default browser for all users is not yet supported");
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||
|
||||
nsCAutoString schemeList;
|
||||
nsCAutoString appKeyValue(mAppPath + NS_LITERAL_CSTRING(" \"%s\""));
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
|
||||
schemeList.Append(nsDependentCString(appProtocols[i].name)
|
||||
+ NS_LITERAL_CSTRING(","));
|
||||
|
||||
if (appProtocols[i].essential || aClaimAllTypes) {
|
||||
gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
|
||||
appKeyValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (aClaimAllTypes) {
|
||||
nsCOMPtr<nsIGnomeVFSService> vfs =
|
||||
do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService =
|
||||
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
NS_ENSURE_TRUE(bundleService, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle));
|
||||
NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE);
|
||||
|
||||
nsXPIDLString brandShortName, brandFullName;
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandShortName));
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
|
||||
getter_Copies(brandFullName));
|
||||
|
||||
// use brandShortName as the application id.
|
||||
NS_ConvertUTF16toUTF8 id(brandShortName);
|
||||
|
||||
vfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_COMMAND, mAppPath);
|
||||
vfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_NAME,
|
||||
NS_ConvertUTF16toUTF8(brandFullName));
|
||||
|
||||
// We don't want to be the default handler for "file:", but we do
|
||||
// want Nautilus to know that we support file: if the MIME type is
|
||||
// one that we can handle.
|
||||
|
||||
schemeList.Append("file");
|
||||
|
||||
vfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_SUPPORTED_URI_SCHEMES,
|
||||
schemeList);
|
||||
|
||||
vfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_EXPECTS_URIS,
|
||||
NS_LITERAL_CSTRING("true"));
|
||||
|
||||
vfs->SetAppBoolKey(id, nsIGnomeVFSService::APP_KEY_CAN_OPEN_MULTIPLE,
|
||||
PR_FALSE);
|
||||
|
||||
vfs->SetAppBoolKey(id, nsIGnomeVFSService::APP_KEY_REQUIRES_TERMINAL,
|
||||
PR_FALSE);
|
||||
|
||||
// Copy icons/document.png to ~/.icons/firefox-document.png
|
||||
nsCAutoString iconFilePath(mAppPath);
|
||||
PRInt32 lastSlash = iconFilePath.RFindChar(PRUnichar('/'));
|
||||
if (lastSlash == -1) {
|
||||
NS_ERROR("no slash in executable path?");
|
||||
} else {
|
||||
iconFilePath.Truncate(lastSlash);
|
||||
nsCOMPtr<nsILocalFile> iconFile;
|
||||
NS_NewNativeLocalFile(iconFilePath, PR_FALSE, getter_AddRefs(iconFile));
|
||||
if (iconFile) {
|
||||
iconFile->AppendRelativeNativePath(NS_LITERAL_CSTRING("icons/document.png"));
|
||||
|
||||
nsCOMPtr<nsILocalFile> userIconPath;
|
||||
NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), PR_FALSE,
|
||||
getter_AddRefs(userIconPath));
|
||||
if (userIconPath) {
|
||||
userIconPath->AppendNative(NS_LITERAL_CSTRING(".icons"));
|
||||
iconFile->CopyToNative(userIconPath,
|
||||
nsDependentCString(kDocumentIconPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < NS_ARRAY_LENGTH(appTypes); ++i) {
|
||||
vfs->AddMimeType(id, nsDependentCString(appTypes[i].mimeType));
|
||||
vfs->SetMimeExtensions(nsDependentCString(appTypes[i].mimeType),
|
||||
nsDependentCString(appTypes[i].extensions));
|
||||
vfs->SetAppForMimeType(nsDependentCString(appTypes[i].mimeType), id);
|
||||
vfs->SetIconForMimeType(nsDependentCString(appTypes[i].mimeType),
|
||||
NS_LITERAL_CSTRING(kDocumentIconPath));
|
||||
}
|
||||
|
||||
vfs->SyncAppRegistry();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -87,16 +355,290 @@ nsGNOMEShellService::SetShouldCheckDefaultBrowser(PRBool aShouldCheck)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
WriteImage(const nsCString& aPath, gfxIImageFrame* aImage)
|
||||
{
|
||||
PRInt32 width, height;
|
||||
aImage->GetWidth(&width);
|
||||
aImage->GetHeight(&height);
|
||||
|
||||
PRInt32 format;
|
||||
aImage->GetFormat(&format);
|
||||
|
||||
aImage->LockImageData();
|
||||
|
||||
PRUint32 bytesPerRow;
|
||||
aImage->GetImageBytesPerRow(&bytesPerRow);
|
||||
|
||||
PRUint32 bpp = bytesPerRow / width * 8;
|
||||
|
||||
// XXX If bpp is not 24, we will need to do something else, like
|
||||
// allocate a new pixbuf and copy the data in ourselves.
|
||||
if (bpp != 24)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint8 *bits;
|
||||
PRUint32 length;
|
||||
|
||||
aImage->GetImageData(&bits, &length);
|
||||
if (!bits) return NS_ERROR_FAILURE;
|
||||
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data(bits,
|
||||
GDK_COLORSPACE_RGB,
|
||||
PR_FALSE,
|
||||
8,
|
||||
width,
|
||||
height,
|
||||
bytesPerRow,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
GdkPixbuf *alphaPixbuf = nsnull;
|
||||
|
||||
if (format == gfxIFormats::RGB_A1 || format == gfxIFormats::RGB_A8) {
|
||||
aImage->LockAlphaData();
|
||||
|
||||
PRUint32 alphaBytesPerRow, alphaDepth, alphaLength;
|
||||
aImage->GetAlphaBytesPerRow(&alphaBytesPerRow);
|
||||
|
||||
#if 0
|
||||
if (format == gfxIFormats::RGB_A1)
|
||||
alphaDepth = 1;
|
||||
else
|
||||
alphaDepth = 8;
|
||||
#endif
|
||||
switch (format) {
|
||||
case gfxIFormats::RGB_A1:
|
||||
alphaDepth = 1;
|
||||
break;
|
||||
case gfxIFormats::RGB_A8:
|
||||
alphaDepth = 8;
|
||||
break;
|
||||
default:
|
||||
// not reached
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
PRUint8 *alphaBits;
|
||||
aImage->GetAlphaData(&alphaBits, &alphaLength);
|
||||
|
||||
alphaPixbuf = gdk_pixbuf_add_alpha(pixbuf, FALSE, 0, 0, 0);
|
||||
|
||||
// Run through alphaBits and copy the alpha mask into the pixbuf's
|
||||
// alpha channel.
|
||||
PRUint8 *maskRow = alphaBits;
|
||||
PRUint8 *pixbufRow = gdk_pixbuf_get_pixels(alphaPixbuf);
|
||||
|
||||
gint pixbufRowStride = gdk_pixbuf_get_rowstride(alphaPixbuf);
|
||||
gint pixbufChannels = gdk_pixbuf_get_n_channels(alphaPixbuf);
|
||||
|
||||
for (PRInt32 y = 0; y < height; ++y) {
|
||||
PRUint8 *pixbufPixel = pixbufRow;
|
||||
PRUint8 *maskPixel = maskRow;
|
||||
|
||||
// If using 1-bit alpha, we must expand it to 8-bit
|
||||
PRUint32 bitPos = 7;
|
||||
|
||||
for (PRInt32 x = 0; x < width; ++x) {
|
||||
if (alphaDepth == 1) {
|
||||
pixbufPixel[pixbufChannels - 1] = ((*maskPixel >> bitPos) & 1) ? 255 : 0;
|
||||
if (bitPos-- == 0) { // wrapped around, move forward a byte
|
||||
++maskPixel;
|
||||
bitPos = 7;
|
||||
}
|
||||
} else {
|
||||
pixbufPixel[pixbufChannels - 1] = *maskPixel++;
|
||||
}
|
||||
|
||||
pixbufPixel += pixbufChannels;
|
||||
}
|
||||
|
||||
pixbufRow += pixbufRowStride;
|
||||
maskRow += alphaBytesPerRow;
|
||||
}
|
||||
}
|
||||
|
||||
gboolean res = gdk_pixbuf_save(alphaPixbuf ? alphaPixbuf : pixbuf,
|
||||
aPath.get(), "png", NULL, NULL);
|
||||
|
||||
if (alphaPixbuf) {
|
||||
aImage->UnlockAlphaData();
|
||||
g_object_unref(alphaPixbuf);
|
||||
}
|
||||
|
||||
aImage->UnlockImageData();
|
||||
g_object_unref(pixbuf);
|
||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||
PRInt32 aPosition)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<gfxIImageFrame> gfxFrame;
|
||||
|
||||
nsCOMPtr<nsIImageLoadingContent> imageContent = do_QueryInterface(aElement, &rv);
|
||||
if (!imageContent) return rv;
|
||||
|
||||
// get the image container
|
||||
nsCOMPtr<imgIRequest> request;
|
||||
rv = imageContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(request));
|
||||
if (!request) return rv;
|
||||
nsCOMPtr<imgIContainer> container;
|
||||
rv = request->GetImage(getter_AddRefs(container));
|
||||
if (!container) return rv;
|
||||
|
||||
// get the current frame, which holds the image data
|
||||
container->GetCurrentFrame(getter_AddRefs(gfxFrame));
|
||||
|
||||
if (!gfxFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Write the background file to the home directory.
|
||||
nsCAutoString filePath(PR_GetEnv("HOME"));
|
||||
|
||||
// get the product brand name from localized strings
|
||||
nsXPIDLString brandName;
|
||||
nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID;
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(bundleCID));
|
||||
if (bundleService) {
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
rv = bundleService->CreateBundle(BRAND_PROPERTIES,
|
||||
getter_AddRefs(brandBundle));
|
||||
if (NS_SUCCEEDED(rv) && brandBundle) {
|
||||
rv = brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandName));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
// build the file name
|
||||
filePath.Append(NS_LITERAL_CSTRING("/") +
|
||||
NS_ConvertUTF16toUTF8(brandName) +
|
||||
NS_LITERAL_CSTRING("_wallpaper.png"));
|
||||
|
||||
// write the image to a file in the home dir
|
||||
rv = WriteImage(filePath, gfxFrame);
|
||||
|
||||
// if the file was written successfully, set it as the system wallpaper
|
||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||
|
||||
nsCAutoString options;
|
||||
if (aPosition == BACKGROUND_TILE)
|
||||
options.Assign("wallpaper");
|
||||
else if (aPosition == BACKGROUND_STRETCH)
|
||||
options.Assign("stretched");
|
||||
else
|
||||
options.Assign("centered");
|
||||
|
||||
gconf->SetString(NS_LITERAL_CSTRING(kDesktopOptionsKey), options);
|
||||
|
||||
// Set the image to an empty string first to force a refresh
|
||||
// (since we could be writing a new image on top of an existing
|
||||
// Firefox_wallpaper.png and nautilus doesn't monitor the file for changes)
|
||||
gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey),
|
||||
NS_LITERAL_CSTRING(""));
|
||||
|
||||
gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey), filePath);
|
||||
gconf->SetBool(NS_LITERAL_CSTRING(kDesktopDrawBGKey), PR_TRUE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
|
||||
{
|
||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||
|
||||
nsCAutoString background;
|
||||
gconf->GetString(NS_LITERAL_CSTRING(kDesktopColorKey), background);
|
||||
|
||||
if (background.IsEmpty()) {
|
||||
*aColor = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Chop off the leading '#' character
|
||||
background.Cut(0, 1);
|
||||
|
||||
nscolor rgb;
|
||||
if (!NS_ASCIIHexToRGB(background, &rgb))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// The result must be in RGB order with the high 8 bits zero.
|
||||
*aColor = (NS_GET_R(rgb) << 16 | NS_GET_G(rgb) << 8 | NS_GET_B(rgb));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::SetDesktopBackgroundColor(PRUint32 aColor)
|
||||
{
|
||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||
|
||||
unsigned char red = (aColor >> 16);
|
||||
unsigned char green = (aColor >> 8) & 0xff;
|
||||
unsigned char blue = aColor & 0xff;
|
||||
|
||||
nsCAutoString colorString;
|
||||
NS_RGBToASCIIHex(NS_RGB(red, green, blue), colorString);
|
||||
|
||||
gconf->SetString(NS_LITERAL_CSTRING(kDesktopColorKey), colorString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::OpenPreferredApplication(PRInt32 aApplication)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
nsCAutoString scheme;
|
||||
if (aApplication == APPLICATION_MAIL)
|
||||
scheme.Assign("mailto");
|
||||
else if (aApplication == APPLICATION_NEWS)
|
||||
scheme.Assign("news");
|
||||
else
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||
|
||||
PRBool enabled;
|
||||
nsCAutoString appCommand;
|
||||
gconf->GetAppForProtocol(scheme, &enabled, appCommand);
|
||||
|
||||
if (!enabled)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// XXX we don't currently handle launching a terminal window.
|
||||
// If the handler requires a terminal, bail.
|
||||
PRBool requiresTerminal;
|
||||
gconf->HandlerRequiresTerminal(scheme, &requiresTerminal);
|
||||
if (requiresTerminal)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Perform shell argument expansion
|
||||
int argc;
|
||||
char **argv;
|
||||
if (!g_shell_parse_argv(appCommand.get(), &argc, &argv, NULL))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
char **newArgv = new char*[argc + 1];
|
||||
int newArgc = 0;
|
||||
|
||||
// Run through the list of arguments. Copy all of them to the new
|
||||
// argv except for %s, which we skip.
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
if (strcmp(argv[i], "%s") != 0)
|
||||
newArgv[newArgc++] = argv[i];
|
||||
}
|
||||
|
||||
newArgv[newArgc] = nsnull;
|
||||
|
||||
gboolean err = g_spawn_async(NULL, newArgv, NULL, G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, NULL, NULL);
|
||||
|
||||
g_strfreev(argv);
|
||||
delete[] newArgv;
|
||||
|
||||
return err ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -38,20 +38,26 @@
|
|||
#define nsgnomeshellservice_h____
|
||||
|
||||
#include "nsIShellService.h"
|
||||
#include "nsString.h"
|
||||
|
||||
class nsGNOMEShellService : public nsIShellService
|
||||
{
|
||||
public:
|
||||
nsGNOMEShellService() : mCheckedThisSession(PR_FALSE) {};
|
||||
virtual ~nsGNOMEShellService() {};
|
||||
nsGNOMEShellService() : mCheckedThisSession(PR_FALSE) { }
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISHELLSERVICE
|
||||
|
||||
protected:
|
||||
nsresult Init() NS_HIDDEN;
|
||||
|
||||
private:
|
||||
PRBool mCheckedThisSession;
|
||||
~nsGNOMEShellService() {}
|
||||
|
||||
NS_HIDDEN_(PRBool) KeyMatchesAppName(const char *aKeyValue) const;
|
||||
|
||||
PRPackedBool mCheckedThisSession;
|
||||
PRPackedBool mUseLocaleFilenames;
|
||||
nsCString mAppPath;
|
||||
};
|
||||
|
||||
#endif // nsgnomeshellservice_h____
|
||||
|
|
|
@ -100,3 +100,14 @@ nsMacShellService::OpenPreferredApplication(PRInt32 aApplication)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacShellService::GetDesktopBackgroundColor(PRUint32 *aColor)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacShellService::SetDesktopBackgroundColor(PRUint32 *aColor)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -67,9 +67,15 @@ nsSetDefaultBrowser.prototype = {
|
|||
get prefNameForStartup() { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
|
||||
|
||||
get chromeUrlForTask() {
|
||||
// First, get winhooks service.
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
// First, get shell service
|
||||
var shell;
|
||||
try {
|
||||
shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
} catch(e) { }
|
||||
if (!shell)
|
||||
throw Components.results.NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
shell.setDefaultBrowser(true, true);
|
||||
|
||||
// Now, get the cmd line service.
|
||||
|
|
|
@ -170,7 +170,9 @@ bin/components/xpinstall.xpt
|
|||
bin/components/xremoteservice.xpt
|
||||
bin/components/xuldoc.xpt
|
||||
bin/components/xultmpl.xpt
|
||||
bin/components/shellservice.xpt
|
||||
; JavaScript components
|
||||
bin/components/nsSetDefaultBrowser.js
|
||||
bin/components/jsconsole-clhandler.js
|
||||
bin/components/nsCloseAllWindows.js
|
||||
bin/components/nsDictionary.js
|
||||
|
@ -191,6 +193,10 @@ bin/components/update.xpt
|
|||
; Kerberos NegotiateAuth
|
||||
bin/components/libnegotiateauth.so
|
||||
|
||||
; GNOME hooks
|
||||
bin/components/libmozgnome.so
|
||||
bin/components/mozgnome.xpt
|
||||
|
||||
; [Browser Chrome Files]
|
||||
bin/chrome/browser.jar
|
||||
bin/chrome/classic.jar
|
||||
|
@ -198,6 +204,10 @@ bin/chrome/comm.jar
|
|||
bin/chrome/toolkit.jar
|
||||
bin/chrome/icons/default/default.xpm
|
||||
|
||||
; shell icons
|
||||
bin/icons/*.xpm
|
||||
bin/icons/*.png
|
||||
|
||||
; [Default Preferences]
|
||||
; All the pref files must be part of base to prevent migration bugs
|
||||
bin/defaults/pref/firefox.js
|
||||
|
|
|
@ -448,7 +448,7 @@ MOZ_XUL_APP = 1
|
|||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for mozilla/toolkit (pulled and built if MOZ_XUL_APP is set)
|
||||
# CVS defines for mozilla/toolkit
|
||||
#
|
||||
|
||||
TOOLKIT_CO_FLAGS := -P
|
||||
|
@ -460,13 +460,8 @@ ifdef TOOLKIT_CO_TAG
|
|||
endif
|
||||
|
||||
CVSCO_MOZTOOLKIT := $(CVS) $(CVS_FLAGS) co $(TOOLKIT_CO_FLAGS) $(CVS_CO_DATE_FLAGS) mozilla/toolkit mozilla/chrome
|
||||
ifdef MOZ_XUL_APP
|
||||
FASTUPDATE_MOZTOOLKIT := fast_update $(CVSCO_MOZTOOLKIT)
|
||||
CHECKOUT_MOZTOOLKIT := cvs_co $(CVSCO_MOZTOOLKIT)
|
||||
else
|
||||
FASTUPDATE_MOZTOOLKIT := true
|
||||
CHECKOUT_MOZTOOLKIT := true
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for codesighs (pulled and built if MOZ_MAPINFO is set)
|
||||
|
|
|
@ -187,6 +187,12 @@ MOZ_GNOMEUI_LIBS = @MOZ_GNOMEUI_LIBS@
|
|||
MOZ_GNOMEVFS_CFLAGS = @MOZ_GNOMEVFS_CFLAGS@
|
||||
MOZ_GNOMEVFS_LIBS = @MOZ_GNOMEVFS_LIBS@
|
||||
|
||||
MOZ_GCONF_CFLAGS = @MOZ_GCONF_CFLAGS@
|
||||
MOZ_GCONF_LIBS = @MOZ_GCONF_LIBS@
|
||||
|
||||
MOZ_LIBGNOME_CFLAGS = @MOZ_LIBGNOME_CFLAGS@
|
||||
MOZ_LIBGNOME_LIBS = @MOZ_LIBGNOME_LIBS@
|
||||
|
||||
MOZ_INSURE = @MOZ_INSURE@
|
||||
MOZ_INSURIFYING = @MOZ_INSURIFYING@
|
||||
MOZ_INSURE_DIRS = @MOZ_INSURE_DIRS@
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
33
configure.in
33
configure.in
|
@ -94,6 +94,8 @@ WINDRES_VERSION=2.14.90
|
|||
W32API_VERSION=2.4
|
||||
GNOMEVFS_VERSION=2.0
|
||||
GNOMEUI_VERSION=2.2.0
|
||||
GCONF_VERSION=1.2.1
|
||||
LIBGNOME_VERSION=2.0
|
||||
|
||||
dnl Set various checks
|
||||
dnl ========================================================
|
||||
|
@ -3505,6 +3507,8 @@ then
|
|||
if test "$MOZ_ENABLE_GTK2"
|
||||
then
|
||||
MOZ_ENABLE_GNOMEVFS=1
|
||||
MOZ_ENABLE_GCONF=1
|
||||
MOZ_ENABLE_LIBGNOME=1
|
||||
fi
|
||||
|
||||
MOZ_ARG_DISABLE_BOOL(gnomevfs,
|
||||
|
@ -3514,12 +3518,12 @@ then
|
|||
|
||||
if test "$MOZ_ENABLE_GNOMEVFS"
|
||||
then
|
||||
PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION,[
|
||||
PKG_CHECK_MODULES(MOZ_GNOMEVFS, gnome-vfs-2.0 >= $GNOMEVFS_VERSION gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION,[
|
||||
MOZ_ENABLE_GNOMEVFS=1
|
||||
],[
|
||||
if test "$MOZ_ENABLE_GNOMEVFS" = "force"
|
||||
then
|
||||
AC_MSG_ERROR([* * * Could not find gnome-vfs-2.0 >= $GNOMEVFS_VERSION])
|
||||
AC_MSG_ERROR([* * * Could not find gnome-vfs-module-2.0 >= $GNOMEVFS_VERSION])
|
||||
fi
|
||||
MOZ_ENABLE_GNOMEVFS=
|
||||
])
|
||||
|
@ -3527,6 +3531,31 @@ then
|
|||
|
||||
AC_SUBST(MOZ_GNOMEVFS_CFLAGS)
|
||||
AC_SUBST(MOZ_GNOMEVFS_LIBS)
|
||||
|
||||
if test "$MOZ_ENABLE_GCONF"
|
||||
then
|
||||
PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION,[
|
||||
MOZ_ENABLE_GCONF=1
|
||||
],[
|
||||
MOZ_ENABLE_GCONF=
|
||||
])
|
||||
fi
|
||||
|
||||
AC_SUBST(MOZ_GCONF_CFLAGS)
|
||||
AC_SUBST(MOZ_GCONF_LIBS)
|
||||
|
||||
if test "$MOZ_ENABLE_LIBGNOME"
|
||||
then
|
||||
PKG_CHECK_MODULES(MOZ_LIBGNOME, libgnome-2.0 >= $LIBGNOME_VERSION,[
|
||||
MOZ_ENABLE_LIBGNOME=1
|
||||
],[
|
||||
MOZ_ENABLE_LIBGNOME=
|
||||
])
|
||||
fi
|
||||
|
||||
AC_SUBST(MOZ_LIBGNOME_CFLAGS)
|
||||
AC_SUBST(MOZ_LIBGNOME_LIBS)
|
||||
|
||||
fi
|
||||
|
||||
dnl ========================================================
|
||||
|
|
|
@ -39,9 +39,7 @@
|
|||
#define nsColor_h___
|
||||
|
||||
#include "gfxCore.h"
|
||||
|
||||
class nsString;
|
||||
class nsAString;
|
||||
#include "nsStringFwd.h"
|
||||
|
||||
// A color is a 32 bit unsigned integer with four components: R, G, B
|
||||
// and A.
|
||||
|
@ -85,6 +83,8 @@ typedef PRUint32 nscolor;
|
|||
// otherwise return false.
|
||||
// This accepts only 3, 6 or 9 digits
|
||||
extern "C" NS_GFX_(PRBool) NS_HexToRGB(const nsString& aBuf, nscolor* aResult);
|
||||
extern "C" NS_GFX_(PRBool) NS_ASCIIHexToRGB(const nsCString& aBuf,
|
||||
nscolor* aResult);
|
||||
|
||||
// Translate a hex string to a color. Return true if it parses ok,
|
||||
// otherwise return false.
|
||||
|
@ -94,6 +94,8 @@ extern "C" NS_GFX_(PRBool) NS_LooseHexToRGB(const nsString& aBuf, nscolor* aResu
|
|||
// Translate a color to a hex string and prepend a '#'.
|
||||
// The returned string is always 7 characters including a '#' character.
|
||||
extern "C" NS_GFX_(void) NS_RGBToHex(nscolor aColor, nsAString& aResult);
|
||||
extern "C" NS_GFX_(void) NS_RGBToASCIIHex(nscolor aColor,
|
||||
nsAFlatCString& aResult);
|
||||
|
||||
// Translate a color name to a color. Return true if it parses ok,
|
||||
// otherwise return false.
|
||||
|
|
|
@ -72,13 +72,20 @@ static int ComponentValue(const char* aColorSpec, int aLen, int color, int dpc)
|
|||
return component;
|
||||
}
|
||||
|
||||
extern "C" NS_GFX_(PRBool) NS_HexToRGB(const nsString& aColorSpec, nscolor* aResult)
|
||||
extern "C" NS_GFX_(PRBool) NS_HexToRGB(const nsString& aColorSpec,
|
||||
nscolor* aResult)
|
||||
{
|
||||
// XXXldb nsStackString<10>
|
||||
NS_LossyConvertUCS2toASCII bufferStr(aColorSpec);
|
||||
const char* buffer = bufferStr.get();
|
||||
return NS_ASCIIHexToRGB(bufferStr, aResult);
|
||||
}
|
||||
|
||||
int nameLen = bufferStr.Length();
|
||||
extern "C" NS_GFX_(PRBool) NS_ASCIIHexToRGB(const nsCString& aColorSpec,
|
||||
nscolor* aResult)
|
||||
{
|
||||
const char* buffer = aColorSpec.get();
|
||||
|
||||
int nameLen = aColorSpec.Length();
|
||||
if ((nameLen == 3) || (nameLen == 6)) {
|
||||
// Make sure the digits are legal
|
||||
for (int i = 0; i < nameLen; i++) {
|
||||
|
@ -166,6 +173,15 @@ extern "C" NS_GFX_(void) NS_RGBToHex(nscolor aColor, nsAString& aResult)
|
|||
CopyASCIItoUTF16(buf, aResult);
|
||||
}
|
||||
|
||||
extern "C" NS_GFX_(void) NS_RGBToASCIIHex(nscolor aColor,
|
||||
nsAFlatCString& aResult)
|
||||
{
|
||||
aResult.SetLength(7);
|
||||
char *buf = aResult.BeginWriting();
|
||||
PR_snprintf(buf, 8, "#%02x%02x%02x",
|
||||
NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor));
|
||||
}
|
||||
|
||||
extern "C" NS_GFX_(PRBool) NS_ColorNameToRGB(const nsAString& aColorName, nscolor* aResult)
|
||||
{
|
||||
nsColorName id = nsColorNames::LookupName(aColorName);
|
||||
|
|
|
@ -23,6 +23,9 @@ BROWSER_APP_FILES = \
|
|||
export::
|
||||
$(NSINSTALL) -D $(DIST)/branding
|
||||
cp $(addprefix $(srcdir)/, $(BROWSER_APP_FILES)) $(DIST)/branding/
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
|
||||
cp $(srcdir)/document.png $(DIST)/branding/document.png
|
||||
endif
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
cp $(srcdir)/firefox.icns $(DIST)/branding/firefox.icns
|
||||
cp $(srcdir)/document.icns $(DIST)/branding/document.icns
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.2 KiB |
|
@ -0,0 +1 @@
|
|||
Makefile
|
|
@ -0,0 +1,81 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Mozilla GNOME integration code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# IBM Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Brian Ryner <bryner@brianryner.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = mozgnome
|
||||
LIBRARY_NAME = mozgnome
|
||||
FORCE_SHARED_LIB = 1
|
||||
IS_COMPONENT = 1
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
necko \
|
||||
$(NULL)
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIGConfService.idl \
|
||||
nsIGnomeVFSService.idl \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
nsGConfService.cpp \
|
||||
nsGnomeVFSService.cpp \
|
||||
nsGnomeModule.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DSO_LDOPTS += \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
$(MOZ_GCONF_LIBS) \
|
||||
$(MOZ_GNOMEVFS_LIBS) \
|
||||
$(MOZ_LIBGNOME_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
CXXFLAGS += \
|
||||
$(MOZ_GCONF_CFLAGS) \
|
||||
$(MOZ_GNOMEVFS_CFLAGS) \
|
||||
$(MOZ_LIBGNOME_CFLAGS) \
|
||||
$(NULL)
|
||||
|
|
@ -0,0 +1,233 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla GNOME integration code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsGConfService.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include <gconf/gconf-client.h>
|
||||
|
||||
nsGConfService::~nsGConfService()
|
||||
{
|
||||
if (mClient)
|
||||
g_object_unref(mClient);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGConfService::Init()
|
||||
{
|
||||
mClient = gconf_client_get_default();
|
||||
return mClient ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsGConfService, nsIGConfService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::GetBool(const nsACString &aKey, PRBool *aResult)
|
||||
{
|
||||
GError* error = nsnull;
|
||||
*aResult = gconf_client_get_bool(mClient, PromiseFlatCString(aKey).get(),
|
||||
&error);
|
||||
|
||||
if (error) {
|
||||
g_error_free(error);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::GetString(const nsACString &aKey, nsACString &aResult)
|
||||
{
|
||||
GError* error = nsnull;
|
||||
gchar *result = gconf_client_get_string(mClient,
|
||||
PromiseFlatCString(aKey).get(),
|
||||
&error);
|
||||
|
||||
if (error) {
|
||||
g_error_free(error);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// We do a string copy here so that the caller doesn't need to worry about
|
||||
// freeing the string with g_free().
|
||||
|
||||
aResult.Assign(result);
|
||||
g_free(result);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::GetInt(const nsACString &aKey, PRInt32* aResult)
|
||||
{
|
||||
GError* error = nsnull;
|
||||
*aResult = gconf_client_get_int(mClient, PromiseFlatCString(aKey).get(),
|
||||
&error);
|
||||
|
||||
if (error) {
|
||||
g_error_free(error);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::GetFloat(const nsACString &aKey, float* aResult)
|
||||
{
|
||||
GError* error = nsnull;
|
||||
*aResult = gconf_client_get_float(mClient, PromiseFlatCString(aKey).get(),
|
||||
&error);
|
||||
|
||||
if (error) {
|
||||
g_error_free(error);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::SetBool(const nsACString &aKey, PRBool aValue)
|
||||
{
|
||||
PRBool res = gconf_client_set_bool(mClient, PromiseFlatCString(aKey).get(),
|
||||
aValue, nsnull);
|
||||
|
||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::SetString(const nsACString &aKey, const nsACString &aValue)
|
||||
{
|
||||
PRBool res = gconf_client_set_string(mClient, PromiseFlatCString(aKey).get(),
|
||||
PromiseFlatCString(aValue).get(),
|
||||
nsnull);
|
||||
|
||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::SetInt(const nsACString &aKey, PRInt32 aValue)
|
||||
{
|
||||
PRBool res = gconf_client_set_int(mClient, PromiseFlatCString(aKey).get(),
|
||||
aValue, nsnull);
|
||||
|
||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::SetFloat(const nsACString &aKey, float aValue)
|
||||
{
|
||||
PRBool res = gconf_client_set_float(mClient, PromiseFlatCString(aKey).get(),
|
||||
aValue, nsnull);
|
||||
|
||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::GetAppForProtocol(const nsACString &aScheme, PRBool *aEnabled,
|
||||
nsACString &aHandler)
|
||||
{
|
||||
nsCAutoString key(NS_LITERAL_CSTRING("/desktop/gnome/url-handlers/")
|
||||
+ aScheme + NS_LITERAL_CSTRING("/command"));
|
||||
|
||||
GError *err = nsnull;
|
||||
gchar *command = gconf_client_get_string(mClient, key.get(), &err);
|
||||
if (!err && command) {
|
||||
key.Replace(key.Length() - 7, 7, NS_LITERAL_CSTRING("enabled"));
|
||||
*aEnabled = gconf_client_get_bool(mClient, key.get(), &err);
|
||||
} else {
|
||||
*aEnabled = PR_FALSE;
|
||||
}
|
||||
|
||||
aHandler.Assign(command);
|
||||
if (command)
|
||||
g_free(command);
|
||||
|
||||
if (err) {
|
||||
g_error_free(err);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::HandlerRequiresTerminal(const nsACString &aScheme,
|
||||
PRBool *aResult)
|
||||
{
|
||||
nsCAutoString key(NS_LITERAL_CSTRING("/desktop/gnome/url-handlers/")
|
||||
+ aScheme + NS_LITERAL_CSTRING("/requires_terminal"));
|
||||
|
||||
GError *err = nsnull;
|
||||
*aResult = gconf_client_get_bool(mClient, key.get(), &err);
|
||||
if (err) {
|
||||
g_error_free(err);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGConfService::SetAppForProtocol(const nsACString &aScheme,
|
||||
const nsACString &aCommand)
|
||||
{
|
||||
nsCAutoString key(NS_LITERAL_CSTRING("/desktop/gnome/url-handlers/")
|
||||
+ aScheme + NS_LITERAL_CSTRING("/command"));
|
||||
|
||||
PRBool res = gconf_client_set_string(mClient, key.get(),
|
||||
PromiseFlatCString(aCommand).get(),
|
||||
nsnull);
|
||||
if (res) {
|
||||
key.Replace(key.Length() - 7, 7, NS_LITERAL_CSTRING("enabled"));
|
||||
res = gconf_client_set_bool(mClient, key.get(), PR_TRUE, nsnull);
|
||||
if (res) {
|
||||
key.Replace(key.Length() - 7, 7, NS_LITERAL_CSTRING("needs_terminal"));
|
||||
res = gconf_client_set_bool(mClient, key.get(), PR_FALSE, nsnull);
|
||||
if (res) {
|
||||
key.Replace(key.Length() - 14, 14, NS_LITERAL_CSTRING("command-id"));
|
||||
res = gconf_client_unset(mClient, key.get(), nsnull);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla GNOME integration code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsGConfService_h_
|
||||
#define nsGConfService_h_
|
||||
|
||||
#include "nsIGConfService.h"
|
||||
#include "gconf/gconf-client.h"
|
||||
|
||||
#define NS_GCONFSERVICE_CID \
|
||||
{0xd96d5985, 0xa13a, 0x4bdc, {0x93, 0x86, 0xef, 0x34, 0x8d, 0x7a, 0x97, 0xa1}}
|
||||
|
||||
class nsGConfService : public nsIGConfService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIGCONFSERVICE
|
||||
|
||||
nsGConfService() : mClient(nsnull) {}
|
||||
NS_HIDDEN_(nsresult) Init();
|
||||
|
||||
private:
|
||||
~nsGConfService() NS_HIDDEN;
|
||||
|
||||
GConfClient *mClient;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla GNOME integration code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsGConfService.h"
|
||||
#include "nsGnomeVFSService.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGConfService, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGnomeVFSService, Init)
|
||||
|
||||
static const nsModuleComponentInfo components[] = {
|
||||
{ "GConf Service",
|
||||
NS_GCONFSERVICE_CID,
|
||||
NS_GCONFSERVICE_CONTRACTID,
|
||||
nsGConfServiceConstructor },
|
||||
{ "GnomeVFS Service",
|
||||
NS_GNOMEVFSSERVICE_CID,
|
||||
NS_GNOMEVFSSERVICE_CONTRACTID,
|
||||
nsGnomeVFSServiceConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(mozgnome, components)
|
|
@ -0,0 +1,277 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla GNOME integration code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsGnomeVFSService.h"
|
||||
#include "nsStringEnumerator.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libgnomevfs/gnome-vfs-application-registry.h>
|
||||
#include <libgnomevfs/gnome-vfs-init.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
|
||||
#include <libgnomevfs/gnome-vfs-mime-info.h>
|
||||
#include <libgnome/gnome-url.h>
|
||||
}
|
||||
|
||||
class nsGnomeVFSMimeApp : public nsIGnomeVFSMimeApp
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIGNOMEVFSMIMEAPP
|
||||
|
||||
nsGnomeVFSMimeApp(GnomeVFSMimeApplication* aApp) : mApp(aApp) {}
|
||||
~nsGnomeVFSMimeApp() { gnome_vfs_mime_application_free(mApp); }
|
||||
|
||||
private:
|
||||
GnomeVFSMimeApplication *mApp;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsGnomeVFSMimeApp, nsIGnomeVFSMimeApp)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSMimeApp::GetId(nsACString& aId)
|
||||
{
|
||||
aId.Assign(mApp->id);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSMimeApp::GetName(nsACString& aName)
|
||||
{
|
||||
aName.Assign(mApp->name);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSMimeApp::GetCommand(nsACString& aCommand)
|
||||
{
|
||||
aCommand.Assign(mApp->command);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSMimeApp::GetCanOpenMultipleFiles(PRBool* aCanOpen)
|
||||
{
|
||||
*aCanOpen = mApp->can_open_multiple_files;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSMimeApp::GetExpectsURIs(PRInt32* aExpects)
|
||||
{
|
||||
*aExpects = mApp->expects_uris;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSMimeApp::GetSupportedURISchemes(nsIUTF8StringEnumerator** aSchemes)
|
||||
{
|
||||
*aSchemes = nsnull;
|
||||
|
||||
nsCStringArray *array = new nsCStringArray();
|
||||
NS_ENSURE_TRUE(array, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
for (GList *list = mApp->supported_uri_schemes; list; list = list->next) {
|
||||
if (!array->AppendCString(nsDependentCString((char*) list->data))) {
|
||||
delete array;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_NewAdoptingUTF8StringEnumerator(aSchemes, array);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSMimeApp::GetRequiresTerminal(PRBool* aRequires)
|
||||
{
|
||||
*aRequires = mApp->requires_terminal;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGnomeVFSService::Init()
|
||||
{
|
||||
return gnome_vfs_init() ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsGnomeVFSService, nsIGnomeVFSService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::GetMimeTypeFromExtension(const nsACString &aExtension,
|
||||
nsACString& aMimeType)
|
||||
{
|
||||
nsCAutoString fileExtToUse(NS_LITERAL_CSTRING(".") + aExtension);
|
||||
|
||||
const char *mimeType = gnome_vfs_mime_type_from_name(fileExtToUse.get());
|
||||
aMimeType.Assign(mimeType);
|
||||
|
||||
// |mimeType| points to internal gnome-vfs data, so don't free it.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::GetAppForMimeType(const nsACString &aMimeType,
|
||||
nsIGnomeVFSMimeApp** aApp)
|
||||
{
|
||||
*aApp = nsnull;
|
||||
GnomeVFSMimeApplication *app =
|
||||
gnome_vfs_mime_get_default_application(PromiseFlatCString(aMimeType).get());
|
||||
|
||||
if (app) {
|
||||
nsGnomeVFSMimeApp *mozApp = new nsGnomeVFSMimeApp(app);
|
||||
NS_ENSURE_TRUE(mozApp, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(*aApp = mozApp);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::SetAppForMimeType(const nsACString &aMimeType,
|
||||
const nsACString &aId)
|
||||
{
|
||||
gnome_vfs_mime_set_default_application(PromiseFlatCString(aMimeType).get(),
|
||||
PromiseFlatCString(aId).get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::SetIconForMimeType(const nsACString &aMimeType,
|
||||
const nsACString &aIconName)
|
||||
{
|
||||
gnome_vfs_mime_set_icon(PromiseFlatCString(aMimeType).get(),
|
||||
PromiseFlatCString(aIconName).get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::GetDescriptionForMimeType(const nsACString &aMimeType,
|
||||
nsACString& aDescription)
|
||||
{
|
||||
const char *desc =
|
||||
gnome_vfs_mime_get_description(PromiseFlatCString(aMimeType).get());
|
||||
aDescription.Assign(desc);
|
||||
|
||||
// |desc| points to internal gnome-vfs data, so don't free it.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::ShowURI(nsIURI *aURI)
|
||||
{
|
||||
nsCAutoString spec;
|
||||
aURI->GetSpec(spec);
|
||||
|
||||
if (gnome_url_show(spec.get(), NULL))
|
||||
return NS_OK;
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::SetAppStringKey(const nsACString &aID,
|
||||
PRInt32 aKey,
|
||||
const nsACString &aValue)
|
||||
{
|
||||
const char *key;
|
||||
|
||||
if (aKey == APP_KEY_COMMAND)
|
||||
key = GNOME_VFS_APPLICATION_REGISTRY_COMMAND;
|
||||
else if (aKey == APP_KEY_NAME)
|
||||
key = GNOME_VFS_APPLICATION_REGISTRY_NAME;
|
||||
else if (aKey == APP_KEY_SUPPORTED_URI_SCHEMES)
|
||||
key = "supported_uri_schemes";
|
||||
else if (aKey == APP_KEY_EXPECTS_URIS)
|
||||
key = "expects_uris";
|
||||
else
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
gnome_vfs_application_registry_set_value(PromiseFlatCString(aID).get(), key,
|
||||
PromiseFlatCString(aValue).get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::SetAppBoolKey(const nsACString &aID,
|
||||
PRInt32 aKey,
|
||||
PRBool aValue)
|
||||
{
|
||||
const char *key;
|
||||
|
||||
if (aKey == APP_KEY_CAN_OPEN_MULTIPLE)
|
||||
key = GNOME_VFS_APPLICATION_REGISTRY_CAN_OPEN_MULTIPLE_FILES;
|
||||
else if (aKey == APP_KEY_REQUIRES_TERMINAL)
|
||||
key = GNOME_VFS_APPLICATION_REGISTRY_REQUIRES_TERMINAL;
|
||||
else
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
gnome_vfs_application_registry_set_bool_value(PromiseFlatCString(aID).get(),
|
||||
key, aValue);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::AddMimeType(const nsACString &aID, const nsACString &aType)
|
||||
{
|
||||
gnome_vfs_application_registry_add_mime_type(PromiseFlatCString(aID).get(),
|
||||
PromiseFlatCString(aType).get());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::SyncAppRegistry()
|
||||
{
|
||||
gnome_vfs_application_registry_sync();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGnomeVFSService::SetMimeExtensions(const nsACString &aMimeType,
|
||||
const nsACString &aExtensionsList)
|
||||
{
|
||||
GnomeVFSResult res =
|
||||
gnome_vfs_mime_set_extensions_list(PromiseFlatCString(aMimeType).get(),
|
||||
PromiseFlatCString(aExtensionsList).get());
|
||||
return (res == GNOME_VFS_OK) ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla GNOME integration code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsGnomeVFSService_h_
|
||||
#define nsGnomeVFSService_h_
|
||||
|
||||
#include "nsIGnomeVFSService.h"
|
||||
|
||||
#define NS_GNOMEVFSSERVICE_CID \
|
||||
{0x5f43022c, 0x6194, 0x4b37, {0xb2, 0x6d, 0xe4, 0x10, 0x24, 0x62, 0x52, 0x64}}
|
||||
|
||||
class nsGnomeVFSService : public nsIGnomeVFSService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIGNOMEVFSSERVICE
|
||||
|
||||
NS_HIDDEN_(nsresult) Init();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,75 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla GNOME integration code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(01ac7b2e-c07c-465f-b35c-542eaef420a9)]
|
||||
interface nsIGConfService : nsISupports
|
||||
{
|
||||
/* Basic registry access */
|
||||
boolean getBool(in AUTF8String key);
|
||||
AUTF8String getString(in AUTF8String key);
|
||||
long getInt(in AUTF8String key);
|
||||
float getFloat(in AUTF8String key);
|
||||
|
||||
void setBool(in AUTF8String key, in boolean value);
|
||||
void setString(in AUTF8String key, in AUTF8String value);
|
||||
void setInt(in AUTF8String key, in long value);
|
||||
void setFloat(in AUTF8String key, in float value);
|
||||
|
||||
/*
|
||||
* Look up the handler for a protocol under the
|
||||
* /desktop/gnome/url-handlers hierarchy.
|
||||
*/
|
||||
AUTF8String getAppForProtocol(in AUTF8String scheme, out boolean enabled);
|
||||
|
||||
/*
|
||||
* Check whether the handler for a scheme requires a terminal to run.
|
||||
*/
|
||||
boolean handlerRequiresTerminal(in AUTF8String scheme);
|
||||
|
||||
/*
|
||||
* Set the handler for a protocol, marking it as enabled.
|
||||
* This removes any GnomeVFSMimeApp association for the protocol.
|
||||
*/
|
||||
void setAppForProtocol(in AUTF8String scheme, in AUTF8String command);
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_GCONFSERVICE_CONTRACTID "@mozilla.org/gnome-gconf-service;1"
|
||||
%}
|
|
@ -0,0 +1,150 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is the Mozilla GNOME integration code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* IBM Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Ryner <bryner@brianryner.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIUTF8StringEnumerator;
|
||||
interface nsIURI;
|
||||
|
||||
/* nsIGnomeVFSMimeApp holds information about an application that is looked up
|
||||
with nsIGnomeVFSService::GetAppForMimeType. */
|
||||
|
||||
[scriptable, uuid(99ae024f-e869-4973-958b-54768a84295a)]
|
||||
interface nsIGnomeVFSMimeApp : nsISupports
|
||||
{
|
||||
const long EXPECTS_URIS = 0;
|
||||
const long EXPECTS_PATHS = 1;
|
||||
const long EXPECTS_URIS_FOR_NON_FILES = 2;
|
||||
|
||||
readonly attribute AUTF8String id;
|
||||
readonly attribute AUTF8String name;
|
||||
readonly attribute AUTF8String command;
|
||||
readonly attribute boolean canOpenMultipleFiles;
|
||||
readonly attribute long expectsURIs; // see constants above
|
||||
readonly attribute nsIUTF8StringEnumerator supportedURISchemes;
|
||||
readonly attribute boolean requiresTerminal;
|
||||
};
|
||||
|
||||
/*
|
||||
* The VFS service makes use of two distinct registries.
|
||||
*
|
||||
* The application registry holds information about applications (uniquely
|
||||
* identified by id), such as which MIME types and URI schemes they are
|
||||
* capable of handling, whether they run in a terminal, etc.
|
||||
*
|
||||
* The MIME registry holds information about MIME types, such as which
|
||||
* extensions map to a given MIME type. The MIME registry also stores the
|
||||
* id of the application selected to handle each MIME type.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(4d6b9f23-8682-41b3-bbff-937a958e6496)]
|
||||
interface nsIGnomeVFSService : nsISupports
|
||||
{
|
||||
/*** Application registry methods ***/
|
||||
|
||||
/* string keys */
|
||||
const long APP_KEY_COMMAND = 0;
|
||||
const long APP_KEY_NAME = 1;
|
||||
const long APP_KEY_SUPPORTED_URI_SCHEMES = 2; /* comma-separated list */
|
||||
const long APP_KEY_EXPECTS_URIS = 3; /* "true", "false", or "non-file" */
|
||||
|
||||
/* Set one of the above string keys for the given application id.
|
||||
'id' can be an arbitrary, unique string to identify the application. */
|
||||
void setAppStringKey(in AUTF8String id,
|
||||
in long key, /* see enums above */
|
||||
in AUTF8String value);
|
||||
|
||||
/* boolean keys */
|
||||
const long APP_KEY_CAN_OPEN_MULTIPLE = 4;
|
||||
const long APP_KEY_REQUIRES_TERMINAL = 5;
|
||||
|
||||
/* Set one of the above boolean keys for the given application id.
|
||||
'id' can be an arbitrary, unique string to identify the application. */
|
||||
void setAppBoolKey(in AUTF8String id,
|
||||
in long key,
|
||||
in boolean value);
|
||||
|
||||
|
||||
/* Add a MIME type to the list of types that the application can handle */
|
||||
void addMimeType(in AUTF8String id,
|
||||
in AUTF8String mimeType);
|
||||
|
||||
/* Commit application registry changes to disk. This must be called
|
||||
to save changes. */
|
||||
void syncAppRegistry();
|
||||
|
||||
|
||||
/*** MIME registry methods ***/
|
||||
|
||||
/* Obtain the MIME type registered for an extension. The extension
|
||||
should not include a leading dot. */
|
||||
AUTF8String getMimeTypeFromExtension(in AUTF8String extension);
|
||||
|
||||
/* Obtain the preferred application for opening a given MIME type */
|
||||
nsIGnomeVFSMimeApp getAppForMimeType(in AUTF8String mimeType);
|
||||
|
||||
/* Set the preferred application for opening a given MIME type */
|
||||
void setAppForMimeType(in AUTF8String mimeType,
|
||||
in AUTF8String id);
|
||||
|
||||
/* Obtain a description for the given MIME type */
|
||||
AUTF8String getDescriptionForMimeType(in AUTF8String mimeType);
|
||||
|
||||
/* Set the icon for a MIME type, which will be searched for by the shell
|
||||
using the icon theme search path. */
|
||||
void setIconForMimeType(in AUTF8String mimeType,
|
||||
in AUTF8String iconPath);
|
||||
|
||||
/*
|
||||
* Set the list of extensions for a given MIME type.
|
||||
* Should be passed a space separated list of extensions with no
|
||||
* dot, i.e. "gif jpg png".
|
||||
*/
|
||||
void setMimeExtensions(in AUTF8String mimeType,
|
||||
in AUTF8String extensionsList);
|
||||
|
||||
|
||||
/*** Misc. methods ***/
|
||||
|
||||
/* Open the given URI in the default application */
|
||||
void showURI(in nsIURI uri);
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_GNOMEVFSSERVICE_CONTRACTID "@mozilla.org/gnome-vfs-service;1"
|
||||
%}
|
Загрузка…
Ссылка в новой задаче