Search in sources :

Example 6 with IIMMessageListener

use of org.eclipse.ecf.presence.IIMMessageListener in project ecf by eclipse.

the class MSNConnectWizard method performFinish.

public boolean performFinish() {
    final String connectID = page.getEmail();
    final String password = page.getPassword();
    // Save combo text even if we don't successfully login
    page.saveComboText();
    connectContext = ConnectContextFactory.createPasswordConnectContext(password);
    try {
        targetID = container.getConnectNamespace().createInstance(new Object[] { connectID });
    } catch (final IDCreateException e) {
        new IDCreateErrorDialog(null, connectID, e).open();
        return false;
    }
    page.saveComboItems();
    final IPresenceContainerAdapter adapter = (IPresenceContainerAdapter) container.getAdapter(IPresenceContainerAdapter.class);
    container.addListener(new IContainerListener() {

        public void handleEvent(IContainerEvent event) {
            if (event instanceof IContainerConnectedEvent) {
                Display.getDefault().asyncExec(new Runnable() {

                    public void run() {
                        openView();
                    }
                });
            }
        }
    });
    final IChatManager icm = adapter.getChatManager();
    icms = icm.getChatMessageSender();
    itms = icm.getTypingMessageSender();
    icm.addMessageListener(new IIMMessageListener() {

        public void handleMessageEvent(IIMMessageEvent e) {
            if (e instanceof IChatMessageEvent) {
                displayMessage((IChatMessageEvent) e);
            } else if (e instanceof ITypingMessageEvent) {
                displayTypingNotification((ITypingMessageEvent) e);
            }
        }
    });
    new AsynchContainerConnectAction(container, targetID, connectContext, null, new Runnable() {

        public void run() {
            cachePassword(connectID, password);
        }
    }).run();
    return true;
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IContainerEvent(org.eclipse.ecf.core.events.IContainerEvent) IContainerListener(org.eclipse.ecf.core.IContainerListener) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IContainerConnectedEvent(org.eclipse.ecf.core.events.IContainerConnectedEvent) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent) IDCreateErrorDialog(org.eclipse.ecf.ui.dialogs.IDCreateErrorDialog) IPresenceContainerAdapter(org.eclipse.ecf.presence.IPresenceContainerAdapter) IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) ITypingMessageEvent(org.eclipse.ecf.presence.im.ITypingMessageEvent) AsynchContainerConnectAction(org.eclipse.ecf.ui.actions.AsynchContainerConnectAction) IChatManager(org.eclipse.ecf.presence.im.IChatManager)

Example 7 with IIMMessageListener

use of org.eclipse.ecf.presence.IIMMessageListener in project ecf by eclipse.

the class ChatRoomMessageHandler method preContainerConnect.

public void preContainerConnect(IContainer container, ID targetID) {
    File file = new File(Platform.getInstanceLocation().getURL().getPath(), "password.properties");
    if (file.exists()) {
        Properties properties = new Properties();
        try {
            properties.load(new FileInputStream(file));
            password = properties.getProperty("password");
        } catch (FileNotFoundException e) {
        } catch (IOException e) {
        }
    }
    this.container = container;
    IChatRoomContainer chatRoomContainer = (IChatRoomContainer) container.getAdapter(IChatRoomContainer.class);
    chatMessageSender = chatRoomContainer.getPrivateMessageSender();
    chatRoomContainer.addMessageListener(new IIMMessageListener() {

        public void handleMessageEvent(IIMMessageEvent e) {
            if (e instanceof IChatMessageEvent) {
                IChatMessageEvent event = (IChatMessageEvent) e;
                String msg = event.getChatMessage().getBody();
                switch(msg.charAt(0)) {
                    case '~':
                    case '!':
                        handleMessage(event.getFromID(), event.getFromID(), msg.substring(1).trim());
                        break;
                    default:
                        handleMessage(event.getFromID(), event.getFromID(), msg.trim());
                        break;
                }
            }
        }
    });
}
Also used : IChatRoomContainer(org.eclipse.ecf.presence.chatroom.IChatRoomContainer) IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) FileNotFoundException(java.io.FileNotFoundException) IChatMessageEvent(org.eclipse.ecf.presence.im.IChatMessageEvent) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File) FileInputStream(java.io.FileInputStream) IIMMessageEvent(org.eclipse.ecf.presence.IIMMessageEvent)

Example 8 with IIMMessageListener

use of org.eclipse.ecf.presence.IIMMessageListener in project ecf by eclipse.

the class IRCAbstractContainer method fireChatMessageEvent.

public void fireChatMessageEvent(ID sender, String msg) {
    for (Iterator i = msgListeners.iterator(); i.hasNext(); ) {
        IIMMessageListener l = (IIMMessageListener) i.next();
        l.handleMessageEvent(new ChatMessageEvent(sender, new ChatMessage(sender, msg)));
    }
}
Also used : IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener) ChatMessageEvent(org.eclipse.ecf.presence.im.ChatMessageEvent) ChatMessage(org.eclipse.ecf.presence.im.ChatMessage)

Example 9 with IIMMessageListener

use of org.eclipse.ecf.presence.IIMMessageListener in project ecf by eclipse.

the class XMPPChatManager method fireMessageEvent.

private void fireMessageEvent(IIMMessageEvent event) {
    List toNotify = null;
    synchronized (messageListeners) {
        toNotify = new ArrayList(messageListeners);
    }
    for (final Iterator i = toNotify.iterator(); i.hasNext(); ) {
        final IIMMessageListener l = (IIMMessageListener) i.next();
        l.handleMessageEvent(event);
    }
}
Also used : IIMMessageListener(org.eclipse.ecf.presence.IIMMessageListener)

Aggregations

IIMMessageListener (org.eclipse.ecf.presence.IIMMessageListener)9 IIMMessageEvent (org.eclipse.ecf.presence.IIMMessageEvent)5 IChatMessageEvent (org.eclipse.ecf.presence.im.IChatMessageEvent)5 IChatMessage (org.eclipse.ecf.presence.im.IChatMessage)3 IContainerListener (org.eclipse.ecf.core.IContainerListener)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 IContainerConnectedEvent (org.eclipse.ecf.core.events.IContainerConnectedEvent)1 IContainerEvent (org.eclipse.ecf.core.events.IContainerEvent)1 ID (org.eclipse.ecf.core.identity.ID)1 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IPresenceContainerAdapter (org.eclipse.ecf.presence.IPresenceContainerAdapter)1 IChatRoomContainer (org.eclipse.ecf.presence.chatroom.IChatRoomContainer)1 ChatMessage (org.eclipse.ecf.presence.im.ChatMessage)1 ChatMessageEvent (org.eclipse.ecf.presence.im.ChatMessageEvent)1 IChatManager (org.eclipse.ecf.presence.im.IChatManager)1