Beispiel #1
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();

}
Beispiel #2
0
/**
 * function invoked to report file transfer progress.
 * */
static void file_transfer_progress_indication(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total) {
	const LinphoneAddress* from_address = linphone_chat_message_get_from(message);
	const LinphoneAddress* to_address = linphone_chat_message_get_to(message);
	char *address = linphone_chat_message_is_outgoing(message)?linphone_address_as_string(to_address):linphone_address_as_string(from_address);
	printf(" File transfer  [%d%%] %s of type [%s/%s] %s [%s] \n", (int)((offset *100)/total)
																	,(linphone_chat_message_is_outgoing(message)?"sent":"received")
																	, linphone_content_get_type(content)
																	, linphone_content_get_subtype(content)
																	,(linphone_chat_message_is_outgoing(message)?"to":"from")
																	, address);
	free(address);
}
Beispiel #3
0
// Called from message_received callback
void SipClient::messageReceivedCb(LinphoneChatMessage *message)
{
	QString url  = QString(linphone_chat_message_get_external_body_url(message));
	QString text = QString(linphone_chat_message_get_text(message));
	QString from = QString(linphone_address_as_string(linphone_chat_message_get_from(message)));

	qDebug() << __PRETTY_FUNCTION__
		 << QDateTime::fromTime_t(linphone_chat_message_get_time(message))
		 << "From:" << from << "Text:" << text << "Url:" << url;

	linphone_chat_message_destroy(message);

	emit messageReceived(from, text, url);
}
Beispiel #4
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();

}
Beispiel #5
0
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),"");
    }
}
Beispiel #6
0
/**
 * function invoked to report file transfer progress.
 * */
void file_transfer_progress_indication(LinphoneChatMessage *message, const LinphoneContent* content, size_t offset, size_t total) {
	LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(message);
	LinphoneCore *lc = linphone_chat_room_get_core(cr);
	const LinphoneAddress* from_address = linphone_chat_message_get_from(message);
	const LinphoneAddress* to_address = linphone_chat_message_get_to(message);
	char *address = linphone_chat_message_is_outgoing(message)?linphone_address_as_string(to_address):linphone_address_as_string(from_address);
	stats* counters = get_stats(lc);
	int progress = (int)((offset * 100)/total);
	ms_message(" File transfer  [%d%%] %s of type [%s/%s] %s [%s] \n", progress
																	,(linphone_chat_message_is_outgoing(message)?"sent":"received")
																	, linphone_content_get_type(content)
																	, linphone_content_get_subtype(content)
																	,(linphone_chat_message_is_outgoing(message)?"to":"from")
																	, address);
	counters->progress_of_LinphoneFileTransfer = progress;
	free(address);
}
Beispiel #7
0
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);
	}
}
Beispiel #8
0
void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage* message) {
	char* from=linphone_address_as_string(linphone_chat_message_get_from(message));
	stats* counters;
	const char *text=linphone_chat_message_get_text(message);
	const char *external_body_url=linphone_chat_message_get_external_body_url(message);
	ms_message("Message from [%s]  is [%s] , external URL [%s]",from?from:""
																,text?text:""
																,external_body_url?external_body_url:"");
	ms_free(from);
	counters = get_stats(lc);
	counters->number_of_LinphoneMessageReceived++;
	if (counters->last_received_chat_message) linphone_chat_message_unref(counters->last_received_chat_message);
	counters->last_received_chat_message=linphone_chat_message_ref(message);
	if (linphone_chat_message_get_file_transfer_information(message)) {
		counters->number_of_LinphoneMessageReceivedWithFile++;
	} else if (linphone_chat_message_get_external_body_url(message)) {
		counters->number_of_LinphoneMessageExtBodyReceived++;
		if (message_external_body_url) {
			CU_ASSERT_STRING_EQUAL(linphone_chat_message_get_external_body_url(message),message_external_body_url);
			message_external_body_url=NULL;
		}
	}
}