From 03f33d2642c63d93303ea9e6a3ddc2ca2d591c3c Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandresavard@msavard.(none)> Date: Mon, 13 Jun 2011 09:45:53 -0400 Subject: [PATCH] #6109: Recording filename in daemon and client for history items + serialization --- sflphone-client-gnome/src/callable_obj.c | 15 ++++++++++-- sflphone-client-gnome/src/callable_obj.h | 6 +++++ sflphone-common/src/history/historyitem.cpp | 23 ++++++++++--------- sflphone-common/src/history/historyitem.h | 16 ++++++++++++- .../src/history/historymanager.cpp | 7 ++++-- sflphone-common/src/history/historymanager.h | 3 ++- 6 files changed, 53 insertions(+), 17 deletions(-) diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index 811e716400..66766a485c 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -233,6 +233,7 @@ void create_new_call (callable_type_t type, call_state_t state, gchar* callID , obj->_peer_name = g_strdup (peer_name); obj->_peer_number = g_strdup (peer_number); obj->_peer_info = g_strdup (get_peer_info (peer_name, peer_number)); + obj->_recordfile = NULL; obj->_trsft_to = ""; set_timestamp (& (obj->_time_start)); @@ -300,6 +301,7 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details { gchar *peer_name=""; gchar *peer_number="", *accountID="", *time_stop=""; + gchar *recordfile=""; callable_obj_t *new_call; history_state_t history_state = MISSED; char **ptr; @@ -311,7 +313,6 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details if ( (ptr = g_strsplit (details, delim,5)) != NULL) { while (ptr != NULL && token < 5) { - switch (token) { case 0: history_state = get_history_state_from_id (*ptr); @@ -328,6 +329,8 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details case 4: accountID = *ptr; break; + case 5: + recordfile = *ptr; default: break; } @@ -346,6 +349,7 @@ void create_history_entry_from_serialized_form (gchar *timestamp, gchar *details new_call->_history_state = history_state; new_call->_time_start = convert_gchar_to_timestamp (timestamp); new_call->_time_stop = convert_gchar_to_timestamp (time_stop); + new_call->_recordfile = g_strdup(recordfile); *call = new_call; } @@ -361,6 +365,12 @@ void free_callable_obj_t (callable_obj_t *c) g_free (c->_peer_name); g_free (c->_peer_number); g_free (c->_peer_info); + + if(c->_recordfile != NULL) { + g_free(c->_recordfile); + c->_recordfile = NULL; + } + g_free (c); DEBUG ("If you don't see it that is because there is a problem"); @@ -458,7 +468,8 @@ gchar* serialize_history_entry (callable_obj_t *entry) entry->_peer_number, separator, peer_name, separator, timestamp, separator, - account_id, + account_id, separator, + entry->_recordfile ? entry->_recordfile : "", NULL); return result; diff --git a/sflphone-client-gnome/src/callable_obj.h b/sflphone-client-gnome/src/callable_obj.h index 3b8bc941ed..fd43e7abf2 100644 --- a/sflphone-client-gnome/src/callable_obj.h +++ b/sflphone-client-gnome/src/callable_obj.h @@ -150,6 +150,12 @@ typedef struct { /* The audio codec used for this call, if applicable */ gchar *_audio_codec; + /** + * The recording file for this call, if NULL, no recording available + * Should be used only for history items + */ + gchar *_recordfile; + /* Associated IM widget */ GtkWidget *_im_widget; diff --git a/sflphone-common/src/history/historyitem.cpp b/sflphone-common/src/history/historyitem.cpp index 2f96f3f692..bf475861ab 100644 --- a/sflphone-common/src/history/historyitem.cpp +++ b/sflphone-common/src/history/historyitem.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,13 +38,14 @@ #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) +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) : _timestamp_start (timestamp_start), _timestamp_stop (timestamp_stop), _call_type (call_type), _name (name), _number (number), - _account_id (account_id) + _account_id (account_id), + _recording_file(recording) { } @@ -52,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; + std::string tmp, id, name, number, stop, account, recordFile; int indice=0; while (serialized_form.find (ITEM_SEPARATOR, 0) != std::string::npos) { @@ -61,27 +63,24 @@ HistoryItem::HistoryItem (std::string timestamp, std::string serialized_form) serialized_form.erase (0, pos + 1); switch (indice) { - case 0: // The call type id = tmp; break; - case 1: // The number field number = tmp; break; - case 2: // The name field name = tmp; break; - case 3: // The end timestamp stop = tmp; break; - case 4: // The account ID account = tmp; break; - + case 5: // The recorded file name + recordFile = tmp; + break; default: // error std::cout <<"[ERROR] unserialized form not recognized."<<std::endl; break; @@ -118,7 +117,8 @@ bool HistoryItem::save (Conf::ConfigTree **history) && (*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, "name", _name) + && (*history)->setConfigTreeItem (section, "recordfile", _recording_file)); return res; } @@ -136,7 +136,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_stop << separator << accountID; + res << _call_type << separator << _number << separator << name << separator << _timestamp_stop << 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 d027408765..df59bf36a0 100644 --- a/sflphone-common/src/history/historyitem.h +++ b/sflphone-common/src/history/historyitem.h @@ -2,6 +2,7 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * Author: Alexamdre Savard <alexandre.savard@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,8 +50,16 @@ class HistoryItem public: /* * Constructor + * + * @param Timestamp start + * @param Call type + * @param Timestamp stop + * @param Call name + * @param Call number + * @param Call account id + * @param Recording file name (if any recording were performed) */ - HistoryItem (std::string, CallType, std::string, std::string, std::string, std::string=""); + HistoryItem (std::string, CallType, std::string, std::string, std::string, std::string="", std::string=""); /* * Constructor from a serialized form @@ -99,6 +108,11 @@ class HistoryItem * The account the call was made with */ std::string _account_id; + + /** + * Wether or not a recording exist for this call + */ + std::string _recording_file; }; diff --git a/sflphone-common/src/history/historymanager.cpp b/sflphone-common/src/history/historymanager.cpp index 7130aed3f2..8ef22ed175 100644 --- a/sflphone-common/src/history/historymanager.cpp +++ b/sflphone-common/src/history/historymanager.cpp @@ -2,6 +2,7 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -94,7 +95,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; + std::string number, name, accountID, timestamp_start, timestamp_stop, recording_file; CallType type; int history_limit; time_t current_timestamp; @@ -116,12 +117,14 @@ int HistoryManager::load_history_items_map (Conf::ConfigTree *history_list, int name = getConfigString (*iter, "name", history_list); number = getConfigString (*iter, "number", history_list); accountID = getConfigString (*iter, "accountid", history_list); + recording_file = getConfigString(*iter, "recordfile", history_list); + timestamp_start = *iter; // 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); + item = new HistoryItem (timestamp_start, type, timestamp_stop, name, number, accountID, recording_file); add_new_history_entry (item); nb_items ++; } diff --git a/sflphone-common/src/history/historymanager.h b/sflphone-common/src/history/historymanager.h index 904d05f76b..f3740feb51 100644 --- a/sflphone-common/src/history/historymanager.h +++ b/sflphone-common/src/history/historymanager.h @@ -2,6 +2,7 @@ * Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. * * Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -76,7 +77,7 @@ class HistoryManager */ int load_history_items_map (Conf::ConfigTree *history_list, int limit); - /* + /* * Inverse method, ie save a data structure containing the history into a file */ bool save_history_to_file (Conf::ConfigTree *history_list); -- GitLab