Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

PT-39474097: Remove mybuddy messages with call event state - fix pres…

…erving new presence, when changed during call
  • Loading branch information...
commit 1ed0dca6bf2625d47fb4cd2c000452c411834c6e 1 parent 1b97fa1
@mirceac mirceac authored
View
5 sipXopenfire/sqa-plugin/src/org/sipfoundry/openfire/sqa/PresenceEventListenerImpl.java
@@ -53,11 +53,14 @@ public void presenceChanged(ClientSession arg0, Presence presence) {
User user = m_users.getUserByJid(userJid);
String callingPartyId = previousPresenceBean.getCallingPartiId();
User callingParty = m_users.getUser(callingPartyId);
+ //Presence changed - save new presence and broadcast -on the phone- to roster
+ m_presenceCache.put(userJid, new SipPresenceBean(presence.getStatus(), callingPartyId));
String presenceMessage = Utils.generateXmppStatusMessageWithSipState(user, callingParty, presence, callingPartyId);
org.jivesoftware.openfire.user.User ofObserverUser = null;
try {
ofObserverUser = XMPPServer.getInstance().getUserManager().getUser(userJid);
- Utils.setPresenceStatus(ofObserverUser, presence, presenceMessage);
+ presence.setStatus(presenceMessage);
+ ofObserverUser.getRoster().broadcastPresence(presence);
} catch (UserNotFoundException e) {
logger.debug("Cannot update user presence ", e);
}
View
43 sipXopenfire/sqa-plugin/src/org/sipfoundry/openfire/sqa/SqaEventHandler.java
@@ -99,57 +99,38 @@ public void run() {
logger.debug("Observer JID (IM Entity that sent the message): " + observerJID.getNode());
org.jivesoftware.openfire.user.User ofObserverUser = m_server.getUserManager().getUser(observerJID.getNode());
Presence presence = m_server.getPresenceManager().getPresence(ofObserverUser);
- String body = null;
- if (ringing) {
- if (StringUtils.equals(observerId, targetSipId)) {
- body = Utils.getDisplayName(user, sipId) + " calls you: your phone is ringing";
- }
- } else if (confirmed) {
- if (StringUtils.equals(observerId, targetSipId)) {
- body = "Call established with: " + Utils.getDisplayName(user, sipId);
- }
+ if (presence == null) {
+ logger.debug("User is OFFLINE -- cannot set presence state");
+ return;
+ }
+ if (confirmed) {
SipPresenceBean previousPresenceBean = m_presenceCache.get(observerJID.getNode());
//if cache is not cleared, than this is a new incomming call, do not broadcast on the call status again
- if (previousPresenceBean == null && presence != null) {
+ if (previousPresenceBean == null) {
logger.debug("ObserverPartyUser " + observerPartyUser + " observer party id " + observerPartyId);
String presenceMessage = Utils.generateXmppStatusMessageWithSipState(observerUser, observerPartyUser, presence, observerPartyId);
//presence status is about to be changed - save current presence
if (presenceMessage != null) {
+ //save current presence and broadcast -on the phone- to roster
m_presenceCache.put(observerJID.getNode(), new SipPresenceBean(presence.getStatus(), observerPartyId));
- Utils.setPresenceStatus(ofObserverUser, presence, presenceMessage);
+ presence.setStatus(presenceMessage);
+ ofObserverUser.getRoster().broadcastPresence(presence);
}
}
} else if (terminated) {
- if (StringUtils.equals(observerId, targetSipId)) {
- body = "Call with: " + Utils.getDisplayName(user, sipId) + " is terminated";
- }
SipPresenceBean previousPresenceBean = m_presenceCache.get(observerJID.getNode());
if(previousPresenceBean != null) {
- Utils.setPresenceStatus(ofObserverUser, presence, previousPresenceBean.getStatusMessage());
+ //if on the phone and call terminated, broadcast previous presence, clear cache
+ presence.setStatus(previousPresenceBean.getStatusMessage());
+ ofObserverUser.getRoster().broadcastPresence(presence);
m_presenceCache.remove(observerJID.getNode());
}
}
- if (body != null && targetJid != null) {
- JID targetJID = m_server.createJID(targetJid, null);
- if (targetJID != null) {
- JID mybuddyJID = m_server.createJID(m_users.getImBotName(), null);
- sendMessage(mybuddyJID, targetJID, body);
- }
- }
} catch (Exception e) {
logger.error("Cannot parse packet: data ", e);
} finally {
IOUtils.closeQuietly(reader);
}
}
-
- private void sendMessage(JID from, JID to, String body) {
- Message message = new Message();
- message.setFrom(from);
- message.setTo(to);
- message.setBody(body);
- message.setType(Message.Type.chat);
- m_server.getMessageRouter().route(message);
- }
}
View
15 sipXopenfire/sqa-plugin/src/org/sipfoundry/openfire/sqa/Utils.java
@@ -17,7 +17,6 @@
package org.sipfoundry.openfire.sqa;
import org.apache.commons.lang.StringUtils;
-import org.jivesoftware.openfire.user.UserNotFoundException;
import org.sipfoundry.commons.userdb.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,18 +55,4 @@ public static String generateXmppStatusMessageWithSipState(User user, User calli
}
return xmppStatusMessageWithSipState;
}
-
- public static void setPresenceStatus(org.jivesoftware.openfire.user.User ofUser, Presence presence, String presenceMessage)
- throws UserNotFoundException {
-
- logger.debug("setPresenceStatus jid = " + ofUser.getUsername() + " presenceMessage = " + presenceMessage);
-
- if (presence == null) {
- logger.debug("User is OFFLINE -- cannot set presence state");
- return;
- }
- presence.setStatus(presenceMessage);
-
- ofUser.getRoster().broadcastPresence(presence);
- }
}
Please sign in to comment.
Something went wrong with that request. Please try again.