Commit a3fcb3ca authored by Emmanuel Lepage's avatar Emmanuel Lepage
parents 9bf14c7b 13c08077
......@@ -93,8 +93,7 @@ typedef std::map<std::string, YamlNode*> Mapping;
void MappingNode::setKeyValue(const std::string &key, YamlNode *value)
{
Mapping::iterator it = map_.end();
map_.insert(it, std::pair<std::string, YamlNode *>(key, value));
map_[key] = value;
}
void MappingNode::removeKeyValue(const std::string &key)
......@@ -107,6 +106,8 @@ YamlNode *MappingNode::getValue(const std::string &key) const
{
Mapping::const_iterator it = map_.find(key);
if (it != map_.end())
return it->second;
else
......@@ -125,19 +126,23 @@ void MappingNode::getValue(const std::string &key, bool *b) const
void MappingNode::getValue(const std::string &key, int *i) const
{
ScalarNode *node = static_cast<ScalarNode*>(getValue(key));
if (!node)
ScalarNode *node = dynamic_cast<ScalarNode*>(getValue(key));
if (!node) {
ERROR("node %s not found", key.c_str());
return;
}
*i = std::atoi(node->getValue().c_str());
}
void MappingNode::getValue(const std::string &key, std::string *v) const
{
ScalarNode *node = static_cast<ScalarNode*>(getValue(key));
ScalarNode *node = dynamic_cast<ScalarNode*>(getValue(key));
if (!node)
if (!node) {
ERROR("node %s not found", key.c_str());
return;
}
*v = node->getValue();
}
......@@ -146,7 +151,7 @@ void MappingNode::getValue(const std::string &key, std::string *v) const
void MappingNode::deleteChildNodes()
{
for (Mapping::iterator it = map_.begin(); it != map_.end(); ++it) {
YamlNode *yamlNode = static_cast<YamlNode *>(it->second);
YamlNode *yamlNode = dynamic_cast<YamlNode *>(it->second);
if (!yamlNode)
continue;
......@@ -155,21 +160,21 @@ void MappingNode::deleteChildNodes()
case DOCUMENT:
break;
case SEQUENCE: {
SequenceNode *sequence = static_cast<SequenceNode *>(yamlNode);
SequenceNode *sequence = dynamic_cast<SequenceNode *>(yamlNode);
sequence->deleteChildNodes();
delete sequence;
sequence = NULL;
}
break;
case MAPPING: {
MappingNode *mapping = static_cast<MappingNode *>(yamlNode);
MappingNode *mapping = dynamic_cast<MappingNode *>(yamlNode);
mapping->deleteChildNodes();
delete mapping;
mapping = NULL;
}
break;
case SCALAR: {
ScalarNode *scalar = static_cast<ScalarNode *>(yamlNode);
ScalarNode *scalar = dynamic_cast<ScalarNode *>(yamlNode);
delete scalar;
scalar = NULL;
}
......
......@@ -33,6 +33,7 @@
#include "../global.h"
#include "sfl_config.h"
#include "yamlnode.h"
#include "logger.h"
#include <cstdio>
namespace Conf {
......@@ -258,6 +259,7 @@ void YamlParser::processScalar(YamlNode *topNode)
break;
case MAPPING:
((MappingNode *)(topNode))->addNode(sclr);
break;
case SCALAR:
default:
break;
......
......@@ -313,6 +313,24 @@
</arg>
</method>
<method name="getConferenceId" tp:name-for-bindings="getConferenceId">
<tp:added version="1.1.0"/>
<tp:docstring>
If thsi call participate to a conference, return the conference id.
Return an empty string elsewhere.
</tp:docstring>
<arg type="s" name="callID" direction="in">
<tp:docstring>
The call id.
</tp:docstring>
</arg>
<arg type="s" name="confID" direction="out">
<tp:docstring>
A string containing the conference ID, or an empty string.
</tp:docstring>
</arg>
</method>
<method name="setRecording" tp:name-for-bindings="setRecording">
<tp:docstring>
Start recording a call.
......
......@@ -232,6 +232,12 @@ CallManager::getParticipantList(const std::string& confID)
return Manager::instance().getParticipantList(confID);
}
std::string
CallManager::getConferenceId(const std::string& callID)
{
return Manager::instance().getConferenceId(callID);
}
bool
CallManager::startRecordedFilePlayback(const std::string& filepath)
{
......
......@@ -99,6 +99,7 @@ class CallManager
void unholdConference(const std::string& confID);
std::vector< std::string > getConferenceList();
std::vector< std::string > getParticipantList(const std::string& confID);
std::string getConferenceId(const std::string& callID);
std::map< std::string, std::string > getConferenceDetails(const std::string& callID);
/* File Playback methods */
......
......@@ -1144,27 +1144,25 @@ void ManagerImpl::processRemainingParticipants(const std::string &current_call_i
void ManagerImpl::joinConference(const std::string& conf_id1,
const std::string& conf_id2)
{
ConferenceMap::iterator iter(conferenceMap_.find(conf_id1));
DEBUG("Join conferences %s and %s", conf_id1.c_str(), conf_id2.c_str());
if (iter == conferenceMap_.end()) {
if (conferenceMap_.find(conf_id1) == conferenceMap_.end()) {
ERROR("Not a valid conference ID: %s", conf_id1.c_str());
return;
}
if (conferenceMap_.find(conf_id2) != conferenceMap_.end()) {
if (conferenceMap_.find(conf_id2) == conferenceMap_.end()) {
ERROR("Not a valid conference ID: %s", conf_id2.c_str());
return;
}
if (iter->second) {
Conference *conf = iter->second;
ParticipantSet participants(conf->getParticipantList());
Conference *conf = conferenceMap_.find(conf_id1)->second;
ParticipantSet participants(conf->getParticipantList());
for (ParticipantSet::const_iterator p = participants.begin();
p != participants.end(); ++p) {
detachParticipant(*p, "");
addParticipant(*p, conf_id2);
}
for (ParticipantSet::const_iterator p = participants.begin();
p != participants.end(); ++p) {
detachParticipant(*p, "");
addParticipant(*p, conf_id2);
}
}
......@@ -2613,8 +2611,9 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
Sequence::const_iterator ip2ip = std::find_if(seq->begin(), seq->end(), isIP2IP);
if (ip2ip != seq->end()) {
MappingNode *node = dynamic_cast<MappingNode*>(*ip2ip);
if (node)
accountMap_[SIPAccount::IP2IP_PROFILE]->unserialize(node);
if (node) {
accountMap_[SIPAccount::IP2IP_PROFILE]->unserialize(*node);
}
}
// Initialize default UDP transport according to
......@@ -2855,6 +2854,20 @@ std::vector<std::string> ManagerImpl::getParticipantList(const std::string& conf
return v;
}
std::string ManagerImpl::getConferenceId(const std::string& callID)
{
std::string account_id = getAccountFromCall(callID);
Call *call = getAccountLink(account_id)->getCall(callID);
if(call == NULL) {
ERROR("Get conference id");
return "";
}
std::string confID = call->getConfId();
return confID;
}
void ManagerImpl::saveHistory()
{
if (!history_.save())
......
......@@ -458,6 +458,8 @@ class ManagerImpl {
*/
std::vector<std::string> getParticipantList(const std::string& confID) const;
std::string getConferenceId(const std::string& callID);
/**
* Save the details of an existing account, given the account ID
* This will load the configuration map with the given data.
......
......@@ -152,9 +152,6 @@ sflphone_quit()
calllist_clean(current_calls_tab);
calllist_clean(contacts_tab);
calllist_clean(history_tab);
gtk_tree_store_clear(history_tab->store);
gtk_tree_store_clear(current_calls_tab->store);
gtk_tree_store_clear(contacts_tab->store);
gtk_main_quit();
}
}
......@@ -186,11 +183,6 @@ sflphone_hung_up(callable_obj_t * c)
call_remove_all_errors(c);
update_actions();
if (c->_confID) {
g_free(c->_confID);
c->_confID = NULL;
}
// test whether the widget contains text, if not remove it
if ((im_window_get_nb_tabs() > 1) && c->_im_widget && !(IM_WIDGET(c->_im_widget)->containText))
im_window_remove_tab(c->_im_widget);
......@@ -396,6 +388,7 @@ sflphone_pick_up()
dbus_transfer(selectedCall);
time(&selectedCall->_time_stop);
calltree_remove_call(current_calls_tab, selectedCall->_callID);
update_actions();
calllist_remove_call(current_calls_tab, selectedCall->_callID);
break;
case CALL_STATE_CURRENT:
......@@ -615,8 +608,12 @@ sflphone_new_call()
callable_obj_t *current_selected_call = calltab_get_selected_call(current_calls_tab);
if ((current_selected_call != NULL) && (current_selected_call->_confID == NULL))
sflphone_on_hold();
if (current_selected_call != NULL) {
gchar *confID = dbus_get_conference_id(current_selected_call->_callID);
if(g_strcmp0(confID, "") != 0) {
sflphone_on_hold();
}
}
// Play a tone when creating a new call
if (calllist_get_size(current_calls_tab) == 0)
......@@ -695,6 +692,7 @@ sflphone_keypad(guint keyval, gchar * key)
dbus_transfer(c);
time(&c->_time_stop);
calltree_remove_call(current_calls_tab, c->_callID);
update_actions();
break;
case GDK_Escape:
sflphone_unset_transfer();
......@@ -814,11 +812,6 @@ sflphone_detach_participant(const gchar* callID)
DEBUG("Detach participant %s", selectedCall->_callID);
if (selectedCall->_confID) {
g_free(selectedCall->_confID);
selectedCall->_confID = NULL;
}
im_widget_update_state(IM_WIDGET(selectedCall->_im_widget), TRUE);
calltree_remove_call(current_calls_tab, selectedCall->_callID);
calltree_add_call(current_calls_tab, selectedCall, NULL);
......@@ -947,20 +940,23 @@ void sflphone_fill_codec_list_per_account(account_t *account)
void sflphone_fill_call_list(void)
{
gchar **list = dbus_get_call_list();
gchar **call_list = dbus_get_call_list();
for (gchar **calls = list; calls && *calls; ++calls) {
gchar *callID = *calls;
for (gchar **callp = call_list; callp && *callp; ++callp) {
gchar *callID = *callp;
if (!calllist_get_call(current_calls_tab, callID)) {
callable_obj_t *c = create_new_call_from_details(*calls, dbus_get_call_details(*calls));
c->_zrtp_confirmed = FALSE;
calllist_add_call(current_calls_tab, c);
if (!c->_confID || strlen(c->_confID) == 0)
calltree_add_call(current_calls_tab, c, NULL);
callable_obj_t *call = create_new_call_from_details(*callp, dbus_get_call_details(*callp));
call->_zrtp_confirmed = FALSE;
calllist_add_call(current_calls_tab, call);
// add in treeview only if does not participate to a conference
gchar *confID = dbus_get_conference_id(call->_callID);
if(g_strcmp0(confID, "") == 0)
calltree_add_call(current_calls_tab, call, NULL);
}
}
g_strfreev(list);
g_strfreev(call_list);
}
......
......@@ -146,7 +146,6 @@ callable_obj_t *create_new_call_from_details(const gchar *call_id, GHashTable *d
const gchar * const peer_number = g_hash_table_lookup(details, "PEER_NUMBER");
const gchar * const display_name = g_hash_table_lookup(details, "DISPLAY_NAME");
const gchar * const state_str = g_hash_table_lookup(details, "CALL_STATE");
const gchar * const conf_id = g_hash_table_lookup(details, "CONF_ID");
if (utf8_case_equal(state_str, "CURRENT"))
state = CALL_STATE_CURRENT;
......@@ -163,7 +162,6 @@ callable_obj_t *create_new_call_from_details(const gchar *call_id, GHashTable *d
gchar *number = call_get_peer_number(peer_number);
callable_obj_t *c = create_new_call(CALL, state, call_id, accountID, display_name, number);
c->_confID = g_strdup(conf_id);
g_free(number);
return c;
}
......@@ -199,8 +197,7 @@ callable_obj_t *create_history_entry_from_hashtable(GHashTable *entry)
value = g_hash_table_lookup(entry, TIMESTAMP_STOP_KEY);
new_call->_time_stop = value ? atoi(value) : 0;
new_call->_recordfile = g_strdup(g_hash_table_lookup(entry, RECORDING_PATH_KEY));
new_call->_confID = g_strdup(g_hash_table_lookup(entry, CONFID_KEY));
new_call->_historyConfID = g_strdup(new_call->_confID);
new_call->_historyConfID = g_strdup(g_hash_table_lookup(entry, CONFID_KEY));
new_call->_record_is_playing = FALSE;
return new_call;
......@@ -209,7 +206,6 @@ callable_obj_t *create_history_entry_from_hashtable(GHashTable *entry)
void free_callable_obj_t (callable_obj_t *c)
{
g_free(c->_callID);
g_free(c->_confID);
g_free(c->_historyConfID);
g_free(c->_accountID);
g_free(c->_srtp_cipher);
......
......@@ -96,8 +96,7 @@ typedef struct {
int _state_code; // The numeric state code as defined in SIP or IAX
gchar* _state_code_description; // A textual description of _state_code
gchar* _callID; // The call ID
gchar* _confID; // The conference ID (NULL if don't participate to a conference)
gchar* _historyConfID; // Persistent conf id to be stored in history
gchar* _historyConfID; // Persistent conf id to be stored in history
gchar* _accountID; // The account the call is made with
time_t _time_start; // The timestamp the call was initiating
time_t _time_stop; // The timestamp the call was over
......
......@@ -143,16 +143,6 @@ void conference_participant_list_update(gchar** participants, conference_obj_t*
return;
}
for (gchar **part = participants; part && *part; ++part) {
const gchar *call_id = (const gchar *) (*part);
callable_obj_t *call = calllist_get_call(current_calls_tab, call_id);
if (call) {
g_free(call->_confID);
call->_confID = NULL;
}
}
if (conf->participant_list) {
g_slist_free(conf->participant_list);
conf->participant_list = NULL;
......@@ -165,7 +155,6 @@ void conference_participant_list_update(gchar** participants, conference_obj_t*
restore_call(call_id);
call = calllist_get_call(current_calls_tab, call_id);
}
call->_confID = g_strdup(conf->_confID);
conference_add_participant(call_id, conf);
}
}
......
......@@ -98,9 +98,9 @@ calltab_create_searchbar(calltab_t* tab)
{
g_assert(tab);
if (utf8_case_equal(tab->_name, HISTORY))
if (g_strcmp0(tab->_name, HISTORY) == 0)
tab->searchbar = history_searchbar_new();
else if (utf8_case_equal(tab->_name, CONTACTS))
else if (g_strcmp0(tab->_name, CONTACTS) == 0)
tab->searchbar = contacts_searchbar_new();
else
ERROR("Current calls tab does not need a searchbar\n");
......
This diff is collapsed.
......@@ -35,12 +35,10 @@
/** @file calltree.h
* @brief The GtkTreeView that list calls in the main window.
*/
typedef enum {
A_CALL,
A_CONFERENCE,
A_INVALID
} CallType;
} CallType;
/**
* Tags used to identify display type in calltree
......@@ -102,21 +100,10 @@ calltree_remove_conference(calltab_t *, const conference_obj_t *);
void
calltree_display (calltab_t *);
void
row_activated (GtkTreeView *, GtkTreePath *, GtkTreeViewColumn *, void *);
/**
* Update elapsed time based on selected calltree's call
*/
gboolean
calltree_update_clock(gpointer);
/**
* @param The calltab (current_calls, history, contacts)
* @param The call
* @param The callID/confID
*/
void
calltree_(calltab_t *, callable_obj_t *, const gchar * const);
#endif
......@@ -313,6 +313,24 @@
</arg>
</method>
<method name="getConferenceId" tp:name-for-bindings="getConferenceId">
<tp:added version="1.1.0"/>
<tp:docstring>
If thsi call participate to a conference, return the conference id.
Return an empty string elsewhere.
</tp:docstring>
<arg type="s" name="callID" direction="in">
<tp:docstring>
The call id.
</tp:docstring>
</arg>
<arg type="s" name="confID" direction="out">
<tp:docstring>
A string containing the conference ID, or an empty string.
</tp:docstring>
</arg>
</method>
<method name="setRecording" tp:name-for-bindings="setRecording">
<tp:docstring>
Start recording a call.
......
......@@ -338,7 +338,6 @@ conference_created_cb(DBusGProxy *proxy UNUSED, const gchar *confID, void *foo U
if (call->_state == CALL_STATE_RECORD)
new_conf->_state = CONFERENCE_STATE_ACTIVE_ATTACHED_RECORD;
call->_confID = g_strdup(confID);
call->_historyConfID = g_strdup(confID);
}
......@@ -365,8 +364,6 @@ conference_removed_cb(DBusGProxy *proxy UNUSED, const gchar *confID,
callable_obj_t *call = calllist_get_call(current_calls_tab, p->data);
if (call) {
g_free(call->_confID);
call->_confID = NULL;
im_widget_update_state(IM_WIDGET(call->_im_widget), TRUE);
}
}
......@@ -1723,6 +1720,16 @@ dbus_get_participant_list(const gchar *confID)
return list;
}
gchar *
dbus_get_conference_id(const gchar *callID)
{
gchar *confID = NULL;
GError *error = NULL;
org_sflphone_SFLphone_CallManager_get_conference_id(call_proxy, callID, &confID, &error);
check_error(error);
return confID;
}
GHashTable *
dbus_get_conference_details(const gchar *confID)
{
......
......@@ -388,6 +388,12 @@ void dbus_add_participant(const gchar *callID, const gchar *confID);
*/
gchar **dbus_get_participant_list(const gchar *confID);
/**
* If thsi call participate to a conference, return the conference id
* Return an empty string elsewhere
*/
gchar *dbus_get_conference_id(const gchar *callID);
/**
* Toggle recording for this instance, may be call or conference
*/
......
......@@ -847,6 +847,7 @@ remove_from_history(void * foo UNUSED)
}
calllist_remove_from_history(call);
update_actions();
}
static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment