Search in sources :

Example 56 with ID

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

the class ScribbleClient method createChannel.

protected void createChannel() throws ECFException {
    // Get IChannelContainerAdapter adapter
    IChannelContainerAdapter channelContainer = (IChannelContainerAdapter) container.getAdapter(IChannelContainerAdapter.class);
    // Create channel ID with fixed name 'channel2'
    final ID channelID = IDFactory.getDefault().createID(channelContainer.getChannelNamespace(), CHANNEL_ID);
    // Setup listener so then when channelmessageevents are received that
    // they present in UI
    final IChannelListener channelListener = new IChannelListener() {

        public void handleChannelEvent(final IChannelEvent event) {
            if (event instanceof IChannelMessageEvent) {
                IChannelMessageEvent msg = (IChannelMessageEvent) event;
                scribbleView.handleDrawLine(msg.getData());
            }
        }
    };
    // Create new channel
    IChannel channel = channelContainer.createChannel(channelID, channelListener, new HashMap());
    // Set the view to use the given channel (for sending)
    scribbleView.setChannel(channel);
}
Also used : IChannelListener(org.eclipse.ecf.datashare.IChannelListener) IChannel(org.eclipse.ecf.datashare.IChannel) IChannelEvent(org.eclipse.ecf.datashare.events.IChannelEvent) HashMap(java.util.HashMap) IChannelContainerAdapter(org.eclipse.ecf.datashare.IChannelContainerAdapter) ID(org.eclipse.ecf.core.identity.ID) IChannelMessageEvent(org.eclipse.ecf.datashare.events.IChannelMessageEvent)

Example 57 with ID

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

the class GenericAuthConsumerContainerSelector method createContainer.

@Override
protected IRemoteServiceContainer createContainer(ContainerTypeDescription containerTypeDescription, String containerTypeDescriptionName, @SuppressWarnings("rawtypes") Map properties) throws SelectContainerException {
    IRemoteServiceContainer result = super.createContainer(containerTypeDescription, containerTypeDescriptionName, properties);
    ISharedObjectContainerClient client = (ISharedObjectContainerClient) result.getContainer().getAdapter(ISharedObjectContainerClient.class);
    if (client != null) {
        client.setConnectInitiatorPolicy(new IConnectInitiatorPolicy() {

            public void refresh() {
            }

            public Object createConnectData(IContainer container, ID targetID, IConnectContext context) {
                // to the server.
                return getConnectData();
            }

            public int getConnectTimeout() {
                return 30000;
            }
        });
    }
    return result;
}
Also used : IRemoteServiceContainer(org.eclipse.ecf.remoteservice.IRemoteServiceContainer) IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ISharedObjectContainerClient(org.eclipse.ecf.core.sharedobject.ISharedObjectContainerClient) IConnectInitiatorPolicy(org.eclipse.ecf.core.security.IConnectInitiatorPolicy) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Example 58 with ID

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

the class Activator method createAndConfigureHostContainer.

private void createAndConfigureHostContainer(BundleContext context) throws Exception {
    // Get IContainerManager singleton
    ServiceTracker<IContainerManager, IContainerManager> containerManagerTracker = new ServiceTracker<IContainerManager, IContainerManager>(context, IContainerManager.class.getName(), null);
    containerManagerTracker.open();
    IContainerManager containerManager = containerManagerTracker.getService();
    if (containerManager == null)
        throw new NullPointerException("Cannot get IContainerManager service");
    containerManagerTracker.close();
    // Now create a hostContainer instance
    hostContainer = containerManager.getContainerFactory().createContainer("ecf.generic.server");
    // Get the ISharedObjectContainerGroupManager adapter interface
    ISharedObjectContainerGroupManager hostManager = (ISharedObjectContainerGroupManager) hostContainer.getAdapter(ISharedObjectContainerGroupManager.class);
    // Set connect policy
    hostManager.setConnectPolicy(new IConnectHandlerPolicy() {

        public void refresh() {
        }

        public PermissionCollection checkConnect(Object address, ID fromID, ID targetID, String targetGroup, Object connectData) throws Exception {
            // What we will do when we receive a check connect call is to call
            // verifyClientConnect
            verifyClientConnect(fromID, connectData);
            return null;
        }
    });
}
Also used : PermissionCollection(java.security.PermissionCollection) ISharedObjectContainerGroupManager(org.eclipse.ecf.core.sharedobject.ISharedObjectContainerGroupManager) IConnectHandlerPolicy(org.eclipse.ecf.core.security.IConnectHandlerPolicy) ServiceTracker(org.osgi.util.tracker.ServiceTracker) IContainerManager(org.eclipse.ecf.core.IContainerManager) ID(org.eclipse.ecf.core.identity.ID)

Example 59 with ID

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

the class ChatRoomMessageHandler method preChatRoomConnect.

public void preChatRoomConnect(IChatRoomContainer roomContainer, ID roomID) {
    // retrieve our name
    ID connectedID = container.getConnectedID();
    botName = connectedID.getName();
    IChatID chatID = (IChatID) connectedID.getAdapter(IChatID.class);
    if (chatID != null) {
        botName = chatID.getUsername();
    }
    messageSenders.put(roomID, roomContainer.getChatRoomMessageSender());
    if (password != null) {
        try {
            sendMessage(IDFactory.getDefault().createStringID("nickserv"), "identify " + password);
        } catch (IDCreateException e) {
        }
    }
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IChatID(org.eclipse.ecf.presence.im.IChatID) ID(org.eclipse.ecf.core.identity.ID) IChatID(org.eclipse.ecf.presence.im.IChatID)

Example 60 with ID

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

the class ChatRobotApplication method start.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.
	 * IApplicationContext)
	 */
public Object start(IApplicationContext context) throws Exception {
    // process program arguments
    String[] originalArgs = (String[]) context.getArguments().get("application.args");
    if (originalArgs.length < 3) {
        System.out.println("Parameters:  <senderAccount> <senderPassword> <targetAccount> [<message>].  e.g. sender@gmail.com senderpassword receiver@gmail.com \"Hello there\"");
        return new Integer(-1);
    }
    String message = null;
    if (originalArgs.length > 3)
        message = originalArgs[3];
    // Create client
    XMPPChatClient client = new XMPPChatClient(this, this);
    // connect
    client.connect(originalArgs[0], originalArgs[1]);
    // Wait for 5s for the roster/presence information to be received
    final Object lock = new Object();
    synchronized (lock) {
        lock.wait(5000);
    }
    // Get desired user ID from rosterUsers map.  This is just looking for a user that's active and on our contacts list
    ID targetID = (ID) rosterUsers.get(originalArgs[2]);
    if (targetID == null) {
        System.out.println("target user=" + originalArgs[2] + " is not on active on your contacts list.  Cannot send message to this user");
        return new Integer(0);
    }
    // Construct message
    String msgToSend = (message == null) ? "Hi, I'm an ECF chat robot." : message;
    System.out.println("ECF chat robot example sending to targetAccount=" + originalArgs[2] + " message=" + msgToSend);
    // Send message to targetID
    client.sendChat(targetID, msgToSend);
    // Close up nicely and return
    client.close();
    return IApplication.EXIT_OK;
}
Also used : ID(org.eclipse.ecf.core.identity.ID) IChatID(org.eclipse.ecf.presence.im.IChatID) XMPPChatClient(org.eclipse.ecf.example.clients.XMPPChatClient)

Aggregations

ID (org.eclipse.ecf.core.identity.ID)256 IContainer (org.eclipse.ecf.core.IContainer)29 IOException (java.io.IOException)19 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)18 UUID (java.util.UUID)17 HashMap (java.util.HashMap)12 ArrayList (java.util.ArrayList)11 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)11 GUID (org.eclipse.ecf.core.identity.GUID)11 ISharedObjectManager (org.eclipse.ecf.core.sharedobject.ISharedObjectManager)11 XMPPRoomID (org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID)11 Namespace (org.eclipse.ecf.core.identity.Namespace)10 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)10 Map (java.util.Map)9 Matcher (java.util.regex.Matcher)9 ECFException (org.eclipse.ecf.core.util.ECFException)9 List (java.util.List)8 ISharedObject (org.eclipse.ecf.core.sharedobject.ISharedObject)8 IChannel (org.eclipse.ecf.datashare.IChannel)8 Iterator (java.util.Iterator)7