diff --git a/connman/plugins/sailfish_ofono.c b/connman/plugins/sailfish_ofono.c index 22c3b78d1..e77282110 100644 --- a/connman/plugins/sailfish_ofono.c +++ b/connman/plugins/sailfish_ofono.c @@ -117,6 +117,7 @@ struct modem_data { gulong connctx_handler_id[CONNCTX_HANDLER_COUNT]; guint activate_timeout_id; guint online_check_id; + GCancellable *pending_set_powered; struct connman_device *device; struct connman_network *network; const char *country; @@ -1060,6 +1061,25 @@ static void modem_online_check(struct modem_data *md) modem_set_online(md, !__connman_technology_get_offlinemode()); } +static void set_powered_cb(OfonoModem* sender, const GError* error, void* arg) +{ + struct modem_data *md = arg; + DBG("set powered callback"); + + md->pending_set_powered = NULL; + + if (error) { + connman_warn("Error setting modem powered %s: %s", + ofono_modem_path(md->modem), error->message); + + // these are doomed to fail until the modem is powered + if (md->online_check_id) { + g_source_remove(md->online_check_id); + md->online_check_id = 0; + } + } +} + static void modem_changed(OfonoModem *modem, void *arg) { struct modem_data *md = arg; @@ -1068,7 +1088,12 @@ static void modem_changed(OfonoModem *modem, void *arg) modem->powered, modem->online); if (!modem->powered) { DBG("%s powering up", ofono_modem_path(modem)); - ofono_modem_set_powered(modem, TRUE); + if (md->pending_set_powered) { + g_cancellable_cancel(md->pending_set_powered); + } + md->pending_set_powered + = ofono_modem_set_powered_full(modem, TRUE, + &set_powered_cb, md); } /* Keep modem online state in sync with the offline mode */ @@ -1177,7 +1202,9 @@ static void modem_create(struct plugin_data *plugin, OfonoModem *modem) g_hash_table_replace(plugin->modems, g_strdup(path), md); if (ofono_modem_valid(modem)) { - ofono_modem_set_powered(modem, TRUE); + md->pending_set_powered + = ofono_modem_set_powered_full(modem, TRUE, + &set_powered_cb, md); modem_online_check(md); } if (ofono_connmgr_valid(md->connmgr)) { @@ -1197,6 +1224,10 @@ static void modem_delete(gpointer value) g_source_remove(md->online_check_id); } + if (md->pending_set_powered) { + g_cancellable_cancel(md->pending_set_powered); + } + if (md->delayed_set_connected_id) { g_source_remove(md->delayed_set_connected_id); } diff --git a/rpm/connman.spec b/rpm/connman.spec index f1444d047..3a55de81d 100644 --- a/rpm/connman.spec +++ b/rpm/connman.spec @@ -7,8 +7,8 @@ URL: http://connman.net/ Source0: %{name}-%{version}.tar.bz2 Source1: main.conf Source2: 01-require-home-mount-to-be-present.conf -Requires: dbus >= 1.4 -Requires: wpa_supplicant >= 0.7.1 +Requires: dbus +Requires: wpa_supplicant Requires: ofono Requires: pacrunner Requires: connman-configs @@ -24,8 +24,6 @@ Requires: tayga >= 0.9.2 Requires(preun): systemd Requires(post): systemd Requires(postun): systemd -# license macro requires reasonably fresh rpm -BuildRequires: rpm >= 4.11 BuildRequires: pkgconfig(xtables) >= 1.6.1 BuildRequires: pkgconfig(libiptc) BuildRequires: pkgconfig(glib-2.0) >= 2.62 @@ -95,7 +93,6 @@ FallbackTimeservers. %package doc Summary: Documentation for %{name} Requires: %{name} = %{version}-%{release} -Obsoletes: %{name}-docs %description doc Man pages for %{name}.