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 | |
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')
6 files changed, 92 insertions, 115 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"); + } } } diff --git a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java index a6e7e41..63ed172 100644 --- a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java +++ b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java @@ -1203,6 +1203,19 @@ public class MessageHistoryServiceImpl logger.trace("Service did not have a im op. set."); } + OperationSetSmsMessaging opSetSMS = + provider.getOperationSet(OperationSetSmsMessaging.class); + + if (opSetSMS != null) + { + opSetSMS.addMessageListener(this); + } + else + { + if (logger.isTraceEnabled()) + logger.trace("Service did not have a sms op. set."); + } + OperationSetMultiUserChat opSetMultiUChat = provider.getOperationSet(OperationSetMultiUserChat.class); @@ -1242,6 +1255,14 @@ public class MessageHistoryServiceImpl opSetIm.removeMessageListener(this); } + OperationSetSmsMessaging opSetSMS = + provider.getOperationSet(OperationSetSmsMessaging.class); + + if (opSetSMS != null) + { + opSetSMS.removeMessageListener(this); + } + OperationSetMultiUserChat opSetMultiUChat = provider.getOperationSet(OperationSetMultiUserChat.class); diff --git a/src/net/java/sip/communicator/service/protocol/event/MessageDeliveredEvent.java b/src/net/java/sip/communicator/service/protocol/event/MessageDeliveredEvent.java index 7e2c66c..065de96 100644 --- a/src/net/java/sip/communicator/service/protocol/event/MessageDeliveredEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/MessageDeliveredEvent.java @@ -25,20 +25,25 @@ public class MessageDeliveredEvent private static final long serialVersionUID = 0L; /** - * The contact that has sent this message. - */ - private Contact to = null; + * The contact that has sent this message. + */ + private Contact to = null; - /** - * A timestamp indicating the exact date when the event occurred. - */ - private final Date timestamp; + /** + * A timestamp indicating the exact date when the event occurred. + */ + private final Date timestamp; - /** - * The ID of the message being corrected, or null if this was a new message - * and not a message correction. - */ - private String correctedMessageUID; + /** + * The ID of the message being corrected, or null if this was a new message + * and not a message correction. + */ + private String correctedMessageUID; + + /** + * Whether the delivered message is a sms message. + */ + private boolean smsMessage = false; /** * Constructor. @@ -136,4 +141,21 @@ public class MessageDeliveredEvent this.correctedMessageUID = correctedMessageUID; } + /** + * Sets whether the message is a sms one. + * @param smsMessage whether it is a sms one. + */ + public void setSmsMessage(boolean smsMessage) + { + this.smsMessage = smsMessage; + } + + /** + * Returns whether the delivered message is a sms one. + * @return whether the delivered message is a sms one. + */ + public boolean isSmsMessage() + { + return smsMessage; + } } |