Make sure that destination contacts for outgoing messages and typing notifications come from the same protocol.

cusax-fix
Emil Ivov 19 years ago
parent 0288e92107
commit 53abcaf360

@ -119,6 +119,11 @@ public void removeMessageListener(MessageListener listener)
public void sendInstantMessage(Contact to, Message message) throws
IllegalStateException, IllegalArgumentException
{
if( !(to instanceof ContactGibberishImpl) )
throw new IllegalArgumentException(
"The specified contact is not a Gibberish contact."
+ to);
MessageDeliveredEvent msgDeliveredEvt
= new MessageDeliveredEvent(
message, to, new Date());

@ -139,6 +139,12 @@ private void fireTypingNotificationsEvent(Contact sourceContact
public void sendTypingNotification(Contact notifiedContact, int typingState)
throws IllegalStateException, IllegalArgumentException
{
if( !(notifiedContact instanceof ContactGibberishImpl) )
throw new IllegalArgumentException(
"The specified contact is not a Gibberish contact."
+ notifiedContact);
String userID = notifiedContact.getAddress();
//if the user id is owr own id, then this message is being routed to us

@ -71,7 +71,7 @@ public class OperationSetBasicInstantMessagingIcqImpl
private OperationSetPersistentPresenceIcqImpl opSetPersPresence = null;
/**
* I do not why but we sometimes receive messages with a date in the future.
* I do not why but we sometimes receive messages with a date in the future.sdf
* I've decided to ignore such messages. I draw the line on
* currentTimeMillis() + ONE_DAY milliseconds. Anything with a date farther
* in the future is considered bogus and its date is replaced with current
@ -87,7 +87,7 @@ public class OperationSetBasicInstantMessagingIcqImpl
/**
* The interval after which a packet is considered to be lost
*/
private final static long KEEPALIVE_WAIT = 20000l;
private final static long KEEPALIVE_WAIT = 20000l; //20 secs
/**
* The task sending packets
@ -102,7 +102,11 @@ public class OperationSetBasicInstantMessagingIcqImpl
*/
private LinkedList receivedKeepAlivePackets = new LinkedList();
private static String SYS_MSG_PREFIX_TEST = "SIP COMMUNICATOR SYSTEM MESSAGE!";
/**
* The ping message prefix that we use in our keep alive thread.
*/
private static String SYS_MSG_PREFIX_TEST
= "SIP COMMUNICATOR SYSTEM MESSAGE!";
/**
@ -194,6 +198,12 @@ public void sendInstantMessage(Contact to, Message message)
{
assertConnected();
if( !(to instanceof ContactIcqImpl) )
throw new IllegalArgumentException(
"The specified contact is not a Icq contact."
+ to);
ImConversation imConversation =
icqProvider.getAimConnection().getIcbmService().
getImConversation(
@ -657,9 +667,11 @@ public void run()
}
catch (Exception ex)
{
logger.error(
"Exception occurred while retrieving keep alive packet."
, ex);
fireUnregistered();
}
}

@ -193,6 +193,12 @@ public void sendTypingNotification(Contact notifiedContact, int typingState)
{
assertConnected();
if( !(notifiedContact instanceof ContactIcqImpl) )
throw new IllegalArgumentException(
"The specified contact is not an ICQ contact."
+ notifiedContact);
icqProvider.getAimConnection().getIcbmService().getImConversation(
new Screenname(notifiedContact.getAddress())).setTypingState(
intToTypingState(typingState));

@ -154,6 +154,12 @@ public void sendInstantMessage(Contact to, Message message)
{
assertConnected();
if( !(to instanceof ContactMsnImpl) )
throw new IllegalArgumentException(
"The specified contact is not an MSN contact."
+ to);
if(to.getPresenceStatus().equals(MsnStatusEnum.OFFLINE))
{
MessageDeliveryFailedEvent evt =

@ -138,7 +138,8 @@ public void sendTypingNotification(Contact notifiedContact, int typingState)
if( !(notifiedContact instanceof ContactMsnImpl) )
throw new IllegalArgumentException(
"The specified contact is not an msn contact." + notifiedContact);
"The specified contact is not an MSN contact."
+ notifiedContact);
if(typingState == OperationSetTypingNotifications.STATE_TYPING)
{

@ -155,6 +155,12 @@ public void sendInstantMessage(Contact to, Message message)
{
assertConnected();
if( !(to instanceof ContactYahooImpl) )
throw new IllegalArgumentException(
"The specified contact is not a Yahoo contact."
+ to);
try
{
String toUserID = ((ContactYahooImpl) to).getID();
@ -243,7 +249,7 @@ private void fireMessageEvent(EventObject evt)
{
listeners = new ArrayList(messageListeners).iterator();
}
logger.debug("Dispatching msg evt. Listeners="
+ messageListeners.size()
+ " evt=" + evt);
@ -285,7 +291,7 @@ public void offlineMessageReceived(SessionEvent ev)
private void handleNewMessage(SessionEvent ev)
{
logger.debug("Message received : " + ev);
Message newMessage = createMessage(ev.getMessage());
Contact sourceContact = opSetPersPresence.

@ -133,13 +133,14 @@ public void sendTypingNotification(Contact notifiedContact, int typingState)
if( !(notifiedContact instanceof ContactYahooImpl) )
throw new IllegalArgumentException(
"The specified contact is not an yahoo contact." + notifiedContact);
"The specified contact is not an yahoo contact."
+ notifiedContact);
if(typingState == OperationSetTypingNotifications.STATE_TYPING)
{
yahooProvider.getYahooSession().
keyTyped(notifiedContact.getAddress(),
keyTyped(notifiedContact.getAddress(),
yahooProvider.getAccountID().getUserID());
}
else
@ -147,7 +148,7 @@ public void sendTypingNotification(Contact notifiedContact, int typingState)
typingState == OperationSetTypingNotifications.STATE_PAUSED)
{
yahooProvider.getYahooSession().
stopTyping(notifiedContact.getAddress(),
stopTyping(notifiedContact.getAddress(),
yahooProvider.getAccountID().getUserID());
}
}
@ -169,11 +170,11 @@ private void assertConnected() throws IllegalStateException
"The yahoo provider must be signed on the service before "
+"being able to communicate.");
}
private class TypingListener
extends SessionAdapter
{
public void notifyReceived(SessionNotifyEvent evt)
public void notifyReceived(SessionNotifyEvent evt)
{
if(evt.isTyping())
{
@ -181,18 +182,18 @@ public void notifyReceived(SessionNotifyEvent evt)
if(typingUserID != null)
{
Contact sourceContact =
Contact sourceContact =
opSetPersPresence.findContactByID(typingUserID);
if(sourceContact == null)
return;
// typing on
if(evt.getMode() == 1)
fireTypingNotificationsEvent(sourceContact, STATE_TYPING);
else
fireTypingNotificationsEvent(sourceContact, STATE_STOPPED);
}
}
}
}
}
@ -221,9 +222,9 @@ public void registrationStateChanged(RegistrationStateChangeEvent evt)
opSetPersPresence = (OperationSetPersistentPresenceYahooImpl)
yahooProvider.getSupportedOperationSets()
.get(OperationSetPersistentPresence.class.getName());
yahooProvider.getYahooSession().addSessionListener(new TypingListener());
}
}
}
}
}

Loading…
Cancel
Save