Fetching the messages in PDU mode (without any conversion yet)
This commit is contained in:
parent
9b4d92a322
commit
0bb228fe93
98
po/fr.po
98
po/fr.po
@ -7,7 +7,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Phone 0.0.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2010-05-09 21:13+0200\n"
|
||||
"POT-Creation-Date: 2010-05-10 09:21+0200\n"
|
||||
"PO-Revision-Date: 2010-04-24 02:07+0200\n"
|
||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||
"Language-Team: French\n"
|
||||
@ -112,7 +112,7 @@ msgstr "Délai d'attente du réseau dépassé"
|
||||
msgid "Network not allowed - emergency calls only"
|
||||
msgstr "Réseau non autorisé - appels d'urgence uniquement"
|
||||
|
||||
#: ../src/gsm.c:113 ../src/gsm.c:881 ../src/gsm.c:1064
|
||||
#: ../src/gsm.c:113 ../src/gsm.c:930 ../src/gsm.c:1113
|
||||
msgid "Unknown error"
|
||||
msgstr "Erreur inconnue"
|
||||
|
||||
@ -128,11 +128,11 @@ msgstr "Service SMS du ME réservé"
|
||||
msgid "Invalid PDU mode parameter"
|
||||
msgstr "Paramètre de mode PDU invalide"
|
||||
|
||||
#: ../src/gsm.c:309
|
||||
#: ../src/gsm.c:313
|
||||
msgid ": Unknown baudrate"
|
||||
msgstr ": Débit inconnu"
|
||||
|
||||
#: ../src/gsm.c:725
|
||||
#: ../src/gsm.c:769
|
||||
msgid "Event not handled"
|
||||
msgstr "Événement non géré"
|
||||
|
||||
@ -145,183 +145,183 @@ msgid ""
|
||||
" -F\tEnable hardware flow control (RTS/CTS)\n"
|
||||
msgstr ""
|
||||
|
||||
#: ../src/phone.c:231
|
||||
#: ../src/phone.c:247
|
||||
msgid "Initializing..."
|
||||
msgstr "Initialisation..."
|
||||
|
||||
#: ../src/phone.c:345
|
||||
#: ../src/phone.c:371
|
||||
msgid "Checking SIM PIN code..."
|
||||
msgstr "Vérification du code SIM PIN..."
|
||||
|
||||
#: ../src/phone.c:530
|
||||
#: ../src/phone.c:556
|
||||
msgid "Answer"
|
||||
msgstr "Répondre"
|
||||
|
||||
#: ../src/phone.c:537
|
||||
#: ../src/phone.c:563
|
||||
msgid "Hangup"
|
||||
msgstr "Raccrocher"
|
||||
|
||||
#: ../src/phone.c:544
|
||||
#: ../src/phone.c:570
|
||||
msgid "Reject"
|
||||
msgstr "Rejeter"
|
||||
|
||||
#: ../src/phone.c:567
|
||||
#: ../src/phone.c:593
|
||||
msgid "Loudspeaker"
|
||||
msgstr "Haut-parleur"
|
||||
|
||||
#: ../src/phone.c:575
|
||||
#: ../src/phone.c:601
|
||||
msgid "Mute microphone"
|
||||
msgstr "Couper le microphone"
|
||||
|
||||
#: ../src/phone.c:589
|
||||
#: ../src/phone.c:615
|
||||
msgid "Unknown contact"
|
||||
msgstr "Contact inconnu"
|
||||
|
||||
#: ../src/phone.c:596
|
||||
#: ../src/phone.c:622
|
||||
msgid "Unknown number"
|
||||
msgstr "Numéro inconnu"
|
||||
|
||||
#: ../src/phone.c:604
|
||||
#: ../src/phone.c:630
|
||||
msgid "In conversation"
|
||||
msgstr "En conversation"
|
||||
|
||||
#: ../src/phone.c:611
|
||||
#: ../src/phone.c:637
|
||||
msgid "Incoming call"
|
||||
msgstr "Appel entrant"
|
||||
|
||||
#: ../src/phone.c:617
|
||||
#: ../src/phone.c:643
|
||||
msgid "Outgoing call"
|
||||
msgstr "Appel sortant"
|
||||
|
||||
#: ../src/phone.c:624
|
||||
#: ../src/phone.c:650
|
||||
msgid "Call finished"
|
||||
msgstr "Appel terminé"
|
||||
|
||||
#: ../src/phone.c:677
|
||||
#: ../src/phone.c:703
|
||||
msgid "Enter"
|
||||
msgstr "Entrer"
|
||||
|
||||
#: ../src/phone.c:679
|
||||
#: ../src/phone.c:705
|
||||
msgid "Skip"
|
||||
msgstr "Ignorer"
|
||||
|
||||
#: ../src/phone.c:690
|
||||
#: ../src/phone.c:716
|
||||
msgid "Enter SIM PIN code"
|
||||
msgstr "Entrer le code SIM PIN"
|
||||
|
||||
#: ../src/phone.c:719
|
||||
#: ../src/phone.c:745
|
||||
msgid "Contacts"
|
||||
msgstr "Contacts"
|
||||
|
||||
#: ../src/phone.c:726 ../src/phone.c:816 ../src/phone.c:859
|
||||
#: ../src/phone.c:752 ../src/phone.c:958 ../src/phone.c:1001
|
||||
msgid "Call"
|
||||
msgstr "Appeler"
|
||||
|
||||
#: ../src/phone.c:736
|
||||
#: ../src/phone.c:762
|
||||
msgid "Write"
|
||||
msgstr "Écrire"
|
||||
|
||||
#: ../src/phone.c:758
|
||||
#: ../src/phone.c:784
|
||||
msgid "Contact"
|
||||
msgstr "Contact"
|
||||
|
||||
#: ../src/phone.c:788
|
||||
#: ../src/phone.c:930
|
||||
msgid "Dialer"
|
||||
msgstr "Composer"
|
||||
|
||||
#: ../src/phone.c:818
|
||||
#: ../src/phone.c:960
|
||||
msgid "Hang up"
|
||||
msgstr "Raccrocher"
|
||||
|
||||
#: ../src/phone.c:852
|
||||
#: ../src/phone.c:994
|
||||
msgid "Messages"
|
||||
msgstr "Messages"
|
||||
|
||||
#: ../src/phone.c:865
|
||||
#: ../src/phone.c:1007
|
||||
msgid "New message"
|
||||
msgstr "Nouveau message"
|
||||
|
||||
#: ../src/phone.c:871
|
||||
#: ../src/phone.c:1013
|
||||
msgid "Reply"
|
||||
msgstr "Répondre"
|
||||
|
||||
#: ../src/phone.c:889
|
||||
#: ../src/phone.c:1031
|
||||
msgid "Inbox"
|
||||
msgstr "Reçus"
|
||||
|
||||
#: ../src/phone.c:893
|
||||
#: ../src/phone.c:1035
|
||||
msgid "Sent"
|
||||
msgstr "Envoyés"
|
||||
|
||||
#: ../src/phone.c:909
|
||||
#: ../src/phone.c:1051
|
||||
msgid "Message"
|
||||
msgstr "Message"
|
||||
|
||||
#: ../src/phone.c:940
|
||||
#: ../src/phone.c:1082
|
||||
msgid "Write message"
|
||||
msgstr "Écrire un message"
|
||||
|
||||
#: ../src/phone.c:946 ../src/phone.c:952
|
||||
#: ../src/phone.c:1088 ../src/phone.c:1094
|
||||
msgid "Send"
|
||||
msgstr "Envoyer"
|
||||
|
||||
#: ../src/phone.c:1038
|
||||
#: ../src/phone.c:1180
|
||||
#, c-format
|
||||
msgid "%d message%s, %d/%d characters"
|
||||
msgstr "%d message%s, %d/%d caractères"
|
||||
|
||||
#: ../src/phone.c:1039
|
||||
#: ../src/phone.c:1181
|
||||
msgid "s"
|
||||
msgstr "s"
|
||||
|
||||
#: ../src/phone.c:1065
|
||||
#: ../src/phone.c:1207
|
||||
msgid "Sending message..."
|
||||
msgstr "Envoi du message..."
|
||||
|
||||
#: ../src/phone.c:1168
|
||||
#: ../src/phone.c:1310
|
||||
msgid "Operation in progress..."
|
||||
msgstr "Opération en cours..."
|
||||
|
||||
#: ../src/phone.c:1196 ../src/phone.c:1201
|
||||
#: ../src/phone.c:1338 ../src/phone.c:1343
|
||||
msgid "Error"
|
||||
msgstr "Erreur"
|
||||
|
||||
#: ../src/phone.c:1252 ../src/phone.c:1257
|
||||
#: ../src/phone.c:1394 ../src/phone.c:1399
|
||||
msgid "Information"
|
||||
msgstr "Information"
|
||||
|
||||
#: ../src/phone.c:1340
|
||||
#: ../src/phone.c:1482
|
||||
msgid "Unknown"
|
||||
msgstr "Inconnu"
|
||||
|
||||
#: ../src/phone.c:1343
|
||||
#: ../src/phone.c:1485
|
||||
msgid "Registering..."
|
||||
msgstr "Enregistrement..."
|
||||
|
||||
#: ../src/phone.c:1346
|
||||
#: ../src/phone.c:1488
|
||||
msgid "Denied"
|
||||
msgstr "Refusé"
|
||||
|
||||
#: ../src/phone.c:1349
|
||||
#: ../src/phone.c:1491
|
||||
msgid "SIM check..."
|
||||
msgstr "Vérification SIM..."
|
||||
|
||||
#: ../src/phone.c:1355
|
||||
#: ../src/phone.c:1497
|
||||
msgid "SIM ready..."
|
||||
msgstr "SIM prête..."
|
||||
|
||||
#: ../src/phone.c:1455
|
||||
#: ../src/phone.c:1609
|
||||
msgid "Message sent"
|
||||
msgstr "Message envoyé"
|
||||
|
||||
#: ../src/phone.c:1470
|
||||
#: ../src/phone.c:1627
|
||||
msgid "SIM PIN is valid"
|
||||
msgstr "Code SIM PIN valide"
|
||||
|
||||
#: ../src/phone.c:1509
|
||||
#: ../src/phone.c:1666
|
||||
msgid "Could not send message"
|
||||
msgstr "Le message n'a pas pu être envoyé"
|
||||
|
||||
#: ../src/phone.c:1517
|
||||
#: ../src/phone.c:1674
|
||||
msgid "Wrong SIM PIN code"
|
||||
msgstr "Code SIM PIN erroné"
|
||||
|
73
src/gsm.c
73
src/gsm.c
@ -168,6 +168,7 @@ static int _gsm_trigger_cme_error(GSM * gsm, char const * result,
|
||||
gboolean * answered);
|
||||
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_cmgr(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,
|
||||
@ -201,6 +202,7 @@ static GSMTrigger _gsm_triggers[] =
|
||||
GSM_TRIGGER("+CME ERROR: ", cme_error),
|
||||
GSM_TRIGGER("+CMS ERROR: ", cms_error),
|
||||
GSM_TRIGGER("+CMGL: ", cmgl),
|
||||
GSM_TRIGGER("+CMGR: ", cmgr),
|
||||
GSM_TRIGGER("+CMGS: ", cmgs),
|
||||
GSM_TRIGGER("+CMTI: ", cmti),
|
||||
GSM_TRIGGER("CONNECT", connect),
|
||||
@ -534,6 +536,11 @@ int gsm_event(GSM * gsm, GSMEventType type, ...)
|
||||
event->incoming_message.index = va_arg(ap,
|
||||
unsigned int);
|
||||
break;
|
||||
case GSM_EVENT_TYPE_MESSAGE:
|
||||
/* FIXME implement correctly */
|
||||
event->message.index = va_arg(ap, unsigned int);
|
||||
event->message.content = va_arg(ap, char const *);
|
||||
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);
|
||||
@ -586,16 +593,16 @@ int gsm_fetch_contacts(GSM * gsm, unsigned int start, unsigned int end)
|
||||
|
||||
|
||||
/* gsm_fetch_message_list */
|
||||
int gsm_fetch_message_list(GSM * gsm)
|
||||
int gsm_fetch_message_list(GSM * gsm, GSMMessageList list)
|
||||
{
|
||||
return gsm_modem_get_message_list(gsm->modem);
|
||||
return gsm_modem_get_message_list(gsm->modem, list);
|
||||
}
|
||||
|
||||
|
||||
/* gsm_fetch_messages */
|
||||
int gsm_fetch_messages(GSM * gsm, unsigned int start, unsigned int end)
|
||||
/* gsm_fetch_message */
|
||||
int gsm_fetch_message(GSM * gsm, unsigned int index)
|
||||
{
|
||||
return gsm_modem_get_messages(gsm->modem, start, end);
|
||||
return gsm_modem_get_message(gsm->modem, index);
|
||||
}
|
||||
|
||||
|
||||
@ -882,7 +889,9 @@ static int _parse_do(GSM * gsm, size_t * i)
|
||||
_gsm_event_set_status(gsm, GSM_STATUS_INITIALIZED);
|
||||
_gsm_queue_push(gsm);
|
||||
}
|
||||
else if(gsm->mode == GSM_MODE_COMMAND)
|
||||
else if(gsm->mode == GSM_MODE_COMMAND
|
||||
/* XXX not sure about PDU mode here */
|
||||
|| gsm->mode == GSM_MODE_PDU)
|
||||
{
|
||||
_gsm_parse_line(gsm, gsm->rd_buf, &answered);
|
||||
if(answered)
|
||||
@ -1178,16 +1187,49 @@ static int _gsm_trigger_cms_error(GSM * gsm, char const * result)
|
||||
/* gsm_trigger_cmgl */
|
||||
static int _gsm_trigger_cmgl(GSM * gsm, char const * result)
|
||||
{
|
||||
unsigned int * start = &gsm->event.message_list.start;
|
||||
unsigned int u;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, result);
|
||||
#endif
|
||||
if(sscanf(result, "(%u-%u)", &gsm->event.message_list.start,
|
||||
&gsm->event.message_list.end) != 2)
|
||||
return 1;
|
||||
/* FIXME this command may be long and the timeout triggered too soon */
|
||||
/* XXX we could already be reading the message at this point */
|
||||
if(sscanf(result, "%u,%u,%u,%u", start, &u, &u, &u) != 4
|
||||
&& sscanf(result, "%u,%u,,%u", start, &u, &u) != 3)
|
||||
/* XXX we may be stuck in PDU mode at this point */
|
||||
return gsm_event(gsm, GSM_EVENT_TYPE_ERROR,
|
||||
GSM_ERROR_MESSAGE_FETCH_FAILED,
|
||||
_("Unknown error"));
|
||||
gsm->event.message_list.end = *start;
|
||||
gsm->mode = GSM_MODE_PDU;
|
||||
return _gsm_event_send(gsm, GSM_EVENT_TYPE_MESSAGE_LIST);
|
||||
}
|
||||
|
||||
|
||||
/* gsm_trigger_cmgr */
|
||||
static int _gsm_trigger_cmgr(GSM * gsm, char const * result)
|
||||
{
|
||||
unsigned int stat;
|
||||
unsigned int alpha = 0;
|
||||
unsigned int length;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, result);
|
||||
#endif
|
||||
/* FIXME implement:
|
||||
* - store the index (and length?) somewhere
|
||||
* - then we (blindly) parse the PDU and report the message */
|
||||
if(sscanf(result, "%u,%u,%u", &stat, &alpha, &length) == 3
|
||||
|| sscanf(result, "%u,,%u", &stat, &length) == 2)
|
||||
return 0;
|
||||
/* FIXME actually parse the PDU */
|
||||
gsm->event.message.index = 0; /* FIXME implement */
|
||||
gsm->event.message.content = result;
|
||||
return _gsm_event_send(gsm, GSM_EVENT_TYPE_MESSAGE);
|
||||
}
|
||||
|
||||
|
||||
/* gsm_trigger_cmgs */
|
||||
static int _gsm_trigger_cmgs(GSM * gsm, char const * result)
|
||||
{
|
||||
@ -1582,7 +1624,7 @@ static gboolean _on_timeout(gpointer data)
|
||||
{
|
||||
GSM * gsm = data;
|
||||
GSMCommand * gsmc;
|
||||
char const * cmd;
|
||||
char const * cmd = "AT";
|
||||
size_t len;
|
||||
char * p;
|
||||
|
||||
@ -1594,16 +1636,17 @@ static gboolean _on_timeout(gpointer data)
|
||||
/* check if the write handler is still running */
|
||||
if(gsm->channel == NULL || gsm->wr_source != 0)
|
||||
return FALSE;
|
||||
if(gsm->queue == NULL || (gsmc = gsm->queue->data) == NULL)
|
||||
return FALSE;
|
||||
if((cmd = gsm_command_get_command(gsmc)) == NULL)
|
||||
if(gsm->mode == GSM_MODE_PDU) /* let's get out of here */
|
||||
gsm->mode = GSM_MODE_COMMAND;
|
||||
else if(gsm->queue == NULL || (gsmc = gsm->queue->data) == NULL
|
||||
/* re-inject the command */
|
||||
|| (cmd = gsm_command_get_command(gsmc)) == NULL)
|
||||
return FALSE;
|
||||
len = strlen(cmd) + 2;
|
||||
/* re-inject the command */
|
||||
if((p = realloc(gsm->wr_buf, len + 1)) == NULL)
|
||||
return FALSE;
|
||||
gsm->wr_buf = p;
|
||||
snprintf(p, len + 1, "%s%s", cmd, "\r\n");
|
||||
snprintf(gsm->wr_buf, len + 1, "%s%s", cmd, "\r\n");
|
||||
gsm->wr_buf_cnt = len;
|
||||
gsm->wr_source = g_io_add_watch(gsm->channel, G_IO_OUT,
|
||||
_on_watch_can_write, gsm);
|
||||
|
22
src/gsm.h
22
src/gsm.h
@ -44,6 +44,7 @@ typedef enum _GSMEventType
|
||||
GSM_EVENT_TYPE_FUNCTIONAL,
|
||||
GSM_EVENT_TYPE_INCOMING_CALL,
|
||||
GSM_EVENT_TYPE_INCOMING_MESSAGE,
|
||||
GSM_EVENT_TYPE_MESSAGE,
|
||||
GSM_EVENT_TYPE_MESSAGE_LIST,
|
||||
GSM_EVENT_TYPE_MESSAGE_SENT,
|
||||
GSM_EVENT_TYPE_OPERATOR,
|
||||
@ -84,6 +85,15 @@ typedef enum _GSMMessageFormat
|
||||
GSM_MESSAGE_FORMAT_TEXT = 1
|
||||
} GSMMessageFormat;
|
||||
|
||||
typedef enum _GSMMessageList
|
||||
{
|
||||
GSM_MESSAGE_LIST_UNREAD = 0,
|
||||
GSM_MESSAGE_LIST_READ = 1,
|
||||
GSM_MESSAGE_LIST_UNSENT = 2,
|
||||
GSM_MESSAGE_LIST_SENT = 3,
|
||||
GSM_MESSAGE_LIST_ALL = 4
|
||||
} GSMMessageList;
|
||||
|
||||
typedef enum _GSMMode
|
||||
{
|
||||
GSM_MODE_INIT = 0, GSM_MODE_COMMAND, GSM_MODE_PDU
|
||||
@ -207,6 +217,14 @@ typedef union _GSMEvent
|
||||
unsigned int index;
|
||||
} incoming_message;
|
||||
|
||||
/* GSM_EVENT_TYPE_MESSAGE */
|
||||
struct
|
||||
{
|
||||
GSMEventType type;
|
||||
unsigned int index;
|
||||
char const * content;
|
||||
} message;
|
||||
|
||||
/* GSM_EVENT_TYPE_MESSAGE_SENT */
|
||||
struct
|
||||
{
|
||||
@ -294,8 +312,8 @@ int gsm_event(GSM * gsm, GSMEventType type, ...);
|
||||
/* fetching data */
|
||||
int gsm_fetch_contact_list(GSM * gsm);
|
||||
int gsm_fetch_contacts(GSM * gsm, unsigned int start, unsigned int end);
|
||||
int gsm_fetch_message_list(GSM * gsm);
|
||||
int gsm_fetch_messages(GSM * gsm, unsigned int start, unsigned int end);
|
||||
int gsm_fetch_message_list(GSM * gsm, GSMMessageList list);
|
||||
int gsm_fetch_message(GSM * gsm, unsigned int index);
|
||||
int gsm_fetch_operator(GSM * gsm);
|
||||
int gsm_fetch_registration(GSM * gsm);
|
||||
int gsm_fetch_signal_level(GSM * gsm);
|
||||
|
30
src/modem.c
30
src/modem.c
@ -258,22 +258,38 @@ int gsm_modem_get_contacts(GSMModem * gsmm, unsigned int start,
|
||||
|
||||
|
||||
/* gsm_modem_get_message_list */
|
||||
int gsm_modem_get_message_list(GSMModem * gsmm)
|
||||
int gsm_modem_get_message_list(GSMModem * gsmm, GSMMessageList list)
|
||||
{
|
||||
char const cmd[] = "AT+CMGL=?";
|
||||
char cmd[] = "AT+CMGL=X";
|
||||
|
||||
switch(list)
|
||||
{
|
||||
case GSM_MESSAGE_LIST_UNREAD:
|
||||
case GSM_MESSAGE_LIST_READ:
|
||||
case GSM_MESSAGE_LIST_UNSENT:
|
||||
case GSM_MESSAGE_LIST_SENT:
|
||||
case GSM_MESSAGE_LIST_ALL:
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
if(gsm_modem_set_message_format(gsmm, GSM_MESSAGE_FORMAT_PDU) != 0)
|
||||
return 1;
|
||||
cmd[8] = list + '0';
|
||||
return gsm_queue_with_error(gsmm->gsm, cmd,
|
||||
GSM_ERROR_MESSAGE_LIST_FAILED);
|
||||
}
|
||||
|
||||
|
||||
/* gsm_modem_get_messages */
|
||||
int gsm_modem_get_messages(GSMModem * gsmm, unsigned int start,
|
||||
unsigned int end)
|
||||
/* gsm_modem_get_message */
|
||||
int gsm_modem_get_message(GSMModem * gsmm, unsigned int index)
|
||||
{
|
||||
char cmd[32];
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "%s%u,%u", "AT+CMGR=", start, end);
|
||||
|
||||
if(gsm_modem_set_message_format(gsmm, GSM_MESSAGE_FORMAT_PDU) != 0)
|
||||
return 1;
|
||||
snprintf(cmd, sizeof(cmd), "%s%u", "AT+CMGR=", index);
|
||||
/* XXX race condition here if the user forces out of PDU mode */
|
||||
return gsm_queue_full(gsmm->gsm, GSM_PRIORITY_LOW, cmd,
|
||||
GSM_ERROR_MESSAGE_FETCH_FAILED, NULL);
|
||||
}
|
||||
|
@ -54,9 +54,8 @@ int gsm_modem_enter_sim_pin(GSMModem * gsmm, char const * code);
|
||||
int gsm_modem_get_contact_list(GSMModem * gsmm);
|
||||
int gsm_modem_get_contacts(GSMModem * gsmm, unsigned int start,
|
||||
unsigned int end);
|
||||
int gsm_modem_get_message_list(GSMModem * gsmm);
|
||||
int gsm_modem_get_messages(GSMModem * gsmm, unsigned int start,
|
||||
unsigned int end);
|
||||
int gsm_modem_get_message_list(GSMModem * gsmm, GSMMessageList list);
|
||||
int gsm_modem_get_message(GSMModem * gsmm, unsigned int index);
|
||||
int gsm_modem_get_model(GSMModem * gsmm);
|
||||
int gsm_modem_get_operator(GSMModem * gsmm);
|
||||
int gsm_modem_get_registration(GSMModem * gsmm);
|
||||
|
32
src/phone.c
32
src/phone.c
@ -490,6 +490,19 @@ void phone_dialer_hangup(Phone * phone)
|
||||
|
||||
|
||||
/* messages */
|
||||
/* phone_messages_add */
|
||||
void phone_messages_add(Phone * phone, unsigned int index, char const * content)
|
||||
{
|
||||
GtkTreeIter iter;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "DEBUG: %s(%u, \"%s\")\n", __func__, index, content);
|
||||
#endif
|
||||
gtk_list_store_append(phone->me_store, &iter);
|
||||
gtk_list_store_set(phone->me_store, &iter, 0, index, 1, content, -1);
|
||||
}
|
||||
|
||||
|
||||
/* phone_messages_write */
|
||||
void phone_messages_write(Phone * phone, char const * number, char const * text)
|
||||
{
|
||||
@ -808,7 +821,6 @@ static struct
|
||||
{ "Answer call", gsm_call_answer },
|
||||
{ "Contact list", gsm_fetch_contact_list },
|
||||
{ "Hangup call", gsm_call_hangup },
|
||||
{ "Message list", gsm_fetch_message_list },
|
||||
{ "Operator", gsm_fetch_operator },
|
||||
{ "Phone active", gsm_is_phone_active },
|
||||
{ "Phone functional", gsm_is_functional },
|
||||
@ -1376,13 +1388,8 @@ static void _phone_fetch_messages(Phone * phone, unsigned int start,
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
for(i = start + 10; i < end; i+=10)
|
||||
{
|
||||
gsm_fetch_messages(phone->gsm, start, i);
|
||||
start = i;
|
||||
}
|
||||
if(start < end)
|
||||
gsm_fetch_messages(phone->gsm, start, end);
|
||||
for(i = start; i <= end; i++)
|
||||
gsm_fetch_message(phone->gsm, i);
|
||||
}
|
||||
|
||||
|
||||
@ -1601,10 +1608,13 @@ static int _phone_gsm_event(GSMEvent * event, gpointer data)
|
||||
return 0;
|
||||
case GSM_EVENT_TYPE_INCOMING_MESSAGE:
|
||||
/* FIXME warn the user */
|
||||
_phone_fetch_messages(phone,
|
||||
event->incoming_message.index,
|
||||
gsm_fetch_message(phone->gsm,
|
||||
event->incoming_message.index);
|
||||
return 0;
|
||||
case GSM_EVENT_TYPE_MESSAGE:
|
||||
phone_messages_add(phone, event->message.index,
|
||||
event->message.content);
|
||||
return 0;
|
||||
case GSM_EVENT_TYPE_MESSAGE_LIST:
|
||||
_phone_fetch_messages(phone, event->message_list.start,
|
||||
event->message_list.end);
|
||||
@ -1737,7 +1747,7 @@ static gboolean _phone_timeout_track(gpointer data)
|
||||
if(phone->tracks[PHONE_TRACK_MESSAGE_LIST])
|
||||
{
|
||||
_phone_track(phone, PHONE_TRACK_MESSAGE_LIST, FALSE);
|
||||
gsm_fetch_message_list(phone->gsm);
|
||||
gsm_fetch_message_list(phone->gsm, GSM_MESSAGE_LIST_ALL);
|
||||
}
|
||||
if(phone->tracks[PHONE_TRACK_MESSAGE_SENT])
|
||||
_phone_progress_pulse(phone->wr_progress);
|
||||
|
@ -95,6 +95,8 @@ void phone_dialer_call(Phone * phone, char const * number);
|
||||
void phone_dialer_hangup(Phone * phone);
|
||||
|
||||
/* messages */
|
||||
void phone_messages_add(Phone * phone, unsigned int index,
|
||||
char const * content);
|
||||
void phone_messages_write(Phone * phone, char const * number,
|
||||
char const * text);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user