Commit 8e7534d1 authored by Alexandre Savard's avatar Alexandre Savard

#6183: Serialize conference participant phone number and account

parent aa60822a
...@@ -337,7 +337,8 @@ gboolean sflphone_init (GError **error) ...@@ -337,7 +337,8 @@ gboolean sflphone_init (GError **error)
account_list_init (); account_list_init ();
codec_capabilities_load (); codec_capabilities_load ();
conferencelist_init (); conferencelist_init (current_calls);
conferencelist_init (history);
// Fetch the configured accounts // Fetch the configured accounts
sflphone_fill_account_list (); sflphone_fill_account_list ();
...@@ -1261,7 +1262,7 @@ void sflphone_fill_conference_list (void) ...@@ -1261,7 +1262,7 @@ void sflphone_fill_conference_list (void)
conf->_confID = g_strdup (conf_id); conf->_confID = g_strdup (conf_id);
conferencelist_add (conf); conferencelist_add (current_calls, conf);
calltree_add_conference (current_calls, conf); calltree_add_conference (current_calls, conf);
} }
} }
...@@ -1336,6 +1337,7 @@ void sflphone_save_history (void) ...@@ -1336,6 +1337,7 @@ void sflphone_save_history (void)
gint size; gint size;
gint i; gint i;
QueueElement *current; QueueElement *current;
conference_obj_t *conf;
GHashTable *result = NULL; GHashTable *result = NULL;
gchar *key, *value; gchar *key, *value;
...@@ -1361,6 +1363,7 @@ void sflphone_save_history (void) ...@@ -1361,6 +1363,7 @@ void sflphone_save_history (void)
else { else {
ERROR("SFLphone: Error: Unknown type for serialization"); ERROR("SFLphone: Error: Unknown type for serialization");
} }
g_hash_table_replace (result, (gpointer) key, (gpointer) value); g_hash_table_replace (result, (gpointer) key, (gpointer) value);
} }
else { else {
...@@ -1368,6 +1371,24 @@ void sflphone_save_history (void) ...@@ -1368,6 +1371,24 @@ void sflphone_save_history (void)
} }
} }
size = conferencelist_get_size(history);
DEBUG("Conference list size %d", size);
while(size > 0) {
conf = conferencelist_pop_head(history);
size = conferencelist_get_size(history);
if(conf) {
DEBUG("Serialize conference");
value = serialize_history_conference_entry(conf);
key = convert_timestamp_to_gchar(conf->_time_start);
}
else {
WARN("SFLphone: Warning: %dth element is NULL", i);
}
g_hash_table_replace(result, (gpointer)key, (gpointer)value);
}
dbus_set_history (result); dbus_set_history (result);
// Decrement the reference count // Decrement the reference count
......
...@@ -28,11 +28,16 @@ ...@@ -28,11 +28,16 @@
* as that of the covered work. * as that of the covered work.
*/ */
#include <callable_obj.h>
#include <sflphone_const.h>
#include <time.h> #include <time.h>
#include "callable_obj.h"
#include "sflphone_const.h"
#include "calltab.h"
#include "calllist.h"
static void set_conference_timestamp (time_t *); static void set_conference_timestamp (time_t *);
static void conference_add_participant_number(const gchar *, conference_obj_t *);
static void set_conference_timestamp (time_t *timestamp) static void set_conference_timestamp (time_t *timestamp)
{ {
...@@ -127,11 +132,25 @@ void conference_add_participant (const gchar* call_id, conference_obj_t* conf) ...@@ -127,11 +132,25 @@ void conference_add_participant (const gchar* call_id, conference_obj_t* conf)
{ {
// store the new participant list after appending participant id // store the new participant list after appending participant id
conf->participant_list = g_slist_append (conf->participant_list, (gpointer) g_strdup(call_id)); conf->participant_list = g_slist_append (conf->participant_list, (gpointer) g_strdup(call_id));
// store the phone number of this participant
conference_add_participant_number(call_id, conf);
} }
static
void conference_add_participant_number(const gchar *call_id, conference_obj_t *conf) void conference_add_participant_number(const gchar *call_id, conference_obj_t *conf)
{ {
conf->participant_number = g_slist_append(conf->participant_number, (gpointer) g_strdup(call_id)); gchar *number_account;
callable_obj_t *call = calllist_get_call(current_calls, call_id);
if(call == NULL) {
ERROR("Conference: Error: Could not find");
return;
}
number_account = g_strconcat(call->_peer_number, ",", call->_accountID, NULL);
conf->participant_number = g_slist_append(conf->participant_number, (gpointer) number_account);
} }
void conference_remove_participant (const gchar* call_id, conference_obj_t* conf) void conference_remove_participant (const gchar* call_id, conference_obj_t* conf)
...@@ -195,7 +214,10 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry) ...@@ -195,7 +214,10 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry)
if(tmp == NULL) { if(tmp == NULL) {
WARN("Conference: Peer number is NULL in conference list"); WARN("Conference: Peer number is NULL in conference list");
} }
g_strconcat(numberstr, tmp, ","); numberstr = g_strconcat(numberstr, tmp, ";", NULL);
DEBUG("Print: %s concat: %s", tmp, numberstr);
} }
result = g_strconcat("2188", separator, result = g_strconcat("2188", separator,
...@@ -207,5 +229,5 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry) ...@@ -207,5 +229,5 @@ gchar *serialize_history_conference_entry(conference_obj_t *entry)
NULL); NULL);
return ""; return result;
} }
...@@ -59,6 +59,7 @@ typedef struct { ...@@ -59,6 +59,7 @@ typedef struct {
// Calllist vars // Calllist vars
GQueue* callQueue; GQueue* callQueue;
GQueue* conferenceQueue;
gint selectedType; gint selectedType;
callable_obj_t* selectedCall; callable_obj_t* selectedCall;
conference_obj_t* selectedConf; conference_obj_t* selectedConf;
......
...@@ -30,10 +30,12 @@ ...@@ -30,10 +30,12 @@
#include <conferencelist.h> #include <conferencelist.h>
#include "logger.h"
static gint is_confID_confstruct(gconstpointer, gconstpointer); static gint is_confID_confstruct(gconstpointer, gconstpointer);
static gchar *generate_conf_id (void);
static static gint is_confID_confstruct (gconstpointer a, gconstpointer b)
gint is_confID_confstruct (gconstpointer a, gconstpointer b)
{ {
conference_obj_t * c = (conference_obj_t*) a; conference_obj_t * c = (conference_obj_t*) a;
...@@ -44,89 +46,154 @@ gint is_confID_confstruct (gconstpointer a, gconstpointer b) ...@@ -44,89 +46,154 @@ gint is_confID_confstruct (gconstpointer a, gconstpointer b)
} }
} }
gchar* static gchar *generate_conf_id (void)
generate_conf_id (void)
{ {
gchar *conf_id; gchar *conf_id;
conf_id = g_new0 (gchar, 30); conf_id = g_new0 (gchar, 30);
g_sprintf (conf_id, "%d", rand()); g_sprintf (conf_id, "%d", rand());
return conf_id; return conf_id;
} }
void void conferencelist_init(calltab_t *tab)
conferencelist_init()
{ {
conferenceQueue = g_queue_new (); if(tab == NULL) {
ERROR("ConferenceList: Error: Call tab is NULL");
return;
}
tab->conferenceQueue = g_queue_new ();
} }
void void conferencelist_clean(calltab_t *tab)
conferencelist_clean()
{ {
g_queue_free (conferenceQueue); if(tab == NULL) {
ERROR("ConferenceList: Error: Calltab tab is NULL");
return;
}
g_queue_free (tab->conferenceQueue);
} }
void void conferencelist_reset(calltab_t *tab)
conferencelist_reset()
{ {
g_queue_free (conferenceQueue); if(tab == NULL) {
conferenceQueue = g_queue_new(); ERROR("ConferenceList: Error: Calltab tab is NULL");
return;
}
g_queue_free (tab->conferenceQueue);
tab->conferenceQueue = g_queue_new();
} }
void void conferencelist_add (calltab_t *tab, const conference_obj_t* conf)
conferencelist_add (const conference_obj_t* conf)
{ {
gchar* c = (gchar*) conferencelist_get (conf->_confID); gchar* c;
if(conf == NULL) {
ERROR("ConferenceList: Error: Conference is NULL");
return;
}
if(tab == NULL) {
ERROR("ConferenceList: Error: Tab is NULL");
return;
}
c = (gchar*) conferencelist_get (tab, conf->_confID);
if (!c) { if (!c) {
g_queue_push_tail (conferenceQueue, (gpointer) conf); // only add conference into the list if not already inserted
g_queue_push_tail (tab->conferenceQueue, (gpointer) conf);
} }
} }
void void conferencelist_remove (calltab_t *tab, const gchar* conf)
conferencelist_remove (const gchar* conf)
{ {
gchar* c = (gchar*) conferencelist_get (conf); gchar* c;
if(conf == NULL) {
ERROR("ConferenceList: Error: Conf id is NULL");
return;
}
if (c) { if(tab == NULL) {
g_queue_remove (conferenceQueue, c); ERROR("ConferenceList: Error: Calltab is NULL");
return;
} }
c = (gchar*) conferencelist_get (tab, conf);
if(c == NULL) {
ERROR("ConferenceList: Error: Could not find conference %s", conf);
return;
}
g_queue_remove (tab->conferenceQueue, c);
} }
conference_obj_t* conference_obj_t* conferencelist_get (calltab_t *tab, const gchar* conf_id)
conferencelist_get (const gchar* conf_id)
{ {
GList* c = g_queue_find_custom (conferenceQueue, conf_id, is_confID_confstruct); GList* c;
if (c) { if(tab == NULL) {
return (conference_obj_t*) c->data; ERROR("ConferenceList: Error: Calltab is NULL");
} else { return;
}
c = g_queue_find_custom (tab->conferenceQueue, conf_id, is_confID_confstruct);
if(c == NULL) {
ERROR("ConferenceList: Error: Could not find conference %s", conf_id);
return NULL; return NULL;
} }
return (conference_obj_t*) c->data;
} }
conference_obj_t* conference_obj_t* conferencelist_get_nth (calltab_t *tab, guint n)
conferencelist_get_nth (guint n)
{ {
GList* c = g_queue_peek_nth (conferenceQueue, n); GList* c;
if (c) { if(tab == NULL) {
return (conference_obj_t*) c->data; ERROR("ConferenceList: Error: Calltab is NULL");
} else { return NULL;
return NULL; }
c = g_queue_peek_nth (tab->conferenceQueue, n);
if(c == NULL) {
ERROR("ConferenceList: Error: Could not fetch conference %d", n);
return NULL;
} }
return (conference_obj_t*) c->data;
} }
conference_obj_t *conferencelist_pop_head(calltab_t *tab)
{
if(tab == NULL) {
ERROR("ConferenceList: Error: Tab is NULL");
return NULL;
}
return g_queue_pop_head(tab->conferenceQueue);
}
guint guint conferencelist_get_size (calltab_t *tab)
conferencelist_get_size ()
{ {
return g_queue_get_length (conferenceQueue); if(tab == NULL) {
ERROR("ConferenceList: Error: Calltab is NULL");
return 0;
}
return g_queue_get_length (tab->conferenceQueue);
} }
...@@ -31,56 +31,59 @@ ...@@ -31,56 +31,59 @@
#ifndef __CONFERENCELIST_H__ #ifndef __CONFERENCELIST_H__
#define __CONFERENCELIST_H__ #define __CONFERENCELIST_H__
#include <conference_obj.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "conference_obj.h"
#include "calllist.h"
/** @file conferencelist.h /** @file conferencelist.h
* @brief A list to store conferences. * @brief A list to store conferences.
*/ */
GQueue* conferenceQueue; // GQueue* conferenceQueue;
/** This function initialize a conference list. */ /** This function initialize a conference list. */
void void
conferencelist_init (); conferencelist_init (calltab_t *);
/** This function empty and free the conference list. */ /** This function empty and free the conference list. */
void void
conferencelist_clean (); conferencelist_clean (calltab_t *);
/** This function empty, free the conference list and allocate a new one. */ /** This function empty, free the conference list and allocate a new one. */
void void
conferencelist_reset (); conferencelist_reset (calltab_t *);
/** This function append a conference to the list. /** This function append a conference to the list.
* @param conf The conference you want to add * @param conf The conference you want to add
* */ * */
void void
conferencelist_add (const conference_obj_t* conf); conferencelist_add (calltab_t *, const conference_obj_t *);
/** This function remove a conference from list. /** This function remove a conference from list.
* @param callID The callID of the conference you want to remove * @param callID The callID of the conference you want to remove
*/ */
void void
conferencelist_remove (const gchar* conf); conferencelist_remove (calltab_t *, const gchar *);
/** Return the number of calls in the list /** Return the number of calls in the list
* @return The number of calls in the list */ * @return The number of calls in the list */
guint guint
conferencelist_get_size (); conferencelist_get_size (calltab_t *);
/** Return the call at the nth position in the list /** Return the call at the nth position in the list
* @param n The position of the call you want * @param n The position of the call you want
* @return A call or NULL */ * @return A call or NULL */
conference_obj_t* conference_obj_t*
conferencelist_get_nth (guint n); conferencelist_get_nth (calltab_t *, guint);
/** Return the call corresponding to the callID /** Return the call corresponding to the callID
* @param n The callID of the call you want * @param n The callID of the call want
* @return A call or NULL */ * @return A call or NULL */
conference_obj_t* conference_obj_t*
conferencelist_get (const gchar* conf); conferencelist_get (calltab_t *, const gchar *);
conference_obj_t*
conferencelist_pop_head(calltab_t *);
#endif #endif
...@@ -167,7 +167,7 @@ incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const ...@@ -167,7 +167,7 @@ incoming_message_cb (DBusGProxy *proxy UNUSED, const gchar* callID UNUSED, const
call = calllist_get_call (current_calls, callID); call = calllist_get_call (current_calls, callID);
// Get the conference information (if this conference exist) // Get the conference information (if this conference exist)
conf = conferencelist_get (callID); conf = conferencelist_get (current_calls, callID);
/* First check if the call is valid */ /* First check if the call is valid */
if (call) { if (call) {
...@@ -275,7 +275,7 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, ...@@ -275,7 +275,7 @@ conference_changed_cb (DBusGProxy *proxy UNUSED, const gchar* confID,
gchar* call_id; gchar* call_id;
// sflphone_display_transfer_status("Transfer successfull"); // sflphone_display_transfer_status("Transfer successfull");
conference_obj_t* changed_conf = conferencelist_get (confID); conference_obj_t* changed_conf = conferencelist_get (current_calls, confID);
GSList * part; GSList * part;
DEBUG ("---------------------------- DBUS: Conference state changed: %s\n", state); DEBUG ("---------------------------- DBUS: Conference state changed: %s\n", state);
...@@ -377,7 +377,8 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo ...@@ -377,7 +377,8 @@ conference_created_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo
set_timestamp(&new_conf->_time_start); set_timestamp(&new_conf->_time_start);
conferencelist_add (new_conf); conferencelist_add (current_calls, new_conf);
conferencelist_add (history, new_conf);
calltree_add_conference (current_calls, new_conf); calltree_add_conference (current_calls, new_conf);
calltree_add_conference (history, new_conf); calltree_add_conference (history, new_conf);
} }
...@@ -387,7 +388,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo ...@@ -387,7 +388,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo
{ {
DEBUG ("DBUS: Conference removed %s", confID); DEBUG ("DBUS: Conference removed %s", confID);
conference_obj_t * c = conferencelist_get (confID); conference_obj_t * c = conferencelist_get (current_calls, confID);
calltree_remove_conference (current_calls, c, NULL); calltree_remove_conference (current_calls, c, NULL);
GSList *participant = c->participant_list; GSList *participant = c->participant_list;
...@@ -418,7 +419,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo ...@@ -418,7 +419,7 @@ conference_removed_cb (DBusGProxy *proxy UNUSED, const gchar* confID, void * foo
participant = conference_next_participant (participant); participant = conference_next_participant (participant);
} }
conferencelist_remove (c->_confID); conferencelist_remove (current_calls, c->_confID);
} }
static void static void
......
...@@ -203,7 +203,7 @@ im_window_add_tab (GtkWidget *widget) ...@@ -203,7 +203,7 @@ im_window_add_tab (GtkWidget *widget)
/* Fetch the call */ /* Fetch the call */
callable_obj_t *im_widget_call = calllist_get_call (current_calls, im->call_id); callable_obj_t *im_widget_call = calllist_get_call (current_calls, im->call_id);
conference_obj_t *im_widget_conf = conferencelist_get (im->call_id); conference_obj_t *im_widget_conf = conferencelist_get (current_calls, im->call_id);