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);
}
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);
}
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;
}
}
Aggregations