summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Michael Brummer <jan.brummer@tabos.org>2023-03-30 07:39:53 +0200
committerJan-Michael Brummer <jan.brummer@tabos.org>2023-03-30 11:44:46 +0200
commitd1107667da6da04395ff72a78839cf07a2fe1aa9 (patch)
tree50f2b0718c47f87133b33d3e13a49c5c08c9631b
parent3604dc5aa5d623740263dd077f5b7d209cf1d486 (diff)
downloadlibproxy-git-d1107667da6da04395ff72a78839cf07a2fe1aa9.tar.gz
Remove libpeas support
As we no longer have further dependencies like glib for accessing the standard linux configurations and the other are platform specific. Let's remove peas all together. Plugins are now built-in.
-rw-r--r--.github/workflows/build.yml4
-rw-r--r--.github/workflows/coverity.yml1
-rw-r--r--docs/build-steps.md6
-rw-r--r--docs/px.toml.in6
-rw-r--r--meson.build6
-rw-r--r--meson_options.txt14
-rw-r--r--src/backend/meson.build16
-rw-r--r--src/backend/plugins/config-env/config-env.c13
-rw-r--r--src/backend/plugins/config-env/config-env.plugin3
-rw-r--r--src/backend/plugins/config-env/meson.build29
-rw-r--r--src/backend/plugins/config-gnome/config-gnome.c16
-rw-r--r--src/backend/plugins/config-gnome/config-gnome.plugin3
-rw-r--r--src/backend/plugins/config-gnome/meson.build29
-rw-r--r--src/backend/plugins/config-kde/config-kde.c16
-rw-r--r--src/backend/plugins/config-kde/config-kde.plugin3
-rw-r--r--src/backend/plugins/config-kde/meson.build29
-rw-r--r--src/backend/plugins/config-osx/config-osx.c18
-rw-r--r--src/backend/plugins/config-osx/config-osx.h5
-rw-r--r--src/backend/plugins/config-osx/config-osx.plugin3
-rw-r--r--src/backend/plugins/config-osx/meson.build39
-rw-r--r--src/backend/plugins/config-sysconfig/config-sysconfig.c13
-rw-r--r--src/backend/plugins/config-sysconfig/config-sysconfig.plugin3
-rw-r--r--src/backend/plugins/config-sysconfig/meson.build30
-rw-r--r--src/backend/plugins/config-windows/config-windows.c14
-rw-r--r--src/backend/plugins/config-windows/config-windows.plugin3
-rw-r--r--src/backend/plugins/config-windows/meson.build36
-rw-r--r--src/backend/plugins/pacrunner-duktape/meson.build32
-rw-r--r--src/backend/plugins/pacrunner-duktape/pacrunner-duktape.c11
-rw-r--r--src/backend/plugins/pacrunner-duktape/pacrunner-duktape.plugin3
-rw-r--r--src/backend/px-manager.c241
-rw-r--r--src/backend/px-plugin-config.h8
-rw-r--r--tests/config-gnome-test.c2
-rw-r--r--tests/config-kde-test.c2
-rw-r--r--tests/config-osx-test.c52
-rw-r--r--tests/config-windows-test.c52
-rw-r--r--tests/meson.build24
-rw-r--r--tests/px-manager-helper.c5
37 files changed, 354 insertions, 436 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 431ff2d..f75c17f 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -18,7 +18,6 @@ jobs:
meson \
gcovr \
gi-docgen \
- libpeas-dev \
gsettings-desktop-schemas-dev \
libcurl4-openssl-dev \
valac
@@ -48,7 +47,7 @@ jobs:
- name: Setup
run: |
pip install meson ninja
- brew install libsoup icu4c gobject-introspection duktape gcovr gi-docgen libpeas curl vala
+ brew install libsoup icu4c gobject-introspection duktape gcovr gi-docgen curl vala
echo 'PKG_CONFIG_PATH=/usr/local/opt/icu4c/lib/pkgconfig:/usr/local/opt/gi-docgen/lib/pkgconfig' >> $GITHUB_ENV
- name: Build and Test
run: |
@@ -79,7 +78,6 @@ jobs:
mingw-w64-x86_64-duktape
mingw-w64-x86_64-gi-docgen
mingw-w64-x86_64-libsoup3
- mingw-w64-x86_64-libpeas
mingw-w64-x86_64-curl
mingw-w64-x86_64-vala
- uses: actions/checkout@v3
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 15f1570..b3a9e9b 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -36,7 +36,6 @@ jobs:
meson \
gcovr \
gi-docgen \
- libpeas-dev \
gsettings-desktop-schemas-dev \
libcurl4-openssl-dev \
valac
diff --git a/docs/build-steps.md b/docs/build-steps.md
index f0ac5df..2590c4e 100644
--- a/docs/build-steps.md
+++ b/docs/build-steps.md
@@ -8,7 +8,7 @@ Slug: building
### Dependencies
```
-sudo dnf install glib2-devel duktape-devel libsoup3-devel meson gcovr gi-docgen libpeas-devel libcurl-devel vala gsettings-desktop-schemas-devel gobject-introspection-devel
+sudo dnf install glib2-devel duktape-devel libsoup3-devel meson gcovr gi-docgen libcurl-devel vala gsettings-desktop-schemas-devel gobject-introspection-devel
```
### Build Setup
@@ -35,7 +35,7 @@ ninja -C build install
```
pip install meson ninja
-brew install libsoup icu4c gobject-introspection duktape gcovr gi-docgen libpeas curl vala
+brew install libsoup icu4c gobject-introspection duktape gcovr gi-docgen curl vala
```
### Build Setup
@@ -61,7 +61,7 @@ ninja -C build install
### Dependencies
```
-pacman -S base-devel git mingw-w64-x86_64-toolchain mingw-w64-x86_64-ccache mingw-w64-x86_64-pkg-config mingw-w64-x86_64-gobject-introspection mingw-w64-x86_64-python-gobject mingw-w64-x86_64-meson mingw-w64-x86_64-glib mingw-w64-x86_64-duktape mingw-w64-x86_64-gi-docgen mingw-w64-x86_64-libsoup3 mingw-w64-x86_64-libpeas mingw-w64-x86_64-curl mingw-w64-x86_64-vala
+pacman -S base-devel git mingw-w64-x86_64-toolchain mingw-w64-x86_64-ccache mingw-w64-x86_64-pkg-config mingw-w64-x86_64-gobject-introspection mingw-w64-x86_64-python-gobject mingw-w64-x86_64-meson mingw-w64-x86_64-glib mingw-w64-x86_64-duktape mingw-w64-x86_64-gi-docgen mingw-w64-x86_64-libsoup3 mingw-w64-x86_64-curl mingw-w64-x86_64-vala
```
### Build Setup
diff --git a/docs/px.toml.in b/docs/px.toml.in
index 2476126..8cab536 100644
--- a/docs/px.toml.in
+++ b/docs/px.toml.in
@@ -11,7 +11,6 @@ dependencies = [
"GObject-2.0",
"Gio-2.0",
"GLib-2.0",
- "Peas-1.0",
"Soup-3.0",
"curl-1.0",
]
@@ -33,11 +32,6 @@ name = "GLib"
description = "The base utility library"
docs_url = "https://developer.gnome.org/glib/stable"
-[dependencies."Peas-1.0"]
-name = "Peas"
-description = "GObject-based plugins engine"
-docs_url = "https://gnome.pages.gitlab.gnome.org/libpeas/libpeas-1.0/"
-
[dependencies."Soup-3.0"]
name = "Soup"
description = "HTTP client/server library for GNOME"
diff --git a/meson.build b/meson.build
index 3543d12..f209f60 100644
--- a/meson.build
+++ b/meson.build
@@ -13,7 +13,6 @@ root_dir = include_directories('.')
px_prefix = get_option('prefix')
datadir = get_option('datadir')
px_libdir = join_paths(px_prefix, get_option('libdir'))
-px_plugins_dir = join_paths(px_libdir, meson.project_name().to_lower(), 'plugins')
girdir = get_option('datadir') / 'gir-1.0'
typelibdir = get_option('libdir') / 'girepository-1.0'
vapidir = get_option('datadir') / 'vala' / 'vapi'
@@ -96,17 +95,17 @@ if host_machine.system() == 'windows'
_platforms = ['windows']
endif
with_platform_windows = _platforms.contains('windows')
+with_platform_darwin = ['darwin', 'ios'].contains(host_system)
module_suffix = []
# Keep the autotools convention for shared module suffix because GModule
# depends on it.
-if ['darwin', 'ios'].contains(host_system)
+if with_platform_darwin
module_suffix = 'so'
endif
glib_dep = dependency('glib-2.0', version: '>= 2.71.3')
gio_dep = dependency('gio-2.0', version: '>= 2.71.3')
-peas_dep = dependency('libpeas-1.0')
soup_dep = dependency('libsoup-3.0', required: get_option('tests'))
curl_dep = dependency('libcurl', required: get_option('curl'))
ws2_32_dep = cc.find_library('ws2_32', required : with_platform_windows)
@@ -114,7 +113,6 @@ gsettings_desktop_schema = dependency('gsettings-desktop-schemas', required: get
config_h = configuration_data()
config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
-config_h.set_quoted('PX_PLUGINS_DIR', px_plugins_dir)
config_h.set('HAVE_CURL', get_option('curl'))
configure_file(output: 'config.h', configuration: config_h)
diff --git a/meson_options.txt b/meson_options.txt
index b04ed96..9e3e9bd 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -16,49 +16,49 @@ option(
'config-env',
type: 'boolean',
value: true,
- description: 'Whether to build plugin for environment configuration'
+ description: 'Whether to build support for environment configuration'
)
option(
'config-gnome',
type: 'boolean',
value: true,
- description: 'Whether to build plugin for GNOME configuration'
+ description: 'Whether to build support for GNOME configuration'
)
option(
'config-windows',
type: 'boolean',
value: true,
- description: 'Whether to build plugin for Windows configuration'
+ description: 'Whether to build support for Windows configuration'
)
option(
'config-sysconfig',
type: 'boolean',
value: true,
- description: 'Whether to build plugin for sysconfig configuration'
+ description: 'Whether to build support for sysconfig configuration'
)
option(
'config-osx',
type: 'boolean',
value: true,
- description: 'Whether to build plugin for OS X configuration'
+ description: 'Whether to build support for OS X configuration'
)
option(
'config-kde',
type: 'boolean',
value: true,
- description: 'Whether to build plugin for KDE System Settings'
+ description: 'Whether to build support for KDE System Settings'
)
option(
'pacrunner-duktape',
type: 'boolean',
value: true,
- description: 'Whether to build plugin for PAC Runner Duktape'
+ description: 'Whether to build support for PAC Runner Duktape'
)
option(
diff --git a/src/backend/meson.build b/src/backend/meson.build
index b25453a..c8be5da 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -1,3 +1,13 @@
+backend_config_h = configuration_data()
+backend_config_h.set('HAVE_CONFIG_ENV', get_option('config-env'))
+backend_config_h.set('HAVE_CONFIG_GNOME', get_option('config-gnome'))
+backend_config_h.set('HAVE_CONFIG_KDE', get_option('config-kde'))
+backend_config_h.set('HAVE_CONFIG_OSX', get_option('config-osx') and with_platform_darwin)
+backend_config_h.set('HAVE_CONFIG_SYSCONFIG', get_option('config-sysconfig'))
+backend_config_h.set('HAVE_CONFIG_WINDOWS', get_option('config-windows') and with_platform_windows)
+backend_config_h.set('HAVE_PACRUNNER_DUKTAPE', get_option('pacrunner-duktape'))
+configure_file(output: 'px-backend-config.h', configuration: backend_config_h)
+
px_backend_sources = [
'px-manager.c',
'px-manager.h',
@@ -11,7 +21,7 @@ px_backend_deps = [
curl_dep,
gio_dep,
glib_dep,
- peas_dep,
+ ws2_32_dep,
]
px_backend_c_args = [
@@ -20,6 +30,8 @@ px_backend_c_args = [
px_backend_inc = include_directories('.')
+subdir('plugins')
+
px_backend = shared_library(
'pxbackend-@0@'.format(api_version),
px_backend_sources,
@@ -33,5 +45,3 @@ px_backend_dep = declare_dependency(
link_with: px_backend,
dependencies: px_backend_deps
)
-
-subdir('plugins') \ No newline at end of file
diff --git a/src/backend/plugins/config-env/config-env.c b/src/backend/plugins/config-env/config-env.c
index d7f5a73..6a326e0 100644
--- a/src/backend/plugins/config-env/config-env.c
+++ b/src/backend/plugins/config-env/config-env.c
@@ -19,7 +19,7 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#include <libpeas/peas.h>
+#include <gio/gio.h>
#include "config-env.h"
@@ -27,7 +27,6 @@
#include "px-plugin-config.h"
static void px_config_iface_init (PxConfigInterface *iface);
-G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
struct _PxConfigEnv {
GObject parent_instance;
@@ -161,14 +160,8 @@ px_config_env_get_config (PxConfig *config,
static void
px_config_iface_init (PxConfigInterface *iface)
{
+ iface->name = "config-env";
+ iface->priority = PX_CONFIG_PRIORITY_FIRST;
iface->is_available = px_config_env_is_available;
iface->get_config = px_config_env_get_config;
}
-
-G_MODULE_EXPORT void
-peas_register_types (PeasObjectModule *module)
-{
- peas_object_module_register_extension_type (module,
- PX_TYPE_CONFIG,
- PX_CONFIG_TYPE_ENV);
-}
diff --git a/src/backend/plugins/config-env/config-env.plugin b/src/backend/plugins/config-env/config-env.plugin
deleted file mode 100644
index 2dfbdf3..0000000
--- a/src/backend/plugins/config-env/config-env.plugin
+++ /dev/null
@@ -1,3 +0,0 @@
-[Plugin]
-Module=config-env
-Name=Environment Variables \ No newline at end of file
diff --git a/src/backend/plugins/config-env/meson.build b/src/backend/plugins/config-env/meson.build
index 471ecc0..00f3cc3 100644
--- a/src/backend/plugins/config-env/meson.build
+++ b/src/backend/plugins/config-env/meson.build
@@ -2,33 +2,8 @@ plugin_name = 'config-env'
if get_option(plugin_name)
-plugin_src = [
- '@0@.c'.format(plugin_name),
+px_backend_sources += [
+ 'plugins/@0@/@0@.c'.format(plugin_name),
]
-plugin_data = [
- '@0@.plugin'.format(plugin_name),
-]
-
-plugin_lib = shared_module(
- plugin_name,
- sources: plugin_src,
- include_directories: px_backend_inc,
- c_args: px_backend_c_args,
- dependencies: [px_backend_dep],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
- name_suffix: module_suffix,
-)
-
-# Starting with Meson 0.64 this can be replaced with fs.copyfile
-custom_target(
- '@0@-data'.format(plugin_name),
- input: plugin_data,
- output: plugin_data,
- command: ['cp', '@INPUT@', '@OUTDIR@'],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
-)
-
endif \ No newline at end of file
diff --git a/src/backend/plugins/config-gnome/config-gnome.c b/src/backend/plugins/config-gnome/config-gnome.c
index 426769c..29cb34a 100644
--- a/src/backend/plugins/config-gnome/config-gnome.c
+++ b/src/backend/plugins/config-gnome/config-gnome.c
@@ -19,7 +19,7 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#include <libpeas/peas.h>
+#include <gio/gio.h>
#include "config-gnome.h"
@@ -43,7 +43,6 @@ typedef enum {
} GnomeProxyMode;
static void px_config_iface_init (PxConfigInterface *iface);
-void peas_register_types (PeasObjectModule *module);
G_DEFINE_FINAL_TYPE_WITH_CODE (PxConfigGnome,
px_config_gnome,
@@ -173,6 +172,9 @@ px_config_gnome_get_config (PxConfig *config,
g_autofree char *proxy = NULL;
GnomeProxyMode mode;
+ if (!self->available)
+ return;
+
if (px_manager_is_ignore (uri, g_settings_get_strv (self->proxy_settings, "ignore-hosts")))
return;
@@ -235,14 +237,8 @@ px_config_gnome_get_config (PxConfig *config,
static void
px_config_iface_init (PxConfigInterface *iface)
{
+ iface->name = "config-gnome";
+ iface->priority = PX_CONFIG_PRIORITY_DEFAULT;
iface->is_available = px_config_gnome_is_available;
iface->get_config = px_config_gnome_get_config;
}
-
-void
-peas_register_types (PeasObjectModule *module)
-{
- peas_object_module_register_extension_type (module,
- PX_TYPE_CONFIG,
- PX_CONFIG_TYPE_GNOME);
-}
diff --git a/src/backend/plugins/config-gnome/config-gnome.plugin b/src/backend/plugins/config-gnome/config-gnome.plugin
deleted file mode 100644
index 5121ceb..0000000
--- a/src/backend/plugins/config-gnome/config-gnome.plugin
+++ /dev/null
@@ -1,3 +0,0 @@
-[Plugin]
-Module=config-gnome
-Name=GNOME Settings \ No newline at end of file
diff --git a/src/backend/plugins/config-gnome/meson.build b/src/backend/plugins/config-gnome/meson.build
index 08acc1c..e6a9b20 100644
--- a/src/backend/plugins/config-gnome/meson.build
+++ b/src/backend/plugins/config-gnome/meson.build
@@ -2,33 +2,8 @@ plugin_name = 'config-gnome'
if get_option(plugin_name)
-plugin_src = [
- '@0@.c'.format(plugin_name),
+px_backend_sources += [
+ 'plugins/@0@/@0@.c'.format(plugin_name),
]
-plugin_data = [
- '@0@.plugin'.format(plugin_name),
-]
-
-plugin_lib = shared_module(
- plugin_name,
- plugin_src,
- include_directories: px_backend_inc,
- c_args: px_backend_c_args,
- dependencies: [peas_dep, px_backend_dep],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
- name_suffix: module_suffix,
-)
-
-# Starting with Meson 0.64 this can be replaced with fs.copyfile
-custom_target(
- '@0@-data'.format(plugin_name),
- input: plugin_data,
- output: plugin_data,
- command: ['cp', '@INPUT@', '@OUTDIR@'],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
-)
-
endif \ No newline at end of file
diff --git a/src/backend/plugins/config-kde/config-kde.c b/src/backend/plugins/config-kde/config-kde.c
index 56c83c0..d0e8ad8 100644
--- a/src/backend/plugins/config-kde/config-kde.c
+++ b/src/backend/plugins/config-kde/config-kde.c
@@ -19,7 +19,7 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#include <libpeas/peas.h>
+#include <gio/gio.h>
#include "config-kde.h"
@@ -27,7 +27,6 @@
#include "px-manager.h"
static void px_config_iface_init (PxConfigInterface *iface);
-G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
typedef enum {
KDE_PROXY_TYPE_NONE = 0,
@@ -256,6 +255,9 @@ px_config_kde_get_config (PxConfig *config,
const char *scheme = g_uri_get_scheme (uri);
g_autofree char *proxy = NULL;
+ if (!self->available)
+ return;
+
if (!self->proxy_type)
return;
@@ -293,14 +295,8 @@ px_config_kde_get_config (PxConfig *config,
static void
px_config_iface_init (PxConfigInterface *iface)
{
+ iface->name = "config-kde";
+ iface->priority = PX_CONFIG_PRIORITY_DEFAULT;
iface->is_available = px_config_kde_is_available;
iface->get_config = px_config_kde_get_config;
}
-
-G_MODULE_EXPORT void
-peas_register_types (PeasObjectModule *module)
-{
- peas_object_module_register_extension_type (module,
- PX_TYPE_CONFIG,
- PX_CONFIG_TYPE_KDE);
-}
diff --git a/src/backend/plugins/config-kde/config-kde.plugin b/src/backend/plugins/config-kde/config-kde.plugin
deleted file mode 100644
index d03d2a8..0000000
--- a/src/backend/plugins/config-kde/config-kde.plugin
+++ /dev/null
@@ -1,3 +0,0 @@
-[Plugin]
-Module=config-kde
-Name=KDE \ No newline at end of file
diff --git a/src/backend/plugins/config-kde/meson.build b/src/backend/plugins/config-kde/meson.build
index ef4adfe..b34d78d 100644
--- a/src/backend/plugins/config-kde/meson.build
+++ b/src/backend/plugins/config-kde/meson.build
@@ -2,33 +2,8 @@ plugin_name = 'config-kde'
if get_option(plugin_name)
-plugin_src = [
- '@0@.c'.format(plugin_name),
+px_backend_sources += [
+ 'plugins/@0@/@0@.c'.format(plugin_name),
]
-plugin_data = [
- '@0@.plugin'.format(plugin_name),
-]
-
-plugin_lib = shared_module(
- plugin_name,
- sources: plugin_src,
- include_directories: px_backend_inc,
- c_args: px_backend_c_args,
- dependencies: [px_backend_dep],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
- name_suffix: module_suffix,
-)
-
-# Starting with Meson 0.64 this can be replaced with fs.copyfile
-custom_target(
- '@0@-data'.format(plugin_name),
- input: plugin_data,
- output: plugin_data,
- command: ['cp', '@INPUT@', '@OUTDIR@'],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
-)
-
endif \ No newline at end of file
diff --git a/src/backend/plugins/config-osx/config-osx.c b/src/backend/plugins/config-osx/config-osx.c
index 8a9e6e4..16813a0 100644
--- a/src/backend/plugins/config-osx/config-osx.c
+++ b/src/backend/plugins/config-osx/config-osx.c
@@ -19,16 +19,20 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#include <libpeas/peas.h>
#include <SystemConfiguration/SystemConfiguration.h>
+#include <gio/gio.h>
+
#include "config-osx.h"
#include "px-plugin-config.h"
#include "px-manager.h"
static void px_config_iface_init (PxConfigInterface *iface);
-G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
+
+struct _PxConfigOsX {
+ GObject parent_instance;
+};
G_DEFINE_FINAL_TYPE_WITH_CODE (PxConfigOsX,
px_config_osx,
@@ -330,14 +334,8 @@ px_config_osx_get_config (PxConfig *self,
static void
px_config_iface_init (PxConfigInterface *iface)
{
+ iface->name = "config-osx";
+ iface->priority = PX_CONFIG_PRIORITY_DEFAULT;
iface->is_available = px_config_osx_is_available;
iface->get_config = px_config_osx_get_config;
}
-
-G_MODULE_EXPORT void
-peas_register_types (PeasObjectModule *module)
-{
- peas_object_module_register_extension_type (module,
- PX_TYPE_CONFIG,
- PX_CONFIG_TYPE_OSX);
-}
diff --git a/src/backend/plugins/config-osx/config-osx.h b/src/backend/plugins/config-osx/config-osx.h
index 544329f..797b51e 100644
--- a/src/backend/plugins/config-osx/config-osx.h
+++ b/src/backend/plugins/config-osx/config-osx.h
@@ -22,7 +22,6 @@
#pragma once
#include <glib.h>
-#include <libpeas/peas.h>
G_BEGIN_DECLS
@@ -30,10 +29,6 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (PxConfigOsX, px_config_osx, PX, CONFIG_OSX, GObject)
-struct _PxConfigOsX {
- GObject parent_instance;
-};
-
G_END_DECLS
diff --git a/src/backend/plugins/config-osx/config-osx.plugin b/src/backend/plugins/config-osx/config-osx.plugin
deleted file mode 100644
index 61c4a2a..0000000
--- a/src/backend/plugins/config-osx/config-osx.plugin
+++ /dev/null
@@ -1,3 +0,0 @@
-[Plugin]
-Module=config-osx
-Name=OS X \ No newline at end of file
diff --git a/src/backend/plugins/config-osx/meson.build b/src/backend/plugins/config-osx/meson.build
index eac98e8..f801d90 100644
--- a/src/backend/plugins/config-osx/meson.build
+++ b/src/backend/plugins/config-osx/meson.build
@@ -1,39 +1,16 @@
plugin_name = 'config-osx'
-if host_machine.system() == 'darwin'
+if get_option(plugin_name) and with_platform_darwin
-if get_option(plugin_name)
-
-plugin_src = [
- '@0@.c'.format(plugin_name),
+foundation_dep = dependency('Foundation')
+system_configuration_dep = dependency('SystemConfiguration')
+px_backend_deps += [
+ foundation_dep,
+ system_configuration_dep,
]
-plugin_data = [
- '@0@.plugin'.format(plugin_name),
+px_backend_sources += [
+ 'plugins/@0@/@0@.c'.format(plugin_name),
]
-plugin_lib = shared_module(
- plugin_name,
- plugin_src,
- include_directories: px_backend_inc,
- c_args: px_backend_c_args,
- dependencies: [px_backend_dep],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
- name_suffix: module_suffix
-)
-
-# Starting with Meson 0.64 this can be replaced with fs.copyfile
-custom_target(
- '@0@-data'.format(plugin_name),
- input: plugin_data,
- output: plugin_data,
- command: ['cp', '@INPUT@', '@OUTDIR@'],
- build_by_default: true,
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
-)
-
-endif
-
endif
diff --git a/src/backend/plugins/config-sysconfig/config-sysconfig.c b/src/backend/plugins/config-sysconfig/config-sysconfig.c
index 1adc1e8..c640f1c 100644
--- a/src/backend/plugins/config-sysconfig/config-sysconfig.c
+++ b/src/backend/plugins/config-sysconfig/config-sysconfig.c
@@ -19,7 +19,7 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#include <libpeas/peas.h>
+#include <gio/gio.h>
#include "config-sysconfig.h"
@@ -41,7 +41,6 @@ struct _PxConfigSysConfig {
};
static void px_config_iface_init (PxConfigInterface *iface);
-G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
G_DEFINE_FINAL_TYPE_WITH_CODE (PxConfigSysConfig,
px_config_sysconfig,
@@ -246,14 +245,8 @@ px_config_sysconfig_get_config (PxConfig *config,
static void
px_config_iface_init (PxConfigInterface *iface)
{
+ iface->name = "config-sysconfig";
+ iface->priority = PX_CONFIG_PRIORITY_LAST;
iface->is_available = px_config_sysconfig_is_available;
iface->get_config = px_config_sysconfig_get_config;
}
-
-G_MODULE_EXPORT void
-peas_register_types (PeasObjectModule *module)
-{
- peas_object_module_register_extension_type (module,
- PX_TYPE_CONFIG,
- PX_CONFIG_TYPE_SYSCONFIG);
-}
diff --git a/src/backend/plugins/config-sysconfig/config-sysconfig.plugin b/src/backend/plugins/config-sysconfig/config-sysconfig.plugin
deleted file mode 100644
index 0697fa2..0000000
--- a/src/backend/plugins/config-sysconfig/config-sysconfig.plugin
+++ /dev/null
@@ -1,3 +0,0 @@
-[Plugin]
-Module=config-sysconfig
-Name=sysconfig \ No newline at end of file
diff --git a/src/backend/plugins/config-sysconfig/meson.build b/src/backend/plugins/config-sysconfig/meson.build
index 1aef00b..6d6789b 100644
--- a/src/backend/plugins/config-sysconfig/meson.build
+++ b/src/backend/plugins/config-sysconfig/meson.build
@@ -2,34 +2,8 @@ plugin_name = 'config-sysconfig'
if get_option(plugin_name)
-plugin_src = [
- '@0@.c'.format(plugin_name),
+px_backend_sources += [
+ 'plugins/@0@/@0@.c'.format(plugin_name),
]
-plugin_data = [
- '@0@.plugin'.format(plugin_name),
-]
-
-plugin_lib = shared_module(
- plugin_name,
- plugin_src,
- include_directories: px_backend_inc,
- c_args: px_backend_c_args,
- dependencies: [px_backend_dep],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
- name_suffix: module_suffix,
-)
-
-# Starting with Meson 0.64 this can be replaced with fs.copyfile
-custom_target(
- '@0@-data'.format(plugin_name),
- input: plugin_data,
- output: plugin_data,
- command: ['cp', '@INPUT@', '@OUTDIR@'],
- build_by_default: true,
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
-)
-
endif
diff --git a/src/backend/plugins/config-windows/config-windows.c b/src/backend/plugins/config-windows/config-windows.c
index 5bffde6..cc9c92d 100644
--- a/src/backend/plugins/config-windows/config-windows.c
+++ b/src/backend/plugins/config-windows/config-windows.c
@@ -21,7 +21,8 @@
#include <windows.h>
#include <winreg.h>
-#include <libpeas/peas.h>
+
+#include <gio/gio.h>
#include "config-windows.h"
@@ -38,7 +39,6 @@ struct _PxConfigWindows {
};
static void px_config_iface_init (PxConfigInterface *iface);
-void peas_register_types (PeasObjectModule *module);
G_DEFINE_FINAL_TYPE_WITH_CODE (PxConfigWindows,
px_config_windows,
@@ -245,14 +245,8 @@ px_config_windows_get_config (PxConfig *self,
static void
px_config_iface_init (PxConfigInterface *iface)
{
+ iface->name = "config-windows";
+ iface->priority = PX_CONFIG_PRIORITY_DEFAULT;
iface->is_available = px_config_windows_is_available;
iface->get_config = px_config_windows_get_config;
}
-
-G_MODULE_EXPORT void
-peas_register_types (PeasObjectModule *module)
-{
- peas_object_module_register_extension_type (module,
- PX_TYPE_CONFIG,
- PX_CONFIG_TYPE_WINDOWS);
-}
diff --git a/src/backend/plugins/config-windows/config-windows.plugin b/src/backend/plugins/config-windows/config-windows.plugin
deleted file mode 100644
index 04a589b..0000000
--- a/src/backend/plugins/config-windows/config-windows.plugin
+++ /dev/null
@@ -1,3 +0,0 @@
-[Plugin]
-Module=config-windows
-Name=Windows \ No newline at end of file
diff --git a/src/backend/plugins/config-windows/meson.build b/src/backend/plugins/config-windows/meson.build
index 2e592b5..302a33e 100644
--- a/src/backend/plugins/config-windows/meson.build
+++ b/src/backend/plugins/config-windows/meson.build
@@ -1,39 +1,9 @@
plugin_name = 'config-windows'
-if host_machine.system() == 'windows'
+if get_option(plugin_name) and with_platform_windows
-if get_option(plugin_name)
-
-plugin_src = [
- '@0@.c'.format(plugin_name),
-]
-
-plugin_data = [
- '@0@.plugin'.format(plugin_name),
+px_backend_sources += [
+ 'plugins/@0@/@0@.c'.format(plugin_name),
]
-plugin_lib = shared_module(
- plugin_name,
- plugin_src,
- include_directories: px_backend_inc,
- c_args: px_backend_c_args,
- dependencies: [px_backend_dep],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
- name_suffix: module_suffix,
-)
-
-# Starting with Meson 0.64 this can be replaced with fs.copyfile
-custom_target(
- '@0@-data'.format(plugin_name),
- input: plugin_data,
- output: plugin_data,
- command: ['cp', '@INPUT@', '@OUTDIR@'],
- build_by_default: true,
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
-)
-
-endif
-
endif \ No newline at end of file
diff --git a/src/backend/plugins/pacrunner-duktape/meson.build b/src/backend/plugins/pacrunner-duktape/meson.build
index ef4a470..f391b6d 100644
--- a/src/backend/plugins/pacrunner-duktape/meson.build
+++ b/src/backend/plugins/pacrunner-duktape/meson.build
@@ -3,35 +3,15 @@ plugin_name = 'pacrunner-duktape'
if get_option(plugin_name)
duktape_dep = dependency('duktape')
+m_dep = cc.find_library('m', required : false)
-plugin_src = [
- '@0@.c'.format(plugin_name),
+px_backend_sources += [
+ 'plugins/@0@/@0@.c'.format(plugin_name),
]
-plugin_data = [
- '@0@.plugin'.format(plugin_name),
+px_backend_deps += [
+ duktape_dep,
+ m_dep
]
-plugin_lib = shared_module(
- plugin_name,
- plugin_src,
- include_directories: px_backend_inc,
- c_args: px_backend_c_args,
- dependencies: [px_backend_dep, duktape_dep, ws2_32_dep],
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
- name_suffix: module_suffix,
-)
-
-# Starting with Meson 0.64 this can be replaced with fs.copyfile
-custom_target(
- '@0@-data'.format(plugin_name),
- input: plugin_data,
- output: plugin_data,
- command: ['cp', '@INPUT@', '@OUTDIR@'],
- build_by_default: true,
- install_dir: join_paths(px_plugins_dir, plugin_name),
- install: true,
-)
-
endif \ No newline at end of file
diff --git a/src/backend/plugins/pacrunner-duktape/pacrunner-duktape.c b/src/backend/plugins/pacrunner-duktape/pacrunner-duktape.c
index 51c2592..3676e48 100644
--- a/src/backend/plugins/pacrunner-duktape/pacrunner-duktape.c
+++ b/src/backend/plugins/pacrunner-duktape/pacrunner-duktape.c
@@ -19,7 +19,7 @@
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
-#include <libpeas/peas.h>
+#include <gio/gio.h>
#include <unistd.h>
#ifdef __WIN32__
@@ -40,7 +40,6 @@ struct _PxPacRunnerDuktape {
};
static void px_pacrunner_iface_init (PxPacRunnerInterface *iface);
-void peas_register_types (PeasObjectModule *module);
G_DEFINE_FINAL_TYPE_WITH_CODE (PxPacRunnerDuktape,
px_pacrunner_duktape,
@@ -200,11 +199,3 @@ px_pacrunner_iface_init (PxPacRunnerInterface *iface)
iface->set_pac = px_pacrunner_duktape_set_pac;
iface->run = px_pacrunner_duktape_run;
}
-
-void
-peas_register_types (PeasObjectModule *module)
-{
- peas_object_module_register_extension_type (module,
- PX_TYPE_PACRUNNER,
- PX_PACRUNNER_TYPE_DUKTAPE);
-}
diff --git a/src/backend/plugins/pacrunner-duktape/pacrunner-duktape.plugin b/src/backend/plugins/pacrunner-duktape/pacrunner-duktape.plugin
deleted file mode 100644
index efb10f0..0000000
--- a/src/backend/plugins/pacrunner-duktape/pacrunner-duktape.plugin
+++ /dev/null
@@ -1,3 +0,0 @@
-[Plugin]
-Module=pacrunner-duktape
-Name=Duktape \ No newline at end of file
diff --git a/src/backend/px-manager.c b/src/backend/px-manager.c
index ecc477e..1eab303 100644
--- a/src/backend/px-manager.c
+++ b/src/backend/px-manager.c
@@ -20,19 +20,50 @@
*/
#include "config.h"
+#include "px-backend-config.h"
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
#include "px-manager.h"
#include "px-plugin-config.h"
#include "px-plugin-pacrunner.h"
+#ifdef HAVE_CONFIG_ENV
+#include <plugins/config-env/config-env.h>
+#endif
+
+#ifdef HAVE_CONFIG_GNOME
+#include <plugins/config-gnome/config-gnome.h>
+#endif
+
+#ifdef HAVE_CONFIG_KDE
+#include <plugins/config-kde/config-kde.h>
+#endif
+
+#ifdef HAVE_CONFIG_OSX
+#include <plugins/config-osx/config-osx.h>
+#endif
+
+#ifdef HAVE_CONFIG_SYSCONFIG
+#include <plugins/config-sysconfig/config-sysconfig.h>
+#endif
+
+#ifdef HAVE_CONFIG_WINDOWS
+#include <plugins/config-windows/config-windows.h>
+#endif
+
+#ifdef HAVE_PACRUNNER_DUKTAPE
+#include <plugins/pacrunner-duktape/pacrunner-duktape.h>
+#endif
+
#ifdef HAVE_CURL
#include <curl/curl.h>
#endif
-#include <libpeas/peas.h>
enum {
PROP_0,
- PROP_PLUGINS_DIR,
PROP_CONFIG_PLUGIN,
PROP_CONFIG_OPTION,
LAST_PROP
@@ -48,14 +79,12 @@ static GParamSpec *obj_properties[LAST_PROP];
struct _PxManager {
GObject parent_instance;
- PeasEngine *engine;
- PeasExtensionSet *config_set;
- PeasExtensionSet *pacrunner_set;
+ GList *config_plugins;
+ GList *pacrunner_plugins;
GNetworkMonitor *network_monitor;
#ifdef HAVE_CURL
CURL *curl;
#endif
- char *plugins_dir;
char *config_plugin;
char *config_option;
@@ -85,11 +114,48 @@ px_manager_on_network_changed (GNetworkMonitor *monitor,
g_clear_pointer (&self->pac_data, g_bytes_unref);
}
+static gint
+config_order_compare (gconstpointer a,
+ gconstpointer b)
+{
+ PxConfig *config_a = (PxConfig *)a;
+ PxConfig *config_b = (PxConfig *)b;
+ PxConfigInterface *ifc_a = PX_CONFIG_GET_IFACE (config_a);
+ PxConfigInterface *ifc_b = PX_CONFIG_GET_IFACE (config_b);
+
+ if (ifc_a->priority < ifc_b->priority)
+ return -1;
+
+ if (ifc_a->priority == ifc_b->priority)
+ return 0;
+
+ return 1;
+}
+
+static void
+px_manager_add_config_plugin (PxManager *self,
+ GType type)
+{
+ PxConfig *config = g_object_new (type, "config-option", self->config_option, NULL);
+ PxConfigInterface *ifc = PX_CONFIG_GET_IFACE (config);
+
+ if (!self->config_plugin || g_strcmp0 (ifc->name, self->config_plugin) == 0)
+ self->config_plugins = g_list_insert_sorted (self->config_plugins, config, config_order_compare);
+}
+
+static void
+px_manager_add_pacrunner_plugin (PxManager *self,
+ GType type)
+{
+ PxPacRunner *pacrunner = g_object_new (type, NULL);
+
+ self->pacrunner_plugins = g_list_append (self->pacrunner_plugins, pacrunner);
+}
+
static void
px_manager_constructed (GObject *object)
{
PxManager *self = PX_MANAGER (object);
- const GList *list;
if (g_getenv ("PX_DEBUG")) {
const gchar *g_messages_debug;
@@ -107,38 +173,37 @@ px_manager_constructed (GObject *object)
}
}
- self->engine = peas_engine_get_default ();
-
- peas_engine_add_search_path (self->engine, self->plugins_dir, NULL);
-
- self->config_set = peas_extension_set_new (self->engine, PX_TYPE_CONFIG, "config-option", self->config_option, NULL);
- self->pacrunner_set = peas_extension_set_new (self->engine, PX_TYPE_PACRUNNER, NULL);
-
- list = peas_engine_get_plugin_list (self->engine);
- for (; list && list->data; list = list->next) {
- PeasPluginInfo *info = PEAS_PLUGIN_INFO (list->data);
- PeasExtension *extension = peas_extension_set_get_extension (self->config_set, info);
- gboolean available = TRUE;
-
- /* In case user requested a specific module, just load that one */
- if (self->config_plugin && g_str_has_prefix (peas_plugin_info_get_module_name (info), "config-")) {
- if (g_strcmp0 (peas_plugin_info_get_module_name (info), self->config_plugin) == 0)
- peas_engine_load_plugin (self->engine, info);
- } else {
- peas_engine_load_plugin (self->engine, info);
- }
-
- extension = peas_extension_set_get_extension (self->config_set, info);
- if (extension) {
- PxConfigInterface *ifc = PX_CONFIG_GET_IFACE (extension);
+#ifdef HAVE_CONFIG_ENV
+ px_manager_add_config_plugin (self, PX_CONFIG_TYPE_ENV);
+#endif
+#ifdef HAVE_CONFIG_GNOME
+ px_manager_add_config_plugin (self, PX_CONFIG_TYPE_GNOME);
+#endif
+#ifdef HAVE_CONFIG_KDE
+ px_manager_add_config_plugin (self, PX_CONFIG_TYPE_KDE);
+#endif
+#ifdef HAVE_CONFIG_OSX
+ px_manager_add_config_plugin (self, PX_CONFIG_TYPE_OSX);
+#endif
+#ifdef HAVE_CONFIG_SYSCONFIG
+ px_manager_add_config_plugin (self, PX_CONFIG_TYPE_SYSCONFIG);
+#endif
+#ifdef HAVE_CONFIG_WINDOWS
+ px_manager_add_config_plugin (self, PX_CONFIG_TYPE_WINDOWS);
+#endif
- available = ifc->is_available (PX_CONFIG (extension));
- }
+ g_debug ("Active config plugins:\n");
+ for (GList *list = self->config_plugins; list && list->data; list = list->next) {
+ PxConfig *config = list->data;
+ PxConfigInterface *ifc = PX_CONFIG_GET_IFACE (config);
- if (!available)
- peas_engine_unload_plugin (self->engine, info);
+ g_debug (" - %s\n", ifc->name);
}
+#ifdef HAVE_PACRUNNER_DUKTAPE
+ px_manager_add_pacrunner_plugin (self, PX_PACRUNNER_TYPE_DUKTAPE);
+#endif
+
self->pac_data = NULL;
self->network_monitor = g_network_monitor_get_default ();
@@ -151,19 +216,14 @@ static void
px_manager_dispose (GObject *object)
{
PxManager *self = PX_MANAGER (object);
- const GList *list;
- list = peas_engine_get_plugin_list (self->engine);
- for (; list && list->data; list = list->next) {
- PeasPluginInfo *info = PEAS_PLUGIN_INFO (list->data);
+ for (GList *list = self->config_plugins; list && list->data; list = list->next)
+ g_clear_object (&list->data);
- if (peas_plugin_info_is_loaded (info))
- peas_engine_unload_plugin (self->engine, info);
- }
+ for (GList *list = self->pacrunner_plugins; list && list->data; list = list->next)
+ g_clear_object (&list->data);
g_clear_pointer (&self->config_plugin, g_free);
- g_clear_pointer (&self->plugins_dir, g_free);
- g_clear_object (&self->engine);
G_OBJECT_CLASS (px_manager_parent_class)->dispose (object);
}
@@ -177,9 +237,6 @@ px_manager_set_property (GObject *object,
PxManager *self = PX_MANAGER (object);
switch (prop_id) {
- case PROP_PLUGINS_DIR:
- self->plugins_dir = g_strdup (g_value_get_string (value));
- break;
case PROP_CONFIG_PLUGIN:
self->config_plugin = g_strdup (g_value_get_string (value));
break;
@@ -198,8 +255,6 @@ px_manager_get_property (GObject *object,
GParamSpec *pspec)
{
switch (prop_id) {
- case PROP_PLUGINS_DIR:
- break;
case PROP_CONFIG_PLUGIN:
break;
default:
@@ -218,12 +273,6 @@ px_manager_class_init (PxManagerClass *klass)
object_class->set_property = px_manager_set_property;
object_class->get_property = px_manager_get_property;
- obj_properties[PROP_PLUGINS_DIR] = g_param_spec_string ("plugins-dir",
- NULL,
- NULL,
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
obj_properties[PROP_CONFIG_PLUGIN] = g_param_spec_string ("config-plugin",
NULL,
NULL,
@@ -277,7 +326,7 @@ px_manager_new_with_options (const char *optname1,
PxManager *
px_manager_new (void)
{
- return px_manager_new_with_options ("plugins-dir", PX_PLUGINS_DIR, NULL);
+ return px_manager_new_with_options (NULL);
}
#ifdef HAVE_CURL
@@ -345,29 +394,6 @@ px_manager_pac_download (PxManager *self,
#endif
}
-struct ConfigData {
- GStrvBuilder *builder;
- GUri *uri;
-};
-
-/**
- * Strategy:
- * - Traverse through all plugins in extension set and ask for configuration data.
- * - A plugin can either return the proxy server for given uri OR nothing! for direc access.
- */
-static void
-get_config (PeasExtensionSet *set,
- PeasPluginInfo *info,
- PeasExtension *extension,
- gpointer data)
-{
- PxConfigInterface *ifc = PX_CONFIG_GET_IFACE (extension);
- struct ConfigData *config_data = data;
-
- g_debug ("%s: Asking plugin '%s' for configuration", __FUNCTION__, peas_plugin_info_get_module_name (info));
- ifc->get_config (PX_CONFIG (extension), config_data->uri, config_data->builder);
-}
-
/**
* px_manager_get_configuration:
* @self: a px manager
@@ -384,37 +410,31 @@ px_manager_get_configuration (PxManager *self,
GError **error)
{
g_autoptr (GStrvBuilder) builder = g_strv_builder_new ();
- struct ConfigData config_data = {
- .uri = uri,
- .builder = builder,
- };
- peas_extension_set_foreach (self->config_set, get_config, &config_data);
+ for (GList *list = self->config_plugins; list && list->data; list = list->next) {
+ PxConfig *config = PX_CONFIG (list->data);
+ PxConfigInterface *ifc = PX_CONFIG_GET_IFACE (config);
+
+ ifc->get_config (config, uri, builder);
+ }
return g_strv_builder_end (builder);
}
-struct PacData {
- GBytes *pac;
- GUri *uri;
- GStrvBuilder *builder;
-};
-
static void
-px_manager_run_pac (PeasExtensionSet *set,
- PeasPluginInfo *info,
- PeasExtension *extension,
- gpointer data)
+px_manager_run_pac (PxPacRunner *pacrunner,
+ GBytes *pac,
+ GUri *uri,
+ GStrvBuilder *builder)
{
- PxPacRunnerInterface *ifc = PX_PAC_RUNNER_GET_IFACE (extension);
- struct PacData *pac_data = data;
+ PxPacRunnerInterface *ifc = PX_PAC_RUNNER_GET_IFACE (pacrunner);
g_auto (GStrv) proxies_split = NULL;
char *pac_response;
- if (!ifc->set_pac (PX_PAC_RUNNER (extension), pac_data->pac))
+ if (!ifc->set_pac (PX_PAC_RUNNER (pacrunner), pac))
return;
- pac_response = ifc->run (PX_PAC_RUNNER (extension), pac_data->uri);
+ pac_response = ifc->run (PX_PAC_RUNNER (pacrunner), uri);
/* Split line to handle multiple proxies */
proxies_split = g_strsplit (pac_response, ";", -1);
@@ -422,7 +442,7 @@ px_manager_run_pac (PeasExtensionSet *set,
for (int idx = 0; idx < g_strv_length (proxies_split); idx++) {
char *line = g_strstrip (proxies_split[idx]);
g_auto (GStrv) word_split = g_strsplit (line, " ", -1);
- g_autoptr (GUri) uri = NULL;
+ g_autoptr (GUri) proxy_uri = NULL;
char *method;
char *server;
@@ -435,12 +455,12 @@ px_manager_run_pac (PeasExtensionSet *set,
server = word_split[1];
uri_string = g_strconcat ("http://", server, NULL);
- uri = g_uri_parse (uri_string, G_URI_FLAGS_PARSE_RELAXED, NULL);
- if (!uri)
+ proxy_uri = g_uri_parse (uri_string, G_URI_FLAGS_PARSE_RELAXED, NULL);
+ if (!proxy_uri)
continue;
if (g_ascii_strncasecmp (method, "proxy", 5) == 0) {
- proxy_string = g_uri_to_string (uri);
+ proxy_string = g_uri_to_string (proxy_uri);
} else if (g_ascii_strncasecmp (method, "socks4a", 7) == 0) {
proxy_string = g_strconcat ("socks4a://", server, NULL);
} else if (g_ascii_strncasecmp (method, "socks4", 6) == 0) {
@@ -451,10 +471,10 @@ px_manager_run_pac (PeasExtensionSet *set,
proxy_string = g_strconcat ("socks://", server, NULL);
}
- px_strv_builder_add_proxy (pac_data->builder, proxy_string);
+ px_strv_builder_add_proxy (builder, proxy_string);
} else {
/* Syntax not found, returning direct */
- px_strv_builder_add_proxy (pac_data->builder, "direct://");
+ px_strv_builder_add_proxy (builder, "direct://");
}
}
}
@@ -562,12 +582,13 @@ px_manager_get_proxies_sync (PxManager *self,
g_debug ("%s: Config[%d] = %s", __FUNCTION__, idx, config[idx]);
if (px_manager_expand_wpad (self, conf_url) || px_manager_expand_pac (self, conf_url)) {
- struct PacData pac_data = {
- .pac = self->pac_data,
- .uri = uri,
- .builder = builder,
- };
- peas_extension_set_foreach (self->pacrunner_set, px_manager_run_pac, &pac_data);
+ GList *list;
+
+ for (list = self->pacrunner_plugins; list && list->data; list = list->next) {
+ PxPacRunner *pacrunner = PX_PAC_RUNNER (list->data);
+
+ px_manager_run_pac (pacrunner, self->pac_data, uri, builder);
+ }
} else if (!g_str_has_prefix (g_uri_get_scheme (conf_url), "wpad") && !g_str_has_prefix (g_uri_get_scheme (conf_url), "pac+")) {
px_strv_builder_add_proxy (builder, g_uri_to_string (conf_url));
}
diff --git a/src/backend/px-plugin-config.h b/src/backend/px-plugin-config.h
index aac62a0..6958df6 100644
--- a/src/backend/px-plugin-config.h
+++ b/src/backend/px-plugin-config.h
@@ -29,9 +29,17 @@ G_BEGIN_DECLS
G_DECLARE_INTERFACE (PxConfig, px_config, PX, CONFIG, GObject)
+enum {
+ PX_CONFIG_PRIORITY_FIRST,
+ PX_CONFIG_PRIORITY_DEFAULT,
+ PX_CONFIG_PRIORITY_LAST,
+};
+
struct _PxConfigInterface
{
GTypeInterface parent_iface;
+ const char *name;
+ gint priority;
gboolean (*is_available) (PxConfig *self);
void (*get_config) (PxConfig *self, GUri *uri, GStrvBuilder *builder);
diff --git a/tests/config-gnome-test.c b/tests/config-gnome-test.c
index 71ddb28..f80914a 100644
--- a/tests/config-gnome-test.c
+++ b/tests/config-gnome-test.c
@@ -190,6 +190,8 @@ main (int argc,
{
g_test_init (&argc, &argv, NULL);
+ g_setenv ("XDG_CURRENT_DESKTOP", "GNOME", TRUE);
+
g_test_add ("/config/gnome/manual", Fixture, NULL, fixture_setup, test_config_gnome_manual, fixture_teardown);
g_test_add ("/config/gnome/manual_auth", Fixture, NULL, fixture_setup, test_config_gnome_manual_auth, fixture_teardown);
g_test_add ("/config/gnome/auto", Fixture, NULL, fixture_setup, test_config_gnome_auto, fixture_teardown);
diff --git a/tests/config-kde-test.c b/tests/config-kde-test.c
index c12d1f4..5129384 100644
--- a/tests/config-kde-test.c
+++ b/tests/config-kde-test.c
@@ -203,6 +203,8 @@ main (int argc,
{
g_test_init (&argc, &argv, NULL);
+ g_setenv ("XDG_CURRENT_DESKTOP", "KDE", TRUE);
+
g_test_add_func ("/config/kde/disabled", test_config_kde_disabled);
g_test_add_func ("/config/kde/manual", test_config_kde_manual);
g_test_add_func ("/config/kde/wpad", test_config_kde_wpad);
diff --git a/tests/config-osx-test.c b/tests/config-osx-test.c
new file mode 100644
index 0000000..cdb8a72
--- /dev/null
+++ b/tests/config-osx-test.c
@@ -0,0 +1,52 @@
+/* config-osx-test.c
+ *
+ * Copyright 2022-2023 The Libproxy Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "px-manager.h"
+
+#include "px-manager-helper.h"
+
+static void
+test_config_osx (void)
+{
+ g_autoptr (GError) error = NULL;
+ g_autoptr (PxManager) manager = NULL;
+ g_autoptr (GUri) uri = NULL;
+ g_auto (GStrv) config = NULL;
+
+ manager = px_test_manager_new ("config-osx", NULL);
+ g_clear_error (&error);
+
+ uri = g_uri_parse ("https://www.example.com", G_URI_FLAGS_PARSE_RELAXED, &error);
+ config = px_manager_get_configuration (manager, uri, &error);
+ g_assert_nonnull (config);
+ g_assert_null (config[0]);
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/config/osx", test_config_osx);
+
+ return g_test_run ();
+}
diff --git a/tests/config-windows-test.c b/tests/config-windows-test.c
new file mode 100644
index 0000000..10d4b21
--- /dev/null
+++ b/tests/config-windows-test.c
@@ -0,0 +1,52 @@
+/* config-windows-test.c
+ *
+ * Copyright 2022-2023 The Libproxy Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "px-manager.h"
+
+#include "px-manager-helper.h"
+
+static void
+test_config_windows (void)
+{
+ g_autoptr (GError) error = NULL;
+ g_autoptr (PxManager) manager = NULL;
+ g_autoptr (GUri) uri = NULL;
+ g_auto (GStrv) config = NULL;
+
+ manager = px_test_manager_new ("config-windows", NULL);
+ g_clear_error (&error);
+
+ uri = g_uri_parse ("https://www.example.com", G_URI_FLAGS_PARSE_RELAXED, &error);
+ config = px_manager_get_configuration (manager, uri, &error);
+ g_assert_nonnull (config);
+ g_assert_nonnull (config[0]);
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/config/windows", test_config_windows);
+
+ return g_test_run ();
+}
diff --git a/tests/meson.build b/tests/meson.build
index b5ca084..4ae8e7d 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -76,4 +76,28 @@ if get_option('tests')
env: [envs, 'XDG_CURRENT_DESKTOP=KDE'],
)
endif
+
+ if get_option('config-osx') and with_platform_darwin
+ config_osx_test = executable('test-config-osx',
+ ['config-osx-test.c', 'px-manager-helper.c'],
+ include_directories: px_backend_inc,
+ dependencies: [glib_dep, px_backend_dep],
+ )
+ test('Config OSX test',
+ config_osx_test,
+ env: [envs],
+ )
+ endif
+
+ if get_option('config-windows') and with_platform_windows
+ config_windows_test = executable('test-config-windows',
+ ['config-windows-test.c', 'px-manager-helper.c'],
+ include_directories: px_backend_inc,
+ dependencies: [glib_dep, px_backend_dep],
+ )
+ test('Config Windows test',
+ config_windows_test,
+ env: [envs],
+ )
+ endif
endif
diff --git a/tests/px-manager-helper.c b/tests/px-manager-helper.c
index c5e0b87..e3129a2 100644
--- a/tests/px-manager-helper.c
+++ b/tests/px-manager-helper.c
@@ -25,10 +25,7 @@
PxManager *
px_test_manager_new (const char *config_plugin, const char *config_option)
{
- g_autofree char *path = g_test_build_filename (G_TEST_BUILT, "../src/backend/plugins", NULL);
-
- return px_manager_new_with_options ("plugins-dir", path,
- "config-plugin", config_plugin,
+ return px_manager_new_with_options ("config-plugin", config_plugin,
"config-option", config_option,
NULL);
}