diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 66bab93af189c66e31f4cf594394adbdc748d881..69bd8b7185074234372d29a585c0d82e4abb1d0b 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -237,15 +237,13 @@ gboolean sflphone_init() history = calltab_init("history"); account_list_init (); codec_list_init(); + // Fetch the configured accounts sflphone_fill_account_list(FALSE); // Fetch the audio codecs sflphone_fill_codec_list(); - // Fetch the history list - // sflphone_fill_history (); - return TRUE; } } @@ -939,6 +937,7 @@ void sflphone_fill_history (void) g_hash_table_iter_init (&iter, entries); while (g_hash_table_iter_next (&iter, &key, &value)) { + DEBUG ("%s\n", (gchar*)value); /* do something with key and value */ create_history_entry_from_serialized_form ((gchar*)key, (gchar*)value, &history_entry); // Add it and update the GUI diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index afc66b2cacdc0dc68e709a9120608de222fcf80a..44272407a464a77c4aa01de4e66fdd4b0e435e32 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -126,13 +126,36 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details { gchar *peer_name, *peer_number, *accountID, *state_str; callable_obj_t *new_call; + history_state_t history_state; + char *ptr; + const char *delim="|"; + int token=0; // details is in serialized form, i e: calltype%to%from%callid - peer_name = g_strdup (details); - peer_number = g_strdup (details); + + if ((ptr = strtok(details, delim)) != NULL) { + do { + switch (token) + { + case 0: + history_state = get_history_state_from_id (ptr); + break; + case 1: + peer_number = ptr; + break; + case 2: + peer_name = ptr; + break; + default: + break; + } + token ++; + } while ((ptr = strtok(NULL, delim)) != NULL); + + } create_new_call (HISTORY_ENTRY, CALL_STATE_DIALING, "", "", peer_name, peer_number, &new_call); - new_call->_history_state = MISSED; + new_call->_history_state = history_state; *call = new_call; } @@ -167,3 +190,19 @@ gchar* get_peer_info (gchar* number, gchar* name) info = g_strconcat("\"", name, "\" <", number, ">", NULL); return info; } + +history_state_t get_history_state_from_id (gchar *indice){ + + history_state_t state; + + if (g_strcasecmp (indice, "0") ==0) + state = MISSED; + else if (g_strcasecmp (indice, "1") ==0) + state = INCOMING; + else if (g_strcasecmp (indice, "2") ==0) + state = OUTGOING; + else + state = MISSED; + + return state; +} diff --git a/sflphone-client-gnome/src/callable_obj.h b/sflphone-client-gnome/src/callable_obj.h index 9acbf6bf7cf279937559ec1b36e7878f6d0be05f..46264b872b494bf25135ecf0e865d149198baac8 100644 --- a/sflphone-client-gnome/src/callable_obj.h +++ b/sflphone-client-gnome/src/callable_obj.h @@ -154,4 +154,6 @@ gchar* generate_call_id (void); gchar* get_peer_info (gchar*, gchar*); +history_state_t get_history_state_from_id (gchar *indice); + #endif diff --git a/sflphone-common/src/history/historyitem.cpp b/sflphone-common/src/history/historyitem.cpp index 9b025ea7bb78b2d2443f010c4b244f19d690c884..fc5d444bfe68ab1c3ae1921076a5ae7e582a4923 100644 --- a/sflphone-common/src/history/historyitem.cpp +++ b/sflphone-common/src/history/historyitem.cpp @@ -24,8 +24,8 @@ #define ITEM_SEPARATOR "|" -HistoryItem::HistoryItem (std::string timestamp, CallType call_type, std::string to, std::string from, std::string caller_id, std::string account_id) - : _timestamp (timestamp), _call_type (call_type), _to (to), _from (from), _caller_id (caller_id), _account_id (account_id) +HistoryItem::HistoryItem (std::string timestamp, CallType call_type, std::string name, std::string number, std::string account_id) + : _timestamp (timestamp), _call_type (call_type), _name (name), _number (number), _account_id (account_id) { } @@ -34,7 +34,7 @@ HistoryItem::HistoryItem (std::string timestamp, std::string serialized_form) : _timestamp (timestamp) { size_t pos; - std::string tmp, id, to, from, callerid; + std::string tmp, id, name, number; int indice=0; while (serialized_form.find(ITEM_SEPARATOR, 0) != std::string::npos) @@ -47,14 +47,11 @@ HistoryItem::HistoryItem (std::string timestamp, std::string serialized_form) case 0: // The call type id = tmp; break; - case 1: // The to field - to = tmp; + case 1: // The number field + number = tmp; break; - case 2: // The from field - from = tmp; - break; - case 3: // The calller id information - callerid = tmp; + case 2: // The name field + name = tmp; break; default: // error std::cout <<"[ERROR] unserialized form not recognized."<<std::endl; @@ -64,9 +61,8 @@ HistoryItem::HistoryItem (std::string timestamp, std::string serialized_form) } _call_type = (CallType)atoi (id.c_str()); - _to = to; - _from = from; - _caller_id = serialized_form; + _number = number; + _name = serialized_form; } HistoryItem::~HistoryItem () @@ -87,9 +83,8 @@ bool HistoryItem::save (Conf::ConfigTree **history){ res = ( (*history)->setConfigTreeItem(section, "type", call_type.str()) && (*history)->setConfigTreeItem(section, "timestamp", timestamp) - && (*history)->setConfigTreeItem(section, "to", _to) - && (*history)->setConfigTreeItem(section, "from", _from) - && (*history)->setConfigTreeItem(section, "id", _caller_id) ); + && (*history)->setConfigTreeItem(section, "number", _number) + && (*history)->setConfigTreeItem(section, "name", _name) ); return res; } @@ -99,7 +94,7 @@ std::string HistoryItem::serialize (void) std::stringstream res; std::string separator = ITEM_SEPARATOR; - res << _call_type << separator << _to << separator << _from << separator << _caller_id; + res << _call_type << separator << _number << separator << _name; return res.str(); } diff --git a/sflphone-common/src/history/historyitem.h b/sflphone-common/src/history/historyitem.h index 007cf13b4ae331a2e70cbe02c6f77afd5d2507d2..ae60e317ab4cdfa186c45b6568860882fd6d4786 100644 --- a/sflphone-common/src/history/historyitem.h +++ b/sflphone-common/src/history/historyitem.h @@ -38,7 +38,7 @@ class HistoryItem { /* * Constructor */ - HistoryItem (std::string, CallType, std::string, std::string, std::string, std::string=""); + HistoryItem (std::string, CallType, std::string, std::string, std::string=""); /* * Constructor from a serialized form @@ -72,11 +72,10 @@ class HistoryItem { CallType _call_type; /* - * The information about the callee/caller, depending on the type of call. One field may be empty. + * The information about the callee/caller, depending on the type of call. */ - std::string _to; - std::string _from; - std::string _caller_id; + std::string _name; + std::string _number; /* * The account the call was made with diff --git a/sflphone-common/src/history/historymanager.cpp b/sflphone-common/src/history/historymanager.cpp index fd93ce5cc56f3bd284fcb0dc3eb62e4df9d9262c..2a1088110f42a259eaa0883c7377453249a183b3 100644 --- a/sflphone-common/src/history/historymanager.cpp +++ b/sflphone-common/src/history/historymanager.cpp @@ -66,7 +66,7 @@ int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list) Conf::TokenList sections; HistoryItem *item; Conf::TokenList::iterator iter; - std::string to, from, caller_id, accountID, timestamp; + std::string number, name, caller_id, accountID, timestamp; CallType type; sections = history_list->getSections(); @@ -76,11 +76,10 @@ int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list) type = (CallType) getConfigInt (*iter, "type", history_list); timestamp = getConfigString (*iter, "timestamp", history_list); - to = getConfigString (*iter, "to", history_list); - from = getConfigString (*iter, "from", history_list); - caller_id = getConfigString (*iter, "id", history_list); + name = getConfigString (*iter, "name", history_list); + number = getConfigString (*iter, "number", history_list); - item = new HistoryItem (timestamp, type, to, from, caller_id); + item = new HistoryItem (timestamp, type, name, number); add_new_history_entry (item); nb_items ++; @@ -204,7 +203,7 @@ int HistoryManager::set_serialized_history (std::map <std::string, std::string> { std::map <std::string, std::string>::iterator iter; HistoryItem *new_item; - int items_added; + int items_added = 0; // Clear the existing history _history_items.clear (); diff --git a/sflphone-common/test/history-sample b/sflphone-common/test/history-sample index 5831fcb8f330b17368100a16e722e4598beed632..39917f17b6cb9a7e96d9e7fab2fc355bd058f15f 100644 --- a/sflphone-common/test/history-sample +++ b/sflphone-common/test/history-sample @@ -1,21 +1,18 @@ [144562436] -from=514-276-5468 -id=Savoir-faire Linux +name=Savoir-faire Linux +number=514-276-5468 timestamp=144562436 -to= type=0 [747638685] -from= -id=Emmanuel Milou +name=Emmanuel Milou +number=136 timestamp=747638685 -to=136 type=2 [775354456] -from=5143848557 -id=Chez wam +name=Chez wam +number=5143848557 timestamp=775354456 -to= type=1 diff --git a/sflphone-common/test/history-sample.tpl b/sflphone-common/test/history-sample.tpl index d181709de558215b886b3d00ea2ca96a5fe99052..f0c8a2a87663448fae2c2adeb4d8699519884a16 100644 --- a/sflphone-common/test/history-sample.tpl +++ b/sflphone-common/test/history-sample.tpl @@ -1,21 +1,17 @@ [144562436] -from=514-276-5468 -id=Savoir-faire Linux +number=514-276-5468 +name=Savoir-faire Linux timestamp=144562436 -to= type=0 [747638685] -from= -id=Emmanuel Milou +name=Emmanuel Milou timestamp=747638685 -to=136 +number=136 type=2 [775354456] -from=5143848557 -id=Chez wam +number=5143848557 +name=Chez wam timestamp=775354456 -to= type=1 - diff --git a/sflphone-common/test/historyTest.cpp b/sflphone-common/test/historyTest.cpp index 279060ec3e6da719f4bef3dd6bc022e0aac0fcc8..4a77267c10959b9cd686ced4543034365412d8a5 100644 --- a/sflphone-common/test/historyTest.cpp +++ b/sflphone-common/test/historyTest.cpp @@ -114,13 +114,14 @@ void HistoryTest::test_get_history_serialized () // The serialized form is: calltype%to%from%callid // Check the first - tmp = "0||514-276-5468|Savoir-faire Linux"; + tmp = "0|514-276-5468|Savoir-faire Linux"; CPPUNIT_ASSERT (tmp == res ["144562436"]); - tmp = "2|136||Emmanuel Milou"; + tmp = "2|136|Emmanuel Milou"; CPPUNIT_ASSERT (tmp == res ["747638685"]); - tmp = "1||5143848557|Chez wam"; + tmp = "1|5143848557|Chez wam"; + std::cout << res ["775354456"] << std::endl; CPPUNIT_ASSERT (tmp == res ["775354456"]); } @@ -131,9 +132,9 @@ void HistoryTest::test_set_serialized_history () std::string tmp; Conf::ConfigTree history_list; - map_test["144562436"] = "0||514-276-5468|Savoir-faire Linux"; - map_test["747638685"] = "2|136||Emmanuel Milou"; - map_test["775354456"] = "1||5143848557|Chez wam"; + map_test["144562436"] = "0|514-276-5468|Savoir-faire Linux"; + map_test["747638685"] = "2|136|Emmanuel Milou"; + map_test["775354456"] = "1|5143848557|Chez wam"; CPPUNIT_ASSERT (history->load_history (HISTORY_SAMPLE) == HISTORY_SAMPLE_SIZE); CPPUNIT_ASSERT (history->set_serialized_history (map_test) == 3); @@ -144,13 +145,13 @@ void HistoryTest::test_set_serialized_history () CPPUNIT_ASSERT (map_test.size()==HISTORY_SAMPLE_SIZE); // Check the first - tmp = "0||514-276-5468|Savoir-faire Linux"; + tmp = "0|514-276-5468|Savoir-faire Linux"; CPPUNIT_ASSERT (tmp == map_test ["144562436"]); - tmp = "2|136||Emmanuel Milou"; + tmp = "2|136|Emmanuel Milou"; CPPUNIT_ASSERT (tmp == map_test ["747638685"]); - tmp = "1||5143848557|Chez wam"; + tmp = "1|5143848557|Chez wam"; CPPUNIT_ASSERT (tmp == map_test ["775354456"]); history->save_history_items_map (&history_list);