summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/dbus/dbus.c190
-rw-r--r--src/backend/dbus/meson.build92
-rw-r--r--src/backend/dbus/org.libproxy.proxy-system.service.in4
-rw-r--r--src/backend/dbus/org.libproxy.proxy.conf.in28
-rw-r--r--src/backend/dbus/org.libproxy.proxy.service.in3
-rw-r--r--src/backend/dbus/org.libproxy.proxy.xml16
-rw-r--r--src/backend/meson.build7
7 files changed, 1 insertions, 339 deletions
diff --git a/src/backend/dbus/dbus.c b/src/backend/dbus/dbus.c
deleted file mode 100644
index 0b30ccf..0000000
--- a/src/backend/dbus/dbus.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/* dbus.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-interface.h"
-
-#include <gio/gio.h>
-
-static gboolean replace;
-static gboolean use_system;
-
-static GApplication *app;
-
-const GOptionEntry options[] = {
- { "replace", 'r', 0, G_OPTION_ARG_NONE, &replace, "Replace running daemon.", NULL },
- { "system", 's', 0, G_OPTION_ARG_NONE, &use_system, "Use system bus.", NULL },
- { NULL }
-};
-
-static void
-handle_method_call (GDBusConnection *connection,
- const gchar *sender,
- const gchar *object_path,
- const gchar *interface_name,
- const gchar *method_name,
- GVariant *parameters,
- GDBusMethodInvocation *invocation,
- gpointer user_data)
-{
- PxManager *manager = PX_MANAGER (user_data);
- GVariantBuilder *result;
- g_auto (GStrv) proxies = NULL;
- g_autoptr (GError) error = NULL;
- const gchar *url;
- int idx;
-
- g_application_hold (app);
- if (g_strcmp0 (method_name, "GetProxiesFor") != 0) {
- g_warning ("Invalid method name '%s', aborting.", method_name);
- g_dbus_method_invocation_return_error (invocation,
- PX_MANAGER_ERROR,
- PX_MANAGER_ERROR_UNKNOWN_METHOD,
- "Unknown method");
- g_application_release (app);
- return;
- }
-
- g_variant_get (parameters, "(&s)", &url);
-
- proxies = px_manager_get_proxies_sync (manager, url, &error);
- if (error) {
- g_warning ("Could not query proxy servers: %s", error->message);
- g_dbus_method_invocation_return_gerror (invocation, error);
- g_application_release (app);
- return;
- }
-
- result = g_variant_builder_new (G_VARIANT_TYPE ("as"));
- if (proxies) {
- for (idx = 0; proxies[idx]; idx++) {
- g_variant_builder_add (result, "s", proxies[idx]);
- }
- }
-
- g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("(as)", result));
- g_application_release (app);
-}
-
-static const GDBusInterfaceVTable interface_vtable = {
- handle_method_call,
-};
-
-static void
-on_bus_acquired (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- g_autoptr (GError) error = NULL;
- PxManager *manager = NULL;
-
- manager = px_manager_new ();
- g_dbus_connection_register_object (connection,
- "/org/libproxy/proxy",
- (GDBusInterfaceInfo *)&org_libproxy_proxy_interface,
- &interface_vtable,
- manager,
- g_object_unref,
- &error);
- g_application_release (user_data);
-
- if (error) {
- g_warning ("Could not register dbus object: %s", error->message);
- g_application_quit (user_data);
- return;
- }
-}
-
-static void
-on_name_lost (GDBusConnection *connection,
- const gchar *name,
- gpointer user_data)
-{
- if (!connection) {
- g_warning ("Can't connect proxy bus");
- g_application_quit (user_data);
- } else {
- g_warning ("Unknown name lost error");
- g_application_quit (user_data);
- }
-}
-
-static void
-activate (GApplication *application)
-{
- GBusNameOwnerFlags flags;
-
- flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT;
- if (replace)
- flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE;
-
- g_bus_own_name (use_system ? G_BUS_TYPE_SYSTEM : G_BUS_TYPE_SESSION,
- "org.libproxy.proxy",
- flags,
- on_bus_acquired,
- NULL,
- on_name_lost,
- app,
- NULL);
-
- g_application_hold (app);
-}
-
-int
-main (int argc,
- char **argv)
-{
- GOptionContext *context;
- g_autoptr (GError) error = NULL;
-
- replace = FALSE;
- use_system = FALSE;
-
- context = g_option_context_new ("");
- g_option_context_set_summary (context, "Libproxy D-Bus Service");
- g_option_context_add_main_entries (context, options, "libproxy");
-
- if (!g_option_context_parse (context, &argc, &argv, &error)) {
- g_printerr ("%s: %s", g_get_application_name (), error->message);
- g_printerr ("\n");
- g_printerr ("Try \"%s --help\" for more information.",
- g_get_prgname ());
- g_printerr ("\n");
- g_option_context_free (context);
- return 1;
- }
-
- app = g_application_new ("org.libproxy.proxy-service",
-#if GLIB_CHECK_VERSION (2, 73, 0)
- G_APPLICATION_DEFAULT_FLAGS
-#else
- G_APPLICATION_FLAGS_NONE
-#endif
- );
-
- g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
-
- /* Set application timeout to 60 seconds */
- g_application_set_inactivity_timeout (app, 60000);
-
- return g_application_run (app, argc, argv);
-}
diff --git a/src/backend/dbus/meson.build b/src/backend/dbus/meson.build
deleted file mode 100644
index 107e401..0000000
--- a/src/backend/dbus/meson.build
+++ /dev/null
@@ -1,92 +0,0 @@
-if build_dbus
- gdbus_codegen = find_program('gdbus-codegen')
-
- unitdir = ''
- dbus_data_dir = join_paths(get_option('prefix'), get_option('datadir'), 'dbus-1')
- dbus_interfaces_dir = join_paths(dbus_data_dir, 'interfaces')
- dbus_user_services_dir = join_paths(dbus_data_dir, 'services')
- dbus_system_services_dir = join_paths(dbus_data_dir, 'system-services')
- dbus_system_conf_dir = join_paths(dbus_data_dir, 'system.d')
-
- px_interface = [
- 'org.libproxy.proxy.xml'
- ]
-
- px_interface_h = custom_target(
- 'px-interface.h',
- input: px_interface,
- output: ['px-interface.h'],
- command: [
- gdbus_codegen,
- '--interface-info-header',
- '--output', '@OUTPUT@',
- '@INPUT@'
- ]
- )
-
- px_interface_c = custom_target(
- 'libproxy-iface.c',
- input: px_interface,
- output: ['px-interface.c'],
- command: [
- gdbus_codegen,
- '--interface-info-body',
- '--output', '@OUTPUT@',
- '@INPUT@'
- ],
- )
-
- proxyd_sources = [
- px_interface_c,
- px_interface_h,
- 'dbus.c',
- ]
-
- proxyd_deps = [
- px_backend_dep
- ]
-
- executable(
- 'proxyd',
- proxyd_sources,
- c_args: px_backend_c_args,
- dependencies: proxyd_deps,
- install_dir: join_paths(px_prefix, get_option('libexecdir')),
- install: true,
- )
-
- # D-Bus Interface
- install_data('org.libproxy.proxy.xml', install_dir : dbus_interfaces_dir)
-
- # D-Bus User Service
- user_service_data = configuration_data()
- user_service_data.set('LIBEXECDIR', join_paths(px_prefix, get_option('libexecdir')))
- configure_file(
- input: 'org.libproxy.proxy.service.in',
- output: 'org.libproxy.proxy.service',
- configuration: user_service_data,
- install: true,
- install_dir: dbus_user_services_dir
- )
-
- # D-Bus System Service
- system_service_data = configuration_data()
- system_service_data.set('LIBEXECDIR', join_paths(px_prefix, get_option('libexecdir')))
- system_service_data.set('USER', get_option('dbus-system-user'))
- dbus_system_service = configure_file(
- input: 'org.libproxy.proxy-system.service.in',
- output: 'org.libproxy.proxy-system.service',
- configuration: system_service_data
- )
- install_data(dbus_system_service, rename : 'org.libproxy.proxy.service', install_dir : dbus_system_services_dir)
-
- dbus_config_data = configuration_data()
- dbus_config_data.set('daemon_user', get_option('dbus-system-user'))
- configure_file(
- input: 'org.libproxy.proxy.conf.in',
- output: 'org.libproxy.proxy.conf',
- configuration: dbus_config_data,
- install: true,
- install_dir: dbus_system_conf_dir
- )
-endif
diff --git a/src/backend/dbus/org.libproxy.proxy-system.service.in b/src/backend/dbus/org.libproxy.proxy-system.service.in
deleted file mode 100644
index 2af960b..0000000
--- a/src/backend/dbus/org.libproxy.proxy-system.service.in
+++ /dev/null
@@ -1,4 +0,0 @@
-[D-BUS Service]
-Name=org.libproxy.proxy
-Exec=@LIBEXECDIR@/proxyd --system
-User=@USER@
diff --git a/src/backend/dbus/org.libproxy.proxy.conf.in b/src/backend/dbus/org.libproxy.proxy.conf.in
deleted file mode 100644
index daa79f5..0000000
--- a/src/backend/dbus/org.libproxy.proxy.conf.in
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE busconfig PUBLIC
- "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-<busconfig>
-
- <!-- This configuration file specifies the required security policies
- for the libproxy to work. -->
-
- <!-- Only user @daemon_user@ can own the libproxy service -->
- <policy user="@daemon_user@">
- <allow own="org.libproxy.proxy"/>
- </policy>
-
- <!-- Allow anyone to call into the service - we'll reject callers using PolicyKit -->
- <policy context="default">
- <allow send_destination="org.libproxy.proxy"
- send_interface="org.freedesktop.DBus.Introspectable"/>
-
- <allow send_destination="org.libproxy.proxy"
- send_interface="org.freedesktop.DBus.Peer"/>
-
- <allow send_destination="org.libproxy.proxy"
- send_interface="org.freedesktop.DBus.Properties"/>
-
- <allow send_destination="org.libproxy.proxy"
- send_interface="org.libproxy.proxy"/>
- </policy>
-</busconfig> \ No newline at end of file
diff --git a/src/backend/dbus/org.libproxy.proxy.service.in b/src/backend/dbus/org.libproxy.proxy.service.in
deleted file mode 100644
index d1ac5f4..0000000
--- a/src/backend/dbus/org.libproxy.proxy.service.in
+++ /dev/null
@@ -1,3 +0,0 @@
-[D-BUS Service]
-Name=org.libproxy.proxy
-Exec=@LIBEXECDIR@/proxyd
diff --git a/src/backend/dbus/org.libproxy.proxy.xml b/src/backend/dbus/org.libproxy.proxy.xml
deleted file mode 100644
index bba9251..0000000
--- a/src/backend/dbus/org.libproxy.proxy.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" >
-<node>
- <interface name="org.libproxy.proxy">
- <method name="GetProxiesFor">
- <arg type='s' name='url' direction='in'/>
- <arg type='as' name='response' direction='out'/>
- <doc:doc>
- <doc:description>
- <doc:para>
- Get proxy servers for given url.
- </doc:para>
- </doc:description>
- </doc:doc>
- </method>
- </interface>
-</node>
diff --git a/src/backend/meson.build b/src/backend/meson.build
index b0b8de9..b25453a 100644
--- a/src/backend/meson.build
+++ b/src/backend/meson.build
@@ -34,9 +34,4 @@ px_backend_dep = declare_dependency(
dependencies: px_backend_deps
)
-subdir('dbus')
-subdir('plugins')
-
-summary({
- 'D-Bus Service' : build_dbus,
-}, section: 'Architecture') \ No newline at end of file
+subdir('plugins') \ No newline at end of file