mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 03:58:08 +00:00
Add notification message sending and name in the chat tab
This commit is contained in:
parent
5730556ca7
commit
56470e4ddd
3 changed files with 61 additions and 18 deletions
43
gtk/chat.c
43
gtk/chat.c
|
|
@ -31,7 +31,7 @@ void linphone_gtk_quit_chatroom(LinphoneChatRoom *cr) {
|
|||
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);
|
||||
linphone_gtk_update_chat_picture(FALSE);
|
||||
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);
|
||||
g_object_set_data(G_OBJECT(w),"cr",NULL);
|
||||
|
|
@ -98,7 +98,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, const cha
|
|||
int off;
|
||||
gtk_text_buffer_get_end_iter(buffer,&iter);
|
||||
off=gtk_text_iter_get_offset(&iter);
|
||||
//GList *list=g_object_get_data(G_OBJECT(w),"list");
|
||||
GList *list=g_object_get_data(G_OBJECT(w),"list");
|
||||
|
||||
if(g_strcmp0((char *)g_object_get_data(G_OBJECT(w),"from_message"),linphone_address_as_string(from))!=0){
|
||||
gtk_text_buffer_get_iter_at_offset(buffer,&iter,off);
|
||||
|
|
@ -129,7 +129,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, const cha
|
|||
}
|
||||
g_object_set_data(G_OBJECT(linphone_gtk_get_main_window()),"history",hash);
|
||||
|
||||
/*if(me){
|
||||
if(me){
|
||||
gtk_text_buffer_get_end_iter(buffer,&iter);
|
||||
list=g_list_append(list,GINT_TO_POINTER(gtk_text_iter_get_line(&iter)));
|
||||
gtk_text_buffer_insert_with_tags_by_name(buffer,&iter,"Message in progress.. ",-1,
|
||||
|
|
@ -137,7 +137,7 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from, const cha
|
|||
gtk_text_buffer_get_end_iter(buffer,&iter);
|
||||
gtk_text_buffer_insert(buffer,&iter,"\n",-1);
|
||||
g_object_set_data(G_OBJECT(w),"list",list);
|
||||
}*/
|
||||
}
|
||||
|
||||
GtkTextMark *mark=gtk_text_buffer_create_mark(buffer,NULL,&iter,FALSE);
|
||||
gtk_text_view_scroll_mark_onscreen(text,mark);
|
||||
|
|
@ -154,7 +154,7 @@ const LinphoneAddress* linphone_gtk_get_used_identity(){
|
|||
|
||||
/* function in dev for displaying ack*/
|
||||
void update_chat_state_message(LinphoneChatMessageState state){
|
||||
/* GtkWidget *main_window=linphone_gtk_get_main_window();
|
||||
GtkWidget *main_window=linphone_gtk_get_main_window();
|
||||
GtkWidget *friendlist=linphone_gtk_get_widget(main_window,"contact_list");
|
||||
GtkWidget *page=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
|
||||
GList *list=g_object_get_data(G_OBJECT(page),"list");
|
||||
|
|
@ -193,11 +193,17 @@ void update_chat_state_message(LinphoneChatMessageState state){
|
|||
break;
|
||||
default : result="Message in progress.. ";
|
||||
}
|
||||
gtk_text_buffer_insert_with_tags_by_name(b,&iter,result,-1,
|
||||
|
||||
GDateTime *dt=g_date_time_new_now_local();
|
||||
char *time=g_date_time_format(dt,"%k:%M");
|
||||
gchar result2[80];
|
||||
sprintf(result2,"%s %s",result,time);
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name(b,&iter,result2,-1,
|
||||
"italic","right","small","font_grey",NULL);
|
||||
list=g_list_remove(list,g_list_nth_data(list,0));
|
||||
g_object_set_data(G_OBJECT(page),"list",list);
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
static void on_chat_state_changed(LinphoneChatMessage *msg, LinphoneChatMessageState state, void *user_pointer){
|
||||
|
|
@ -247,7 +253,7 @@ GtkWidget* linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddres
|
|||
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),"from_chatroom",linphone_address_as_string_uri_only(with));
|
||||
g_object_set_data(G_OBJECT(chat_view),"from_chatroom",(gpointer) with);
|
||||
|
||||
GList *list=NULL;
|
||||
g_object_set_data(G_OBJECT(chat_view),"list",list);
|
||||
|
|
@ -295,8 +301,8 @@ LinphoneChatRoom * linphone_gtk_create_chatroom(const LinphoneAddress *with){
|
|||
void linphone_gtk_load_chatroom(LinphoneChatRoom *cr,const LinphoneAddress *uri,GtkWidget *chat_view){
|
||||
GtkWidget *main_window=linphone_gtk_get_main_window ();
|
||||
GHashTable *hash=g_object_get_data(G_OBJECT(main_window),"history");
|
||||
if(g_strcmp0((char *)g_object_get_data(G_OBJECT(chat_view),"from_chatroom"),
|
||||
linphone_address_as_string_uri_only(uri))!=0)
|
||||
LinphoneAddress *from=(LinphoneAddress *)g_object_get_data(G_OBJECT(chat_view),"from_chatroom");
|
||||
if(g_strcmp0(linphone_address_as_string(from),linphone_address_as_string(uri))!=0)
|
||||
{
|
||||
GtkTextView *text_view=GTK_TEXT_VIEW(linphone_gtk_get_widget(chat_view,"textview"));
|
||||
GtkTextIter start;
|
||||
|
|
@ -315,7 +321,7 @@ void linphone_gtk_load_chatroom(LinphoneChatRoom *cr,const LinphoneAddress *uri,
|
|||
|
||||
udpate_tab_chat_header(chat_view,uri,cr);
|
||||
g_object_set_data(G_OBJECT(chat_view),"cr",cr);
|
||||
g_object_set_data(G_OBJECT(chat_view),"from_chatroom",linphone_address_as_string_uri_only(uri));
|
||||
g_object_set_data(G_OBJECT(chat_view),"from_chatroom",(gpointer) uri);
|
||||
g_object_set_data(G_OBJECT(chat_view),"from_message",linphone_address_as_string_uri_only(uri));
|
||||
g_object_set_data(G_OBJECT(linphone_gtk_get_widget(main_window,"contact_list")),"chatview",(gpointer)chat_view);
|
||||
}
|
||||
|
|
@ -336,6 +342,8 @@ void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, const
|
|||
GtkWidget *main_window=linphone_gtk_get_main_window();
|
||||
GtkWidget *friendlist=linphone_gtk_get_widget(main_window,"contact_list");
|
||||
GtkWidget *w;
|
||||
GDateTime *dt=g_date_time_new_now_local();
|
||||
char *time=g_date_time_format(dt,"%k:%M");
|
||||
|
||||
w=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
|
||||
if(w!=NULL){
|
||||
|
|
@ -344,14 +352,21 @@ void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, const
|
|||
w=linphone_gtk_init_chatroom(room,from);
|
||||
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)w);
|
||||
}
|
||||
|
||||
const char *display=linphone_address_get_display_name(from);
|
||||
if (display==NULL || display[0]=='\0') {
|
||||
display=linphone_address_get_username(from);
|
||||
}
|
||||
|
||||
#ifdef HAVE_GTK_OSX
|
||||
#ifdef HAVE_GTK_OSXs
|
||||
/* 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,message);
|
||||
gchar result2[80];
|
||||
sprintf(result2,"%s \n %s sent at %s",message,display,time);
|
||||
linphone_gtk_notify(NULL,result2);
|
||||
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));
|
||||
|
|
@ -359,7 +374,7 @@ void linphone_gtk_text_received(LinphoneCore *lc, LinphoneChatRoom *room, const
|
|||
}
|
||||
#endif
|
||||
linphone_gtk_push_text(w,from,message,FALSE,room);
|
||||
//linphone_gtk_update_chat_picture(TRUE);
|
||||
linphone_gtk_update_chat_picture();
|
||||
//gtk_window_present(GTK_WINDOW(w));
|
||||
/*gtk_window_set_urgency_hint(GTK_WINDOW(w),TRUE);*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ static void linphone_gtk_call_selected(GtkTreeView *treeview){
|
|||
"start_call"));
|
||||
}
|
||||
|
||||
void linphone_gtk_update_chat_picture(gboolean active){
|
||||
void linphone_gtk_create_chat_picture(gboolean active){
|
||||
GtkTreeIter iter;
|
||||
GtkWidget *w = linphone_gtk_get_main_window();
|
||||
GtkWidget *friendlist=linphone_gtk_get_widget(w,"contact_list");
|
||||
|
|
@ -187,6 +187,31 @@ void linphone_gtk_update_chat_picture(gboolean active){
|
|||
}
|
||||
}
|
||||
|
||||
void linphone_gtk_update_chat_picture(){
|
||||
GtkTreeIter iter;
|
||||
GtkListStore *store=NULL;
|
||||
GtkWidget *w = linphone_gtk_get_main_window();
|
||||
GtkWidget *friendlist=linphone_gtk_get_widget(w,"contact_list");
|
||||
GtkTreeModel *model=gtk_tree_view_get_model(GTK_TREE_VIEW(friendlist));
|
||||
GtkWidget *chat_view=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
|
||||
LinphoneFriend *lf=NULL;
|
||||
LinphoneAddress *uri=(LinphoneAddress *)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(g_strcmp0(linphone_address_as_string(linphone_friend_get_address(lf)),
|
||||
linphone_address_as_string(uri))==0){
|
||||
gtk_list_store_set(store,&iter,FRIEND_CHAT,create_active_chat_picture(),-1);
|
||||
} else {
|
||||
gtk_list_store_set(store,&iter,FRIEND_CHAT,create_chat_picture(),-1);
|
||||
}
|
||||
}
|
||||
}while(gtk_tree_model_iter_next(model,&iter));
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean grab_focus(GtkWidget *w){
|
||||
gtk_widget_grab_focus(w);
|
||||
return FALSE;
|
||||
|
|
@ -214,6 +239,7 @@ void linphone_gtk_chat_selected(GtkWidget *item){
|
|||
cr=linphone_gtk_create_chatroom(uri);
|
||||
}
|
||||
page=(GtkWidget*)g_object_get_data(G_OBJECT(friendlist),"chatview");
|
||||
g_object_set_data(G_OBJECT(friendlist),"from",(gpointer)uri);
|
||||
if(page==NULL){
|
||||
page=linphone_gtk_init_chatroom(cr,uri);
|
||||
g_object_set_data(G_OBJECT(friendlist),"chatview",(gpointer)page);
|
||||
|
|
@ -221,7 +247,7 @@ void linphone_gtk_chat_selected(GtkWidget *item){
|
|||
linphone_gtk_load_chatroom(cr,uri,page);
|
||||
}
|
||||
gtk_notebook_set_current_page(notebook,gtk_notebook_page_num(notebook,page));
|
||||
linphone_gtk_update_chat_picture(FALSE);
|
||||
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);
|
||||
}
|
||||
|
|
@ -669,6 +695,7 @@ void linphone_gtk_show_friends(void){
|
|||
escaped=g_markup_escape_text(uri,-1);
|
||||
gtk_list_store_set(store,&iter,FRIEND_SIP_ADDRESS,escaped,-1);
|
||||
g_free(escaped);
|
||||
linphone_gtk_update_chat_picture();
|
||||
//bi=linphone_friend_get_info(lf);
|
||||
/*if (bi!=NULL && bi->image_data!=NULL){
|
||||
GdkPixbuf *pbuf=
|
||||
|
|
@ -890,7 +917,7 @@ static gint tree_view_get_cell_from_pos(GtkTreeView *view, guint x, guint y){
|
|||
for (node = columns; node != NULL && col == NULL; node = node->next){
|
||||
GtkTreeViewColumn *checkcol = (GtkTreeViewColumn*) node->data;
|
||||
gtk_tree_view_column_cell_get_size(checkcol,NULL,NULL,NULL,NULL,&height);
|
||||
if (x >= colx && x < (colx + checkcol->width) && y < height*coly){
|
||||
if (x >= colx && x < (colx + checkcol->width) && y < (height+2)*coly){
|
||||
col = checkcol;
|
||||
gint num = get_col_number_from_tree_view_column(col);
|
||||
return num;
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ LinphoneChatRoom *linphone_gtk_start_chat(GtkTreeView* t);
|
|||
void linphone_gtk_load_chatroom(LinphoneChatRoom *cr,const LinphoneAddress *uri,GtkWidget *chat_view);
|
||||
void linphone_gtk_send_text();
|
||||
GtkWidget * linphone_gtk_init_chatroom(LinphoneChatRoom *cr, const LinphoneAddress *with);
|
||||
void linphone_gtk_update_chat_picture(gboolean active);
|
||||
void linphone_gtk_create_chat_picture(gboolean active);
|
||||
void linphone_gtk_update_chat_picture();
|
||||
void linphone_gtk_chat_set_conversation(const LinphoneAddress *uri,gchar *conversation);
|
||||
gchar * linphone_gtk_chat_get_conversation(const LinphoneAddress *uri);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue