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;
}
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;
}
}
}
});
}
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)));
}
}
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);
}
}
Aggregations