Search in sources :

Example 1 with IChatID

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

the class ChatRoomMessageHandler method preChatRoomConnect.

public void preChatRoomConnect(IChatRoomContainer roomContainer, ID roomID) {
    // retrieve our name
    ID connectedID = container.getConnectedID();
    botName = connectedID.getName();
    IChatID chatID = (IChatID) connectedID.getAdapter(IChatID.class);
    if (chatID != null) {
        botName = chatID.getUsername();
    }
    messageSenders.put(roomID, roomContainer.getChatRoomMessageSender());
    if (password != null) {
        try {
            sendMessage(IDFactory.getDefault().createStringID("nickserv"), "identify " + password);
        } catch (IDCreateException e) {
        }
    }
}
Also used : IDCreateException(org.eclipse.ecf.core.identity.IDCreateException) IChatID(org.eclipse.ecf.presence.im.IChatID) ID(org.eclipse.ecf.core.identity.ID) IChatID(org.eclipse.ecf.presence.im.IChatID)

Example 2 with IChatID

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

the class ChatRoomManagerView method getUsernameFromID.

/**
 * @return String username for given <code>targetID</code>
 */
public static String getUsernameFromID(ID targetID) {
    IChatID chatID = (IChatID) targetID.getAdapter(IChatID.class);
    if (chatID != null)
        return chatID.getUsername();
    try {
        URI uri = new URI(targetID.getName());
        String user = uri.getUserInfo();
        return user == null ? targetID.getName() : user;
    } catch (URISyntaxException e) {
        String userAtHost = targetID.getName();
        int atIndex = userAtHost.lastIndexOf(ATSIGN);
        if (atIndex != -1)
            userAtHost = userAtHost.substring(0, atIndex);
        return userAtHost;
    }
}
Also used : URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) IChatID(org.eclipse.ecf.presence.im.IChatID)

Example 3 with IChatID

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

the class ChatSORobotApplication method handlePresence.

/**
 * @since 2.0
 */
public void handlePresence(ID fromID, IPresence presence) {
    System.out.println("handlePresence fromID=" + fromID + " presence=" + presence);
    IChatID fromChatID = (IChatID) fromID.getAdapter(IChatID.class);
    if (fromChatID != null) {
        rosterUsers.put(fromChatID.getUsername() + "@" + fromChatID.getHostname(), fromID);
    }
}
Also used : IChatID(org.eclipse.ecf.presence.im.IChatID)

Example 4 with IChatID

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

the class ChatRobotApplication method handlePresence.

/**
 * @since 2.0
 */
public void handlePresence(ID fromID, IPresence presence) {
    System.out.println("handlePresence fromID=" + fromID + " presence=" + presence);
    IChatID fromChatID = (IChatID) fromID.getAdapter(IChatID.class);
    if (fromChatID != null) {
        rosterUsers.put(fromChatID.getUsername() + "@" + fromChatID.getHostname(), fromID);
    }
}
Also used : IChatID(org.eclipse.ecf.presence.im.IChatID)

Example 5 with IChatID

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

the class IRCDatashareChannel method sendMessage.

public void sendMessage(ID receiver, byte[] message) throws ECFException {
    // $NON-NLS-1$
    Assert.isNotNull(receiver, "A receiver must be specified");
    // retrieve the target's name
    String name = receiver instanceof IChatID ? ((IChatID) receiver).getUsername() : receiver.getName();
    // now create a string that is similar to our own ID, using the form
    // username@irc.freenode.net:6667
    StringBuffer buffer = new StringBuffer(name);
    buffer.append('@').append(userId.getHost());
    buffer.append(':').append(userId.getPort());
    // now create a new ID
    ID modifiedId = receiverNamespace.createInstance(new Object[] { buffer.toString() });
    // send the message with the new ID
    super.sendMessage(modifiedId, message);
}
Also used : ID(org.eclipse.ecf.core.identity.ID) IChatID(org.eclipse.ecf.presence.im.IChatID) IRCID(org.eclipse.ecf.internal.provider.irc.identity.IRCID) IChatID(org.eclipse.ecf.presence.im.IChatID)

Aggregations

IChatID (org.eclipse.ecf.presence.im.IChatID)6 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 ID (org.eclipse.ecf.core.identity.ID)2 IDCreateException (org.eclipse.ecf.core.identity.IDCreateException)1 IRCID (org.eclipse.ecf.internal.provider.irc.identity.IRCID)1