- char *uri=(char *)g_object_get_data(G_OBJECT(friendlist),"from");
- store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist)));
- if (gtk_tree_model_get_iter_first(model,&iter)) {
- do{
- gtk_tree_model_get (model, &iter,FRIEND_ID , &lf, -1);
- if(chat_view!=NULL){
- if(uri !=NULL) {
- if(g_strcmp0(linphone_address_as_string(linphone_friend_get_address(lf)),
- uri)==0){
- gtk_list_store_set(store,&iter,FRIEND_CHAT,create_active_chat_picture(),-1);
+ LinphoneChatRoom *cr=NULL;
+ GtkNotebook *notebook=(GtkNotebook *)linphone_gtk_get_widget(w,"viewswitch");
+ char *la_str=linphone_address_as_string(la);
+
+ lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),la_str);
+ if(lf==NULL){
+ cr=linphone_gtk_create_chatroom(la);
+ g_object_set_data(G_OBJECT(friendlist),"from",la_str);
+ if(chat_view==NULL){
+ chat_view=linphone_gtk_init_chatroom(cr,la);
+ g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)chat_view);
+ } else {
+ linphone_gtk_load_chatroom(cr,la,chat_view);
+ }
+ gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,chat_view));
+ linphone_gtk_friend_list_update_chat_picture();
+ g_idle_add((GSourceFunc)grab_focus,linphone_gtk_get_widget(chat_view,"text_entry"));
+ } else {
+ store=GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist)));
+ if (gtk_tree_model_get_iter_first(model,&iter)) {
+ do{
+ const LinphoneAddress *uri;
+ char *lf_str;
+ 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){
+ gtk_tree_model_get (model, &iter,FRIEND_CHATROOM , &cr, -1);
+ if(cr==NULL){
+ cr=linphone_gtk_create_chatroom(uri);
+ gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
+ }
+ g_object_set_data(G_OBJECT(friendlist),"from",linphone_address_as_string(uri));
+ if(chat_view==NULL){
+ chat_view=linphone_gtk_init_chatroom(cr,uri);
+ g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)chat_view);