Code cleanup

This commit is contained in:
Pierre Pronchery 2011-11-01 16:57:12 +00:00
parent 701fb5d87c
commit 2f8a06d2ec
6 changed files with 116 additions and 92 deletions

View File

@ -250,6 +250,7 @@ typedef union _ModemEvent
{ {
ModemEventType type; ModemEventType type;
unsigned int id; unsigned int id;
/* FIXME add a field for errors? */
} message_deleted, message_sent; } message_deleted, message_sent;
/* MODEM_EVENT_TYPE_MODEL */ /* MODEM_EVENT_TYPE_MODEL */

142
po/fr.po
View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Phone 0.0.0\n" "Project-Id-Version: Phone 0.0.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2011-11-01 14:14+0100\n" "POT-Creation-Date: 2011-11-01 17:56+0100\n"
"PO-Revision-Date: 2010-04-24 02:07+0200\n" "PO-Revision-Date: 2010-04-24 02:07+0200\n"
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n" "Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
"Language-Team: DeforaOS development (French) <devel-fr@lists.defora.org>\n" "Language-Team: DeforaOS development (French) <devel-fr@lists.defora.org>\n"
@ -47,11 +47,11 @@ msgstr "Brouillons"
msgid "Trash" msgid "Trash"
msgstr "Corbeille" msgstr "Corbeille"
#: ../src/phone.c:507 ../src/phone.c:2633 #: ../src/phone.c:507 ../src/phone.c:2629
msgid "System preferences" msgid "System preferences"
msgstr "Préférences système" msgstr "Préférences système"
#: ../src/phone.c:518 ../src/phone.c:2059 #: ../src/phone.c:518 ../src/phone.c:2055
msgid "Plug-ins" msgid "Plug-ins"
msgstr "Greffons" msgstr "Greffons"
@ -64,276 +64,276 @@ msgstr "Vérification %s..."
msgid "Delete this contact?" msgid "Delete this contact?"
msgstr "Supprimer ce contact?" msgstr "Supprimer ce contact?"
#: ../src/phone.c:1128 ../src/phone.c:1294 #: ../src/phone.c:1124 ../src/phone.c:1290
msgid "Delete this message?" msgid "Delete this message?"
msgstr "Supprimer ce message?" msgstr "Supprimer ce message?"
#: ../src/phone.c:1134 ../src/phone.c:1299 #: ../src/phone.c:1130 ../src/phone.c:1295
msgid "Deleting message..." msgid "Deleting message..."
msgstr "Suppression du message..." msgstr "Suppression du message..."
#: ../src/phone.c:1383 #: ../src/phone.c:1379
msgid "translator-credits" msgid "translator-credits"
msgstr "Pierre Pronchery <khorben@defora.org>" msgstr "Pierre Pronchery <khorben@defora.org>"
#: ../src/phone.c:1430 #: ../src/phone.c:1426
msgid "Unknown contact" msgid "Unknown contact"
msgstr "Contact inconnu" msgstr "Contact inconnu"
#: ../src/phone.c:1433 #: ../src/phone.c:1429
msgid "Unknown number" msgid "Unknown number"
msgstr "Numéro inconnu" msgstr "Numéro inconnu"
#: ../src/phone.c:1452 #: ../src/phone.c:1448
msgid "In conversation" msgid "In conversation"
msgstr "En conversation" msgstr "En conversation"
#: ../src/phone.c:1463 #: ../src/phone.c:1459
msgid "Incoming call" msgid "Incoming call"
msgstr "Appel entrant" msgstr "Appel entrant"
#: ../src/phone.c:1473 #: ../src/phone.c:1469
msgid "Outgoing call" msgid "Outgoing call"
msgstr "Appel sortant" msgstr "Appel sortant"
#: ../src/phone.c:1484 #: ../src/phone.c:1480
msgid "Call finished" msgid "Call finished"
msgstr "Appel terminé" msgstr "Appel terminé"
#: ../src/phone.c:1518 #: ../src/phone.c:1514
msgid "_Answer" msgid "_Answer"
msgstr "_Répondre" msgstr "_Répondre"
#: ../src/phone.c:1523 #: ../src/phone.c:1519
msgid "_Hangup" msgid "_Hangup"
msgstr "Ra_ccrocher" msgstr "Ra_ccrocher"
#: ../src/phone.c:1528 #: ../src/phone.c:1524
msgid "_Reject" msgid "_Reject"
msgstr "Re_jeter" msgstr "Re_jeter"
#: ../src/phone.c:1549 #: ../src/phone.c:1545
msgid "Loudspeaker" msgid "Loudspeaker"
msgstr "Haut-parleur" msgstr "Haut-parleur"
#: ../src/phone.c:1557 #: ../src/phone.c:1553
msgid "Mute microphone" msgid "Mute microphone"
msgstr "Couper le microphone" msgstr "Couper le microphone"
#: ../src/phone.c:1565 #: ../src/phone.c:1561
msgid "Show dialer" msgid "Show dialer"
msgstr "Afficher le cadran" msgstr "Afficher le cadran"
#: ../src/phone.c:1606 #: ../src/phone.c:1602
#, c-format #, c-format
msgid "Enter %s" msgid "Enter %s"
msgstr "Entrer %s" msgstr "Entrer %s"
#: ../src/phone.c:1649 #: ../src/phone.c:1645
msgid "Enter" msgid "Enter"
msgstr "Entrer" msgstr "Entrer"
#: ../src/phone.c:1651 #: ../src/phone.c:1647
msgid "Skip" msgid "Skip"
msgstr "Ignorer" msgstr "Ignorer"
#: ../src/phone.c:1679 #: ../src/phone.c:1675
msgid "Contacts" msgid "Contacts"
msgstr "Contacts" msgstr "Contacts"
#: ../src/phone.c:1685 ../src/phone.c:1804 ../src/phone.c:1840 #: ../src/phone.c:1681 ../src/phone.c:1800 ../src/phone.c:1836
#: ../src/phone.c:1955 ../src/phone.c:2311 #: ../src/phone.c:1951 ../src/phone.c:2307
msgid "Call" msgid "Call"
msgstr "Appeler" msgstr "Appeler"
#: ../src/phone.c:1691 #: ../src/phone.c:1687
msgid "Write" msgid "Write"
msgstr "Écrire" msgstr "Écrire"
#: ../src/phone.c:1733 ../src/phone.c:2090 ../src/phone.c:2422 #: ../src/phone.c:1729 ../src/phone.c:2086 ../src/phone.c:2418
msgid "Name" msgid "Name"
msgstr "Nom" msgstr "Nom"
#: ../src/phone.c:1779 #: ../src/phone.c:1775
msgid "Dialer" msgid "Dialer"
msgstr "Composer" msgstr "Composer"
#: ../src/phone.c:1806 #: ../src/phone.c:1802
msgid "Hang up" msgid "Hang up"
msgstr "Raccrocher" msgstr "Raccrocher"
#: ../src/phone.c:1834 #: ../src/phone.c:1830
msgid "Phone logs" msgid "Phone logs"
msgstr "Journal d'appels" msgstr "Journal d'appels"
#: ../src/phone.c:1846 #: ../src/phone.c:1842
msgid "Message" msgid "Message"
msgstr "Message" msgstr "Message"
#: ../src/phone.c:1877 #: ../src/phone.c:1873
msgid "Direction" msgid "Direction"
msgstr "Direction" msgstr "Direction"
#: ../src/phone.c:1882 ../src/phone.c:2001 #: ../src/phone.c:1878 ../src/phone.c:1997
msgid "To/From" msgid "To/From"
msgstr "Vers/De" msgstr "Vers/De"
#: ../src/phone.c:1888 ../src/phone.c:2009 #: ../src/phone.c:1884 ../src/phone.c:2005
msgid "Date" msgid "Date"
msgstr "Date" msgstr "Date"
#: ../src/phone.c:1949 #: ../src/phone.c:1945
msgid "Messages" msgid "Messages"
msgstr "Messages" msgstr "Messages"
#: ../src/phone.c:1960 #: ../src/phone.c:1956
msgid "New message" msgid "New message"
msgstr "Nouveau message" msgstr "Nouveau message"
#: ../src/phone.c:1966 ../src/phone.c:2317 #: ../src/phone.c:1962 ../src/phone.c:2313
msgid "Reply" msgid "Reply"
msgstr "Répondre" msgstr "Répondre"
#: ../src/phone.c:2078 #: ../src/phone.c:2074
msgid "Enabled" msgid "Enabled"
msgstr "Activé" msgstr "Activé"
#: ../src/phone.c:2305 #: ../src/phone.c:2301
msgid "Read message" msgid "Read message"
msgstr "Lire le message" msgstr "Lire le message"
#: ../src/phone.c:2323 #: ../src/phone.c:2319
msgid "Forward" msgid "Forward"
msgstr "Transmettre" msgstr "Transmettre"
#: ../src/phone.c:2397 #: ../src/phone.c:2393
msgid "Phone settings" msgid "Phone settings"
msgstr "Paramètres du téléphone" msgstr "Paramètres du téléphone"
#: ../src/phone.c:2474 #: ../src/phone.c:2470
msgid "missed calls" msgid "missed calls"
msgstr "appels manqués" msgstr "appels manqués"
#: ../src/phone.c:2474 #: ../src/phone.c:2470
msgid "missed call" msgid "missed call"
msgstr "appel manqué" msgstr "appel manqué"
#: ../src/phone.c:2483 #: ../src/phone.c:2479
msgid "new messages" msgid "new messages"
msgstr "nouveaux messages" msgstr "nouveaux messages"
#: ../src/phone.c:2484 #: ../src/phone.c:2480
msgid "new message" msgid "new message"
msgstr "nouveau message" msgstr "nouveau message"
#: ../src/phone.c:2502 ../src/phone.c:3438 ../src/phone.c:3442 #: ../src/phone.c:2498 ../src/phone.c:3436 ../src/phone.c:3440
msgid "Information" msgid "Information"
msgstr "Information" msgstr "Information"
#: ../src/phone.c:2512 #: ../src/phone.c:2508
msgid "Status" msgid "Status"
msgstr "État" msgstr "État"
#: ../src/phone.c:2536 #: ../src/phone.c:2532
msgid "_View" msgid "_View"
msgstr "_Vue" msgstr "_Vue"
#: ../src/phone.c:2555 #: ../src/phone.c:2551
msgid "_Read" msgid "_Read"
msgstr "_Lire" msgstr "_Lire"
#: ../src/phone.c:2687 #: ../src/phone.c:2683
msgid "Open file..." msgid "Open file..."
msgstr "Ouvrir fichier..." msgstr "Ouvrir fichier..."
#: ../src/phone.c:2858 #: ../src/phone.c:2855
msgid "Write message" msgid "Write message"
msgstr "Écrire un message" msgstr "Écrire un message"
#: ../src/phone.c:2864 #: ../src/phone.c:2861
msgid "Send" msgid "Send"
msgstr "Envoyer" msgstr "Envoyer"
#: ../src/phone.c:2870 #: ../src/phone.c:2867
msgid "Attach" msgid "Attach"
msgstr "Joindre" msgstr "Joindre"
#: ../src/phone.c:2986 #: ../src/phone.c:2983
msgid "Attach file..." msgid "Attach file..."
msgstr "Joindre un fichier..." msgstr "Joindre un fichier..."
#: ../src/phone.c:3057 #: ../src/phone.c:3055
#, c-format #, c-format
msgid "%d message%s, %d/%d characters" msgid "%d message%s, %d/%d characters"
msgstr "%d message%s, %d/%d caractères" msgstr "%d message%s, %d/%d caractères"
#: ../src/phone.c:3058 #: ../src/phone.c:3056
msgid "s" msgid "s"
msgstr "s" msgstr "s"
#: ../src/phone.c:3122 #: ../src/phone.c:3120
msgid "Sending message..." msgid "Sending message..."
msgstr "Envoi du message..." msgstr "Envoi du message..."
#: ../src/phone.c:3157 #: ../src/phone.c:3155
msgid "Outgoing" msgid "Outgoing"
msgstr "Sortant" msgstr "Sortant"
#: ../src/phone.c:3343 #: ../src/phone.c:3341
msgid "Operation in progress..." msgid "Operation in progress..."
msgstr "Opération en cours..." msgstr "Opération en cours..."
#: ../src/phone.c:3383 ../src/phone.c:3387 #: ../src/phone.c:3381 ../src/phone.c:3385
msgid "Question" msgid "Question"
msgstr "Question" msgstr "Question"
#: ../src/phone.c:3407 ../src/phone.c:3411 #: ../src/phone.c:3405 ../src/phone.c:3409
msgid "Error" msgid "Error"
msgstr "Erreur" msgstr "Erreur"
#: ../src/phone.c:3640 #: ../src/phone.c:3638
msgid "Name: " msgid "Name: "
msgstr "Nom: " msgstr "Nom: "
#: ../src/phone.c:3649 #: ../src/phone.c:3647
msgid "Number: " msgid "Number: "
msgstr "Numéro: " msgstr "Numéro: "
#: ../src/phone.c:3665 #: ../src/phone.c:3663
msgid "New contact" msgid "New contact"
msgstr "Nouveau contact" msgstr "Nouveau contact"
#: ../src/phone.c:3667 #: ../src/phone.c:3665
msgid "Edit contact: " msgid "Edit contact: "
msgstr "Modifier contact: " msgstr "Modifier contact: "
#: ../src/phone.c:3694 #: ../src/phone.c:3692
msgid "The name cannot be empty" msgid "The name cannot be empty"
msgstr "Le nom ne peut être vide" msgstr "Le nom ne peut être vide"
#: ../src/phone.c:3699 #: ../src/phone.c:3697
msgid "The number cannot be empty" msgid "The number cannot be empty"
msgstr "Le numéro ne peut être vide" msgstr "Le numéro ne peut être vide"
#: ../src/phone.c:3833 #: ../src/phone.c:3831
msgid "Message sent" msgid "Message sent"
msgstr "Message envoyé" msgstr "Message envoyé"
#: ../src/phone.c:3859 #: ../src/phone.c:3857
#, c-format #, c-format
msgid "Wrong %s" msgid "Wrong %s"
msgstr "Mauvais %s" msgstr "Mauvais %s"
#: ../src/phone.c:3868 #: ../src/phone.c:3866
#, c-format #, c-format
msgid "%s is valid" msgid "%s is valid"
msgstr "%s valide" msgstr "%s valide"
#: ../src/phone.c:3931 #: ../src/phone.c:3929
msgid "Raw data (not shown)" msgid "Raw data (not shown)"
msgstr "Données brutes (non affichées)" msgstr "Données brutes (non affichées)"
#: ../src/phone.c:3967 #: ../src/phone.c:3965
msgid "Message deleted" msgid "Message deleted"
msgstr "Message effacé" msgstr "Message effacé"

View File

@ -216,6 +216,7 @@ static int _request_call(ModemPlugin * modem, ModemRequest * request)
return -modem->helper->error(modem->helper->modem, return -modem->helper->error(modem->helper->modem,
"Cannot create operation handle", 1); "Cannot create operation handle", 1);
nua_invite(op->handle, /* other tags as needed ... */ TAG_END()); nua_invite(op->handle, /* other tags as needed ... */ TAG_END());
/* XXX free url and op? */
return 0; return 0;
} }
@ -245,6 +246,7 @@ static void _sofia_callback(nua_event_t event, int status, char const * phrase,
{ {
ModemPlugin * modem = magic; ModemPlugin * modem = magic;
Sofia * sofia = modem->priv; Sofia * sofia = modem->priv;
ModemEvent mevent;
#ifdef DEBUG #ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__); fprintf(stderr, "DEBUG: %s()\n", __func__);
@ -253,29 +255,52 @@ static void _sofia_callback(nua_event_t event, int status, char const * phrase,
{ {
case nua_i_error: case nua_i_error:
/* FIXME report error */ /* FIXME report error */
fprintf(stderr, "%03d %s\n", status, phrase); fprintf(stderr, "i_error %03d %s\n", status, phrase);
break; break;
case nua_i_notify: case nua_i_notify:
/* FIXME report event */ /* FIXME report event */
fprintf(stderr, "%03d %s\n", status, phrase); fprintf(stderr, "i_notify %03d %s\n", status, phrase);
break; break;
case nua_i_state: case nua_i_state:
/* FIXME report event */ /* FIXME report event */
fprintf(stderr, "%03d %s\n", status, phrase); fprintf(stderr, "i_state %03d %s\n", status, phrase);
break; break;
case nua_r_invite: case nua_r_invite:
if(status == 200) if(status == 200)
nua_ack(nh, TAG_END()); nua_ack(nh, TAG_END());
else else
/* FIXME report error */ /* FIXME report error */
fprintf(stderr, "%03d %s\n", status, phrase); fprintf(stderr, "r_invite %03d %s\n", status,
phrase);
break;
case nua_r_message:
/* FIXME report event */
fprintf(stderr, "r_message %03d %s\n", status, phrase);
break; break;
case nua_r_register: case nua_r_register:
/* FIXME implement */ memset(&mevent, 0, sizeof(mevent));
fprintf(stderr, "register: %03d %s\n", status, phrase); mevent.type = MODEM_EVENT_TYPE_REGISTRATION;
mevent.registration.mode
= MODEM_REGISTRATION_MODE_AUTOMATIC;
if(status == 200)
mevent.registration.status
= MODEM_REGISTRATION_STATUS_REGISTERED;
else if(status == 405)
mevent.registration.status
= MODEM_REGISTRATION_STATUS_DENIED;
else if(status >= 400 && status <= 499)
mevent.registration.status
= MODEM_REGISTRATION_STATUS_NOT_SEARCHING;
modem->helper->event(modem->helper->modem, &mevent);
/* FIXME report errors */
fprintf(stderr, "r_register %03d %s\n", status, phrase);
break; break;
case nua_r_set_params: case nua_r_set_params:
if(status == 200)
break;
/* FIXME implement */ /* FIXME implement */
fprintf(stderr, "r_set_params %03d %s\n", status,
phrase);
break; break;
case nua_r_shutdown: case nua_r_shutdown:
/* exit the background loop when ready */ /* exit the background loop when ready */

View File

@ -904,19 +904,15 @@ int phone_event(Phone * phone, PhoneEvent * event)
if(ret == 0) if(ret == 0)
ret = modem_start(phone->modem); ret = modem_start(phone->modem);
if(ret == 0) if(ret == 0)
{ phone_event_type(phone,
event->type = PHONE_EVENT_TYPE_STARTED; PHONE_EVENT_TYPE_STARTED);
phone_event(phone, event);
}
break; break;
case PHONE_EVENT_TYPE_STOPPING: case PHONE_EVENT_TYPE_STOPPING:
if(ret == 0) if(ret == 0)
ret = modem_stop(phone->modem); ret = modem_stop(phone->modem);
if(ret == 0) if(ret == 0)
{ phone_event_type(phone,
event->type = PHONE_EVENT_TYPE_STOPPED; PHONE_EVENT_TYPE_STOPPED);
phone_event(phone, event);
}
break; break;
default: default:
break; break;
@ -2780,6 +2776,7 @@ static void _on_system_ok(gpointer data)
if((widget = g_object_get_data(G_OBJECT(phone->sy_window), if((widget = g_object_get_data(G_OBJECT(phone->sy_window),
config[i].name)) == NULL) config[i].name)) == NULL)
continue; continue;
/* FIXME "hayes" is still hard-coded */
switch(config[i].type) switch(config[i].type)
{ {
case MCT_NONE: /* XXX should not happen */ case MCT_NONE: /* XXX should not happen */
@ -2816,10 +2813,10 @@ static void _on_system_ok(gpointer data)
} }
} }
_phone_config_save(phone); _phone_config_save(phone);
if(modem_stop(phone->modem) != 0) /* restart the phone */
error_print(PACKAGE); phone_event_type(phone, PHONE_EVENT_TYPE_STOPPING); /* ignore errors */
else if(modem_start(phone->modem) != 0) modem_stop(phone->modem);
error_print(PACKAGE); phone_event_type(phone, PHONE_EVENT_TYPE_STARTING);
} }
@ -3038,6 +3035,7 @@ void phone_write_count_buffer(Phone * phone)
tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(phone->wr_view)); tbuf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(phone->wr_view));
if((cnt = gtk_text_buffer_get_char_count(tbuf)) < 0) if((cnt = gtk_text_buffer_get_char_count(tbuf)) < 0)
return; return;
/* FIXME this only applies to the "hayes" plug-in */
if(cnt <= max) if(cnt <= max)
{ {
cur_cnt = cnt; cur_cnt = cnt;

View File

@ -113,7 +113,7 @@ static int _blacklist_event(PhonePlugin * plugin, PhoneEvent * event)
number = event->modem_event.event->call.number; number = event->modem_event.event->call.number;
break; break;
default: default:
break; return 0;
} }
if(number == NULL) if(number == NULL)
return 0; return 0;

View File

@ -181,7 +181,7 @@ static int _gprs_event_modem(PhonePlugin * plugin, ModemEvent * event)
? "Connected" : "Not connected", ? "Connected" : "Not connected",
event->connection.in, event->connection.in,
event->connection.out); event->connection.out);
return 0; break;
case MODEM_EVENT_TYPE_REGISTRATION: case MODEM_EVENT_TYPE_REGISTRATION:
gprs->roaming = event->registration.roaming; gprs->roaming = event->registration.roaming;
if(gprs->active != FALSE) if(gprs->active != FALSE)
@ -191,7 +191,7 @@ static int _gprs_event_modem(PhonePlugin * plugin, ModemEvent * event)
break; break;
gprs->active = TRUE; gprs->active = TRUE;
/* FIXME optionally force GPRS registration */ /* FIXME optionally force GPRS registration */
return 0; break;
default: default:
break; break;
} }