diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index 3f0d33ceb9be684573d773eff5a1a03df9910e03..4cfe153600a8d8671c14a4c891f8063bcee4ef4d 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -1362,27 +1362,14 @@ void sflphone_fill_history (void) current_entry = *entries; - ptr = g_strsplit(current_entry, delim, 6); - if(ptr != NULL) { - - // first ptr refers to entry type - if(g_strcmp0(*ptr, "2188") == 0) { - DEBUG("------------------------------- SFLphone: Serialized item: %s", *ptr); - create_conference_history_entry_from_serialized(ptr, &conference_entry); - conferencelist_add (history, conference_entry); - conferencelist_add(current_calls, conference_entry); - calltree_add_conference (history, conference_entry); - } - else { - // do something with key and value - create_history_entry_from_serialized_form (ptr, &history_entry); + // do something with key and value + create_history_entry_from_serialized_form (current_entry, &history_entry); - // Add it and update the GUI - calllist_add_call (history, history_entry); - calltree_add_call (history, history_entry, NULL); - } - } - entries++; + // Add it and update the GUI + calllist_add_call (history, history_entry); + calltree_add_call (history, history_entry, NULL); + + entries++; } DEBUG ("======================================================== SFLphone: Loading history ...(end)"); @@ -1431,25 +1418,6 @@ void sflphone_save_history (void) } } - size = conferencelist_get_size(history); - DEBUG("SFLphone: Conference list size %d", size); - - while(size > 0) { - conf = conferencelist_pop_head(history); - size = conferencelist_get_size(history); - - if(conf) { - value = serialize_history_conference_entry(conf); - key = convert_timestamp_to_gchar(conf->_time_start); - DEBUG("-------------------------------------- SFLphone: Serialize conference [%s]: %s", key, value); - } - else { - WARN("SFLphone: Warning: %dth element is NULL", i); - } - g_hash_table_replace(result, (gpointer)key, - g_slist_append(g_hash_table_lookup(result, key), (gpointer)value)); - } - sflphone_order_history_hash_table(result, &ordered_result); gchar **testprnt = ordered_result; diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index 6d3f100800811742cf5aa954a32926a05322a442..1f09feea7df82a159d1d7ea9f6e2e97f8c42f5af 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -261,6 +261,9 @@ void create_new_call (callable_type_t type, call_state_t state, gchar* callID , } } + obj->_confID = NULL; + obj->_time_added = 0; + *new_call = obj; } @@ -298,17 +301,21 @@ void create_new_call_from_details (const gchar *call_id, GHashTable *details, ca *call = new_call; } -void create_history_entry_from_serialized_form (gchar **ptr, callable_obj_t **call) +void create_history_entry_from_serialized_form (gchar *entry, callable_obj_t **call) { - gchar *peer_name = ""; - gchar *peer_number = "", *accountID = "", *time_start = "", *time_stop = ""; + gchar *peer_name = "", *peer_number = ""; + gchar *callID = "", *accountID = ""; + gchar *time_start = "", *time_stop = ""; gchar *recordfile = ""; + gchar *confID = "", *time_added = ""; callable_obj_t *new_call; history_state_t history_state = MISSED; gint token = 0; - - // details is in serialized form, i e: calltype%to%from%callid - while (ptr != NULL && token < 7) { + gchar **ptr; + gchar *delim = "|"; + + ptr = g_strsplit(entry, delim, 10); + while (ptr != NULL && token < 10) { switch (token) { case 0: history_state = get_history_state_from_id (*ptr); @@ -325,34 +332,39 @@ void create_history_entry_from_serialized_form (gchar **ptr, callable_obj_t **ca case 4: time_stop = *ptr; break; - case 5: + case 5: + callID = *ptr; + break; + case 6: accountID = *ptr; - // remove terminating | (this may occurs if recordfiel filed is empty) - if(g_str_has_suffix(accountID, "|")) { - int len = strlen(accountID); - gchar *tmpchar = g_strdup(accountID); - g_strlcpy(accountID, tmpchar, len); - } break; - case 6: + case 7: recordfile = *ptr; + break; + case 8: + confID = *ptr; + break; + case 9: + time_added = *ptr; + break; default: break; } token++; ptr++; - } if (g_strcasecmp (peer_name, "empty") == 0) - peer_name=""; + peer_name = ""; - create_new_call (HISTORY_ENTRY, CALL_STATE_DIALING, "", accountID, peer_name, peer_number, &new_call); + create_new_call (HISTORY_ENTRY, CALL_STATE_DIALING, callID, accountID, peer_name, peer_number, &new_call); new_call->_history_state = history_state; new_call->_time_start = convert_gchar_to_timestamp (time_start); new_call->_time_stop = convert_gchar_to_timestamp (time_stop); new_call->_recordfile = g_strdup(recordfile); + new_call->_confID = g_strdup(confID); + new_call->_time_added = convert_gchar_to_timestamp(time_start); *call = new_call; } @@ -452,28 +464,39 @@ gchar* get_call_duration (callable_obj_t *obj) gchar* serialize_history_call_entry (callable_obj_t *entry) { // "0|514-276-5468|Savoir-faire Linux|144562458" for instance - + gchar *peer_number = "", *peer_name = "", *account_id = ""; gchar *result = ""; gchar *separator = "|"; gchar *history_state = "", *time_start = "", *time_stop = ""; + gchar *record_file = ""; + gchar *confID = "", *time_added = ""; + + gchar *call_id = entry->_callID; // Need the string form for the history state history_state = get_history_id_from_state (entry->_history_state); // and the timestamps time_start = convert_timestamp_to_gchar (entry->_time_start); time_stop = convert_timestamp_to_gchar (entry->_time_stop); + time_added = convert_timestamp_to_gchar (entry->_time_added); + peer_number = (entry->_peer_number == NULL) ? "" : entry->_peer_number; + peer_name = (entry->_peer_name == NULL || g_strcasecmp (entry->_peer_name,"") == 0) ? "empty": entry->_peer_name; + account_id = (entry->_accountID == NULL || g_strcasecmp (entry->_accountID,"") == 0) ? "empty": entry->_accountID; + confID = (entry->_confID == NULL) ? "" : entry->_confID; - gchar* peer_name = (entry->_peer_name == NULL || g_strcasecmp (entry->_peer_name,"") == 0) ? "empty": entry->_peer_name; - gchar* account_id = (entry->_accountID == NULL || g_strcasecmp (entry->_accountID,"") == 0) ? "empty": entry->_accountID; + record_file = g_strdup((entry->_recordfile == NULL) ? "" : entry->_recordfile); result = g_strconcat (history_state, separator, entry->_peer_number, separator, peer_name, separator, time_start, separator, time_stop, separator, + call_id, separator, account_id, separator, - entry->_recordfile ? entry->_recordfile : "", + record_file, separator, + confID, separator, + time_added, NULL); return result; @@ -549,7 +572,7 @@ gchar* get_peer_information (callable_obj_t *c) { - if (g_strcasecmp (c->_peer_name,"") == 0) + if (g_strcasecmp (c->_peer_name, "") == 0) return g_strdup (c->_peer_number); else return g_strdup (c->_peer_name); diff --git a/sflphone-client-gnome/src/callable_obj.h b/sflphone-client-gnome/src/callable_obj.h index 94f4b4297c9a4e0187c7a209151284050415cd02..33f6b40fa56967eb50046784f9f81ef7ff78e47a 100644 --- a/sflphone-client-gnome/src/callable_obj.h +++ b/sflphone-client-gnome/src/callable_obj.h @@ -165,13 +165,15 @@ typedef struct { int clockStarted; + time_t _time_added; + } callable_obj_t; void create_new_call (callable_type_t, call_state_t, gchar*, gchar*, gchar*, gchar*, callable_obj_t **); void create_new_call_from_details (const gchar *, GHashTable *, callable_obj_t **); -void create_history_entry_from_serialized_form (gchar **, callable_obj_t **); +void create_history_entry_from_serialized_form (gchar *, callable_obj_t **); void call_add_error (callable_obj_t * call, gpointer dialog); diff --git a/sflphone-client-gnome/src/conference_obj.c b/sflphone-client-gnome/src/conference_obj.c index 5d7ae40b5232feb8acf18b6595c9e4ef57b44fdf..c3e43913def651e0fa2d3fba8652f95e81526211 100644 --- a/sflphone-client-gnome/src/conference_obj.c +++ b/sflphone-client-gnome/src/conference_obj.c @@ -215,35 +215,39 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry) gchar *time_start = ""; gchar *time_stop = ""; gchar *peer_name = ""; - gchar *numberstr = ""; - GSList *number_list; + gchar *participantstr = ""; + gchar *confID = ""; + GSList *participant_list; gint length = 0; gint i; + confID = entry->_confID; + time_start = convert_timestamp_to_gchar(entry->_time_start); time_stop = convert_timestamp_to_gchar(entry->_time_stop); peer_name = (entry->_confID == NULL || g_strcasecmp(entry->_confID, "") == 0) ? "empty": entry->_confID; - length = g_slist_length(entry->participant_number); - number_list = entry->participant_number; + length = g_slist_length(entry->participant_list); + participant_list = entry->participant_list; for(i = 0; i < length; i++) { - gchar *tmp = g_slist_nth_data(number_list, i); + gchar *tmp = g_slist_nth_data(participant_list, i); if(tmp == NULL) { WARN("Conference: Peer number is NULL in conference list"); } - numberstr = g_strconcat(numberstr, tmp, ";", NULL); + participantstr = g_strconcat(participantstr, tmp, ";", NULL); - DEBUG("Conference: Participant number: %s, concatenation: %s", tmp, numberstr); + DEBUG("Conference: Participant number: %s, concatenation: %s", tmp, participantstr); } result = g_strconcat("2188", separator, - numberstr, separator, // peer number + participantstr, separator, // peer number peer_name, separator, time_start, separator, time_stop, separator, + confID, separator, "", separator, // peer AccountID entry->_recordfile ? entry->_recordfile : "", NULL); @@ -263,21 +267,17 @@ void create_conference_history_entry_from_serialized(gchar **ptr, conference_obj gchar *time_stop = ""; gchar *accountID = ""; gchar *recordfile = ""; - const gchar *confID = generate_call_id(); + const gchar *confID = ""; DEBUG("Conference: Create a conference from serialized form"); - // create a new empty conference - create_new_conference(state, confID, conf); - - while(ptr != NULL && token < 7) { + while(ptr != NULL && token < 8) { switch(token) { case 0: history_state = MISSED; break; case 1: participant = g_strdup(*ptr); - process_conference_participant_from_serialized(participant, *conf); break; case 2: name = *ptr; @@ -288,10 +288,13 @@ void create_conference_history_entry_from_serialized(gchar **ptr, conference_obj case 4: time_stop = *ptr; break; - case 5: - accountID = *ptr; + case 5: + confID = *ptr; break; case 6: + accountID = *ptr; + break; + case 7: recordfile = *ptr; break; default: @@ -302,6 +305,11 @@ void create_conference_history_entry_from_serialized(gchar **ptr, conference_obj ptr++; } + // create a new empty conference + create_new_conference(state, confID, conf); + + process_conference_participant_from_serialized(participant, *conf); + g_free(participant); } @@ -319,19 +327,27 @@ static void process_conference_participant_from_serialized(gchar *participant, c DEBUG("Conference: Process participant from serialized form"); - ptr = g_strsplit(participant, delim, 2); + ptr = g_strsplit(participant, delim, 3); while(ptr != NULL && (tok < 2)) { + gchar *call_id = NULL; +/* gchar *phone_number = NULL; gchar *account = NULL; + gchar *name = ""; token = 0; numberaccount = *ptr; numberptr = g_strsplit(numberaccount, delimnumber, 2); - while(numberptr != NULL && (token < 2)) { +*/ +/* + while(numberptr != NULL && (token < 3)) { switch(token) { case 0: phone_number = *numberptr; break; - case 1: + case 1: + call_id = *ptr; + break; + case 2: account = *numberptr; // remove the ";" character at the end of the account string if(g_str_has_suffix(account, ";")) { @@ -346,20 +362,17 @@ static void process_conference_participant_from_serialized(gchar *participant, c token++; numberptr++; } +*/ - tok++; - - gchar *name = ""; - gchar *call_id = generate_call_id(); - // we should create call here and add it to the conference to be inserted in history - create_new_call(HISTORY_ENTRY, CALL_STATE_DIALING, call_id, account, name, phone_number, &tmp_call); + // create_new_call(HISTORY_ENTRY, CALL_STATE_DIALING, call_id, account, name, phone_number, &tmp_call); // calllist_add_history_call(tmp_call); - calllist_add_call(history, tmp_call); + // calllist_add_call(history, tmp_call); // calllist_add_call(current_calls, tmp_call); conference_add_participant(call_id, conf); + tok++; ptr++; } } diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 988616ea192a10b05358d9fab0faae2314987fcb..d64d83fd2a98010160a41abddd967510f32ee3fd 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -363,6 +363,8 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo call_id = (gchar*) (*part); call = calllist_get_call (current_calls, call_id); + DEBUG("PART: %s", call_id); + // if a text widget is already created, disable it, use conference widget instead if (call->_im_widget) { im_widget_update_state (IM_WIDGET (call->_im_widget), FALSE); diff --git a/sflphone-common/src/conference.cpp b/sflphone-common/src/conference.cpp index 18b0e47c0c40554a1370a4c7f9cb1f77f97f7503..24b553221a79f1a60d7929ff14eae7cc683f34c6 100644 --- a/sflphone-common/src/conference.cpp +++ b/sflphone-common/src/conference.cpp @@ -43,17 +43,8 @@ Conference::Conference() : _id (""), _confState (ACTIVE_ATTACHED), _nbParticipan _nbParticipant = 0; ++count; - - std::string conf ("conf_"); - - // convert count into string - std::string s; - std::stringstream out; - out << count; - s = out.str(); - _nbParticipant = 0; - _id = conf.append (s); + _id = Manager::instance().getNewCallID(); Recordable::initRecFileName (_id); diff --git a/sflphone-common/src/history/historyitem.cpp b/sflphone-common/src/history/historyitem.cpp index 0c09f12f2a7cf2f9f0e104b6f9ef9279f7e24029..3e9e53136daa972e3ad08b85bdb34229efb02834 100644 --- a/sflphone-common/src/history/historyitem.cpp +++ b/sflphone-common/src/history/historyitem.cpp @@ -38,14 +38,17 @@ #define ITEM_SEPARATOR "|" #define EMPTY_STRING "empty" -HistoryItem::HistoryItem (std::string timestamp_start, CallType call_type, std::string timestamp_stop, std::string name, std::string number, std::string account_id, std::string recording) +HistoryItem::HistoryItem (std::string timestamp_start, CallType call_type, std::string timestamp_stop, std::string name, std::string number, std::string id, std::string account_id, std::string recording, std::string confID, std::string timeAdded) : _timestamp_start (timestamp_start), _timestamp_stop (timestamp_stop), _call_type (call_type), _name (name), _number (number), + _id(id), _account_id (account_id), - _recording_file(recording) + _recording_file(recording), + _confID(confID), + _timeAdded(timeAdded) { } @@ -53,8 +56,9 @@ HistoryItem::HistoryItem (std::string timestamp_start, CallType call_type, std:: HistoryItem::HistoryItem (std::string serialized_form) { size_t pos; - std::string tmp, id, name, number, start, stop, account, recordFile; - int indice=0; + std::string tmp, type, name, number, start, stop, id, account, recordFile; + std::string confID, timeAdded; + int indice = 0; while (serialized_form.find (ITEM_SEPARATOR, 0) != std::string::npos) { pos = serialized_form.find (ITEM_SEPARATOR, 0); @@ -63,8 +67,8 @@ HistoryItem::HistoryItem (std::string serialized_form) switch (indice) { case 0: // The call type - id = tmp; - _error("Unserialized id: %s", tmp.c_str()); + type = tmp; + _error("Unserialized type: %s", tmp.c_str()); break; case 1: // The number field number = tmp; @@ -82,29 +86,47 @@ HistoryItem::HistoryItem (std::string serialized_form) _error("Serialized time stop: %s", tmp.c_str()); stop = tmp; break; - case 5: // The account ID + case 5: // The ID + _error("Serialized id: %s", tmp.c_str()); + id = tmp; + break; + case 6: // The account ID _error("Serialized account: %s", tmp.c_str()); account = tmp; break; - case 6: // The recorded file name + case 7: // The recorded file name _error("Serialized recordfile: %s", tmp.c_str()); recordFile = tmp; break; + case 8: // The conference ID + _error("Serialized conferenceID: %s", tmp.c_str()); + confID = tmp; + break; + case 9: // The time + _error("Serialized timeadded: %s", tmp.c_str()); + timeAdded = tmp; + break; default: // error - std::cout <<"[ERROR] unserialized form not recognized."<<std::endl; + std::cout << "[ERROR] unserialized form not recognized." << std::endl; break; } indice ++; } - _call_type = (CallType) atoi (id.c_str()); + _id = id; + + _call_type = (CallType) atoi (type.c_str()); _number = number; (name == EMPTY_STRING) ? _name = "" : _name = name; _timestamp_start = start; _timestamp_stop = stop; - (serialized_form == EMPTY_STRING) ? _account_id = "" : _account_id=tmp; + // (serialized_form == EMPTY_STRING) ? _account_id = "" : _account_id = tmp; + _account_id = account; + + _confID = confID; + _timeAdded = timeAdded; } HistoryItem::~HistoryItem () @@ -125,21 +147,29 @@ bool HistoryItem::save (Conf::ConfigTree **history) 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()); - _error("Unserialized number: %s", _number.c_str()); - _error("Unserialized account: %s", _account_id.c_str()); - _error("Unserialized name: %s", _name.c_str()); - _error("Unserialized record file: %s", _recording_file.c_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()); + _error("-- Unserialized number: %s", _number.c_str()); + _error("-- Unserialized id: %s", _id.c_str()); + _error("-- Unserialized account: %s", _account_id.c_str()); + _error("-- Unserialized name: %s", _name.c_str()); + _error("-- Unserialized record file: %s", _recording_file.c_str()); + _error("-- Unserialized conference id:%s", _confID.c_str()); + _error("-- Unserialized time added: %s", _timeAdded.c_str()); + 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, "id", _id) && (*history)->setConfigTreeItem (sectionstr, "accountid", _account_id) && (*history)->setConfigTreeItem (sectionstr, "name", _name) - && (*history)->setConfigTreeItem (sectionstr, "recordfile", _recording_file)); + && (*history)->setConfigTreeItem (sectionstr, "recordfile", _recording_file) + && (*history)->setConfigTreeItem (sectionstr, "confid", _confID) + && (*history)->setConfigTreeItem (sectionstr, "timeadded", _timeAdded)); + return res; } @@ -157,8 +187,8 @@ std::string HistoryItem::serialize (void) (_account_id == "" || non_valid_account (_account_id)) ? accountID = "empty" : accountID = _account_id; // Serialize it - res << _call_type << separator << _number << separator << name << separator << _timestamp_start << separator << _timestamp_stop << separator << accountID - << separator << _recording_file; + res << _call_type << separator << _number << separator << name << separator << _timestamp_start << separator << _timestamp_stop + << separator << _id << separator << accountID << separator << _recording_file; return res.str(); } diff --git a/sflphone-common/src/history/historyitem.h b/sflphone-common/src/history/historyitem.h index 463321513d6b473acd5afd6544cd3946434835ad..ab73a5d157b275c27ab8d9994a13d0b40466b042 100644 --- a/sflphone-common/src/history/historyitem.h +++ b/sflphone-common/src/history/historyitem.h @@ -56,10 +56,13 @@ class HistoryItem * @param Timestamp stop * @param Call name * @param Call number + * @param Call id * @param Call account id * @param Recording file name (if any recording were performed) + * @param Configuration ID + * @param time added */ - HistoryItem (std::string, CallType, std::string, std::string, std::string, std::string="", std::string=""); + HistoryItem (std::string, CallType, std::string, std::string, std::string, std::string, std::string, std::string, std::string, std::string); /* * Constructor from a serialized form @@ -105,6 +108,11 @@ class HistoryItem std::string _name; std::string _number; + /** + * The identifier fo this item + */ + std::string _id; + /* * The account the call was made with */ @@ -114,6 +122,16 @@ class HistoryItem * Wether or not a recording exist for this call */ std::string _recording_file; + + /** + * The conference ID for this call (if any) + */ + std::string _confID; + + /** + * Time added to conference + */ + std::string _timeAdded; }; diff --git a/sflphone-common/src/history/historymanager.cpp b/sflphone-common/src/history/historymanager.cpp index f005ec4a219d3bdd2376fed07ef4f4553ff864ab..be4138bcbf60ea15302b7d0078780d2b407992ab 100644 --- a/sflphone-common/src/history/historymanager.cpp +++ b/sflphone-common/src/history/historymanager.cpp @@ -98,7 +98,7 @@ int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list, int Conf::TokenList sections; HistoryItem *item; Conf::TokenList::iterator iter; - std::string number, name, accountID, timestamp_start, timestamp_stop, recording_file; + std::string number, name, callID, accountID, timestamp_start, timestamp_stop, recording_file, confID, time_added; CallType type; int history_limit; time_t current_timestamp; @@ -120,20 +120,26 @@ int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list, int timestamp_stop = getConfigString (*iter, "timestamp_stop", history_list); name = getConfigString (*iter, "name", history_list); number = getConfigString (*iter, "number", history_list); + callID = getConfigString(*iter, "id", history_list); accountID = getConfigString (*iter, "accountid", history_list); recording_file = getConfigString(*iter, "recordfile", history_list); + confID = getConfigString(*iter, "confid", history_list); + time_added = getConfigString(*iter, "timeadded", history_list); _error("Unserialized time start: %s", timestamp_start.c_str()); _error("Unserialized time stop: %s", timestamp_stop.c_str()); _error("Unserialized number: %s", number.c_str()); + _error("Unserialized callid: %s", callID.c_str()); _error("Unserialized account: %s", accountID.c_str()); _error("Unserialized name: %s", name.c_str()); _error("Unserialized record file: %s", recording_file.c_str()); + _error("Unserialized confid: %s", confID.c_str()); + _error("Unserialized timeadded: %s", time_added.c_str()); // Make a check on the start timestamp to know it is loadable according to CONFIG_HISTORY_LIMIT if (atoi (timestamp_start.c_str ()) >= ( (int) current_timestamp - history_limit)) { - item = new HistoryItem (timestamp_start, type, timestamp_stop, name, number, accountID, recording_file); + item = new HistoryItem (timestamp_start, type, timestamp_stop, name, number, callID, accountID, recording_file, confID, time_added); add_new_history_entry (item); nb_items ++; }