377 lines
12 KiB
Diff
377 lines
12 KiB
Diff
From 88af8783a80be0871c8050a49e173d65727f2533 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
|
|
Date: Fri, 5 Mar 2021 11:30:41 +0100
|
|
Subject: [PATCH 1/5] wwan-iface: Add 'enabled' property
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
This indicates if the modem is enabled.
|
|
|
|
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
|
|
---
|
|
src/wwan/phosh-wwan-iface.c | 21 +++++++++++++++++++++
|
|
src/wwan/phosh-wwan-iface.h | 3 +++
|
|
2 files changed, 24 insertions(+)
|
|
|
|
diff --git a/src/wwan/phosh-wwan-iface.c b/src/wwan/phosh-wwan-iface.c
|
|
index b2ee12d8..1fd96e6a 100644
|
|
--- a/src/wwan/phosh-wwan-iface.c
|
|
+++ b/src/wwan/phosh-wwan-iface.c
|
|
@@ -64,6 +64,14 @@ phosh_wwan_default_init (PhoshWWanInterface *iface)
|
|
FALSE,
|
|
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
|
|
|
|
+ g_object_interface_install_property (
|
|
+ iface,
|
|
+ g_param_spec_boolean ("enabled",
|
|
+ "Modem enabled",
|
|
+ "Whether there modem is enabled",
|
|
+ FALSE,
|
|
+ G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
|
|
+
|
|
g_object_interface_install_property (
|
|
iface,
|
|
g_param_spec_string ("operator",
|
|
@@ -140,6 +148,19 @@ phosh_wwan_is_present (PhoshWWan *self)
|
|
}
|
|
|
|
|
|
+gboolean
|
|
+phosh_wwan_is_enabled (PhoshWWan *self)
|
|
+{
|
|
+ PhoshWWanInterface *iface;
|
|
+
|
|
+ g_return_val_if_fail (PHOSH_IS_WWAN (self), FALSE);
|
|
+
|
|
+ iface = PHOSH_WWAN_GET_IFACE (self);
|
|
+ g_return_val_if_fail (iface->is_enabled != NULL, FALSE);
|
|
+ return iface->is_enabled (self);
|
|
+}
|
|
+
|
|
+
|
|
const char *
|
|
phosh_wwan_get_operator (PhoshWWan *self)
|
|
{
|
|
diff --git a/src/wwan/phosh-wwan-iface.h b/src/wwan/phosh-wwan-iface.h
|
|
index eae9f55c..1e5fd201 100644
|
|
--- a/src/wwan/phosh-wwan-iface.h
|
|
+++ b/src/wwan/phosh-wwan-iface.h
|
|
@@ -20,6 +20,7 @@ G_DECLARE_INTERFACE (PhoshWWan, phosh_wwan, PHOSH, WWAN, GObject)
|
|
* @is_unlocked: whether the SIM in the modem is locked
|
|
* @has_sim: Whether there's a sim in the modem
|
|
* @is_present: whether a modem is present at all
|
|
+ * @is_enabled: whether a modem is enabled
|
|
* @get_operator: Get the current network operator name
|
|
*
|
|
* Provides an interface for interacting with a modem
|
|
@@ -34,6 +35,7 @@ struct _PhoshWWanInterface
|
|
gboolean (*is_unlocked) (PhoshWWan *self);
|
|
gboolean (*has_sim) (PhoshWWan *self);
|
|
gboolean (*is_present) (PhoshWWan *self);
|
|
+ gboolean (*is_enabled) (PhoshWWan *self);
|
|
const char* (*get_operator) (PhoshWWan *self);
|
|
};
|
|
|
|
@@ -42,4 +44,5 @@ const char* phosh_wwan_get_access_tec (PhoshWWan* self);
|
|
gboolean phosh_wwan_is_unlocked (PhoshWWan* self);
|
|
gboolean phosh_wwan_has_sim (PhoshWWan* self);
|
|
gboolean phosh_wwan_is_present (PhoshWWan* self);
|
|
+gboolean phosh_wwan_is_enabled (PhoshWWan *self);
|
|
const char *phosh_wwan_get_operator (PhoshWWan *self);
|
|
--
|
|
2.26.2
|
|
|
|
|
|
From fb5a00e994fb2103193a7dff26788efde9e3096d Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
|
|
Date: Fri, 5 Mar 2021 11:31:08 +0100
|
|
Subject: [PATCH 2/5] wwan-mm: Complete PhoshMMModemState
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
This matches MMModemState
|
|
|
|
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
|
|
---
|
|
src/wwan/phosh-wwan-mm.c | 10 +++++++++-
|
|
1 file changed, 9 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/wwan/phosh-wwan-mm.c b/src/wwan/phosh-wwan-mm.c
|
|
index a5589419..ca0b1c45 100644
|
|
--- a/src/wwan/phosh-wwan-mm.c
|
|
+++ b/src/wwan/phosh-wwan-mm.c
|
|
@@ -55,7 +55,15 @@ typedef enum { /*< underscore_name=mm_modem_state >*/
|
|
MM_MODEM_STATE_UNKNOWN = 0,
|
|
MM_MODEM_STATE_INITIALIZING = 1,
|
|
MM_MODEM_STATE_LOCKED = 2,
|
|
- /* ... */
|
|
+ MM_MODEM_STATE_DISABLED = 3,
|
|
+ MM_MODEM_STATE_DISABLING = 4,
|
|
+ MM_MODEM_STATE_ENABLING = 5,
|
|
+ MM_MODEM_STATE_ENABLED = 6,
|
|
+ MM_MODEM_STATE_SEARCHING = 7,
|
|
+ MM_MODEM_STATE_REGISTERED = 8,
|
|
+ MM_MODEM_STATE_DISCONNECTING = 9,
|
|
+ MM_MODEM_STATE_CONNECTING = 10,
|
|
+ MM_MODEM_STATE_CONNECTED = 11,
|
|
} PhoshMMModemState;
|
|
|
|
enum {
|
|
--
|
|
2.26.2
|
|
|
|
|
|
From 1a75bcb4806897c1995dc2eebe599d3e8f1dba78 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
|
|
Date: Fri, 5 Mar 2021 11:32:45 +0100
|
|
Subject: [PATCH 3/5] wwan-mm: Handle 'enabled' property
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
|
|
---
|
|
src/wwan/phosh-wwan-mm.c | 43 ++++++++++++++++++++++++++++++++++++++++
|
|
1 file changed, 43 insertions(+)
|
|
|
|
diff --git a/src/wwan/phosh-wwan-mm.c b/src/wwan/phosh-wwan-mm.c
|
|
index ca0b1c45..ec52e838 100644
|
|
--- a/src/wwan/phosh-wwan-mm.c
|
|
+++ b/src/wwan/phosh-wwan-mm.c
|
|
@@ -73,6 +73,7 @@ enum {
|
|
PHOSH_WWAN_MM_PROP_UNLOCKED,
|
|
PHOSH_WWAN_MM_PROP_SIM,
|
|
PHOSH_WWAN_MM_PROP_PRESENT,
|
|
+ PHOSH_WWAN_MM_PROP_ENABLED,
|
|
PHOSH_WWAN_MM_PROP_OPERATOR,
|
|
PHOSH_WWAN_MM_PROP_LAST_PROP,
|
|
};
|
|
@@ -96,6 +97,7 @@ typedef struct _PhoshWWanMM {
|
|
gboolean unlocked;
|
|
gboolean sim;
|
|
gboolean present;
|
|
+ gboolean enabled;
|
|
char *operator;
|
|
} PhoshWWanMM;
|
|
|
|
@@ -236,6 +238,25 @@ phosh_wwan_mm_update_present (PhoshWWanMM *self, gboolean present)
|
|
}
|
|
|
|
|
|
+static void
|
|
+phosh_wwan_mm_update_enabled (PhoshWWanMM *self)
|
|
+{
|
|
+ PhoshMMModemState state;
|
|
+ gboolean enabled;
|
|
+
|
|
+ g_return_if_fail (self);
|
|
+
|
|
+ state = phosh_mm_dbus_modem_get_state (self->proxy);
|
|
+
|
|
+ enabled = (state > MM_MODEM_STATE_ENABLING) ? TRUE : FALSE;
|
|
+ g_debug ("Modem is %senabled, state: %d", enabled ? "" : "not ", state);
|
|
+ if (self->enabled != enabled) {
|
|
+ self->enabled = enabled;
|
|
+ g_object_notify (G_OBJECT (self), "enabled");
|
|
+ }
|
|
+}
|
|
+
|
|
+
|
|
static void
|
|
phosh_wwan_mm_dbus_props_changed_cb (PhoshMMDBusModem *proxy,
|
|
GVariant *changed_properties,
|
|
@@ -256,6 +277,7 @@ phosh_wwan_mm_dbus_props_changed_cb (PhoshMMDBusModem *proxy,
|
|
phosh_wwan_mm_update_lock_status (self);
|
|
} else if (g_strcmp0 (property, "State") == 0) {
|
|
phosh_wwan_mm_update_lock_status (self);
|
|
+ phosh_wwan_mm_update_enabled (self);
|
|
} else if (g_strcmp0 (property, "Sim") == 0) {
|
|
phosh_wwan_mm_update_sim_status (self);
|
|
}
|
|
@@ -330,6 +352,9 @@ phosh_wwan_mm_destroy_modem (PhoshWWanMM *self)
|
|
|
|
phosh_wwan_mm_update_present (self, FALSE);
|
|
|
|
+ self->enabled = FALSE;
|
|
+ g_object_notify (G_OBJECT (self), "enabled");
|
|
+
|
|
self->signal_quality = 0;
|
|
g_object_notify (G_OBJECT (self), "signal-quality");
|
|
|
|
@@ -397,6 +422,7 @@ phosh_wwan_mm_on_proxy_new_for_bus_finish (GObject *source_object,
|
|
phosh_wwan_mm_update_lock_status (self);
|
|
phosh_wwan_mm_update_sim_status (self);
|
|
phosh_wwan_mm_update_present (self, TRUE);
|
|
+ phosh_wwan_mm_update_enabled (self);
|
|
g_object_unref (self);
|
|
}
|
|
|
|
@@ -566,6 +592,9 @@ phosh_wwan_mm_class_init (PhoshWWanMMClass *klass)
|
|
g_object_class_override_property (object_class,
|
|
PHOSH_WWAN_MM_PROP_PRESENT,
|
|
"present");
|
|
+ g_object_class_override_property (object_class,
|
|
+ PHOSH_WWAN_MM_PROP_ENABLED,
|
|
+ "enabled");
|
|
g_object_class_override_property (object_class,
|
|
PHOSH_WWAN_MM_PROP_OPERATOR,
|
|
"operator");
|
|
@@ -637,6 +666,19 @@ phosh_wwan_mm_is_present (PhoshWWan *phosh_wwan)
|
|
}
|
|
|
|
|
|
+static gboolean
|
|
+phosh_wwan_mm_is_enabled (PhoshWWan *phosh_wwan)
|
|
+{
|
|
+ PhoshWWanMM *self;
|
|
+
|
|
+ g_return_val_if_fail (PHOSH_IS_WWAN_MM (phosh_wwan), FALSE);
|
|
+
|
|
+ self = PHOSH_WWAN_MM (phosh_wwan);
|
|
+
|
|
+ return self->enabled;
|
|
+}
|
|
+
|
|
+
|
|
static const char *
|
|
phosh_wwan_mm_get_operator (PhoshWWan *phosh_wwan)
|
|
{
|
|
@@ -658,6 +700,7 @@ phosh_wwan_mm_interface_init (PhoshWWanInterface *iface)
|
|
iface->is_unlocked = phosh_wwan_mm_is_unlocked;
|
|
iface->has_sim = phosh_wwan_mm_has_sim;
|
|
iface->is_present = phosh_wwan_mm_is_present;
|
|
+ iface->is_enabled = phosh_wwan_mm_is_enabled;
|
|
iface->get_operator = phosh_wwan_mm_get_operator;
|
|
}
|
|
|
|
--
|
|
2.26.2
|
|
|
|
|
|
From ecc3a8bff11b92f7a3608cf33913a4809533b851 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
|
|
Date: Fri, 5 Mar 2021 11:33:04 +0100
|
|
Subject: [PATCH 4/5] wwan-ofono: Handle enabled property
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
We always return TRUE here to not break existing users.
|
|
|
|
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
|
|
---
|
|
src/wwan/phosh-wwan-ofono.c | 14 ++++++++++++++
|
|
1 file changed, 14 insertions(+)
|
|
|
|
diff --git a/src/wwan/phosh-wwan-ofono.c b/src/wwan/phosh-wwan-ofono.c
|
|
index 923d73aa..547590f8 100644
|
|
--- a/src/wwan/phosh-wwan-ofono.c
|
|
+++ b/src/wwan/phosh-wwan-ofono.c
|
|
@@ -30,6 +30,7 @@ enum {
|
|
PHOSH_WWAN_OFONO_PROP_UNLOCKED,
|
|
PHOSH_WWAN_OFONO_PROP_SIM,
|
|
PHOSH_WWAN_OFONO_PROP_PRESENT,
|
|
+ PHOSH_WWAN_OFONO_PROP_ENABLED,
|
|
PHOSH_WWAN_OFONO_PROP_OPERATOR,
|
|
PHOSH_WWAN_OFONO_PROP_LAST_PROP,
|
|
};
|
|
@@ -622,6 +623,9 @@ phosh_wwan_ofono_class_init (PhoshWWanOfonoClass *klass)
|
|
g_object_class_override_property (object_class,
|
|
PHOSH_WWAN_OFONO_PROP_PRESENT,
|
|
"present");
|
|
+ g_object_class_override_property (object_class,
|
|
+ PHOSH_WWAN_OFONO_PROP_ENABLED,
|
|
+ "enabled");
|
|
g_object_class_override_property (object_class,
|
|
PHOSH_WWAN_OFONO_PROP_OPERATOR,
|
|
"operator");
|
|
@@ -693,6 +697,15 @@ phosh_wwan_ofono_is_present (PhoshWWan *phosh_wwan)
|
|
}
|
|
|
|
|
|
+static gboolean
|
|
+phosh_wwan_ofono_is_enabled (PhoshWWan *phosh_wwan)
|
|
+{
|
|
+ g_return_val_if_fail (PHOSH_IS_WWAN_OFONO (phosh_wwan), FALSE);
|
|
+
|
|
+ return TRUE;
|
|
+}
|
|
+
|
|
+
|
|
static const char *
|
|
phosh_wwan_ofono_get_operator (PhoshWWan *phosh_wwan)
|
|
{
|
|
@@ -714,6 +727,7 @@ phosh_wwan_ofono_interface_init (PhoshWWanInterface *iface)
|
|
iface->is_unlocked = phosh_wwan_ofono_is_unlocked;
|
|
iface->has_sim = phosh_wwan_ofono_has_sim;
|
|
iface->is_present = phosh_wwan_ofono_is_present;
|
|
+ iface->is_enabled = phosh_wwan_ofono_is_enabled;
|
|
iface->get_operator = phosh_wwan_ofono_get_operator;
|
|
}
|
|
|
|
--
|
|
2.26.2
|
|
|
|
|
|
From 8a56699ceb46e06c94061d5988c0968817ba0058 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx@sigxcpu.org>
|
|
Date: Fri, 5 Mar 2021 11:33:36 +0100
|
|
Subject: [PATCH 5/5] wwaninfo: Correctly indicate disabled state
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
So far we used the signal-strength 0 icon which is confusing.
|
|
|
|
Signed-off-by: Guido Günther <guido.gunther@puri.sm>
|
|
---
|
|
src/wwaninfo.c | 13 ++++++++-----
|
|
1 file changed, 8 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/wwaninfo.c b/src/wwaninfo.c
|
|
index 1abe4d2a..d473af18 100644
|
|
--- a/src/wwaninfo.c
|
|
+++ b/src/wwaninfo.c
|
|
@@ -110,7 +110,7 @@ update_icon_data(PhoshWWanInfo *self, GParamSpec *psepc, PhoshWWan *wwan)
|
|
guint quality;
|
|
const char *icon_name = NULL;
|
|
const char *access_tec;
|
|
- gboolean present;
|
|
+ gboolean present, enabled;
|
|
|
|
g_return_if_fail (PHOSH_IS_WWAN_INFO (self));
|
|
present = phosh_wwan_is_present (self->wwan);
|
|
@@ -122,13 +122,15 @@ update_icon_data(PhoshWWanInfo *self, GParamSpec *psepc, PhoshWWan *wwan)
|
|
|
|
access_tec_widget = phosh_status_icon_get_extra_widget (PHOSH_STATUS_ICON (self));
|
|
|
|
+ enabled = phosh_wwan_is_enabled (self->wwan);
|
|
if (!present) {
|
|
- icon_name = ("network-cellular-disabled-symbolic");
|
|
- } else if (!phosh_wwan_has_sim (self->wwan)) /* SIM missing */
|
|
+ icon_name = "network-cellular-disabled-symbolic";
|
|
+ } else if (!phosh_wwan_has_sim (self->wwan)) {
|
|
icon_name = "auth-sim-missing-symbolic";
|
|
- else { /* SIM unlock required */
|
|
- if (!phosh_wwan_is_unlocked (self->wwan))
|
|
+ } else if (!phosh_wwan_is_unlocked (self->wwan)) {
|
|
icon_name = "auth-sim-locked-symbolic";
|
|
+ } else if (!enabled) {
|
|
+ icon_name = "network-cellular-disabled-symbolic";
|
|
}
|
|
|
|
if (icon_name) {
|
|
@@ -191,6 +193,7 @@ phosh_wwan_info_constructed (GObject *object)
|
|
"notify::unlocked",
|
|
"notify::sim",
|
|
"notify::present",
|
|
+ "notify::enabled",
|
|
NULL,
|
|
};
|
|
|
|
--
|
|
2.26.2
|
|
|