Reset the modem when the device is changed
This commit is contained in:
parent
8fae6cb0c0
commit
0f03769f71
28
src/gsm.c
28
src/gsm.c
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Phone */
|
||||
/* 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
|
||||
@ -1041,13 +1041,25 @@ int gsm_queue_with_error(GSM * gsm, char const * command, GSMError error)
|
||||
|
||||
|
||||
/* gsm_reset */
|
||||
int gsm_reset(GSM * gsm, unsigned int delay)
|
||||
int gsm_reset(GSM * gsm, unsigned int delay, char const * device)
|
||||
{
|
||||
int ret;
|
||||
char * p = NULL;
|
||||
|
||||
if((ret = gsm_stop(gsm)) != 0)
|
||||
return ret;
|
||||
return gsm_start(gsm, delay);
|
||||
if(device != NULL && (p = strdup(device)) == NULL)
|
||||
return -1;
|
||||
if((ret = gsm_stop(gsm)) == 0)
|
||||
{
|
||||
if(p != NULL)
|
||||
{
|
||||
free(gsm->device);
|
||||
gsm->device = p;
|
||||
}
|
||||
ret = gsm_start(gsm, delay);
|
||||
}
|
||||
else
|
||||
free(p);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@ -1932,7 +1944,7 @@ static int _gsm_trigger_connect(GSM * gsm, char const * result,
|
||||
*answered = TRUE;
|
||||
/* FIXME implement pass-through */
|
||||
/* FIXME reset is probably not enough (send "+++"?) */
|
||||
return gsm_reset(gsm, gsm->retry);
|
||||
return gsm_reset(gsm, gsm->retry, NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -2395,7 +2407,7 @@ static gboolean _on_watch_can_read(GIOChannel * source, GIOCondition condition,
|
||||
case G_IO_STATUS_EOF:
|
||||
default: /* should not happen... */
|
||||
if(gsm->retry > 0)
|
||||
gsm_reset(gsm, gsm->retry);
|
||||
gsm_reset(gsm, gsm->retry, NULL);
|
||||
gsm->rd_source = 0;
|
||||
return FALSE;
|
||||
}
|
||||
@ -2446,7 +2458,7 @@ static gboolean _on_watch_can_write(GIOChannel * source, GIOCondition condition,
|
||||
case G_IO_STATUS_EOF:
|
||||
default: /* should not happen */
|
||||
if(gsm->retry > 0)
|
||||
gsm_reset(gsm, gsm->retry);
|
||||
gsm_reset(gsm, gsm->retry, NULL);
|
||||
gsm->wr_source = 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* $Id$ */
|
||||
/* Copyright (c) 2010 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Phone */
|
||||
/* 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
|
||||
@ -447,7 +447,7 @@ int gsm_queue_full_mode(GSM * gsm, GSMPriority priority, char const * command,
|
||||
GSMError error, GSMCommandCallback callback, GSMMode mode);
|
||||
int gsm_queue_with_error(GSM * gsm, char const * command, GSMError error);
|
||||
|
||||
int gsm_reset(GSM * gsm, unsigned int delay);
|
||||
int gsm_reset(GSM * gsm, unsigned int delay, char const * device);
|
||||
int gsm_start(GSM * gsm, unsigned int delay);
|
||||
int gsm_stop(GSM * gsm);
|
||||
|
||||
|
@ -2284,17 +2284,17 @@ static gboolean _on_system_closex(gpointer data)
|
||||
static void _on_system_ok(gpointer data)
|
||||
{
|
||||
Phone * phone = data;
|
||||
char const * p;
|
||||
char const * device;
|
||||
|
||||
gtk_widget_hide(phone->sy_window);
|
||||
/* FIXME requires a restart to be applied at the moment */
|
||||
if((p = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(
|
||||
if((device = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(
|
||||
phone->sy_device))) != NULL)
|
||||
config_set(phone->config, NULL, "device", p);
|
||||
config_set(phone->config, NULL, "device", device);
|
||||
config_set(phone->config, NULL, "hwflow", gtk_toggle_button_get_active(
|
||||
GTK_TOGGLE_BUTTON(phone->sy_hwflow))
|
||||
? "1" : "0");
|
||||
_phone_config_save(phone);
|
||||
gsm_reset(phone->gsm, 0, device);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user