diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties index 8a34e09aa..9c5420e11 100644 --- a/resources/languages/resources.properties +++ b/resources/languages/resources.properties @@ -195,6 +195,7 @@ service.gui.MSG_DELIVERY_NOT_SUPPORTED=The protocol you are using doesn't suppor service.gui.MSG_DELIVERY_INTERNAL_ERROR=An internal error occured. This is most probably a bug. Please report it here: http://www.sip-communicator.org/index.php/Development/BugsAndIssues. Server returned error: {0} service.gui.MSG_DELIVERY_UNKNOWN_ERROR=Your message could not be delivered due to the following problem: {0}. service.gui.MSG_NOT_DELIVERED=A network problem occured. Please check your network configuration and try again. Server returned error: {0}. +service.gui.MSG_NOT_POSSIBLE=Messaging is not possible for this contact (it is not supported by the protocol) service.gui.MSG_RECEIVED={0} has sent you a message service.gui.MSG_SEND_CONNECTION_PROBLEM=You should be connected to be able to send messages. service.gui.MULTIPLE_LOGINS=You have logged in more than once with the same account. The following account: User name: {0}, Server name: {1} is currently disconnected. diff --git a/resources/languages/resources_de.properties b/resources/languages/resources_de.properties index 795481439..e0b9516d0 100644 --- a/resources/languages/resources_de.properties +++ b/resources/languages/resources_de.properties @@ -161,6 +161,7 @@ service.gui.MSG_DELIVERY_NOT_SUPPORTED=Das verwendetet Protokoll kann Nachrichte service.gui.MSG_DELIVERY_INTERNAL_ERROR=Ein interner Fehler ist aufgetreten. Dies ist wahrscheinlich ein Bug. Bitte melden Sie ihn unter http://www.sip-communicator.org/index.php/Development/BugsAndIssues service.gui.MSG_DELIVERY_UNKNOWN_ERROR=Ihre Nachricht konnte nicht zugestellt werden: service.gui.MSG_NOT_DELIVERED=Ein Netzwerkproblem ist aufgetreten. +service.gui.MSG_NOT_POSSIBLE=Nachrichtenversand ist für diesen Kontakt nicht möglich (dies wird vom verwendeten Protokoll nicht unterstützt). service.gui.MSG_RECEIVED={0} hat Ihnen eine Nachricht gesendet. service.gui.MSG_SEND_CONNECTION_PROBLEM=Sie sollen verbunden sein, um Nachrichten zu senden. service.gui.MULTIPLE_LOGINS=Sie sind mehrfach mit dem selben Konto verbunden. Das Konto User name: {0}, Server name: {1} ist derzeit nicht verbunden. diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java index 2f068f6ee..a9d5e6e24 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java @@ -155,6 +155,15 @@ public void setChatSession(ChatSession chatSession) initChatTransportSelectorBox(); + if (!transportSelectorBox.getMenu().isEnabled()) + { + // Show a message to the user that IM is not possible. + getChatConversationPanel().appendMessageToEnd("
" + + GuiActivator.getResources(). + getI18NString("service.gui.MSG_NOT_POSSIBLE") + + "
"); + } + //Enables to change the protocol provider by simply pressing the // CTRL-P key combination ActionMap amap = this.getActionMap(); @@ -947,10 +956,22 @@ private void initChatTransportSelectorBox() sendPanel.add(transportSelectorBox, 0); sendPanel.add(sendViaLabel, 0); + updateSendButtonStatus(); + this.revalidate(); this.repaint(); } + /** + * Sets the send button to the same state (enabled/ disabled) as the + * transportSelectorBox. + */ + private void updateSendButtonStatus() + { + getChatSendPanel().getSendButton(). + setEnabled(transportSelectorBox.getMenu().isEnabled()); + } + /** * Removes the send via selector box and label. */ @@ -1200,11 +1221,13 @@ public void setContactName(ChatContact chatContact, String name) public void addChatTransport(ChatTransport chatTransport) { transportSelectorBox.addChatTransport(chatTransport); + updateSendButtonStatus(); } public void removeChatTransport(ChatTransport chatTransport) { transportSelectorBox.removeChatTransport(chatTransport); + updateSendButtonStatus(); } public void setSelectedChatTransport(ChatTransport chatTransport) diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java index 23cfe6fef..239cbe940 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatTransportSelectorBox.java @@ -25,7 +25,7 @@ * chat window. The menu contains all protocol specific transports. In the case * of meta contact these would be all contacts for the currently selected meta * contact chat. - * + * * @author Yana Stamcheva */ public class ChatTransportSelectorBox @@ -53,6 +53,10 @@ public ChatTransportSelectorBox(ChatPanel chatPanel, this.add(menu); + // as a default disable the menu, it will be enabled as soon as we add + // a valid menu item + this.menu.setEnabled(false); + Iterator chatTransports = chatSession.getChatTransports(); while (chatTransports.hasNext()) { @@ -61,41 +65,62 @@ public ChatTransportSelectorBox(ChatPanel chatPanel, this.addChatTransport(chatTransport); } - this.setSelected(selectedChatTransport); + if (this.menu.getItemCount() > 0 && + selectedChatTransport.allowsInstantMessage()) + { + this.setSelected(selectedChatTransport); + } + } + + /* + * Sets the menu to enabled or disabled. The menu is enabled, as soon as it + * contains one or more items. If it is empty, it is disabled. + */ + private void updateEnableStatus() + { + this.menu.setEnabled(this.menu.getItemCount() > 0); } /** * Adds the given chat transport to the "send via" menu. - * + * Only add those that support IM. + * * @param chatTransport The chat transport to add. */ public void addChatTransport(ChatTransport chatTransport) { - Image img = createTransportStatusImage(chatTransport); + if (chatTransport.allowsInstantMessage()) + { + Image img = createTransportStatusImage(chatTransport); - JMenuItem menuItem = new JMenuItem( - chatTransport.getName(), - new ImageIcon(img)); + JMenuItem menuItem = new JMenuItem( + chatTransport.getName(), + new ImageIcon(img)); - menuItem.addActionListener(this); - this.transportMenuItems.put(chatTransport, menuItem); + menuItem.addActionListener(this); + this.transportMenuItems.put(chatTransport, menuItem); - this.menu.add(menuItem); + this.menu.add(menuItem); + + updateEnableStatus(); + } } - + /** * Removes the given chat transport from the "send via" menu. This method is * used to update the "send via" menu when a protocol contact is moved or * removed from the contact list. - * + * * @param chatTransport the chat transport to be removed */ public void removeChatTransport(ChatTransport chatTransport) { this.menu.remove(transportMenuItems.get(chatTransport)); this.transportMenuItems.remove(chatTransport); + + updateEnableStatus(); } - + /** * The listener of the chat transport selector box. */ @@ -124,7 +149,7 @@ public void actionPerformed(ActionEvent e) /** * Obtains the status icon for the given chat transport and * adds to it the account index information. - * + * * @param chatTransport The chat transport for which to create the image. * @return The indexed status image. */ @@ -162,7 +187,7 @@ public Image createTransportStatusImage(ChatTransport chatTransport) /** * Updates the chat transport presence status. - * + * * @param chatTransport The chat transport to update. */ public void updateTransportStatus(ChatTransport chatTransport) @@ -199,7 +224,7 @@ public void updateTransportStatus(ChatTransport chatTransport) /** * In the "send via" menu selects the given contact and sets the given icon * to the "send via" menu button. - * + * * @param chatTransport * @param icon */ @@ -222,7 +247,7 @@ private void setSelected(ChatTransport chatTransport, ImageIcon icon) this.menu.setToolTipText(tooltipText); } - + /** * Sets the selected contact to the given proto contact. * @param chatTransport the proto contact to select @@ -232,10 +257,10 @@ public void setSelected(ChatTransport chatTransport) this.setSelected(chatTransport, new ImageIcon(createTransportStatusImage(chatTransport))); } - + /** * Returns the protocol menu. - * + * * @return the protocol menu */ public SIPCommMenu getMenu() @@ -245,7 +270,7 @@ public SIPCommMenu getMenu() /** * Searches online contacts in the send via combo box. - * + * * @return TRUE if the send via combo box contains online contacts, otherwise * returns FALSE. */ diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java index 86c0cf5a4..d2a47f020 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java @@ -459,19 +459,22 @@ protected void initialize(String sipAddress, OperationSetPresence.class.getName() , opSetPersPresence); - // init instant messaging - OperationSetBasicInstantMessagingSipImpl opSetBasicIM = - new OperationSetBasicInstantMessagingSipImpl(this); - this.supportedOperationSets.put( - OperationSetBasicInstantMessaging.class.getName(), - opSetBasicIM); - - // init typing notifications - OperationSetTypingNotificationsSipImpl opSetTyping = - new OperationSetTypingNotificationsSipImpl(this, opSetBasicIM); - this.supportedOperationSets.put( - OperationSetTypingNotifications.class.getName(), - opSetTyping); + if (enablePresence) + { + // init instant messaging + OperationSetBasicInstantMessagingSipImpl opSetBasicIM = + new OperationSetBasicInstantMessagingSipImpl(this); + this.supportedOperationSets.put( + OperationSetBasicInstantMessaging.class.getName(), + opSetBasicIM); + + // init typing notifications + OperationSetTypingNotificationsSipImpl opSetTyping = + new OperationSetTypingNotificationsSipImpl(this, opSetBasicIM); + this.supportedOperationSets.put( + OperationSetTypingNotifications.class.getName(), + opSetTyping); + } // OperationSetVideoTelephony supportedOperationSets.put(