Search in sources :

Example 1 with IChatRoomManager

use of org.eclipse.ecf.presence.chatroom.IChatRoomManager in project ecf by eclipse.

the class IRCConnectWizard method performFinish.

public boolean performFinish() {
    final String connectID = page.getConnectID();
    final String password = page.getPassword();
    connectContext = ConnectContextFactory.createPasswordConnectContext(password);
    page.saveComboText();
    try {
        targetID = IDFactory.getDefault().createID(container.getConnectNamespace(), connectID);
    } catch (final IDCreateException e) {
        new IDCreateErrorDialog(null, connectID, e).open();
        return false;
    }
    final IChatRoomManager manager = (IChatRoomManager) this.container.getAdapter(IChatRoomManager.class);
    final IRCUI ui = new IRCUI(this.container, manager, null);
    ui.showForTarget(targetID);
    // If it's not already connected, then we connect this new container
    if (!ui.isContainerConnected()) {
        page.saveComboItems();
        // bug 274613, we need to remove the extra autojoin channel bits
        IRCID id = (IRCID) targetID;
        // start with user, then host, then port, abc@irc.freenode.net:6667
        StringBuffer buffer = new StringBuffer(id.getUsername());
        buffer.append('@').append(id.getHost());
        buffer.append(':').append(id.getPort());
        // create a truncated ID instance for the container to connect to
        id = (IRCID) container.getConnectNamespace().createInstance(new Object[] { buffer.toString() });
        new AsynchContainerConnectAction(container, id, connectContext, null, new Runnable() {

            public void run() {
                cachePassword(page.getPasswordKeyFromUserName(connectID), password);
            }
        }).run();
    }
    return true;
}
Also used : IDCreateErrorDialog(org.eclipse.ecf.ui.dialogs.IDCreateErrorDialog) AsynchContainerConnectAction(org.eclipse.ecf.ui.actions.AsynchContainerConnectAction) IChatRoomManager(org.eclipse.ecf.presence.chatroom.IChatRoomManager) IRCID(org.eclipse.ecf.internal.provider.irc.identity.IRCID)

Example 2 with IChatRoomManager

use of org.eclipse.ecf.presence.chatroom.IChatRoomManager in project ecf by eclipse.

the class AbstractAdapterAccessTest method testGetChatRoomManager.

public void testGetChatRoomManager() {
    final IPresenceContainerAdapter adapter = getPresenceAdapter();
    assertNotNull(adapter);
    final IChatRoomManager chatRoomManager = adapter.getChatRoomManager();
    assertNotNull(chatRoomManager);
}
Also used : IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IChatRoomManager(org.eclipse.ecf.presence.chatroom.IChatRoomManager)

Example 3 with IChatRoomManager

use of org.eclipse.ecf.presence.chatroom.IChatRoomManager in project ecf by eclipse.

the class IRCChannelHyperlink method open.

public void open() {
    IChatRoomContainer container = view.getRootChatRoomContainer();
    final IChatRoomManager manager = (IChatRoomManager) container.getAdapter(IChatRoomManager.class);
    view.joinRoom(manager.getChatRoomInfo(channel), "");
}
Also used : IChatRoomContainer(org.eclipse.ecf.presence.chatroom.IChatRoomContainer) IChatRoomManager(org.eclipse.ecf.presence.chatroom.IChatRoomManager)

Example 4 with IChatRoomManager

use of org.eclipse.ecf.presence.chatroom.IChatRoomManager in project ecf by eclipse.

the class AbstractChatRoomParticipantTest method setUp.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.tests.presence.AbstractPresenceTestCase#setUp()
	 */
protected void setUp() throws Exception {
    super.setUp();
    setClientCount(2);
    clients = createClients();
    IChatRoomManager chat0, chat1;
    chat0 = getPresenceAdapter(0).getChatRoomManager();
    chat1 = getPresenceAdapter(1).getChatRoomManager();
    for (int i = 0; i < getClientCount(); i++) {
        connectClient(i);
    }
    final IChatRoomInfo roomInfo0 = chat0.getChatRoomInfo(CHAT_ROOM_NAME);
    if (roomInfo0 == null)
        return;
    chatRoomContainer0 = roomInfo0.createChatRoomContainer();
    chatRoomContainer0.addChatRoomParticipantListener(participantListener0);
    chatRoomContainer0.connect(roomInfo0.getRoomID(), null);
    final IChatRoomInfo roomInfo1 = chat1.getChatRoomInfo(CHAT_ROOM_NAME);
    chatRoomContainer1 = roomInfo1.createChatRoomContainer();
    chatRoomContainer1.addChatRoomParticipantListener(participantListener1);
    chatRoomContainer1.connect(roomInfo1.getRoomID(), null);
    Thread.sleep(2000);
}
Also used : IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) IChatRoomManager(org.eclipse.ecf.presence.chatroom.IChatRoomManager)

Example 5 with IChatRoomManager

use of org.eclipse.ecf.presence.chatroom.IChatRoomManager in project ecf by eclipse.

the class ChatRoomBot 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
            // $NON-NLS-1$
            throw new ContainerConnectException("Already connected");
        targetID = IDFactory.getDefault().createID(namespace, bot.getConnectID());
        IChatRoomManager manager = (IChatRoomManager) container.getAdapter(IChatRoomManager.class);
        if (manager == null)
            // $NON-NLS-1$
            throw new ECFException("No chat room manager available");
        firePreConnect();
        String password = bot.getPassword();
        IConnectContext context = (password == null) ? null : ConnectContextFactory.createPasswordConnectContext(password);
        container.connect(targetID, context);
        String[] roomNames = bot.getChatRooms();
        String[] roomPasswords = bot.getChatRoomPasswords();
        for (int i = 0; i < roomNames.length; i++) {
            IChatRoomInfo room = manager.getChatRoomInfo(roomNames[i]);
            roomContainer = room.createChatRoomContainer();
            roomID = room.getRoomID();
            firePreRoomConnect();
            roomContainer.addMessageListener(this);
            IConnectContext roomContext = (roomPasswords[i] == null) ? null : ConnectContextFactory.createPasswordConnectContext(roomPasswords[i]);
            roomContainer.connect(roomID, roomContext);
        }
    } catch (ECFException e) {
        if (container != null) {
            if (container.getConnectedID() != null) {
                container.disconnect();
            }
            container.dispose();
        }
        container = null;
        throw e;
    }
}
Also used : IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) IConnectContext(org.eclipse.ecf.core.security.IConnectContext) ContainerConnectException(org.eclipse.ecf.core.ContainerConnectException) ECFException(org.eclipse.ecf.core.util.ECFException) IChatRoomManager(org.eclipse.ecf.presence.chatroom.IChatRoomManager) Namespace(org.eclipse.ecf.core.identity.Namespace)

Aggregations

IChatRoomManager (org.eclipse.ecf.presence.chatroom.IChatRoomManager)5 IChatRoomInfo (org.eclipse.ecf.presence.chatroom.IChatRoomInfo)2 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)1 Namespace (org.eclipse.ecf.core.identity.Namespace)1 IConnectContext (org.eclipse.ecf.core.security.IConnectContext)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IRCID (org.eclipse.ecf.internal.provider.irc.identity.IRCID)1 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)1 IChatRoomContainer (org.eclipse.ecf.presence.chatroom.IChatRoomContainer)1 AsynchContainerConnectAction (org.eclipse.ecf.ui.actions.AsynchContainerConnectAction)1 IDCreateErrorDialog (org.eclipse.ecf.ui.dialogs.IDCreateErrorDialog)1