diff options
author | Damian Minkov <damencho@jitsi.org> | 2013-11-18 18:23:29 +0200 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2013-11-18 18:24:19 +0200 |
commit | eb2079f63a597829cabe4f86e22193225c93bf6e (patch) | |
tree | 867d45fbd6c81f1a084bc2c766890bc567057131 /src/net/java/sip/communicator/impl/gui | |
parent | 0e617eb15cb2e069b5861d528cee8d62a6d99d38 (diff) | |
download | jitsi-eb2079f63a597829cabe4f86e22193225c93bf6e.zip jitsi-eb2079f63a597829cabe4f86e22193225c93bf6e.tar.gz jitsi-eb2079f63a597829cabe4f86e22193225c93bf6e.tar.bz2 |
Removes some unnecessary listeners and avoid adding a sms message listener multiple times. Do not send typing notificaitons when sending sms.
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui')
4 files changed, 37 insertions, 103 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java index f20cb25..91df9bb 100644 --- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java @@ -597,6 +597,19 @@ public class MainFrame im.addMessageListener(getContactListPanel()); } + // Obtain the sms messaging operation set. + String smsOpSetClassName = OperationSetSmsMessaging + .class.getName(); + + if (supportedOperationSets.containsKey(smsOpSetClassName)) + { + OperationSetSmsMessaging sms + = (OperationSetSmsMessaging) + supportedOperationSets.get(smsOpSetClassName); + + sms.addMessageListener(getContactListPanel()); + } + // Obtain the typing notifications operation set. String tnOpSetClassName = OperationSetTypingNotifications .class.getName(); @@ -727,6 +740,18 @@ public class MainFrame im.removeMessageListener(getContactListPanel()); } + // Obtain the sms messaging operation set. + String smsOpSetClassName = OperationSetSmsMessaging.class.getName(); + + if (supportedOperationSets.containsKey(smsOpSetClassName)) + { + OperationSetSmsMessaging sms + = (OperationSetSmsMessaging) + supportedOperationSets.get(smsOpSetClassName); + + sms.removeMessageListener(getContactListPanel()); + } + // Obtain the typing notifications operation set. String tnOpSetClassName = OperationSetTypingNotifications .class.getName(); 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 2689ae2..d97f0da 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 @@ -1669,9 +1669,6 @@ public class ChatPanel return; } - smsChatTransport.addSmsMessageListener( - new SmsMessageListener(smsChatTransport)); - // We open the send SMS dialog. SendSmsDialog smsDialog = new SendSmsDialog(this, smsChatTransport, messageText); @@ -1903,105 +1900,6 @@ public class ChatPanel } /** - * Listens for SMS messages and shows them in the chat. - */ - private class SmsMessageListener implements MessageListener - { - /** - * Initializes a new <tt>SmsMessageListener</tt> instance. - * - * @param chatTransport Currently unused - */ - public SmsMessageListener(ChatTransport chatTransport) - { - } - - public void messageDelivered(MessageDeliveredEvent evt) - { - Message msg = evt.getSourceMessage(); - - Contact contact = evt.getDestinationContact(); - - addMessage( - contact.getDisplayName(), - new Date(), - Chat.OUTGOING_MESSAGE, - msg.getContent(), msg.getContentType()); - - addMessage( - contact.getDisplayName(), - new Date(), - Chat.ACTION_MESSAGE, - GuiActivator.getResources().getI18NString( - "service.gui.SMS_SUCCESSFULLY_SENT"), - "text"); - } - - public void messageDeliveryFailed(MessageDeliveryFailedEvent evt) - { - logger.error(evt.getReason()); - - String errorMsg = null; - - Message sourceMessage = (Message) evt.getSource(); - - Contact sourceContact = evt.getDestinationContact(); - - MetaContact metaContact = GuiActivator - .getContactListService().findMetaContactByContact(sourceContact); - - if (evt.getErrorCode() - == MessageDeliveryFailedEvent.OFFLINE_MESSAGES_NOT_SUPPORTED) - { - errorMsg = GuiActivator.getResources().getI18NString( - "service.gui.MSG_DELIVERY_NOT_SUPPORTED", - new String[]{sourceContact.getDisplayName()}); - } - else if (evt.getErrorCode() - == MessageDeliveryFailedEvent.NETWORK_FAILURE) - { - errorMsg = GuiActivator.getResources().getI18NString( - "service.gui.MSG_NOT_DELIVERED"); - } - else if (evt.getErrorCode() - == MessageDeliveryFailedEvent.PROVIDER_NOT_REGISTERED) - { - errorMsg = GuiActivator.getResources().getI18NString( - "service.gui.MSG_SEND_CONNECTION_PROBLEM"); - } - else if (evt.getErrorCode() - == MessageDeliveryFailedEvent.INTERNAL_ERROR) - { - errorMsg = GuiActivator.getResources().getI18NString( - "service.gui.MSG_DELIVERY_INTERNAL_ERROR"); - } - else { - errorMsg = GuiActivator.getResources().getI18NString( - "service.gui.MSG_DELIVERY_UNKNOWN_ERROR"); - } - - String reason = evt.getReason(); - if (reason != null) - errorMsg += " " + GuiActivator.getResources().getI18NString( - "service.gui.ERROR_WAS", - new String[]{reason}); - - addMessage( - metaContact.getDisplayName(), - new Date(), - Chat.OUTGOING_MESSAGE, - sourceMessage.getContent(), - sourceMessage.getContentType()); - - addErrorMessage( - metaContact.getDisplayName(), - errorMsg); - } - - public void messageReceived(MessageReceivedEvent evt) {} - } - - /** * Returns the date of the first message in history for this chat. * * @return the date of the first message in history for this chat. diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java index a37ce8c..433b701 100755 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatWritePanel.java @@ -550,7 +550,7 @@ public class ChatWritePanel */ public void keyTyped(KeyEvent e) { - if (ConfigurationUtils.isSendTypingNotifications()) + if (ConfigurationUtils.isSendTypingNotifications() && !smsMode) { if (typingState != OperationSetTypingNotifications.STATE_TYPING) { 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 9bf7b0e..82e0f6d 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 @@ -439,6 +439,17 @@ public class ContactListPane msg.getContentType(), msg.getMessageUID(), evt.getCorrectedMessageUID()); + + if(evt.isSmsMessage()) + { + chatPanel.addMessage( + contact.getDisplayName(), + new Date(), + Chat.ACTION_MESSAGE, + GuiActivator.getResources().getI18NString( + "service.gui.SMS_SUCCESSFULLY_SENT"), + "text"); + } } } |