use of org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.ReceiveFileTransfer in project Spark by igniterealtime.
the class SparkTransferManager method handleTransferRequest.
private void handleTransferRequest(FileTransferRequest request, ContactList contactList) {
// Check if a listener handled this request
if (fireTransferListeners(request)) {
return;
}
String requestor = request.getRequestor();
String bareJID = XmppStringUtils.parseBareJid(requestor);
String fileName = request.getFileName();
ContactItem contactItem = contactList.getContactItemByJID(bareJID);
ChatRoom chatRoom;
if (contactItem != null) {
chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, contactItem.getDisplayName(), contactItem.getDisplayName());
} else {
chatRoom = SparkManager.getChatManager().createChatRoom(bareJID, bareJID, bareJID);
}
TranscriptWindow transcriptWindow = chatRoom.getTranscriptWindow();
transcriptWindow.insertCustomText(Res.getString("message.file.transfer.chat.window"), true, false, Color.BLACK);
final ReceiveFileTransfer receivingMessageUI = new ReceiveFileTransfer();
receivingMessageUI.acceptFileTransfer(request);
chatRoom.addClosingListener(() -> receivingMessageUI.cancelTransfer());
transcriptWindow.addComponent(receivingMessageUI);
chatRoom.increaseUnreadMessageCount();
chatRoom.scrollToBottom();
String fileTransMsg = contactItem.getDisplayName() + " " + Res.getString("message.file.transfer.short.message") + " " + fileName;
SparkManager.getChatManager().getChatContainer().fireNotifyOnMessage(chatRoom, true, fileTransMsg, Res.getString("message.file.transfer.notification"));
}
Aggregations