From ebbcc7256a63314e849e1231c5f40b40353e4446 Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandresavard@msavard.(none)> Date: Thu, 23 Jun 2011 13:42:06 -0400 Subject: [PATCH] #6251: Fix insertion in history map in before saving history file in daemon --- sflphone-client-gnome/src/actions.c | 6 ----- sflphone-common/src/history/historyitem.cpp | 22 ++++++++++--------- .../src/history/historymanager.cpp | 11 +++++++++- sflphone-common/test/sflphoned-sample.yml | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index d38f7a6c0c..3f0d33ceb9 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -1464,12 +1464,6 @@ void sflphone_save_history (void) // Decrement the reference count g_hash_table_unref (result); - while(*ordered_result) { - g_free(*ordered_result); - ordered_result++; - } - g_free(ordered_result); - DEBUG ("==================================================== SFLphone: Saving history (end)"); } diff --git a/sflphone-common/src/history/historyitem.cpp b/sflphone-common/src/history/historyitem.cpp index 333959a98b..0c09f12f2a 100644 --- a/sflphone-common/src/history/historyitem.cpp +++ b/sflphone-common/src/history/historyitem.cpp @@ -114,15 +114,17 @@ HistoryItem::~HistoryItem () bool HistoryItem::save (Conf::ConfigTree **history) { - - std::string section, timestamp; + std::stringstream section; std::stringstream call_type; + std::string sectionstr; bool res; // The section is : "[" + timestamp = "]" - section = get_timestamp (); + section << rand(); call_type << _call_type; + sectionstr = section.str(); + _error("Unserialized type: %s", call_type.str().c_str()); _error("Unserialized time start: %s", _timestamp_start.c_str()); _error("Unserialized time stop: %s", _timestamp_stop.c_str()); @@ -131,13 +133,13 @@ bool HistoryItem::save (Conf::ConfigTree **history) _error("Unserialized name: %s", _name.c_str()); _error("Unserialized record file: %s", _recording_file.c_str()); - res = ( (*history)->setConfigTreeItem (section, "type", call_type.str()) - && (*history)->setConfigTreeItem (section, "timestamp_start", _timestamp_start) - && (*history)->setConfigTreeItem (section, "timestamp_stop", _timestamp_stop) - && (*history)->setConfigTreeItem (section, "number", _number) - && (*history)->setConfigTreeItem (section, "accountid", _account_id) - && (*history)->setConfigTreeItem (section, "name", _name) - && (*history)->setConfigTreeItem (section, "recordfile", _recording_file)); + res = ( (*history)->setConfigTreeItem (sectionstr, "type", call_type.str()) + && (*history)->setConfigTreeItem (sectionstr, "timestamp_start", _timestamp_start) + && (*history)->setConfigTreeItem (sectionstr, "timestamp_stop", _timestamp_stop) + && (*history)->setConfigTreeItem (sectionstr, "number", _number) + && (*history)->setConfigTreeItem (sectionstr, "accountid", _account_id) + && (*history)->setConfigTreeItem (sectionstr, "name", _name) + && (*history)->setConfigTreeItem (sectionstr, "recordfile", _recording_file)); return res; } diff --git a/sflphone-common/src/history/historymanager.cpp b/sflphone-common/src/history/historymanager.cpp index 4e8dd0a8af..f005ec4a21 100644 --- a/sflphone-common/src/history/historymanager.cpp +++ b/sflphone-common/src/history/historymanager.cpp @@ -45,7 +45,6 @@ HistoryManager::HistoryManager () HistoryManager::~HistoryManager () { HistoryItemMap::iterator iter = _history_items.begin(); - HistoryItem * item; while (iter != _history_items.end()) { @@ -63,6 +62,8 @@ int HistoryManager::load_history (int limit, std::string path) { Conf::ConfigTree history_list; + _debug("HistoryManager: Load history"); + create_history_path (path); load_history_from_file (&history_list); return load_history_items_map (&history_list, limit); @@ -72,6 +73,8 @@ bool HistoryManager::save_history (void) { Conf::ConfigTree history_list; + _debug("HistoryManager: Save history"); + save_history_items_map (&history_list); return save_history_to_file (&history_list); } @@ -155,6 +158,8 @@ int HistoryManager::save_history_items_map (Conf::ConfigTree *history_list) HistoryItem *item; int items_saved = 0; + _debug("HistoryManager: Save history items map"); + iter = _history_items.begin (); while (iter != _history_items.end ()) { @@ -246,6 +251,8 @@ std::vector<std::string> HistoryManager::get_history_serialized (void) HistoryItem *current; std::string res; + _debug("HistoryManager: Get history serialized"); + iter = _history_items.begin (); while (iter != _history_items.end()) { @@ -272,6 +279,8 @@ int HistoryManager::set_serialized_history (std::vector<std::string> history, in int history_limit; time_t current_timestamp; + _debug("HistoryManager: Set serialized history"); + // Clear the existing history _history_items.clear (); diff --git a/sflphone-common/test/sflphoned-sample.yml b/sflphone-common/test/sflphoned-sample.yml index 6a9d6cef55..e5f1ba1316 100644 --- a/sflphone-common/test/sflphoned-sample.yml +++ b/sflphone-common/test/sflphoned-sample.yml @@ -54,7 +54,7 @@ preferences: historyMaxCalls: 20 md5Hash: false notifyMails: false - order: Account:1307975440/Account:1307975347/Account:1307974800/Account:1307974672/Account:1307974527/Account:1303487773/Account:1303247743/Account:1302895321/Account:1302892836/Account:1302891834/Account:1302882519/Account:1302207377/Account:1302207262/Account:1302204136/Account:1302204108/Account:1294850905/Account:1294850775/Account:1294850618/Account:1294849651/Account:1294849602/Account:1294849310/Account:1288964768/Account:1288964603/Account:1288964434/Account:1288964141/Account:1288964134/ + order: Account:1308839853/Account:1308839662/Account:1308839447/Account:1308839359/Account:1308839335/Account:1308838875/Account:1308838713/Account:1308838236/Account:1307975440/Account:1307975347/Account:1307974800/Account:1307974672/Account:1307974527/Account:1303487773/Account:1303247743/Account:1302895321/Account:1302892836/Account:1302891834/Account:1302882519/Account:1302207377/Account:1302207262/Account:1302204136/Account:1302204108/Account:1294850905/Account:1294850775/Account:1294850618/Account:1294849651/Account:1294849602/Account:1294849310/Account:1288964768/Account:1288964603/Account:1288964434/Account:1288964141/Account:1288964134/ portNum: 5060 registrationExpire: 180 searchBarDisplay: true -- GitLab