diff options
author | slewis | 2006-05-07 18:22:26 +0000 |
---|---|---|
committer | slewis | 2006-05-07 18:22:26 +0000 |
commit | 12899309bfec6d833c6256358b41a1766d235e83 (patch) | |
tree | adddbcda1424c377e5c45e5890379525051e43ba | |
parent | 62f53324ce371c01f43178b2dbfb268cfec1e0a3 (diff) | |
download | org.eclipse.ecf-12899309bfec6d833c6256358b41a1766d235e83.tar.gz org.eclipse.ecf-12899309bfec6d833c6256358b41a1766d235e83.tar.xz org.eclipse.ecf-12899309bfec6d833c6256358b41a1766d235e83.zip |
Moved createChatRoomContainer from IChatRoomManager to IRoomInfo interfaces. Updated all implementers and tested xmpp and irc implementations
6 files changed, 31 insertions, 64 deletions
diff --git a/examples/bundles/org.eclipse.ecf.example.clients/src/org/eclipse/ecf/example/clients/XMPPChatClient.java b/examples/bundles/org.eclipse.ecf.example.clients/src/org/eclipse/ecf/example/clients/XMPPChatClient.java index ccaebc4ac..ef3520f83 100644 --- a/examples/bundles/org.eclipse.ecf.example.clients/src/org/eclipse/ecf/example/clients/XMPPChatClient.java +++ b/examples/bundles/org.eclipse.ecf.example.clients/src/org/eclipse/ecf/example/clients/XMPPChatClient.java @@ -22,6 +22,7 @@ import org.eclipse.ecf.presence.IMessageSender; import org.eclipse.ecf.presence.IPresenceContainer; import org.eclipse.ecf.presence.chat.IChatRoomContainer; import org.eclipse.ecf.presence.chat.IChatRoomManager; +import org.eclipse.ecf.presence.chat.IRoomInfo; public class XMPPChatClient { @@ -75,11 +76,12 @@ public class XMPPChatClient { public IChatRoomContainer connectChatRoom(String username, String hostname, String chatRoomID) throws Exception { // Get chat room manager chatmanager = presence.getChatRoomManager(); - // Create chat room container from manager - chatroom = chatmanager.createChatRoomContainer(); - socontainer = (ISharedObjectContainer) chatroom.getAdapter(ISharedObjectContainer.class); // create target room id ID targetChatID = IDFactory.getDefault().createID(chatroom.getConnectNamespace(), new Object[] {username,hostname,null,chatRoomID,username}); + // Create chat room container from manager + IRoomInfo roomInfo = chatmanager.getChatRoomInfo(targetChatID); + chatroom = roomInfo.createChatRoomContainer(); + socontainer = (ISharedObjectContainer) chatroom.getAdapter(ISharedObjectContainer.class); // connect to target chatroom.connect(targetChatID, null); return chatroom; diff --git a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ChatRoomManagerUI.java b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ChatRoomManagerUI.java index 86a3f21a3..8ff4e4d5e 100644 --- a/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ChatRoomManagerUI.java +++ b/examples/bundles/org.eclipse.ecf.example.collab/src/org/eclipse/ecf/example/collab/ChatRoomManagerUI.java @@ -38,9 +38,10 @@ public class ChatRoomManagerUI { Display.getDefault().syncExec(new Runnable() { public void run() { try { + IRoomInfo roomInfo = manager.getChatRoomInfo(targetID); IChatRoomContainer chatRoom = null; try { - chatRoom = manager.createChatRoomContainer(); + chatRoom = roomInfo.createChatRoomContainer(); } catch (ContainerInstantiationException e1) { // can't happen } @@ -56,42 +57,7 @@ public class ChatRoomManagerUI { public void chatRoomViewClosing(String secondaryID) { newClient.dispose(); } - }, null, chatRoom, new IRoomInfo() { - public String getDescription() { - return null; - } - public String getSubject() { - return "TODO"; - } - public ID getRoomID() { - return targetID; - } - public int getParticipantsCount() { - // TODO Auto-generated method stub - return 0; - } - public String getName() { - return targetID.getName(); - } - public boolean isPersistent() { - // TODO Auto-generated method stub - return false; - } - public boolean requiresPassword() { - // TODO Auto-generated method stub - return false; - } - public boolean isModerated() { - // TODO Auto-generated method stub - return false; - } - public ID getConnectedID() { - return targetID; - } - public Object getAdapter(Class clazz) { - return null; - } - }, sender); + }, null, chatRoom, roomInfo, sender); // Add listeners so that the new chat room gets // asynch notifications of various relevant chat room events chatRoom.addMessageListener(new IMessageListener() { diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/chat/IChatRoomManager.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/chat/IChatRoomManager.java index d52cff044..3531665bb 100644 --- a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/chat/IChatRoomManager.java +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/chat/IChatRoomManager.java @@ -53,6 +53,6 @@ public interface IChatRoomManager { * @return non-null IChatRoomContainer implementer * @throws ContainerInstantiationException if chat room container cannot be made */ - public IChatRoomContainer createChatRoomContainer() throws ContainerInstantiationException; + //public IChatRoomContainer createChatRoomContainer() throws ContainerInstantiationException; } diff --git a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/chat/IRoomInfo.java b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/chat/IRoomInfo.java index 42cc1b341..be0cdd5df 100644 --- a/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/chat/IRoomInfo.java +++ b/framework/bundles/org.eclipse.ecf.presence/src/org/eclipse/ecf/presence/chat/IRoomInfo.java @@ -11,6 +11,7 @@ package org.eclipse.ecf.presence.chat; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.ecf.core.ContainerInstantiationException; import org.eclipse.ecf.core.identity.ID; public interface IRoomInfo extends IAdaptable { @@ -59,4 +60,11 @@ public interface IRoomInfo extends IAdaptable { * @return ID of service we are currently connected to */ public ID getConnectedID(); + /** + * Create a new IChatRoomContainer instance + * @return non-null IChatRoomContainer instance. Will not return null. + * @throws ContainerInstantiationException if chat room container cannot be made + */ + public IChatRoomContainer createChatRoomContainer() throws ContainerInstantiationException; + } diff --git a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java index 5a1b6a1f9..8e9db2e49 100644 --- a/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java +++ b/framework/bundles/org.eclipse.ecf.ui/src/org/eclipse/ecf/ui/views/RosterView.java @@ -892,17 +892,12 @@ public class RosterView extends ViewPart implements IChatRoomViewCloseListener { IChatRoomContainer container; ChatRoomView view; String secondaryID; - IChatRoomManager manager; - RoomWithAView(IChatRoomManager manager, IChatRoomContainer container, + RoomWithAView(IChatRoomContainer container, ChatRoomView view, String secondaryID) { - this.manager = manager; this.container = container; this.view = view; this.secondaryID = secondaryID; } - public IChatRoomManager getManager() { - return manager; - } public IChatRoomContainer getContainer() { return container; } @@ -969,11 +964,9 @@ public class RosterView extends ViewPart implements IChatRoomViewCloseListener { } // Get selected room, selected manager, and selected IRoomInfo ChatRoomSelectionDialog.Room room = dialog.getSelectedRoom(); - IChatRoomManager selectedManager = room.getManager(); IRoomInfo selectedInfo = room.getRoomInfo(); // If they are null then we can't proceed - if (room == null || selectedManager == null - || selectedInfo == null) { + if (room == null || selectedInfo == null) { MessageDialog.openInformation(RosterView.this.getViewSite() .getShell(), "No room selected", "Cannot connect to null room"); @@ -1008,7 +1001,7 @@ public class RosterView extends ViewPart implements IChatRoomViewCloseListener { // now, create chat room instance IChatRoomContainer chatRoom = null; try { - chatRoom = selectedManager.createChatRoomContainer(); + chatRoom = selectedInfo.createChatRoomContainer(); } catch (ContainerInstantiationException e1) { MessageDialog.openError(RosterView.this.getViewSite() .getShell(), "Could not create chat room", @@ -1090,7 +1083,7 @@ public class RosterView extends ViewPart implements IChatRoomViewCloseListener { } // If connect successful...we create a room with a view and add // it to our known set - addRoomView(new RoomWithAView(selectedManager, chatRoom, + addRoomView(new RoomWithAView(chatRoom, (ChatRoomView) view, secondaryID)); } diff --git a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java index 8270d68a6..0c1c921db 100644 --- a/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java +++ b/providers/bundles/org.eclipse.ecf.provider.xmpp/src/org/eclipse/ecf/provider/xmpp/container/XMPPClientSOContainer.java @@ -557,18 +557,6 @@ public class XMPPClientSOContainer extends ClientSOContainer { public IRoomInfo getChatRoomInfo(ID roomID) { return XMPPClientSOContainer.this.getChatRoomInfo(roomID); } - public IChatRoomContainer createChatRoomContainer() throws ContainerInstantiationException { - IChatRoomContainer chatContainer = null; - try { - chatContainer = new XMPPGroupChatSOContainer(XMPPClientSOContainer.this.getConnection(),sharedObject.getConnection(),getConnectNamespace()); - } catch (IDInstantiationException e) { - ContainerInstantiationException newExcept = new ContainerInstantiationException("Exception creating chat container for presence container "+getID(),e); - newExcept.setStackTrace(e.getStackTrace()); - throw newExcept; - } - chats.add(chatContainer); - return chatContainer; - } public IRoomInfo[] getChatRoomsInfo() { ID [] chatRooms = getChatRooms(); if (chatRooms == null) return null; @@ -666,6 +654,16 @@ public class XMPPClientSOContainer extends ClientSOContainer { public Object getAdapter(Class clazz) { return null; } + public IChatRoomContainer createChatRoomContainer() throws ContainerInstantiationException { + IChatRoomContainer chatContainer = null; + try { + chatContainer = new XMPPGroupChatSOContainer(XMPPClientSOContainer.this.getConnection(),sharedObject.getConnection(),getConnectNamespace()); + } catch (IDInstantiationException e) { + throw new ContainerInstantiationException("Exception creating chat container for presence container "+getID(),e); + } + chats.add(chatContainer); + return chatContainer; + } public String toString() { StringBuffer buf = new StringBuffer("ECFRoomInfo["); buf.append("id=").append(getID()).append(";name="+getName()); |