From 275cbb770c8eaf6e1e300fca7d594effe43a61be Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Mon, 18 Nov 2013 19:59:02 +0200 Subject: [PATCH] Implements the right button menu for chat room contacts. Fixes the issue with the dialog for chat room password. --- resources/languages/resources.properties | 1 + .../communicator/impl/gui/UIServiceImpl.java | 34 ++ .../main/chat/ChatContactRightButtonMenu.java | 2 +- .../conference/ConferenceChatManager.java | 214 +------- .../gui/main/chat/toolBars/MainToolBar.java | 12 +- .../ChatRoomRightButtonMenu.java | 9 +- .../chatroomslist/ChatRoomTableDialog.java | 19 +- .../main/chatroomslist/ChatRoomTableUI.java | 5 +- .../SourceContactRightButtonMenu.java | 10 +- .../contactsource/ExternalContactSource.java | 151 +++++- .../contactsource/SourceUIContact.java | 34 +- .../main/login/DefaultSecurityAuthority.java | 3 +- .../main/login/LoginRendererSwingImpl.java | 2 +- .../impl/gui/swing.ui.manifest.mf | 3 +- .../impl/gui/utils/ImageLoader.java | 30 -- .../communicator/impl/muc/MUCActivator.java | 34 ++ .../muc/MUCCustomContactActionService.java | 503 ++++++++++++++++++ .../communicator/impl/muc/MUCServiceImpl.java | 4 +- .../sip/communicator/impl/muc/muc.manifest.mf | 5 +- .../desktoputil/AuthenticationWindow.java | 32 ++ .../desktoputil/DesktopUtilActivator.java | 22 + .../desktoputil}/MessageDialog.java | 30 +- .../chat/ChatOperationReasonDialog.java | 24 +- .../chat/ChatRoomJoinOptionsDialog.java | 196 +++++++ .../desktoputil/desktoputil.manifest.mf | 6 +- .../ContactActionMenuItem.java | 87 +++ .../CustomContactActionsService.java | 7 + .../communicator/service/gui/UIContact.java | 14 + .../communicator/service/gui/UIService.java | 17 + 29 files changed, 1199 insertions(+), 311 deletions(-) create mode 100644 src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java rename src/net/java/sip/communicator/{impl/gui/customcontrols => plugin/desktoputil}/MessageDialog.java (92%) rename src/net/java/sip/communicator/{impl/gui/main => plugin/desktoputil}/chat/ChatOperationReasonDialog.java (89%) create mode 100644 src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java create mode 100644 src/net/java/sip/communicator/service/customcontactactions/ContactActionMenuItem.java diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index b51ab1958..b175b5eae 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -307,6 +307,7 @@ service.gui.JOIN_CHAT_ROOM=&Join chat room... service.gui.JOIN_CHAT_ROOM_TITLE=Join chat room service.gui.JOIN_CHAT_ROOM_NAME=Please enter the name of the chat room you would like to join. service.gui.JOIN_CHAT_ROOM_WIZARD=Join chat room wizard +service.gui.JOIN_AUTOMATICALLY=Join automatically service.gui.KICK=&Kick service.gui.KICK_FAILED=Kick failed service.gui.KICK_FAILED_GENERAL_ERROR=Failed to kick {0}. A general server error occurred. diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index a4eec98d1..d9bac3649 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -34,6 +34,7 @@ import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.gui.Container; import net.java.sip.communicator.service.gui.event.*; +import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.shutdown.*; import net.java.sip.communicator.util.*; @@ -55,6 +56,7 @@ * @author Lyubomir Marinov * @author Dmitri Melnikov * @author Adam Netocny + * @author Hristo Terezov */ public class UIServiceImpl implements UIService, @@ -1542,6 +1544,38 @@ public void startChat(String[] participants) else throw new IllegalArgumentException("participants"); } + + /** + * Opens a chat room window for the given ChatRoomWrapper instance. + * + * @param chatRoom the chat room associated with the chat room window + */ + public void openChatRoomWindow(ChatRoomWrapper chatRoom) + { + ChatWindowManager chatWindowManager + = getChatWindowManager(); + ChatPanel chatPanel + = chatWindowManager.getMultiChat(chatRoom, true); + + chatWindowManager.openChat(chatPanel, true); + } + + /** + * Closes the chat room window for the given ChatRoomWrapper + * instance. + * + * @param chatRoom the chat room associated with the chat room window. + */ + public void closeChatRoomWindow(ChatRoomWrapper chatRoom) + { + ChatWindowManager chatWindowManager + = getChatWindowManager(); + ChatPanel chatPanel + = chatWindowManager.getMultiChat(chatRoom, false); + + if (chatPanel != null) + chatWindowManager.closeChat(chatPanel); + } /** * Creates a contact list component. diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java index 52b6c6fad..fbd03d805 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatContactRightButtonMenu.java @@ -12,9 +12,9 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; 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 847f0e3d2..9733e601a 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 @@ -6,18 +6,15 @@ */ package net.java.sip.communicator.impl.gui.main.chat.conference; -import java.awt.*; -import java.awt.event.*; import java.util.*; import java.util.concurrent.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.chat.*; import net.java.sip.communicator.impl.gui.main.chat.history.*; import net.java.sip.communicator.impl.gui.main.chatroomslist.*; -import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; @@ -29,8 +26,6 @@ import org.osgi.framework.*; import javax.swing.*; -// Java 1.6 has javax.swing.SwingWorker so we have to disambiguate. -import javax.swing.border.*; /** * The ConferenceChatManager is the one that manages both chat room and @@ -535,7 +530,8 @@ else if (LocalUserChatRoomPresenceChangeEvent { if(chatRoomWrapper != null) { - this.closeChatRoom(chatRoomWrapper); + GuiActivator.getUIService() + .closeChatRoomWindow(chatRoomWrapper); // Need to refresh the chat room's list in order to change // the state of the chat room to offline. @@ -701,7 +697,7 @@ public void removeChatRoom(ChatRoomWrapper chatRoomWrapper) if (chatRoom != null) leaveChatRoom(chatRoomWrapper); - this.closeChatRoom(chatRoomWrapper); + GuiActivator.getUIService().closeChatRoomWindow(chatRoomWrapper); GuiActivator.getMUCService().removeChatRoom(chatRoomWrapper); @@ -755,7 +751,7 @@ public void leaveChatRoom(ChatRoomWrapper chatRoomWrapper) ChatRoomWrapper leavedRoomWrapped = GuiActivator.getMUCService().leaveChatRoom(chatRoomWrapper); if(leavedRoomWrapped != null) - this.closeChatRoom(leavedRoomWrapped); + GuiActivator.getUIService().closeChatRoomWindow(leavedRoomWrapped); } /** @@ -879,23 +875,6 @@ private void fireAdHocChatRoomListChangedEvent( } } - /** - * Closes the chat corresponding to the given chat room wrapper, if such - * exists. - * - * @param chatRoomWrapper the chat room wrapper for which we search a chat - * to close. - */ - public void closeChatRoom(ChatRoomWrapper chatRoomWrapper) - { - ChatWindowManager chatWindowManager - = GuiActivator.getUIService().getChatWindowManager(); - ChatPanel chatPanel - = chatWindowManager.getMultiChat(chatRoomWrapper, false); - - if (chatPanel != null) - chatWindowManager.closeChat(chatPanel); - } /** * Closes the chat corresponding to the given ad-hoc chat room wrapper, if @@ -1316,7 +1295,7 @@ public void openChatRoom(ChatRoomWrapper room) if (savedNick == null) { - String[] joinOptions = getJoinOptions( + String[] joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( room.getParentProvider().getProtocolProvider(), room.getChatRoomID()); String nickName = joinOptions[0]; @@ -1336,186 +1315,9 @@ public void openChatRoom(ChatRoomWrapper room) GuiActivator.getMUCService().joinChatRoom(room, savedNick, null); } - ChatWindowManager chatWindowManager - = GuiActivator.getUIService().getChatWindowManager(); - ChatPanel chatPanel - = chatWindowManager.getMultiChat(room, true); - - chatWindowManager.openChat(chatPanel, true); + GuiActivator.getUIService().openChatRoomWindow(room); } - /** - * Opens a dialog with a fields for the nickname and the subject of the room - * and returns them. - * - * @param pps the protocol provider associated with the chat room. - * @param chatRoomId the id of the chat room. - * @return array with the nickname and subject values. - */ - public String[] getJoinOptions(ProtocolProviderService pps, - String chatRoomId) - { - return getJoinOptions(false, pps, chatRoomId); - } - - /** - * Opens a dialog with a fields for the nickname and the subject of the room - * and returns them. - * - * @param dontDisplaySubjectFields if true the subject fields will be hidden - * @return array with the nickname and subject values. - */ - public String[] getJoinOptions(boolean dontDisplaySubjectFields, - ProtocolProviderService pps, String chatRoomId) - { - String nickName = null; - ChatRoomJoinOptionsDialog reasonDialog = - new ChatRoomJoinOptionsDialog(GuiActivator.getResources() - .getI18NString("service.gui.CHANGE_NICKNAME"), GuiActivator - .getResources().getI18NString( - "service.gui.CHANGE_NICKNAME_LABEL"), false, true, - dontDisplaySubjectFields); - reasonDialog.setIcon(ImageLoader.getImage( - ImageLoader.CHANGE_NICKNAME_ICON)); - - final OperationSetServerStoredAccountInfo accountInfoOpSet - = pps.getOperationSet( - OperationSetServerStoredAccountInfo.class); - - String displayName = ""; - if (accountInfoOpSet != null) - { - displayName = AccountInfoUtils.getDisplayName(accountInfoOpSet); - } - - if(displayName == null || displayName.length() == 0) - { - displayName = GuiActivator.getGlobalDisplayDetailsService() - .getGlobalDisplayName(); - if(displayName == null || displayName.length() == 0) - { - displayName = pps.getAccountID().getUserID(); - if(displayName != null) - { - int atIndex = displayName.lastIndexOf("@"); - if (atIndex > 0) - displayName = displayName.substring(0, atIndex); - } - } - } - reasonDialog.setReasonFieldText(displayName); - - int result = reasonDialog.showDialog(); - - if (result == MessageDialog.OK_RETURN_CODE) - { - nickName = reasonDialog.getReason().trim(); - ConfigurationUtils.updateChatRoomProperty( - pps, - chatRoomId, "userNickName", nickName); - - } - String[] joinOptions = {nickName, reasonDialog.getSubject()}; - return joinOptions; - } - - /** - * Dialog with fields for nickname and subject. - */ - private class ChatRoomJoinOptionsDialog extends ChatOperationReasonDialog - { - /** - * Text field for the subject. - */ - private SIPCommTextField subject = new SIPCommTextField(GuiActivator - .getResources().getI18NString("service.gui.SUBJECT")); - - /** - * Label that hides and shows the subject fields panel on click. - */ - private JLabel cmdExpandSubjectFields; - - /** - * Panel that holds the subject fields. - */ - private JPanel subjectFieldsPannel = new JPanel(new BorderLayout()); - - /** - * Adds the subject fields to dialog. Sets action listeners. - * - * @param title the title of the dialog - * @param message the message shown in this dialog - * @param disableOKIfReasonIsEmpty if true the OK button will be - * disabled if the reason text is empty. - * @param showReasonLabel specify if we want the "Reason:" label - * @param dontDisplaySubjectFields if true the sibject fields will be - * hidden. - */ - public ChatRoomJoinOptionsDialog(String title, String message, - boolean showReasonLabel, - boolean disableOKIfReasonIsEmpty, - boolean dontDisplaySubjectFields) - { - super(title, - message, - showReasonLabel, - disableOKIfReasonIsEmpty); - - if(dontDisplaySubjectFields) - return; - - JPanel subjectPanel = new JPanel(new BorderLayout()); - subjectPanel.setOpaque(false); - subjectPanel.setBorder( - BorderFactory.createEmptyBorder(10, 0, 0, 0)); - - subjectFieldsPannel.setBorder( - BorderFactory.createEmptyBorder(10, 30, 0, 0)); - subjectFieldsPannel.setOpaque(false); - subjectFieldsPannel.add(subject, BorderLayout.CENTER); - subjectFieldsPannel.setVisible(false); - subject.setFont(getFont().deriveFont(12f)); - - cmdExpandSubjectFields = new JLabel(); - cmdExpandSubjectFields.setBorder(new EmptyBorder(0, 5, 0, 0)); - cmdExpandSubjectFields.setIcon(GuiActivator.getResources() - .getImage("service.gui.icons.RIGHT_ARROW_ICON")); - cmdExpandSubjectFields.setText(GuiActivator - .getResources().getI18NString("service.gui.SET_SUBJECT")); - cmdExpandSubjectFields.addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent e) - { - cmdExpandSubjectFields.setIcon( - UtilActivator.getResources().getImage( - subjectFieldsPannel.isVisible() - ? "service.gui.icons.RIGHT_ARROW_ICON" - : "service.gui.icons.DOWN_ARROW_ICON")); - - subjectFieldsPannel.setVisible( - !subjectFieldsPannel.isVisible()); - - pack(); - } - }); - subjectPanel.add(cmdExpandSubjectFields,BorderLayout.NORTH); - subjectPanel.add(subjectFieldsPannel,BorderLayout.CENTER); - addToReasonFieldPannel(subjectPanel); - this.pack(); - } - - /** - * Returns the text entered in the subject field. - * - * @return the text from the subject field. - */ - public String getSubject() - { - return subject.getText(); - } - } - @Override public void chatRoomProviderWrapperAdded(ChatRoomProviderWrapper provider) {} @@ -1524,6 +1326,6 @@ public void chatRoomProviderWrapperAdded(ChatRoomProviderWrapper provider) public void chatRoomProviderWrapperRemoved(ChatRoomProviderWrapper provider) { for(int i = 0; i < provider.countChatRooms(); i++) - closeChatRoom(provider.getChatRoom(i)); + GuiActivator.getUIService().closeChatRoomWindow(provider.getChatRoom(i)); } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java index 7d0d5ebd5..31f53f718 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/toolBars/MainToolBar.java @@ -488,10 +488,14 @@ else if (buttonText.equals("invite")) } else if (buttonText.equals("leave")) { - ConferenceChatManager conferenceManager - = GuiActivator.getUIService().getConferenceChatManager(); - conferenceManager.leaveChatRoom( - (ChatRoomWrapper)chatPanel.getChatSession().getDescriptor()); + ChatRoomWrapper chatRoomWrapper + = (ChatRoomWrapper)chatPanel.getChatSession().getDescriptor(); + ChatRoomWrapper leavedRoomWrapped + = GuiActivator.getMUCService().leaveChatRoom( + chatRoomWrapper); + if(leavedRoomWrapped != null) + GuiActivator.getUIService().closeChatRoomWindow( + leavedRoomWrapped); } else if (buttonText.equals("call")) { 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 fa5937986..a1ca465a8 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 @@ -16,6 +16,7 @@ import net.java.sip.communicator.impl.gui.main.chat.conference.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.muc.ChatRoomWrapper; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.resources.*; @@ -125,7 +126,7 @@ else if (itemName.equals("joinChatRoom")) .getChatRoomID(), "userNickName"); if(nickName == null) { - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); nickName = joinOptions[0]; @@ -165,7 +166,7 @@ else if (itemName.equals("openChatRoom")) .getChatRoomID(), "userNickName"); if(nickName == null) { - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider() .getProtocolProvider(), chatRoomWrapper.getChatRoomID()); @@ -189,7 +190,7 @@ else if (itemName.equals("openChatRoom")) } else if(itemName.equals("joinAsChatRoom")) { - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); if(joinOptions[0] == null) @@ -200,7 +201,7 @@ else if(itemName.equals("joinAsChatRoom")) } else if(itemName.equals("nickNameChatRoom")) { - conferenceManager.getJoinOptions(true, + ChatRoomJoinOptionsDialog.getJoinOptions(true, chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); } diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableDialog.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableDialog.java index 66197e31a..95259bda8 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/ChatRoomTableDialog.java @@ -17,9 +17,9 @@ import net.java.sip.communicator.impl.gui.*; 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.plugin.desktoputil.*; import net.java.sip.communicator.plugin.desktoputil.SwingWorker; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.muc.ChatRoomList; import net.java.sip.communicator.service.muc.ChatRoomProviderWrapper; import net.java.sip.communicator.service.muc.ChatRoomWrapper; @@ -351,8 +351,6 @@ public void actionPerformed(ActionEvent e) String[] joinOptions; String subject = null; JButton sourceButton = (JButton) e.getSource(); - ConferenceChatManager conferenceManager - = GuiActivator.getUIService().getConferenceChatManager(); if(sourceButton.equals(addButton)) { String chatRoomName = editor.getText(); @@ -365,7 +363,7 @@ public void actionPerformed(ActionEvent e) getSelectedProvider().getProtocolProvider(), new ArrayList(), "", false, true, true); - conferenceManager.getJoinOptions(true, + ChatRoomJoinOptionsDialog.getJoinOptions(true, chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); @@ -393,7 +391,7 @@ else if(sourceButton.equals(okButton)) false, false); - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); String nickName = joinOptions[0]; @@ -427,10 +425,11 @@ else if(sourceButton.equals(okButton)) { - joinOptions = conferenceManager.getJoinOptions( - selectedRoom.getParentProvider() - .getProtocolProvider(), - selectedRoom.getChatRoomID()); + joinOptions = ChatRoomJoinOptionsDialog + .getJoinOptions( + selectedRoom.getParentProvider() + .getProtocolProvider(), + selectedRoom.getChatRoomID()); savedNick = joinOptions[0]; subject = joinOptions[1]; if(savedNick == null) @@ -464,7 +463,7 @@ else if(sourceButton.equals(okButton)) if (savedNick == null) { - joinOptions = conferenceManager.getJoinOptions( + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( selectedRoom.getParentProvider() .getProtocolProvider(), selectedRoom.getChatRoomID()); 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 43c5901d5..b5cb1ca13 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 @@ -19,6 +19,7 @@ import net.java.sip.communicator.impl.gui.main.chat.conference.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.plugin.desktoputil.chat.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -176,9 +177,7 @@ void openChatForSelection() if (savedNick == null) { - ConferenceChatManager conferenceManager - = GuiActivator.getUIService().getConferenceChatManager(); - String[] joinOptions = conferenceManager.getJoinOptions( + String[] joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( chatRoomWrapper.getParentProvider().getProtocolProvider(), chatRoomWrapper.getChatRoomID()); String nickName = joinOptions[0]; diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java index ad940dc61..81f7fb853 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/SourceContactRightButtonMenu.java @@ -93,7 +93,9 @@ private void initItems() add(initCallMenu()); // Only create the menu if the add contact functionality is enabled. - if (!ConfigurationUtils.isAddContactDisabled()) + if ((sourceContact.getPreferredContactDetail( + OperationSetMultiUserChat.class) == null) + && !ConfigurationUtils.isAddContactDisabled()) { addContactComponent = TreeContactList.createAddContactMenu(sourceContact); @@ -101,6 +103,12 @@ private void initItems() if (addContactComponent != null) add(addContactComponent); + + for(JMenuItem item : + sourceUIContact.getContactCustomActionMenuItems(true)) + { + add(item); + } } /** diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ExternalContactSource.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ExternalContactSource.java index 74a272b22..d20d2a529 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ExternalContactSource.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/ExternalContactSource.java @@ -28,6 +28,7 @@ * ContactSourceService. * * @author Yana Stamcheva + * @author Hristo Terezov */ public class ExternalContactSource implements UIContactSource @@ -59,6 +60,12 @@ public class ExternalContactSource */ private static Map, SIPCommButton> customContactActionButtons; + + /** + * The list of right menu action items for this source contact. + */ + private static Map, JMenuItem> + customContactActionMenuItems; /** * The list of action buttons for this source service. @@ -174,8 +181,7 @@ public Collection getContactCustomActionButtons( SIPCommButton actionButton = customContactActionButtons.get(contactAction); - if (isContactActionVisible( contactAction, - sourceContact)) + if (isContactActionVisible( contactAction, sourceContact)) { availableCustomActionButtons.add(actionButton); } @@ -183,6 +189,44 @@ public Collection getContactCustomActionButtons( return availableCustomActionButtons; } + + /** + * Returns all custom action menu items for this contact. + * + * @param initActions if true the actions will be reloaded. + * @param sourceContact the contact. + * @return a list of all custom action menu items for this contact. + */ + public Collection getContactCustomActionMenuItems( + final SourceContact sourceContact, boolean initActions) + { + customActionContact = sourceContact; + + if (initActions || (customContactActionMenuItems == null)) + initCustomContactActionMenuItems(); + + Iterator> customActionsIter + = customContactActionMenuItems.keySet().iterator(); + + Collection availableCustomActionMenuItems + = new LinkedList(); + + while (customActionsIter.hasNext()) + { + ContactActionMenuItem contactAction + = customActionsIter.next(); + + JMenuItem actionMenuItem = + customContactActionMenuItems.get(contactAction); + + if (isContactActionVisible( contactAction, sourceContact)) + { + availableCustomActionMenuItems.add(actionMenuItem); + } + } + + return availableCustomActionMenuItems; + } /** * Indicates if the given ContactAction should be visible for the @@ -202,6 +246,25 @@ private static boolean isContactActionVisible( return false; } + + /** + * Indicates if the given ContactActionMenuItem should be visible + * for the given SourceContact. + * + * @param contactAction the ContactActionMenuItem to verify + * if the given action should be visible + * @return true if the given ContactActionMenuItem is + * visible for the given SourceContact, false - otherwise + */ + private static boolean isContactActionVisible( + ContactActionMenuItem contactAction, + SourceContact contact) + { + if (contactAction.isVisible(contact)) + return true; + + return false; + } /** * Initializes custom action buttons for this contact source. @@ -222,12 +285,36 @@ private void initCustomContactActionButtons() { final ContactAction ca = actionIterator.next(); - initActionButton(ca, SourceContact.class); } } } } + + /** + * Initializes custom action menu items for this contact source. + */ + private void initCustomContactActionMenuItems() + { + customContactActionMenuItems + = new LinkedHashMap, JMenuItem>(); + for (CustomContactActionsService ccas + : getContactActionsServices()) + { + Iterator> actionIterator + = ccas.getCustomContactActionsMenuItems(); + + if (actionIterator!= null) + { + while (actionIterator.hasNext()) + { + final ContactActionMenuItem ca + = actionIterator.next(); + initActionMenuItem(ca); + } + } + } + } /** * Initializes custom action buttons for this source service. @@ -247,7 +334,6 @@ private void initCustomServiceActionButtons() while (actionIterator!= null && actionIterator.hasNext()) { final ContactAction ca = actionIterator.next(); - initActionButton(ca, ContactSourceService.class); } } @@ -352,6 +438,63 @@ else if(contactSourceClass.equals(ContactSourceService.class)) } } } + + /** + * Initializes an action menu item. + * + * @param ca the ContactActionMenuItem corresponding to the item. + */ + private void initActionMenuItem( + final ContactActionMenuItem ca) + { + JMenuItem actionMenuItem; + + actionMenuItem = customContactActionMenuItems.get(ca); + + if (actionMenuItem == null) + { + if(ca.isCheckBox()) + { + actionMenuItem = new JCheckBoxMenuItem(); + } + else + { + actionMenuItem = new JMenuItem(); + } + + actionMenuItem.setText(ca.getText()); + + actionMenuItem.setMnemonic(ca.getMnemonics()); + + byte[] icon = ca.getIcon(); + if(icon != null) + actionMenuItem.setIcon( + new ImageIcon(icon)); + + actionMenuItem.setSelected(ca.isSelected(customActionContact)); + actionMenuItem.setEnabled(ca.isEnabled(customActionContact)); + + actionMenuItem.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent event) + { + try + { + ca.actionPerformed(customActionContact); + } + catch (OperationFailedException e) + { + new ErrorDialog(null, + GuiActivator.getResources() + .getI18NString("service.gui.ERROR"), + e.getMessage()); + } + } + }); + + customContactActionMenuItems.put(ca, actionMenuItem); + } + } /** * Returns a list of all custom contact action services. diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java index 3cddd533c..517f79000 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/SourceUIContact.java @@ -16,11 +16,9 @@ import org.jitsi.util.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.main.chatroomslist.*; import net.java.sip.communicator.impl.gui.main.contactlist.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; -import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.protocol.*; @@ -32,6 +30,7 @@ * ExternalContactSource. * * @author Yana Stamcheva + * @author Hristo Terezov */ public class SourceUIContact extends UIContactImpl @@ -413,19 +412,7 @@ public PresenceStatus getPresenceStatus() @Override public JPopupMenu getRightButtonMenu() { - if(!(sourceContact instanceof MetaContact) && - (sourceContact.getPreferredContactDetail( - OperationSetMultiUserChat.class) - != null)) - { - return new ChatRoomRightButtonMenu( - GuiActivator.getMUCService() - .findChatRoomWrapperFromSourceContact(sourceContact)); - } - else - { - return new SourceContactRightButtonMenu(this); - } + return new SourceContactRightButtonMenu(this); } /** @@ -708,4 +695,21 @@ public Collection getContactCustomActionButtons() return null; } + + /** + * Returns all custom action menu items for this contact. + * + * @param initActions if true the actions will be reloaded. + * @return a list of all custom action menu items for this contact. + */ + @Override + public Collection getContactCustomActionMenuItems( + boolean initActions) + { + if (sourceContact != null) + return uiGroup.getParentUISource() + .getContactCustomActionMenuItems(sourceContact, initActions); + + return null; + } } diff --git a/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java b/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java index df798c0dc..288cab6f6 100644 --- a/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java +++ b/src/net/java/sip/communicator/impl/gui/main/login/DefaultSecurityAuthority.java @@ -9,7 +9,6 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.service.protocol.*; @@ -71,7 +70,7 @@ public UserCredentials obtainCredentials( String userName = userCredentials.getUserName(); char[] password = userCredentials.getPassword(); ImageIcon icon - = ImageLoader.getAuthenticationWindowIcon(protocolProvider); + = AuthenticationWindow.getAuthenticationWindowIcon(protocolProvider); if (errorMessage == null) loginWindow = new AuthenticationWindow( diff --git a/src/net/java/sip/communicator/impl/gui/main/login/LoginRendererSwingImpl.java b/src/net/java/sip/communicator/impl/gui/main/login/LoginRendererSwingImpl.java index 56f84e760..00d5deafc 100644 --- a/src/net/java/sip/communicator/impl/gui/main/login/LoginRendererSwingImpl.java +++ b/src/net/java/sip/communicator/impl/gui/main/login/LoginRendererSwingImpl.java @@ -7,9 +7,9 @@ package net.java.sip.communicator.impl.gui.main.login; import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.authorization.*; +import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.account.*; 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 607dffc6a..38041b963 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 @@ -80,4 +80,5 @@ Import-Package: com.apple.eawt, org.osgi.framework, say.swing, net.java.sip.communicator.service.credentialsstorage, - net.java.sip.communicator.service.muc + net.java.sip.communicator.service.muc, + net.java.sip.communicator.plugin.desktoputil.chat 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 c2dba5779..51af8c6d2 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -1718,34 +1718,4 @@ public static void clearCache() { getImageLoaderService().clearCache(); } - - /** - * Returns the icon corresponding to the given protocolProvider. - * - * @param protocolProvider the ProtocolProviderService, which icon - * we're looking for - * @return the icon to show on the authentication window - */ - public static ImageIcon getAuthenticationWindowIcon( - ProtocolProviderService protocolProvider) - { - Image image = null; - - if(protocolProvider != null) - { - ProtocolIcon protocolIcon = protocolProvider.getProtocolIcon(); - - if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_64x64)) - image = ImageUtils.getBytesInImage( - protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_64x64)); - else if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_48x48)) - image = ImageUtils.getBytesInImage( - protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_48x48)); - } - - if (image != null) - return new ImageIcon(image); - - return null; - } } diff --git a/src/net/java/sip/communicator/impl/muc/MUCActivator.java b/src/net/java/sip/communicator/impl/muc/MUCActivator.java index 5e6d086d7..37a943bfe 100644 --- a/src/net/java/sip/communicator/impl/muc/MUCActivator.java +++ b/src/net/java/sip/communicator/impl/muc/MUCActivator.java @@ -10,6 +10,7 @@ import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.credentialsstorage.*; +import net.java.sip.communicator.service.customcontactactions.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.muc.*; import net.java.sip.communicator.service.protocol.*; @@ -79,6 +80,16 @@ public class MUCActivator * The credential storage service. */ private static CredentialsStorageService credentialsService; + + /** + * The custom actions service. + */ + private static MUCCustomContactActionService mucCustomActionService; + + /** + * The UI service. + */ + private static UIService uiService = null; /** * Starts this bundle. @@ -98,6 +109,11 @@ public void start(BundleContext context) throws Exception MUCService.class.getName(), mucService, null); + mucCustomActionService = new MUCCustomContactActionService(); + bundleContext.registerService( + CustomContactActionsService.class.getName(), + mucCustomActionService, + null); } public void stop(BundleContext context) throws Exception @@ -343,4 +359,22 @@ private static void handleProviderRemoved( if (chatRoomProviders.contains(protocolProvider)) chatRoomProviders.remove(protocolProvider); } + + /** + * Returns the UIService obtained from the bundle + * context. + * @return the UIService obtained from the bundle + * context + */ + public static UIService getUIService() + { + if(uiService == null) + { + uiService + = ServiceUtils.getService( + bundleContext, + UIService.class); + } + return uiService; + } } diff --git a/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java new file mode 100644 index 000000000..2d3884e07 --- /dev/null +++ b/src/net/java/sip/communicator/impl/muc/MUCCustomContactActionService.java @@ -0,0 +1,503 @@ +/* + * 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 org.jitsi.service.resources.*; + +import net.java.sip.communicator.plugin.desktoputil.chat.*; +import net.java.sip.communicator.service.contactsource.*; +import net.java.sip.communicator.service.customcontactactions.*; +import net.java.sip.communicator.service.muc.*; +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; + +/** + * Implements CustomContactActionsService for MUC contact source. + * + * @author Hristo Terezov + */ +public class MUCCustomContactActionService + implements CustomContactActionsService +{ + /** + * List of custom menu items. + */ + private final List> MUCActionMenuItems + = new LinkedList>(); + + /** + * Array of labels for the custom menu items. + */ + private String[] actionsLabels = { + "service.gui.OPEN", "service.gui.JOIN", + "service.gui.JOIN_AS", "service.gui.LEAVE", + "service.gui.REMOVE", "service.gui.CHANGE_NICK", + "service.gui.JOIN_AUTOMATICALLY" + }; + + /** + * Array of icons for the custom menu items. + */ + private String[] actionsIcons = { + "service.gui.icons.CHAT_ROOM_16x16_ICON", "service.gui.icons.JOIN_ICON", + "service.gui.icons.JOIN_AS_ICON", "service.gui.icons.LEAVE_ICON", + "service.gui.icons.REMOVE_CHAT_ICON", + "service.gui.icons.RENAME_16x16_ICON", + null + }; + + /** + * Array of MUCCustomActionRunnable objects for the custom menu + * items. They will be executed when the item is pressed. + */ + private MUCCustomActionRunnable[] actionsRunnable = { + new MUCCustomActionRunnable() + { + @Override + public void run() + { + String[] joinOptions; + String subject = null; + if(chatRoomWrapper.getChatRoom() == null) + { + // this is not a server persistent room we must create it + // and join + chatRoomWrapper = + MUCActivator.getMUCService().createChatRoom( + chatRoomWrapper.getChatRoomName(), + chatRoomWrapper.getParentProvider() + .getProtocolProvider(), + new ArrayList(), + "", + false, + false, + true); + } + + if(!chatRoomWrapper.getChatRoom().isJoined()) + { + String nickName = null; + + nickName = + ConfigurationUtils.getChatRoomProperty( + chatRoomWrapper.getParentProvider() + .getProtocolProvider(), chatRoomWrapper + .getChatRoomID(), "userNickName"); + if(nickName == null) + { + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( + chatRoomWrapper.getParentProvider() + .getProtocolProvider(), + chatRoomWrapper.getChatRoomID()); + nickName = joinOptions[0]; + subject = joinOptions[1]; + } + + if (nickName != null) + MUCActivator.getMUCService().joinChatRoom(chatRoomWrapper, + nickName, null, subject); + else + return; + } + + MUCActivator.getUIService().openChatRoomWindow(chatRoomWrapper); + } + }, + new MUCCustomActionRunnable() + { + + @Override + public void run() + { + String[] joinOptions; + String subject = null; + String nickName = null; + + nickName = + ConfigurationUtils.getChatRoomProperty( + chatRoomWrapper.getParentProvider() + .getProtocolProvider(), chatRoomWrapper + .getChatRoomID(), "userNickName"); + if(nickName == null) + { + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( + chatRoomWrapper.getParentProvider() + .getProtocolProvider(), + chatRoomWrapper.getChatRoomID()); + nickName = joinOptions[0]; + subject = joinOptions[1]; + } + + if (nickName != null) + MUCActivator.getMUCService().joinChatRoom(chatRoomWrapper, + nickName, null, subject); + } + }, + new MUCCustomActionRunnable() + { + + @Override + public void run() + { + String[] joinOptions; + joinOptions = ChatRoomJoinOptionsDialog.getJoinOptions( + chatRoomWrapper.getParentProvider().getProtocolProvider(), + chatRoomWrapper.getChatRoomID()); + if(joinOptions[0] == null) + return; + MUCActivator.getMUCService() + .joinChatRoom(chatRoomWrapper, joinOptions[0], null, + joinOptions[1]); + } + }, + new MUCCustomActionRunnable() + { + + @Override + public void run() + { + ChatRoomWrapper leavedRoomWrapped + = MUCActivator.getMUCService().leaveChatRoom( + chatRoomWrapper); + if(leavedRoomWrapped != null) + MUCActivator.getUIService().closeChatRoomWindow( + leavedRoomWrapped); + } + }, + new MUCCustomActionRunnable() + { + + @Override + public void run() + { + ChatRoom chatRoom = chatRoomWrapper.getChatRoom(); + + if (chatRoom != null) + { + ChatRoomWrapper leavedRoomWrapped + = MUCActivator.getMUCService().leaveChatRoom( + chatRoomWrapper); + if(leavedRoomWrapped != null) + MUCActivator.getUIService().closeChatRoomWindow( + leavedRoomWrapped); + } + + MUCActivator.getUIService().closeChatRoomWindow(chatRoomWrapper); + + MUCActivator.getMUCService().removeChatRoom(chatRoomWrapper); + } + }, + new MUCCustomActionRunnable() + { + + @Override + public void run() + { + ChatRoomJoinOptionsDialog.getJoinOptions(true, + chatRoomWrapper.getParentProvider().getProtocolProvider(), + chatRoomWrapper.getChatRoomID()); + } + }, + new MUCCustomActionRunnable() + { + + @Override + public void run() + { + chatRoomWrapper.setAutoJoin(!chatRoomWrapper.isAutojoin()); + } + } + }; + + /** + * Array of EnableChecker objects for the custom menu items. They + * are used to check if the item is enabled or disabled. + */ + private EnableChecker[] actionsEnabledCheckers = { + null, + new JoinEnableChecker(), + new JoinEnableChecker(), + new LeaveEnableChecker(), + null, + null, + null + }; + + /** + * Array for the custom menu items that describes the type of the menu item. + * If true - the item is check box. + */ + private boolean[] actionsIsCheckBox = { + false, + false, + false, + false, + false, + false, + true + }; + + /** + * The resource management service instance. + */ + ResourceManagementService resources = MUCActivator.getResources(); + + /** + * Constructs the custom actions. + */ + public MUCCustomContactActionService() + { + for(int i = 0; i < actionsLabels.length; i++) + { + MUCActionMenuItems item = new MUCActionMenuItems(actionsLabels[i], + actionsIcons[i], actionsRunnable[i], actionsIsCheckBox[i]); + MUCActionMenuItems.add(item); + if(actionsEnabledCheckers[i] != null) + item.setEnabled(actionsEnabledCheckers[i]); + } + + } + + /** + * Returns the template class that this service has been initialized with + * + * @return the template class + */ + public Class getContactSourceClass() + { + return SourceContact.class; + } + + @Override + public Iterator> + getCustomContactActionsMenuItems() + { + return MUCActionMenuItems.iterator(); + } + + + @Override + public Iterator> getCustomContactActions() + { + return null; + } + + /** + * Implements the MUC custom menu items. + */ + private class MUCActionMenuItems + implements ContactActionMenuItem + { + /** + * The key used to retrieve the label for the menu item. + */ + private String textKey; + + /** + * The key used to retrieve the icon for the menu item. + */ + private String imageKey; + + /** + * The action executed when the menu item is pressed. + */ + private MUCCustomActionRunnable actionPerformed; + + /** + * Object that is used to check if the item is enabled or disabled. + */ + private EnableChecker enabled; + + /** + * if true the item should be check box and if false + * it is standard menu item. + */ + private boolean isCheckBox; + + /** + * Constructs MUCActionMenuItems instance. + * + * @param textKey the key used to retrieve the label for the menu item. + * @param imageKey the key used to retrieve the icon for the menu item. + * @param actionPerformed the action executed when the menu item is + * pressed. + * @param isCheckBox if true the item should be check box. + */ + public MUCActionMenuItems(String textKey, String imageKey, + MUCCustomActionRunnable actionPerformed, boolean isCheckBox) + { + this.textKey = textKey; + this.imageKey = imageKey; + this.actionPerformed = actionPerformed; + this.enabled = new EnableChecker(); + this.isCheckBox = isCheckBox; + } + + @Override + public void actionPerformed(SourceContact actionSource) + throws OperationFailedException + { + if(!(actionSource instanceof ChatRoomSourceContact)) + return; + actionPerformed.setContact(actionSource); + new Thread(actionPerformed).start(); + } + + @Override + public byte[] getIcon() + { + return (imageKey == null)? null : + resources.getImageInBytes(imageKey); + } + + + @Override + public String getText() + { + return resources.getI18NString(textKey); + } + + @Override + public boolean isVisible(SourceContact actionSource) + { + return (actionSource instanceof ChatRoomSourceContact); + } + + @Override + public char getMnemonics() + { + return resources.getI18nMnemonic(textKey); + } + + @Override + public boolean isEnabled(SourceContact actionSource) + { + return enabled.check(actionSource); + } + + /** + * Sets EnabledChecker instance that will be used to check if + * the item should be enabled or disabled. + * + * @param enabled the EnabledChecker instance. + */ + public void setEnabled(EnableChecker enabled) + { + this.enabled = enabled; + } + + @Override + public boolean isCheckBox() + { + return isCheckBox; + } + + @Override + public boolean isSelected(SourceContact contact) + { + ChatRoomWrapper chatRoomWrapper = MUCActivator.getMUCService() + .findChatRoomWrapperFromSourceContact(contact); + return chatRoomWrapper.isAutojoin(); + } + + } + + /** + * Checks if the menu item should be enabled or disabled. This is default + * implementation. Always returns that the item should be enabled. + */ + private class EnableChecker + { + /** + * Checks if the menu item should be enabled or disabled. + * + * @param contact the contact associated with the menu item. + * @return always true + */ + public boolean check(SourceContact contact) + { + return true; + } + } + + /** + * Implements EnableChecker for the join menu items. + */ + private class JoinEnableChecker extends EnableChecker + { + /** + * Checks if the menu item should be enabled or disabled. + * + * @param contact the contact associated with the menu item. + * @return true if the item should be enabled and + * false if not. + */ + public boolean check(SourceContact contact) + { + ChatRoomWrapper chatRoomWrapper = MUCActivator.getMUCService() + .findChatRoomWrapperFromSourceContact(contact); + ChatRoom chatRoom = null; + if(chatRoomWrapper != null) + { + chatRoom = chatRoomWrapper.getChatRoom(); + } + + if((chatRoom != null) && chatRoom.isJoined()) + return false; + return true; + } + } + + /** + * Implements EnableChecker for the leave menu item. + */ + private class LeaveEnableChecker extends JoinEnableChecker + { + /** + * Checks if the menu item should be enabled or disabled. + * + * @param contact the contact associated with the menu item. + * @return true if the item should be enabled and + * false if not. + */ + public boolean check(SourceContact contact) + { + return !super.check(contact); + } + } + + /** + * Implements base properties for the MUC menu items.These properties are + * used when the menu item is pressed. + */ + private abstract class MUCCustomActionRunnable implements Runnable + { + /** + * The contact associated with the menu item. + */ + protected SourceContact contact; + + /** + * The contact associated with the menu item. + */ + protected ChatRoomWrapper chatRoomWrapper; + + /** + * Sets the source contact. + * @param contact the contact to set + */ + public void setContact(SourceContact contact) + { + this.contact = contact; + chatRoomWrapper = MUCActivator.getMUCService() + .findChatRoomWrapperFromSourceContact(contact); + } + + } +} diff --git a/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java b/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java index 0fa21b390..5a62c80c7 100644 --- a/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java +++ b/src/net/java/sip/communicator/impl/muc/MUCServiceImpl.java @@ -11,7 +11,7 @@ import org.jitsi.service.resources.*; -import net.java.sip.communicator.impl.gui.utils.*; +import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.service.contactsource.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.muc.*; @@ -737,7 +737,7 @@ private void done(String returnCode) authWindowsService.create( null, null, null, false, chatRoomWrapper.isPersistent(), - ImageLoader.getAuthenticationWindowIcon( + AuthenticationWindow.getAuthenticationWindowIcon( chatRoomWrapper.getParentProvider() .getProtocolProvider()), resources.getI18NString( diff --git a/src/net/java/sip/communicator/impl/muc/muc.manifest.mf b/src/net/java/sip/communicator/impl/muc/muc.manifest.mf index 6427cbf43..21c5d9a5e 100644 --- a/src/net/java/sip/communicator/impl/muc/muc.manifest.mf +++ b/src/net/java/sip/communicator/impl/muc/muc.manifest.mf @@ -13,5 +13,8 @@ Import-Package: org.osgi.framework, org.jitsi.service.configuration, net.java.sip.communicator.service.protocol.event, net.java.sip.communicator.service.credentialsstorage, - net.java.sip.communicator.service.gui + net.java.sip.communicator.service.gui, + net.java.sip.communicator.service.customcontactactions, + net.java.sip.communicator.plugin.desktoputil, + net.java.sip.communicator.plugin.desktoputil.chat Export-Package: net.java.sip.communicator.service.muc diff --git a/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java b/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java index 265c44d43..a989eec44 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/AuthenticationWindow.java @@ -12,6 +12,7 @@ import javax.swing.*; import net.java.sip.communicator.service.gui.*; +import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.Logger; import org.jitsi.util.*; @@ -757,5 +758,36 @@ public void mousePressed(MouseEvent e) }); return subscribeLabel; } + + + /** + * Returns the icon corresponding to the given protocolProvider. + * + * @param protocolProvider the ProtocolProviderService, which icon + * we're looking for + * @return the icon to show on the authentication window + */ + public static ImageIcon getAuthenticationWindowIcon( + ProtocolProviderService protocolProvider) + { + Image image = null; + + if(protocolProvider != null) + { + ProtocolIcon protocolIcon = protocolProvider.getProtocolIcon(); + + if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_64x64)) + image = ImageUtils.getBytesInImage( + protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_64x64)); + else if(protocolIcon.isSizeSupported(ProtocolIcon.ICON_SIZE_48x48)) + image = ImageUtils.getBytesInImage( + protocolIcon.getIcon(ProtocolIcon.ICON_SIZE_48x48)); + } + + if (image != null) + return new ImageIcon(image); + + return null; + } } diff --git a/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java b/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java index 23bb10d53..2be0ca1aa 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/DesktopUtilActivator.java @@ -10,6 +10,7 @@ import net.java.sip.communicator.service.browserlauncher.*; import net.java.sip.communicator.service.certificate.*; import net.java.sip.communicator.service.credentialsstorage.*; +import net.java.sip.communicator.service.globaldisplaydetails.*; import net.java.sip.communicator.service.gui.*; import net.java.sip.communicator.service.keybindings.*; import net.java.sip.communicator.service.protocol.*; @@ -52,6 +53,8 @@ public class DesktopUtilActivator private static AudioNotifierService audioNotifierService; + private static GlobalDisplayDetailsService globalDisplayDetailsService; + static BundleContext bundleContext; /** @@ -324,4 +327,23 @@ public static AudioNotifierService getAudioNotifier() } return audioNotifierService; } + + /** + * Returns the GlobalDisplayDetailsService obtained from the bundle + * context. + * + * @return the GlobalDisplayDetailsService obtained from the bundle + * context + */ + public static GlobalDisplayDetailsService getGlobalDisplayDetailsService() + { + if (globalDisplayDetailsService == null) + { + globalDisplayDetailsService + = ServiceUtils.getService( + bundleContext, + GlobalDisplayDetailsService.class); + } + return globalDisplayDetailsService; + } } \ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/gui/customcontrols/MessageDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/MessageDialog.java similarity index 92% rename from src/net/java/sip/communicator/impl/gui/customcontrols/MessageDialog.java rename to src/net/java/sip/communicator/plugin/desktoputil/MessageDialog.java index 2832a341e..1b4ec6897 100644 --- a/src/net/java/sip/communicator/impl/gui/customcontrols/MessageDialog.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/MessageDialog.java @@ -4,7 +4,7 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package net.java.sip.communicator.impl.gui.customcontrols; +package net.java.sip.communicator.plugin.desktoputil; import java.awt.*; import java.awt.event.*; @@ -12,9 +12,6 @@ import javax.swing.*; -import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.utils.*; -import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.util.skin.*; /** @@ -35,17 +32,17 @@ public class MessageDialog private static final long serialVersionUID = 1L; private JButton cancelButton = new JButton( - GuiActivator.getResources().getI18NString("service.gui.CANCEL")); + DesktopUtilActivator.getResources().getI18NString("service.gui.CANCEL")); protected JButton okButton = new JButton( - GuiActivator.getResources().getI18NString("service.gui.OK")); + DesktopUtilActivator.getResources().getI18NString("service.gui.OK")); private JCheckBox doNotAskAgain = new SIPCommCheckBox( - GuiActivator.getResources() + DesktopUtilActivator.getResources() .getI18NString("service.gui.DO_NOT_ASK_AGAIN")); - private JLabel iconLabel = new JLabel(new ImageIcon(ImageLoader - .getImage(ImageLoader.WARNING_ICON))); + private JLabel iconLabel = new JLabel(new ImageIcon( + DesktopUtilActivator.getImage("service.gui.icons.WARNING_ICON"))); private StyledHTMLEditorPane messageArea = new StyledHTMLEditorPane(); @@ -166,7 +163,7 @@ public MessageDialog( Frame owner, if(!isCancelButtonEnabled) { - doNotAskAgain.setText(GuiActivator.getResources() + doNotAskAgain.setText(DesktopUtilActivator.getResources() .getI18NString("service.gui.DO_NOT_SHOW_AGAIN")); buttonsPanel.remove(cancelButton); @@ -322,8 +319,8 @@ protected void close(boolean isEscaped) */ public void loadSkin() { - iconLabel.setIcon(new ImageIcon(ImageLoader - .getImage(ImageLoader.WARNING_ICON))); + iconLabel.setIcon(new ImageIcon( + DesktopUtilActivator.getImage("service.gui.icons.WARNING_ICON"))); } /** @@ -334,4 +331,13 @@ public void setIcon(Image image) { iconLabel.setIcon(new ImageIcon(image)); } + + /** + * Changes the icon in the dialog. + * @param image + */ + public void setIcon(ImageIcon image) + { + iconLabel.setIcon(image); + } } diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatOperationReasonDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatOperationReasonDialog.java similarity index 89% rename from src/net/java/sip/communicator/impl/gui/main/chat/ChatOperationReasonDialog.java rename to src/net/java/sip/communicator/plugin/desktoputil/chat/ChatOperationReasonDialog.java index b8f518ea6..ae59707b6 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatOperationReasonDialog.java +++ b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatOperationReasonDialog.java @@ -4,15 +4,15 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ -package net.java.sip.communicator.impl.gui.main.chat; +package net.java.sip.communicator.plugin.desktoputil.chat; import java.awt.*; import javax.swing.*; import javax.swing.event.*; -import net.java.sip.communicator.impl.gui.*; -import net.java.sip.communicator.impl.gui.customcontrols.*; +import net.java.sip.communicator.plugin.desktoputil.DesktopUtilActivator; +import net.java.sip.communicator.plugin.desktoputil.MessageDialog; /** * @@ -34,11 +34,11 @@ public class ChatOperationReasonDialog extends MessageDialog public ChatOperationReasonDialog() { this(null, - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.REASON"), - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.SPECIFY_REASON"), - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.OK"), true, false); @@ -54,11 +54,11 @@ public ChatOperationReasonDialog() public ChatOperationReasonDialog(boolean disableOKIfReasonIsEmpty) { this(null, - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.REASON"), - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.SPECIFY_REASON"), - GuiActivator.getResources().getI18NString( + DesktopUtilActivator.getResources().getI18NString( "service.gui.OK"), true, disableOKIfReasonIsEmpty); @@ -75,7 +75,7 @@ public ChatOperationReasonDialog(String title, String message) this(null, title, message, - GuiActivator.getResources().getI18NString("service.gui.OK"), + DesktopUtilActivator.getResources().getI18NString("service.gui.OK"), true, false); @@ -97,7 +97,7 @@ public ChatOperationReasonDialog(String title, String message, this(null, title, message, - GuiActivator.getResources().getI18NString("service.gui.OK"), + DesktopUtilActivator.getResources().getI18NString("service.gui.OK"), showReasonLabel, disableOKIfReasonIsEmpty); } @@ -144,7 +144,7 @@ public ChatOperationReasonDialog(Frame chatWindow, String title, JLabel reasonLabel = new JLabel( showReasonLabel - ? (GuiActivator.getResources().getI18NString( + ? (DesktopUtilActivator.getResources().getI18NString( "service.gui.REASON") + ":") : ""); diff --git a/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java new file mode 100644 index 000000000..cd7ed11b4 --- /dev/null +++ b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java @@ -0,0 +1,196 @@ +/** + * + */ +package net.java.sip.communicator.plugin.desktoputil.chat; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; +import javax.swing.border.*; + +import net.java.sip.communicator.plugin.desktoputil.*; +import net.java.sip.communicator.service.protocol.*; +import net.java.sip.communicator.util.*; + +/** + * @author Ico + * + */ +/** + * Dialog with fields for nickname and subject. + */ +public class ChatRoomJoinOptionsDialog extends ChatOperationReasonDialog +{ + /** + * Serial id. + */ + private static final long serialVersionUID = -916498752420264164L; + + /** + * Text field for the subject. + */ + private SIPCommTextField subject = new SIPCommTextField(DesktopUtilActivator + .getResources().getI18NString("service.gui.SUBJECT")); + + /** + * Label that hides and shows the subject fields panel on click. + */ + private JLabel cmdExpandSubjectFields; + + /** + * Panel that holds the subject fields. + */ + private JPanel subjectFieldsPannel = new JPanel(new BorderLayout()); + + /** + * Adds the subject fields to dialog. Sets action listeners. + * + * @param title the title of the dialog + * @param message the message shown in this dialog + * @param disableOKIfReasonIsEmpty if true the OK button will be + * disabled if the reason text is empty. + * @param showReasonLabel specify if we want the "Reason:" label + * @param dontDisplaySubjectFields if true the sibject fields will be + * hidden. + */ + public ChatRoomJoinOptionsDialog(String title, String message, + boolean showReasonLabel, + boolean disableOKIfReasonIsEmpty, + boolean dontDisplaySubjectFields) + { + super(title, + message, + showReasonLabel, + disableOKIfReasonIsEmpty); + + if(dontDisplaySubjectFields) + return; + + JPanel subjectPanel = new JPanel(new BorderLayout()); + subjectPanel.setOpaque(false); + subjectPanel.setBorder( + BorderFactory.createEmptyBorder(10, 0, 0, 0)); + + subjectFieldsPannel.setBorder( + BorderFactory.createEmptyBorder(10, 30, 0, 0)); + subjectFieldsPannel.setOpaque(false); + subjectFieldsPannel.add(subject, BorderLayout.CENTER); + subjectFieldsPannel.setVisible(false); + subject.setFont(getFont().deriveFont(12f)); + + cmdExpandSubjectFields = new JLabel(); + cmdExpandSubjectFields.setBorder(new EmptyBorder(0, 5, 0, 0)); + cmdExpandSubjectFields.setIcon(DesktopUtilActivator.getResources() + .getImage("service.gui.icons.RIGHT_ARROW_ICON")); + cmdExpandSubjectFields.setText(DesktopUtilActivator + .getResources().getI18NString("service.gui.SET_SUBJECT")); + cmdExpandSubjectFields.addMouseListener(new MouseAdapter() + { + @Override + public void mouseClicked(MouseEvent e) + { + cmdExpandSubjectFields.setIcon( + UtilActivator.getResources().getImage( + subjectFieldsPannel.isVisible() + ? "service.gui.icons.RIGHT_ARROW_ICON" + : "service.gui.icons.DOWN_ARROW_ICON")); + + subjectFieldsPannel.setVisible( + !subjectFieldsPannel.isVisible()); + + pack(); + } + }); + subjectPanel.add(cmdExpandSubjectFields,BorderLayout.NORTH); + subjectPanel.add(subjectFieldsPannel,BorderLayout.CENTER); + addToReasonFieldPannel(subjectPanel); + this.pack(); + } + + /** + * Returns the text entered in the subject field. + * + * @return the text from the subject field. + */ + public String getSubject() + { + return subject.getText(); + } + + /** + * Opens a dialog with a fields for the nickname and the subject of the room + * and returns them. + * + * @param pps the protocol provider associated with the chat room. + * @param chatRoomId the id of the chat room. + * @return array with the nickname and subject values. + */ + public static String[] getJoinOptions(ProtocolProviderService pps, + String chatRoomId) + { + return getJoinOptions(false, pps, chatRoomId); + } + + /** + * Opens a dialog with a fields for the nickname and the subject of the room + * and returns them. + * + * @param dontDisplaySubjectFields if true the subject fields will be hidden + * @return array with the nickname and subject values. + */ + public static String[] getJoinOptions(boolean dontDisplaySubjectFields, + ProtocolProviderService pps, String chatRoomId) + { + String nickName = null; + ChatRoomJoinOptionsDialog reasonDialog = + new ChatRoomJoinOptionsDialog(DesktopUtilActivator.getResources() + .getI18NString("service.gui.CHANGE_NICKNAME"), + DesktopUtilActivator.getResources().getI18NString( + "service.gui.CHANGE_NICKNAME_LABEL"), false, true, + dontDisplaySubjectFields); + reasonDialog.setIcon(new ImageIcon(DesktopUtilActivator.getImage( + "service.gui.icons.CHANGE_NICKNAME_16x16"))); + + final OperationSetServerStoredAccountInfo accountInfoOpSet + = pps.getOperationSet( + OperationSetServerStoredAccountInfo.class); + + String displayName = ""; + if (accountInfoOpSet != null) + { + displayName = AccountInfoUtils.getDisplayName(accountInfoOpSet); + } + + if(displayName == null || displayName.length() == 0) + { + displayName = DesktopUtilActivator.getGlobalDisplayDetailsService() + .getGlobalDisplayName(); + if(displayName == null || displayName.length() == 0) + { + displayName = pps.getAccountID().getUserID(); + if(displayName != null) + { + int atIndex = displayName.lastIndexOf("@"); + if (atIndex > 0) + displayName = displayName.substring(0, atIndex); + } + } + } + reasonDialog.setReasonFieldText(displayName); + + int result = reasonDialog.showDialog(); + + if (result == MessageDialog.OK_RETURN_CODE) + { + nickName = reasonDialog.getReason().trim(); + ConfigurationUtils.updateChatRoomProperty( + pps, + chatRoomId, "userNickName", nickName); + + } + String[] joinOptions = {nickName, reasonDialog.getSubject()}; + return joinOptions; + } + +} diff --git a/src/net/java/sip/communicator/plugin/desktoputil/desktoputil.manifest.mf b/src/net/java/sip/communicator/plugin/desktoputil/desktoputil.manifest.mf index 4b91013e6..91f2af6ff 100644 --- a/src/net/java/sip/communicator/plugin/desktoputil/desktoputil.manifest.mf +++ b/src/net/java/sip/communicator/plugin/desktoputil/desktoputil.manifest.mf @@ -59,7 +59,8 @@ Import-Package: com.sun.awt, org.xml.sax, sun.awt.shell, sun.net.dns, - sun.net.util + sun.net.util, + net.java.sip.communicator.service.globaldisplaydetails Export-Package: net.java.sip.communicator.plugin.desktoputil, net.java.sip.communicator.plugin.desktoputil.border, net.java.sip.communicator.plugin.desktoputil.event, @@ -67,4 +68,5 @@ Export-Package: net.java.sip.communicator.plugin.desktoputil, net.java.sip.communicator.plugin.desktoputil.presence, net.java.sip.communicator.plugin.desktoputil.presence.avatar, net.java.sip.communicator.plugin.desktoputil.transparent, - net.java.sip.communicator.plugin.desktoputil.wizard + net.java.sip.communicator.plugin.desktoputil.wizard, + net.java.sip.communicator.plugin.desktoputil.chat diff --git a/src/net/java/sip/communicator/service/customcontactactions/ContactActionMenuItem.java b/src/net/java/sip/communicator/service/customcontactactions/ContactActionMenuItem.java new file mode 100644 index 000000000..1c97623bb --- /dev/null +++ b/src/net/java/sip/communicator/service/customcontactactions/ContactActionMenuItem.java @@ -0,0 +1,87 @@ +/* + * 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.service.customcontactactions; + +import net.java.sip.communicator.service.contactsource.SourceContact; +import net.java.sip.communicator.service.protocol.*; + +/** + * A custom contact action menu item, used to define an action that can be + * represented in the contact list entry in the user interface. + * + * @author Hristo Terezov + */ +public interface ContactActionMenuItem +{ + /** + * Invoked when an action occurs. + * + * @param actionSource the source of the action + */ + public void actionPerformed(T actionSource) + throws OperationFailedException; + + /** + * The icon used by the UI to visualize this action. + * @return the button icon. + */ + public byte[] getIcon(); + + /** + * Returns the text of the component to create for this contact + * action. + * + * @return the tool tip text of the component to create for this contact + * action + */ + public String getText(); + + /** + * Indicates if this action is visible for the given actionSource. + * + * @param actionSource the action source for which we're verifying the + * action. + * @return true if the action should be visible for the given + * actionSource, false - otherwise + */ + public boolean isVisible(T actionSource); + + /** + * + * @return + */ + public char getMnemonics(); + + /** + * Returns true if the item should be enabled and false + * - not. + * + * @param actionSource the action source for which we're verifying the + * action. + * @return true if the item should be enabled and false + * - not. + */ + public boolean isEnabled(T actionSource); + + /** + * Returns true if the item should be a check box and + * false if not + * + * @return true if the item should be a check box and + * false if not + */ + public boolean isCheckBox(); + + /** + * Returns the state of the item if the item is check box. + * + * @param actionSource the action source for which we're verifying the + * action. + * @return the state of the item. + */ + public boolean isSelected(T actionSource); +} \ No newline at end of file diff --git a/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java b/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java index 3aaf0badd..52c4b4d58 100644 --- a/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java +++ b/src/net/java/sip/communicator/service/customcontactactions/CustomContactActionsService.java @@ -29,4 +29,11 @@ public interface CustomContactActionsService * @return an iterator over a list of ContactActions */ public Iterator> getCustomContactActions(); + + /** + * Returns all custom actions menu items defined by this service. + * + * @return an iterator over a list of ContactActionMenuItems + */ + public Iterator> getCustomContactActionsMenuItems(); } diff --git a/src/net/java/sip/communicator/service/gui/UIContact.java b/src/net/java/sip/communicator/service/gui/UIContact.java index e842cbb72..0c3b34333 100644 --- a/src/net/java/sip/communicator/service/gui/UIContact.java +++ b/src/net/java/sip/communicator/service/gui/UIContact.java @@ -10,6 +10,8 @@ import java.util.*; import java.util.List; +import javax.swing.*; + import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.service.protocol.*; @@ -136,4 +138,16 @@ public int getPreferredHeight() { return -1; } + + /** + * Returns all custom action menu items for this contact. + * + * @param initActions if true the actions will be reloaded. + * @return a list of all custom action menu items for this contact. + */ + public Collection getContactCustomActionMenuItems( + boolean initActions) + { + return null; + } } diff --git a/src/net/java/sip/communicator/service/gui/UIService.java b/src/net/java/sip/communicator/service/gui/UIService.java index 68ab90734..ffdd05234 100644 --- a/src/net/java/sip/communicator/service/gui/UIService.java +++ b/src/net/java/sip/communicator/service/gui/UIService.java @@ -13,6 +13,7 @@ import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.event.*; +import net.java.sip.communicator.service.muc.ChatRoomWrapper; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.account.*; @@ -49,6 +50,7 @@ * @author Dmitri Melnikov * @author Adam Netocny * @author Lyubomir Marinov + * @author Hristo Terezov */ public interface UIService { @@ -473,4 +475,19 @@ public ContactList createContactListComponent( * @return the login manager used by the current UI implementation */ public LoginManager getLoginManager(); + + /** + * Opens a chat room window for the given ChatRoomWrapper instance. + * + * @param chatRoom the chat room associated with the chat room window + */ + public void openChatRoomWindow(ChatRoomWrapper chatRoom); + + /** + * Closes the chat room window for the given ChatRoomWrapper + * instance. + * + * @param chatRoom the chat room associated with the chat room window + */ + public void closeChatRoomWindow(ChatRoomWrapper chatRoom); }