printers: Convert unnecessary use of GDBusProxy to using GDBusConnection directly
This commit is contained in:
parent
7dd5ae6b94
commit
bda149fdd0
2 changed files with 145 additions and 187 deletions
|
@ -320,7 +320,7 @@ devices_get_cb (GObject *source_object,
|
||||||
PpNewPrinterDialog *pp = user_data;
|
PpNewPrinterDialog *pp = user_data;
|
||||||
cups_dest_t *dests;
|
cups_dest_t *dests;
|
||||||
GHashTable *devices = NULL;
|
GHashTable *devices = NULL;
|
||||||
GDBusProxy *proxy;
|
GDBusConnection *bus;
|
||||||
GtkWidget *widget = NULL;
|
GtkWidget *widget = NULL;
|
||||||
GVariant *dg_output = NULL;
|
GVariant *dg_output = NULL;
|
||||||
gboolean already_present;
|
gboolean already_present;
|
||||||
|
@ -480,16 +480,8 @@ devices_get_cb (GObject *source_object,
|
||||||
* Show devices with device-id.
|
* Show devices with device-id.
|
||||||
* Other preferences should apply here.
|
* Other preferences should apply here.
|
||||||
*/
|
*/
|
||||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
if (bus)
|
||||||
NULL,
|
|
||||||
SCP_BUS,
|
|
||||||
SCP_PATH,
|
|
||||||
SCP_IFACE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (proxy)
|
|
||||||
{
|
{
|
||||||
GVariantBuilder device_list;
|
GVariantBuilder device_list;
|
||||||
GVariantBuilder device_hash;
|
GVariantBuilder device_hash;
|
||||||
|
@ -530,13 +522,17 @@ devices_get_cb (GObject *source_object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output = g_dbus_proxy_call_sync (proxy,
|
output = g_dbus_connection_call_sync (bus,
|
||||||
"GroupPhysicalDevices",
|
SCP_BUS,
|
||||||
g_variant_new ("(v)", g_variant_builder_end (&device_list)),
|
SCP_PATH,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
SCP_IFACE,
|
||||||
60000,
|
"GroupPhysicalDevices",
|
||||||
NULL,
|
g_variant_new ("(v)", g_variant_builder_end (&device_list)),
|
||||||
&error);
|
NULL,
|
||||||
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
60000,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
|
||||||
if (output && g_variant_n_children (output) == 1)
|
if (output && g_variant_n_children (output) == 1)
|
||||||
{
|
{
|
||||||
|
@ -564,12 +560,12 @@ devices_get_cb (GObject *source_object,
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
g_variant_unref (output);
|
g_variant_unref (output);
|
||||||
g_object_unref (proxy);
|
g_object_unref (bus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
if (proxy == NULL ||
|
if (bus == NULL ||
|
||||||
(error->domain == G_DBUS_ERROR &&
|
(error->domain == G_DBUS_ERROR &&
|
||||||
(error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
|
(error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
|
||||||
error->code == G_DBUS_ERROR_UNKNOWN_METHOD)))
|
error->code == G_DBUS_ERROR_UNKNOWN_METHOD)))
|
||||||
|
@ -764,38 +760,33 @@ static void
|
||||||
service_enable (gchar *service_name,
|
service_enable (gchar *service_name,
|
||||||
gint service_timeout)
|
gint service_timeout)
|
||||||
{
|
{
|
||||||
GDBusProxy *proxy;
|
GDBusConnection *bus;
|
||||||
GVariant *output = NULL;
|
GVariant *output = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
if (!bus)
|
||||||
NULL,
|
|
||||||
FIREWALLD_BUS,
|
|
||||||
FIREWALLD_PATH,
|
|
||||||
FIREWALLD_IFACE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (!proxy)
|
|
||||||
{
|
{
|
||||||
g_warning ("%s", error->message);
|
g_warning ("%s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output = g_dbus_connection_call_sync (bus,
|
||||||
|
FIREWALLD_BUS,
|
||||||
|
FIREWALLD_PATH,
|
||||||
|
FIREWALLD_IFACE,
|
||||||
|
"enableService",
|
||||||
|
g_variant_new ("(si)",
|
||||||
|
service_name,
|
||||||
|
service_timeout),
|
||||||
|
NULL,
|
||||||
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
60000,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
|
||||||
output = g_dbus_proxy_call_sync (proxy,
|
g_object_unref (bus);
|
||||||
"enableService",
|
|
||||||
g_variant_new ("(si)",
|
|
||||||
service_name,
|
|
||||||
service_timeout),
|
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
|
||||||
60000,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
g_object_unref (proxy);
|
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
|
@ -811,35 +802,31 @@ service_enable (gchar *service_name,
|
||||||
static void
|
static void
|
||||||
service_disable (gchar *service_name)
|
service_disable (gchar *service_name)
|
||||||
{
|
{
|
||||||
GDBusProxy *proxy;
|
GDBusConnection *bus;
|
||||||
GVariant *output = NULL;
|
GVariant *output = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
if (!bus)
|
||||||
NULL,
|
|
||||||
FIREWALLD_BUS,
|
|
||||||
FIREWALLD_PATH,
|
|
||||||
FIREWALLD_IFACE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (!proxy)
|
|
||||||
{
|
{
|
||||||
g_warning ("%s", error->message);
|
g_warning ("%s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
output = g_dbus_proxy_call_sync (proxy,
|
output = g_dbus_connection_call_sync (bus,
|
||||||
"disableService",
|
FIREWALLD_BUS,
|
||||||
g_variant_new ("(s)", service_name),
|
FIREWALLD_PATH,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
FIREWALLD_IFACE,
|
||||||
60000,
|
"disableService",
|
||||||
NULL,
|
g_variant_new ("(s)", service_name),
|
||||||
&error);
|
NULL,
|
||||||
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
60000,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
|
||||||
g_object_unref (proxy);
|
g_object_unref (bus);
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
|
@ -855,36 +842,32 @@ service_disable (gchar *service_name)
|
||||||
static gboolean
|
static gboolean
|
||||||
service_enabled (gchar *service_name)
|
service_enabled (gchar *service_name)
|
||||||
{
|
{
|
||||||
GDBusProxy *proxy;
|
GDBusConnection *bus;
|
||||||
GVariant *output = NULL;
|
GVariant *output = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gint query_result = 0;
|
gint query_result = 0;
|
||||||
|
|
||||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
if (!bus)
|
||||||
NULL,
|
|
||||||
FIREWALLD_BUS,
|
|
||||||
FIREWALLD_PATH,
|
|
||||||
FIREWALLD_IFACE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (!proxy)
|
|
||||||
{
|
{
|
||||||
g_warning ("%s", error->message);
|
g_warning ("%s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
output = g_dbus_proxy_call_sync (proxy,
|
output = g_dbus_connection_call_sync (bus,
|
||||||
"queryService",
|
FIREWALLD_BUS,
|
||||||
g_variant_new ("(s)", service_name),
|
FIREWALLD_PATH,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
FIREWALLD_IFACE,
|
||||||
60000,
|
"queryService",
|
||||||
NULL,
|
g_variant_new ("(s)", service_name),
|
||||||
&error);
|
G_VARIANT_TYPE ("(i)"),
|
||||||
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
60000,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
|
||||||
g_object_unref (proxy);
|
g_object_unref (bus);
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
|
@ -911,36 +894,32 @@ dbus_method_available (gchar *name,
|
||||||
gchar *iface,
|
gchar *iface,
|
||||||
gchar *method)
|
gchar *method)
|
||||||
{
|
{
|
||||||
GDBusProxy *proxy;
|
GDBusConnection *bus;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GVariant *output = NULL;
|
GVariant *output = NULL;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
|
||||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
|
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
if (!bus)
|
||||||
NULL,
|
|
||||||
name,
|
|
||||||
path,
|
|
||||||
iface,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (!proxy)
|
|
||||||
{
|
{
|
||||||
g_warning ("%s", error->message);
|
g_warning ("%s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
output = g_dbus_proxy_call_sync (proxy,
|
output = g_dbus_connection_call_sync (bus,
|
||||||
method,
|
name,
|
||||||
NULL,
|
path,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
iface,
|
||||||
60000,
|
method,
|
||||||
NULL,
|
NULL,
|
||||||
&error);
|
NULL,
|
||||||
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
60000,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
|
||||||
g_object_unref (proxy);
|
g_object_unref (bus);
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
|
@ -1917,7 +1896,6 @@ new_printer_add_button_cb (GtkButton *button,
|
||||||
|
|
||||||
if (ppd_file_name)
|
if (ppd_file_name)
|
||||||
{
|
{
|
||||||
GDBusProxy *proxy;
|
|
||||||
GVariant *output;
|
GVariant *output;
|
||||||
GVariant *array;
|
GVariant *array;
|
||||||
GList *executables = NULL;
|
GList *executables = NULL;
|
||||||
|
@ -1925,25 +1903,21 @@ new_printer_add_button_cb (GtkButton *button,
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
|
|
||||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
if (bus)
|
||||||
NULL,
|
|
||||||
SCP_BUS,
|
|
||||||
SCP_PATH,
|
|
||||||
SCP_IFACE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (proxy)
|
|
||||||
{
|
{
|
||||||
output = g_dbus_proxy_call_sync (proxy,
|
output = g_dbus_connection_call_sync (bus,
|
||||||
"MissingExecutables",
|
SCP_BUS,
|
||||||
g_variant_new ("(s)", ppd_file_name),
|
SCP_PATH,
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
SCP_IFACE,
|
||||||
60000,
|
"MissingExecutables",
|
||||||
NULL,
|
g_variant_new ("(s)", ppd_file_name),
|
||||||
&error);
|
NULL,
|
||||||
g_object_unref (proxy);
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
60000,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
g_object_unref (bus);
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
|
@ -1966,7 +1940,7 @@ new_printer_add_button_cb (GtkButton *button,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxy == NULL ||
|
if (bus == NULL ||
|
||||||
(error &&
|
(error &&
|
||||||
error->domain == G_DBUS_ERROR &&
|
error->domain == G_DBUS_ERROR &&
|
||||||
(error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
|
(error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
|
||||||
|
@ -1982,30 +1956,26 @@ DBus method \"MissingExecutables\" to find missing executables and filters.");
|
||||||
|
|
||||||
if (executables)
|
if (executables)
|
||||||
{
|
{
|
||||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
if (bus)
|
||||||
NULL,
|
|
||||||
PACKAGE_KIT_BUS,
|
|
||||||
PACKAGE_KIT_PATH,
|
|
||||||
PACKAGE_KIT_QUERY_IFACE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (proxy)
|
|
||||||
{
|
{
|
||||||
GList *exec_iter;
|
GList *exec_iter;
|
||||||
|
|
||||||
for (exec_iter = executables; exec_iter; exec_iter = exec_iter->next)
|
for (exec_iter = executables; exec_iter; exec_iter = exec_iter->next)
|
||||||
{
|
{
|
||||||
output = g_dbus_proxy_call_sync (proxy,
|
output = g_dbus_connection_call_sync (bus,
|
||||||
"SearchFile",
|
PACKAGE_KIT_BUS,
|
||||||
g_variant_new ("(ss)",
|
PACKAGE_KIT_PATH,
|
||||||
(gchar *) exec_iter->data,
|
PACKAGE_KIT_QUERY_IFACE,
|
||||||
""),
|
"SearchFile",
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
g_variant_new ("(ss)",
|
||||||
60000,
|
(gchar *) exec_iter->data,
|
||||||
NULL,
|
""),
|
||||||
&error);
|
G_VARIANT_TYPE ("(bs)"),
|
||||||
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
60000,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
|
@ -2027,7 +1997,7 @@ DBus method \"MissingExecutables\" to find missing executables and filters.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_unref (proxy);
|
g_object_unref (bus);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2043,16 +2013,8 @@ DBus method \"MissingExecutables\" to find missing executables and filters.");
|
||||||
|
|
||||||
if (packages)
|
if (packages)
|
||||||
{
|
{
|
||||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
if (bus)
|
||||||
NULL,
|
|
||||||
PACKAGE_KIT_BUS,
|
|
||||||
PACKAGE_KIT_PATH,
|
|
||||||
PACKAGE_KIT_MODIFY_IFACE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (proxy)
|
|
||||||
{
|
{
|
||||||
GVariantBuilder array_builder;
|
GVariantBuilder array_builder;
|
||||||
GList *pkg_iter;
|
GList *pkg_iter;
|
||||||
|
@ -2069,17 +2031,21 @@ DBus method \"MissingExecutables\" to find missing executables and filters.");
|
||||||
window_id = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (pp->dialog))),
|
window_id = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (pp->dialog))),
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
output = g_dbus_proxy_call_sync (proxy,
|
output = g_dbus_connection_call_sync (bus,
|
||||||
"InstallPackageNames",
|
PACKAGE_KIT_BUS,
|
||||||
g_variant_new ("(uass)",
|
PACKAGE_KIT_PATH,
|
||||||
window_id,
|
PACKAGE_KIT_MODIFY_IFACE,
|
||||||
&array_builder,
|
"InstallPackageNames",
|
||||||
"hide-finished"),
|
g_variant_new ("(uass)",
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
window_id,
|
||||||
60000,
|
&array_builder,
|
||||||
NULL,
|
"hide-finished"),
|
||||||
&error);
|
NULL,
|
||||||
g_object_unref (proxy);
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
|
60000,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
g_object_unref (bus);
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
{
|
{
|
||||||
|
|
|
@ -771,8 +771,7 @@ get_ppd_name (gchar *device_id,
|
||||||
gchar *device_make_and_model,
|
gchar *device_make_and_model,
|
||||||
gchar *device_uri)
|
gchar *device_uri)
|
||||||
{
|
{
|
||||||
GDBusProxy *proxy;
|
GDBusConnection *bus;
|
||||||
GVariant *input;
|
|
||||||
GVariant *output;
|
GVariant *output;
|
||||||
GVariant *array;
|
GVariant *array;
|
||||||
GVariant *tuple;
|
GVariant *tuple;
|
||||||
|
@ -787,29 +786,23 @@ get_ppd_name (gchar *device_id,
|
||||||
"generic",
|
"generic",
|
||||||
"none"};
|
"none"};
|
||||||
|
|
||||||
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
|
bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
if (bus)
|
||||||
NULL,
|
|
||||||
SCP_BUS,
|
|
||||||
SCP_PATH,
|
|
||||||
SCP_IFACE,
|
|
||||||
NULL,
|
|
||||||
&error);
|
|
||||||
|
|
||||||
if (proxy)
|
|
||||||
{
|
{
|
||||||
input = g_variant_new ("(sss)",
|
output = g_dbus_connection_call_sync (bus,
|
||||||
device_id ? device_id : "",
|
SCP_BUS,
|
||||||
device_make_and_model ? device_make_and_model : "",
|
SCP_PATH,
|
||||||
device_uri ? device_uri : "");
|
SCP_IFACE,
|
||||||
|
"GetBestDrivers",
|
||||||
output = g_dbus_proxy_call_sync (proxy,
|
g_variant_new ("(sss)",
|
||||||
"GetBestDrivers",
|
device_id ? device_id : "",
|
||||||
input,
|
device_make_and_model ? device_make_and_model : "",
|
||||||
G_DBUS_CALL_FLAGS_NONE,
|
device_uri ? device_uri : ""),
|
||||||
60000,
|
NULL,
|
||||||
NULL,
|
G_DBUS_CALL_FLAGS_NONE,
|
||||||
&error);
|
60000,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
|
||||||
if (output && g_variant_n_children (output) >= 1)
|
if (output && g_variant_n_children (output) >= 1)
|
||||||
{
|
{
|
||||||
|
@ -853,11 +846,10 @@ get_ppd_name (gchar *device_id,
|
||||||
|
|
||||||
if (output)
|
if (output)
|
||||||
g_variant_unref (output);
|
g_variant_unref (output);
|
||||||
g_variant_unref (input);
|
g_object_unref (bus);
|
||||||
g_object_unref (proxy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxy == NULL ||
|
if (bus == NULL ||
|
||||||
(error &&
|
(error &&
|
||||||
error->domain == G_DBUS_ERROR &&
|
error->domain == G_DBUS_ERROR &&
|
||||||
(error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
|
(error->code == G_DBUS_ERROR_SERVICE_UNKNOWN ||
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue