Commit 34950ccb authored by Simon Morlat's avatar Simon Morlat
Browse files

fix problems with chat in GTK interface due to SIP uris not compared properly.

parent b47a1793
......@@ -76,7 +76,7 @@ void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
}
g_hash_table_destroy(table);
g_object_set_data(G_OBJECT(w),"cr",NULL);
g_object_set_data(G_OBJECT(friendlist),"from",NULL);
linphone_gtk_friend_list_set_active_address(NULL);
gtk_widget_destroy(w);
}
......@@ -467,12 +467,12 @@ void linphone_gtk_text_received ( LinphoneCore *lc, LinphoneChatRoom *room,
GtkWidget *w;
gboolean send=TRUE;
/*GtkNotebook *notebook= ( GtkNotebook * ) linphone_gtk_get_widget ( main_window,"viewswitch" );*/
char *from=linphone_address_as_string_uri_only( linphone_chat_message_get_from ( msg ) );
const LinphoneAddress *from= 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 ) {
const LinphoneAddress *from_chatview=linphone_gtk_friend_list_get_active_address();
if (linphone_address_weak_equal(from,from_chatview)) {
send=TRUE;
} else {
if ( !linphone_gtk_friend_list_is_contact ( linphone_chat_message_get_from ( msg ) ) ) {
......@@ -487,7 +487,7 @@ void linphone_gtk_text_received ( LinphoneCore *lc, LinphoneChatRoom *room,
}
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 );
linphone_gtk_friend_list_set_active_address(from);
}
#ifdef HAVE_GTK_OSX
......
......@@ -197,9 +197,9 @@ void linphone_gtk_delete_history(GtkWidget *button){
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){
const LinphoneAddress *from=linphone_gtk_friend_list_get_active_address();
const LinphoneAddress *addr=linphone_friend_get_address(lf);
if(linphone_address_weak_equal(from,addr)){
GtkTextView *text_view=GTK_TEXT_VIEW(linphone_gtk_get_widget(chat_view,"textview"));
GtkTextIter start;
GtkTextIter end;
......@@ -246,6 +246,20 @@ static gboolean grab_focus(GtkWidget *w){
return FALSE;
}
void linphone_gtk_friend_list_set_active_address(const LinphoneAddress *addr){
GtkWidget *w=linphone_gtk_get_main_window();
GtkWidget *friendlist=linphone_gtk_get_widget(w,"contact_list");
LinphoneAddress *old_addr=(LinphoneAddress*)g_object_get_data(G_OBJECT(friendlist),"from");
g_object_set_data(G_OBJECT(friendlist),"from", addr ? linphone_address_clone(addr) : NULL);
if (old_addr) linphone_address_unref(old_addr);
}
const LinphoneAddress *linphone_gtk_friend_list_get_active_address(void){
GtkWidget *w=linphone_gtk_get_main_window();
GtkWidget *friendlist=linphone_gtk_get_widget(w,"contact_list");
return (const LinphoneAddress*)g_object_get_data(G_OBJECT(friendlist),"from");
}
void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la){
GtkTreeIter iter;
GtkListStore *store=NULL;
......@@ -256,12 +270,11 @@ void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la){
LinphoneFriend *lf=NULL;
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);
lf=linphone_core_find_friend(linphone_gtk_get_core(),la);
if(lf==NULL){
cr=linphone_gtk_create_chatroom(la);
g_object_set_data(G_OBJECT(friendlist),"from",la_str);
linphone_gtk_friend_list_set_active_address(la);
if(chat_view==NULL){
chat_view=linphone_gtk_init_chatroom(cr,la);
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)chat_view);
......@@ -276,17 +289,15 @@ void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la){
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){
if (linphone_address_weak_equal(uri,la)){
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));
linphone_gtk_friend_list_set_active_address(uri);
if(chat_view==NULL){
chat_view=linphone_gtk_init_chatroom(cr,uri);
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)chat_view);
......@@ -345,7 +356,7 @@ void linphone_gtk_chat_selected(GtkWidget *item){
gtk_list_store_set(store,&iter,FRIEND_CHATROOM,cr,-1);
}
page=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
g_object_set_data(G_OBJECT(friendlist),"from",linphone_address_as_string(uri));
linphone_gtk_friend_list_set_active_address(uri);
if(page==NULL){
page=linphone_gtk_init_chatroom(cr,uri);
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)page);
......
......@@ -108,6 +108,8 @@ void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, Linpho
void linphone_gtk_friend_list_update_chat_picture();
void linphone_gtk_friend_list_set_chat_conversation(const LinphoneAddress *la);
gboolean linphone_gtk_friend_list_is_contact(const LinphoneAddress *addr);
void linphone_gtk_friend_set_active_address(const LinphoneAddress *addr);
const LinphoneAddress *linphone_gtk_friend_list_get_active_address(void);
void linphone_gtk_notebook_tab_select(GtkNotebook *notebook,GtkWidget *page,guint page_num, gpointer data);
void linphone_gtk_show_friends(void);
void linphone_gtk_show_contact(LinphoneFriend *lf);
......
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