Fetching incoming messages as they are reported
This commit is contained in:
parent
ff6660cc3e
commit
0f1244eb5f
25
src/gsm.c
25
src/gsm.c
@ -169,6 +169,7 @@ static int _gsm_trigger_cme_error(GSM * gsm, char const * result,
|
||||
static int _gsm_trigger_cms_error(GSM * gsm, char const * result);
|
||||
static int _gsm_trigger_cmgl(GSM * gsm, char const * result);
|
||||
static int _gsm_trigger_cmgs(GSM * gsm, char const * result);
|
||||
static int _gsm_trigger_cmti(GSM * gsm, char const * result);
|
||||
static int _gsm_trigger_connect(GSM * gsm, char const * result,
|
||||
gboolean * answered);
|
||||
static int _gsm_trigger_cops(GSM * gsm, char const * result);
|
||||
@ -198,6 +199,7 @@ static GSMTrigger _gsm_triggers[] =
|
||||
GSM_TRIGGER("+CMS ERROR: ", cms_error),
|
||||
GSM_TRIGGER("+CMGL: ", cmgl),
|
||||
GSM_TRIGGER("+CMGS: ", cmgs),
|
||||
GSM_TRIGGER("+CMTI: ", cmti),
|
||||
GSM_TRIGGER("CONNECT", connect),
|
||||
GSM_TRIGGER("+COPS: ", cops),
|
||||
GSM_TRIGGER("+CPBR: ", cpbr),
|
||||
@ -482,6 +484,12 @@ int gsm_event(GSM * gsm, GSMEventType type, ...)
|
||||
event->incoming_call.calltype = va_arg(ap,
|
||||
unsigned int);
|
||||
break;
|
||||
case GSM_EVENT_TYPE_INCOMING_MESSAGE:
|
||||
event->incoming_message.memory = va_arg(ap,
|
||||
char const *);
|
||||
event->incoming_message.index = va_arg(ap,
|
||||
unsigned int);
|
||||
break;
|
||||
case GSM_EVENT_TYPE_MESSAGE_LIST:
|
||||
event->message_list.start = va_arg(ap, unsigned int);
|
||||
event->message_list.end = va_arg(ap, unsigned int);
|
||||
@ -1130,6 +1138,23 @@ static int _gsm_trigger_cmgs(GSM * gsm, char const * result)
|
||||
}
|
||||
|
||||
|
||||
/* gsm_trigger_cmti */
|
||||
static int _gsm_trigger_cmti(GSM * gsm, char const * result)
|
||||
{
|
||||
char memory[32];
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, result);
|
||||
#endif
|
||||
if(sscanf(result, "\"%31[^\"]\",%u", memory,
|
||||
&gsm->event.incoming_message.index) != 2)
|
||||
return 1;
|
||||
memory[sizeof(memory) - 1] = '\0';
|
||||
gsm->event.incoming_message.memory = memory;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* gsm_trigger_connect */
|
||||
static int _gsm_trigger_connect(GSM * gsm, char const * result,
|
||||
gboolean * answered)
|
||||
|
@ -43,6 +43,7 @@ typedef enum _GSMEventType
|
||||
GSM_EVENT_TYPE_CONTACT_LIST,
|
||||
GSM_EVENT_TYPE_FUNCTIONAL,
|
||||
GSM_EVENT_TYPE_INCOMING_CALL,
|
||||
GSM_EVENT_TYPE_INCOMING_MESSAGE,
|
||||
GSM_EVENT_TYPE_MESSAGE_LIST,
|
||||
GSM_EVENT_TYPE_MESSAGE_SENT,
|
||||
GSM_EVENT_TYPE_OPERATOR,
|
||||
@ -188,6 +189,14 @@ typedef union _GSMEvent
|
||||
GSMCallType calltype;
|
||||
} incoming_call;
|
||||
|
||||
/* GSM_EVENT_TYPE_INCOMING_MESSAGE */
|
||||
struct
|
||||
{
|
||||
GSMEventType type;
|
||||
char const * memory;
|
||||
unsigned int index;
|
||||
} incoming_message;
|
||||
|
||||
/* GSM_EVENT_TYPE_MESSAGE_SENT */
|
||||
struct
|
||||
{
|
||||
|
@ -1444,6 +1444,12 @@ static int _phone_gsm_event(GSMEvent * event, gpointer data)
|
||||
phone_show_call(phone, TRUE, PHONE_CALL_INCOMING, "",
|
||||
"");
|
||||
return 0;
|
||||
case GSM_EVENT_TYPE_INCOMING_MESSAGE:
|
||||
/* FIXME warn the user */
|
||||
_phone_fetch_messages(phone,
|
||||
event->incoming_message.index,
|
||||
event->incoming_message.index);
|
||||
return 0;
|
||||
case GSM_EVENT_TYPE_MESSAGE_LIST:
|
||||
_phone_fetch_messages(phone, event->message_list.start,
|
||||
event->message_list.end);
|
||||
|
Loading…
Reference in New Issue
Block a user