Merge branch 'add-flags' into 'master'
lib: Change allow_interactive_authorization bool to flags See merge request pwithnall/malcontent!6
This commit is contained in:
commit
fb1d43428b
|
@ -563,22 +563,21 @@ accounts_find_user_by_id (GDBusConnection *connection,
|
||||||
* @connection: (nullable): a #GDBusConnection to the system bus, or %NULL to
|
* @connection: (nullable): a #GDBusConnection to the system bus, or %NULL to
|
||||||
* use the default
|
* use the default
|
||||||
* @user_id: ID of the user to query, typically coming from getuid()
|
* @user_id: ID of the user to query, typically coming from getuid()
|
||||||
* @allow_interactive_authorization: %TRUE to allow interactive polkit
|
* @flags: flags to affect the behaviour of the call
|
||||||
* authorization dialogues to be displayed during the call; %FALSE otherwise
|
|
||||||
* @cancellable: (nullable): a #GCancellable, or %NULL
|
* @cancellable: (nullable): a #GCancellable, or %NULL
|
||||||
* @error: return location for a #GError, or %NULL
|
* @error: return location for a #GError, or %NULL
|
||||||
*
|
*
|
||||||
* Synchronous version of mct_get_app_filter_async().
|
* Synchronous version of mct_get_app_filter_async().
|
||||||
*
|
*
|
||||||
* Returns: (transfer full): app filter for the queried user
|
* Returns: (transfer full): app filter for the queried user
|
||||||
* Since: 0.2.0
|
* Since: 0.3.0
|
||||||
*/
|
*/
|
||||||
MctAppFilter *
|
MctAppFilter *
|
||||||
mct_get_app_filter (GDBusConnection *connection,
|
mct_get_app_filter (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
gboolean allow_interactive_authorization,
|
MctGetAppFilterFlags flags,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_autofree gchar *object_path = NULL;
|
g_autofree gchar *object_path = NULL;
|
||||||
g_autoptr(GVariant) result_variant = NULL;
|
g_autoptr(GVariant) result_variant = NULL;
|
||||||
|
@ -603,7 +602,7 @@ mct_get_app_filter (GDBusConnection *connection,
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
object_path = accounts_find_user_by_id (connection, user_id,
|
object_path = accounts_find_user_by_id (connection, user_id,
|
||||||
allow_interactive_authorization,
|
(flags & MCT_GET_APP_FILTER_FLAGS_INTERACTIVE),
|
||||||
cancellable, error);
|
cancellable, error);
|
||||||
if (object_path == NULL)
|
if (object_path == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -616,7 +615,7 @@ mct_get_app_filter (GDBusConnection *connection,
|
||||||
"GetAll",
|
"GetAll",
|
||||||
g_variant_new ("(s)", "com.endlessm.ParentalControls.AppFilter"),
|
g_variant_new ("(s)", "com.endlessm.ParentalControls.AppFilter"),
|
||||||
G_VARIANT_TYPE ("(a{sv})"),
|
G_VARIANT_TYPE ("(a{sv})"),
|
||||||
allow_interactive_authorization
|
(flags & MCT_GET_APP_FILTER_FLAGS_INTERACTIVE)
|
||||||
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
||||||
: G_DBUS_CALL_FLAGS_NONE,
|
: G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1, /* timeout, ms */
|
-1, /* timeout, ms */
|
||||||
|
@ -700,7 +699,7 @@ typedef struct
|
||||||
{
|
{
|
||||||
GDBusConnection *connection; /* (nullable) (owned) */
|
GDBusConnection *connection; /* (nullable) (owned) */
|
||||||
uid_t user_id;
|
uid_t user_id;
|
||||||
gboolean allow_interactive_authorization;
|
MctGetAppFilterFlags flags;
|
||||||
} GetAppFilterData;
|
} GetAppFilterData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -717,8 +716,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (GetAppFilterData, get_app_filter_data_free)
|
||||||
* @connection: (nullable): a #GDBusConnection to the system bus, or %NULL to
|
* @connection: (nullable): a #GDBusConnection to the system bus, or %NULL to
|
||||||
* use the default
|
* use the default
|
||||||
* @user_id: ID of the user to query, typically coming from getuid()
|
* @user_id: ID of the user to query, typically coming from getuid()
|
||||||
* @allow_interactive_authorization: %TRUE to allow interactive polkit
|
* @flags: flags to affect the behaviour of the call
|
||||||
* authorization dialogues to be displayed during the call; %FALSE otherwise
|
|
||||||
* @cancellable: (nullable): a #GCancellable, or %NULL
|
* @cancellable: (nullable): a #GCancellable, or %NULL
|
||||||
* @callback: a #GAsyncReadyCallback
|
* @callback: a #GAsyncReadyCallback
|
||||||
* @user_data: user data to pass to @callback
|
* @user_data: user data to pass to @callback
|
||||||
|
@ -733,12 +731,12 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (GetAppFilterData, get_app_filter_data_free)
|
||||||
* On failure, an #MctAppFilterError, a #GDBusError or a #GIOError will be
|
* On failure, an #MctAppFilterError, a #GDBusError or a #GIOError will be
|
||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
* Since: 0.2.0
|
* Since: 0.3.0
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mct_get_app_filter_async (GDBusConnection *connection,
|
mct_get_app_filter_async (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
gboolean allow_interactive_authorization,
|
MctGetAppFilterFlags flags,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
|
@ -755,7 +753,7 @@ mct_get_app_filter_async (GDBusConnection *connection,
|
||||||
data = g_new0 (GetAppFilterData, 1);
|
data = g_new0 (GetAppFilterData, 1);
|
||||||
data->connection = (connection != NULL) ? g_object_ref (connection) : NULL;
|
data->connection = (connection != NULL) ? g_object_ref (connection) : NULL;
|
||||||
data->user_id = user_id;
|
data->user_id = user_id;
|
||||||
data->allow_interactive_authorization = allow_interactive_authorization;
|
data->flags = flags;
|
||||||
g_task_set_task_data (task, g_steal_pointer (&data),
|
g_task_set_task_data (task, g_steal_pointer (&data),
|
||||||
(GDestroyNotify) get_app_filter_data_free);
|
(GDestroyNotify) get_app_filter_data_free);
|
||||||
|
|
||||||
|
@ -773,7 +771,7 @@ get_app_filter_thread_cb (GTask *task,
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
|
|
||||||
filter = mct_get_app_filter (data->connection, data->user_id,
|
filter = mct_get_app_filter (data->connection, data->user_id,
|
||||||
data->allow_interactive_authorization,
|
data->flags,
|
||||||
cancellable, &local_error);
|
cancellable, &local_error);
|
||||||
|
|
||||||
if (local_error != NULL)
|
if (local_error != NULL)
|
||||||
|
@ -810,23 +808,22 @@ mct_get_app_filter_finish (GAsyncResult *result,
|
||||||
* use the default
|
* use the default
|
||||||
* @user_id: ID of the user to set the filter for, typically coming from getuid()
|
* @user_id: ID of the user to set the filter for, typically coming from getuid()
|
||||||
* @app_filter: (transfer none): the app filter to set for the user
|
* @app_filter: (transfer none): the app filter to set for the user
|
||||||
* @allow_interactive_authorization: %TRUE to allow interactive polkit
|
* @flags: flags to affect the behaviour of the call
|
||||||
* authorization dialogues to be displayed during the call; %FALSE otherwise
|
|
||||||
* @cancellable: (nullable): a #GCancellable, or %NULL
|
* @cancellable: (nullable): a #GCancellable, or %NULL
|
||||||
* @error: return location for a #GError, or %NULL
|
* @error: return location for a #GError, or %NULL
|
||||||
*
|
*
|
||||||
* Synchronous version of mct_set_app_filter_async().
|
* Synchronous version of mct_set_app_filter_async().
|
||||||
*
|
*
|
||||||
* Returns: %TRUE on success, %FALSE otherwise
|
* Returns: %TRUE on success, %FALSE otherwise
|
||||||
* Since: 0.2.0
|
* Since: 0.3.0
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
mct_set_app_filter (GDBusConnection *connection,
|
mct_set_app_filter (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
MctAppFilter *app_filter,
|
MctAppFilter *app_filter,
|
||||||
gboolean allow_interactive_authorization,
|
MctSetAppFilterFlags flags,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
g_autofree gchar *object_path = NULL;
|
g_autofree gchar *object_path = NULL;
|
||||||
g_autoptr(GVariant) app_filter_variant = NULL;
|
g_autoptr(GVariant) app_filter_variant = NULL;
|
||||||
|
@ -851,7 +848,7 @@ mct_set_app_filter (GDBusConnection *connection,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
object_path = accounts_find_user_by_id (connection, user_id,
|
object_path = accounts_find_user_by_id (connection, user_id,
|
||||||
allow_interactive_authorization,
|
(flags & MCT_SET_APP_FILTER_FLAGS_INTERACTIVE),
|
||||||
cancellable, error);
|
cancellable, error);
|
||||||
if (object_path == NULL)
|
if (object_path == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -873,7 +870,7 @@ mct_set_app_filter (GDBusConnection *connection,
|
||||||
"AppFilter",
|
"AppFilter",
|
||||||
g_steal_pointer (&app_filter_variant)),
|
g_steal_pointer (&app_filter_variant)),
|
||||||
G_VARIANT_TYPE ("()"),
|
G_VARIANT_TYPE ("()"),
|
||||||
allow_interactive_authorization
|
(flags & MCT_SET_APP_FILTER_FLAGS_INTERACTIVE)
|
||||||
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
||||||
: G_DBUS_CALL_FLAGS_NONE,
|
: G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1, /* timeout, ms */
|
-1, /* timeout, ms */
|
||||||
|
@ -896,7 +893,7 @@ mct_set_app_filter (GDBusConnection *connection,
|
||||||
"OarsFilter",
|
"OarsFilter",
|
||||||
g_steal_pointer (&oars_filter_variant)),
|
g_steal_pointer (&oars_filter_variant)),
|
||||||
G_VARIANT_TYPE ("()"),
|
G_VARIANT_TYPE ("()"),
|
||||||
allow_interactive_authorization
|
(flags & MCT_SET_APP_FILTER_FLAGS_INTERACTIVE)
|
||||||
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
||||||
: G_DBUS_CALL_FLAGS_NONE,
|
: G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1, /* timeout, ms */
|
-1, /* timeout, ms */
|
||||||
|
@ -919,7 +916,7 @@ mct_set_app_filter (GDBusConnection *connection,
|
||||||
"AllowUserInstallation",
|
"AllowUserInstallation",
|
||||||
g_steal_pointer (&allow_user_installation_variant)),
|
g_steal_pointer (&allow_user_installation_variant)),
|
||||||
G_VARIANT_TYPE ("()"),
|
G_VARIANT_TYPE ("()"),
|
||||||
allow_interactive_authorization
|
(flags & MCT_SET_APP_FILTER_FLAGS_INTERACTIVE)
|
||||||
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
||||||
: G_DBUS_CALL_FLAGS_NONE,
|
: G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1, /* timeout, ms */
|
-1, /* timeout, ms */
|
||||||
|
@ -942,7 +939,7 @@ mct_set_app_filter (GDBusConnection *connection,
|
||||||
"AllowSystemInstallation",
|
"AllowSystemInstallation",
|
||||||
g_steal_pointer (&allow_system_installation_variant)),
|
g_steal_pointer (&allow_system_installation_variant)),
|
||||||
G_VARIANT_TYPE ("()"),
|
G_VARIANT_TYPE ("()"),
|
||||||
allow_interactive_authorization
|
(flags & MCT_SET_APP_FILTER_FLAGS_INTERACTIVE)
|
||||||
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
? G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION
|
||||||
: G_DBUS_CALL_FLAGS_NONE,
|
: G_DBUS_CALL_FLAGS_NONE,
|
||||||
-1, /* timeout, ms */
|
-1, /* timeout, ms */
|
||||||
|
@ -967,7 +964,7 @@ typedef struct
|
||||||
GDBusConnection *connection; /* (nullable) (owned) */
|
GDBusConnection *connection; /* (nullable) (owned) */
|
||||||
uid_t user_id;
|
uid_t user_id;
|
||||||
MctAppFilter *app_filter; /* (owned) */
|
MctAppFilter *app_filter; /* (owned) */
|
||||||
gboolean allow_interactive_authorization;
|
MctSetAppFilterFlags flags;
|
||||||
} SetAppFilterData;
|
} SetAppFilterData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -986,8 +983,7 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (SetAppFilterData, set_app_filter_data_free)
|
||||||
* use the default
|
* use the default
|
||||||
* @user_id: ID of the user to set the filter for, typically coming from getuid()
|
* @user_id: ID of the user to set the filter for, typically coming from getuid()
|
||||||
* @app_filter: (transfer none): the app filter to set for the user
|
* @app_filter: (transfer none): the app filter to set for the user
|
||||||
* @allow_interactive_authorization: %TRUE to allow interactive polkit
|
* @flags: flags to affect the behaviour of the call
|
||||||
* authorization dialogues to be displayed during the call; %FALSE otherwise
|
|
||||||
* @cancellable: (nullable): a #GCancellable, or %NULL
|
* @cancellable: (nullable): a #GCancellable, or %NULL
|
||||||
* @callback: a #GAsyncReadyCallback
|
* @callback: a #GAsyncReadyCallback
|
||||||
* @user_data: user data to pass to @callback
|
* @user_data: user data to pass to @callback
|
||||||
|
@ -1002,16 +998,16 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (SetAppFilterData, set_app_filter_data_free)
|
||||||
* On failure, an #MctAppFilterError, a #GDBusError or a #GIOError will be
|
* On failure, an #MctAppFilterError, a #GDBusError or a #GIOError will be
|
||||||
* returned. The user’s app filter settings will be left in an undefined state.
|
* returned. The user’s app filter settings will be left in an undefined state.
|
||||||
*
|
*
|
||||||
* Since: 0.2.0
|
* Since: 0.3.0
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
mct_set_app_filter_async (GDBusConnection *connection,
|
mct_set_app_filter_async (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
MctAppFilter *app_filter,
|
MctAppFilter *app_filter,
|
||||||
gboolean allow_interactive_authorization,
|
MctSetAppFilterFlags flags,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
g_autoptr(GTask) task = NULL;
|
g_autoptr(GTask) task = NULL;
|
||||||
g_autoptr(SetAppFilterData) data = NULL;
|
g_autoptr(SetAppFilterData) data = NULL;
|
||||||
|
@ -1028,7 +1024,7 @@ mct_set_app_filter_async (GDBusConnection *connection,
|
||||||
data->connection = (connection != NULL) ? g_object_ref (connection) : NULL;
|
data->connection = (connection != NULL) ? g_object_ref (connection) : NULL;
|
||||||
data->user_id = user_id;
|
data->user_id = user_id;
|
||||||
data->app_filter = mct_app_filter_ref (app_filter);
|
data->app_filter = mct_app_filter_ref (app_filter);
|
||||||
data->allow_interactive_authorization = allow_interactive_authorization;
|
data->flags = flags;
|
||||||
g_task_set_task_data (task, g_steal_pointer (&data),
|
g_task_set_task_data (task, g_steal_pointer (&data),
|
||||||
(GDestroyNotify) set_app_filter_data_free);
|
(GDestroyNotify) set_app_filter_data_free);
|
||||||
|
|
||||||
|
@ -1046,8 +1042,7 @@ set_app_filter_thread_cb (GTask *task,
|
||||||
g_autoptr(GError) local_error = NULL;
|
g_autoptr(GError) local_error = NULL;
|
||||||
|
|
||||||
success = mct_set_app_filter (data->connection, data->user_id,
|
success = mct_set_app_filter (data->connection, data->user_id,
|
||||||
data->app_filter,
|
data->app_filter, data->flags,
|
||||||
data->allow_interactive_authorization,
|
|
||||||
cancellable, &local_error);
|
cancellable, &local_error);
|
||||||
|
|
||||||
if (local_error != NULL)
|
if (local_error != NULL)
|
||||||
|
|
|
@ -76,6 +76,40 @@ typedef enum
|
||||||
MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
MCT_APP_FILTER_OARS_VALUE_INTENSE,
|
||||||
} MctAppFilterOarsValue;
|
} MctAppFilterOarsValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MctGetAppFilterFlags:
|
||||||
|
* @MCT_GET_APP_FILTER_FLAGS_NONE: No flags set.
|
||||||
|
* @MCT_GET_APP_FILTER_FLAGS_INTERACTIVE: Allow interactive polkit dialogs when
|
||||||
|
* requesting authorization.
|
||||||
|
*
|
||||||
|
* Flags to control the behaviour of mct_get_app_filter() and
|
||||||
|
* mct_get_app_filter_async().
|
||||||
|
*
|
||||||
|
* Since: 0.3.0
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
MCT_GET_APP_FILTER_FLAGS_NONE = 0,
|
||||||
|
MCT_GET_APP_FILTER_FLAGS_INTERACTIVE,
|
||||||
|
} MctGetAppFilterFlags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MctSetAppFilterFlags:
|
||||||
|
* @MCT_SET_APP_FILTER_FLAGS_NONE: No flags set.
|
||||||
|
* @MCT_SET_APP_FILTER_FLAGS_INTERACTIVE: Allow interactive polkit dialogs when
|
||||||
|
* requesting authorization.
|
||||||
|
*
|
||||||
|
* Flags to control the behaviour of mct_set_app_filter() and
|
||||||
|
* mct_set_app_filter_async().
|
||||||
|
*
|
||||||
|
* Since: 0.3.0
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
MCT_SET_APP_FILTER_FLAGS_NONE = 0,
|
||||||
|
MCT_SET_APP_FILTER_FLAGS_INTERACTIVE,
|
||||||
|
} MctSetAppFilterFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MctAppFilter:
|
* MctAppFilter:
|
||||||
*
|
*
|
||||||
|
@ -116,12 +150,12 @@ gboolean mct_app_filter_is_system_installation_allowed (MctAppFil
|
||||||
|
|
||||||
MctAppFilter *mct_get_app_filter (GDBusConnection *connection,
|
MctAppFilter *mct_get_app_filter (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
gboolean allow_interactive_authorization,
|
MctGetAppFilterFlags flags,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
void mct_get_app_filter_async (GDBusConnection *connection,
|
void mct_get_app_filter_async (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
gboolean allow_interactive_authorization,
|
MctGetAppFilterFlags flags,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
@ -131,13 +165,13 @@ MctAppFilter *mct_get_app_filter_finish (GAsyncResult *result,
|
||||||
gboolean mct_set_app_filter (GDBusConnection *connection,
|
gboolean mct_set_app_filter (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
MctAppFilter *app_filter,
|
MctAppFilter *app_filter,
|
||||||
gboolean allow_interactive_authorization,
|
MctSetAppFilterFlags flags,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
void mct_set_app_filter_async (GDBusConnection *connection,
|
void mct_set_app_filter_async (GDBusConnection *connection,
|
||||||
uid_t user_id,
|
uid_t user_id,
|
||||||
MctAppFilter *app_filter,
|
MctAppFilter *app_filter,
|
||||||
gboolean allow_interactive_authorization,
|
MctSetAppFilterFlags flags,
|
||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
|
@ -555,7 +555,8 @@ test_app_filter_bus_get (BusFixture *fixture,
|
||||||
|
|
||||||
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
MCT_GET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
async_result_cb, &result);
|
||||||
|
|
||||||
while (result == NULL)
|
while (result == NULL)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
|
@ -565,7 +566,8 @@ test_app_filter_bus_get (BusFixture *fixture,
|
||||||
{
|
{
|
||||||
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, &local_error);
|
MCT_GET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
&local_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert_no_error (local_error);
|
g_assert_no_error (local_error);
|
||||||
|
@ -608,7 +610,8 @@ test_app_filter_bus_get_whitelist (BusFixture *fixture,
|
||||||
|
|
||||||
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, &local_error);
|
MCT_GET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
&local_error);
|
||||||
|
|
||||||
g_assert_no_error (local_error);
|
g_assert_no_error (local_error);
|
||||||
g_assert_nonnull (app_filter);
|
g_assert_nonnull (app_filter);
|
||||||
|
@ -658,7 +661,8 @@ test_app_filter_bus_get_all_oars_values (BusFixture *fixture,
|
||||||
|
|
||||||
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, &local_error);
|
MCT_GET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
&local_error);
|
||||||
|
|
||||||
g_assert_no_error (local_error);
|
g_assert_no_error (local_error);
|
||||||
g_assert_nonnull (app_filter);
|
g_assert_nonnull (app_filter);
|
||||||
|
@ -705,7 +709,8 @@ test_app_filter_bus_get_defaults (BusFixture *fixture,
|
||||||
|
|
||||||
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
app_filter = mct_get_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, &local_error);
|
MCT_GET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
&local_error);
|
||||||
|
|
||||||
g_assert_no_error (local_error);
|
g_assert_no_error (local_error);
|
||||||
g_assert_nonnull (app_filter);
|
g_assert_nonnull (app_filter);
|
||||||
|
@ -736,7 +741,8 @@ test_app_filter_bus_get_error_invalid_user (BusFixture *fixture,
|
||||||
|
|
||||||
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->missing_uid,
|
fixture->missing_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
MCT_GET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
async_result_cb, &result);
|
||||||
|
|
||||||
/* Handle the FindUserById() call and claim the user doesn’t exist. */
|
/* Handle the FindUserById() call and claim the user doesn’t exist. */
|
||||||
gint64 user_id;
|
gint64 user_id;
|
||||||
|
@ -780,7 +786,8 @@ test_app_filter_bus_get_error_permission_denied (BusFixture *fixture,
|
||||||
|
|
||||||
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
MCT_GET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
async_result_cb, &result);
|
||||||
|
|
||||||
/* Handle the FindUserById() call. */
|
/* Handle the FindUserById() call. */
|
||||||
gint64 user_id;
|
gint64 user_id;
|
||||||
|
@ -835,7 +842,8 @@ test_app_filter_bus_get_error_permission_denied_missing (BusFixture *fixture,
|
||||||
|
|
||||||
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
MCT_GET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
async_result_cb, &result);
|
||||||
|
|
||||||
/* Handle the FindUserById() call. */
|
/* Handle the FindUserById() call. */
|
||||||
gint64 user_id;
|
gint64 user_id;
|
||||||
|
@ -888,7 +896,8 @@ test_app_filter_bus_get_error_unknown (BusFixture *fixture,
|
||||||
|
|
||||||
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_get_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid,
|
fixture->valid_uid,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
MCT_GET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
async_result_cb, &result);
|
||||||
|
|
||||||
/* Handle the FindUserById() call and return a bogus error. */
|
/* Handle the FindUserById() call and return a bogus error. */
|
||||||
gint64 user_id;
|
gint64 user_id;
|
||||||
|
@ -1068,7 +1077,8 @@ test_app_filter_bus_set (BusFixture *fixture,
|
||||||
|
|
||||||
mct_set_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_set_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
MCT_SET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
async_result_cb, &result);
|
||||||
|
|
||||||
while (result == NULL)
|
while (result == NULL)
|
||||||
g_main_context_iteration (NULL, TRUE);
|
g_main_context_iteration (NULL, TRUE);
|
||||||
|
@ -1078,7 +1088,8 @@ test_app_filter_bus_set (BusFixture *fixture,
|
||||||
{
|
{
|
||||||
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, &local_error);
|
MCT_SET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
&local_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_assert_no_error (local_error);
|
g_assert_no_error (local_error);
|
||||||
|
@ -1106,7 +1117,8 @@ test_app_filter_bus_set_error_invalid_user (BusFixture *fixture,
|
||||||
|
|
||||||
mct_set_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
mct_set_app_filter_async (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->missing_uid, app_filter,
|
fixture->missing_uid, app_filter,
|
||||||
FALSE, NULL, async_result_cb, &result);
|
MCT_SET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
async_result_cb, &result);
|
||||||
|
|
||||||
/* Handle the FindUserById() call and claim the user doesn’t exist. */
|
/* Handle the FindUserById() call and claim the user doesn’t exist. */
|
||||||
gint64 user_id;
|
gint64 user_id;
|
||||||
|
@ -1160,7 +1172,8 @@ test_app_filter_bus_set_error_permission_denied (BusFixture *fixture,
|
||||||
|
|
||||||
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, &local_error);
|
MCT_SET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
&local_error);
|
||||||
|
|
||||||
g_assert_error (local_error,
|
g_assert_error (local_error,
|
||||||
MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_PERMISSION_DENIED);
|
MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_PERMISSION_DENIED);
|
||||||
|
@ -1197,7 +1210,8 @@ test_app_filter_bus_set_error_unknown (BusFixture *fixture,
|
||||||
|
|
||||||
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, &local_error);
|
MCT_SET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
&local_error);
|
||||||
|
|
||||||
g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR);
|
g_assert_error (local_error, G_IO_ERROR, G_IO_ERROR_DBUS_ERROR);
|
||||||
g_assert_false (success);
|
g_assert_false (success);
|
||||||
|
@ -1239,7 +1253,8 @@ test_app_filter_bus_set_error_invalid_property (BusFixture *fixture,
|
||||||
|
|
||||||
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
success = mct_set_app_filter (gt_dbus_queue_get_client_connection (fixture->queue),
|
||||||
fixture->valid_uid, app_filter,
|
fixture->valid_uid, app_filter,
|
||||||
FALSE, NULL, &local_error);
|
MCT_SET_APP_FILTER_FLAGS_NONE, NULL,
|
||||||
|
&local_error);
|
||||||
|
|
||||||
g_assert_error (local_error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS);
|
g_assert_error (local_error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS);
|
||||||
g_assert_false (success);
|
g_assert_false (success);
|
||||||
|
|
|
@ -37,9 +37,14 @@ def __get_app_filter(user_id, interactive):
|
||||||
|
|
||||||
If `interactive` is `True`, interactive polkit authorisation dialogues will
|
If `interactive` is `True`, interactive polkit authorisation dialogues will
|
||||||
be allowed. An exception will be raised on failure."""
|
be allowed. An exception will be raised on failure."""
|
||||||
|
if interactive:
|
||||||
|
flags = Malcontent.GetAppFilterFlags.INTERACTIVE
|
||||||
|
else:
|
||||||
|
flags = Malcontent.GetAppFilterFlags.NONE
|
||||||
|
|
||||||
return Malcontent.get_app_filter(
|
return Malcontent.get_app_filter(
|
||||||
connection=None, user_id=user_id,
|
connection=None, user_id=user_id,
|
||||||
allow_interactive_authorization=interactive, cancellable=None)
|
flags=flags, cancellable=None)
|
||||||
|
|
||||||
|
|
||||||
def __get_app_filter_or_error(user_id, interactive):
|
def __get_app_filter_or_error(user_id, interactive):
|
||||||
|
@ -58,9 +63,14 @@ def __set_app_filter(user_id, app_filter, interactive):
|
||||||
|
|
||||||
If `interactive` is `True`, interactive polkit authorisation dialogues will
|
If `interactive` is `True`, interactive polkit authorisation dialogues will
|
||||||
be allowed. An exception will be raised on failure."""
|
be allowed. An exception will be raised on failure."""
|
||||||
|
if interactive:
|
||||||
|
flags = Malcontent.GetAppFilterFlags.INTERACTIVE
|
||||||
|
else:
|
||||||
|
flags = Malcontent.GetAppFilterFlags.NONE
|
||||||
|
|
||||||
Malcontent.set_app_filter(
|
Malcontent.set_app_filter(
|
||||||
connection=None, user_id=user_id, app_filter=app_filter,
|
connection=None, user_id=user_id, app_filter=app_filter,
|
||||||
allow_interactive_authorization=interactive, cancellable=None)
|
flags=flags, cancellable=None)
|
||||||
|
|
||||||
|
|
||||||
def __set_app_filter_or_error(user_id, app_filter, interactive):
|
def __set_app_filter_or_error(user_id, app_filter, interactive):
|
||||||
|
|
Loading…
Reference in New Issue