Esempio n. 1
0
void linphone_gtk_add_buddy_from_database(GtkWidget *button){
	GtkWidget *w=gtk_widget_get_toplevel(button);
	GtkTreeSelection *select;
	GtkTreeIter iter;
	GtkTreeModel *model;
	select = gtk_tree_view_get_selection(GTK_TREE_VIEW(linphone_gtk_get_widget(w,"search_results")));
	if (gtk_tree_selection_get_selected (select, &model, &iter))
	{
		char *uri;
		char *name;
		char *addr;
		LinphoneFriend *lf;
		int presence=linphone_gtk_get_ui_config_int("use_subscribe_notify",1);
		gtk_tree_model_get (model, &iter,LOOKUP_RESULT_SIP_URI , &uri,LOOKUP_RESULT_NAME, &name, -1);
		addr=g_strdup_printf("%s <%s>",name,uri);

		lf=linphone_friend_new_with_address(addr);
		linphone_friend_set_inc_subscribe_policy(lf,presence ? LinphoneSPAccept : LinphoneSPDeny);
		linphone_friend_send_subscribe(lf,presence);
		linphone_core_add_friend(linphone_gtk_get_core(),lf);
		linphone_gtk_show_friends();
		g_free(addr);
		g_free(uri);
		g_free(name);
	}
}
Esempio n. 2
0
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();
	
}
Esempio n. 3
0
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();

}
Esempio n. 4
0
static void linphone_gtk_chat_add_contact(const LinphoneAddress *addr){
	LinphoneFriend *lf=NULL;
	gboolean show_presence=FALSE;
	char *uri=linphone_address_as_string(addr);

	lf=linphone_friend_new_with_address(uri);
	ms_free(uri);

	linphone_friend_set_inc_subscribe_policy(lf,LinphoneSPWait);
	linphone_friend_send_subscribe(lf,show_presence);

	linphone_friend_set_address(lf,addr);
	linphone_core_add_friend(linphone_gtk_get_core(),lf);
	linphone_gtk_show_friends();
}
Esempio n. 5
0
void linphone_gtk_chat_add_contact(const LinphoneAddress *addr) {
    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();
}