Commit bc090859 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

#6183: Ability to store conference inside history tab queue

parent 07132141
......@@ -94,6 +94,8 @@ account_list_remove (const gchar * accountID)
{
GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct);
DEBUG("Account List remove");
if (c) {
g_queue_remove (accountQueue, c->data);
}
......@@ -118,11 +120,12 @@ account_list_get_by_id (gchar * accountID)
{
GList * c = g_queue_find_custom (accountQueue, accountID, is_accountID_struct);
if (c) {
return (account_t *) c->data;
} else {
return NULL;
}
if(c == NULL) {
ERROR("AccountList: Could not find account %s", accountID);
return NULL;
}
return (account_t *) c->data;
}
guint account_list_get_size (void)
......
......@@ -195,7 +195,7 @@ sflphone_hung_up (callable_obj_t * c)
{
DEBUG ("SFLphone: Hung up");
calllist_remove (current_calls, c->_callID);
calllist_remove_call (current_calls, c->_callID);
calltree_remove_call (current_calls, c, NULL);
c->_state = CALL_STATE_DIALING;
call_remove_all_errors (c);
......@@ -452,7 +452,6 @@ sflphone_pick_up()
if (selectedCall) {
switch (selectedCall->_state) {
case CALL_STATE_DIALING:
DEBUG("------------------------------------ PLACING A NEW CALL FROM SFLPHONE PICKUP");
sflphone_place_call (selectedCall);
// if instant messaging window is visible, create new tab (deleted automatically if not used)
......@@ -469,7 +468,6 @@ sflphone_pick_up()
im_widget_display ( (IMWidget **) (&selectedCall->_im_widget), NULL, selectedCall->_callID, NULL);
dbus_accept (selectedCall);
DEBUG ("from sflphone_pick_up : ");
stop_notification();
break;
case CALL_STATE_HOLD:
......@@ -625,8 +623,8 @@ sflphone_incoming_call (callable_obj_t * c)
gchar *msg = "";
c->_history_state = MISSED;
calllist_add (current_calls, c);
calllist_add (history, c);
calllist_add_call (current_calls, c);
calllist_add_call (history, c);
calltree_add_call (current_calls, c, NULL);
update_actions();
calltree_display (current_calls);
......@@ -737,7 +735,7 @@ sflphone_new_call()
c->_history_state = OUTGOING;
calllist_add (current_calls,c);
calllist_add_call (current_calls,c);
calltree_add_call (current_calls, c, NULL);
update_actions();
......@@ -952,7 +950,7 @@ static int _place_registered_call (callable_obj_t * c)
}
c->_history_state = OUTGOING;
calllist_add (history, c);
calllist_add_call (history, c);
return 0;
}
......@@ -1009,7 +1007,7 @@ sflphone_detach_participant (const gchar* callID)
calltree_add_call (current_calls, selectedCall, NULL);
dbus_detach_participant (selectedCall->_callID);
} else {
callable_obj_t * selectedCall = calllist_get (current_calls, callID);
callable_obj_t * selectedCall = calllist_get_call (current_calls, callID);
DEBUG ("Action: Darticipant %s", callID);
if (selectedCall->_confID) {
......@@ -1225,7 +1223,7 @@ void sflphone_fill_call_list (void)
c->_zrtp_confirmed = FALSE;
// Add it to the list
DEBUG ("Add call retrieved from server side: %s\n", c->_callID);
calllist_add (current_calls, c);
calllist_add_call (current_calls, c);
// Update the GUI
calltree_add_call (current_calls, c, NULL);
}
......@@ -1318,7 +1316,7 @@ void sflphone_fill_history (void)
create_history_entry_from_serialized_form ( (gchar*) key, (gchar*) value, &history_entry);
DEBUG ("HISTORY ENTRY: %i\n", history_entry->_time_start);
// Add it and update the GUI
calllist_add (history, history_entry);
calllist_add_call (history, history_entry);
// remove entry from map
g_hash_table_remove (entries, key_to_min);
......@@ -1336,7 +1334,7 @@ void sflphone_save_history (void)
GHashTable *result = NULL;
gchar *key, *value;
DEBUG ("Saving history ...");
DEBUG ("SFLphone: Saving history ...");
result = g_hash_table_new (NULL, g_str_equal);
items = history->callQueue;
......
......@@ -39,10 +39,10 @@
#define UNIX_DAY 86400
#define UNIX_WEEK 86400 * 6
#define UNIX_TWO_DAYS 86400 * 2
/*
gint is_callID_callstruct (gconstpointer a, gconstpointer b)
{
callable_obj_t * c = (callable_obj_t*) a;
callable_obj_t * c = (callable_obj_t*) a;
if (g_strcasecmp (c->_callID, (const gchar*) b) == 0) {
return 0;
......@@ -50,6 +50,7 @@ gint is_callID_callstruct (gconstpointer a, gconstpointer b)
return 1;
}
}
*/
gint get_state_callstruct (gconstpointer a, gconstpointer b)
{
......
......@@ -182,7 +182,7 @@ void call_remove_all_errors (callable_obj_t * call);
/*
* GCompareFunc to compare a callID (gchar* and a callable_obj_t)
*/
gint is_callID_callstruct (gconstpointer, gconstpointer);
// gint is_callID_callstruct (gconstpointer, gconstpointer);
/*
* GCompareFunc to get current call (gchar* and a callable_obj_t)
......
......@@ -33,6 +33,31 @@
#include <contacts/searchbar.h>
#include <eel-gconf-extensions.h>
static
gint is_callID_callstruct(gconstpointer a, gconstpointer b)
{
QueueElement *c = (QueueElement *) a;
callable_obj_t *call;
if(c == NULL) {
return 1;
}
if(c->type != HIST_CALL) {
return 1;
}
call = c->elem.call;
DEBUG("Compare %s to %s", call->_callID, (const gchar *)b);
if(g_strcasecmp(call->_callID, (const gchar *) b) == 0) {
return 0;
}
else {
return 1;
}
}
// TODO : sflphoneGTK : try to do this more generic
void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_type_t type, GdkPixbuf *photo)
{
......@@ -66,7 +91,7 @@ void calllist_add_contact (gchar *contact_name, gchar *contact_phone, contact_ty
attach_thumbnail (new_call, pixbuf);
}
calllist_add (contacts, new_call);
calllist_add_call (contacts, new_call);
calltree_add_call (contacts, new_call, NULL);
}
}
......@@ -91,38 +116,66 @@ calllist_reset (calltab_t* tab)
tab->callQueue = g_queue_new();
}
void calllist_add_history_entry (callable_obj_t *obj)
void calllist_add_history_call (callable_obj_t *obj)
{
QueueElement *element;
if (eel_gconf_get_integer (HISTORY_ENABLED)) {
g_queue_push_tail (history->callQueue, (gpointer *) obj);
element = (QueueElement *)malloc(sizeof(QueueElement));
element->type = HIST_CALL;
element->elem.call = obj;
g_queue_push_tail (history->callQueue, (gpointer *) element);
calltree_add_call (history, obj, NULL);
}
}
void
calllist_add (calltab_t* tab, callable_obj_t * c)
void calllist_add_history_conference(conference_obj_t *obj)
{
if (tab == history) {
calllist_add_history_entry (c);
} else {
g_queue_push_tail (tab->callQueue, (gpointer *) c);
QueueElement *element;
if(eel_gconf_get_integer (HISTORY_ENABLED)) {
element = (QueueElement *)malloc(sizeof(QueueElement));
element->type = HIST_CONFERENCE;
element->elem.conf = obj;
g_queue_push_tail (history->callQueue, (gpointer *)element);
calltree_add_conference (history, obj);
}
}
void
calllist_add_call (calltab_t* tab, callable_obj_t * c)
{
QueueElement *element;
DEBUG(")))))))))))))))))))))))))))))))))))))))))))) Calllist: Add Call %s", c->_callID);
// if (tab == history) {
// calllist_add_history_call (c);
// } else {
element = (QueueElement *)malloc(sizeof(QueueElement));
element->type = HIST_CALL;
element->elem.call = c;
g_queue_push_tail (tab->callQueue, (gpointer *) element);
// }
}
// TODO : sflphoneGTK : try to do this more generic
void
calllist_clean_history (void)
{
unsigned int i;
guint size = calllist_get_size (history);
DEBUG ("CallList: history list size = %i", calllist_get_size (history));
for (i = 0 ; i < size ; i++) {
DEBUG ("CallList: Delete calls");
callable_obj_t* c = calllist_get_nth (history , i);
// Delete the call from the call tree
DEBUG ("CallList: Delete calls");
calltree_remove_call (history, c, NULL);
DEBUG ("CallList: History list size = %i", calllist_get_size (history));
for (i = 0 ; i < size; i++) {
QueueElement* c = calllist_get_nth (history , i);
if(c->type == HIST_CALL) {
calltree_remove_call (history, c->elem.call, NULL);
}
else if(c->type == HIST_CONFERENCE) {
calltree_remove_conference (history, c->elem.conf, NULL);
}
free(c);
}
calllist_reset (history);
......@@ -132,15 +185,15 @@ calllist_clean_history (void)
void
calllist_remove_from_history (callable_obj_t* c)
{
calllist_remove (history, c->_callID);
calllist_remove_call (history, c->_callID);
calltree_remove_call (history, c, NULL);
DEBUG ("CallList: Size of history = %i" , calllist_get_size (history));
}
void
calllist_remove (calltab_t* tab, const gchar * callID)
calllist_remove_call (calltab_t* tab, const gchar * callID)
{
callable_obj_t * c = calllist_get (tab, callID);
callable_obj_t * c = calllist_get_call (tab, callID);
if (c) {
g_queue_remove (tab->callQueue, c);
......@@ -167,20 +220,33 @@ calllist_get_size (calltab_t* tab)
return g_queue_get_length (tab->callQueue);
}
callable_obj_t *
QueueElement *
calllist_get_nth (calltab_t* tab, guint n)
{
return g_queue_peek_nth (tab->callQueue, n);
}
callable_obj_t *
calllist_get (calltab_t* tab, const gchar * callID)
calllist_get_call (calltab_t* tab, const gchar * callID)
{
QueueElement *element;
callable_obj_t *call;
DEBUG("CallList: Get call: %s", callID);
GList * c = g_queue_find_custom (tab->callQueue, callID, is_callID_callstruct);
if (c) {
return (callable_obj_t *) c->data;
} else {
if(c == NULL) {
ERROR("CallList: Error: Could not find call %s", callID);
return NULL;
}
element = (QueueElement *)c->data;
if(element->type != HIST_CALL) {
ERROR("CallList: Error: Element %s is not a call", callID);
return NULL;
}
call = element->elem.call;
return call;
}
......@@ -39,6 +39,18 @@
* @brief A list to hold calls.
*/
typedef enum { HIST_CONFERENCE, HIST_CALL } ElementType;
typedef struct {
callable_obj_t *call;
conference_obj_t *conf;
} callableElement;
typedef struct {
ElementType type;
callableElement elem;
} QueueElement;
typedef struct {
GtkTreeStore* store;
GtkWidget* view;
......@@ -56,7 +68,9 @@ typedef struct {
void
calllist_add_contact (gchar *, gchar *, contact_type_t, GdkPixbuf *);
void calllist_add_history_entry (callable_obj_t *obj);
void calllist_add_history_call (callable_obj_t *obj);
void calllist_add_history_conference (conference_obj_t *obj);
/** This function initialize a call list. */
void
......@@ -82,13 +96,13 @@ call_history_set_max_calls (const gdouble number);
* @param c The call you want to add
* */
void
calllist_add (calltab_t* tab, callable_obj_t * c);
calllist_add_call (calltab_t* tab, callable_obj_t * c);
/** This function remove a call from list.
* @param callID The callID of the call you want to remove
*/
void
calllist_remove (calltab_t* tab, const gchar * callID);
calllist_remove_call (calltab_t* tab, const gchar * callID);
/** Return the first call that corresponds to the state.
* This is usefull for unique states as DIALING and CURRENT.
......@@ -105,14 +119,14 @@ calllist_get_size (calltab_t* tab);
/** Return the call at the nth position in the list
* @param n The position of the call you want
* @return A call or NULL */
callable_obj_t *
QueueElement *
calllist_get_nth (calltab_t* tab, guint n);
/** Return the call corresponding to the callID
* @param n The callID of the call you want
* @return A call or NULL */
callable_obj_t *
calllist_get (calltab_t* tab, const gchar * callID);
calllist_get_call (calltab_t* tab, const gchar * callID);
/**
* Clean the history. Delete all calls
......
......@@ -242,7 +242,7 @@ row_activated (GtkTreeView *tree_view UNUSED,
create_new_call (CALL, CALL_STATE_DIALING, "", account_id, selectedCall->_peer_name, selectedCall->_peer_number, &new_call);
// sflphone_place_call(new_call);
calllist_add (current_calls, new_call);
calllist_add_call(current_calls, new_call);
calltree_add_call (current_calls, new_call, NULL);
// Function sflphone_place_call (new_call) is processed in process_dialing
sflphone_place_call(new_call);
......@@ -308,7 +308,7 @@ calltree_create_conf_from_participant_list(GSList *list) {
for(i = 0; i < list_length; i++) {
gchar *participant_id = g_slist_nth_data(list, i);
DEBUG("********************* participant %s ***************************", participant_id);
callable_obj_t *call = calllist_get(history, participant_id);
callable_obj_t *call = calllist_get_call(history, participant_id);
if(c!=0) {
participant_list = (void *) realloc(participant_list, (c+1) * sizeof(void *));
......@@ -1234,7 +1234,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf)
while (conference_participant) {
call_id = (gchar*) (conference_participant->data);
call = calllist_get (tab, call_id);
call = calllist_get_call(tab, call_id);
if (call != NULL) {
......@@ -1268,7 +1268,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf)
while (conference_participant) {
// call_id = (gchar*)(*pl);
call_id = (gchar*) (conference_participant->data);
call = calllist_get (tab, call_id);
call = calllist_get_call(tab, call_id);
if (call != NULL) {
......@@ -1326,7 +1326,7 @@ void calltree_add_conference (calltab_t* tab, conference_obj_t* conf)
while (conference_participant) {
call_id = (gchar*) (conference_participant->data);
call = calllist_get (tab, call_id);
call = calllist_get_call(tab, call_id);
// create_new_call_from_details (conf_id, conference_details, &c);
calltree_remove_call (tab, call, NULL);
......@@ -1455,7 +1455,7 @@ void calltree_add_history_conference(conference_obj_t *conf) {
if(conference_participant) {
while(conference_participant) {
call_id = (gchar *)(conference_participant->data);
call = calllist_get(current_calls, call_id);
call = calllist_get_call(current_calls, call_id);
if(call) {
calltree_add_history_entry(call, &iter);
}
......
......@@ -63,7 +63,7 @@ new_call_created_cb (DBusGProxy *proxy UNUSED, const gchar *accountID,
const gchar *callID, const gchar *to, void *foo UNUSED)
{
callable_obj_t *c;
gchar *peer_name = to;
gchar *peer_name = (gchar *)to;
gchar *peer_number = "";
DEBUG("DBus: New Call (%s) created to (%s)", callID, to);
......@@ -73,8 +73,8 @@ new_call_created_cb (DBusGProxy *proxy UNUSED, const gchar *accountID,
set_timestamp(&c->_time_start);
calllist_add(current_calls, c);
calllist_add(history, c);
calllist_add_call(current_calls, c);
calllist_add_call(history, c);
calltree_add_call(current_calls, c, NULL);
update_actions();
calltree_display(current_calls);
......@@ -115,7 +115,7 @@ zrtp_negotiation_failed_cb (DBusGProxy *proxy UNUSED, const gchar* callID,
DEBUG ("Zrtp negotiation failed.");
main_window_zrtp_negotiation_failed (callID, reason, severity);
callable_obj_t * c = NULL;
c = calllist_get (current_calls, callID);
c = calllist_get_call (current_calls, callID);
if (c) {
notify_zrtp_negotiation_failed (c);
......@@ -162,7 +162,7 @@ incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const
return;
// Get the call information. (if this call exist)
call = calllist_get (current_calls, callID);
call = calllist_get_call (current_calls, callID);
// Get the conference information (if this conference exist)
conf = conferencelist_get (callID);
......@@ -189,13 +189,16 @@ call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* state
void * foo UNUSED)
{
DEBUG ("DBUS: Call %s state %s",callID, state);
callable_obj_t * c = calllist_get (current_calls, callID);
callable_obj_t *c = calllist_get_call (current_calls, callID);
if(c == NULL) {
ERROR("DBUS: Call is NULL");
}
if (c) {
if (strcmp (state, "HUNGUP") == 0) {
if (c->_state == CALL_STATE_CURRENT) {
// peer hung up, the conversation was established, so _stop has been initialized with the current time value
DEBUG ("call state current");
DEBUG ("DBUS: call state current");
set_timestamp (&c->_time_stop);
calltree_update_call (history, c, NULL);
}
......@@ -250,8 +253,8 @@ call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* state
new_call->_history_state = OUTGOING;
}
calllist_add (current_calls, new_call);
calllist_add (history, new_call);
calllist_add_call (current_calls, new_call);
calllist_add_call (history, new_call);
calltree_add_call (current_calls, new_call, NULL);
update_actions();
calltree_display (current_calls);
......@@ -301,7 +304,7 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID,
while (part) {
call_id = (gchar*) (part->data);
call = calllist_get (current_calls, call_id);
call = calllist_get_call (current_calls, call_id);
if (call && call->_im_widget) {
im_widget_update_state (IM_WIDGET (call->_im_widget), TRUE);
......@@ -318,7 +321,7 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID,
while (part) {
call_id = (gchar*) (part->data);
call = calllist_get (current_calls, call_id);
call = calllist_get_call (current_calls, call_id);
if (call && call->_im_widget) {
im_widget_update_state (IM_WIDGET (call->_im_widget), FALSE);
......@@ -353,7 +356,7 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo
// Add conference ID in in each calls
for (part = participants; *part; part++) {
call_id = (gchar*) (*part);
call = calllist_get (current_calls, call_id);
call = calllist_get_call (current_calls, call_id);
// if a text widget is already created, disable it, use conference widget instead
if (call->_im_widget) {
......@@ -395,7 +398,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo
// remove all participant for this conference
while (participant) {
call = calllist_get (current_calls, (const gchar *) (participant->data));
call = calllist_get_call (current_calls, (const gchar *) (participant->data));
if (call) {
DEBUG ("DBUS: Remove participant %s", call->_callID);
......@@ -450,7 +453,7 @@ static void
secure_sdes_on_cb (DBusGProxy *proxy UNUSED, const gchar *callID, void *foo UNUSED)
{
DEBUG ("SRTP using SDES is on");
callable_obj_t *c = calllist_get (current_calls, callID);
callable_obj_t *c = calllist_get_call (current_calls, callID);
if (c) {
sflphone_srtp_sdes_on (c);
......@@ -463,7 +466,7 @@ static void
secure_sdes_off_cb (DBusGProxy *proxy UNUSED, const gchar *callID, void *foo UNUSED)
{
DEBUG ("SRTP using SDES is off");
callable_obj_t *c = calllist_get (current_calls, callID);
callable_obj_t *c = calllist_get_call (current_calls, callID);
if (c) {
sflphone_srtp_sdes_off (c);
......@@ -476,7 +479,7 @@ secure_zrtp_on_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* c
void * foo UNUSED)
{
DEBUG ("SRTP using ZRTP is ON secure_on_cb");
callable_obj_t * c = calllist_get (current_calls, callID);
callable_obj_t * c = calllist_get_call (current_calls, callID);
if (c) {
c->_srtp_cipher = g_strdup (cipher);
......@@ -490,7 +493,7 @@ static void
secure_zrtp_off_cb (DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED)
{
DEBUG ("SRTP using ZRTP is OFF");
callable_obj_t * c = calllist_get (current_calls, callID);
callable_obj_t * c = calllist_get_call (current_calls, callID);
if (c) {
sflphone_srtp_zrtp_off (c);
......@@ -503,7 +506,7 @@ show_zrtp_sas_cb (DBusGProxy *proxy UNUSED, const gchar* callID, const gchar* sa
const gboolean verified, void * foo UNUSED)
{
DEBUG ("Showing SAS");
callable_obj_t * c = calllist_get (current_calls, callID);
callable_obj_t * c = calllist_get_call (current_calls, callID);
if (c) {
sflphone_srtp_zrtp_show_sas (c, sas, verified);
......@@ -514,7 +517,7 @@ static void
confirm_go_clear_cb (DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED)
{
DEBUG ("Confirm Go Clear request");
callable_obj_t * c = calllist_get (current_calls, callID);
callable_obj_t * c = calllist_get_call (current_calls, callID);
if (c) {
sflphone_confirm_go_clear (c);
......@@ -525,7 +528,7 @@ static void
zrtp_not_supported_cb (DBusGProxy *proxy UNUSED, const gchar* callID, void * foo UNUSED)
{
DEBUG ("ZRTP not supported on the other end");
callable_obj_t * c = calllist_get (current_calls, callID);
callable_obj_t * c = calllist_get_call (current_calls, callID);
if (c) {
sflphone_srtp_zrtp_not_supported (c);
......@@ -538,7 +541,7 @@ sip_call_state_cb (DBusGProxy *proxy UNUSED, const gchar* callID,
const gchar* description, const guint code, void * foo UNUSED)
{
callable_obj_t * c = NULL;
c = calllist_get (current_calls, callID);
c = calllist_get_call (current_calls, callID);
if (c != NULL) {
ERROR("DBUS: Error call is NULL in state changed");
......
......@@ -202,7 +202,7 @@ im_window_add_tab (GtkWidget *widget)
IMWidget *im = IM_WIDGET (widget);