Index: common/phones/atgen.c =================================================================== RCS file: /sources/gnokii/gnokii/common/phones/atgen.c,v retrieving revision 1.143 diff -u -p -r1.143 atgen.c --- common/phones/atgen.c 1 May 2007 23:50:14 -0000 1.143 +++ common/phones/atgen.c 2 Jul 2007 19:05:37 -0000 @@ -1563,6 +1563,52 @@ static gn_error ReplyGetSMS(int messaget if (!data->raw_sms) return GN_ERR_INTERNALERROR; + /* Try to figure out the status first */ + tmp = strchr (buf.line2, ','); + if (tmp != NULL && ((char *) tmp - buf.line2 - strlen ("+CMGR: ")) >= 1) { + char *status; + int len; + + len = (char *) tmp - buf.line2 - strlen ("+CMGR: "); + status = malloc (len + 1); + if (!status) { + dprintf("Not enough memory for buffer.\n"); + return GN_ERR_INTERNALERROR; + } + + memcpy (status, buf.line2 + strlen ("+CMGR: "), len); + status[len] = '\0'; + + if (strcmp (status, "\"REC UNREAD\"") == 0) { + data->raw_sms->status = GN_SMS_Unread; + } else if (strcmp (status, "\"REC READ\"") == 0) { + data->raw_sms->status = GN_SMS_Read; + } else if (strcmp (status, "\"STO UNSENT\"") == 0) { + data->raw_sms->status = GN_SMS_Unsent; + } else if (strcmp (status, "\"STO SENT\"") == 0) { + data->raw_sms->status = GN_SMS_Sent; + } else { + int s; + + s = atoi (status); + switch (s) { + case 0: + data->raw_sms->status = GN_SMS_Unread; + break; + case 1: + data->raw_sms->status = GN_SMS_Read; + break; + case 2: + data->raw_sms->status = GN_SMS_Unsent; + break; + case 3: + data->raw_sms->status = GN_SMS_Sent; + break; + } + } + free(status); + } + tmp = strrchr(buf.line2, ','); /* The following sequence is correct for emtpy location: * w: AT+CMGR=9