Do not always automatically connect to the network
This commit is contained in:
parent
42843bb9a6
commit
009b3fae80
41
src/phone.c
41
src/phone.c
@ -926,6 +926,9 @@ void phone_dialer_hangup(Phone * phone)
|
|||||||
|
|
||||||
/* events */
|
/* events */
|
||||||
/* phone_event */
|
/* phone_event */
|
||||||
|
static int _event_type_started(Phone * phone);
|
||||||
|
static int _event_type_starting(Phone * phone);
|
||||||
|
|
||||||
int phone_event(Phone * phone, PhoneEvent * event)
|
int phone_event(Phone * phone, PhoneEvent * event)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -947,23 +950,19 @@ int phone_event(Phone * phone, PhoneEvent * event)
|
|||||||
switch(event->type)
|
switch(event->type)
|
||||||
{
|
{
|
||||||
case PHONE_EVENT_TYPE_OFFLINE:
|
case PHONE_EVENT_TYPE_OFFLINE:
|
||||||
/* connect to the network */
|
|
||||||
modem_request_type(phone->modem,
|
|
||||||
MODEM_REQUEST_CONNECTIVITY, 1);
|
|
||||||
break;
|
break;
|
||||||
case PHONE_EVENT_TYPE_ONLINE:
|
case PHONE_EVENT_TYPE_ONLINE:
|
||||||
/* authenticate if necessary */
|
/* authenticate if necessary */
|
||||||
modem_trigger(phone->modem,
|
modem_trigger(phone->modem,
|
||||||
MODEM_EVENT_TYPE_AUTHENTICATION);
|
MODEM_EVENT_TYPE_AUTHENTICATION);
|
||||||
break;
|
break;
|
||||||
|
case PHONE_EVENT_TYPE_STARTED:
|
||||||
|
if(ret == 0)
|
||||||
|
ret = _event_type_started(phone);
|
||||||
|
break;
|
||||||
case PHONE_EVENT_TYPE_STARTING:
|
case PHONE_EVENT_TYPE_STARTING:
|
||||||
if(ret == 0)
|
if(ret == 0)
|
||||||
{
|
ret = _event_type_starting(phone);
|
||||||
ret = modem_start(phone->modem);
|
|
||||||
phone_event_type(phone, (ret == 0)
|
|
||||||
? PHONE_EVENT_TYPE_STARTED
|
|
||||||
: PHONE_EVENT_TYPE_STOPPED);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PHONE_EVENT_TYPE_STOPPING:
|
case PHONE_EVENT_TYPE_STOPPING:
|
||||||
if(ret == 0 && phone->modem != NULL
|
if(ret == 0 && phone->modem != NULL
|
||||||
@ -978,6 +977,30 @@ int phone_event(Phone * phone, PhoneEvent * event)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int _event_type_started(Phone * phone)
|
||||||
|
{
|
||||||
|
int online = 0;
|
||||||
|
char const * p;
|
||||||
|
|
||||||
|
if((p = config_get(phone->config, NULL, "online")) == NULL
|
||||||
|
|| strtol(p, NULL, 10) != 0
|
||||||
|
|| _phone_confirm(phone, NULL,
|
||||||
|
_("Connect to the network?")) != 0)
|
||||||
|
online = 1;
|
||||||
|
modem_request_type(phone->modem, MODEM_REQUEST_CONNECTIVITY, online);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int _event_type_starting(Phone * phone)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = modem_start(phone->modem);
|
||||||
|
phone_event_type(phone, (ret == 0) ? PHONE_EVENT_TYPE_STARTED
|
||||||
|
: PHONE_EVENT_TYPE_STOPPED);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* phone_event_type */
|
/* phone_event_type */
|
||||||
int phone_event_type(Phone * phone, PhoneEventType type, ...)
|
int phone_event_type(Phone * phone, PhoneEventType type, ...)
|
||||||
|
Loading…
Reference in New Issue
Block a user