Search in sources :

Example 6 with IChatRoomInfo

use of org.eclipse.ecf.presence.chatroom.IChatRoomInfo 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 7 with IChatRoomInfo

use of org.eclipse.ecf.presence.chatroom.IChatRoomInfo 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)

Example 8 with IChatRoomInfo

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

the class XMPPChatRoomManager method getChatRoomInfos.

public IChatRoomInfo[] getChatRoomInfos() {
    final ID[] chatRooms = getChatRooms();
    if (chatRooms == null)
        return new IChatRoomInfo[0];
    final IChatRoomInfo[] res = new IChatRoomInfo[chatRooms.length];
    int count = 0;
    for (int i = 0; i < chatRooms.length; i++) {
        final IChatRoomInfo infoResult = getChatRoomInfo(chatRooms[i]);
        if (infoResult != null) {
            res[count++] = infoResult;
        }
    }
    final IChatRoomInfo[] results = new IChatRoomInfo[count];
    for (int i = 0; i < count; i++) {
        results[i] = res[i];
    }
    return results;
}
Also used : IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) XMPPID(org.eclipse.ecf.provider.xmpp.identity.XMPPID) XMPPRoomID(org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID) ID(org.eclipse.ecf.core.identity.ID)

Example 9 with IChatRoomInfo

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

the class XMPPChatRoomManager method getChatRoomInfo.

public IChatRoomInfo getChatRoomInfo(String roomname) {
    try {
        if (ecfConnection == null)
            return null;
        // Create roomid
        final XMPPConnection conn = ecfConnection.getXMPPConnection();
        final XMPPRoomID roomID = new XMPPRoomID(connectNamespace, conn, roomname);
        final String mucName = roomID.getMucString();
        final RoomInfo info = MultiUserChat.getRoomInfo(conn, mucName);
        if (info != null) {
            return new ECFRoomInfo(roomID, info, connectedID);
        }
    } catch (final Exception e) {
        return null;
    }
    return null;
}
Also used : XMPPRoomID(org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID) IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) RoomInfo(org.jivesoftware.smackx.muc.RoomInfo) XMPPConnection(org.jivesoftware.smack.XMPPConnection) ECFException(org.eclipse.ecf.core.util.ECFException) ChatRoomCreateException(org.eclipse.ecf.presence.chatroom.ChatRoomCreateException) URISyntaxException(java.net.URISyntaxException) IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) ContainerCreateException(org.eclipse.ecf.core.ContainerCreateException) XMPPException(org.jivesoftware.smack.XMPPException)

Aggregations

IChatRoomInfo (org.eclipse.ecf.presence.chatroom.IChatRoomInfo)9 ID (org.eclipse.ecf.core.identity.ID)3 ECFException (org.eclipse.ecf.core.util.ECFException)3 XMPPRoomID (org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID)3 URISyntaxException (java.net.URISyntaxException)2 ChatRoomCreateException (org.eclipse.ecf.presence.chatroom.ChatRoomCreateException)2 IChatRoomContainer (org.eclipse.ecf.presence.chatroom.IChatRoomContainer)2 IChatRoomManager (org.eclipse.ecf.presence.chatroom.IChatRoomManager)2 XMPPException (org.jivesoftware.smack.XMPPException)2 RoomInfo (org.jivesoftware.smackx.muc.RoomInfo)2 ContainerConnectException (org.eclipse.ecf.core.ContainerConnectException)1 ContainerCreateException (org.eclipse.ecf.core.ContainerCreateException)1 IContainer (org.eclipse.ecf.core.IContainer)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 Namespace (org.eclipse.ecf.core.identity.Namespace)1 IConnectContext (org.eclipse.ecf.core.security.IConnectContext)1 IChatRoomInvitationSender (org.eclipse.ecf.presence.chatroom.IChatRoomInvitationSender)1 XMPPID (org.eclipse.ecf.provider.xmpp.identity.XMPPID)1 ContainerConnectErrorDialog (org.eclipse.ecf.ui.dialogs.ContainerConnectErrorDialog)1 XMPPConnection (org.jivesoftware.smack.XMPPConnection)1