Improving contact support
This commit is contained in:
parent
af22de5f89
commit
37a78d4a0b
@ -146,6 +146,7 @@ typedef enum _ModemEventType
|
|||||||
MODEM_EVENT_TYPE_CALL,
|
MODEM_EVENT_TYPE_CALL,
|
||||||
MODEM_EVENT_TYPE_CONNECTION,
|
MODEM_EVENT_TYPE_CONNECTION,
|
||||||
MODEM_EVENT_TYPE_CONTACT,
|
MODEM_EVENT_TYPE_CONTACT,
|
||||||
|
MODEM_EVENT_TYPE_CONTACT_DELETED,
|
||||||
MODEM_EVENT_TYPE_MESSAGE,
|
MODEM_EVENT_TYPE_MESSAGE,
|
||||||
MODEM_EVENT_TYPE_MESSAGE_DELETED,
|
MODEM_EVENT_TYPE_MESSAGE_DELETED,
|
||||||
MODEM_EVENT_TYPE_MESSAGE_SENT,
|
MODEM_EVENT_TYPE_MESSAGE_SENT,
|
||||||
@ -214,6 +215,13 @@ typedef union _ModemEvent
|
|||||||
char const * number;
|
char const * number;
|
||||||
} contact;
|
} contact;
|
||||||
|
|
||||||
|
/* MODEM_EVENT_TYPE_CONTACT_DELETED */
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ModemEventType type;
|
||||||
|
unsigned int id;
|
||||||
|
} contact_deleted;
|
||||||
|
|
||||||
/* MODEM_EVENT_TYPE_MESSAGE */
|
/* MODEM_EVENT_TYPE_MESSAGE */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -337,7 +345,6 @@ typedef union _ModemRequest
|
|||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
ModemRequestType type;
|
ModemRequestType type;
|
||||||
unsigned int id;
|
|
||||||
char const * name;
|
char const * name;
|
||||||
char const * number;
|
char const * number;
|
||||||
} contact_new;
|
} contact_new;
|
||||||
|
@ -205,7 +205,6 @@ int modem_request_type(Modem * modem, ModemRequestType type, ...)
|
|||||||
request.contact.id = va_arg(ap, unsigned int);
|
request.contact.id = va_arg(ap, unsigned int);
|
||||||
break;
|
break;
|
||||||
case MODEM_REQUEST_CONTACT_NEW:
|
case MODEM_REQUEST_CONTACT_NEW:
|
||||||
request.contact_new.id = va_arg(ap, unsigned int);
|
|
||||||
request.contact_new.name = va_arg(ap, char const *);
|
request.contact_new.name = va_arg(ap, char const *);
|
||||||
request.contact_new.number = va_arg(ap, char const *);
|
request.contact_new.number = va_arg(ap, char const *);
|
||||||
break;
|
break;
|
||||||
|
@ -230,6 +230,11 @@ static int _debug_request(ModemPlugin * modem, ModemRequest * request)
|
|||||||
memset(&event, 0, sizeof(event));
|
memset(&event, 0, sizeof(event));
|
||||||
switch(request->type)
|
switch(request->type)
|
||||||
{
|
{
|
||||||
|
case MODEM_REQUEST_CONTACT_DELETE:
|
||||||
|
event.type = MODEM_EVENT_TYPE_CONTACT_DELETED;
|
||||||
|
event.contact_deleted.id = request->contact_delete.id;
|
||||||
|
helper->event(helper->modem, &event);
|
||||||
|
break;
|
||||||
case MODEM_REQUEST_CONTACT_NEW:
|
case MODEM_REQUEST_CONTACT_NEW:
|
||||||
debug->event_contact.type = MODEM_EVENT_TYPE_CONTACT;
|
debug->event_contact.type = MODEM_EVENT_TYPE_CONTACT;
|
||||||
debug->event_contact.contact.id++;
|
debug->event_contact.contact.id++;
|
||||||
|
@ -273,6 +273,8 @@ static HayesCommandStatus _on_request_call_outgoing(HayesCommand * command,
|
|||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
static HayesCommandStatus _on_request_call_status(HayesCommand * command,
|
static HayesCommandStatus _on_request_call_status(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
|
static HayesCommandStatus _on_request_contact_delete(HayesCommand * command,
|
||||||
|
HayesCommandStatus status, void * priv);
|
||||||
static HayesCommandStatus _on_request_contact_list(HayesCommand * command,
|
static HayesCommandStatus _on_request_contact_list(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv);
|
HayesCommandStatus status, void * priv);
|
||||||
static HayesCommandStatus _on_request_functional(HayesCommand * command,
|
static HayesCommandStatus _on_request_functional(HayesCommand * command,
|
||||||
@ -492,6 +494,8 @@ static HayesRequestHandler _hayes_request_handlers[] =
|
|||||||
_on_request_call_status },
|
_on_request_call_status },
|
||||||
{ MODEM_REQUEST_CALL_PRESENTATION, NULL,
|
{ MODEM_REQUEST_CALL_PRESENTATION, NULL,
|
||||||
_on_request_generic },
|
_on_request_generic },
|
||||||
|
{ MODEM_REQUEST_CONTACT_DELETE, NULL,
|
||||||
|
_on_request_contact_delete },
|
||||||
{ MODEM_REQUEST_CONTACT_LIST, "AT+CPBR=?",
|
{ MODEM_REQUEST_CONTACT_LIST, "AT+CPBR=?",
|
||||||
_on_request_contact_list },
|
_on_request_contact_list },
|
||||||
{ MODEM_REQUEST_MESSAGE, NULL,
|
{ MODEM_REQUEST_MESSAGE, NULL,
|
||||||
@ -609,6 +613,8 @@ static char * _request_attention_apn(char const * protocol, char const * apn);
|
|||||||
static char * _request_attention_call(ModemPlugin * modem,
|
static char * _request_attention_call(ModemPlugin * modem,
|
||||||
ModemRequest * request);
|
ModemRequest * request);
|
||||||
static char * _request_attention_call_hangup(ModemPlugin * modem);
|
static char * _request_attention_call_hangup(ModemPlugin * modem);
|
||||||
|
static char * _request_attention_contact_delete(ModemPlugin * modem,
|
||||||
|
unsigned int id);
|
||||||
static char * _request_attention_contact_list(ModemRequest * request);
|
static char * _request_attention_contact_list(ModemRequest * request);
|
||||||
static char * _request_attention_gprs(ModemPlugin * modem,
|
static char * _request_attention_gprs(ModemPlugin * modem,
|
||||||
char const * username, char const * password);
|
char const * username, char const * password);
|
||||||
@ -700,12 +706,15 @@ static char * _request_attention(ModemPlugin * modem, ModemRequest * request)
|
|||||||
request->call_presentation.enabled
|
request->call_presentation.enabled
|
||||||
? 1 : 0);
|
? 1 : 0);
|
||||||
return strdup(buf);
|
return strdup(buf);
|
||||||
|
case MODEM_REQUEST_CONTACT_DELETE:
|
||||||
|
return _request_attention_contact_delete(modem,
|
||||||
|
request->contact_delete.id);
|
||||||
case MODEM_REQUEST_MESSAGE:
|
case MODEM_REQUEST_MESSAGE:
|
||||||
return _request_attention_message(modem,
|
return _request_attention_message(modem,
|
||||||
request->message.id);
|
request->message.id);
|
||||||
case MODEM_REQUEST_MESSAGE_DELETE:
|
case MODEM_REQUEST_MESSAGE_DELETE:
|
||||||
return _request_attention_message_delete(modem,
|
return _request_attention_message_delete(modem,
|
||||||
request->message.id);
|
request->message_delete.id);
|
||||||
case MODEM_REQUEST_MESSAGE_SEND:
|
case MODEM_REQUEST_MESSAGE_SEND:
|
||||||
return _request_attention_message_send(modem,
|
return _request_attention_message_send(modem,
|
||||||
request->message_send.number,
|
request->message_send.number,
|
||||||
@ -793,6 +802,19 @@ static char * _request_attention_call_hangup(ModemPlugin * modem)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char * _request_attention_contact_delete(ModemPlugin * modem,
|
||||||
|
unsigned int id)
|
||||||
|
{
|
||||||
|
Hayes * hayes = modem->priv;
|
||||||
|
char const cmd[] = "AT+CPBW=";
|
||||||
|
char buf[32];
|
||||||
|
|
||||||
|
/* FIXME store in the command itself */
|
||||||
|
hayes->events[MODEM_EVENT_TYPE_CONTACT_DELETED].contact_deleted.id = id;
|
||||||
|
snprintf(buf, sizeof(buf), "%s%u%s", cmd, id, ",\"\"");
|
||||||
|
return strdup(buf);
|
||||||
|
}
|
||||||
|
|
||||||
static char * _request_attention_contact_list(ModemRequest * request)
|
static char * _request_attention_contact_list(ModemRequest * request)
|
||||||
{
|
{
|
||||||
HayesRequestContactList * list = request->plugin.data;
|
HayesRequestContactList * list = request->plugin.data;
|
||||||
@ -1069,7 +1091,8 @@ static int _hayes_trigger(ModemPlugin * modem, ModemEventType event)
|
|||||||
e = &hayes->events[MODEM_EVENT_TYPE_STATUS];
|
e = &hayes->events[MODEM_EVENT_TYPE_STATUS];
|
||||||
modem->helper->event(modem->helper->modem, e);
|
modem->helper->event(modem->helper->modem, e);
|
||||||
break;
|
break;
|
||||||
case MODEM_EVENT_TYPE_ERROR: /* do not make sense */
|
case MODEM_EVENT_TYPE_CONTACT_DELETED: /* do not make sense */
|
||||||
|
case MODEM_EVENT_TYPE_ERROR:
|
||||||
case MODEM_EVENT_TYPE_MESSAGE:
|
case MODEM_EVENT_TYPE_MESSAGE:
|
||||||
case MODEM_EVENT_TYPE_MESSAGE_DELETED:
|
case MODEM_EVENT_TYPE_MESSAGE_DELETED:
|
||||||
case MODEM_EVENT_TYPE_MESSAGE_SENT:
|
case MODEM_EVENT_TYPE_MESSAGE_SENT:
|
||||||
@ -2293,6 +2316,21 @@ static HayesCommandStatus _on_request_call_status(HayesCommand * command,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* on_request_contact_delete */
|
||||||
|
static HayesCommandStatus _on_request_contact_delete(HayesCommand * command,
|
||||||
|
HayesCommandStatus status, void * priv)
|
||||||
|
{
|
||||||
|
ModemPlugin * modem = priv;
|
||||||
|
Hayes * hayes = modem->priv;
|
||||||
|
ModemEvent * event = &hayes->events[MODEM_EVENT_TYPE_CONTACT_DELETED];
|
||||||
|
|
||||||
|
if((status = _on_request_generic(command, status, priv)) != HCS_SUCCESS)
|
||||||
|
return status;
|
||||||
|
modem->helper->event(modem->helper->modem, event);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* on_request_contact_list */
|
/* on_request_contact_list */
|
||||||
static HayesCommandStatus _on_request_contact_list(HayesCommand * command,
|
static HayesCommandStatus _on_request_contact_list(HayesCommand * command,
|
||||||
HayesCommandStatus status, void * priv)
|
HayesCommandStatus status, void * priv)
|
||||||
|
Loading…
Reference in New Issue
Block a user