Search in sources :

Example 11 with Namespace

use of org.eclipse.ecf.core.identity.Namespace 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 12 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class DiscoveryTestsWithoutRegister method testGetServicesNamespace.

/**
 * Test method for
 * {@link org.eclipse.ecf.discovery.IdiscoveryLocatorAdapter#getServicesNamespace()}.
 */
public void testGetServicesNamespace() {
    testConnect();
    final Namespace namespace = discoveryLocator.getServicesNamespace();
    assertNotNull(namespace);
    final IServiceTypeID serviceTypeID = ServiceIDFactory.getDefault().createServiceTypeID(namespace, serviceInfo.getServiceID().getServiceTypeID());
    assertNotNull("It must be possible to obtain a IServiceTypeID", serviceTypeID);
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 13 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class LongIDTest method testEqualNamespaces.

public void testEqualNamespaces() throws Exception {
    final ID id1 = createID();
    final ID id2 = createID();
    final Namespace ns1 = id1.getNamespace();
    final Namespace ns2 = id2.getNamespace();
    assertTrue(ns1.equals(ns2));
    assertTrue(ns2.equals(ns2));
}
Also used : ID(org.eclipse.ecf.core.identity.ID) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 14 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class NamespaceTest method testNewNamespaceGetSupportedParameterTypesForCreateInstance.

public void testNewNamespaceGetSupportedParameterTypesForCreateInstance() {
    Namespace ns = createNamespace();
    Class[][] result = ns.getSupportedParameterTypes();
    assertTrue(result.length == 1);
    assertTrue(result[0][0].equals(String.class));
}
Also used : Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 15 with Namespace

use of org.eclipse.ecf.core.identity.Namespace in project ecf by eclipse.

the class NamespaceTest method testNewNamespaceGetDescription.

public void testNewNamespaceGetDescription() {
    Namespace ns = createNamespace();
    String desc = ns.getDescription();
    assertTrue(desc.equals(DESCRIPTION));
}
Also used : Namespace(org.eclipse.ecf.core.identity.Namespace)

Aggregations

Namespace (org.eclipse.ecf.core.identity.Namespace)51 ID (org.eclipse.ecf.core.identity.ID)10 IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)10 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)9 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)5 JSLPNamespace (org.eclipse.ecf.provider.jslp.identity.JSLPNamespace)4 GUID (org.eclipse.ecf.core.identity.GUID)3 UnknownHostException (java.net.UnknownHostException)2 UUID (java.util.UUID)2 IContainer (org.eclipse.ecf.core.IContainer)2 ContainerConnectedEvent (org.eclipse.ecf.core.events.ContainerConnectedEvent)2 ContainerConnectingEvent (org.eclipse.ecf.core.events.ContainerConnectingEvent)2 StringID (org.eclipse.ecf.core.identity.StringID)2 IConnectContext (org.eclipse.ecf.core.security.IConnectContext)2 ECFException (org.eclipse.ecf.core.util.ECFException)2 ServiceTypeID (org.eclipse.ecf.discovery.identity.ServiceTypeID)2 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)2 SimpleResolver (org.xbill.DNS.SimpleResolver)2 URI (java.net.URI)1 Map (java.util.Map)1