void display_history_message(GtkWidget *chat_view,MSList *messages,const LinphoneAddress *with){ if(messages != NULL){ MSList *it; char *from_str; char *with_str; gchar *tmp; for(it=messages;it!=NULL;it=it->next){ LinphoneChatMessage *msg=(LinphoneChatMessage *)it->data; from_str=linphone_address_as_string_uri_only(linphone_chat_message_get_from(msg)); with_str=linphone_address_as_string_uri_only(with); linphone_gtk_push_text(chat_view,strcmp(from_str,with_str)==0? with : linphone_chat_message_get_from(msg), strcmp(from_str,with_str)==0? FALSE : TRUE, linphone_chat_message_get_chat_room(msg),msg,TRUE); } tmp=g_object_get_data(G_OBJECT(chat_view),"from_message"); if (tmp){ g_object_set_data(G_OBJECT(chat_view),"from_message",NULL); g_free(tmp); } ms_free(from_str); ms_free(with_str); linphone_gtk_free_list(messages); } }
void linphone_gtk_text_received ( LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg ) { GtkWidget *main_window=linphone_gtk_get_main_window(); 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" );*/ const LinphoneAddress *from= linphone_chat_message_get_from ( msg ); w= ( GtkWidget* ) g_object_get_data ( G_OBJECT ( friendlist ),"chatview" ); if ( w!=NULL ) { /* Chat window opened */ 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 ) ) ) { linphone_gtk_chat_add_contact ( linphone_chat_message_get_from ( msg ) ); } send=FALSE; } } else { /* Chat window closed */ #ifdef MSG_STORAGE_ENABLED send=FALSE; #else send=TRUE; #endif if ( !linphone_gtk_friend_list_is_contact ( linphone_chat_message_get_from ( msg ) ) ) { 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 ); linphone_gtk_friend_list_set_active_address(from); } #ifdef HAVE_GTK_OSX /* Notified when a new message is sent */ linphone_gtk_status_icon_set_blinking ( TRUE ); #else if ( !gtk_window_is_active ( GTK_WINDOW ( main_window ) ) ) { if ( !GPOINTER_TO_INT ( g_object_get_data ( G_OBJECT ( w ),"is_notified" ) ) ) { linphone_gtk_notify ( NULL,linphone_chat_message_get_text ( msg ) ); g_object_set_data ( G_OBJECT ( w ),"is_notified",GINT_TO_POINTER ( TRUE ) ); } else { g_object_set_data ( G_OBJECT ( w ),"is_notified",GINT_TO_POINTER ( FALSE ) ); } } #endif if ( send ) { linphone_gtk_push_text ( w,linphone_chat_message_get_from ( msg ), FALSE,room,msg,FALSE ); } linphone_core_play_local(lc,linphone_gtk_get_sound_path("incoming_chat.wav")); linphone_gtk_show_friends(); }
void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message){ GtkWidget *w=(GtkWidget*)linphone_chat_room_get_user_data(room); if (w==NULL){ w=linphone_gtk_init_chatroom(room,linphone_address_as_string_uri_only(from)); } linphone_gtk_push_text(GTK_TEXT_VIEW(linphone_gtk_get_widget(w,"textlog")), linphone_address_as_string_uri_only(from), message,FALSE); gtk_window_present(GTK_WINDOW(w)); /*gtk_window_set_urgency_hint(GTK_WINDOW(w),TRUE);*/ }
void linphone_gtk_send_text(GtkWidget *button){ GtkWidget *w=gtk_widget_get_toplevel(button); GtkWidget *entry=linphone_gtk_get_widget(w,"text_entry"); LinphoneChatRoom *cr=(LinphoneChatRoom*)g_object_get_data(G_OBJECT(w),"cr"); const gchar *entered; entered=gtk_entry_get_text(GTK_ENTRY(entry)); if (strlen(entered)>0) { linphone_gtk_push_text(GTK_TEXT_VIEW(linphone_gtk_get_widget(w,"textlog")), linphone_gtk_get_used_identity(), entered,TRUE); linphone_chat_room_send_message(cr,entered); gtk_entry_set_text(GTK_ENTRY(entry),""); } }
void linphone_gtk_text_received ( LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *msg ) { GtkWidget *main_window=linphone_gtk_get_main_window(); 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_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_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 ); } #ifdef HAVE_GTK_OSX /* Notified when a new message is sent */ linphone_gtk_status_icon_set_blinking ( TRUE ); #else if ( !gtk_window_is_active ( GTK_WINDOW ( main_window ) ) ) { if ( !GPOINTER_TO_INT ( g_object_get_data ( G_OBJECT ( w ),"is_notified" ) ) ) { linphone_gtk_notify ( NULL,linphone_chat_message_get_text ( msg ) ); g_object_set_data ( G_OBJECT ( w ),"is_notified",GINT_TO_POINTER ( TRUE ) ); } else { g_object_set_data ( G_OBJECT ( w ),"is_notified",GINT_TO_POINTER ( FALSE ) ); } } #endif if ( send ) { linphone_gtk_push_text ( w,linphone_chat_message_get_from ( msg ), FALSE,room,msg,FALSE ); } linphone_gtk_show_friends(); }
void linphone_gtk_send_text() { GtkWidget *main_window=linphone_gtk_get_main_window(); GtkWidget *friendlist=linphone_gtk_get_widget(main_window,"contact_list"); GtkWidget *w=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview"); GtkWidget *entry=linphone_gtk_get_widget(w,"text_entry"); const gchar *entered; LinphoneChatRoom *cr=g_object_get_data(G_OBJECT(w),"cr"); entered=gtk_entry_get_text(GTK_ENTRY(entry)); if (strlen(entered)>0) { LinphoneChatMessage *msg; msg=linphone_chat_room_create_message(cr,entered); linphone_chat_room_send_message2(cr,msg,on_chat_state_changed,NULL); linphone_gtk_push_text(w,linphone_chat_message_get_from(msg), TRUE,cr,msg,FALSE); gtk_entry_set_text(GTK_ENTRY(entry),""); } }
void linphone_gtk_send_text(){ GtkWidget *main_window=linphone_gtk_get_main_window(); GtkWidget *friendlist=linphone_gtk_get_widget(main_window,"contact_list"); GtkWidget *w=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview"); GtkWidget *entry=linphone_gtk_get_widget(w,"text_entry"); const gchar *entered; LinphoneChatRoom *cr=g_object_get_data(G_OBJECT(w),"cr"); entered=gtk_entry_get_text(GTK_ENTRY(entry)); if (strlen(entered)>0) { LinphoneChatMessage *msg; msg=linphone_chat_room_create_message(cr,entered); linphone_chat_room_send_message2(cr,msg,on_chat_state_changed,NULL); linphone_gtk_push_text(w,linphone_chat_message_get_from(msg), TRUE,cr,msg,FALSE); // Disconnect and reconnect the "changed" signal to prevent triggering it when clearing the text entry. g_signal_handlers_disconnect_by_func(G_OBJECT(entry),(GCallback)linphone_gtk_compose_text,NULL); gtk_entry_set_text(GTK_ENTRY(entry),""); g_signal_connect_swapped(G_OBJECT(entry),"changed",(GCallback)linphone_gtk_compose_text,NULL); } }