Search in sources :

Example 6 with IPresenceContainerAdapter

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());
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IContainer(org.eclipse.ecf.core.IContainer)

Example 7 with IPresenceContainerAdapter

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;
    }
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ECFException(org.eclipse.ecf.core.util.ECFException) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 8 with IPresenceContainerAdapter

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));
        }
    }
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IRosterManager(org.eclipse.ecf.presence.roster.IRosterManager) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID) Namespace(org.eclipse.ecf.core.identity.Namespace) XMPPSID(org.eclipse.ecf.provider.xmpp.identity.XMPPSID)

Example 9 with IPresenceContainerAdapter

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;
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IAdaptable(org.eclipse.core.runtime.IAdaptable) ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IContainer(org.eclipse.ecf.core.IContainer) ResourcesShare(org.eclipse.ecf.internal.sync.resources.core.ResourcesShare) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject)

Example 10 with IPresenceContainerAdapter

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;
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) IContainerListener(org.eclipse.ecf.core.IContainerListener) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent) IDCreateErrorDialog(org.eclipse.ecf.ui.dialogs.IDCreateErrorDialog) IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) ITypingMessageEvent(org.eclipse.ecf.presence.im.ITypingMessageEvent) AsynchContainerConnectAction(org.eclipse.ecf.ui.actions.AsynchContainerConnectAction) IChatManager(org.eclipse.ecf.presence.im.IChatManager)

Aggregations

IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)18 IContainer (org.eclipse.ecf.core.IContainer)5 IRosterManager (org.eclipse.ecf.presence.roster.IRosterManager)4 IChatManager (org.eclipse.ecf.presence.im.IChatManager)3 Iterator (java.util.Iterator)2 List (java.util.List)2 Namespace (org.eclipse.ecf.core.identity.Namespace)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Entry (java.util.Map.Entry)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)1 IContainerListener (org.eclipse.ecf.core.IContainerListener)1 IContainerManager (org.eclipse.ecf.core.IContainerManager)1 IContainerConnectedEvent (org.eclipse.ecf.core.events.IContainerConnectedEvent)1 IContainerEvent (org.eclipse.ecf.core.events.IContainerEvent)1