Search in sources :

Example 1 with IChatMessage

use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.

the class MSNConnectWizard method displayMessage.

private void displayMessage(IChatMessageEvent e) {
    final IChatMessage message = e.getChatMessage();
    Display.getDefault().asyncExec(new Runnable() {

        public void run() {
            MessagesView view = (MessagesView) workbench.getActiveWorkbenchWindow().getActivePage().findView(MessagesView.VIEW_ID);
            if (view != null) {
                final IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) view.getSite().getAdapter(IWorkbenchSiteProgressService.class);
                view.openTab(icms, itms, targetID, message.getFromID());
                view.showMessage(message);
                service.warnOfContentChange();
            } else {
                try {
                    final IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
                    view = (MessagesView) page.showView(MessagesView.VIEW_ID, null, IWorkbenchPage.VIEW_CREATE);
                    if (!page.isPartVisible(view)) {
                        final IWorkbenchSiteProgressService service = (IWorkbenchSiteProgressService) view.getSite().getAdapter(IWorkbenchSiteProgressService.class);
                        service.warnOfContentChange();
                    }
                    view.openTab(icms, itms, targetID, message.getFromID());
                    view.showMessage(message);
                } catch (final PartInitException e) {
                    e.printStackTrace();
                }
            }
        }
    });
}
Also used : IChatMessage(org.eclipse.ecf.presence.im.IChatMessage) IWorkbenchSiteProgressService(org.eclipse.ui.progress.IWorkbenchSiteProgressService) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) MessagesView(org.eclipse.ecf.presence.ui.MessagesView)

Example 2 with IChatMessage

use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.

the class AbstractChatTest method testSendIM.

public void testSendIM() throws Exception {
    chat0.getChatMessageSender().sendChatMessage(getClient(1).getConnectedID(), "abcdef");
    sleep(SLEEPTIME);
    assertHasEvent(receivedChatMessages, IChatMessage.class);
    final IChatMessage message = (IChatMessage) receivedChatMessages.get(0);
    assertTrue(message.getBody().equals("abcdef"));
    assertTrue(message.getType().equals(IChatMessage.Type.CHAT));
    assertNull(message.getSubject());
    final Map props = message.getProperties();
    assertNotNull(props);
    assertTrue(props.size() == 0);
}
Also used : IChatMessage(org.eclipse.ecf.presence.im.IChatMessage) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with IChatMessage

use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.

the class XMPPChatClient method setupPresence.

public void setupPresence() throws ECFException {
    if (presence == null) {
        presence = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
        if (presence == null)
            throw new ECFException("adapter is null");
        sender = presence.getChatManager().getChatMessageSender();
        presence.getChatManager().addMessageListener(new IIMMessageListener() {

            public void handleMessageEvent(IIMMessageEvent messageEvent) {
                if (messageEvent instanceof IChatMessageEvent) {
                    IChatMessage m = ((IChatMessageEvent) messageEvent).getChatMessage();
                    if (receiver != null) {
                        receiver.handleMessage(m);
                    }
                }
            }
        });
        if (presenceListener != null) {
            presence.getRosterManager().addPresenceListener(presenceListener);
        }
    }
}
Also used : IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) ECFException(org.eclipse.ecf.core.util.ECFException) IChatMessage(org.eclipse.ecf.presence.im.IChatMessage) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent)

Example 4 with IChatMessage

use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.

the class ChatRoomManagerUI method setupNewView.

private void setupNewView() throws Exception {
    IChatRoomInfo roomInfo = manager.getChatRoomInfo(null);
    Assert.isNotNull(roomInfo, Messages.ChatRoomManagerUI_EXCEPTION_NO_ROOT_CHAT_ROOM_MANAGER);
    final IChatRoomContainer managerChatRoom = roomInfo.createChatRoomContainer();
    chatroomview.initializeWithManager(ChatRoomManagerView.getUsernameFromID(targetID), ChatRoomManagerView.getHostnameFromID(targetID), managerChatRoom, this, createChatRoomViewCloseListener());
    chatroomview.setMessageRenderer(getDefaultMessageRenderer());
    // Add listener for container, so that if the container is spontaneously
    // disconnected,
    // then we will be able to have the UI respond by making itself inactive
    container.addListener(new IContainerListener() {

        public void handleEvent(final IContainerEvent evt) {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    if (evt instanceof IContainerDisconnectedEvent || evt instanceof IContainerEjectedEvent) {
                        final ID departedContainerID = ((evt instanceof IContainerDisconnectedEvent) ? ((IContainerDisconnectedEvent) evt).getTargetID() : ((IContainerEjectedEvent) evt).getTargetID());
                        ID connectedID = targetID;
                        if (connectedID == null || connectedID.equals(departedContainerID)) {
                            chatroomview.disconnected();
                            isContainerConnected = false;
                        }
                    } else if (evt instanceof IContainerConnectedEvent) {
                        isContainerConnected = true;
                        chatroomview.setEnabled(true);
                        String[] roomsForTarget = getRoomsForTarget();
                        for (int i = 0; i < roomsForTarget.length; i++) {
                            IChatRoomInfo info = manager.getChatRoomInfo(roomsForTarget[i]);
                            chatroomview.joinRoom(info, getPasswordForChatRoomConnect(info));
                        }
                    }
                }
            });
        }
    });
    // Add listeners so that the new chat room gets
    // asynch notifications of various relevant chat room events
    managerChatRoom.addMessageListener(new IIMMessageListener() {

        public void handleMessageEvent(IIMMessageEvent messageEvent) {
            if (messageEvent instanceof IChatRoomMessageEvent) {
                IChatRoomMessage m = ((IChatRoomMessageEvent) messageEvent).getChatRoomMessage();
                chatroomview.handleMessage(m.getFromID(), m.getMessage());
            } else if (messageEvent instanceof IChatMessageEvent) {
                final IChatMessage chatMessage = ((IChatMessageEvent) messageEvent).getChatMessage();
                chatroomview.handleChatMessage(chatMessage);
            }
        }
    });
}
Also used : IContainerListener(org.eclipse.ecf.core.IContainerListener) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent) IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) IChatMessage(org.eclipse.ecf.presence.im.IChatMessage) ID(org.eclipse.ecf.core.identity.ID)

Example 5 with IChatMessage

use of org.eclipse.ecf.presence.im.IChatMessage in project ecf by eclipse.

the class XMPPChatRoomClient method setupPresenceAdapter.

protected void setupPresenceAdapter() {
    // Get presence adapter off of container
    presence = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
    // Get sender interface
    sender = presence.getChatManager().getChatMessageSender();
    // Setup message requestListener to handle incoming messages
    presence.getChatManager().addMessageListener(new IIMMessageListener() {

        public void handleMessageEvent(IIMMessageEvent messageEvent) {
            if (messageEvent instanceof IChatMessageEvent) {
                final IChatMessage m = ((IChatMessageEvent) messageEvent).getChatMessage();
                receiver.handleMessage(m);
            }
        }
    });
}
Also used : IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) IChatMessage(org.eclipse.ecf.presence.im.IChatMessage) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent)

Aggregations

IChatMessage (org.eclipse.ecf.presence.im.IChatMessage)8 IChatMessageEvent (org.eclipse.ecf.presence.im.IChatMessageEvent)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 IIMMessageEvent (org.eclipse.ecf.presence.IIMMessageEvent)3 IIMMessageListener (org.eclipse.ecf.presence.IIMMessageListener)3 ID (org.eclipse.ecf.core.identity.ID)2 List (java.util.List)1 IContainerListener (org.eclipse.ecf.core.IContainerListener)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IIMMessageHandlerEntry (org.eclipse.ecf.presence.bot.IIMMessageHandlerEntry)1 MessagesView (org.eclipse.ecf.presence.ui.MessagesView)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 PartInitException (org.eclipse.ui.PartInitException)1 IWorkbenchSiteProgressService (org.eclipse.ui.progress.IWorkbenchSiteProgressService)1