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