Detects failed typing notifications.

cusax-fix
Damian Minkov 13 years ago
parent 1e0d76ee7f
commit 3f3ca000f0

Binary file not shown.

@ -139,6 +139,7 @@ service.gui.CONTACT_NOT_SUPPORTING_TELEPHONY=The chosen {0} contact doesn''t sup
service.gui.CONTACT_NOT_SUPPORTING_CHAT_CONF=The chosen {0} contact doesn''t support chat conferencing.
service.gui.CONTACT_PAUSED_TYPING={0} paused typing the message
service.gui.CONTACT_TYPING={0} is typing a message
service.gui.CONTACT_TYPING_SEND_FAILED=uh-oh...we couldn't tell {0} that you're writing
service.gui.CONTACT_INFO=&Contact info
service.gui.CONTACTLIST=Contactlist
service.gui.CONTACTS=Contacts

@ -379,6 +379,26 @@ public void addTypingNotification(String typingNotification)
repaint();
}
/**
* Adds a typing notification message to the conversation panel,
* saying that typin notifications has not been delivered.
*
* @param typingNotification the typing notification to show
*/
public void addErrorSendingTypingNotification(
String typingNotification)
{
typingNotificationLabel.setText(typingNotification);
if (typingNotification != null && !typingNotification.equals(" "))
typingNotificationLabel.setIcon(typingIcon);
else
typingNotificationLabel.setIcon(null);
revalidate();
repaint();
}
/**
* Removes the typing notification message from the conversation panel.
*/

@ -519,6 +519,50 @@ else if (typingState == OperationSetTypingNotifications.STATE_PAUSED)
}
}
/**
* Called to indicate that sending typing notification has failed.
*
* @param evt a <tt>TypingNotificationEvent</tt> containing the sender
* of the notification and its type.
*/
public void typingNotificationDeliveryFailed(TypingNotificationEvent evt)
{
if (typingTimer.isRunning())
typingTimer.stop();
String notificationMsg = "";
MetaContact metaContact = GuiActivator.getContactListService()
.findMetaContactByContact(evt.getSourceContact());
String contactName = metaContact.getDisplayName() + " ";
if (contactName.equals(""))
{
contactName = GuiActivator.getResources()
.getI18NString("service.gui.UNKNOWN") + " ";
}
ChatPanel chatPanel
= chatWindowManager.getContactChat(metaContact, false);
notificationMsg
= GuiActivator.getResources().getI18NString(
"service.gui.CONTACT_TYPING_SEND_FAILED",
new String[]{contactName});
// Proactive typing notification
if (!chatWindowManager.isChatOpenedFor(metaContact))
{
return;
}
if (chatPanel != null)
chatPanel.addErrorSendingTypingNotification(notificationMsg);
typingTimer.setMetaContact(metaContact);
typingTimer.start();
}
/**
* When a request has been received we show it to the user through the
* chat session renderer.

@ -6,8 +6,6 @@
*/
package net.java.sip.communicator.impl.protocol.jabber;
import java.util.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.jabberconstants.*;
@ -50,8 +48,8 @@ public class OperationSetTypingNotificationsJabberImpl
*/
private MessageEventManager messageEventManager = null;
private final Map<String, String> packetIDsTable
= new Hashtable<String, String>();
// private final Map<String, String> packetIDsTable
// = new Hashtable<String, String>();
/**
* The listener instance that we use to track chat states according to
@ -322,11 +320,11 @@ public void displayedNotificationRequested(String from, String packetID,
public void composingNotificationRequested(String from, String packetID,
MessageEventManager messageEventManager)
{
if(packetID != null)
{
String fromID = StringUtils.parseBareAddress(from);
packetIDsTable.put(fromID, packetID);
}
// if(packetID != null)
// {
// String fromID = StringUtils.parseBareAddress(from);
// packetIDsTable.put(fromID, packetID);
// }
}
public void offlineNotificationRequested(String from, String packetID,
@ -388,15 +386,19 @@ public void cancelledNotification(String from, String packetID)
* The listener that we use to track chat state notifications according
* to XEP-0085.
*/
private class SmackChatStateListener implements ChatStateListener
private class SmackChatStateListener
implements ChatStateListener
{
/**
* Called by smack when the state of a chat changes.
*
* @param chat the chat that is concerned by this event.
* @param state the new state of the chat.
* @param message the message containing the new chat state
*/
public void stateChanged(Chat chat, ChatState state)
public void stateChanged(Chat chat,
ChatState state,
org.jivesoftware.smack.packet.Message message)
{
if (logger.isTraceEnabled())
logger.trace(chat.getParticipant() + " entered the "
@ -411,20 +413,30 @@ public void stateChanged(Chat chat, ChatState state)
sourceContact = opSetPersPresence.createVolatileContact(fromID);
}
int evtCode = STATE_UNKNOWN;
if (ChatState.composing.equals(state))
{
fireTypingNotificationsEvent(sourceContact, STATE_TYPING);
evtCode = STATE_TYPING;
}
else if (ChatState.paused.equals(state)
|| ChatState.active.equals(state) )
{
fireTypingNotificationsEvent(sourceContact, STATE_PAUSED);
evtCode = STATE_PAUSED;
}
else if (ChatState.inactive.equals(state)
|| ChatState.gone.equals(state) )
{
fireTypingNotificationsEvent(sourceContact, STATE_STOPPED);
evtCode = STATE_STOPPED;
}
if(message.getError() != null)
fireTypingNotificationsDeliveryFailedEvent(
sourceContact, evtCode);
else if(evtCode != STATE_UNKNOWN)
fireTypingNotificationsEvent(sourceContact, STATE_STOPPED);
else
logger.warn("Unknown typing state!");
}
/**

@ -1012,6 +1012,15 @@ public void typingNotificationReceived(TypingNotificationEvent event)
}
}
/**
* Called to indicate that sending typing notification has failed.
*
* @param event a <tt>TypingNotificationEvent</tt> containing the sender
* of the notification and its type.
*/
public void typingNotificationDeliveryFailed(TypingNotificationEvent event)
{}
/**
* Implements CallListener.incomingCallReceived. When a call is received
* plays the ring phone sound to the user and gathers caller information

@ -133,6 +133,43 @@ public void fireTypingNotificationsEvent(
listener.typingNotificationReceived(evt);
}
/**
* Delivers a <tt>TypingNotificationEvent</tt> to all registered listeners
* for delivery failed event.
*
* @param sourceContact the contact who has sent the notification
* @param evtCode the code of the event to deliver
*/
public void fireTypingNotificationsDeliveryFailedEvent(
Contact sourceContact,
int evtCode)
{
TypingNotificationsListener[] listeners;
synchronized (typingNotificationsListeners)
{
listeners
= typingNotificationsListeners
.toArray(
new TypingNotificationsListener[
typingNotificationsListeners.size()]);
}
if (logger.isDebugEnabled())
logger.debug(
"Dispatching a TypingNotificationEvent to "
+ listeners.length
+ " listeners for typingNotificationDeliveryFailed. Contact "
+ sourceContact.getAddress()
+ " has now a typing status of "
+ evtCode);
TypingNotificationEvent evt
= new TypingNotificationEvent(sourceContact, evtCode);
for (TypingNotificationsListener listener : listeners)
listener.typingNotificationDeliveryFailed(evt);
}
/**
* Removes <tt>listener</tt> from the list of listeners registered for
* receiving <tt>TypingNotificationEvent</tt>s.

@ -25,4 +25,12 @@ public interface TypingNotificationsListener
* of the notification and its type.
*/
public void typingNotificationReceived(TypingNotificationEvent event);
/**
* Called to indicate that sending typing notification has failed.
*
* @param event a <tt>TypingNotificationEvent</tt> containing the sender
* of the notification and its type.
*/
public void typingNotificationDeliveryFailed(TypingNotificationEvent event);
}

@ -288,6 +288,15 @@ public void typingNotificationReceived(TypingNotificationEvent event)
}
}
/**
* Called to indicate that sending typing notification has failed.
*
* @param event a <tt>TypingNotificationEvent</tt> containing the sender
* of the notification and its type.
*/
public void typingNotificationDeliveryFailed(TypingNotificationEvent event)
{}
/**
* Blocks until at least one event is received or until waitFor
* miliseconds pass (whicever happens first).

@ -191,6 +191,16 @@ public void typingNotificationReceived(TypingNotificationEvent event)
}
}
/**
* Called to indicate that sending typing notification has failed.
*
* @param event a <tt>TypingNotificationEvent</tt> containing the sender
* of the notification and its type.
*/
public void typingNotificationDeliveryFailed(TypingNotificationEvent event)
{}
/**
* Blocks until at least one event is received or until waitFor
* miliseconds pass (whicever happens first).

@ -292,6 +292,15 @@ public void typingNotificationReceived(TypingNotificationEvent event)
}
}
/**
* Called to indicate that sending typing notification has failed.
*
* @param event a <tt>TypingNotificationEvent</tt> containing the sender
* of the notification and its type.
*/
public void typingNotificationDeliveryFailed(TypingNotificationEvent event)
{}
/**
* Blocks until at least one event is received or until waitFor
* miliseconds pass (whicever happens first).

@ -266,6 +266,15 @@ public void typingNotificationReceived(TypingNotificationEvent event)
}
}
/**
* Called to indicate that sending typing notification has failed.
*
* @param event a <tt>TypingNotificationEvent</tt> containing the sender
* of the notification and its type.
*/
public void typingNotificationDeliveryFailed(TypingNotificationEvent event)
{}
/**
* Blocks until at least one event is received or until waitFor
* miliseconds pass (whicever happens first).

@ -269,6 +269,15 @@ public void typingNotificationReceived(TypingNotificationEvent event)
}
}
/**
* Called to indicate that sending typing notification has failed.
*
* @param event a <tt>TypingNotificationEvent</tt> containing the sender
* of the notification and its type.
*/
public void typingNotificationDeliveryFailed(TypingNotificationEvent event)
{}
/**
* Blocks until at least one event is received or until waitFor
* miliseconds pass (whicever happens first).

Loading…
Cancel
Save