Search in sources :

Example 1 with ISendFileTransferContainerAdapter

use of org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter in project ecf by eclipse.

the class MultiProtocolOutgoingAdapter method sendOutgoingRequest.

/* (non-Javadoc)
	 * @see org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter#sendOutgoingRequest(org.eclipse.ecf.filetransfer.identity.IFileID, org.eclipse.ecf.filetransfer.IFileTransferInfo, org.eclipse.ecf.filetransfer.IFileTransferListener, java.util.Map)
	 */
public void sendOutgoingRequest(IFileID targetID, IFileTransferInfo localFileToSend, IFileTransferListener transferListener, Map options) throws SendFileTransferException {
    Assert.isNotNull(targetID);
    Assert.isNotNull(localFileToSend);
    Assert.isNotNull(transferListener);
    String protocol = null;
    try {
        protocol = targetID.getURI().getScheme();
    } catch (URISyntaxException e) {
        try {
            protocol = targetID.getURL().getProtocol();
        } catch (final MalformedURLException e1) {
            throw new SendFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
        }
    }
    ISendFileTransferContainerAdapter fileTransfer = Activator.getDefault().getSendFileTransfer(protocol);
    // If no handler setup for this protocol then throw
    if (fileTransfer == null) {
        throw new SendFileTransferException(NLS.bind(Messages.MultiProtocolOutgoingAdapter_EXCEPTION_NO_PROTOCOL_HANDER, targetID));
    }
    fileTransfer.setConnectContextForAuthentication(connectContext);
    fileTransfer.setProxy(proxy);
    fileTransfer.sendOutgoingRequest(targetID, localFileToSend, transferListener, options);
}
Also used : ISendFileTransferContainerAdapter(org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter) MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) SendFileTransferException(org.eclipse.ecf.filetransfer.SendFileTransferException)

Example 2 with ISendFileTransferContainerAdapter

use of org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter in project ecf by eclipse.

the class MultiProtocolOutgoingAdapter method sendOutgoingRequest.

public void sendOutgoingRequest(IFileID targetID, File outgoingFile, IFileTransferListener transferListener, Map options) throws SendFileTransferException {
    Assert.isNotNull(targetID);
    Assert.isNotNull(outgoingFile);
    Assert.isNotNull(transferListener);
    String protocol = null;
    try {
        protocol = targetID.getURI().getScheme();
    } catch (URISyntaxException e) {
        try {
            protocol = targetID.getURL().getProtocol();
        } catch (final MalformedURLException e1) {
            throw new SendFileTransferException(Messages.AbstractRetrieveFileTransfer_MalformedURLException);
        }
    }
    ISendFileTransferContainerAdapter fileTransfer = Activator.getDefault().getSendFileTransfer(protocol);
    // If no handler setup for this protocol then throw
    if (fileTransfer == null) {
        if (protocol.equalsIgnoreCase("file")) {
            // $NON-NLS-1$
            fileTransfer = new LocalFileOutgoingFileTransfer();
        }
    }
    if (fileTransfer == null) {
        throw new SendFileTransferException(NLS.bind(Messages.MultiProtocolOutgoingAdapter_EXCEPTION_NO_PROTOCOL_HANDER, targetID));
    }
    fileTransfer.setConnectContextForAuthentication(connectContext);
    fileTransfer.setProxy(proxy);
    fileTransfer.sendOutgoingRequest(targetID, outgoingFile, transferListener, options);
}
Also used : ISendFileTransferContainerAdapter(org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter) MalformedURLException(java.net.MalformedURLException) URISyntaxException(java.net.URISyntaxException) SendFileTransferException(org.eclipse.ecf.filetransfer.SendFileTransferException)

Example 3 with ISendFileTransferContainerAdapter

use of org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter in project ecf by eclipse.

the class XMPPCompoundContributionItem method getContributionItems.

protected IContributionItem[] getContributionItems() {
    final Object selection = getSelection();
    if (!(selection instanceof IRosterEntry)) {
        return EMPTY_ARRAY;
    }
    final IRosterEntry entry = (IRosterEntry) selection;
    final IContainer container = getContainerForRosterEntry(entry);
    if (container instanceof XMPPContainer) {
        final IContributionItem[] contributions = new IContributionItem[1];
        final ISendFileTransferContainerAdapter ioftca = (ISendFileTransferContainerAdapter) container.getAdapter(ISendFileTransferContainerAdapter.class);
        if (!(ioftca != null && isAvailable(entry)))
            return EMPTY_ARRAY;
        final IAction fileSendAction = new Action() {

            public void run() {
                sendFileToTarget(ioftca, entry.getUser().getID());
            }
        };
        fileSendAction.setText(Messages.XMPPCompoundContributionItem_SEND_FILE);
        fileSendAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE));
        contributions[0] = new ActionContributionItem(fileSendAction);
        return contributions;
    } else {
        return EMPTY_ARRAY;
    }
}
Also used : ISendFileTransferContainerAdapter(org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) IAction(org.eclipse.jface.action.IAction) IContributionItem(org.eclipse.jface.action.IContributionItem) IRosterEntry(org.eclipse.ecf.presence.roster.IRosterEntry) XMPPContainer(org.eclipse.ecf.provider.xmpp.XMPPContainer) IContainer(org.eclipse.ecf.core.IContainer)

Aggregations

ISendFileTransferContainerAdapter (org.eclipse.ecf.filetransfer.ISendFileTransferContainerAdapter)3 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2 SendFileTransferException (org.eclipse.ecf.filetransfer.SendFileTransferException)2 IContainer (org.eclipse.ecf.core.IContainer)1 IRosterEntry (org.eclipse.ecf.presence.roster.IRosterEntry)1 XMPPContainer (org.eclipse.ecf.provider.xmpp.XMPPContainer)1 Action (org.eclipse.jface.action.Action)1 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)1 IAction (org.eclipse.jface.action.IAction)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1