2007-12-06 Tambet Ingo <tambet@gmail.com>

* src/nm-umts-device.c (real_act_stage1_prepare): Flash the
        * modem (drop DTR)
        before doing anything else.
        (init_modem): Move modem initialization here.

        * src/nm-serial-device.c (ppp_state_changed): React on pppd
        * state changes.
        (nm_serial_device_flash): Implement.

        * src/ppp-manager/nm-ppp-manager.c (name_owner_changed): Fix the
        * typoes: the state
        changes signal is "StateChanged" and not "Status".
        (ppp_exit_code, ppp_status_changed): Remove the debug output,
it's working fine now.



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3146 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Tambet Ingo 2007-12-06 15:55:52 +00:00
parent a9a58b28c7
commit f2f36ffa7b
6 changed files with 88 additions and 39 deletions

View file

@ -1,3 +1,16 @@
2007-12-06 Tambet Ingo <tambet@gmail.com>
* src/nm-umts-device.c (real_act_stage1_prepare): Flash the modem (drop DTR)
before doing anything else.
(init_modem): Move modem initialization here.
* src/nm-serial-device.c (ppp_state_changed): React on pppd state changes.
(nm_serial_device_flash): Implement.
* src/ppp-manager/nm-ppp-manager.c (name_owner_changed): Fix the typoes: the state
changes signal is "StateChanged" and not "Status".
(ppp_exit_code, ppp_status_changed): Remove the debug output, it's working fine now.
2007-12-06 Dan Williams <dcbw@redhat.com>
* src/supplicant-manager/nm-supplicant-config.c

View file

@ -697,67 +697,93 @@ nm_serial_device_wait_quiet (NMSerialDevice *device,
wait_quiet_info_destroy);
}
#endif
typedef struct {
NMSerialDevice *device;
int current_speed;
speed_t current_speed;
NMSerialFlashFn callback;
gpointer user_data;
} FlashInfo;
static gboolean
flash_done (gpointer user_data)
static speed_t
get_speed (NMSerialDevice *device)
{
FlashInfo *info = (FlashInfo *) user_data;
struct termios options;
/* FIXME: Restore the speed */
info->current_speed;
tcgetattr (NM_SERIAL_DEVICE_GET_PRIVATE (device)->fd, &options);
return cfgetospeed (&options);
}
static void
set_speed (NMSerialDevice *device, speed_t speed)
{
struct termios options;
int fd;
fd = NM_SERIAL_DEVICE_GET_PRIVATE (device)->fd;
tcgetattr (fd, &options);
cfsetispeed (&options, speed);
cfsetospeed (&options, speed);
options.c_cflag |= (CLOCAL | CREAD);
tcsetattr (fd, TCSANOW, &options);
}
static gboolean
flash_done (gpointer data)
{
FlashInfo *info = (FlashInfo *) data;
set_speed (info->device, info->current_speed);
info->callback (info->device, info->user_data);
return FALSE;
}
void
guint
nm_serial_device_flash (NMSerialDevice *device,
guint32 flash_time,
NMSerialFlashFn callback,
gpointer user_data)
{
int fd;
struct termio stbuf;
int speed;
FlashInfo *info;
g_return_if_fail (NM_IS_SERIAL_DEVICE (device));
g_return_if_fail (callback != NULL);
fd = NM_SERIAL_DEVICE_GET_PRIVATE (device)->fd;
ioctl (fd, TCGETA, &stbuf);
speed = stbuf.c_cflags & CBAUD;
/* FIXME: Set speed to 0 */
g_return_val_if_fail (NM_IS_SERIAL_DEVICE (device), 0);
g_return_val_if_fail (callback != NULL, 0);
info = g_new (FlashInfo, 1);
info->device = device;
info->current_speed = speed;
info->current_speed = get_speed (device);
info->callback = callback;
info->user_data = user_data;
g_timeout_add_full (G_PRIORITY_DEFAULT,
flash_time,
flash_done,
info,
g_free);
}
set_speed (device, B0);
#endif
return g_timeout_add_full (G_PRIORITY_DEFAULT,
flash_time,
flash_done,
info,
g_free);
}
static void
ppp_state_changed (NMPPPManager *ppp_manager, NMPPPStatus status, gpointer user_data)
{
nm_debug ("ppp state changed: %d", status);
/* FIXME */
NMDevice *device = NM_DEVICE (user_data);
switch (status) {
case NM_PPP_STATUS_NETWORK:
nm_device_state_changed (device, NM_DEVICE_STATE_IP_CONFIG);
break;
case NM_PPP_STATUS_DISCONNECT:
nm_device_state_changed (device, NM_DEVICE_STATE_FAILED);
break;
default:
break;
}
}
static void

View file

@ -67,7 +67,7 @@ void nm_serial_device_wait_quiet (NMSerialDevice *device,
NMSerialWaitQuietFn callback,
gpointer user_data);
void nm_serial_device_flash (NMSerialDevice *device,
guint nm_serial_device_flash (NMSerialDevice *device,
guint32 flash_time,
NMSerialFlashFn callback,
gpointer user_data);

View file

@ -421,20 +421,33 @@ init_done (NMSerialDevice *device,
}
}
static void
init_modem (NMSerialDevice *device, gpointer user_data)
{
guint id;
char *responses[] = { "OK", "ERR", NULL };
nm_serial_device_send_command_string (device, "ATZ E0");
id = nm_serial_device_wait_for_reply (device, 10, responses, init_done, NULL);
if (id)
umts_device_set_pending (NM_UMTS_DEVICE (device), id);
else
nm_device_state_changed (NM_DEVICE (device), NM_DEVICE_STATE_FAILED);
}
static NMActStageReturn
real_act_stage1_prepare (NMDevice *device)
{
NMUmtsDevicePrivate *priv = NM_UMTS_DEVICE_GET_PRIVATE (device);
NMSerialDevice *serial_device = NM_SERIAL_DEVICE (device);
char *responses[] = { "OK", "ERR", NULL };
priv->need_secret = NM_UMTS_SECRET_NONE;
if (!nm_serial_device_open (NM_SERIAL_DEVICE (device)))
if (!nm_serial_device_open (serial_device))
return NM_ACT_STAGE_RETURN_FAILURE;
nm_serial_device_send_command_string (serial_device, "ATZ E0");
priv->pending_id = nm_serial_device_wait_for_reply (serial_device, 10, responses, init_done, NULL);
priv->pending_id = nm_serial_device_flash (serial_device, 100, init_modem, NULL);
return priv->pending_id ? NM_ACT_STAGE_RETURN_POSTPONE : NM_ACT_STAGE_RETURN_FAILURE;
}

View file

@ -381,8 +381,8 @@ name_owner_changed (NMDBusManager *dbus_manager,
NM_DBUS_PATH_PPP,
NM_DBUS_INTERFACE_PPP);
dbus_g_proxy_add_signal (priv->proxy, "Status", G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "Status",
dbus_g_proxy_add_signal (priv->proxy, "StateChanged", G_TYPE_UINT, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (priv->proxy, "StateChanged",
G_CALLBACK (ppp_status_changed),
manager, NULL);

View file

@ -197,8 +197,6 @@ nm_phasechange (void *data, int arg)
break;
}
g_message ("pppd reported new phase: %s", ppp_phase);
if (ppp_status != NM_PPP_STATUS_UNKNOWN)
nm_pppd_plugin_state_changed (plugin, ppp_status);
}
@ -301,7 +299,6 @@ nm_exit_notify (void *data, int arg)
{
NMPppdPlugin *plugin = NM_PPPD_PLUGIN (data);
g_message ("exiting");
g_object_unref (plugin);
}