aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhristoterezov <hristo@jitsi.org>2013-11-01 20:38:12 +0200
committerhristoterezov <hristo@jitsi.org>2013-11-01 20:38:12 +0200
commit98c973a16d020adf6682076a828f69d806fae1b1 (patch)
tree7fb27638715e177994f9b8e941b92f30848b780a
parenta128defd529ff4b12b10da889c3d3298be2de0f5 (diff)
downloadjitsi-98c973a16d020adf6682076a828f69d806fae1b1.zip
jitsi-98c973a16d020adf6682076a828f69d806fae1b1.tar.gz
jitsi-98c973a16d020adf6682076a828f69d806fae1b1.tar.bz2
Adds chat room contacts to the search filter in the contact list.
-rw-r--r--build.xml15
-rw-r--r--lib/felix.client.run.properties1
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomProviderWrapper.java16
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java56
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomCommonRightButtonMenu.java4
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomList.java40
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java2
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java4
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableUI.java4
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsListCellRenderer.java2
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java111
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java24
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java7
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java2
-rw-r--r--src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf3
-rwxr-xr-xsrc/net/java/sip/communicator/impl/gui/utils/Constants.java15
-rw-r--r--src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java5
-rw-r--r--src/net/java/sip/communicator/impl/muc/ChatRoomContactSourceService.java111
-rw-r--r--src/net/java/sip/communicator/impl/muc/ChatRoomPresenceStatus.java68
-rw-r--r--src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java164
-rw-r--r--src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java164
-rw-r--r--src/net/java/sip/communicator/impl/muc/MUCActivator.java243
-rw-r--r--src/net/java/sip/communicator/impl/muc/muc.manifest.mf15
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java3
24 files changed, 1013 insertions, 66 deletions
diff --git a/build.xml b/build.xml
index 2f69874..2f58858 100644
--- a/build.xml
+++ b/build.xml
@@ -1078,7 +1078,8 @@
bundle-plugin-contactsourceconfig,bundle-plugin-certconfig,
bundle-globalshortcut,bundle-plugin-msofficecomm,bundle-libjitsi,
bundle-customcontactactions, bundle-phonenumbercontactsource,
- bundle-demuxcontactsource, bundle-desktoputil,
+ bundle-demuxcontactsource, bundle-muc,
+ bundle-desktoputil,
bundle-globaldisplaydetails,bundle-plugin-propertieseditor"/>
<!--BUNDLE-SC-LAUNCHER-->
@@ -2898,7 +2899,7 @@ javax.swing.event, javax.swing.border"/>
prefix="net/java/sip/communicator/service/customcontactactions"/>
</jar>
</target>
-
+
<!-- BUNDLE-PHONE-NUMBER-CONTACT-SOURCE -->
<target name="bundle-phonenumbercontactsource">
<!-- Creates a bundle containing the contact source interfaces.-->
@@ -2918,6 +2919,16 @@ javax.swing.event, javax.swing.border"/>
prefix="net/java/sip/communicator/plugin/demuxcontactsource"/>
</jar>
</target>
+
+ <!-- BUNDLE-CHAT-ROOM-CONTACT-SOURCE -->
+ <target name="bundle-muc">
+ <!-- Creates a bundle containing the contact source interfaces.-->
+ <jar compress="false" destfile="${bundles.dest}/muc.jar"
+ manifest="${src}/net/java/sip/communicator/impl/muc/muc.manifest.mf">
+ <zipfileset dir="${dest}/net/java/sip/communicator/impl/muc"
+ prefix="net/java/sip/communicator/impl/muc"/>
+ </jar>
+ </target>
<!-- BUNDLE-SWING-UTIL -->
<target name="bundle-desktoputil">
diff --git a/lib/felix.client.run.properties b/lib/felix.client.run.properties
index 4487111..2a43635 100644
--- a/lib/felix.client.run.properties
+++ b/lib/felix.client.run.properties
@@ -185,6 +185,7 @@ felix.auto.start.67= \
reference:file:sc-bundles/plugin-certconfig.jar \
reference:file:sc-bundles/phonenumbercontactsource.jar \
reference:file:sc-bundles/demuxcontactsource.jar \
+ reference:file:sc-bundles/muc.jar \
reference:file:sc-bundles/propertieseditor.jar
# Level 68 is for profiler4j. Either don't use it or change the build.xml file
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomProviderWrapper.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomProviderWrapper.java
index 0813010..ff9ee6c 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomProviderWrapper.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ChatRoomProviderWrapper.java
@@ -15,6 +15,7 @@ import net.java.sip.communicator.util.*;
/**
* @author Yana Stamcheva
* @author Damian Minkov
+ * @author Hristo Terezov
*/
public class ChatRoomProviderWrapper
{
@@ -151,12 +152,25 @@ public class ChatRoomProviderWrapper
*/
public ChatRoomWrapper findChatRoomWrapperForChatRoom(ChatRoom chatRoom)
{
+ return findChatRoomWrapperForChatRoomID(chatRoom.getIdentifier());
+ }
+
+ /**
+ * Returns the chat room wrapper contained in this provider that corresponds
+ * to the chat room with the given id.
+ *
+ * @param chatRoomID the id of the chat room we're looking for.
+ * @return the chat room wrapper contained in this provider that corresponds
+ * to the given chat room id.
+ */
+ public ChatRoomWrapper findChatRoomWrapperForChatRoomID(String chatRoomID)
+ {
// Compare ids, cause saved chatrooms don't have ChatRoom object
// but Id's are the same.
for (ChatRoomWrapper chatRoomWrapper : chatRoomsOrderedCopy)
{
if (chatRoomWrapper.getChatRoomID()
- .equals(chatRoom.getIdentifier()))
+ .equals(chatRoomID))
{
return chatRoomWrapper;
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
index eb49c93..214f61d 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chat/conference/ConferenceChatManager.java
@@ -35,6 +35,7 @@ import javax.swing.*;
* @author Yana Stamcheva
* @author Lubomir Marinov
* @author Valentin Martinet
+ * @author Hristo Terezov
*/
public class ConferenceChatManager
implements ChatRoomMessageListener,
@@ -2314,4 +2315,59 @@ public class ConferenceChatManager
}
public void invitationRejected(AdHocChatRoomInvitationRejectedEvent evt) {}
+
+
+ /**
+ * Opens a chat window for the chat room.
+ *
+ * @param room the chat room.
+ */
+ public void openChatRoom(ChatRoomWrapper room)
+ {
+ if (room.getChatRoom() == null)
+ {
+ room = createChatRoom(
+ room.getChatRoomName(),
+ room.getParentProvider().getProtocolProvider(),
+ new ArrayList<String>(),"", false, false, true);
+
+ // leave the chatroom because getChatRoom().isJoined() returns true
+ // otherwise
+ if (room.getChatRoom().isJoined())
+ room.getChatRoom().leave();
+
+ }
+
+ String savedNick =
+ ConfigurationUtils.getChatRoomProperty(room
+ .getParentProvider().getProtocolProvider(), room
+ .getChatRoomID(), "userNickName");
+
+ if (savedNick == null)
+ {
+ String[] joinOptions = room.getJoinOptions();
+ String nickName = joinOptions[0];
+ if(nickName == null)
+ return;
+
+ if (!room.getChatRoom().isJoined())
+ {
+ joinChatRoom(room, nickName, null,
+ joinOptions[1]);
+ }
+
+ }
+ else
+ {
+ if (!room.getChatRoom().isJoined())
+ joinChatRoom(room, savedNick, null);
+ }
+
+ ChatWindowManager chatWindowManager
+ = GuiActivator.getUIService().getChatWindowManager();
+ ChatPanel chatPanel
+ = chatWindowManager.getMultiChat(room, true);
+
+ chatWindowManager.openChat(chatPanel, true);
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomCommonRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomCommonRightButtonMenu.java
index 4cd02de..9acb904 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomCommonRightButtonMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomCommonRightButtonMenu.java
@@ -45,7 +45,7 @@ public class ChatRoomCommonRightButtonMenu
private JMenuItem createChatRoomItem = new JMenuItem(
GuiActivator.getResources().getI18NString("service.gui.CREATE_CHAT_ROOM"),
- new ImageIcon(ImageLoader.getImage(ImageLoader.CHAT_ROOM_16x16_ICON)));
+ new ImageIcon(ImageLoader.getImage(ImageLoader.CHAT_ROOM_OFFLINE_ICON)));
private JMenuItem searchForChatRoomsItem = new JMenuItem(
GuiActivator.getResources().getI18NString("service.gui.JOIN_CHAT_ROOM"),
@@ -200,7 +200,7 @@ public class ChatRoomCommonRightButtonMenu
public void loadSkin()
{
createChatRoomItem.setIcon(new ImageIcon(
- ImageLoader.getImage(ImageLoader.CHAT_ROOM_16x16_ICON)));
+ ImageLoader.getImage(ImageLoader.CHAT_ROOM_OFFLINE_ICON)));
searchForChatRoomsItem.setIcon(new ImageIcon(
ImageLoader.getImage(ImageLoader.SEARCH_ICON_16x16)));
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomList.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomList.java
index f82e39b..c6fee09 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomList.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomList.java
@@ -21,6 +21,7 @@ import org.osgi.framework.*;
* The <tt>ChatRoomsList</tt> is the list containing all chat rooms.
*
* @author Yana Stamcheva
+ * @author Hristo Terezov
*/
public class ChatRoomList
implements RegistrationStateChangeListener
@@ -326,6 +327,45 @@ public class ChatRoomList
return null;
}
+
+ /**
+ * Returns the <tt>ChatRoomWrapper</tt> that correspond to the given id of
+ * chat room and provider. If the list of chat rooms doesn't contain a
+ * corresponding wrapper - returns null.
+ *
+ * @param chatRoomID the id of <tt>ChatRoom</tt> that we're looking for
+ * @param pps the procol provider associated with the chat room.
+ * @return the <tt>ChatRoomWrapper</tt> object corresponding to the given id
+ * of the chat room
+ */
+ public ChatRoomWrapper findChatRoomWrapperFromChatRoomID(String chatRoomID,
+ ProtocolProviderService pps)
+ {
+ for (ChatRoomProviderWrapper provider : providersList)
+ {
+ // check only for the right PP
+ if(!pps.equals(provider.getProtocolProvider()))
+ continue;
+
+ ChatRoomWrapper systemRoomWrapper = provider.getSystemRoomWrapper();
+ ChatRoom systemRoom = systemRoomWrapper.getChatRoom();
+
+ if ((systemRoom != null)
+ && systemRoom.getIdentifier().equals(chatRoomID))
+ {
+ return systemRoomWrapper;
+ }
+ else
+ {
+ ChatRoomWrapper chatRoomWrapper
+ = provider.findChatRoomWrapperForChatRoomID(chatRoomID);
+
+ return chatRoomWrapper;
+ }
+ }
+
+ return null;
+ }
/**
* Returns the <tt>ChatRoomProviderWrapper</tt> that correspond to the
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java
index 7eca377..8e40dcb 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomRightButtonMenu.java
@@ -52,7 +52,7 @@ public class ChatRoomRightButtonMenu
createMenuItem(
"service.gui.OPEN",
- ImageLoader.CHAT_ROOM_16x16_ICON,
+ ImageLoader.CHAT_ROOM_OFFLINE_ICON,
"openChatRoom");
JMenuItem joinChatRoomItem
= createMenuItem(
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java
index d9fc262..c4e36ae 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomServerRightButtonMenu.java
@@ -33,7 +33,7 @@ public class ChatRoomServerRightButtonMenu
{
private JMenuItem createChatRoomItem = new JMenuItem(
GuiActivator.getResources().getI18NString("service.gui.CREATE_CHAT_ROOM"),
- new ImageIcon(ImageLoader.getImage(ImageLoader.CHAT_ROOM_16x16_ICON)));
+ new ImageIcon(ImageLoader.getImage(ImageLoader.CHAT_ROOM_OFFLINE_ICON)));
private JMenuItem joinChannelItem = new JMenuItem(
GuiActivator.getResources().getI18NString("service.gui.JOIN_CHAT_ROOM"),
@@ -111,7 +111,7 @@ public class ChatRoomServerRightButtonMenu
public void loadSkin()
{
createChatRoomItem.setIcon(new ImageIcon(
- ImageLoader.getImage(ImageLoader.CHAT_ROOM_16x16_ICON)));
+ ImageLoader.getImage(ImageLoader.CHAT_ROOM_OFFLINE_ICON)));
joinChannelItem.setIcon(new ImageIcon(
ImageLoader.getImage(ImageLoader.SEARCH_ICON_16x16)));
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableUI.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableUI.java
index 5619331..d98dcc7 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableUI.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableUI.java
@@ -315,12 +315,12 @@ public class ChatRoomTableUI
!chatRoom.getChatRoom().isJoined())
{
chatRoomImage = ImageLoader
- .getImage(ImageLoader.CHAT_ROOM_16x16_ICON);
+ .getImage(ImageLoader.CHAT_ROOM_OFFLINE_ICON);
}
else
{
chatRoomImage = ImageLoader
- .getImage(ImageLoader.CHAT_ROOM_JOINED_ICON);
+ .getImage(ImageLoader.CHAT_ROOM_ONLINE_ICON);
}
this.setIcon(new ImageIcon(chatRoomImage));
diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsListCellRenderer.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsListCellRenderer.java
index ee5e8dc..c568593 100644
--- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsListCellRenderer.java
+++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomsListCellRenderer.java
@@ -70,7 +70,7 @@ public class ChatRoomsListCellRenderer extends JPanel
this.nameLabel.setText(chatRoomWrapper.getChatRoomName());
Image chatRoomImage = ImageLoader
- .getImage(ImageLoader.CHAT_ROOM_16x16_ICON);
+ .getImage(ImageLoader.CHAT_ROOM_OFFLINE_ICON);
if(chatRoomWrapper.getChatRoom() == null ||
!chatRoomWrapper.getChatRoom().isJoined())
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java
index 0372958..4140ab0 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListPane.java
@@ -17,6 +17,9 @@ import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.event.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
+import net.java.sip.communicator.impl.gui.main.chat.conference.*;
+import net.java.sip.communicator.impl.gui.main.chatroomslist.*;
+import net.java.sip.communicator.impl.muc.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.contacteventhandler.*;
import net.java.sip.communicator.service.contactlist.*;
@@ -35,6 +38,7 @@ import org.osgi.framework.*;
* all typing notifications. Here are managed all contact list mouse events.
*
* @author Yana Stamcheva
+ * @author Hristo Terezov
*/
public class ContactListPane
extends SIPCommScrollPane
@@ -152,61 +156,76 @@ public class ContactListPane
UIContact descriptor = evt.getSourceContact();
// We're currently only interested in MetaContacts.
- if (!(descriptor.getDescriptor() instanceof MetaContact))
- return;
-
- MetaContact metaContact = (MetaContact) descriptor.getDescriptor();
-
- // Searching for the right proto contact to use as default for the
- // chat conversation.
- Contact defaultContact = metaContact.getDefaultContact(
- OperationSetBasicInstantMessaging.class);
-
- // do nothing
- if(defaultContact == null)
- return;
-
- ProtocolProviderService defaultProvider
- = defaultContact.getProtocolProvider();
-
- OperationSetBasicInstantMessaging
- defaultIM = defaultProvider.getOperationSet(
- OperationSetBasicInstantMessaging.class);
-
- ProtocolProviderService protoContactProvider;
- OperationSetBasicInstantMessaging protoContactIM;
-
- boolean isOfflineMessagingSupported
- = defaultIM != null && !defaultIM.isOfflineMessagingSupported();
-
- if (defaultContact.getPresenceStatus().getStatus() < 1
- && (!isOfflineMessagingSupported
- || !defaultProvider.isRegistered()))
+ if (descriptor.getDescriptor() instanceof MetaContact)
{
- Iterator<Contact> protoContacts = metaContact.getContacts();
+ MetaContact metaContact = (MetaContact) descriptor.getDescriptor();
- while(protoContacts.hasNext())
- {
- Contact contact = protoContacts.next();
-
- protoContactProvider = contact.getProtocolProvider();
+ // Searching for the right proto contact to use as default for the
+ // chat conversation.
+ Contact defaultContact = metaContact.getDefaultContact(
+ OperationSetBasicInstantMessaging.class);
- protoContactIM = protoContactProvider.getOperationSet(
- OperationSetBasicInstantMessaging.class);
+ // do nothing
+ if(defaultContact == null)
+ return;
- if(protoContactIM != null
- && protoContactIM.isOfflineMessagingSupported()
- && protoContactProvider.isRegistered())
+ ProtocolProviderService defaultProvider
+ = defaultContact.getProtocolProvider();
+
+ OperationSetBasicInstantMessaging
+ defaultIM = defaultProvider.getOperationSet(
+ OperationSetBasicInstantMessaging.class);
+
+ ProtocolProviderService protoContactProvider;
+ OperationSetBasicInstantMessaging protoContactIM;
+
+ boolean isOfflineMessagingSupported
+ = defaultIM != null && !defaultIM.isOfflineMessagingSupported();
+
+ if (defaultContact.getPresenceStatus().getStatus() < 1
+ && (!isOfflineMessagingSupported
+ || !defaultProvider.isRegistered()))
+ {
+ Iterator<Contact> protoContacts = metaContact.getContacts();
+
+ while(protoContacts.hasNext())
{
- defaultContact = contact;
+ Contact contact = protoContacts.next();
+
+ protoContactProvider = contact.getProtocolProvider();
+
+ protoContactIM = protoContactProvider.getOperationSet(
+ OperationSetBasicInstantMessaging.class);
+
+ if(protoContactIM != null
+ && protoContactIM.isOfflineMessagingSupported()
+ && protoContactProvider.isRegistered())
+ {
+ defaultContact = contact;
+ }
}
}
- }
- ContactEventHandler contactHandler = mainFrame
- .getContactHandler(defaultContact.getProtocolProvider());
+ ContactEventHandler contactHandler = mainFrame
+ .getContactHandler(defaultContact.getProtocolProvider());
- contactHandler.contactClicked(defaultContact, evt.getClickCount());
+ contactHandler.contactClicked(defaultContact, evt.getClickCount());
+ }
+ else if(descriptor.getDescriptor() instanceof ChatRoomSourceContact)
+ {
+ ConferenceChatManager conferenceChatManager
+ = GuiActivator.getUIService()
+ .getConferenceChatManager();
+ ChatRoomList chatRoomList
+ = conferenceChatManager.getChatRoomList();
+
+ ChatRoomSourceContact contact = (ChatRoomSourceContact)
+ descriptor.getDescriptor();
+ ChatRoomWrapper room
+ = chatRoomList.findChatRoomWrapperFromChatRoomID(
+ contact.getChatRoomID(), contact.getProvider());
+ conferenceChatManager.openChatRoom(room);
+ }
}
/**
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java
index 398ed96..4e3763a 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/ContactListTreeCellRenderer.java
@@ -18,8 +18,11 @@ import javax.swing.tree.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.main.call.*;
+import net.java.sip.communicator.impl.gui.main.chat.conference.*;
+import net.java.sip.communicator.impl.gui.main.chatroomslist.*;
import net.java.sip.communicator.impl.gui.main.contactlist.contactsource.*;
import net.java.sip.communicator.impl.gui.utils.*;
+import net.java.sip.communicator.impl.muc.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.contactsource.*;
@@ -41,6 +44,7 @@ import net.java.sip.communicator.util.skin.*;
* @author Yana Stamcheva
* @author Lubomir Marinov
* @author Adam Netocny
+ * @author Hristo Terezov
*/
public class ContactListTreeCellRenderer
extends JPanel
@@ -321,6 +325,22 @@ public class ContactListTreeCellRenderer
.startChat(
(MetaContact) contactDescriptor.getDescriptor());
}
+ else if(contactDescriptor.getDescriptor()
+ instanceof ChatRoomSourceContact)
+ {
+ ConferenceChatManager conferenceChatManager
+ = GuiActivator.getUIService()
+ .getConferenceChatManager();
+ ChatRoomList chatRoomList
+ = conferenceChatManager.getChatRoomList();
+
+ ChatRoomSourceContact contact = (ChatRoomSourceContact)
+ contactDescriptor.getDescriptor();
+ ChatRoomWrapper room
+ = chatRoomList.findChatRoomWrapperFromChatRoomID(
+ contact.getChatRoomID(), contact.getProvider());
+ conferenceChatManager.openChatRoom(room);
+ }
}
}
});
@@ -815,6 +835,10 @@ public class ContactListTreeCellRenderer
if (uiContact.getDescriptor() instanceof MetaContact)
imContact = uiContact.getDefaultContactDetail(
OperationSetBasicInstantMessaging.class);
+
+ if(imContact == null)
+ imContact = uiContact.getDefaultContactDetail(
+ OperationSetMultiUserChat.class);
int x = (statusIcon == null ? 0 : statusIcon.getIconWidth())
+ LEFT_BORDER
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java
index 137f642..6a574a8 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/TreeContactList.java
@@ -20,6 +20,7 @@ import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.main.contactlist.contactsource.*;
import net.java.sip.communicator.impl.gui.main.contactlist.notifsource.*;
import net.java.sip.communicator.impl.gui.utils.*;
+import net.java.sip.communicator.impl.muc.*;
import net.java.sip.communicator.plugin.desktoputil.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.contactsource.*;
@@ -216,7 +217,6 @@ public class TreeContactList
if (sourceUI == null)
return;
-
UIContact uiContact
= sourceUI.createUIContact(sourceContact);
@@ -1250,8 +1250,10 @@ public class TreeContactList
UIContact uiContact
= ((ContactNode) lastComponent).getContactDescriptor();
- if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
+ if (((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
|| (e.isControlDown() && !e.isMetaDown()))
+ && !(uiContact.getDescriptor()
+ instanceof ChatRoomSourceContact))
{
rightButtonMenu = uiContact.getRightButtonMenu();
@@ -1669,6 +1671,7 @@ public class TreeContactList
else
contactSources.add(extContactSource);
}
+
}
GuiActivator.bundleContext.addServiceListener(
diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java
index 63f5b12..74e4136 100644
--- a/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/menus/FileMenu.java
@@ -221,7 +221,7 @@ public class FileMenu
ImageLoader.GROUPS_16x16_ICON)));
myChatRoomsItem.setIcon(
new ImageIcon(ImageLoader.getImage(
- ImageLoader.CHAT_ROOM_16x16_ICON)));
+ ImageLoader.CHAT_ROOM_OFFLINE_ICON)));
if(closeMenuItem != null)
{
diff --git a/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf b/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf
index 31824d6..a7c001a 100644
--- a/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf
+++ b/src/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf
@@ -78,4 +78,5 @@ Import-Package: com.apple.eawt,
org.jitsi.util.swing,
org.osgi.framework,
say.swing,
- net.java.sip.communicator.service.credentialsstorage
+ net.java.sip.communicator.service.credentialsstorage,
+ net.java.sip.communicator.impl.muc
diff --git a/src/net/java/sip/communicator/impl/gui/utils/Constants.java b/src/net/java/sip/communicator/impl/gui/utils/Constants.java
index f195148..856eceb 100755
--- a/src/net/java/sip/communicator/impl/gui/utils/Constants.java
+++ b/src/net/java/sip/communicator/impl/gui/utils/Constants.java
@@ -15,6 +15,7 @@ import javax.swing.*;
import javax.swing.text.html.*;
import net.java.sip.communicator.impl.gui.*;
+import net.java.sip.communicator.impl.muc.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.util.*;
@@ -289,11 +290,23 @@ public class Constants
return ImageLoader
.getImage(ImageLoader.USER_ONLINE_ICON);
}
- else if(connectivity < PresenceStatus.MAX_STATUS_VALUE)
+ else if(connectivity <
+ ChatRoomPresenceStatus.CHAT_ROOM_ONLINE_THRESHOLD)
{
return ImageLoader
.getImage(ImageLoader.USER_FFC_ICON);
}
+ else if(connectivity <
+ ChatRoomPresenceStatus.CHAT_ROOM_OFFLINE_THRESHOLD)
+ {
+ return ImageLoader
+ .getImage(ImageLoader.CHAT_ROOM_ONLINE_ICON);
+ }
+ else if(connectivity < PresenceStatus.MAX_STATUS_VALUE)
+ {
+ return ImageLoader
+ .getImage(ImageLoader.CHAT_ROOM_OFFLINE_ICON);
+ }
else
{
return ImageLoader
diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
index 9819290..083e2d1 100644
--- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
+++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
@@ -26,6 +26,7 @@ import net.java.sip.communicator.util.*;
* @author Yana Stamcheva
* @author Lubomir Marinov
* @author Adam Netocny
+ * @author Hristo Terezov
*/
public class ImageLoader
{
@@ -953,13 +954,13 @@ public class ImageLoader
/**
* The image used for chat rooms.
*/
- public static final ImageID CHAT_ROOM_16x16_ICON
+ public static final ImageID CHAT_ROOM_OFFLINE_ICON
= new ImageID("service.gui.icons.CHAT_ROOM_16x16_ICON");
/**
* The image used for joined chat rooms.
*/
- public static final ImageID CHAT_ROOM_JOINED_ICON
+ public static final ImageID CHAT_ROOM_ONLINE_ICON
= new ImageID("service.gui.icons.CHAT_ROOM_JOINED_ICON");
/**
diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomContactSourceService.java b/src/net/java/sip/communicator/impl/muc/ChatRoomContactSourceService.java
new file mode 100644
index 0000000..a943c8b
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/muc/ChatRoomContactSourceService.java
@@ -0,0 +1,111 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.impl.muc;
+
+import java.util.*;
+import net.java.sip.communicator.service.contactsource.*;
+
+/**
+ * Contact source service for chat rooms.
+ *
+ * @author Hristo Terezov
+ */
+public class ChatRoomContactSourceService
+ implements ContactSourceService
+{
+ /**
+ * The <tt>List</tt> of <tt>ChatRoomQuery</tt> instances
+ * which have been started and haven't stopped yet.
+ */
+ private final List<ChatRoomQuery> queries
+ = new LinkedList<ChatRoomQuery>();
+
+ /**
+ * Returns the type of this contact source.
+ *
+ * @return the type of this contact source
+ */
+ public int getType()
+ {
+ return DEFAULT_TYPE;
+ }
+
+ /**
+ * Returns a user-friendly string that identifies this contact source.
+ *
+ * @return the display name of this contact source
+ */
+ public String getDisplayName()
+ {
+ return MUCActivator.getResources().getI18NString(
+ "service.gui.CHAT_ROOMS");
+ }
+
+ /**
+ * Queries this contact source for the given <tt>queryString</tt>.
+ *
+ * @param queryString the string to search for
+ * @return the created query
+ */
+ @Override
+ public ContactQuery queryContactSource(String queryString)
+ {
+ return queryContactSource(queryString, -1);
+ }
+
+ /**
+ * Queries this contact source for the given <tt>queryString</tt>.
+ *
+ * @param queryString the string to search for
+ * @param contactCount the maximum count of result contacts
+ * @return the created query
+ */
+ @Override
+ public ContactQuery queryContactSource(String queryString, int contactCount)
+ {
+ if (queryString == null)
+ queryString = "";
+ ChatRoomQuery contactQuery
+ = new ChatRoomQuery(queryString, contactCount, this);
+
+ synchronized (queries)
+ {
+ queries.add(contactQuery);
+ }
+
+ boolean queryHasStarted = false;
+
+ try
+ {
+ contactQuery.start();
+ queryHasStarted = true;
+ }
+ finally
+ {
+ if (!queryHasStarted)
+ {
+ synchronized (queries)
+ {
+ if (queries.remove(contactQuery))
+ queries.notify();
+ }
+ }
+ }
+ return contactQuery;
+ }
+
+ /**
+ * Returns the index of the contact source in the result list.
+ *
+ * @return the index of the contact source in the result list
+ */
+ @Override
+ public int getIndex()
+ {
+ return -1;
+ }
+
+}
diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomPresenceStatus.java b/src/net/java/sip/communicator/impl/muc/ChatRoomPresenceStatus.java
new file mode 100644
index 0000000..8f13dcb
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/muc/ChatRoomPresenceStatus.java
@@ -0,0 +1,68 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.impl.muc;
+
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ * The chat room statuses.
+ *
+ * @author Hristo Terezov
+ */
+public class ChatRoomPresenceStatus extends PresenceStatus
+{
+ /**
+ * An integer above which all values of the status coefficient indicate
+ * eagerness to communicate
+ */
+ public static final int CHAT_ROOM_ONLINE_THRESHOLD = 86;
+
+ /**
+ * An integer above which all values of the status coefficient indicate
+ * eagerness to communicate
+ */
+ public static final int CHAT_ROOM_OFFLINE_THRESHOLD = 87;
+
+ /**
+ * Indicates that the user is connected and ready to communicate.
+ */
+ public static final String ONLINE_STATUS = "Online";
+
+ /**
+ * Indicates that the user is disconnected.
+ */
+ public static final String OFFLINE_STATUS = "Offline";
+
+ /**
+ * The Online status. Indicate that the user is able and willing to
+ * communicate in the chat room.
+ */
+ public static final ChatRoomPresenceStatus CHAT_ROOM_ONLINE
+ = new ChatRoomPresenceStatus(
+ 86,
+ ONLINE_STATUS);
+
+ /**
+ * The Offline status. Indicates the user does not seem to be connected
+ * to the chat room.
+ */
+ public static final ChatRoomPresenceStatus CHAT_ROOM_OFFLINE
+ = new ChatRoomPresenceStatus(
+ 87,
+ OFFLINE_STATUS);
+
+ /**
+ * Creates a status with the specified connectivity coeff and name for the
+ * chat rooms.
+ * @param status the connectivity coefficient for the specified status
+ * @param statusName String
+ */
+ protected ChatRoomPresenceStatus(int status, String statusName)
+ {
+ super(status, statusName);
+ }
+
+}
diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java b/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java
new file mode 100644
index 0000000..1d06dec
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/muc/ChatRoomQuery.java
@@ -0,0 +1,164 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.impl.muc;
+
+import java.util.*;
+import java.util.regex.*;
+
+import net.java.sip.communicator.service.contactsource.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.event.*;
+
+import org.jitsi.service.configuration.*;
+
+/**
+ * The <tt>ChatRoomQuery</tt> is a query over the
+ * <tt>ChatRoomContactSourceService</tt>.
+ *
+ * @author Hristo Terezov
+ */
+public class ChatRoomQuery
+ extends AsyncContactQuery<ContactSourceService>
+ implements LocalUserChatRoomPresenceListener
+{
+ /**
+ * Creates an instance of <tt>ChatRoomQuery</tt> by specifying
+ * the parent contact source, the query string to match and the maximum
+ * result contacts to return.
+ *
+ * @param contactSource the parent contact source
+ * @param queryString the query string to match
+ * @param contactCount the maximum result contact count
+ */
+ public ChatRoomQuery(String queryString,
+ int count, ChatRoomContactSourceService contactSource)
+ {
+ super(contactSource,
+ Pattern.compile(queryString, Pattern.CASE_INSENSITIVE
+ | Pattern.LITERAL), true);
+ for(ProtocolProviderService pps : MUCActivator
+ .getChatRoomProviders())
+ {
+ OperationSetMultiUserChat opSetMUC = (OperationSetMultiUserChat)
+ pps.getOperationSet(OperationSetMultiUserChat.class);
+ if(opSetMUC != null)
+ {
+ opSetMUC.addPresenceListener(this);
+ }
+ }
+ }
+
+ @Override
+ protected void run()
+ {
+ ConfigurationService configService
+ = MUCActivator.getConfigurationService();
+
+ String prefix = "net.java.sip.communicator.impl.gui.accounts";
+
+ List<String> accounts =
+ configService.getPropertyNamesByPrefix(prefix, true);
+
+ for(ProtocolProviderService pps : MUCActivator
+ .getChatRoomProviders())
+ {
+ for (String accountRootPropName : accounts) {
+ String accountUID
+ = configService.getString(accountRootPropName);
+
+ if(accountUID.equals(pps
+ .getAccountID().getAccountUniqueID()))
+ {
+ List<String> chatRooms = configService
+ .getPropertyNamesByPrefix(
+ accountRootPropName + ".chatRooms", true);
+
+ for (String chatRoomPropName : chatRooms)
+ {
+ addChatRoom( pps, configService.getString(
+ chatRoomPropName + ".chatRoomName"),
+ configService.getString(chatRoomPropName));
+ }
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Handles chat room presence status updates.
+ *
+ * @param evt the <tt>LocalUserChatRoomPresenceChangeEvent</tt> instance
+ * containing the chat room and the type, and reason of the change
+ */
+ @Override
+ public void localUserPresenceChanged(
+ LocalUserChatRoomPresenceChangeEvent evt)
+ {
+ ChatRoom sourceChatRoom = evt.getChatRoom();
+
+ String eventType = evt.getEventType();
+
+ boolean existingContact = false;
+ SourceContact foundContact = null;
+ for(SourceContact contact : getQueryResults())
+ {
+ if(contact.getContactAddress().equals(sourceChatRoom.getName()))
+ {
+ existingContact = true;
+ foundContact = contact;
+ break;
+ }
+ }
+
+ if (LocalUserChatRoomPresenceChangeEvent
+ .LOCAL_USER_JOINED.equals(eventType))
+ {
+ if(existingContact)
+ {
+ ((ChatRoomSourceContact)foundContact).setPresenceStatus(
+ ChatRoomPresenceStatus.CHAT_ROOM_ONLINE);
+ fireContactChanged(foundContact);
+ }
+ else
+ {
+ addQueryResult(
+ new ChatRoomSourceContact(sourceChatRoom,this));
+ }
+ }
+ else if ((LocalUserChatRoomPresenceChangeEvent
+ .LOCAL_USER_LEFT.equals(eventType)
+ || LocalUserChatRoomPresenceChangeEvent
+ .LOCAL_USER_KICKED.equals(eventType)
+ || LocalUserChatRoomPresenceChangeEvent
+ .LOCAL_USER_DROPPED.equals(eventType))
+ )
+ {
+ if(existingContact)
+ {
+ ((ChatRoomSourceContact)foundContact)
+ .setPresenceStatus(
+ ChatRoomPresenceStatus.CHAT_ROOM_OFFLINE);
+ fireContactChanged(foundContact);
+ }
+ }
+ }
+
+ /**
+ * Adds found result to the query results.
+ *
+ * @param pps the protocol provider associated with the found chat room.
+ * @param chatRoomName the name of the chat room.
+ * @param chatRoomID the id of the chat room.
+ */
+ private void addChatRoom(ProtocolProviderService pps,
+ String chatRoomName, String chatRoomID)
+ {
+
+ addQueryResult(
+ new ChatRoomSourceContact(chatRoomName, chatRoomID, this, pps));
+ }
+} \ No newline at end of file
diff --git a/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java b/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java
new file mode 100644
index 0000000..1b00785
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/muc/ChatRoomSourceContact.java
@@ -0,0 +1,164 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license. See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.impl.muc;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.contactsource.*;
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ * Source contact for the chat rooms.
+ *
+ * @author Hristo Terezov
+ */
+public class ChatRoomSourceContact
+ extends SortedGenericSourceContact
+{
+ /**
+ * The name of the chat room associated with the contact.
+ */
+ private String chatRoomName;
+
+ /**
+ * The ID of the chat room associated with the contact.
+ */
+ private String chatRoomID;
+
+ /**
+ * The protocol provider of the chat room associated with the contact.
+ */
+ private ProtocolProviderService provider;
+
+ /**
+ *
+ * @param chatRoomName
+ * @param chatRoomID
+ * @param query
+ * @param pps
+ */
+ public ChatRoomSourceContact(String chatRoomName,
+ String chatRoomID, ChatRoomQuery query, ProtocolProviderService pps)
+ {
+ super(query, query.getContactSource(), chatRoomName,
+ generateDefaultContactDetails(chatRoomName));
+
+ this.chatRoomName = chatRoomName;
+ this.chatRoomID = chatRoomID;
+ this.provider = pps;
+
+ initContactProperties(getChatRoomStateByName());
+
+ }
+
+ /**
+ *
+ * @param chatRoom
+ * @param query
+ */
+ public ChatRoomSourceContact(ChatRoom chatRoom, ChatRoomQuery query)
+ {
+ super(query, query.getContactSource(), chatRoom.getName(),
+ generateDefaultContactDetails(chatRoom.getName()));
+
+ this.chatRoomName = chatRoom.getName();
+ this.chatRoomID = chatRoom.getIdentifier();
+ this.provider = chatRoom.getParentProvider();
+
+ initContactProperties(
+ (chatRoom.isJoined()?
+ ChatRoomPresenceStatus.CHAT_ROOM_ONLINE :
+ ChatRoomPresenceStatus.CHAT_ROOM_OFFLINE));
+
+ }
+
+ /**
+ * Sets the given presence status and the name of the chat room associated with the
+ * contact.
+ * @param status the presence status to be set.
+ */
+ private void initContactProperties(PresenceStatus status)
+ {
+ setPresenceStatus(status);
+ setContactAddress(chatRoomName);
+ }
+
+ /**
+ * Checks if the chat room associated with the contact is joinned or not and
+ * returns it presence status.
+ *
+ * @return the presence status of the chat room associated with the contact.
+ */
+ private PresenceStatus getChatRoomStateByName()
+ {
+ for(ChatRoom room :
+ provider.getOperationSet(OperationSetMultiUserChat.class)
+ .getCurrentlyJoinedChatRooms())
+ {
+ if(room.getName().equals(chatRoomName))
+ {
+ return ChatRoomPresenceStatus.CHAT_ROOM_ONLINE;
+ }
+ }
+ return ChatRoomPresenceStatus.CHAT_ROOM_OFFLINE;
+ }
+
+ /**
+ * Generates the default contact details for <tt>ChatRoomSourceContact</tt>
+ * instances.
+ *
+ * @param chatRoomName the name of the chat room associated with the contact
+ * @return list of default <tt>ContactDetail</tt>s for the contact.
+ */
+ private static List<ContactDetail> generateDefaultContactDetails(
+ String chatRoomName)
+ {
+ ContactDetail contactDetail
+ = new ContactDetail(chatRoomName);
+ List<Class<? extends OperationSet>> supportedOpSets
+ = new ArrayList<Class<? extends OperationSet>>();
+
+ supportedOpSets.add(OperationSetMultiUserChat.class);
+ contactDetail.setSupportedOpSets(supportedOpSets);
+
+ List<ContactDetail> contactDetails
+ = new ArrayList<ContactDetail>();
+
+ contactDetails.add(contactDetail);
+ return contactDetails;
+ }
+
+ /**
+ * Returns the id of the chat room associated with the contact.
+ *
+ * @return the chat room id.
+ */
+ public String getChatRoomID()
+ {
+ return chatRoomID;
+ }
+
+ /**
+ * Returns the name of the chat room associated with the contact.
+ *
+ * @return the chat room name
+ */
+ public String getChatRoomName()
+ {
+ return chatRoomName;
+ }
+
+ /**
+ * Returns the provider of the chat room associated with the contact.
+ *
+ * @return the provider
+ */
+ public ProtocolProviderService getProvider()
+ {
+ return provider;
+ }
+
+}
diff --git a/src/net/java/sip/communicator/impl/muc/MUCActivator.java b/src/net/java/sip/communicator/impl/muc/MUCActivator.java
new file mode 100644
index 0000000..052341f
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/muc/MUCActivator.java
@@ -0,0 +1,243 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.impl.muc;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.contactsource.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+import org.jitsi.service.configuration.ConfigurationService;
+import org.jitsi.service.resources.*;
+import org.osgi.framework.*;
+
+/**
+ * The activator for the chat room contact source bundle.
+ *
+ * @author Hristo Terezov
+ */
+public class MUCActivator
+ implements BundleActivator
+{
+ /**
+ * The <tt>Logger</tt> used by the
+ * <tt>MUCActivator</tt> class for logging output.
+ */
+ private static final Logger logger
+ = Logger.getLogger(MUCActivator.class);
+
+ /**
+ * The bundle context.
+ */
+ static BundleContext bundleContext = null;
+
+ /**
+ * The configuration service.
+ */
+ private static ConfigurationService configService;
+
+ /**
+ * Providers of contact info.
+ */
+ private static List<ProtocolProviderService> chatRoomProviders;
+
+ /**
+ * The contact source.
+ */
+ private static final ChatRoomContactSourceService chatRoomContactSource
+ = new ChatRoomContactSourceService();
+
+ /**
+ * The resource service.
+ */
+ private static ResourceManagementService resources = null;
+
+ /**
+ * Starts this bundle.
+ *
+ * @param context the bundle context where we register and obtain services.
+ */
+ public void start(BundleContext context) throws Exception
+ {
+ bundleContext = context;
+
+ bundleContext.registerService(
+ ContactSourceService.class.getName(),
+ chatRoomContactSource,
+ null);
+ }
+
+ public void stop(BundleContext context) throws Exception
+ {
+ }
+
+ /**
+ * Returns a reference to the ResourceManagementService implementation
+ * currently registered in the bundle context or null if no such
+ * implementation was found.
+ *
+ * @return a reference to a ResourceManagementService implementation
+ * currently registered in the bundle context or null if no such
+ * implementation was found.
+ */
+ public static ResourceManagementService getResources()
+ {
+ if (resources == null)
+ {
+ resources
+ = ServiceUtils.getService(
+ bundleContext, ResourceManagementService.class);
+ }
+
+ return resources;
+ }
+
+ /**
+ * Returns the <tt>ConfigurationService</tt> obtained from the bundle
+ * context.
+ * @return the <tt>ConfigurationService</tt> obtained from the bundle
+ * context
+ */
+ public static ConfigurationService getConfigurationService()
+ {
+ if(configService == null)
+ {
+ configService
+ = ServiceUtils.getService(
+ bundleContext,
+ ConfigurationService.class);
+ }
+ return configService;
+ }
+
+ /**
+ * Returns a list of all currently registered providers.
+ *
+ * @return a list of all currently registered providers
+ */
+ public static List<ProtocolProviderService> getChatRoomProviders()
+ {
+ if (chatRoomProviders != null)
+ return chatRoomProviders;
+
+ chatRoomProviders = new LinkedList<ProtocolProviderService>();
+
+ bundleContext.addServiceListener(new ProtocolProviderRegListener());
+
+ ServiceReference[] serRefs = null;
+ try
+ {
+ // get all registered provider factories
+ serRefs
+ = bundleContext.getServiceReferences(
+ ProtocolProviderFactory.class.getName(),
+ null);
+ }
+ catch (InvalidSyntaxException e)
+ {
+ logger.error("LoginManager : " + e);
+ }
+
+ if (serRefs != null)
+ {
+ for (ServiceReference serRef : serRefs)
+ {
+ ProtocolProviderFactory providerFactory
+ = (ProtocolProviderFactory)
+ bundleContext.getService(serRef);
+
+ ProtocolProviderService protocolProvider;
+
+ for (AccountID accountID
+ : providerFactory.getRegisteredAccounts())
+ {
+ serRef = providerFactory.getProviderForAccount(accountID);
+
+ protocolProvider
+ = (ProtocolProviderService) bundleContext
+ .getService(serRef);
+
+ handleProviderAdded(protocolProvider);
+ }
+ }
+ }
+ return chatRoomProviders;
+ }
+
+ /**
+ * Listens for <tt>ProtocolProviderService</tt> registrations.
+ */
+ private static class ProtocolProviderRegListener
+ implements ServiceListener
+ {
+ /**
+ * Handles service change events.
+ */
+ public void serviceChanged(ServiceEvent event)
+ {
+ ServiceReference serviceRef = event.getServiceReference();
+
+ // if the event is caused by a bundle being stopped, we don't want to
+ // know
+ if (serviceRef.getBundle().getState() == Bundle.STOPPING)
+ {
+ return;
+ }
+
+ Object service = bundleContext.getService(serviceRef);
+
+ // we don't care if the source service is not a protocol provider
+ if (!(service instanceof ProtocolProviderService))
+ {
+ return;
+ }
+
+ switch (event.getType())
+ {
+ case ServiceEvent.REGISTERED:
+ handleProviderAdded((ProtocolProviderService) service);
+ break;
+ case ServiceEvent.UNREGISTERING:
+ handleProviderRemoved((ProtocolProviderService) service);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Handles the registration of a new <tt>ProtocolProviderService</tt>. Adds
+ * the given <tt>protocolProvider</tt> to the list of queried providers.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt> to add
+ */
+ private static void handleProviderAdded(
+ ProtocolProviderService protocolProvider)
+ {
+ if (protocolProvider.getOperationSet(
+ OperationSetMultiUserChat.class) != null
+ && protocolProvider.isRegistered()
+ && !chatRoomProviders.contains(protocolProvider))
+ {
+ chatRoomProviders.add(protocolProvider);
+ }
+ }
+
+ /**
+ * Handles the un-registration of a <tt>ProtocolProviderService</tt>.
+ * Removes the given <tt>protocolProvider</tt> from the list of queried
+ * providers.
+ *
+ * @param protocolProvider the <tt>ProtocolProviderService</tt> to remove
+ */
+ private static void handleProviderRemoved(
+ ProtocolProviderService protocolProvider)
+ {
+ if (chatRoomProviders.contains(protocolProvider))
+ chatRoomProviders.remove(protocolProvider);
+ }
+}
diff --git a/src/net/java/sip/communicator/impl/muc/muc.manifest.mf b/src/net/java/sip/communicator/impl/muc/muc.manifest.mf
new file mode 100644
index 0000000..d5bbd58
--- /dev/null
+++ b/src/net/java/sip/communicator/impl/muc/muc.manifest.mf
@@ -0,0 +1,15 @@
+Bundle-Activator: net.java.sip.communicator.impl.muc.MUCActivator
+Bundle-Name: Chat room contact source
+Bundle-Description: Chat room contact source
+Bundle-Vendor: jitsi.org
+Bundle-Version: 0.0.1
+System-Bundle: yes
+Import-Package: org.osgi.framework,
+ net.java.sip.communicator.service.contactsource,
+ net.java.sip.communicator.service.protocol,
+ net.java.sip.communicator.util,
+ org.jitsi.service.resources,
+ net.java.sip.communicator.service.protocol.globalstatus,
+ org.jitsi.service.configuration,
+ net.java.sip.communicator.service.protocol.event
+Export-Package: net.java.sip.communicator.impl.muc
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java
index d0125a9..0d8adeb 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/ChatRoomJabberImpl.java
@@ -32,6 +32,7 @@ import org.jivesoftware.smackx.packet.*;
* @author Yana Stamcheva
* @author Valentin Martinet
* @author Boris Grozev
+ * @author Hristo Terezov
*/
public class ChatRoomJabberImpl
extends AbstractChatRoom
@@ -838,11 +839,9 @@ public class ChatRoomJabberImpl
List<CallJabberImpl> tmpConferenceCalls;
synchronized (chatRoomConferenceCalls)
{
- logger.info("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
tmpConferenceCalls
= new ArrayList<CallJabberImpl>(chatRoomConferenceCalls);
chatRoomConferenceCalls.clear();
- logger.info("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA2222222222");
}
for(CallJabberImpl call : tmpConferenceCalls)