From f57a3d7846ef0b575a8fd558f3fa1463d4cc0c4a Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 2 May 2010 02:09:11 +0000 Subject: [PATCH] Can now sometimes determine voice calls among incoming calls --- src/gsm.c | 16 +++++++++++++--- src/gsm.h | 13 +++++++++++-- src/phone.c | 2 ++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/gsm.c b/src/gsm.c index 619a6f1..f7e1bdb 100644 --- a/src/gsm.c +++ b/src/gsm.c @@ -731,6 +731,8 @@ static int _gsm_event(GSM * gsm, GSMEventType type, ...) event->functional.functional = va_arg(ap, unsigned int); break; case GSM_EVENT_TYPE_INCOMING_CALL: + event->incoming_call.calltype = va_arg(ap, + unsigned int); break; case GSM_EVENT_TYPE_MESSAGE_LIST: event->message_list.start = va_arg(ap, unsigned int); @@ -1400,7 +1402,8 @@ static int _gsm_parse_line(GSM * gsm, char const * line, gboolean * answered) return 0; if(strcmp(line, "RING") == 0) { - _gsm_event(gsm, GSM_EVENT_TYPE_INCOMING_CALL); + _gsm_event(gsm, GSM_EVENT_TYPE_INCOMING_CALL, + GSM_CALL_TYPE_UNKNOWN); return 0; } if(strcmp(line, "OK") == 0) @@ -1825,8 +1828,15 @@ static int _gsm_trigger_creg(GSM * gsm, char const * result) /* gsm_trigger_cring */ static int _gsm_trigger_cring(GSM * gsm, char const * result) { - /* FIXME implement the call type */ - return _gsm_event_send(gsm, GSM_EVENT_TYPE_INCOMING_CALL); + GSMCallType calltype = GSM_CALL_TYPE_UNKNOWN; + +#ifdef DEBUG + fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, result); +#endif + /* XXX implement the other call types */ + if(strcmp(result, "VOICE") == 0) + calltype = GSM_CALL_TYPE_VOICE; + return _gsm_event(gsm, GSM_EVENT_TYPE_INCOMING_CALL, calltype); } diff --git a/src/gsm.h b/src/gsm.h index ada3fc5..a9e3e5c 100644 --- a/src/gsm.h +++ b/src/gsm.h @@ -23,7 +23,9 @@ /* types */ typedef enum _GSMCallType { - GSM_CALL_TYPE_DATA, GSM_CALL_TYPE_VOICE + GSM_CALL_TYPE_UNKNOWN = 0, + GSM_CALL_TYPE_DATA, + GSM_CALL_TYPE_VOICE } GSMCallType; typedef enum _GSMEventType @@ -82,7 +84,7 @@ typedef enum _GSMOperatorMode GSM_OPERATOR_MODE_MANUAL_WITH_FALLBACK = 4 } GSMOperatorMode; -typedef enum _GSMRegisrationReport +typedef enum _GSMRegistrationReport { GSM_REGISTRATION_REPORT_DISABLE_UNSOLLICITED = 0, GSM_REGISTRATION_REPORT_ENABLE_UNSOLLICITED = 1, @@ -147,6 +149,13 @@ typedef union _GSMEvent unsigned int functional; } functional; + /* GSM_EVENT_TYPE_INCOMING_CALL */ + struct + { + GSMEventType type; + GSMCallType calltype; + } incoming_call; + /* GSM_EVENT_TYPE_MESSAGE_SENT */ struct { diff --git a/src/phone.c b/src/phone.c index c0811f8..4e5bbe3 100644 --- a/src/phone.c +++ b/src/phone.c @@ -1100,6 +1100,8 @@ static int _phone_gsm_event(GSMEvent * event, gpointer data) event->contact_list.end); return 0; case GSM_EVENT_TYPE_FUNCTIONAL: + /* FIXME implement */ + return 0; case GSM_EVENT_TYPE_INCOMING_CALL: /* FIXME implement */ return 0;