30
30
#include "nm-device-private.h"
31
31
#include "nm-setting-connection.h"
32
32
#include "nm-setting-gsm.h"
33
#include "nm-setting-ppp.h"
33
34
#include "nm-modem-types.h"
34
35
#include "nm-logging.h"
35
36
#include "NetworkManagerUtils.h"
248
251
static void stage1_enable_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data);
253
/* do_enable() is used as a GSourceFunc, hence the gboolean return */
251
255
do_enable (NMModemGsm *self)
253
257
DBusGProxy *proxy;
255
g_return_if_fail (self != NULL);
256
g_return_if_fail (NM_IS_MODEM_GSM (self));
259
g_return_val_if_fail (self != NULL, FALSE);
260
g_return_val_if_fail (NM_IS_MODEM_GSM (self), FALSE);
262
NM_MODEM_GSM_GET_PRIVATE (self)->enable_delay_id = 0;
258
263
proxy = nm_modem_get_proxy (NM_MODEM (self), MM_DBUS_INTERFACE_MODEM);
259
264
dbus_g_proxy_begin_call_with_timeout (proxy,
260
265
"Enable", stage1_enable_done,
261
266
self, NULL, 20000,
262
267
G_TYPE_BOOLEAN, TRUE,
267
273
stage1_pin_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
269
275
NMModemGsm *self = NM_MODEM_GSM (user_data);
276
NMModemGsmPrivate *priv = NM_MODEM_GSM_GET_PRIVATE (self);
270
277
NMDeviceStateReason reason;
271
278
GError *error = NULL;
273
280
if (dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
274
/* Success; go back and try the enable again */
281
/* Success; try to enable the modem again. Wait a few seconds to ensure
282
* that ModemManager is ready for the enable right after the unlock.
284
if (priv->enable_delay_id == 0)
285
priv->enable_delay_id = g_timeout_add_seconds (4, (GSourceFunc) do_enable, self);
277
287
nm_log_warn (LOGD_MB, "GSM PIN unlock failed: (%d) %s",
278
288
error ? error->code : -1,
515
526
if (!nm_setting_gsm_get_number (s_gsm))
516
527
g_object_set (G_OBJECT (s_gsm), NM_SETTING_GSM_NUMBER, "*99#", NULL);
529
s_ppp = nm_connection_get_setting_ppp (connection);
531
s_ppp = (NMSettingPPP *) nm_setting_ppp_new ();
532
g_object_set (G_OBJECT (s_ppp),
533
NM_SETTING_PPP_LCP_ECHO_FAILURE, 5,
534
NM_SETTING_PPP_LCP_ECHO_INTERVAL, 30,
536
nm_connection_add_setting (connection, NM_SETTING (s_ppp));
518
539
nm_utils_complete_generic (connection,
519
540
NM_SETTING_GSM_SETTING_NAME,
520
541
existing_connections,
586
610
if (priv->connect_properties)
587
611
g_hash_table_destroy (priv->connect_properties);
612
if (priv->enable_delay_id)
613
g_source_remove (priv->enable_delay_id);
589
615
G_OBJECT_CLASS (nm_modem_gsm_parent_class)->dispose (object);