Skip to content
Snippets Groups Projects
Commit af571461 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#6251: Add start_time timestamp in history serialization

parent a90ceac5
No related branches found
No related tags found
No related merge requests found
......@@ -298,19 +298,17 @@ void create_new_call_from_details (const gchar *call_id, GHashTable *details, ca
*call = new_call;
}
void create_history_entry_from_serialized_form (gchar *timestamp, gchar **ptr, callable_obj_t **call)
void create_history_entry_from_serialized_form (gchar *timestamp UNUSED, gchar **ptr, callable_obj_t **call)
{
gchar *peer_name = "";
gchar *peer_number = "", *accountID = "", *time_stop = "";
gchar *peer_number = "", *accountID = "", *time_start = "", *time_stop = "";
gchar *recordfile = "";
callable_obj_t *new_call;
history_state_t history_state = MISSED;
const gchar *delim = "|";
gint token = 0;
// details is in serialized form, i e: calltype%to%from%callid
while (ptr != NULL && token < 6) {
while (ptr != NULL && token < 7) {
switch (token) {
case 0:
history_state = get_history_state_from_id (*ptr);
......@@ -322,12 +320,15 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar **ptr, c
peer_name = *ptr;
break;
case 3:
time_stop = *ptr;
time_start = *ptr;
break;
case 4:
accountID = *ptr;
time_stop = *ptr;
break;
case 5:
accountID = *ptr;
break;
case 6:
recordfile = *ptr;
default:
break;
......@@ -343,7 +344,7 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar **ptr, c
create_new_call (HISTORY_ENTRY, CALL_STATE_DIALING, "", accountID, peer_name, peer_number, &new_call);
new_call->_history_state = history_state;
new_call->_time_start = convert_gchar_to_timestamp (timestamp);
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);
......@@ -448,14 +449,16 @@ gchar* serialize_history_call_entry (callable_obj_t *entry)
{
// "0|514-276-5468|Savoir-faire Linux|144562458" for instance
gchar* result;
gchar *result = "";
gchar *separator = "|";
gchar* history_state, *timestamp;
gchar *history_state = "", *time_start = "", *time_stop = "";
// Need the string form for the history state
history_state = get_history_id_from_state (entry->_history_state);
// and the timestamps
timestamp = convert_timestamp_to_gchar (entry->_time_stop);
time_start = convert_timestamp_to_gchar (entry->_time_start);
time_stop = convert_timestamp_to_gchar (entry->_time_stop);
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;
......@@ -463,7 +466,8 @@ gchar* serialize_history_call_entry (callable_obj_t *entry)
result = g_strconcat (history_state, separator,
entry->_peer_number, separator,
peer_name, separator,
timestamp, separator,
time_start, separator,
time_stop, separator,
account_id, separator,
entry->_recordfile ? entry->_recordfile : "",
NULL);
......
......@@ -210,17 +210,18 @@ void conference_participant_list_update (gchar** participants, conference_obj_t*
gchar *serialize_history_conference_entry(conference_obj_t *entry)
{
gchar *result;
gchar *result = "";
gchar *separator = "|";
gchar *sep;
gchar *timestamp;
gchar *peer_name;
gchar *time_start = "";
gchar *time_stop = "";
gchar *peer_name = "";
gchar *numberstr = "";
GSList *number_list;
gint length = 0;
gint i;
timestamp = convert_timestamp_to_gchar(entry->_time_stop);
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;
......@@ -235,13 +236,14 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry)
numberstr = g_strconcat(numberstr, tmp, ";", NULL);
DEBUG("Print: %s concat: %s", tmp, numberstr);
DEBUG("Conference: Participant number: %s, concatenation: %s", tmp, numberstr);
}
result = g_strconcat("2188", separator,
numberstr, separator, // peer number
peer_name, separator,
timestamp, separator,
time_start, separator,
time_stop, separator,
"", separator, // peer AccountID
entry->_recordfile ? entry->_recordfile : "",
NULL);
......@@ -250,14 +252,14 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry)
return result;
}
void create_conference_history_entry_from_serialized(gchar *timestamp, gchar **ptr, conference_obj_t **conf)
void create_conference_history_entry_from_serialized(gchar *timestamp UNUSED, gchar **ptr, conference_obj_t **conf)
{
gchar *conference_id = "";
history_state_t history_state = MISSED;
gint token = 0;
conference_state_t state = CONFERENCE_STATE_ACTIVE_ATACHED;
gchar *participant = "";
gchar *name = "";
gchar *time_start = "";
gchar *time_stop = "";
gchar *accountID = "";
gchar *recordfile = "";
......@@ -268,7 +270,7 @@ void create_conference_history_entry_from_serialized(gchar *timestamp, gchar **p
// create a new empty conference
create_new_conference(state, confID, conf);
while(ptr != NULL && token < 6) {
while(ptr != NULL && token < 7) {
switch(token) {
case 0:
history_state = MISSED;
......@@ -281,12 +283,15 @@ void create_conference_history_entry_from_serialized(gchar *timestamp, gchar **p
name = *ptr;
break;
case 3:
time_stop = *ptr;
time_start = *ptr;
break;
case 4:
accountID = *ptr;
time_stop = *ptr;
break;
case 5:
accountID = *ptr;
break;
case 6:
recordfile = *ptr;
break;
default:
......
......@@ -54,7 +54,7 @@ HistoryItem::HistoryItem (std::string timestamp, std::string serialized_form)
: _timestamp_start (timestamp)
{
size_t pos;
std::string tmp, id, name, number, stop, account, recordFile;
std::string tmp, id, name, number, start, stop, account, recordFile;
int indice=0;
while (serialized_form.find (ITEM_SEPARATOR, 0) != std::string::npos) {
......@@ -75,15 +75,19 @@ HistoryItem::HistoryItem (std::string timestamp, std::string serialized_form)
name = tmp;
_error("Unserialized name: %s", tmp.c_str());
break;
case 3: // The end timestamp
_error("Unserialized timestamp: %s", tmp.c_str());
case 3: // The start timestamp
_error("Unserialized time start: %s", tmp.c_str());
start = tmp;
break;
case 4: // The end timestamp
_error("Unserialized time stop: %s", tmp.c_str());
stop = tmp;
break;
case 4: // The account ID
case 5: // The account ID
_error("Unserialized account: %s", tmp.c_str());
account = tmp;
break;
case 5: // The recorded file name
case 6: // The recorded file name
_error("Unserialized recordfile: %s", tmp.c_str());
recordFile = tmp;
break;
......@@ -120,6 +124,7 @@ bool HistoryItem::save (Conf::ConfigTree **history)
call_type << _call_type;
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)
......@@ -142,7 +147,7 @@ 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_stop << separator << accountID
res << _call_type << separator << _number << separator << name << separator << _timestamp_start << separator << _timestamp_stop << separator << accountID
<< separator << _recording_file;
return res.str();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment