libsysprof-ui: allow restricting remote proxy

This commit is contained in:
Christian Hergert
2019-05-19 22:36:20 -07:00
parent 6e7ef3d52d
commit c368da09de
9 changed files with 196 additions and 158 deletions

View File

@ -627,6 +627,7 @@ sysprof_helpers_authorize_finish (SysprofHelpers *self,
gboolean
sysprof_helpers_get_process_info (SysprofHelpers *self,
const gchar *attributes,
gboolean no_proxy,
GCancellable *cancellable,
GVariant **info,
GError **error)
@ -636,6 +637,12 @@ sysprof_helpers_get_process_info (SysprofHelpers *self,
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
g_assert (info != NULL);
if (no_proxy)
{
*info = helpers_get_process_info (attributes);
return TRUE;
}
return ipc_service_call_get_process_info_sync (self->proxy, attributes, info, cancellable, error);
}

View File

@ -75,6 +75,7 @@ gboolean sysprof_helpers_get_proc_file_finish (SysprofHelpers
GError **error);
gboolean sysprof_helpers_get_process_info (SysprofHelpers *self,
const gchar *attributes,
gboolean no_proxy,
GCancellable *cancellable,
GVariant **info,
GError **error);

View File

@ -32,8 +32,9 @@
struct _SysprofProcessModel
{
GObject parent_instance;
guint reload_source;
GPtrArray *items;
guint reload_source;
guint no_proxy : 1;
};
static void list_model_iface_init (GListModelInterface *iface);
@ -181,6 +182,7 @@ sysprof_process_model_reload_worker (GTask *task,
gpointer task_data,
GCancellable *cancellable)
{
SysprofProcessModel *self = source_object;
SysprofHelpers *helpers = sysprof_helpers_get_default ();
g_autoptr(GPtrArray) ret = NULL;
g_autoptr(GVariant) info = NULL;
@ -190,7 +192,7 @@ sysprof_process_model_reload_worker (GTask *task,
ret = g_ptr_array_new_with_free_func (g_object_unref);
if (sysprof_helpers_get_process_info (helpers, "pid,cmdline,comm", NULL, &info, NULL))
if (sysprof_helpers_get_process_info (helpers, "pid,cmdline,comm", self->no_proxy, NULL, &info, NULL))
{
gsize n_children = g_variant_n_children (info);
@ -294,3 +296,12 @@ list_model_iface_init (GListModelInterface *iface)
iface->get_n_items = sysprof_process_model_get_n_items;
iface->get_item = sysprof_process_model_get_item;
}
void
sysprof_process_model_set_no_proxy (SysprofProcessModel *self,
gboolean no_proxy)
{
g_return_if_fail (SYSPROF_IS_PROCESS_MODEL (self));
self->no_proxy = !!no_proxy;
}

View File

@ -38,6 +38,9 @@ G_DECLARE_FINAL_TYPE (SysprofProcessModel, sysprof_process_model, SYSPROF, PROCE
SYSPROF_AVAILABLE_IN_ALL
SysprofProcessModel *sysprof_process_model_new (void);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_process_model_set_no_proxy (SysprofProcessModel *self,
gboolean no_proxy);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_process_model_reload (SysprofProcessModel *self);
SYSPROF_AVAILABLE_IN_ALL
void sysprof_process_model_queue_reload (SysprofProcessModel *self);