diff -Nur ../ant-phone-0.0.6-backup/callerid.c ./callerid.c --- ../ant-phone-0.0.6-backup/callerid.c Fri Nov 22 15:45:23 2002 +++ ./callerid.c Fri Nov 22 15:45:40 2002 @@ -161,12 +161,15 @@ if (ct == CALL_IN) { pixmap = session->symbol_in_pixmap; bitmap = session->symbol_in_bitmap; + gtk_clist_set_pixtext(GTK_CLIST(session->cid_list), session->cid_num - 1 , 1, + "IN", 50, pixmap, bitmap); } else { pixmap = session->symbol_out_pixmap; bitmap = session->symbol_out_bitmap; + gtk_clist_set_pixtext(GTK_CLIST(session->cid_list), session->cid_num - 1 , 1, + "OUT", 50, pixmap, bitmap); } - gtk_clist_set_pixmap(GTK_CLIST(session->cid_list), session->cid_num - 1 , 1, - pixmap, bitmap); + /* select last item and adjust view to end of list */ cid_jump_to_end(session); diff -Nur ../ant-phone-0.0.6-backup/session.c ./session.c --- ../ant-phone-0.0.6-backup/session.c Fri Nov 22 15:45:23 2002 +++ ./session.c Fri Nov 22 15:45:40 2002 @@ -1074,3 +1074,33 @@ session->dial_number_history, temp); session_history_normalize(session); } + +/* + * Add a line to clist + */ +void session_incoming_history_append(struct session_t *session, char *number) { + char *temp = strdup(number); + gchar *date = g_new0 (gchar, 21); + gchar *type = g_new0 (gchar, 4); + gchar *from = g_new0 (gchar, 41); + gchar *to = g_new0 (gchar, 41); + gchar *duration = g_new0 (gchar, 41); + + if (sscanf (temp, "%20[0-9a-fA-F: -]!!%3[INOUT]!!%40[0-9]!!%40[0-9]!!%40s!!%*", + date, type, from, to, duration) != 5); + + if (debug) + printf ("Incoming history:\nDate: |%s|, Type: |%s|, From: |%s|, To: |%s|, Dur: |%s|\n", + date, type, from, to, duration); + + if (strncmp(type, "IN", 2) == 0) + { + cid_add_line(session, CALL_IN, from, to); + gtk_clist_set_text(GTK_CLIST(session->cid_list), session->cid_num - 1, 0, date); + gtk_clist_set_text(GTK_CLIST(session->cid_list), session->cid_num - 1, 4, duration); + } else if (strncmp(type, "OUT", 3) == 0) { + cid_add_line(session, CALL_OUT, from, to); + gtk_clist_set_text(GTK_CLIST(session->cid_list), session->cid_num - 1, 0, date); + gtk_clist_set_text(GTK_CLIST(session->cid_list), session->cid_num - 1, 4, duration); + } +} diff -Nur ../ant-phone-0.0.6-backup/session.h ./session.h --- ../ant-phone-0.0.6-backup/session.h Fri Nov 22 15:45:23 2002 +++ ./session.h Fri Nov 22 15:45:40 2002 @@ -203,4 +203,5 @@ void session_history_add(struct session_t *session, char *number); void session_history_append(struct session_t *session, char *number); +void session_incoming_history_append(struct session_t *session, char *number); #endif /* session.h */ diff -Nur ../ant-phone-0.0.6-backup/settings.c ./settings.c --- ../ant-phone-0.0.6-backup/settings.c Fri Nov 22 15:45:23 2002 +++ ./settings.c Fri Nov 22 15:45:40 2002 @@ -282,6 +282,8 @@ return; } + if (debug) + fprintf(stdout, "Info: History Filename: %s.\n", filename); if ((f = fopen(filename, "r"))) { do { got = getline(&lineptr, &linesize, f); @@ -290,10 +292,12 @@ } if (got > 0 && strlen(lineptr) > 0) { session_history_append(session, lineptr); + if (debug) + fprintf(stdout, "Info: History Number: %s.\n", lineptr); } } while (got > 0); - free(lineptr); + //free(lineptr); if (fclose(f) == EOF) { fprintf(stderr, "Warning: Couldn't close history file.\n"); @@ -303,6 +307,40 @@ } free(filename); + + + if (asprintf(&filename, "%s/." PACKAGE "/%s", + homedir, SETTINGS_INCOMING_HISTORY_FILENAME) < 0) { + fprintf(stderr, + "Warning: Couldn't allocate memory for incoming history filename.\n"); + return; + } + + if (debug) + fprintf(stdout, "Info: Incoming History Filename: %s.\n", filename); + if ((f = fopen(filename, "r"))) { + do { + got = getline(&lineptr, &linesize, f); + if (lineptr[got - 1] == '\n') { + lineptr[got - 1] = '\0'; + } + if (got > 0 && strlen(lineptr) > 0) { + session_incoming_history_append(session, lineptr); + if (debug) + fprintf(stdout, "Info: Incoming History Number: %s.\n", lineptr); + } + } while (got > 0); + + if (fclose(f) == EOF) { + fprintf(stderr, "Warning: Couldn't close history file.\n"); + } + } else if (debug) { + fprintf(stderr, "Warning: No history file available.\n"); + } + + free(lineptr); + free(filename); + } /* @@ -322,12 +360,22 @@ char *homedir; char *filename; FILE *f; + int akt_line; + gchar *date = g_new0 (gchar, 21); + gchar *type = g_new0 (gchar, 4); + gchar *from = g_new0 (gchar, 41); + gchar *to = g_new0 (gchar, 41); + gchar *duration = g_new0 (gchar, 41); + gchar *ges_line = g_new0 (gchar, 160); if (!(homedir = settings_get_homedir())) { fprintf(stderr, "Warning: Couldn't get home dir.\n"); return; } + + /* write history file (dialed numbers) */ + if (asprintf(&filename, "%s/." PACKAGE "/%s", homedir, SETTINGS_HISTORY_FILENAME) < 0) { fprintf(stderr, @@ -347,4 +395,39 @@ } free(filename); + + + /* write incoming history file */ + + if (asprintf(&filename, "%s/." PACKAGE "/%s", + homedir, SETTINGS_INCOMING_HISTORY_FILENAME) < 0) { + fprintf(stderr, + "Warning: Couldn't allocate memory for incoming history filename.\n"); + return; + } + + if ((f = fopen(filename, "w"))) { + for (akt_line = 0; akt_line < session->cid_num; akt_line++) + { + gtk_clist_get_text (GTK_CLIST(session->cid_list), akt_line, 0, &date); + gtk_clist_get_pixtext (GTK_CLIST(session->cid_list), akt_line, 1, &type, NULL, NULL, NULL); + gtk_clist_get_text (GTK_CLIST(session->cid_list), akt_line, 2, &from); + gtk_clist_get_text (GTK_CLIST(session->cid_list), akt_line, 3, &to); + gtk_clist_get_text (GTK_CLIST(session->cid_list), akt_line, 4, &duration); + + fprintf (f, "%s!!%s!!%s!!%s!!%s\n", date, type, from, to, duration); + if (debug) + printf ("%s!!%s!!%s!!%s!!%s\n", date, type, from, to, duration); + + } + + if (fclose(f) == EOF) { + fprintf(stderr, "Warning: Couldn't close history file.\n"); + } + } else if (debug) { + fprintf(stderr, "Warning: Can't write to history file.\n"); + } + + free(filename); + } diff -Nur ../ant-phone-0.0.6-backup/settings.h ./settings.h --- ../ant-phone-0.0.6-backup/settings.h Fri Nov 22 15:45:23 2002 +++ ./settings.h Fri Nov 22 15:45:40 2002 @@ -12,6 +12,8 @@ #define SETTINGS_OPTIONS_FILENAME "options" #define SETTINGS_HISTORY_FILENAME "history" +#define SETTINGS_INCOMING_HISTORY_FILENAME "incoming_history" + void settings_option_set(struct session_t *session, char *option, char *value); void settings_options_read(struct session_t *session);