Commit 073f5a28 authored by Alexandre Savard's avatar Alexandre Savard
Browse files

[#2006] Hangup a conference

parent 8dbd5873
......@@ -305,6 +305,16 @@ sflphone_hang_up()
}
void
sflphone_conference_hang_up()
{
conference_obj_t * selectedConf = calltab_get_selected_conf();
if(selectedConf)
dbus_hang_up_conference(selectedConf);
}
void
sflphone_pick_up()
{
......@@ -887,6 +897,19 @@ sflphone_add_conference()
// dbus_join_participant(selected_call, dragged_call);
}
void
sflphone_conference_on_hold()
{
}
void
sflphone_conference_off_hold()
{
}
void
sflphone_rec_call()
{
......
......@@ -21,6 +21,7 @@
#define __CALLLIST_H__
#include <callable_obj.h>
#include <conference_obj.h>
#include <gtk/gtk.h>
/** @file calllist.h
......@@ -35,7 +36,9 @@ typedef struct {
// Calllist vars
GQueue* callQueue;
gint selectedType;
callable_obj_t* selectedCall;
conference_obj_t* selectedConf;
gchar *_name;
} calltab_t;
......
......@@ -32,10 +32,11 @@ calltab_t* calltab_init (gboolean searchbar_type, gchar *name)
ret->store = NULL;
ret->view = NULL;
ret->tree = NULL;
ret->searchbar = NULL;
ret->searchbar = NULL;
ret->callQueue = NULL;
ret->selectedCall = NULL;
ret->_name = g_strdup (name);
ret->selectedConf = NULL;
ret->_name = g_strdup (name);
calltree_create (ret, searchbar_type);
calllist_init(ret);
......@@ -47,16 +48,36 @@ calltab_t* calltab_init (gboolean searchbar_type, gchar *name)
void
calltab_select_call (calltab_t* tab, callable_obj_t * c )
{
tab->selectedCall = c;
tab->selectedType = A_CALL;
tab->selectedCall = c;
}
void
calltab_select_conf (conference_obj_t * c )
{
current_calls->selectedType = A_CONFERENCE;
current_calls->selectedConf = c;
}
gint
calltab_get_selected_type(calltab_t* tab)
{
return tab->selectedType;
}
callable_obj_t *
calltab_get_selected_call (calltab_t* tab)
{
return tab->selectedCall;
}
conference_obj_t*
calltab_get_selected_conf ()
{
return current_calls->selectedConf;
}
void
calltab_create_searchbar (calltab_t* tab)
{
......
......@@ -31,17 +31,28 @@ calltab_t* contacts;
calltab_t* calltab_init (gboolean searchbar_type, gchar *name);
/** Mark a call as selected. There can be only one selected call. This call
* is the currently highlighted one in the list.
* @param c The call */
void
calltab_select_call (calltab_t*, callable_obj_t *);
void
calltab_select_conf (conference_obj_t *);
gint
calltab_get_selected_type(calltab_t* tab);
/** Return the selected call.
* @return The number of the caller */
callable_obj_t *
calltab_get_selected_call (calltab_t*);
conference_obj_t *
calltab_get_selected_conf ();
void
calltab_create_searchbar (calltab_t *);
......
......@@ -32,12 +32,6 @@ GtkCellRenderer *rend;
GtkTreeViewColumn *col;
GtkTreeSelection *sel;
enum
{
A_CALL,
A_CONFERENCE
};
gint dragged_type;
gint selected_type;
......@@ -105,6 +99,8 @@ selected(GtkTreeSelection *sel, void* data UNUSED )
val.g_type = 0;
gtk_tree_model_get_value (model, &iter, 2, &val);
calltab_select_conf((conference_obj_t*) g_value_get_pointer(&val));
selected_conf = (conference_obj_t*)g_value_get_pointer(&val);
selected_call_id = selected_conf->_confID;
......
......@@ -29,6 +29,12 @@
* @brief The GtkTreeView that list calls in the main window.
*/
enum
{
A_CALL,
A_CONFERENCE
};
/**
* Create a new widget calltree
* @return GtkWidget* A new widget
......
......@@ -19,6 +19,10 @@
<method name="hangUp">
<arg type="s" name="callID" direction="in"/>
</method>
<method name="hangUpConference">
<arg type="s" name="confID" direction="in"/>
</method>
<method name="hold">
<arg type="s" name="callID" direction="in"/>
......@@ -146,7 +150,7 @@
<arg type="s" name="confID" direction="in"/>
</method>
<method name="unHoldConference">
<method name="unholdConference">
<arg type="s" name="confID" direction="in"/>
</method>
......
......@@ -501,6 +501,36 @@ dbus_unhold (const callable_obj_t * c)
}
}
void
dbus_hold_conference (const conference_obj_t * c)
{
DEBUG("dbus_hold_conference %s\n", c->_confID);
GError *error = NULL;
org_sflphone_SFLphone_CallManager_hold_conference ( callManagerProxy, c->_confID, &error);
if (error)
{
ERROR ("Failed to call hold() on CallManager: %s",
error->message);
g_error_free (error);
}
}
void
dbus_unhold_conference (const conference_obj_t * c)
{
DEBUG("dbus_unhold_conference %s\n", c->_confID);
GError *error = NULL;
org_sflphone_SFLphone_CallManager_unhold_conference ( callManagerProxy, c->_confID, &error);
if (error)
{
ERROR ("Failed to call unhold() on CallManager: %s",
error->message);
g_error_free (error);
}
}
void
dbus_hang_up (const callable_obj_t * c)
{
......@@ -516,6 +546,22 @@ dbus_hang_up (const callable_obj_t * c)
}
}
void
dbus_hang_up_conference (const conference_obj_t * c)
{
DEBUG("dbus_hang_up_conference %s\n", c->_confID);
GError *error = NULL;
org_sflphone_SFLphone_CallManager_hang_up_conference ( callManagerProxy, c->_confID, &error);
if (error)
{
ERROR ("Failed to call hang_up() on CallManager: %s",
error->message);
g_error_free (error);
}
}
void
dbus_transfert (const callable_obj_t * c)
{
......
......@@ -230,6 +230,26 @@ call_hold (void* foo UNUSED)
}
}
static void
conference_hold (void* foo UNUSED)
{
conference_obj_t * selectedConf = calltab_get_selected_conf();
if(selectedConf)
{
if(selectedConf->_state == CONFERENCE_STATE_HOLD)
{
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( holdMenu ), gtk_image_new_from_file( ICONS_DIR "/icon_unhold.svg"));
sflphone_conference_off_hold();
}
else
{
gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM ( holdMenu ), gtk_image_new_from_file( ICONS_DIR "/icon_hold.svg"));
sflphone_conference_on_hold();
}
}
}
static void
call_pick_up ( void * foo UNUSED)
{
......@@ -242,6 +262,12 @@ call_hang_up ( void * foo UNUSED)
sflphone_hang_up();
}
static void
conference_hang_up ( void * foo UNUSED)
{
sflphone_conference_hang_up();
}
static void
call_record ( void * foo UNUSED)
{
......@@ -689,45 +715,81 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
{
// TODO update the selection to make sure the call under the mouse is the call selected
// call type boolean
gboolean pickup = FALSE, hangup = FALSE, hold = FALSE, copy = FALSE, record = FALSE;
gboolean accounts = FALSE;
callable_obj_t * selectedCall = calltab_get_selected_call(current_calls);
if (selectedCall)
// conference type boolean
gboolean hangup_conf = FALSE, hold_conf = FALSE;
callable_obj_t * selectedCall;
conference_obj_t * selectedConf;
if (calltab_get_selected_type(current_calls) == A_CALL)
{
copy = TRUE;
switch(selectedCall->_state)
{
case CALL_STATE_INCOMING:
pickup = TRUE;
hangup = TRUE;
break;
case CALL_STATE_HOLD:
hangup = TRUE;
hold = TRUE;
break;
case CALL_STATE_RINGING:
hangup = TRUE;
break;
case CALL_STATE_DIALING:
pickup = TRUE;
hangup = TRUE;
accounts = TRUE;
break;
case CALL_STATE_RECORD:
case CALL_STATE_CURRENT:
hangup = TRUE;
hold = TRUE;
record = TRUE;
break;
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
hangup = TRUE;
break;
default:
WARN("Should not happen in show_popup_menu!");
break;
}
DEBUG("MENUS: SELECTED A CALL");
selectedCall = calltab_get_selected_call(current_calls);
if (selectedCall)
{
copy = TRUE;
switch(selectedCall->_state)
{
case CALL_STATE_INCOMING:
pickup = TRUE;
hangup = TRUE;
break;
case CALL_STATE_HOLD:
hangup = TRUE;
hold = TRUE;
break;
case CALL_STATE_RINGING:
hangup = TRUE;
break;
case CALL_STATE_DIALING:
pickup = TRUE;
hangup = TRUE;
accounts = TRUE;
break;
case CALL_STATE_RECORD:
case CALL_STATE_CURRENT:
hangup = TRUE;
hold = TRUE;
record = TRUE;
break;
case CALL_STATE_BUSY:
case CALL_STATE_FAILURE:
hangup = TRUE;
break;
default:
WARN("Should not happen in show_popup_menu for calls!");
break;
}
}
}
else
{
DEBUG("MENUS: SELECTED A CONF");
selectedConf = calltab_get_selected_conf();
if (selectedConf)
{
switch(selectedConf->_state)
{
case CONFERENCE_STATE_ACTIVE:
hangup_conf = TRUE;
hold_conf = TRUE;
break;
case CONFERENCE_STATE_HOLD:
hangup_conf = TRUE;
hold_conf = TRUE;
break;
default:
WARN("Should not happen in show_popup_menu for conferences!");
break;
}
}
}
GtkWidget *menu;
......@@ -738,94 +800,127 @@ show_popup_menu (GtkWidget *my_widget, GdkEventButton *event)
menu = gtk_menu_new ();
//g_signal_connect (menu, "deactivate",
// G_CALLBACK (gtk_widget_destroy), NULL);
if(copy)
{
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_COPY, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (edit_copy),
NULL);
gtk_widget_show (menu_items);
}
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_PASTE, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (edit_paste),
NULL);
gtk_widget_show (menu_items);
if(pickup || hangup || hold)
{
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_widget_show (menu_items);
}
if(pickup)
{
menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Pick up"));
image = gtk_image_new_from_file( ICONS_DIR "/icon_accept.svg");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_pick_up),
NULL);
gtk_widget_show (menu_items);
}
if(hangup)
if (calltab_get_selected_type(current_calls) == A_CALL)
{
menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Hang up"));
image = gtk_image_new_from_file( ICONS_DIR "/icon_hangup.svg");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_hang_up),
NULL);
gtk_widget_show (menu_items);
}
DEBUG("BUILD CALL MENU");
if(copy)
{
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_COPY, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (edit_copy),
NULL);
gtk_widget_show (menu_items);
}
menu_items = gtk_image_menu_item_new_from_stock( GTK_STOCK_PASTE, get_accel_group());
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (edit_paste),
NULL);
gtk_widget_show (menu_items);
if(pickup || hangup || hold)
{
menu_items = gtk_separator_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_widget_show (menu_items);
}
if(pickup)
{
menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Pick up"));
image = gtk_image_new_from_file( ICONS_DIR "/icon_accept.svg");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_pick_up),
NULL);
gtk_widget_show (menu_items);
}
if(hangup)
{
menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Hang up"));
image = gtk_image_new_from_file( ICONS_DIR "/icon_hangup.svg");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_hang_up),
NULL);
gtk_widget_show (menu_items);
}
if(hold)
{
menu_items = gtk_check_menu_item_new_with_mnemonic (_("On _Hold"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items),
(selectedCall->_state == CALL_STATE_HOLD ? TRUE : FALSE));
g_signal_connect(G_OBJECT (menu_items), "activate",
G_CALLBACK (call_hold),
NULL);
gtk_widget_show (menu_items);
}
if(record)
{
menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Record"));
image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_record),
NULL);
gtk_widget_show (menu_items);
}
if(hold)
{
menu_items = gtk_check_menu_item_new_with_mnemonic (_("On _Hold"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items),
(selectedCall->_state == CALL_STATE_HOLD ? TRUE : FALSE));
g_signal_connect(G_OBJECT (menu_items), "activate",
G_CALLBACK (call_hold),
NULL);
gtk_widget_show (menu_items);
}
if(record)
else
{
menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Record"));
image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_RECORD, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (call_record),
NULL);
gtk_widget_show (menu_items);
DEBUG("BUILD CONFERENCE MENU");
if(hangup_conf)
{
menu_items = gtk_image_menu_item_new_with_mnemonic(_("_Hang up"));
image = gtk_image_new_from_file( ICONS_DIR "/icon_hangup.svg");
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_items), image);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
g_signal_connect (G_OBJECT (menu_items), "activate",
G_CALLBACK (conference_hang_up),
NULL);
gtk_widget_show (menu_items);
}
if(hold_conf)
{
menu_items = gtk_check_menu_item_new_with_mnemonic (_("On _Hold"));
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_items);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_items),
(selectedCall->_state == CALL_STATE_HOLD ? TRUE : FALSE));
g_signal_connect(G_OBJECT (menu_items), "activate",
G_CALLBACK (conference_hold),
NULL);
gtk_widget_show (menu_items);
}
}
if(accounts)
{
add_registered_accounts_to_menu (menu);
add_registered_accounts_to_menu (menu);
}
if (event)
{
button = event->button;
event_time = event->time;
button = event->button;
event_time = event->time;
}
else
{
button = 0;
event_time = gtk_get_current_event_time ();
button = 0;
event_time = gtk_get_current_event_time ();
}
gtk_menu_attach_to_widget (GTK_MENU (menu), my_widget, NULL);
......
......@@ -27,6 +27,7 @@ Call::Call (const CallID& id, Call::CallType type)
, _localAudioPort (0)
, _localExternalAudioPort (0)
, _id (id)