aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/Makefile.am4
-rw-r--r--plugins/option/mm-broadband-modem-hso.c10
-rw-r--r--plugins/option/mm-broadband-modem-option.c10
-rw-r--r--plugins/option/mm-shared-option.c77
-rw-r--r--plugins/option/mm-shared-option.h49
-rw-r--r--plugins/option/mm-sim-option.c84
-rw-r--r--plugins/option/mm-sim-option.h51
7 files changed, 285 insertions, 0 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 0ccde202..f0095516 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -228,6 +228,10 @@ if WITH_SHARED_OPTION
pkglib_LTLIBRARIES += libmm-shared-option.la
libmm_shared_option_la_SOURCES = \
option/mm-shared.c \
+ option/mm-shared-option.h \
+ option/mm-shared-option.c \
+ option/mm-sim-option.c \
+ option/mm-sim-option.h \
option/mm-broadband-modem-option.c \
option/mm-broadband-modem-option.h \
$(NULL)
diff --git a/plugins/option/mm-broadband-modem-hso.c b/plugins/option/mm-broadband-modem-hso.c
index e20cd9e7..a2cc1770 100644
--- a/plugins/option/mm-broadband-modem-hso.c
+++ b/plugins/option/mm-broadband-modem-hso.c
@@ -34,7 +34,9 @@
#include "mm-broadband-modem-hso.h"
#include "mm-broadband-bearer-hso.h"
#include "mm-bearer-list.h"
+#include "mm-shared-option.h"
+static void shared_option_init (MMSharedOption *iface);
static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
static void iface_modem_location_init (MMIfaceModemLocation *iface);
@@ -43,6 +45,7 @@ static MMIfaceModem3gpp *iface_modem_3gpp_parent;
static MMIfaceModemLocation *iface_modem_location_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemHso, mm_broadband_modem_hso, MM_TYPE_BROADBAND_MODEM_OPTION, 0,
+ G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_OPTION, shared_option_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init));
@@ -729,8 +732,15 @@ mm_broadband_modem_hso_init (MMBroadbandModemHso *self)
}
static void
+shared_option_init (MMSharedOption *iface)
+{
+}
+
+static void
iface_modem_init (MMIfaceModem *iface)
{
+ iface->create_sim = mm_shared_option_create_sim;
+ iface->create_sim_finish = mm_shared_option_create_sim_finish;
iface->create_bearer = modem_create_bearer;
iface->create_bearer_finish = modem_create_bearer_finish;
iface->load_unlock_retries = load_unlock_retries;
diff --git a/plugins/option/mm-broadband-modem-option.c b/plugins/option/mm-broadband-modem-option.c
index 6ab34e95..5919364d 100644
--- a/plugins/option/mm-broadband-modem-option.c
+++ b/plugins/option/mm-broadband-modem-option.c
@@ -31,7 +31,9 @@
#include "mm-iface-modem-3gpp.h"
#include "mm-base-modem-at.h"
#include "mm-broadband-modem-option.h"
+#include "mm-shared-option.h"
+static void shared_option_init (MMSharedOption *iface);
static void iface_modem_init (MMIfaceModem *iface);
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
@@ -39,6 +41,7 @@ static MMIfaceModem *iface_modem_parent;
static MMIfaceModem3gpp *iface_modem_3gpp_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemOption, mm_broadband_modem_option, MM_TYPE_BROADBAND_MODEM, 0,
+ G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_OPTION, shared_option_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init))
@@ -1180,10 +1183,17 @@ mm_broadband_modem_option_init (MMBroadbandModemOption *self)
}
static void
+shared_option_init (MMSharedOption *iface)
+{
+}
+
+static void
iface_modem_init (MMIfaceModem *iface)
{
iface_modem_parent = g_type_interface_peek_parent (iface);
+ iface->create_sim = mm_shared_option_create_sim;
+ iface->create_sim_finish = mm_shared_option_create_sim_finish;
iface->modem_after_power_up = modem_after_power_up;
iface->modem_after_power_up_finish = modem_after_power_up_finish;
iface->load_access_technologies = load_access_technologies;
diff --git a/plugins/option/mm-shared-option.c b/plugins/option/mm-shared-option.c
new file mode 100644
index 00000000..a06888a1
--- /dev/null
+++ b/plugins/option/mm-shared-option.c
@@ -0,0 +1,77 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#define _LIBMM_INSIDE_MM
+#include <libmm-glib.h>
+
+#include "mm-log-object.h"
+#include "mm-iface-modem.h"
+#include "mm-sim-option.h"
+#include "mm-shared-option.h"
+
+/*****************************************************************************/
+/* Create SIM (Modem inteface) */
+
+MMBaseSim *
+mm_shared_option_create_sim_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return mm_sim_option_new_finish (res, error);
+}
+
+void
+mm_shared_option_create_sim (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ mm_sim_option_new (MM_BASE_MODEM (self),
+ NULL, /* cancellable */
+ callback,
+ user_data);
+}
+
+/*****************************************************************************/
+
+static void
+shared_option_init (gpointer g_iface)
+{
+}
+
+GType
+mm_shared_option_get_type (void)
+{
+ static GType shared_option_type = 0;
+
+ if (!G_UNLIKELY (shared_option_type)) {
+ static const GTypeInfo info = {
+ sizeof (MMSharedOption), /* class_size */
+ shared_option_init, /* base_init */
+ NULL, /* base_finalize */
+ };
+
+ shared_option_type = g_type_register_static (G_TYPE_INTERFACE, "MMSharedOption", &info, 0);
+ g_type_interface_add_prerequisite (shared_option_type, MM_TYPE_IFACE_MODEM);
+ }
+
+ return shared_option_type;
+}
diff --git a/plugins/option/mm-shared-option.h b/plugins/option/mm-shared-option.h
new file mode 100644
index 00000000..0d4baf60
--- /dev/null
+++ b/plugins/option/mm-shared-option.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#ifndef MM_SHARED_OPTION_H
+#define MM_SHARED_OPTION_H
+
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#define _LIBMM_INSIDE_MM
+#include <libmm-glib.h>
+
+#include "mm-broadband-modem.h"
+#include "mm-iface-modem.h"
+#include "mm-iface-modem-location.h"
+
+#define MM_TYPE_SHARED_OPTION (mm_shared_option_get_type ())
+#define MM_SHARED_OPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SHARED_OPTION, MMSharedOption))
+#define MM_IS_SHARED_OPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SHARED_OPTION))
+#define MM_SHARED_OPTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_SHARED_OPTION, MMSharedOption))
+
+typedef struct _MMSharedOption MMSharedOption;
+
+struct _MMSharedOption {
+ GTypeInterface g_iface;
+};
+
+GType mm_shared_option_get_type (void);
+
+void mm_shared_option_create_sim (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+MMBaseSim *mm_shared_option_create_sim_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error);
+
+#endif /* MM_SHARED_OPTION_H */
diff --git a/plugins/option/mm-sim-option.c b/plugins/option/mm-sim-option.c
new file mode 100644
index 00000000..0871c4f2
--- /dev/null
+++ b/plugins/option/mm-sim-option.c
@@ -0,0 +1,84 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <ModemManager.h>
+#define _LIBMM_INSIDE_MM
+#include <libmm-glib.h>
+
+#include "mm-sim-option.h"
+
+G_DEFINE_TYPE (MMSimOption, mm_sim_option, MM_TYPE_BASE_SIM)
+
+/*****************************************************************************/
+
+MMBaseSim *
+mm_sim_option_new_finish (GAsyncResult *res,
+ GError **error)
+{
+ GObject *source;
+ GObject *sim;
+
+ source = g_async_result_get_source_object (res);
+ sim = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error);
+ g_object_unref (source);
+
+ if (!sim)
+ return NULL;
+
+ /* Only export valid SIMs */
+ mm_base_sim_export (MM_BASE_SIM (sim));
+
+ return MM_BASE_SIM (sim);
+}
+
+void
+mm_sim_option_new (MMBaseModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_async_initable_new_async (MM_TYPE_SIM_OPTION,
+ G_PRIORITY_DEFAULT,
+ cancellable,
+ callback,
+ user_data,
+ MM_BASE_SIM_MODEM, modem,
+ "active", TRUE, /* by default always active */
+ NULL);
+}
+
+static void
+mm_sim_option_init (MMSimOption *self)
+{
+}
+
+static void
+mm_sim_option_class_init (MMSimOptionClass *klass)
+{
+ MMBaseSimClass *base_sim_class = MM_BASE_SIM_CLASS (klass);
+
+ /* Skip managing preferred networks, not supported by Option modems */
+ base_sim_class->load_preferred_networks = NULL;
+ base_sim_class->load_preferred_networks_finish = NULL;
+ base_sim_class->set_preferred_networks = NULL;
+ base_sim_class->set_preferred_networks_finish = NULL;
+}
diff --git a/plugins/option/mm-sim-option.h b/plugins/option/mm-sim-option.h
new file mode 100644
index 00000000..c502a397
--- /dev/null
+++ b/plugins/option/mm-sim-option.h
@@ -0,0 +1,51 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2021 Aleksander Morgado <aleksander@aleksander.es>
+ */
+
+#ifndef MM_SIM_OPTION_H
+#define MM_SIM_OPTION_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "mm-base-sim.h"
+
+#define MM_TYPE_SIM_OPTION (mm_sim_option_get_type ())
+#define MM_SIM_OPTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SIM_OPTION, MMSimOption))
+#define MM_SIM_OPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SIM_OPTION, MMSimOptionClass))
+#define MM_IS_SIM_OPTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SIM_OPTION))
+#define MM_IS_SIM_OPTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SIM_OPTION))
+#define MM_SIM_OPTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SIM_OPTION, MMSimOptionClass))
+
+typedef struct _MMSimOption MMSimOption;
+typedef struct _MMSimOptionClass MMSimOptionClass;
+
+struct _MMSimOption {
+ MMBaseSim parent;
+};
+
+struct _MMSimOptionClass {
+ MMBaseSimClass parent;
+};
+
+GType mm_sim_option_get_type (void);
+
+void mm_sim_option_new (MMBaseModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+MMBaseSim *mm_sim_option_new_finish (GAsyncResult *res,
+ GError **error);
+
+#endif /* MM_SIM_OPTION_H */