Esempio n. 1
0
static void text_delivery_update(SalOp *op, SalTextDeliveryStatus status, SalReason reason){
	LinphoneChatMessage *chat_msg=(LinphoneChatMessage* )sal_op_get_user_pointer(op);
	const MSList* calls;

	if (chat_msg == NULL) {
		// Do not handle delivery status for isComposing messages.
		return;
	}
	calls = linphone_core_get_calls(chat_msg->chat_room->lc);

	chat_msg->state=chatStatusSal2Linphone(status);
	chat_msg->reason=reason;
	linphone_chat_message_store_state(chat_msg);
	if (chat_msg && chat_msg->cb) {
		ms_message("Notifying text delivery with status %i",chat_msg->state);
		chat_msg->cb(chat_msg
			,chat_msg->state
			,chat_msg->cb_ud);
	}
	if (status != SalTextDeliveryInProgress) { /*don't release op if progress*/
		linphone_chat_message_destroy(chat_msg);

		if (!ms_list_find_custom((MSList*)calls, (MSCompareFunc) op_equals, op)) {
			/*op was only create for messaging purpose, destroying*/
			sal_op_release(op);
		}
	}
}
Esempio n. 2
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);
}
Esempio n. 3
0
/**
 * function invoked when a file transfer is received.
 **/
static void file_transfer_received(LinphoneChatMessage *message, const LinphoneContent* content, const LinphoneBuffer *buffer){
	FILE* file=NULL;
	if (!linphone_chat_message_get_user_data(message)) {
		/*first chunk, creating file*/
		file = fopen("receive_file.dump","wb");
		linphone_chat_message_set_user_data(message,(void*)file); /*store fd for next chunks*/
	}

	file = (FILE*)linphone_chat_message_get_user_data(message);
	if (linphone_buffer_is_empty(buffer)) {
		printf("File transfert completed\n");
		linphone_chat_room_destroy(linphone_chat_message_get_chat_room(message));
		linphone_chat_message_destroy(message);
		fclose(file);
		running=FALSE;
	} else { /* store content on a file*/
		if (fwrite(linphone_buffer_get_content(buffer),linphone_buffer_get_size(buffer),1,file)==-1){
			ms_warning("file_transfer_received() write failed: %s",strerror(errno));
		}
	}
}
Esempio n. 4
0
static void linphone_gtk_chat_message_destroy(LinphoneChatMessage *msg){
	linphone_chat_message_destroy(msg);
}