Issue #2700 fixed subscribe back after contact request accept
we were sending the wrong presence type when accepting request pidgin handled it, but it wasn't to the spec fixed by adding contact to roster if not already a friend request authorization dialog doesn't prompt for group if they are already in one Former-commit-id:dc59e8fa2d
[formerly7176bf59b8
] [formerlyb88eaeb73e
] [formerlydc59e8fa2d
[formerly7176bf59b8
] [formerlyb88eaeb73e
] [formerlyb0402be1d3
[formerlyb88eaeb73e
[formerly 4d860337ea821975b6ddb4846f102199347a4dcc]]]] Former-commit-id:b0402be1d3
Former-commit-id:7678703ae0
[formerly9210aae10a
] [formerly 49b91dbbac727f3af22f35a351ce544d8ce31b75 [formerlyb651ada4b3
]] Former-commit-id: e467e72241d8923b566978180702bf8b00148966 [formerly7e1425c419
] Former-commit-id:f2a97eb00e
This commit is contained in:
parent
b9a7590177
commit
fb03f7b570
3 changed files with 65 additions and 14 deletions
|
@ -23,7 +23,9 @@ import java.util.Arrays;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.PacketListener;
|
||||
import org.jivesoftware.smack.Roster.SubscriptionMode;
|
||||
import org.jivesoftware.smack.RosterEntry;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.filter.PacketTypeFilter;
|
||||
import org.jivesoftware.smack.packet.Packet;
|
||||
|
@ -64,6 +66,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
|||
* Dec 6, 2013 2561 bclement removed ECF
|
||||
* Jan 07, 2013 2563 bclement fixed id parsing in auto responder
|
||||
* Jan 27, 2014 2700 bclement changes to subscription request responders
|
||||
* Jan 31, 2014 2700 bclement fixed subscribe back after accepting subscription
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -154,16 +157,13 @@ public class AccountManager implements IAccountManager {
|
|||
*/
|
||||
private void handleSubRequest(UserId fromId, boolean accept) {
|
||||
Presence.Type subscribedType;
|
||||
|
||||
ContactsManager cm = sessionManager.getContactsManager();
|
||||
boolean addToRoster = false;
|
||||
if (accept) {
|
||||
ContactsManager cm = sessionManager.getContactsManager();
|
||||
subscribedType = Presence.Type.subscribed;
|
||||
RosterEntry entry = cm.getRosterEntry(fromId);
|
||||
if (entry == null || ContactsManager.isBlocked(entry)) {
|
||||
// we aren't subscribed to them, subscribe back
|
||||
subscribedType = Presence.Type.subscribe;
|
||||
} else {
|
||||
// we are already subscribed, let them know
|
||||
subscribedType = Presence.Type.subscribed;
|
||||
if (entry == null) {
|
||||
addToRoster = true;
|
||||
}
|
||||
} else {
|
||||
subscribedType = Presence.Type.unsubscribed;
|
||||
|
@ -172,6 +172,9 @@ public class AccountManager implements IAccountManager {
|
|||
Presence presence = new Presence(subscribedType);
|
||||
try {
|
||||
sendPresence(fromId, presence);
|
||||
if (addToRoster) {
|
||||
cm.addToRoster(fromId);
|
||||
}
|
||||
} catch (CollaborationException e) {
|
||||
AccountManager.this.log.error("Unable to send presence", e);
|
||||
}
|
||||
|
@ -192,8 +195,10 @@ public class AccountManager implements IAccountManager {
|
|||
AccountManager(
|
||||
CollaborationConnection manager) {
|
||||
sessionManager = manager;
|
||||
XMPPConnection xmppConnection = manager.getXmppConnection();
|
||||
smackManager = new org.jivesoftware.smack.AccountManager(
|
||||
manager.getXmppConnection());
|
||||
xmppConnection);
|
||||
xmppConnection.getRoster().setSubscriptionMode(SubscriptionMode.manual);
|
||||
sessionManager.getXmppConnection().addPacketListener(subscriptionEventListener,
|
||||
new PacketTypeFilter(Presence.class));
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.jivesoftware.smack.RosterGroup;
|
|||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
import org.jivesoftware.smack.packet.Presence.Type;
|
||||
import org.jivesoftware.smack.packet.RosterPacket.ItemStatus;
|
||||
import org.jivesoftware.smack.packet.RosterPacket.ItemType;
|
||||
import org.jivesoftware.smack.packet.XMPPError;
|
||||
|
@ -68,6 +69,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConn
|
|||
* Jan 27, 2014 2700 bclement fixed ungrouped entries being out of date
|
||||
* added utility methods for subscription status
|
||||
* Jan 30, 2014 2698 bclement removed unneeded nickname changed event
|
||||
* Jan 31, 2014 2700 bclement added addToRoster, fixed add to group when in roster, but blocked
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -182,9 +184,20 @@ public class ContactsManager {
|
|||
String id = user.getNormalizedId();
|
||||
RosterEntry entry = group.getEntry(id);
|
||||
if (entry != null) {
|
||||
statusHandler
|
||||
.debug("Attempted to add user to group it was already in: "
|
||||
+ id + " in " + groupName);
|
||||
if (isBlocked(entry)) {
|
||||
// entry is in roster, but we aren't subscribed. Request a
|
||||
// subscription.
|
||||
try {
|
||||
connection.getAccountManager().sendPresence(user,
|
||||
new Presence(Type.subscribe));
|
||||
} catch (CollaborationException e) {
|
||||
statusHandler.error("Problem subscribing to user", e);
|
||||
}
|
||||
} else {
|
||||
statusHandler
|
||||
.debug("Attempted to add user to group it was already in: "
|
||||
+ id + " in " + groupName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
@ -225,6 +238,31 @@ public class ContactsManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that user is in roster.
|
||||
*
|
||||
* @param user
|
||||
* @throws CollaborationException
|
||||
*/
|
||||
public void addToRoster(UserId user) throws CollaborationException {
|
||||
RosterEntry entry = getRosterEntry(user);
|
||||
if (entry == null) {
|
||||
// we dont have user as a contact at all
|
||||
// ensure that the user object is up-to-date
|
||||
user = findUser(user.getName());
|
||||
String alias = user.getAlias();
|
||||
if (StringUtils.isBlank(alias)) {
|
||||
alias = user.getName();
|
||||
}
|
||||
try {
|
||||
getRoster().createEntry(user.getFQName(), alias, new String[0]);
|
||||
} catch (XMPPException e) {
|
||||
throw new CollaborationException(
|
||||
"Unable to add user to roster: " + user, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove user from group.
|
||||
*
|
||||
|
@ -380,7 +418,7 @@ public class ContactsManager {
|
|||
public Collection<RosterGroup> getGroups(UserId user) {
|
||||
RosterEntry entry = getRoster().getEntry(user.getNormalizedId());
|
||||
if (entry == null) {
|
||||
statusHandler.error("Requested groups for user not in roster: "
|
||||
statusHandler.debug("Requested groups for user not in roster: "
|
||||
+ user);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 27, 2014 2700 bclement Initial creation
|
||||
* Jan 31, 2014 2700 bclement don't prompt for group if user is already in one
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -129,10 +130,17 @@ public class SubRequestDialog extends Dialog {
|
|||
groupComposite.setLayoutData(new GridData(SWT.LEFT, SWT.DEFAULT,
|
||||
true, false));
|
||||
new Label(groupComposite, SWT.NONE).setText("Group: ");
|
||||
|
||||
groupCombo = new Combo(groupComposite, SWT.BORDER | SWT.READ_ONLY
|
||||
| SWT.DROP_DOWN);
|
||||
groupCombo.setItems(getGroupNames());
|
||||
CollaborationConnection conn = CollaborationConnection.getConnection();
|
||||
Collection<RosterGroup> groups = conn.getContactsManager().getGroups(
|
||||
userid);
|
||||
if (!groups.isEmpty()) {
|
||||
// we already have this user in a group in our roster, no need to
|
||||
// prompt
|
||||
groupComposite.setVisible(false);
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue