Commit 2499c3aa authored by Margaux Clerc's avatar Margaux Clerc
Browse files

Automatically adding friends in the address book

Display missed call in recent calls tab
Notification for chat message
parent 6f1ca06a
......@@ -19,7 +19,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphone.h"
static void fill_renderers(GtkTreeView *v){
GtkTreeViewColumn *c;
GtkCellRenderer *r;
......@@ -36,14 +35,16 @@ static void fill_renderers(GtkTreeView *v){
void call_log_selection_changed(GtkTreeView *v){
GtkTreeSelection *select;
GtkTreeIter iter;
GtkTreeModel *model;
GtkTreeModel *model=NULL;
select = gtk_tree_view_get_selection(v);
if (gtk_tree_selection_get_selected (select, &model, &iter)){
GtkTreePath *path=gtk_tree_model_get_path(model,&iter);
gtk_tree_view_collapse_all(v);
gtk_tree_view_expand_row(v,path,TRUE);
gtk_tree_path_free(path);
if (select!=NULL){
if (gtk_tree_selection_get_selected (select, &model, &iter)){
GtkTreePath *path=gtk_tree_model_get_path(model,&iter);
gtk_tree_view_collapse_all(v);
gtk_tree_view_expand_row(v,path,TRUE);
gtk_tree_path_free(path);
}
}
}
......@@ -91,19 +92,18 @@ void linphone_gtk_call_log_add_contact(GtkWidget *w){
static bool_t put_selection_to_uribar(GtkWidget *treeview){
GtkTreeSelection *sel;
sel=gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
if (sel!=NULL){
GtkTreeModel *model=NULL;
GtkTreeIter iter;
if (gtk_tree_selection_get_selected (sel,&model,&iter)){
gpointer pla;
LinphoneAddress *la;
char *tmp;
gtk_tree_model_get(model,&iter,2,&pla,-1);
la=(LinphoneAddress*)pla;
tmp=linphone_address_as_string (la);
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),tmp);
LinphoneAddress *la;
gtk_tree_model_get(model,&iter,2,&la,-1);
tmp=linphone_address_as_string(la);
if(tmp!=NULL)
gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),tmp);
ms_free(tmp);
return TRUE;
}
......@@ -159,7 +159,6 @@ static GtkWidget *linphone_gtk_create_call_log_menu(GtkWidget *call_log){
gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
g_signal_connect_swapped(G_OBJECT(menu_item),"activate",(GCallback)linphone_gtk_call_log_chat_selected,call_log);
}
menu_item=gtk_image_menu_item_new_from_stock(GTK_STOCK_ADD,NULL);
gtk_widget_show(menu_item);
gtk_menu_shell_append(GTK_MENU_SHELL(menu),menu_item);
......@@ -186,25 +185,74 @@ gboolean linphone_gtk_call_log_button_pressed(GtkWidget *widget, GdkEventButton
return FALSE;
}
void linphone_gtk_call_log_clear_missed_call(){
GtkWidget *mw=linphone_gtk_get_main_window();
GtkNotebook *notebook=GTK_NOTEBOOK(linphone_gtk_get_widget(mw,"viewswitch"));
GtkWidget *page=gtk_notebook_get_nth_page(notebook,0);
GtkWidget *box=gtk_hbox_new(FALSE,0);
GtkWidget *image=gtk_image_new_from_stock(GTK_STOCK_REFRESH,GTK_ICON_SIZE_MENU);
GtkWidget *l;
l=gtk_label_new("Recent calls");
gtk_box_pack_start(GTK_BOX(box),image,FALSE,FALSE,0);
gtk_box_pack_start(GTK_BOX(box),l,FALSE,FALSE,0);
gtk_notebook_set_tab_label(notebook,page,box);
gtk_widget_show_all(box);
}
gboolean linphone_gtk_call_log_reset_missed_call(GtkWidget *w, GdkEvent *event,gpointer user_data){
linphone_core_reset_missed_calls_count(linphone_gtk_get_core());
linphone_gtk_call_log_clear_missed_call();
return TRUE;
}
void linphone_gtk_call_log_display_missed_call(int nb){
GtkWidget *mw=linphone_gtk_get_main_window();
GtkNotebook *notebook=GTK_NOTEBOOK(linphone_gtk_get_widget(mw,"viewswitch"));
GtkWidget *page=gtk_notebook_get_nth_page(notebook,0);
GtkWidget *ebox=gtk_event_box_new();
GtkWidget *box=gtk_hbox_new(FALSE,0);
GtkWidget *image=gtk_image_new_from_stock(GTK_STOCK_REFRESH,GTK_ICON_SIZE_MENU);
GtkWidget *l;
gchar *buf;
buf=g_markup_printf_escaped(_("<b>Recent calls (%i)</b>"),nb);
l=gtk_label_new(NULL);
gtk_label_set_markup(GTK_LABEL(l),buf);
gtk_box_pack_start(GTK_BOX(box),image,FALSE,FALSE,0);
gtk_box_pack_start(GTK_BOX(box),l,FALSE,FALSE,0);
gtk_container_add(GTK_CONTAINER(ebox),box);
gtk_notebook_set_tab_label(notebook,page,ebox);
gtk_widget_add_events(ebox,GDK_BUTTON_PRESS_MASK);
g_signal_connect(G_OBJECT(ebox),"button_press_event",(GCallback)linphone_gtk_call_log_reset_missed_call,NULL);
gtk_widget_show_all(ebox);
}
void linphone_gtk_call_log_update(GtkWidget *w){
GtkTreeView *v=GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view"));
GtkTreeStore *store;
const MSList *logs;
GtkTreeSelection *select;
GtkWidget *notebook=linphone_gtk_get_widget(w,"viewswitch");
gint nb;
store=(GtkTreeStore*)gtk_tree_view_get_model(v);
if (store==NULL){
store=gtk_tree_store_new(3,GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_POINTER);
store=gtk_tree_store_new(3,GDK_TYPE_PIXBUF,G_TYPE_STRING,G_TYPE_POINTER,G_TYPE_STRING);
gtk_tree_view_set_model(v,GTK_TREE_MODEL(store));
g_object_unref(G_OBJECT(store));
fill_renderers(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"logs_view")));
select=gtk_tree_view_get_selection(v);
gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
g_signal_connect_swapped(G_OBJECT(select),"changed",(GCallback)call_log_selection_changed,v);
g_signal_connect(G_OBJECT(notebook),"focus-tab",(GCallback)linphone_gtk_call_log_reset_missed_call,NULL);
g_signal_connect(G_OBJECT(v),"button-press-event",(GCallback)linphone_gtk_call_log_button_pressed,NULL);
// gtk_button_set_image(GTK_BUTTON(linphone_gtk_get_widget(w,"call_back_button")),
// create_pixmap (linphone_gtk_get_ui_config("callback_button","status-green.png")));
}
nb=linphone_core_get_missed_calls_count(linphone_gtk_get_core());
if(nb > 0)
linphone_gtk_call_log_display_missed_call(nb);
gtk_tree_store_clear (store);
for (logs=linphone_core_get_call_logs(linphone_gtk_get_core());logs!=NULL;logs=logs->next){
......@@ -237,7 +285,6 @@ void linphone_gtk_call_log_update(GtkWidget *w){
} else {
display=linphone_address_get_display_name(la);
}
if (display==NULL){
display=linphone_address_get_username (la);
if (display==NULL){
......@@ -294,7 +341,6 @@ void linphone_gtk_call_log_update(GtkWidget *w){
g_free(logtxt);
g_free(headtxt);
}
}
void linphone_gtk_history_row_activated(GtkWidget *treeview){
......
......@@ -61,10 +61,9 @@ void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
GtkWidget *nb=linphone_gtk_get_widget(main_window,"viewswitch");
GtkWidget *friendlist=linphone_gtk_get_widget(main_window,"contact_list");
GtkWidget *w=g_object_get_data(G_OBJECT(friendlist),"chatview");
int idx = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"idx"));
g_return_if_fail(w!=NULL);
gtk_notebook_remove_page(GTK_NOTEBOOK(nb),idx);
gtk_notebook_remove_page(GTK_NOTEBOOK(nb),gtk_notebook_page_num(GTK_NOTEBOOK(nb),w));
linphone_gtk_create_chat_picture(FALSE);
g_object_set_data(G_OBJECT(friendlist),"chatview",NULL);
g_object_set_data(G_OBJECT(w),"from_message",NULL);
......@@ -74,7 +73,8 @@ void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
}
const char* get_display_name(const LinphoneAddress *from){
const char *display=linphone_address_get_display_name(from);
const char *display;
display=linphone_address_get_display_name(from);
if (display==NULL || display[0]=='\0') {
display=linphone_address_get_username(from);
}
......@@ -92,7 +92,7 @@ GtkWidget *create_tab_chat_header(LinphoneChatRoom *cr,const LinphoneAddress *ur
gtk_button_set_relief(GTK_BUTTON(b),GTK_RELIEF_NONE);
gtk_widget_set_size_request(b,25,20);
g_signal_connect_swapped(G_OBJECT(b),"clicked",G_CALLBACK(linphone_gtk_quit_chatroom),cr);
l=gtk_label_new (get_display_name(uri));
l=gtk_label_new(get_display_name(uri));
gtk_box_pack_start (GTK_BOX(w),i,FALSE,FALSE,0);
gtk_box_pack_start (GTK_BOX(w),l,FALSE,FALSE,0);
gtk_box_pack_end(GTK_BOX(w),b,TRUE,TRUE,0);
......@@ -131,7 +131,12 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
char *from_message=(char *)g_object_get_data(G_OBJECT(w),"from_message");
GList *list=g_object_get_data(G_OBJECT(w),"list");
time_t t;
char buf[80];
time_t tnow;
struct tm *tm;
int tnow_day;
int tnow_year;
gtk_text_buffer_get_start_iter(buffer,&begin);
gtk_text_buffer_get_end_iter(buffer,&iter);
off=gtk_text_iter_get_offset(&iter);
......@@ -162,15 +167,22 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
}
case LinphoneChatMessageStateDelivered:
{
struct tm *tm=localtime(&t);
char buf[80];
tnow=time(NULL);
tm=gmtime(&tnow);
tnow_day=tm->tm_yday;
tnow_year=tm->tm_year;
tm=gmtime(&t);
if(tnow_day != tm->tm_yday || (tnow_day == tm->tm_yday && tnow_year != tm->tm_year)) {
strftime(buf,80,"%a %x, %H:%M",tm);
} else {
strftime(buf,80,"%H:%M",tm);
gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,buf,-1,
"right","small","italic","font_grey",me ? "bg":NULL,NULL);
break;
}
gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,buf,-1,
"right","small","italic","font_grey",me ? "bg":NULL,NULL);
break;
}
case LinphoneChatMessageStateNotDelivered:
gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,"Error",-1,
gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,"Message not sent",-1,
"right","small","italic","font_grey",me ? "bg":NULL,NULL);
break;
default : gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,"Sending ..",-1,
......@@ -202,6 +214,7 @@ void update_chat_state_message(LinphoneChatMessageState state,LinphoneChatMessag
GtkTextIter iter;
GtkTextIter end;
GtkTextIter start;
gchar *result;
gtk_text_buffer_get_iter_at_line(b,&iter,
GPOINTER_TO_INT(g_list_nth_data(list,0)));
......@@ -217,7 +230,6 @@ void update_chat_state_message(LinphoneChatMessageState state,LinphoneChatMessag
GPOINTER_TO_INT(g_list_nth_data(list,0)),0);
gtk_text_buffer_delete(b,&start,&end);
gtk_text_buffer_get_iter_at_line(b,&iter,GPOINTER_TO_INT(g_list_nth_data(list,0)));
gchar *result;
switch (state) {
case LinphoneChatMessageStateInProgress:
result="Sending ";
......@@ -295,6 +307,29 @@ void display_history_message(GtkWidget *chat_view,MSList *messages,const Linphon
}
}
void linphone_gtk_chat_add_contact(const LinphoneAddress *addr){
//LinphoneAddress *addr=(LinphoneAddress *)data;
LinphoneFriend *lf=NULL;
char *uri=linphone_address_as_string(addr);
lf=linphone_friend_new_with_addr(uri);
ms_free(uri);
char *fixed_uri=NULL;
gboolean show_presence=FALSE;
linphone_friend_set_inc_subscribe_policy(lf,LinphoneSPDeny);
linphone_friend_send_subscribe(lf,show_presence);
linphone_core_interpret_friend_uri(linphone_gtk_get_core(),uri,&fixed_uri);
if (fixed_uri==NULL){
linphone_gtk_display_something(GTK_MESSAGE_WARNING,_("Invalid sip contact !"));
return ;
}
linphone_friend_set_addr(lf,addr);
linphone_core_add_friend(linphone_gtk_get_core(),lf);
ms_free(fixed_uri);
linphone_gtk_show_friends();
}
GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddress *with){
GtkWidget *chat_view=linphone_gtk_create_widget("main","chatroom_frame");
GtkWidget *main_window=linphone_gtk_get_main_window ();
......@@ -312,7 +347,6 @@ GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddres
color.red = 32512;
color.green = 32512;
color.blue = 32512;
colorb.red = 56832;
colorb.green = 60928;
colorb.blue = 61952;
......@@ -321,12 +355,12 @@ GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddres
linphone_chat_room_mark_as_read(cr);
gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text),GTK_WRAP_WORD_CHAR);
gtk_text_view_set_editable(GTK_TEXT_VIEW(text),FALSE);
gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text),FALSE);
gtk_notebook_append_page(notebook,chat_view,create_tab_chat_header(cr,with));
idx = gtk_notebook_page_num(notebook, chat_view);
gtk_notebook_set_current_page(notebook, idx);
gtk_widget_show(chat_view);
g_object_set_data(G_OBJECT(chat_view),"cr",cr);
g_object_set_data(G_OBJECT(chat_view),"idx",GINT_TO_POINTER(idx));
g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
g_object_set_data(G_OBJECT(chat_view),"list",list);
gtk_text_buffer_create_tag(gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)),
......@@ -369,18 +403,25 @@ void linphone_gtk_load_chatroom(LinphoneChatRoom *cr,const LinphoneAddress *uri,
char *uri_str=linphone_address_as_string(uri);
char *uri_only=linphone_address_as_string_uri_only(uri);
MSList *messages=NULL;
linphone_chat_room_mark_as_read(cr);
if(g_strcmp0(from_str,uri_only)!=0){
GtkTextView *text_view=GTK_TEXT_VIEW(linphone_gtk_get_widget(chat_view,"textview"));
GtkTextIter start;
GtkTextIter end;
GtkTextBuffer *text_buffer;
GtkWidget *cb;
text_buffer=gtk_text_view_get_buffer(text_view);
gtk_text_buffer_get_bounds(text_buffer, &start, &end);
gtk_text_buffer_delete (text_buffer, &start, &end);
udpate_tab_chat_header(chat_view,uri,cr);
cb=linphone_gtk_get_widget(chat_view,"contact_bar");
if(!linphone_gtk_friend_list_is_contact(uri)){
gtk_widget_show(cb);
} else {
gtk_widget_hide(cb);
}
g_object_set_data(G_OBJECT(chat_view),"cr",cr);
g_object_set_data(G_OBJECT(linphone_gtk_get_widget(main_window,"contact_list")),"chatview",(gpointer)chat_view);
messages=linphone_chat_room_get_history(cr,NB_MSG_HIST);
......@@ -389,6 +430,7 @@ void linphone_gtk_load_chatroom(LinphoneChatRoom *cr,const LinphoneAddress *uri,
}
ms_free(from_str);
ms_free(uri_str);
ms_free(uri_only);
}
void linphone_gtk_chat_destroyed(GtkWidget *w){
......@@ -408,18 +450,27 @@ void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room,
GtkWidget *friendlist=linphone_gtk_get_widget(main_window,"contact_list");
GtkWidget *w;
gboolean send=TRUE;
GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(main_window,"viewswitch");
char *from=linphone_address_as_string(linphone_chat_message_get_from(msg));
w=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
if(w!=NULL){
char *from_chatview=(char *)g_object_get_data(G_OBJECT(friendlist),"from");
if(g_strcmp0(from,from_chatview)==0){
send=TRUE;
} else {
if(!linphone_gtk_friend_list_is_contact(linphone_chat_message_get_from(msg))){
//linphone_gtk_load_chatroom(room,linphone_chat_message_get_from(msg),w);
linphone_gtk_chat_add_contact(linphone_chat_message_get_from(msg));
}
send=FALSE;
}
} else {
send=FALSE;
if(!linphone_gtk_friend_list_is_contact(linphone_chat_message_get_from(msg))){
//linphone_gtk_load_chatroom(room,linphone_chat_message_get_from(msg),w);
linphone_gtk_chat_add_contact(linphone_chat_message_get_from(msg));
}
w=linphone_gtk_init_chatroom(room,linphone_chat_message_get_from(msg));
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)w);
g_object_set_data(G_OBJECT(friendlist),"from",from);
......@@ -439,14 +490,13 @@ void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room,
}
#endif
if(send){
linphone_chat_room_mark_as_read(room);
if(gtk_notebook_get_current_page(notebook)!=gtk_notebook_page_num(notebook,w)){
linphone_gtk_show_friends();
}
linphone_gtk_push_text(w,linphone_chat_message_get_from(msg),
FALSE,room,msg,FALSE);
} else {
linphone_gtk_show_friends();
//linphone_gtk_friend_list_update_message(msg);
}
//linphone_gtk_update_chat_picture();
//gtk_window_present(GTK_WINDOW(w));
/*gtk_window_set_urgency_hint(GTK_WINDOW(w),TRUE);*/
//linphone_gtk_update_chat_picture();
}
......@@ -32,7 +32,6 @@ enum{
FRIEND_ICON,
FRIEND_CALL,
FRIEND_CHAT,
FRIEND_NB_UNREAD_MSG,
FRIEND_LIST_NCOL
};
......@@ -76,17 +75,23 @@ static GdkPixbuf *create_call_picture(){
return pixbuf;
}
static GdkPixbuf *create_unread_msg(){
GdkPixbuf *pixbuf;
pixbuf = create_pixbuf("active_chat.png");
return pixbuf;
}
static GdkPixbuf *create_chat_picture(){
GdkPixbuf *pixbuf;
pixbuf = create_pixbuf("chat.png");
return pixbuf;
}
static GdkPixbuf *create_active_chat_picture(){
/*static GdkPixbuf *create_active_chat_picture(){
GdkPixbuf *pixbuf;
pixbuf = create_pixbuf("active_chat.png");
return pixbuf;
}
}*/
/*
void linphone_gtk_set_friend_status(GtkWidget *friendlist , LinphoneFriend * fid, const gchar *url, const gchar *status, const gchar *img){
GtkTreeIter iter;
......@@ -110,6 +115,16 @@ void linphone_gtk_set_friend_status(GtkWidget *friendlist , LinphoneFriend * fid
}
}
*/
gboolean linphone_gtk_friend_list_is_contact(const LinphoneAddress *addr){
LinphoneFriend *lf;
char *addr_str=linphone_address_as_string(addr);
lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),addr_str);
if(lf == NULL){
return FALSE;
} return TRUE;
}
static void linphone_gtk_set_selection_to_uri_bar(GtkTreeView *treeview){
GtkTreeSelection *select;
GtkTreeIter iter;
......@@ -156,28 +171,51 @@ void linphone_gtk_remove_contact(GtkWidget *button){
GtkTreeIter iter;
GtkTreeModel *model;
LinphoneFriend *lf=NULL;
LinphoneChatRoom *cr=NULL;
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"contact_list")));
if (gtk_tree_selection_get_selected (select, &model, &iter))
{
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
linphone_core_remove_friend(linphone_gtk_get_core(),lf);
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
linphone_chat_room_delete_history(cr);
linphone_gtk_show_friends();
}
}
void linphone_gtk_delete_history(GtkWidget *button){
GtkWidget *w=gtk_widget_get_toplevel(button);
GtkWidget *w=linphone_gtk_get_main_window();
GtkTreeSelection *select;
GtkTreeIter iter;
GtkTreeModel *model;
GtkWidget *chat_view;
LinphoneFriend *lf=NULL;
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"contact_list")));
GtkWidget *friendlist;
friendlist=linphone_gtk_get_widget(w,"contact_list");
chat_view=(GtkWidget *)g_object_get_data(G_OBJECT(friendlist),"chatview");
select = gtk_tree_view_get_selection(GTK_TREE_VIEW(friendlist));
if (gtk_tree_selection_get_selected (select, &model, &iter))
{
LinphoneChatRoom *cr;
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
cr=linphone_core_get_chat_room(linphone_gtk_get_core(),linphone_friend_get_address(lf));
gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
linphone_chat_room_delete_history(cr);
if(chat_view!=NULL){
char *from=g_object_get_data(G_OBJECT(friendlist),"from");
char *addr=linphone_address_as_string(linphone_friend_get_address(lf));
if(g_strcmp0(from,addr)==0){
GtkTextView *text_view=GTK_TEXT_VIEW(linphone_gtk_get_widget(chat_view,"textview"));
GtkTextIter start;
GtkTextIter end;
GtkTextBuffer *text_buffer;
text_buffer=gtk_text_view_get_buffer(text_view);
gtk_text_buffer_get_bounds(text_buffer, &start, &end);
gtk_text_buffer_delete (text_buffer, &start, &end);
g_object_set_data(G_OBJECT(chat_view),"from_message",NULL);
}
}
linphone_gtk_show_friends();
}
}
......@@ -209,7 +247,7 @@ static gboolean grab_focus(GtkWidget *w){
return FALSE;
}
void linphone_gtk_tree_view_set_chat_conversation(LinphoneAddress *la){
void linphone_gtk_tree_view_set_chat_conversation(const LinphoneAddress *la){
GtkTreeIter iter;
GtkListStore *store=NULL;
GtkWidget *w = linphone_gtk_get_main_window();
......@@ -240,7 +278,7 @@ void linphone_gtk_tree_view_set_chat_conversation(LinphoneAddress *la){
do{
const LinphoneAddress *uri;
char *lf_str;
gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
gtk_tree_model_get(model, &iter,FRIEND_ID , &lf, -1);
uri=linphone_friend_get_address(lf);
lf_str=linphone_address_as_string(uri);
if( g_strcmp0(lf_str,la_str)==0){
......@@ -259,14 +297,30 @@ void linphone_gtk_tree_view_set_chat_conversation(LinphoneAddress *la){
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,chat_view));
linphone_gtk_create_chat_picture(FALSE);
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(chat_view,"text_entry"));
gtk_list_store_set(store,&iter,FRIEND_CHAT,create_active_chat_picture(),-1);
gtk_list_store_set(store,&iter,FRIEND_NB_UNREAD_MSG,"",-1);
break;
}
}while(gtk_tree_model_iter_next(model,&iter));
}
}
}
void linphone_gtk_notebook_tab_select(GtkNotebook *notebook,GtkWidget *page,guint page_num, gpointer data){
GtkWidget *w=linphone_gtk_get_main_window();
GtkWidget *friendlist=linphone_gtk_get_widget(w,"contact_list");
GtkWidget *chat_view;
LinphoneChatRoom *cr=NULL;
const LinphoneAddress *addr=(const LinphoneAddress *)data;
chat_view=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
if(page != NULL){
notebook=(GtkNotebook *)linphone_gtk_get_widget(w,"viewswitch");
if(gtk_notebook_page_num(notebook,page)==gtk_notebook_page_num(notebook,chat_view)){
cr=linphone_core_get_chat_room(linphone_gtk_get_core(),addr);
if(cr!=NULL){
linphone_chat_room_mark_as_read(cr);
linphone_gtk_show_friends();
}
}
}
}
void linphone_gtk_chat_selected(GtkWidget *item){
......@@ -303,8 +357,7 @@ void linphone_gtk_chat_selected(GtkWidget *item){
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,page));
linphone_gtk_create_chat_picture(FALSE);
g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(page,"text_entry"));
gtk_list_store_set(store,&iter,FRIEND_CHAT,create_active_chat_picture(),-1);
gtk_list_store_set(store,&iter,FRIEND_NB_UNREAD_MSG,"",-1);
g_signal_connect(G_OBJECT(notebook),"switch_page",(GCallback)linphone_gtk_notebook_tab_select,(gpointer)uri);
}
}
......@@ -577,8 +630,7 @@ static void linphone_gtk_friend_list_init(GtkWidget *friendlist){
linphone_gtk_init_bookmark_icon();
store = gtk_list_store_new(FRIEND_LIST_NCOL,GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER,
G_TYPE_POINTER, G_TYPE_STRING, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF,
G_TYPE_STRING, G_TYPE_STRING);
G_TYPE_POINTER, G_TYPE_STRING, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF, GDK_TYPE_PIXBUF);
gtk_tree_view_set_model(GTK_TREE_VIEW(friendlist),GTK_TREE_MODEL(store));
g_object_unref(G_OBJECT(store));
......@@ -588,7 +640,7 @@ static void linphone_gtk_friend_list_init(GtkWidget *friendlist){
gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(friendlist),friend_search_func,NULL,NULL);
gtk_tree_view_set_search_column(GTK_TREE_VIEW(friendlist),FRIEND_NAME);
gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(store),FRIEND_NAME,friend_sort,NULL,NULL);
/*Name and presence column*/
renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes (_("Presence status"),
......@@ -599,6 +651,7 @@ static void linphone_gtk_friend_list_init(GtkWidget *friendlist){
g_signal_connect_swapped(G_OBJECT(column),"clicked",(GCallback)on_presence_column_clicked,GTK_TREE_MODEL(store));
gtk_tree_view_column_set_clickable(column,TRUE);
gtk_tree_view_column_set_visible(column,linphone_gtk_get_ui_config_int("friendlist_status",1));
gtk_tree_view_column_set_min_width(column,50);
renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_pack_start(column,renderer,TRUE);
......@@ -616,11 +669,6 @@ static void linphone_gtk_friend_list_init(GtkWidget *friendlist){
gtk_tree_view_column_set_clickable(column,TRUE);
gtk_tree_view_column_set_expand(column,TRUE);
gtk_tree_view_column_set_max_width(column,60);
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start(column,renderer,TRUE);
gtk_tree_view_column_add_attribute (column,renderer,"text",FRIEND_NB_UNREAD_MSG);
gtk_tree_view_append_column (GTK_TREE_VIEW (friendlist), column);
/* Call column*/
......@@ -641,7 +689,7 @@ static void linphone_gtk_friend_list_init(GtkWidget *friendlist){
gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(friendlist),FRIEND_SIP_ADDRESS);
#endif
gtk_widget_set_size_request(friendlist,200,100);
gtk_widget_set_size_request(friendlist,200,120);
/*gtk_combo_box_set_active(GTK_COMBO_BOX(linphone_gtk_get_widget(
gtk_widget_get_toplevel(friendlist),"show_category")),0);*/
}
......@@ -713,7 +761,6 @@ void linphone_gtk_show_friends(void){
LinphoneChatRoom *cr=NULL;
linphone_gtk_show_directory_search();
if (gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist))==NULL){
linphone_gtk_friend_list_init(friendlist);
}
......@@ -735,7 +782,7 @@ void linphone_gtk_show_friends(void){
const char *name=linphone_address_get_display_name(f_uri);
const char *display=name;
char *escaped=NULL;
char buf[26]={0};
//char buf[26]={0};
int nbmsg=0;
/*if (lookup){
......@@ -752,26 +799,13 @@ void linphone_gtk_show_friends(void){
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,FRIEND_NAME, display,FRIEND_ID,lf,
FRIEND_PRESENCE_IMG, send_subscribe ? create_status_picture(linphone_friend_get_status(lf)) : NULL,
-1);
gtk_tree_model_get(gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist)),&iter,FRIEND_CHATROOM,&cr,-1);
if(cr!=NULL){
nbmsg=linphone_chat_room_get_unread_messages_count(cr);
if(nbmsg != 0){
sprintf(buf,"%i",nbmsg);
}
} else {
cr=linphone_gtk_create_chatroom(f_uri);
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);