org.jivesoftware.smackx.filetransfer.FileTransferRequest Java Examples
The following examples show how to use
org.jivesoftware.smackx.filetransfer.FileTransferRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReceiveFileTransfer.java From Spark with Apache License 2.0 | 6 votes |
private void rejectRequest(FileTransferRequest request) { try { request.reject(); } catch ( SmackException.NotConnectedException | InterruptedException ex ) { Log.warning( "Unable to reject the request.", ex); } setBackground(new Color(239, 245, 250)); acceptButton.setVisible(false); declineButton.setVisible(false); fileLabel.setText(""); titleLabel.setText(Res.getString("message.file.transfer.canceled")); titleLabel.setForeground(new Color(65, 139, 179)); invalidate(); validate(); repaint(); }
Example #2
Source File: XMPPFileTransferManager.java From saros with GNU General Public License v2.0 | 5 votes |
@Override public void fileTransferRequest(FileTransferRequest request) { XMPPContact contact = contactsService.getContact(request.getRequestor()).orElse(null); if (contact == null) { log.info("received transfer request but contact unknown " + request.getRequestor()); return; } String identifier = request.getDescription(); log.info( "received transfer request, name: " + request.getFileName() + ", identifier: " + identifier + " by " + contact); if (identifier != null) { CompletableFuture<XMPPFileTransferRequest> future = expectedTransfers.remove(identifier); if (future != null) { future.complete(new XMPPFileTransferRequest(contact, request)); return; } } Consumer<XMPPFileTransferRequest> defaultListener = defaultTransferHandler.get(); if (defaultListener == null) { request.reject(); } else { defaultListener.accept(new XMPPFileTransferRequest(contact, request)); } }
Example #3
Source File: SparkTransferManager.java From Spark with Apache License 2.0 | 5 votes |
private void handleTransferRequest(FileTransferRequest request, ContactList contactList) { // Check if a listener handled this request if (fireTransferListeners(request)) { return; } Jid requestor = request.getRequestor(); EntityBareJid bareJID = requestor.asEntityBareJidOrThrow(); 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")); }
Example #4
Source File: SparkTransferManager.java From Spark with Apache License 2.0 | 5 votes |
private boolean fireTransferListeners(FileTransferRequest request) { for (FileTransferListener listener : new ArrayList<>( listeners )) { boolean accepted = listener.handleTransfer(request); if (accepted) { return true; } } return false; }
Example #5
Source File: FileTransferSettingsPlugin.java From Spark with Apache License 2.0 | 5 votes |
/** * Tests the supplied {@link FileTransferRequest} against the supplied {@link FileTransferSettings}. Returns true if the request * fails to match the configuration for allowed files. * * @param request the transfer request to test. * @param settings the transfer settings to use in testing the request. * @return true if the request fails to match the configuration for allowed files. */ private boolean requestContainsBannedFile(FileTransferRequest request, FileTransferSettings settings) { if (settings.getCheckFileSize() && request.getFileSize() > settings.getMaxFileSize()) { return true; } if (settings.getBlockedJIDs().contains(request.getRequestor().asBareJid())) { return true; } if (settings.getBlockedExtensions().contains(getFileExtensionFromName(request.getFileName()))) { return true; } return false; }
Example #6
Source File: XMPPFileTransferRequest.java From saros with GNU General Public License v2.0 | 4 votes |
XMPPFileTransferRequest(XMPPContact contact, FileTransferRequest request) { this.contact = contact; this.request = request; }
Example #7
Source File: FileTransferListener.java From Spark with Apache License 2.0 | 2 votes |
/** * Returns true if the object wishes to handle the file transfer itself. Otherwise, * it will default. * * @param request the <code>FileTransferRequest</code> * @return true if object handles transfer request. */ boolean handleTransfer(FileTransferRequest request);