Code cleanup

This commit is contained in:
Pierre Pronchery 2010-06-03 19:00:59 +00:00
parent d921529f79
commit 7f9119e06e
2 changed files with 12 additions and 15 deletions

View File

@ -1450,7 +1450,6 @@ static int _gsm_trigger_cmgr(GSM * gsm, char const * result)
struct tm t; struct tm t;
char * p; char * p;
GSMCommand * gsmc; GSMCommand * gsmc;
char * q;
size_t l = 0; size_t l = 0;
#ifdef DEBUG #ifdef DEBUG
@ -1485,22 +1484,14 @@ static int _gsm_trigger_cmgr(GSM * gsm, char const * result)
} }
else if((p = _cmgr_pdu_parse(result, &gsm->event.message.date, else if((p = _cmgr_pdu_parse(result, &gsm->event.message.date,
gsm->number, gsm->number,
&gsm->event.message.encoding, &gsm->event.message.encoding, &l))
&l)) != NULL) != NULL)
{ {
gsm->event.message.index = 0; gsm->event.message.index = 0;
if((gsmc = g_slist_nth_data(gsm->queue, 0)) != NULL) if((gsmc = g_slist_nth_data(gsm->queue, 0)) != NULL)
gsm->event.message.index /* XXX ugly */ gsm->event.message.index /* XXX ugly */
= (unsigned long)gsm_command_get_data(gsmc); = (unsigned long)gsm_command_get_data(gsmc);
gsm->event.message.number = gsm->number; /* XXX ugly */ gsm->event.message.number = gsm->number; /* XXX ugly */
if(gsm->event.message.encoding == GSM_ENCODING_UTF8
&& (q = g_convert(p, -1, "UTF-8", "ISO-8859-1",
NULL, NULL, NULL)) != NULL)
{
free(p);
p = q;
l = strlen(p) + 1;
}
gsm->event.message.length = l; gsm->event.message.length = l;
gsm->event.message.content = p; gsm->event.message.content = p;
_gsm_event_send(gsm, GSM_EVENT_TYPE_MESSAGE); _gsm_event_send(gsm, GSM_EVENT_TYPE_MESSAGE);
@ -1597,6 +1588,7 @@ static char * _cmgr_pdu_parse_encoding_default(char const * pdu, size_t len,
char const * q; char const * q;
unsigned int u; unsigned int u;
unsigned char byte; unsigned char byte;
char * r;
if((p = malloc(len - i + 1)) == NULL) if((p = malloc(len - i + 1)) == NULL)
return NULL; return NULL;
@ -1628,8 +1620,14 @@ static char * _cmgr_pdu_parse_encoding_default(char const * pdu, size_t len,
} }
} }
*encoding = GSM_ENCODING_UTF8; *encoding = GSM_ENCODING_UTF8;
if((r = g_convert((char *)p, j, "UTF-8", "ISO-8859-1", NULL, NULL,
NULL)) != NULL)
{
free(p);
p = (unsigned char *)r;
j = strlen(r);
}
*length = j; *length = j;
p[j] = '\0';
return (char *)p; return (char *)p;
} }

View File

@ -432,8 +432,6 @@ static void _on_plug_embedded(gpointer data)
/* phone_delete */ /* phone_delete */
void phone_delete(Phone * phone) void phone_delete(Phone * phone)
{ {
PhonePlugin * plugin;
phone_unload_all(phone); phone_unload_all(phone);
if(phone->config != NULL) if(phone->config != NULL)
config_delete(phone->config); config_delete(phone->config);
@ -2472,9 +2470,10 @@ static int _gsm_event_message(Phone * phone, GSMEvent * event)
encoding = event->message.encoding; encoding = event->message.encoding;
length = event->message.length; length = event->message.length;
if((content = malloc(length)) == NULL) if((content = malloc(length + 1)) == NULL)
return 1; /* XXX report error */ return 1; /* XXX report error */
memcpy(content, event->message.content, length); memcpy(content, event->message.content, length);
content[length] = '\0'; /* just in case */
phone_event(phone, PHONE_EVENT_SMS_RECEIVING, &encoding, &content, phone_event(phone, PHONE_EVENT_SMS_RECEIVING, &encoding, &content,
&length); &length);
phone_event(phone, PHONE_EVENT_SMS_RECEIVED); phone_event(phone, PHONE_EVENT_SMS_RECEIVED);