Branch data Line data Source code
1 : : /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
2 : : *
3 : : * Copyright 2025 GNOME Foundation, Inc.
4 : : *
5 : : * SPDX-License-Identifier: LGPL-2.1-or-later
6 : : *
7 : : * This library is free software; you can redistribute it and/or
8 : : * modify it under the terms of the GNU Lesser General Public
9 : : * License as published by the Free Software Foundation; either
10 : : * version 2.1 of the License, or (at your option) any later version.
11 : : *
12 : : * This library is distributed in the hope that it will be useful,
13 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 : : * Lesser General Public License for more details.
16 : : *
17 : : * You should have received a copy of the GNU Lesser General Public
18 : : * License along with this library; if not, write to the Free Software
19 : : * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 : : *
21 : : * Authors:
22 : : * - Philip Withnall <pwithnall@gnome.org>
23 : : */
24 : :
25 : : #pragma once
26 : :
27 : : #include <gio/gio.h>
28 : : #include <glib.h>
29 : : #include <glib-object.h>
30 : : #include <libmalcontent/user.h>
31 : :
32 : : G_BEGIN_DECLS
33 : :
34 : : #define MCT_TYPE_USER_MANAGER mct_user_manager_get_type ()
35 [ - + + - : 13 : G_DECLARE_FINAL_TYPE (MctUserManager, mct_user_manager, MCT, USER_MANAGER, GObject)
+ - ][ + - ]
36 : :
37 : : MctUserManager *mct_user_manager_new (GDBusConnection *connection);
38 : :
39 : : void mct_user_manager_load_async (MctUserManager *self,
40 : : GCancellable *cancellable,
41 : : GAsyncReadyCallback callback,
42 : : void *user_data);
43 : : gboolean mct_user_manager_load_finish (MctUserManager *self,
44 : : GAsyncResult *result,
45 : : GError **error);
46 : :
47 : : gboolean mct_user_manager_get_is_loaded (MctUserManager *self);
48 : :
49 : : void mct_user_manager_get_user_by_uid_async (MctUserManager *self,
50 : : uid_t uid,
51 : : GCancellable *cancellable,
52 : : GAsyncReadyCallback callback,
53 : : void *user_data);
54 : : MctUser *mct_user_manager_get_user_by_uid_finish (MctUserManager *self,
55 : : GAsyncResult *result,
56 : : GError **error);
57 : : void mct_user_manager_get_user_by_username_async (MctUserManager *self,
58 : : const char *username,
59 : : GCancellable *cancellable,
60 : : GAsyncReadyCallback callback,
61 : : void *user_data);
62 : : MctUser *mct_user_manager_get_user_by_username_finish (MctUserManager *self,
63 : : GAsyncResult *result,
64 : : GError **error);
65 : :
66 : : void mct_user_manager_get_family_members_for_user_async (MctUserManager *self,
67 : : MctUser *user,
68 : : GCancellable *cancellable,
69 : : GAsyncReadyCallback callback,
70 : : void *user_data);
71 : : MctUser **mct_user_manager_get_family_members_for_user_finish (MctUserManager *self,
72 : : GAsyncResult *result,
73 : : size_t *out_len,
74 : : GError **error);
75 : :
76 : : void mct_user_manager_get_all_users_async (MctUserManager *self,
77 : : GCancellable *cancellable,
78 : : GAsyncReadyCallback callback,
79 : : void *user_data);
80 : : MctUser **mct_user_manager_get_all_users_finish (MctUserManager *self,
81 : : GAsyncResult *result,
82 : : size_t *out_len,
83 : : GError **error);
84 : :
85 : : /**
86 : : * MctUserArray:
87 : : *
88 : : * Convenience type to allow use of `g_autoptr()` with arrays of
89 : : * [class@Malcontent.User].
90 : : *
91 : : * Use it as:
92 : : * ```c
93 : : * g_autoptr(MctUserArray) users = mct_user_manager_get_family_members_for_user (…);
94 : : * ```
95 : : *
96 : : * Since: 0.14.0
97 : : */
98 : : typedef MctUser* MctUserArray;
99 : :
100 : : /**
101 : : * mct_user_array_free:
102 : : * @users: (transfer full) (array zero-terminated=1): array of users
103 : : *
104 : : * Convenience free function for arrays of [class@Malcontent.User].
105 : : *
106 : : * See [type@Malcontent.UserArray].
107 : : *
108 : : * Since: 0.14.0
109 : : */
110 : : static inline void
111 : 0 : mct_user_array_free (MctUser **users)
112 : : {
113 : : size_t i;
114 : :
115 [ # # ]: 0 : if (users == NULL)
116 : 0 : return;
117 : :
118 [ # # ]: 0 : for (i = 0; users[i] != NULL; i++)
119 : 0 : g_object_unref (users[i]);
120 : 0 : g_free (users);
121 : : }
122 : :
123 [ # # ]: 0 : G_DEFINE_AUTOPTR_CLEANUP_FUNC (MctUserArray, mct_user_array_free)
124 : :
125 : : G_END_DECLS
|