Search in sources :

Example 1 with IChatRoomInfo

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

the class Bot method setup.

protected void setup() throws ECFException {
    if (container == null) {
        container = ContainerFactory.getDefault().createContainer(CONTAINER_TYPE);
        namespace = container.getConnectNamespace();
    }
    manager = (IChatRoomManager) container.getAdapter(IChatRoomManager.class);
    ID targetID = IDFactory.getDefault().createID(namespace, "irc://" + bot.getName() + "@" + bot.getServer());
    container.connect(targetID, null);
    IChatRoomInfo room = manager.getChatRoomInfo(bot.getChannel());
    IChatRoomContainer roomContainer = room.createChatRoomContainer();
    roomContainer.connect(room.getRoomID(), null);
    roomContainer.addMessageListener(this);
    sender = roomContainer.getChatRoomMessageSender();
}
Also used : IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) IChatRoomContainer(org.eclipse.ecf.presence.chatroom.IChatRoomContainer) ID(org.eclipse.ecf.core.identity.ID)

Example 2 with IChatRoomInfo

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

the class AbstractChatRoomInvitationTest method testSendInvitation.

public void testSendInvitation() throws Exception {
    final IChatRoomInvitationSender invitationSender = chat0.getInvitationSender();
    assertNotNull(invitationSender);
    final IChatRoomInfo roomInfo = chat0.getChatRoomInfo(CHAT_ROOM_NAME);
    if (roomInfo == null)
        return;
    final IChatRoomContainer chatRoomContainer = roomInfo.createChatRoomContainer();
    chatRoomContainer.connect(roomInfo.getRoomID(), null);
    invitationSender.sendInvitation(roomInfo.getRoomID(), getClient(1).getConnectedID(), null, "this is an invitation");
    try {
        synchronized (synchObject) {
            synchObject.wait(WAITTIME);
        }
    } catch (final Exception e) {
        throw e;
    }
    assertHasEvent(invitationsReceived, ID.class);
}
Also used : IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) IChatRoomContainer(org.eclipse.ecf.presence.chatroom.IChatRoomContainer) IChatRoomInvitationSender(org.eclipse.ecf.presence.chatroom.IChatRoomInvitationSender)

Example 3 with IChatRoomInfo

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

the class AbstractChatRoomSOAddTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    setClientCount(2);
    chatRoomContainer = new IChatRoomContainer[2];
    clients = createClients();
    for (int i = 0; i < 2; i++) {
        connectClient(i);
        final IChatRoomInfo info = getPresenceAdapter(i).getChatRoomManager().getChatRoomInfo(CHAT_ROOM_NAME);
        if (info == null) {
            chatRoomContainer[i] = null;
        } else {
            chatRoomContainer[i] = info.createChatRoomContainer();
            chatRoomContainer[i].connect(info.getRoomID(), null);
        }
    }
}
Also used : IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo)

Example 4 with IChatRoomInfo

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

the class MultiRosterView method selectAndJoinChatRoomForAccounts.

private void selectAndJoinChatRoomForAccounts(MultiRosterAccount[] accounts) {
    // Create chat room selection dialog with managers, open
    ChatRoomSelectionDialog dialog = new ChatRoomSelectionDialog(getViewSite().getShell(), accounts);
    dialog.open();
    // If selection cancelled then simply return
    if (dialog.getReturnCode() != Window.OK)
        return;
    // Get selected room, selected manager, and selected IChatRoomInfo
    IChatRoomInfo selectedInfo = dialog.getSelectedRoom().getRoomInfo();
    MultiRosterAccount account = dialog.getSelectedRoom().getAccount();
    // Now get the secondary ID from the selected room id
    final IContainer container = account.getContainer();
    final ID connectedID = container.getConnectedID();
    if (connectedID == null) {
        MessageDialog.openError(getViewSite().getShell(), Messages.MultiRosterView_NO_IDENTIFIER_FOR_ROOM_TITLE, NLS.bind(Messages.MultiRosterView_NO_IDENTIFIER_FOR_ROOM_MESSAGE, selectedInfo.getRoomID()));
        return;
    }
    try {
        joinChatRoom(container, selectedInfo, null);
    } catch (ECFException e) {
        Throwable e1 = e.getStatus().getException();
        Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, Messages.MultiRosterView_EXCEPTION_LOG_JOIN_ROOM, e1));
        ContainerConnectErrorDialog ed = new ContainerConnectErrorDialog(getViewSite().getShell(), selectedInfo.getRoomID().getName(), e1);
        ed.open();
    }
}
Also used : IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) ECFException(org.eclipse.ecf.core.util.ECFException) ContainerConnectErrorDialog(org.eclipse.ecf.ui.dialogs.ContainerConnectErrorDialog) ID(org.eclipse.ecf.core.identity.ID) IContainer(org.eclipse.ecf.core.IContainer)

Example 5 with IChatRoomInfo

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

the class XMPPChatRoomManager method createChatRoom.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ecf.presence.chatroom.IChatRoomManager#createChatRoom(java.lang.String,
	 *      java.util.Map)
	 */
public IChatRoomInfo createChatRoom(String roomname, Map properties) throws ChatRoomCreateException {
    if (roomname == null)
        throw new ChatRoomCreateException(roomname, Messages.XMPPChatRoomManager_EXCEPTION_ROOM_CANNOT_BE_NULL);
    try {
        final String nickname = ecfConnection.getXMPPConnection().getUser();
        final String server = ecfConnection.getXMPPConnection().getHost();
        final String domain = (properties == null) ? XMPPRoomID.DOMAIN_DEFAULT : (String) properties.get(PROP_XMPP_CONFERENCE);
        final String conference = XMPPRoomID.fixConferenceDomain(domain, server);
        final String roomID = roomname + XMPPRoomID.AT_SIGN + conference;
        // create proxy to the room
        final MultiUserChat muc = new MultiUserChat(ecfConnection.getXMPPConnection(), roomID);
        if (!checkRoom(conference, roomID)) {
            // otherwise create a new one
            muc.create(nickname);
            muc.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
            final String subject = (properties == null) ? null : (String) properties.get(PROP_XMPP_SUBJECT);
            if (subject != null)
                muc.changeSubject(subject);
        }
        String longname = muc.getRoom();
        if (longname == null || longname.length() <= 0) {
            longname = roomID;
        }
        final RoomInfo info = MultiUserChat.getRoomInfo(ecfConnection.getXMPPConnection(), roomID);
        if (info != null) {
            final XMPPRoomID xid = new XMPPRoomID(connectedID.getNamespace(), ecfConnection.getXMPPConnection(), roomID, longname);
            return new ECFRoomInfo(xid, info, connectedID);
        } else
            throw new XMPPException(NLS.bind(Messages.XMPPChatRoomManager_EXCEPTION_NO_ROOM_INFO, roomID));
    } catch (final XMPPException e) {
        throw new ChatRoomCreateException(roomname, e.getMessage(), e);
    } catch (final URISyntaxException e) {
        throw new ChatRoomCreateException(roomname, e.getMessage(), e);
    }
}
Also used : MultiUserChat(org.jivesoftware.smackx.muc.MultiUserChat) Form(org.jivesoftware.smackx.Form) IChatRoomInfo(org.eclipse.ecf.presence.chatroom.IChatRoomInfo) RoomInfo(org.jivesoftware.smackx.muc.RoomInfo) XMPPRoomID(org.eclipse.ecf.provider.xmpp.identity.XMPPRoomID) URISyntaxException(java.net.URISyntaxException) XMPPException(org.jivesoftware.smack.XMPPException) ChatRoomCreateException(org.eclipse.ecf.presence.chatroom.ChatRoomCreateException)

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