From 7c79b84ce4dd8bb9c9ab2fa33e2f706f4be613aa Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sat, 7 Aug 2010 00:31:48 +0000 Subject: [PATCH] Adding a phone activity log window --- Makefile | 2 + po/fr.po | 174 +++++++++++++++++++++++++---------------------- src/.cvsignore | 1 + src/Makefile | 23 +++++-- src/callbacks.c | 31 +++++++++ src/callbacks.h | 5 ++ src/logs.c | 22 ++++++ src/phone.c | 135 +++++++++++++++++++++++++++++++++--- src/phone.h | 2 + src/project.conf | 14 +++- 10 files changed, 309 insertions(+), 100 deletions(-) create mode 100644 src/logs.c diff --git a/Makefile b/Makefile index 34150a4..33cfa96 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,7 @@ dist: $(PACKAGE)-$(VERSION)/src/phone.c \ $(PACKAGE)-$(VERSION)/src/contacts.c \ $(PACKAGE)-$(VERSION)/src/dialer.c \ + $(PACKAGE)-$(VERSION)/src/logs.c \ $(PACKAGE)-$(VERSION)/src/messages.c \ $(PACKAGE)-$(VERSION)/src/settings.c \ $(PACKAGE)-$(VERSION)/src/Makefile \ @@ -58,6 +59,7 @@ dist: $(PACKAGE)-$(VERSION)/src/phone.h \ $(PACKAGE)-$(VERSION)/src/common.c \ $(PACKAGE)-$(VERSION)/src/project.conf \ + $(PACKAGE)-$(VERSION)/src/plugins/blacklist.c \ $(PACKAGE)-$(VERSION)/src/plugins/engineering.c \ $(PACKAGE)-$(VERSION)/src/plugins/openmoko.c \ $(PACKAGE)-$(VERSION)/src/plugins/panel.c \ diff --git a/po/fr.po b/po/fr.po index 81d013f..ac01eaa 100644 --- a/po/fr.po +++ b/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-08-01 20:27+0200\n" +"POT-Creation-Date: 2010-08-07 02:24+0200\n" "PO-Revision-Date: 2010-04-24 02:07+0200\n" "Last-Translator: Pierre Pronchery \n" "Language-Team: French\n" @@ -112,8 +112,8 @@ 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:172 ../src/gsm.c:1235 ../src/gsm.c:1445 ../src/gsm.c:1505 -#: ../src/gsm.c:2047 +#: ../src/gsm.c:172 ../src/gsm.c:1234 ../src/gsm.c:1444 ../src/gsm.c:1504 +#: ../src/gsm.c:2046 msgid "Unknown error" msgstr "Erreur inconnue" @@ -189,266 +189,274 @@ msgstr "" msgid "Conflict with command details" msgstr "" -#: ../src/gsm.c:391 +#: ../src/gsm.c:390 msgid ": Unknown baudrate, assuming 115200" msgstr ": Débit inconnu, tente 115200" -#: ../src/gsm.c:1075 +#: ../src/gsm.c:1074 msgid "Event not handled" msgstr "Événement non géré" #: ../src/main.c:45 msgid "" -"Usage: phone -b baudrate -d device -r retry -F\n" +"Usage: phone [-b baudrate][-d device][-r retry][-F]\n" " -b\tSpeed to set before communicating with the device\n" " -d\tPath to the modem device\n" " -r\tDelay between two tries to open and settle with the modem (ms)\n" " -F\tEnable hardware flow control (RTS/CTS)\n" msgstr "" -#: ../src/phone.c:334 +#: ../src/phone.c:354 msgid "Initializing..." msgstr "Initialisation..." -#: ../src/phone.c:512 +#: ../src/phone.c:533 msgid "Checking SIM PIN code..." msgstr "Vérification du code SIM PIN..." -#: ../src/phone.c:564 +#: ../src/phone.c:585 msgid "Delete this contact?" msgstr "Supprimer ce contact?" -#: ../src/phone.c:903 ../src/phone.c:975 +#: ../src/phone.c:934 ../src/phone.c:1005 msgid "Delete this message?" msgstr "Supprimer ce message?" -#: ../src/phone.c:909 ../src/phone.c:980 +#: ../src/phone.c:940 ../src/phone.c:1010 msgid "Deleting message..." msgstr "Suppression du message..." -#: ../src/phone.c:1054 +#: ../src/phone.c:1084 msgid "Answer" msgstr "Répondre" -#: ../src/phone.c:1061 +#: ../src/phone.c:1091 msgid "Hangup" msgstr "Raccrocher" -#: ../src/phone.c:1068 +#: ../src/phone.c:1098 msgid "Reject" msgstr "Rejeter" -#: ../src/phone.c:1091 +#: ../src/phone.c:1121 msgid "Loudspeaker" msgstr "Haut-parleur" -#: ../src/phone.c:1101 +#: ../src/phone.c:1131 msgid "Mute microphone" msgstr "Couper le microphone" -#: ../src/phone.c:1117 +#: ../src/phone.c:1147 msgid "Unknown contact" msgstr "Contact inconnu" -#: ../src/phone.c:1124 +#: ../src/phone.c:1154 msgid "Unknown number" msgstr "Numéro inconnu" -#: ../src/phone.c:1132 +#: ../src/phone.c:1162 msgid "In conversation" msgstr "En conversation" -#: ../src/phone.c:1140 +#: ../src/phone.c:1170 msgid "Incoming call" msgstr "Appel entrant" -#: ../src/phone.c:1147 +#: ../src/phone.c:1177 msgid "Outgoing call" msgstr "Appel sortant" -#: ../src/phone.c:1155 +#: ../src/phone.c:1185 msgid "Call finished" msgstr "Appel terminé" -#: ../src/phone.c:1209 +#: ../src/phone.c:1239 msgid "Enter" msgstr "Entrer" -#: ../src/phone.c:1211 +#: ../src/phone.c:1241 msgid "Skip" msgstr "Ignorer" -#: ../src/phone.c:1222 +#: ../src/phone.c:1252 msgid "Enter SIM PIN code" msgstr "Entrer le code SIM PIN" -#: ../src/phone.c:1251 +#: ../src/phone.c:1281 msgid "Contacts" msgstr "Contacts" -#: ../src/phone.c:1258 ../src/phone.c:1573 ../src/phone.c:1616 -#: ../src/phone.c:1740 +#: ../src/phone.c:1288 ../src/phone.c:1603 ../src/phone.c:1645 +#: ../src/phone.c:1722 ../src/phone.c:1846 msgid "Call" msgstr "Appeler" -#: ../src/phone.c:1264 +#: ../src/phone.c:1294 msgid "Write" msgstr "Écrire" -#: ../src/phone.c:1296 ../src/phone.c:1844 +#: ../src/phone.c:1326 ../src/phone.c:1950 msgid "Name" msgstr "Nom" -#: ../src/phone.c:1545 +#: ../src/phone.c:1575 msgid "Dialer" msgstr "Composer" -#: ../src/phone.c:1575 +#: ../src/phone.c:1605 msgid "Hang up" msgstr "Raccrocher" -#: ../src/phone.c:1609 -msgid "Messages" -msgstr "Messages" +#: ../src/phone.c:1638 +msgid "Phone log" +msgstr "" -#: ../src/phone.c:1622 -msgid "New message" -msgstr "Nouveau message" +#: ../src/phone.c:1651 +msgid "Message" +msgstr "Message" -#: ../src/phone.c:1628 ../src/phone.c:1746 -msgid "Reply" -msgstr "Répondre" +#: ../src/phone.c:1672 ../src/phone.c:1775 +msgid "To/From" +msgstr "Vers/De" -#: ../src/phone.c:1646 -msgid "Inbox" -msgstr "Reçus" - -#: ../src/phone.c:1650 -msgid "Sent" -msgstr "Envoyés" - -#: ../src/phone.c:1669 -msgid "From" -msgstr "De" - -#: ../src/phone.c:1675 +#: ../src/phone.c:1678 ../src/phone.c:1781 msgid "Date" msgstr "Date" -#: ../src/phone.c:1734 +#: ../src/phone.c:1715 +msgid "Messages" +msgstr "Messages" + +#: ../src/phone.c:1728 +msgid "New message" +msgstr "Nouveau message" + +#: ../src/phone.c:1734 ../src/phone.c:1852 +msgid "Reply" +msgstr "Répondre" + +#: ../src/phone.c:1752 +msgid "Inbox" +msgstr "Reçus" + +#: ../src/phone.c:1756 +msgid "Sent" +msgstr "Envoyés" + +#: ../src/phone.c:1840 msgid "Read message" msgstr "Lire le message" -#: ../src/phone.c:1821 +#: ../src/phone.c:1927 msgid "Phone settings" msgstr "Paramètres du téléphone" -#: ../src/phone.c:1884 +#: ../src/phone.c:1990 msgid "Write message" msgstr "Écrire un message" -#: ../src/phone.c:1890 +#: ../src/phone.c:1996 msgid "Send" msgstr "Envoyer" -#: ../src/phone.c:1896 +#: ../src/phone.c:2002 msgid "Attach" msgstr "Attacher" -#: ../src/phone.c:2010 +#: ../src/phone.c:2116 #, c-format msgid "%d message%s, %d/%d characters" msgstr "%d message%s, %d/%d caractères" -#: ../src/phone.c:2011 +#: ../src/phone.c:2117 msgid "s" msgstr "s" -#: ../src/phone.c:2040 +#: ../src/phone.c:2146 msgid "Sending message..." msgstr "Envoi du message..." -#: ../src/phone.c:2155 +#: ../src/phone.c:2273 msgid "Operation in progress..." msgstr "Opération en cours..." -#: ../src/phone.c:2183 ../src/phone.c:2188 +#: ../src/phone.c:2301 ../src/phone.c:2306 msgid "Question" msgstr "Question" -#: ../src/phone.c:2208 ../src/phone.c:2213 +#: ../src/phone.c:2326 ../src/phone.c:2331 msgid "Error" msgstr "Erreur" -#: ../src/phone.c:2260 ../src/phone.c:2265 +#: ../src/phone.c:2378 ../src/phone.c:2383 msgid "Information" msgstr "Information" -#: ../src/phone.c:2344 +#: ../src/phone.c:2462 msgid "Unknown" msgstr "Inconnu" -#: ../src/phone.c:2347 +#: ../src/phone.c:2465 msgid "Registering..." msgstr "Enregistrement..." -#: ../src/phone.c:2350 +#: ../src/phone.c:2468 msgid "Denied" msgstr "Refusé" -#: ../src/phone.c:2355 +#: ../src/phone.c:2473 msgid "SIM check..." msgstr "Vérification SIM..." -#: ../src/phone.c:2361 +#: ../src/phone.c:2479 msgid "SIM ready..." msgstr "SIM prête..." -#: ../src/phone.c:2407 +#: ../src/phone.c:2525 msgid "Name: " msgstr "Nom: " -#: ../src/phone.c:2414 +#: ../src/phone.c:2532 msgid "Number: " msgstr "Numéro: " -#: ../src/phone.c:2428 +#: ../src/phone.c:2546 msgid "New contact" msgstr "Nouveau contact" -#: ../src/phone.c:2430 +#: ../src/phone.c:2548 msgid "Edit contact: " msgstr "Modifier contact: " -#: ../src/phone.c:2557 +#: ../src/phone.c:2677 msgid "New message received" msgstr "Nouveau message reçu" -#: ../src/phone.c:2573 +#: ../src/phone.c:2693 msgid "Message sent" msgstr "Message envoyé" -#: ../src/phone.c:2597 +#: ../src/phone.c:2722 ../src/phone.c:2726 msgid "SIM PIN is valid" msgstr "Code SIM PIN valide" -#: ../src/phone.c:2633 +#: ../src/phone.c:2763 msgid "Could not request new message indications" msgstr "Impossible d'obtenir des notifications de nouveaux messages" -#: ../src/phone.c:2644 +#: ../src/phone.c:2774 msgid "Could not send message" msgstr "Le message n'a pas pu être envoyé" -#: ../src/phone.c:2652 +#: ../src/phone.c:2782 msgid "Wrong SIM PIN code" msgstr "Code SIM PIN erroné" -#: ../src/phone.c:2687 +#: ../src/phone.c:2817 msgid "Raw data (not shown)" msgstr "Données brutes (non affichées)" -#: ../src/phone.c:2702 +#: ../src/phone.c:2832 msgid "Message deleted" msgstr "Message supprimé" diff --git a/src/.cvsignore b/src/.cvsignore index 2ed6f0c..86e1df0 100644 --- a/src/.cvsignore +++ b/src/.cvsignore @@ -2,5 +2,6 @@ phone phone-contacts phone-dialer +phone-logs phone-messages phone-settings diff --git a/src/Makefile b/src/Makefile index 23b8656..617e1ea 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,13 +1,13 @@ SUBDIRS = plugins -TARGETS = phone phone-contacts phone-dialer phone-messages phone-settings +TARGETS = phone phone-contacts phone-dialer phone-logs phone-messages phone-settings PREFIX = /usr/local DESTDIR = BINDIR = $(PREFIX)/bin CC = cc CPPFLAGSF= -I ../include CPPFLAGS= -I $(PREFIX)/include -CFLAGSF = -W -CFLAGS = -Wall -g -O2 -pedantic `pkg-config --cflags gtk+-2.0` +CFLAGSF = -W `pkg-config --cflags gtk+-2.0` +CFLAGS = -Wall -g -O2 -pedantic LDFLAGSF= `pkg-config --libs gtk+-2.0` -lSystem LDFLAGS = -L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib RM = rm -f @@ -42,6 +42,13 @@ phone-dialer_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) phone-dialer: $(phone-dialer_OBJS) $(CC) -o phone-dialer $(phone-dialer_OBJS) $(phone-dialer_LDFLAGS) +phone-logs_OBJS = logs.o +phone-logs_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) +phone-logs_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) + +phone-logs: $(phone-logs_OBJS) + $(CC) -o phone-logs $(phone-logs_OBJS) $(phone-logs_LDFLAGS) + phone-messages_OBJS = messages.o phone-messages_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS) phone-messages_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) @@ -80,6 +87,9 @@ contacts.o: contacts.c common.c dialer.o: dialer.c common.c $(CC) $(phone-dialer_CFLAGS) -c dialer.c +logs.o: logs.c common.c + $(CC) $(phone-logs_CFLAGS) -c logs.c + messages.o: messages.c common.c $(CC) $(phone-messages_CFLAGS) -c messages.c @@ -88,11 +98,11 @@ settings.o: settings.c common.c clean: @for i in $(SUBDIRS); do (cd $$i && $(MAKE) clean) || exit; done - $(RM) -- $(phone_OBJS) $(phone-contacts_OBJS) $(phone-dialer_OBJS) $(phone-messages_OBJS) $(phone-settings_OBJS) + $(RM) -- $(phone_OBJS) $(phone-contacts_OBJS) $(phone-dialer_OBJS) $(phone-logs_OBJS) $(phone-messages_OBJS) $(phone-settings_OBJS) distclean: @for i in $(SUBDIRS); do (cd $$i && $(MAKE) distclean) || exit; done - $(RM) -- $(phone_OBJS) $(phone-contacts_OBJS) $(phone-dialer_OBJS) $(phone-messages_OBJS) $(phone-settings_OBJS) + $(RM) -- $(phone_OBJS) $(phone-contacts_OBJS) $(phone-dialer_OBJS) $(phone-logs_OBJS) $(phone-messages_OBJS) $(phone-settings_OBJS) $(RM) -- $(TARGETS) install: all @@ -104,6 +114,8 @@ install: all $(MKDIR) $(DESTDIR)$(BINDIR) $(INSTALL) -m 0755 -- phone-dialer $(DESTDIR)$(BINDIR)/phone-dialer $(MKDIR) $(DESTDIR)$(BINDIR) + $(INSTALL) -m 0755 -- phone-logs $(DESTDIR)$(BINDIR)/phone-logs + $(MKDIR) $(DESTDIR)$(BINDIR) $(INSTALL) -m 0755 -- phone-messages $(DESTDIR)$(BINDIR)/phone-messages $(MKDIR) $(DESTDIR)$(BINDIR) $(INSTALL) -m 0755 -- phone-settings $(DESTDIR)$(BINDIR)/phone-settings @@ -113,6 +125,7 @@ uninstall: $(RM) -- $(DESTDIR)$(BINDIR)/phone $(RM) -- $(DESTDIR)$(BINDIR)/phone-contacts $(RM) -- $(DESTDIR)$(BINDIR)/phone-dialer + $(RM) -- $(DESTDIR)$(BINDIR)/phone-logs $(RM) -- $(DESTDIR)$(BINDIR)/phone-messages $(RM) -- $(DESTDIR)$(BINDIR)/phone-settings diff --git a/src/callbacks.c b/src/callbacks.c index 5cdaa2c..c3bb15f 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -69,6 +69,9 @@ static GdkFilterReturn _filter_message_show(Phone * phone, case PHONE_MESSAGE_SHOW_DIALER: phone_show_dialer(phone, show); break; + case PHONE_MESSAGE_SHOW_LOGS: + phone_show_logs(phone, show); + break; case PHONE_MESSAGE_SHOW_MESSAGES: phone_show_messages(phone, show); break; @@ -266,6 +269,34 @@ void on_phone_dialer_hangup(gpointer data) } +/* logs */ +/* on_phone_logs_activated */ +void on_phone_logs_activated(gpointer data) +{ + Phone * phone = data; + + /* FIXME implement */ +} + + +/* on_phone_logs_call */ +void on_phone_logs_call(gpointer data) +{ + Phone * phone = data; + + /* FIXME implement */ +} + + +/* on_phone_logs_write */ +void on_phone_logs_write(gpointer data) +{ + Phone * phone = data; + + /* FIXME implement */ +} + + /* messages */ /* on_phone_messages_activated */ void on_phone_messages_activated(gpointer data) diff --git a/src/callbacks.h b/src/callbacks.h index 72f2c4a..28bc790 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -53,6 +53,11 @@ void on_phone_dialer_call(gpointer data); void on_phone_dialer_clicked(GtkWidget * widget, gpointer data); void on_phone_dialer_hangup(gpointer data); +/* logs */ +void on_phone_logs_activated(gpointer data); +void on_phone_logs_call(gpointer data); +void on_phone_logs_write(gpointer data); + /* messages */ void on_phone_messages_activated(gpointer data); void on_phone_messages_call(gpointer data); diff --git a/src/logs.c b/src/logs.c new file mode 100644 index 0000000..bb83e53 --- /dev/null +++ b/src/logs.c @@ -0,0 +1,22 @@ +/* $Id$ */ +/* Copyright (c) 2010 Pierre Pronchery */ +/* This file is part of DeforaOS Desktop Phone */ +/* This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + + + +#define PROGNAME "logs" +#define PHONE_MESSAGE PHONE_MESSAGE_SHOW +#define PHONE_MESSAGE_WHAT PHONE_MESSAGE_SHOW_LOGS + +#include "common.c" diff --git a/src/phone.c b/src/phone.c index 12d661b..871c6ef 100644 --- a/src/phone.c +++ b/src/phone.c @@ -51,6 +51,16 @@ typedef enum _PhoneContactColumn #define PHONE_CONTACT_COLUMN_LAST PHONE_CONTACT_COLUMN_NUMBER #define PHONE_CONTACT_COLUMN_COUNT (PHONE_CONTACT_COLUMN_LAST + 1) +typedef enum _PhoneLogsColumn +{ + PHONE_LOGS_COLUMN_TYPE = 0, + PHONE_LOGS_COLUMN_NUMBER_DISPLAY, + PHONE_LOGS_COLUMN_DATE, + PHONE_LOGS_COLUMN_DATE_DISPLAY +} PhoneLogsColumn; +#define PHONE_LOGS_COLUMN_LAST PHONE_LOGS_COLUMN_DATE_DISPLAY +#define PHONE_LOGS_COLUMN_COUNT (PHONE_LOGS_COLUMN_LAST + 1) + typedef enum _PhoneMessageColumn { PHONE_MESSAGE_COLUMN_ID = 0, @@ -162,6 +172,11 @@ struct _Phone GtkWidget * di_window; GtkWidget * di_entry; + /* logs */ + GtkWidget * lo_window; + GtkListStore * lo_store; + GtkWidget * lo_view; + /* messages */ GtkWidget * me_window; GtkListStore * me_store; @@ -195,6 +210,8 @@ struct _Phone /* prototypes */ +static int _phone_call_number(Phone * phone, char const * number); + static char const * _phone_config_get(Phone * phone, char const * section, char const * variable); @@ -312,6 +329,9 @@ Phone * phone_new(char const * device, unsigned int baudrate, int retry, phone->de_window = NULL; #endif phone->di_window = NULL; + phone->lo_window = NULL; + phone->lo_store = gtk_list_store_new(PHONE_LOGS_COLUMN_COUNT, + G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING); phone->me_window = NULL; phone->me_store = gtk_list_store_new(PHONE_MESSAGE_COLUMN_COUNT, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, @@ -685,8 +705,7 @@ void phone_dialer_call(Phone * phone, char const * number) number = gtk_entry_get_text(GTK_ENTRY(phone->di_entry)); if(number[0] == '\0') number = NULL; /* call the last number dialled */ - gsm_call(phone->gsm, GSM_CALL_TYPE_VOICE, number); - phone_show_call(phone, TRUE, PHONE_CALL_OUTGOING, " ", number); + _phone_call_number(phone, number); } @@ -725,6 +744,14 @@ int phone_event(Phone * phone, PhoneEvent event, ...) va_start(ap, event); switch(event) { + case PHONE_EVENT_BATTERY_LEVEL: + level = va_arg(ap, gdouble); + ret |= plugin->event(plugin, event, level); + break; + case PHONE_EVENT_CALLING: + number = va_arg(ap, char const *); + ret |= plugin->event(plugin, event, number); + break; case PHONE_EVENT_SET_OPERATOR: operator = va_arg(ap, char const *); ret |= plugin->event(plugin, event, operator); @@ -747,6 +774,7 @@ int phone_event(Phone * phone, PhoneEvent event, ...) case PHONE_EVENT_CALL_INCOMING: case PHONE_EVENT_CALL_OUTGOING: case PHONE_EVENT_CALL_TERMINATED: + case PHONE_EVENT_FUNCTIONAL: case PHONE_EVENT_KEY_TONE: case PHONE_EVENT_NOTIFICATION_OFF: case PHONE_EVENT_NOTIFICATION_ON: @@ -884,8 +912,7 @@ void phone_messages_call_selected(Phone * phone) PHONE_MESSAGE_COLUMN_NUMBER, &number, -1); if(number == NULL) return; - gsm_call(phone->gsm, GSM_CALL_TYPE_VOICE, number); - phone_show_call(phone, TRUE, PHONE_CALL_OUTGOING, " ", number); + _phone_call_number(phone, number); g_free(number); } @@ -968,8 +995,7 @@ void phone_read_call(Phone * phone) return; if((number = gtk_label_get_text(GTK_LABEL(phone->re_number))) == NULL) return; - gsm_call(phone->gsm, GSM_CALL_TYPE_VOICE, number); - phone_show_call(phone, TRUE, PHONE_CALL_OUTGOING, " ", number); + _phone_call_number(phone, number); } @@ -1590,6 +1616,82 @@ void phone_show_dialer(Phone * phone, gboolean show) } +/* phone_show_logs */ +void phone_show_logs(Phone * phone, gboolean show) +{ + GtkWidget * vbox; + GtkWidget * widget; + GtkToolItem * toolitem; + GtkCellRenderer * renderer; + GtkTreeViewColumn * column; + + if(phone->lo_window == NULL) + { + phone->lo_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_default_size(GTK_WINDOW(phone->lo_window), 200, + 300); +#if GTK_CHECK_VERSION(2, 6, 0) + gtk_window_set_icon_name(GTK_WINDOW(phone->me_window), + "phone-logs"); /* FIXME find sth appropriate */ +#endif + gtk_window_set_title(GTK_WINDOW(phone->lo_window), + _("Phone log")); + g_signal_connect_swapped(G_OBJECT(phone->lo_window), + "delete-event", G_CALLBACK(on_phone_closex), + phone->lo_window); + vbox = gtk_vbox_new(FALSE, 0); + /* toolbar */ + widget = gtk_toolbar_new(); + toolitem = gtk_tool_button_new(NULL, _("Call")); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(toolitem), + "call-start"); + g_signal_connect_swapped(G_OBJECT(toolitem), "clicked", + G_CALLBACK(on_phone_logs_call), phone); + gtk_toolbar_insert(GTK_TOOLBAR(widget), toolitem, -1); + toolitem = gtk_tool_button_new(NULL, _("Message")); + gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(toolitem), + "stock_mail-compose"); + g_signal_connect_swapped(G_OBJECT(toolitem), "clicked", + G_CALLBACK(on_phone_logs_write), phone); + gtk_toolbar_insert(GTK_TOOLBAR(widget), toolitem, -1); + gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0); + /* view */ + widget = gtk_scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(widget), + GTK_SHADOW_ETCHED_IN); + phone->lo_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL( + phone->lo_store)); + g_signal_connect_swapped(G_OBJECT(phone->lo_view), + "row-activated", G_CALLBACK( + on_phone_logs_activated), phone); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(phone->lo_view), + FALSE); /* XXX consider reverting this */ + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes(_("To/From"), + renderer, "text", + PHONE_LOGS_COLUMN_NUMBER_DISPLAY, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(phone->lo_view), + column); + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes(_("Date"), + renderer, "text", + PHONE_LOGS_COLUMN_DATE_DISPLAY, NULL); + gtk_tree_view_append_column(GTK_TREE_VIEW(phone->lo_view), + column); + gtk_container_add(GTK_CONTAINER(widget), phone->lo_view); + gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0); + gtk_container_add(GTK_CONTAINER(phone->lo_window), vbox); + gtk_widget_show_all(vbox); + } + if(show) + gtk_window_present(GTK_WINDOW(phone->lo_window)); + else + gtk_widget_hide(phone->lo_window); +} + + /* phone_show_messages */ void phone_show_messages(Phone * phone, gboolean show) { @@ -1670,7 +1772,7 @@ void phone_show_messages(Phone * phone, gboolean show) gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(phone->me_view), FALSE); /* XXX consider reverting this */ renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes(_("From"), + column = gtk_tree_view_column_new_with_attributes(_("To/From"), renderer, "text", PHONE_MESSAGE_COLUMN_NUMBER_DISPLAY, NULL); gtk_tree_view_append_column(GTK_TREE_VIEW(phone->me_view), @@ -2050,6 +2152,18 @@ void phone_write_send(Phone * phone) /* private */ +/* phone_call_number */ +static int _phone_call_number(Phone * phone, char const * number) +{ + if(number != NULL && phone_event(phone, PHONE_EVENT_CALLING, number) + != 0) + return -1; + gsm_call(phone->gsm, GSM_CALL_TYPE_VOICE, number); + phone_show_call(phone, TRUE, PHONE_CALL_OUTGOING, "", number); + return 0; +} + + /* phone_config_get */ static char const * _phone_config_get(Phone * phone, char const * section, char const * variable) @@ -2509,7 +2623,8 @@ static int _phone_gsm_event(GSMEvent * event, gpointer data) case GSM_EVENT_TYPE_ERROR: return _gsm_event_error(phone, event); case GSM_EVENT_TYPE_BATTERY_CHARGE: - /* FIXME implement */ + phone_event(phone, PHONE_EVENT_BATTERY_LEVEL, + event->battery_charge.level + 0.0); return 0; case GSM_EVENT_TYPE_CALL_PRESENTATION: /* FIXME convert number, contact will be automatic */ @@ -2550,6 +2665,7 @@ static int _phone_gsm_event(GSMEvent * event, gpointer data) _phone_track(phone, PHONE_TRACK_CONTACT_LIST, TRUE); _phone_track(phone, PHONE_TRACK_MESSAGE_LIST, TRUE); #endif + phone_event(phone, PHONE_EVENT_FUNCTIONAL); return 0; case GSM_EVENT_TYPE_INCOMING_CALL: phone_show_call(phone, TRUE, PHONE_CALL_INCOMING, "", @@ -2731,7 +2847,8 @@ static int _gsm_event_phone_activity(Phone * phone, GSMPhoneActivity activity) case GSM_PHONE_ACTIVITY_UNKNOWN: break; /* what should we do? */ case GSM_PHONE_ACTIVITY_RINGING: - phone_show_call(phone, TRUE, PHONE_CALL_OUTGOING, NULL, + /* FIXME is this really incoming? */ + phone_show_call(phone, TRUE, PHONE_CALL_INCOMING, NULL, NULL); break; } diff --git a/src/phone.h b/src/phone.h index 12bdd28..d4e80c3 100644 --- a/src/phone.h +++ b/src/phone.h @@ -32,6 +32,7 @@ typedef enum _PhoneMessageShow { PHONE_MESSAGE_SHOW_CONTACTS = 0, PHONE_MESSAGE_SHOW_DIALER, + PHONE_MESSAGE_SHOW_LOGS, PHONE_MESSAGE_SHOW_MESSAGES, PHONE_MESSAGE_SHOW_SETTINGS } PhoneMessageShow; @@ -85,6 +86,7 @@ void phone_show_call(Phone * phone, gboolean show, ...); /* PhoneCall */ void phone_show_code(Phone * phone, gboolean show, ...); /* PhoneCode */ void phone_show_contacts(Phone * phone, gboolean show); void phone_show_dialer(Phone * phone, gboolean show); +void phone_show_logs(Phone * phone, gboolean show); void phone_show_messages(Phone * phone, gboolean show); void phone_show_read(Phone * phone, gboolean show, ...); void phone_show_settings(Phone * phone, gboolean show); diff --git a/src/project.conf b/src/project.conf index d5c8e89..068e7b0 100644 --- a/src/project.conf +++ b/src/project.conf @@ -1,8 +1,8 @@ -targets=phone,phone-contacts,phone-dialer,phone-messages,phone-settings +targets=phone,phone-contacts,phone-dialer,phone-logs,phone-messages,phone-settings cppflags_force=-I ../include cppflags=-I $(PREFIX)/include -cflags_force=-W -cflags=-Wall -g -O2 -pedantic `pkg-config --cflags gtk+-2.0` +cflags_force=-W `pkg-config --cflags gtk+-2.0` +cflags=-Wall -g -O2 -pedantic ldflags_force=`pkg-config --libs gtk+-2.0` -lSystem ldflags=-L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib subdirs=plugins @@ -24,6 +24,14 @@ install=$(BINDIR) [dialer.c] depends=common.c +[phone-logs] +type=binary +sources=logs.c +install=$(BINDIR) + +[logs.c] +depends=common.c + [phone-messages] type=binary sources=messages.c