aboutsummaryrefslogtreecommitdiff
path: root/src/mm-auth-provider.c
diff options
context:
space:
mode:
authorDan Williams <dan@ioncontrol.co>2025-04-29 20:54:36 -0500
committerDan Williams <dan@ioncontrol.co>2025-05-08 20:08:06 -0500
commitef5cee3ab578c2fde8ca6cc636f10acfdb79f123 (patch)
tree02510944a5782a9c4047234b747fdc02dd8f31c8 /src/mm-auth-provider.c
parent7262b46a82642b7232ef922b827d77626a93eec0 (diff)
auth-provider: move auth provider logic into each class
Rather than make all of them rely on MMBaseModem for it. This lets us disentangle dependencies for easier unit testing. For interfaces, rather than casting directly to MMBaseModem use intermediate interfaces (MMIfaceAuth and MMIfaceOpLock) that tests can fake out. Signed-off-by: Dan Williams <dan@ioncontrol.co>
Diffstat (limited to 'src/mm-auth-provider.c')
-rw-r--r--src/mm-auth-provider.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/mm-auth-provider.c b/src/mm-auth-provider.c
index 38ec04d3..2455da30 100644
--- a/src/mm-auth-provider.c
+++ b/src/mm-auth-provider.c
@@ -226,3 +226,40 @@ mm_auth_provider_class_init (MMAuthProviderClass *class)
}
MM_DEFINE_SINGLETON_GETTER (MMAuthProvider, mm_auth_provider_get, MM_TYPE_AUTH_PROVIDER)
+
+/*****************************************************************************/
+/* Auth interface */
+
+G_DEFINE_INTERFACE (MMIfaceAuth, mm_iface_auth, G_TYPE_OBJECT)
+
+void
+mm_iface_auth_authorize (MMIfaceAuth *self,
+ GDBusMethodInvocation *invocation,
+ const gchar *authorization,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_assert (MM_IFACE_AUTH_GET_IFACE (self)->authorize != NULL);
+
+ MM_IFACE_AUTH_GET_IFACE (self)->authorize (self,
+ invocation,
+ authorization,
+ callback,
+ user_data);
+}
+
+gboolean
+mm_iface_auth_authorize_finish (MMIfaceAuth *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ g_assert (MM_IFACE_AUTH_GET_IFACE (self)->authorize_finish != NULL);
+
+ return MM_IFACE_AUTH_GET_IFACE (self)->authorize_finish (self, res, error);
+}
+
+static void
+mm_iface_auth_default_init (MMIfaceAuthInterface *iface)
+{
+}
+