зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1433685 - Remove nsGConfService, r=glandium
Differential Revision: https://phabricator.services.mozilla.com/D26484 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
690951e993
Коммит
e1d04ebd15
|
@ -9,7 +9,6 @@ LOCAL_INCLUDES += [
|
||||||
'/xpcom/build'
|
'/xpcom/build'
|
||||||
]
|
]
|
||||||
|
|
||||||
XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
|
|
||||||
BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
|
BROWSER_CHROME_MANIFESTS += ['test/browser.ini']
|
||||||
MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
|
MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini']
|
||||||
|
|
||||||
|
|
|
@ -70,31 +70,7 @@ add_task(async function() {
|
||||||
gsettings.setString(GS_OPTION_KEY, prevOption);
|
gsettings.setString(GS_OPTION_KEY, prevOption);
|
||||||
gsettings.setBoolean(GS_DRAW_BG_KEY, prevDrawBG);
|
gsettings.setBoolean(GS_DRAW_BG_KEY, prevDrawBG);
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {}
|
||||||
// Fallback to GConf
|
|
||||||
var gconf = Cc["@mozilla.org/gnome-gconf-service;1"].
|
|
||||||
getService(Ci.nsIGConfService);
|
|
||||||
|
|
||||||
var prevImageKey = gconf.getString(DG_IMAGE_KEY);
|
|
||||||
var prevOptionKey = gconf.getString(DG_OPTION_KEY);
|
|
||||||
var prevDrawBgKey = gconf.getBool(DG_DRAW_BG_KEY);
|
|
||||||
|
|
||||||
checkWallpaper = function(position, expectedGConfPosition) {
|
|
||||||
shell.setDesktopBackground(image, position, "");
|
|
||||||
ok(wpFile.exists(), "Wallpaper was written to disk");
|
|
||||||
is(gconf.getString(DG_IMAGE_KEY), wpFile.path,
|
|
||||||
"Wallpaper file GConf key is correct");
|
|
||||||
is(gconf.getString(DG_OPTION_KEY), expectedGConfPosition,
|
|
||||||
"Wallpaper position GConf key is correct");
|
|
||||||
wpFile.remove(false);
|
|
||||||
};
|
|
||||||
|
|
||||||
restoreSettings = function() {
|
|
||||||
gconf.setString(DG_IMAGE_KEY, prevImageKey);
|
|
||||||
gconf.setString(DG_OPTION_KEY, prevOptionKey);
|
|
||||||
gconf.setBool(DG_DRAW_BG_KEY, prevDrawBgKey);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
checkWallpaper(Ci.nsIShellService.BACKGROUND_TILE, "wallpaper");
|
checkWallpaper(Ci.nsIShellService.BACKGROUND_TILE, "wallpaper");
|
||||||
checkWallpaper(Ci.nsIShellService.BACKGROUND_STRETCH, "stretched");
|
checkWallpaper(Ci.nsIShellService.BACKGROUND_STRETCH, "stretched");
|
||||||
|
|
|
@ -1,114 +0,0 @@
|
||||||
const GCONF_BG_COLOR_KEY = "/desktop/gnome/background/primary_color";
|
|
||||||
|
|
||||||
var gShell;
|
|
||||||
var gGConf;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts from a rgb numerical color valule (r << 16 | g << 8 | b)
|
|
||||||
* into a hex string in #RRGGBB format.
|
|
||||||
*/
|
|
||||||
function colorToHex(aColor) {
|
|
||||||
const rMask = 4294901760;
|
|
||||||
const gMask = 65280;
|
|
||||||
const bMask = 255;
|
|
||||||
|
|
||||||
var r = (aColor & rMask) >> 16;
|
|
||||||
var g = (aColor & gMask) >> 8;
|
|
||||||
var b = (aColor & bMask);
|
|
||||||
|
|
||||||
return "#" + [r, g, b].map(aInt =>
|
|
||||||
aInt.toString(16).replace(/^(.)$/, "0$1"))
|
|
||||||
.join("").toUpperCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a color string in #RRGGBB format to a rgb numerical color value
|
|
||||||
* (r << 16 | g << 8 | b).
|
|
||||||
*/
|
|
||||||
function hexToColor(aString) {
|
|
||||||
return parseInt(aString.substring(1, 3), 16) << 16 |
|
|
||||||
parseInt(aString.substring(3, 5), 16) << 8 |
|
|
||||||
parseInt(aString.substring(5, 7), 16);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks that setting the GConf background key to aGConfColor will
|
|
||||||
* result in the Shell component returning a background color equals
|
|
||||||
* to aExpectedShellColor in #RRGGBB format.
|
|
||||||
*/
|
|
||||||
function checkGConfToShellColor(aGConfColor, aExpectedShellColor) {
|
|
||||||
gGConf.setString(GCONF_BG_COLOR_KEY, aGConfColor);
|
|
||||||
var shellColor = colorToHex(gShell.desktopBackgroundColor);
|
|
||||||
|
|
||||||
Assert.equal(shellColor, aExpectedShellColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks that setting the background color (in #RRGGBB format) using the Shell
|
|
||||||
* component will result in having a GConf key for the background color set to
|
|
||||||
* aExpectedGConfColor.
|
|
||||||
*/
|
|
||||||
function checkShellToGConfColor(aShellColor, aExpectedGConfColor) {
|
|
||||||
gShell.desktopBackgroundColor = hexToColor(aShellColor);
|
|
||||||
var gconfColor = gGConf.getString(GCONF_BG_COLOR_KEY);
|
|
||||||
|
|
||||||
Assert.equal(gconfColor, aExpectedGConfColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
function run_test() {
|
|
||||||
// This test is Linux specific for now
|
|
||||||
if (!("@mozilla.org/gnome-gconf-service;1" in Cc))
|
|
||||||
return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
// If GSettings is available, then the GConf tests
|
|
||||||
// will fail
|
|
||||||
Cc["@mozilla.org/gsettings-service;1"].
|
|
||||||
getService(Ci.nsIGSettingsService).
|
|
||||||
getCollectionForSchema("org.gnome.desktop.background");
|
|
||||||
return;
|
|
||||||
} catch (e) { }
|
|
||||||
|
|
||||||
gGConf = Cc["@mozilla.org/gnome-gconf-service;1"].
|
|
||||||
getService(Ci.nsIGConfService);
|
|
||||||
|
|
||||||
gShell = Cc["@mozilla.org/browser/shell-service;1"].
|
|
||||||
getService(Ci.nsIShellService);
|
|
||||||
|
|
||||||
// Save the original background color so that we can restore it
|
|
||||||
// after the test.
|
|
||||||
var origGConfColor = gGConf.getString(GCONF_BG_COLOR_KEY);
|
|
||||||
|
|
||||||
try {
|
|
||||||
checkGConfToShellColor("#000", "#000000");
|
|
||||||
checkGConfToShellColor("#00f", "#0000FF");
|
|
||||||
checkGConfToShellColor("#b2f", "#BB22FF");
|
|
||||||
checkGConfToShellColor("#fff", "#FFFFFF");
|
|
||||||
|
|
||||||
checkGConfToShellColor("#000000", "#000000");
|
|
||||||
checkGConfToShellColor("#0000ff", "#0000FF");
|
|
||||||
checkGConfToShellColor("#b002f0", "#B002F0");
|
|
||||||
checkGConfToShellColor("#ffffff", "#FFFFFF");
|
|
||||||
|
|
||||||
checkGConfToShellColor("#000000000", "#000000");
|
|
||||||
checkGConfToShellColor("#00f00f00f", "#000000");
|
|
||||||
checkGConfToShellColor("#aaabbbccc", "#AABBCC");
|
|
||||||
checkGConfToShellColor("#fffffffff", "#FFFFFF");
|
|
||||||
|
|
||||||
checkGConfToShellColor("#000000000000", "#000000");
|
|
||||||
checkGConfToShellColor("#000f000f000f", "#000000");
|
|
||||||
checkGConfToShellColor("#00ff00ff00ff", "#000000");
|
|
||||||
checkGConfToShellColor("#aaaabbbbcccc", "#AABBCC");
|
|
||||||
checkGConfToShellColor("#111122223333", "#112233");
|
|
||||||
checkGConfToShellColor("#ffffffffffff", "#FFFFFF");
|
|
||||||
|
|
||||||
checkShellToGConfColor("#000000", "#000000000000");
|
|
||||||
checkShellToGConfColor("#0000FF", "#00000000ffff");
|
|
||||||
checkShellToGConfColor("#FFFFFF", "#ffffffffffff");
|
|
||||||
checkShellToGConfColor("#0A0B0C", "#0a0a0b0b0c0c");
|
|
||||||
checkShellToGConfColor("#A0B0C0", "#a0a0b0b0c0c0");
|
|
||||||
checkShellToGConfColor("#AABBCC", "#aaaabbbbcccc");
|
|
||||||
} finally {
|
|
||||||
gGConf.setString(GCONF_BG_COLOR_KEY, origGConfColor);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
[DEFAULT]
|
|
||||||
head =
|
|
||||||
firefox-appdir = browser
|
|
||||||
skip-if = toolkit == 'android'
|
|
||||||
|
|
||||||
[test_421977.js]
|
|
|
@ -61,7 +61,6 @@ GTK2_VERSION=2.18.0
|
||||||
GTK3_VERSION=3.4.0
|
GTK3_VERSION=3.4.0
|
||||||
GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4
|
GDK_VERSION_MAX_ALLOWED=GDK_VERSION_3_4
|
||||||
W32API_VERSION=3.14
|
W32API_VERSION=3.14
|
||||||
GCONF_VERSION=1.2.1
|
|
||||||
STARTUP_NOTIFICATION_VERSION=0.8
|
STARTUP_NOTIFICATION_VERSION=0.8
|
||||||
DBUS_VERSION=0.60
|
DBUS_VERSION=0.60
|
||||||
SQLITE_VERSION=3.27.2
|
SQLITE_VERSION=3.27.2
|
||||||
|
@ -1908,47 +1907,6 @@ fi
|
||||||
AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
|
AC_DEFINE_UNQUOTED(MOZ_DISTRIBUTION_ID,"$MOZ_DISTRIBUTION_ID")
|
||||||
AC_SUBST(MOZ_DISTRIBUTION_ID)
|
AC_SUBST(MOZ_DISTRIBUTION_ID)
|
||||||
|
|
||||||
dnl ========================================================
|
|
||||||
dnl = GConf support module
|
|
||||||
dnl ========================================================
|
|
||||||
|
|
||||||
if test "$MOZ_X11"
|
|
||||||
then
|
|
||||||
if test "$MOZ_ENABLE_GTK"
|
|
||||||
then
|
|
||||||
MOZ_ENABLE_GCONF=1
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl ========================================================
|
|
||||||
dnl = GConf support module
|
|
||||||
dnl ========================================================
|
|
||||||
MOZ_ARG_DISABLE_BOOL(gconf,
|
|
||||||
[ --disable-gconf Disable Gconf support ],
|
|
||||||
MOZ_ENABLE_GCONF=,
|
|
||||||
MOZ_ENABLE_GCONF=1)
|
|
||||||
|
|
||||||
if test "$MOZ_ENABLE_GCONF"
|
|
||||||
then
|
|
||||||
PKG_CHECK_MODULES(MOZ_GCONF, gconf-2.0 >= $GCONF_VERSION gobject-2.0 ,[
|
|
||||||
MOZ_GCONF_LIBS=`$PKG_CONFIG --libs gobject-2.0`
|
|
||||||
MOZ_ENABLE_GCONF=1
|
|
||||||
],[
|
|
||||||
if test -n "$MOZ_ENABLE_GCONF";
|
|
||||||
then
|
|
||||||
AC_MSG_ERROR([* * * Could not find gconf-2.0 ])
|
|
||||||
else
|
|
||||||
AC_MSG_WARN([Many automated tests will fail with --disable-gconf. See bug 1167201.])
|
|
||||||
fi
|
|
||||||
])
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "$MOZ_ENABLE_GCONF"; then
|
|
||||||
AC_DEFINE(MOZ_ENABLE_GCONF)
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_SUBST(MOZ_ENABLE_GCONF)
|
|
||||||
fi
|
|
||||||
|
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
dnl = libproxy support
|
dnl = libproxy support
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
|
|
|
@ -107,7 +107,6 @@ static gboolean ReportCompleted(gpointer success) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MOZ_ENABLE_GCONF
|
|
||||||
# define HTTP_PROXY_DIR "/system/http_proxy"
|
# define HTTP_PROXY_DIR "/system/http_proxy"
|
||||||
|
|
||||||
void LoadProxyinfo() {
|
void LoadProxyinfo() {
|
||||||
|
@ -179,7 +178,6 @@ void LoadProxyinfo() {
|
||||||
|
|
||||||
// Don't dlclose gconfLib as libORBit-2 uses atexit().
|
// Don't dlclose gconfLib as libORBit-2 uses atexit().
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
gpointer SendThread(gpointer args) {
|
gpointer SendThread(gpointer args) {
|
||||||
string response, error;
|
string response, error;
|
||||||
|
|
|
@ -95,9 +95,7 @@ void SaveSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendReport() {
|
void SendReport() {
|
||||||
#ifdef MOZ_ENABLE_GCONF
|
|
||||||
LoadProxyinfo();
|
LoadProxyinfo();
|
||||||
#endif
|
|
||||||
|
|
||||||
// spawn a thread to do the sending
|
// spawn a thread to do the sending
|
||||||
gSendThreadID = g_thread_create(SendThread, nullptr, TRUE, nullptr);
|
gSendThreadID = g_thread_create(SendThread, nullptr, TRUE, nullptr);
|
||||||
|
|
|
@ -32,14 +32,3 @@ Classes = [
|
||||||
'init_method': 'Init',
|
'init_method': 'Init',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
if defined('MOZ_ENABLE_GCONF'):
|
|
||||||
Classes += [
|
|
||||||
{
|
|
||||||
'cid': '{d96d5985-a13a-4bdc-9386-ef348d7a97a1}',
|
|
||||||
'contract_ids': ['@mozilla.org/gnome-gconf-service;1'],
|
|
||||||
'type': 'nsGConfService',
|
|
||||||
'headers': ['/toolkit/system/gnome/nsGConfService.h'],
|
|
||||||
'init_method': 'Init',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
|
@ -13,11 +13,6 @@ SOURCES += [
|
||||||
'nsSystemAlertsService.cpp',
|
'nsSystemAlertsService.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
if CONFIG['MOZ_ENABLE_GCONF']:
|
|
||||||
SOURCES += [
|
|
||||||
'nsGConfService.cpp',
|
|
||||||
]
|
|
||||||
|
|
||||||
SOURCES += [
|
SOURCES += [
|
||||||
'nsGIOService.cpp',
|
'nsGIOService.cpp',
|
||||||
'nsGSettingsService.cpp',
|
'nsGSettingsService.cpp',
|
||||||
|
@ -33,7 +28,6 @@ LOCAL_INCLUDES += [
|
||||||
'/toolkit/components/build/',
|
'/toolkit/components/build/',
|
||||||
]
|
]
|
||||||
|
|
||||||
CXXFLAGS += CONFIG['MOZ_GCONF_CFLAGS']
|
|
||||||
CXXFLAGS += CONFIG['GLIB_CFLAGS']
|
CXXFLAGS += CONFIG['GLIB_CFLAGS']
|
||||||
CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
|
CXXFLAGS += CONFIG['MOZ_DBUS_GLIB_CFLAGS']
|
||||||
CXXFLAGS += CONFIG['TK_CFLAGS']
|
CXXFLAGS += CONFIG['TK_CFLAGS']
|
||||||
|
|
|
@ -1,296 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#include "mozilla/ArrayUtils.h"
|
|
||||||
#include "nsGConfService.h"
|
|
||||||
#include "nsString.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nsComponentManagerUtils.h"
|
|
||||||
#include "nsISupportsPrimitives.h"
|
|
||||||
#include "nsIMutableArray.h"
|
|
||||||
#include "nsXULAppAPI.h"
|
|
||||||
#include "prlink.h"
|
|
||||||
|
|
||||||
#include <gconf/gconf-client.h>
|
|
||||||
|
|
||||||
using namespace mozilla;
|
|
||||||
|
|
||||||
#define GCONF_FUNCTIONS \
|
|
||||||
FUNC(gconf_client_get_default, GConfClient *, (void)) \
|
|
||||||
FUNC(gconf_client_get_bool, gboolean, \
|
|
||||||
(GConfClient *, const gchar *, GError **)) \
|
|
||||||
FUNC(gconf_client_get_string, gchar *, \
|
|
||||||
(GConfClient *, const gchar *, GError **)) \
|
|
||||||
FUNC(gconf_client_get_int, gint, (GConfClient *, const gchar *, GError **)) \
|
|
||||||
FUNC(gconf_client_get_float, gdouble, \
|
|
||||||
(GConfClient *, const gchar *, GError **)) \
|
|
||||||
FUNC(gconf_client_get_list, GSList *, \
|
|
||||||
(GConfClient *, const gchar *, GConfValueType, GError **)) \
|
|
||||||
FUNC(gconf_client_set_bool, gboolean, \
|
|
||||||
(GConfClient *, const gchar *, gboolean, GError **)) \
|
|
||||||
FUNC(gconf_client_set_string, gboolean, \
|
|
||||||
(GConfClient *, const gchar *, const gchar *, GError **)) \
|
|
||||||
FUNC(gconf_client_set_int, gboolean, \
|
|
||||||
(GConfClient *, const gchar *, gint, GError **)) \
|
|
||||||
FUNC(gconf_client_set_float, gboolean, \
|
|
||||||
(GConfClient *, const gchar *, gdouble, GError **)) \
|
|
||||||
FUNC(gconf_client_unset, gboolean, (GConfClient *, const gchar *, GError **))
|
|
||||||
|
|
||||||
#define FUNC(name, type, params) \
|
|
||||||
typedef type(*_##name##_fn) params; \
|
|
||||||
static _##name##_fn _##name;
|
|
||||||
|
|
||||||
GCONF_FUNCTIONS
|
|
||||||
|
|
||||||
#undef FUNC
|
|
||||||
|
|
||||||
#define gconf_client_get_default _gconf_client_get_default
|
|
||||||
#define gconf_client_get_bool _gconf_client_get_bool
|
|
||||||
#define gconf_client_get_string _gconf_client_get_string
|
|
||||||
#define gconf_client_get_int _gconf_client_get_int
|
|
||||||
#define gconf_client_get_float _gconf_client_get_float
|
|
||||||
#define gconf_client_get_list _gconf_client_get_list
|
|
||||||
#define gconf_client_set_bool _gconf_client_set_bool
|
|
||||||
#define gconf_client_set_string _gconf_client_set_string
|
|
||||||
#define gconf_client_set_int _gconf_client_set_int
|
|
||||||
#define gconf_client_set_float _gconf_client_set_float
|
|
||||||
#define gconf_client_unset _gconf_client_unset
|
|
||||||
|
|
||||||
static PRLibrary *gconfLib = nullptr;
|
|
||||||
|
|
||||||
typedef void (*nsGConfFunc)();
|
|
||||||
struct nsGConfDynamicFunction {
|
|
||||||
const char *functionName;
|
|
||||||
nsGConfFunc *function;
|
|
||||||
};
|
|
||||||
|
|
||||||
nsGConfService::~nsGConfService() {
|
|
||||||
if (mClient) g_object_unref(mClient);
|
|
||||||
|
|
||||||
// We don't unload gconf here because liborbit uses atexit(). In addition to
|
|
||||||
// this, it's not a good idea to unload any gobject based library, as it
|
|
||||||
// leaves types registered in glib's type system
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult nsGConfService::Init() {
|
|
||||||
#define FUNC(name, type, params) {#name, (nsGConfFunc *)&_##name},
|
|
||||||
static const nsGConfDynamicFunction kGConfSymbols[] = {GCONF_FUNCTIONS};
|
|
||||||
#undef FUNC
|
|
||||||
|
|
||||||
if (NS_WARN_IF(XRE_IsContentProcess())) {
|
|
||||||
return NS_ERROR_SERVICE_NOT_AVAILABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!gconfLib) {
|
|
||||||
gconfLib = PR_LoadLibrary("libgconf-2.so.4");
|
|
||||||
if (!gconfLib) return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto GConfSymbol : kGConfSymbols) {
|
|
||||||
*GConfSymbol.function =
|
|
||||||
PR_FindFunctionSymbol(gconfLib, GConfSymbol.functionName);
|
|
||||||
if (!*GConfSymbol.function) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mClient = gconf_client_get_default();
|
|
||||||
return mClient ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsGConfService, nsIGConfService)
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGConfService::GetBool(const nsACString &aKey, bool *aResult) {
|
|
||||||
GError *error = nullptr;
|
|
||||||
*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 = nullptr;
|
|
||||||
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, int32_t *aResult) {
|
|
||||||
GError *error = nullptr;
|
|
||||||
*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 = nullptr;
|
|
||||||
*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::GetStringList(const nsACString &aKey, nsIArray **aResult) {
|
|
||||||
nsCOMPtr<nsIMutableArray> items(do_CreateInstance(NS_ARRAY_CONTRACTID));
|
|
||||||
if (!items) return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
|
|
||||||
GError *error = nullptr;
|
|
||||||
GSList *list = gconf_client_get_list(mClient, PromiseFlatCString(aKey).get(),
|
|
||||||
GCONF_VALUE_STRING, &error);
|
|
||||||
if (error) {
|
|
||||||
g_error_free(error);
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (GSList *l = list; l; l = l->next) {
|
|
||||||
nsCOMPtr<nsISupportsString> obj(
|
|
||||||
do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
|
|
||||||
if (!obj) {
|
|
||||||
g_slist_free(list);
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
obj->SetData(NS_ConvertUTF8toUTF16((const char *)l->data));
|
|
||||||
items->AppendElement(obj);
|
|
||||||
g_free(l->data);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_free(list);
|
|
||||||
items.forget(aResult);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGConfService::SetBool(const nsACString &aKey, bool aValue) {
|
|
||||||
bool res = gconf_client_set_bool(mClient, PromiseFlatCString(aKey).get(),
|
|
||||||
aValue, nullptr);
|
|
||||||
|
|
||||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGConfService::SetString(const nsACString &aKey, const nsACString &aValue) {
|
|
||||||
bool res = gconf_client_set_string(mClient, PromiseFlatCString(aKey).get(),
|
|
||||||
PromiseFlatCString(aValue).get(), nullptr);
|
|
||||||
|
|
||||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGConfService::SetInt(const nsACString &aKey, int32_t aValue) {
|
|
||||||
bool res = gconf_client_set_int(mClient, PromiseFlatCString(aKey).get(),
|
|
||||||
aValue, nullptr);
|
|
||||||
|
|
||||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGConfService::SetFloat(const nsACString &aKey, float aValue) {
|
|
||||||
bool res = gconf_client_set_float(mClient, PromiseFlatCString(aKey).get(),
|
|
||||||
aValue, nullptr);
|
|
||||||
|
|
||||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGConfService::GetAppForProtocol(const nsACString &aScheme, bool *aEnabled,
|
|
||||||
nsACString &aHandler) {
|
|
||||||
nsAutoCString key("/desktop/gnome/url-handlers/");
|
|
||||||
key.Append(aScheme);
|
|
||||||
key.AppendLiteral("/command");
|
|
||||||
|
|
||||||
GError *err = nullptr;
|
|
||||||
gchar *command = gconf_client_get_string(mClient, key.get(), &err);
|
|
||||||
if (!err && command) {
|
|
||||||
key.ReplaceLiteral(key.Length() - 7, 7, "enabled");
|
|
||||||
*aEnabled = gconf_client_get_bool(mClient, key.get(), &err);
|
|
||||||
} else {
|
|
||||||
*aEnabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
aHandler.Assign(command);
|
|
||||||
g_free(command);
|
|
||||||
|
|
||||||
if (err) {
|
|
||||||
g_error_free(err);
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGConfService::HandlerRequiresTerminal(const nsACString &aScheme,
|
|
||||||
bool *aResult) {
|
|
||||||
nsAutoCString key("/desktop/gnome/url-handlers/");
|
|
||||||
key.Append(aScheme);
|
|
||||||
key.AppendLiteral("/requires_terminal");
|
|
||||||
|
|
||||||
GError *err = nullptr;
|
|
||||||
*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) {
|
|
||||||
nsAutoCString key("/desktop/gnome/url-handlers/");
|
|
||||||
key.Append(aScheme);
|
|
||||||
key.AppendLiteral("/command");
|
|
||||||
|
|
||||||
bool res = gconf_client_set_string(
|
|
||||||
mClient, key.get(), PromiseFlatCString(aCommand).get(), nullptr);
|
|
||||||
if (res) {
|
|
||||||
key.ReplaceLiteral(key.Length() - 7, 7, "enabled");
|
|
||||||
res = gconf_client_set_bool(mClient, key.get(), true, nullptr);
|
|
||||||
if (res) {
|
|
||||||
key.ReplaceLiteral(key.Length() - 7, 7, "needs_terminal");
|
|
||||||
res = gconf_client_set_bool(mClient, key.get(), false, nullptr);
|
|
||||||
if (res) {
|
|
||||||
key.ReplaceLiteral(key.Length() - 14, 14, "command-id");
|
|
||||||
res = gconf_client_unset(mClient, key.get(), nullptr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res ? NS_OK : NS_ERROR_FAILURE;
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#ifndef nsGConfService_h_
|
|
||||||
#define nsGConfService_h_
|
|
||||||
|
|
||||||
#include "nsIGConfService.h"
|
|
||||||
#include "mozilla/Attributes.h"
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
struct _GConfClient;
|
|
||||||
typedef struct _GConfClient GConfClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
class nsGConfService final : public nsIGConfService {
|
|
||||||
public:
|
|
||||||
NS_DECL_ISUPPORTS
|
|
||||||
NS_DECL_NSIGCONFSERVICE
|
|
||||||
|
|
||||||
nsGConfService() : mClient(nullptr) {}
|
|
||||||
nsresult Init();
|
|
||||||
|
|
||||||
private:
|
|
||||||
~nsGConfService();
|
|
||||||
|
|
||||||
GConfClient *mClient;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -72,7 +72,6 @@
|
||||||
#include "mozilla/Likely.h"
|
#include "mozilla/Likely.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "nsIPrefService.h"
|
#include "nsIPrefService.h"
|
||||||
#include "nsIGConfService.h"
|
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsGfxCIID.h"
|
#include "nsGfxCIID.h"
|
||||||
#include "nsGtkUtils.h"
|
#include "nsGtkUtils.h"
|
||||||
|
|
|
@ -8,7 +8,6 @@ XPIDL_SOURCES += [
|
||||||
'nsIBlocklistService.idl',
|
'nsIBlocklistService.idl',
|
||||||
'nsICrashReporter.idl',
|
'nsICrashReporter.idl',
|
||||||
'nsIDeviceSensors.idl',
|
'nsIDeviceSensors.idl',
|
||||||
'nsIGConfService.idl',
|
|
||||||
'nsIGeolocationProvider.idl',
|
'nsIGeolocationProvider.idl',
|
||||||
'nsIGIOService.idl',
|
'nsIGIOService.idl',
|
||||||
'nsIGSettingsService.idl',
|
'nsIGSettingsService.idl',
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#include "nsISupports.idl"
|
|
||||||
|
|
||||||
interface nsIArray;
|
|
||||||
|
|
||||||
[scriptable, uuid(5009acae-6973-48c3-b6d6-52c692cc5d9d)]
|
|
||||||
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);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use this to return any list items in GConf, this will return
|
|
||||||
* an array of UTF16 nsISupportsString's.
|
|
||||||
*/
|
|
||||||
nsIArray getStringList(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"
|
|
||||||
%}
|
|
Загрузка…
Ссылка в новой задаче