Search in sources :

Example 1 with ReceiveFileTransfer

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"));
}
Also used : ReceiveFileTransfer(org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.ReceiveFileTransfer) ChatRoom(org.jivesoftware.spark.ui.ChatRoom) TranscriptWindow(org.jivesoftware.spark.ui.TranscriptWindow) ContactItem(org.jivesoftware.spark.ui.ContactItem)

Aggregations

ChatRoom (org.jivesoftware.spark.ui.ChatRoom)1 ContactItem (org.jivesoftware.spark.ui.ContactItem)1 TranscriptWindow (org.jivesoftware.spark.ui.TranscriptWindow)1 ReceiveFileTransfer (org.jivesoftware.sparkimpl.plugin.filetransfer.transfer.ui.ReceiveFileTransfer)1