use of org.eclipse.ecf.presence.IPresenceContainerAdapter in project ecf by eclipse.
the class URLRosterViewerDropTarget method getURLShare.
private URLShare getURLShare(IRosterEntry rosterEntry1) {
final IPresenceContainerAdapter pca = rosterEntry1.getRoster().getPresenceContainerAdapter();
if (pca == null)
return null;
final IContainer container = (IContainer) pca.getAdapter(IContainer.class);
if (container == null)
return null;
return URLShare.getURLShare(container.getID());
}
use of org.eclipse.ecf.presence.IPresenceContainerAdapter in project ecf by eclipse.
the class IMBot method connect.
public synchronized void connect() throws ECFException {
fireInitBot();
try {
Namespace namespace = null;
if (container == null) {
container = ContainerFactory.getDefault().createContainer(bot.getContainerFactoryName());
namespace = container.getConnectNamespace();
} else
throw new ContainerConnectException("Already connected");
targetID = IDFactory.getDefault().createID(namespace, bot.getConnectID());
firePreConnect();
IPresenceContainerAdapter presenceAdapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
presenceAdapter.getChatManager().addMessageListener(this);
String password = bot.getPassword();
IConnectContext context = (password == null) ? null : ConnectContextFactory.createPasswordConnectContext(password);
container.connect(targetID, context);
} catch (ECFException e) {
if (container != null) {
if (container.getConnectedID() != null) {
container.disconnect();
}
container.dispose();
}
container = null;
throw e;
}
}
use of org.eclipse.ecf.presence.IPresenceContainerAdapter in project ecf by eclipse.
the class XMPPHyperlink method openContainer.
/**
* @param presenceContainerAdapter
*/
private void openContainer(IContainer container) {
final IPresenceContainerAdapter presenceContainerAdapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
final IChatManager chatManager = presenceContainerAdapter.getChatManager();
final IRosterManager rosterManager = presenceContainerAdapter.getRosterManager();
if (chatManager != null && rosterManager != null) {
try {
// get local ID
final XMPPID localID = (XMPPID) rosterManager.getRoster().getUser().getID();
final Namespace ns = container.getConnectNamespace();
// create target ID
final XMPPID targetID = (isXMPPS) ? new XMPPSID(ns, getURI().getAuthority()) : new XMPPID(ns, getURI().getAuthority());
// If they are same, just tell user and return
if (localID.equals(targetID)) {
MessageDialog.openError(null, Messages.XMPPHyperlink_MESSAGING_ERROR_TITLE, Messages.XMPPHyperlink_MESSAGING_ERROR_MESSAGE);
return;
} else {
final String localHost = localID.getHostname();
final String targetHost = targetID.getHostname();
// it's pretty obvious that we wish to message to them
if (localHost.equals(targetHost)) {
openMessagesView(chatManager, localID, targetID, targetID.getUsername());
} else {
// Otherwise, ask the user whether messaging, or
// connecting is desired
final MessageDialog messageDialog = new MessageDialog(null, Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_TITLE, null, NLS.bind(Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_MESSAGE, new Object[] { targetHost, localHost, targetID.getName(), localID.getName() }), MessageDialog.QUESTION, new String[] { Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_BUTTON_SEND_MESSAGE, Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_BUTTON_CONNECT, Messages.XMPPHyperlink_SELECT_ACTION_DIALOG_BUTTON_CANCEL }, 2);
final int selected = messageDialog.open();
switch(selected) {
case 0:
openMessagesView(chatManager, localID, targetID, targetID.getUsername());
return;
case 1:
super.open();
return;
default:
return;
}
}
}
} catch (final Exception e) {
MessageDialog.openError(null, Messages.XMPPHyperlink_ERROR_OPEN_MESSAGE_VIEW_DIALOG_TITLE, NLS.bind(Messages.XMPPHyperlink_ERROR_OPEN_MESSAGE_VIEW_DIALOG_MESSAGE, e.getLocalizedMessage()));
Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.XMPPHyperlink_ERROR_OPEN_MESSAGE_VIEW_LOG_STATUS_MESSAGE, e));
}
}
}
use of org.eclipse.ecf.presence.IPresenceContainerAdapter in project ecf by eclipse.
the class ResourcesShareHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
ISelection selection = HandlerUtil.getCurrentSelectionChecked(event);
if (!(selection instanceof IStructuredSelection)) {
return null;
}
IStructuredSelection iss = (IStructuredSelection) selection;
Object o = iss.getFirstElement();
IResource resource = null;
if (o instanceof IAdaptable) {
resource = (IResource) ((IAdaptable) o).getAdapter(IResource.class);
} else {
return null;
}
IPresenceContainerAdapter ipca = getRosterEntry().getRoster().getPresenceContainerAdapter();
IContainer container = (IContainer) ipca.getAdapter(IContainer.class);
ResourcesShare sender = SyncResourcesCore.getResourcesShare(container.getID());
IProject project = resource.getProject();
String projectName = project.getName();
if (!SyncResourcesCore.isSharing(projectName)) {
run(HandlerUtil.getActiveShellChecked(event), sender, projectName);
} else {
sender.stopSharing(projectName);
}
return null;
}
use of org.eclipse.ecf.presence.IPresenceContainerAdapter in project ecf by eclipse.
the class MSNConnectWizard method performFinish.
public boolean performFinish() {
final String connectID = page.getEmail();
final String password = page.getPassword();
// Save combo text even if we don't successfully login
page.saveComboText();
connectContext = ConnectContextFactory.createPasswordConnectContext(password);
try {
targetID = container.getConnectNamespace().createInstance(new Object[] { connectID });
} catch (final IDCreateException e) {
new IDCreateErrorDialog(null, connectID, e).open();
return false;
}
page.saveComboItems();
final IPresenceContainerAdapter adapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
container.addListener(new IContainerListener() {
public void handleEvent(IContainerEvent event) {
if (event instanceof IContainerConnectedEvent) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
openView();
}
});
}
}
});
final IChatManager icm = adapter.getChatManager();
icms = icm.getChatMessageSender();
itms = icm.getTypingMessageSender();
icm.addMessageListener(new IIMMessageListener() {
public void handleMessageEvent(IIMMessageEvent e) {
if (e instanceof IChatMessageEvent) {
displayMessage((IChatMessageEvent) e);
} else if (e instanceof ITypingMessageEvent) {
displayTypingNotification((ITypingMessageEvent) e);
}
}
});
new AsynchContainerConnectAction(container, targetID, connectContext, null, new Runnable() {
public void run() {
cachePassword(connectID, password);
}
}).run();
return true;
}
Aggregations