Commit 65a8471b authored by Alexandre Savard's avatar Alexandre Savard

[#4064] create/delete instant messaging tabs automatically

parent d20daabe
......@@ -52,6 +52,7 @@
#include <linux/if.h>
#include <widget/imwidget.h>
#include <imwindow.h>
GHashTable * ip2ip_profile=NULL;
......@@ -199,8 +200,11 @@ sflphone_hung_up (callable_obj_t * c)
call_remove_all_errors (c);
update_actions();
/* Update the IM interface */
im_widget_update_state (IM_WIDGET (c->_im_widget), FALSE);
// test wether the widget contain 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);
else
im_widget_update_state (IM_WIDGET (c->_im_widget), FALSE);
#if GTK_CHECK_VERSION(2,10,0)
status_tray_icon_blink (FALSE);
......@@ -380,7 +384,13 @@ sflphone_hang_up()
call_remove_all_errors (selectedCall);
selectedCall->_state = CALL_STATE_DIALING;
set_timestamp (&selectedCall->_time_stop);
//if ( (im_window_get_nb_tabs() > 1) && selectedCall->_im_widget &&
// ! (IM_WIDGET (selectedCall->_im_widget)->containText))
// im_window_remove_tab (selectedCall->_im_widget);
//else
im_widget_update_state (IM_WIDGET (selectedCall->_im_widget), FALSE);
break;
case CALL_STATE_FAILURE:
dbus_hang_up (selectedCall);
......@@ -437,10 +447,20 @@ sflphone_pick_up()
switch (selectedCall->_state) {
case CALL_STATE_DIALING:
sflphone_place_call (selectedCall);
// if instant messaging window is visible, create new tab (deleted automatically if not used)
if (im_window_is_visible())
im_widget_display ( (IMWidget **) (&selectedCall->_im_widget), NULL, selectedCall->_callID, NULL);
break;
case CALL_STATE_INCOMING:
selectedCall->_history_state = INCOMING;
calltree_update_call (history, selectedCall, NULL);
// if instant messaging window is visible, create new tab (deleted automatically if not used)
if (im_window_is_visible())
im_widget_display ( (IMWidget **) (&selectedCall->_im_widget), NULL, selectedCall->_callID, NULL);
dbus_accept (selectedCall);
DEBUG ("from sflphone_pick_up : ");
stop_notification();
......
......@@ -138,6 +138,23 @@ im_window_get()
return im_window;
}
gboolean
im_window_is_active ()
{
if (!im_window)
return FALSE;
else
return gtk_window_is_active (im_window);
}
gboolean
im_window_is_visible ()
{
return gtk_widget_get_visible (im_window);
}
void
im_window_show ()
{
......@@ -157,6 +174,15 @@ im_window_add (GtkWidget *widget)
ERROR ("Could not create the main instant messaging window");
}
gint
im_window_get_nb_tabs()
{
if (im_notebook)
return gtk_notebook_get_n_pages (im_notebook);
else
return 0;
}
static void
close_tab_cb (GtkButton *button UNUSED, gpointer userdata)
{
......
......@@ -60,6 +60,12 @@ void im_window_remove_tab (GtkWidget *widget);
void im_window_show ();
gboolean im_window_is_active (void);
gboolean im_window_is_visible (void);
gint im_window_get_nb_tab (void);
/*! @function
@abstract Add a new tab in the notebook. Each tab is an IM Widget
@param The IM widget
......
......@@ -107,6 +107,9 @@ im_widget_add_message (IMWidget *im, const gchar *from, const gchar *message, gi
gchar *script = g_strdup_printf ("add_message('%s', '%s', '%s', '%s');", message_escaped, from, css_class, msgtime);
webkit_web_view_execute_script (WEBKIT_WEB_VIEW (im->web_view), script);
/* Mark it as used */
im->containText = TRUE;
/* Cleanup */
g_free (script);
g_free (message_escaped);
......@@ -275,6 +278,8 @@ im_widget_init (IMWidget *im)
im->js_global = JSContextGetGlobalObject (im->js_context);
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (im->web_view), "file://" DATA_DIR "/webkit/im/im.html");
im->containText = FALSE;
g_signal_connect (G_OBJECT (im->web_frame), "notify", G_CALLBACK (on_frame_loading_done), im);
}
......@@ -437,7 +442,7 @@ call_state_image_widget (call_state_t state)
image = gtk_image_new_from_stock (GTK_STOCK_IM, GTK_ICON_SIZE_LARGE_TOOLBAR);
break;
default:
image = gtk_image_new_from_stock (GTK_STOCK_FAIL, GTK_ICON_SIZE_LARGE_TOOLBAR);
image = gtk_image_new_from_stock (GTK_STOCK_IM, GTK_ICON_SIZE_LARGE_TOOLBAR);
break;
}
......
......@@ -67,6 +67,7 @@ struct _IMWidget {
WebKitWebFrame *web_frame; // Our web frame
JSGlobalContextRef js_context; // The frame's global JS context
JSObjectRef js_global; // The frame's global context JS object
gboolean containText;
};
struct _IMWidgetClass {
......
......@@ -3118,6 +3118,7 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
return;
}
/*
pjsip_hdr *allow_header = NULL;
std::string *allowed_options = NULL;
......@@ -3134,6 +3135,7 @@ void call_on_state_changed (pjsip_inv_session *inv, pjsip_event *e)
if (allowed_options)
delete allowed_options;
*/
// If this is an outgoing INVITE that was created because of
// REFER/transfer, send NOTIFY to transferer.
......
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