Commit 53e6ae31 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Fixed problem where a roster item was assumed to exist (implicitly) when using...

Fixed problem where a roster item was assumed to exist (implicitly) when using public shared groups. JM-647

git-svn-id: http://svn.igniterealtime.org/svn/repos/wildfire/trunk@3786 b35dd754-fafc-0310-a699-88a17e54d16e
parent 69349bb7
...@@ -82,7 +82,7 @@ public class Roster implements Cacheable { ...@@ -82,7 +82,7 @@ public class Roster implements Cacheable {
// Get the shared groups of this user // Get the shared groups of this user
Collection<Group> sharedGroups = rosterManager.getSharedGroups(username); Collection<Group> sharedGroups = rosterManager.getSharedGroups(username);
Collection<Group> userGroups = GroupManager.getInstance().getGroups(getUserJID());; Collection<Group> userGroups = GroupManager.getInstance().getGroups(getUserJID());
// Add RosterItems that belong to the personal roster // Add RosterItems that belong to the personal roster
rosterItemProvider = RosterItemProvider.getInstance(); rosterItemProvider = RosterItemProvider.getInstance();
...@@ -217,9 +217,12 @@ public class Roster implements Cacheable { ...@@ -217,9 +217,12 @@ public class Roster implements Cacheable {
// Check if there is a public shared group. That means that anyone can see this user. // Check if there is a public shared group. That means that anyone can see this user.
for (Group group : userGroups) { for (Group group : userGroups) {
if (rosterManager.isPulicSharedGroup(group)) { if (rosterManager.isPulicSharedGroup(group)) {
// Only local users may see public shared groups
if (server.isLocal(user)) {
return new RosterItem(user, RosterItem.SUB_FROM, RosterItem.ASK_NONE, return new RosterItem(user, RosterItem.SUB_FROM, RosterItem.ASK_NONE,
RosterItem.RECV_NONE, "", null); RosterItem.RECV_NONE, "", null);
} }
}
else if (rosterManager.isSharedGroup(group)) { else if (rosterManager.isSharedGroup(group)) {
// This is a shared group that can be seen only by group members or // This is a shared group that can be seen only by group members or
// (maybe) by other groups // (maybe) by other groups
...@@ -227,11 +230,8 @@ public class Roster implements Cacheable { ...@@ -227,11 +230,8 @@ public class Roster implements Cacheable {
} }
} }
if (!sharedGroups.isEmpty()) { if (!sharedGroups.isEmpty()) {
// Check if any group of contact may see a shared group of this user // Check if any group of the contact may see a shared group of this user
Collection<Group> contactGroups = GroupManager.getInstance().getGroups(user); Collection<Group> contactGroups = GroupManager.getInstance().getGroups(user);
if (contactGroups == null) {
return null;
}
for (Group sharedGroup : sharedGroups) { for (Group sharedGroup : sharedGroups) {
if (rosterManager.isSharedGroupVisible(sharedGroup, contactGroups)) { if (rosterManager.isSharedGroupVisible(sharedGroup, contactGroups)) {
return new RosterItem(user, RosterItem.SUB_FROM, RosterItem.ASK_NONE, return new RosterItem(user, RosterItem.SUB_FROM, RosterItem.ASK_NONE,
...@@ -342,7 +342,7 @@ public class Roster implements Cacheable { ...@@ -342,7 +342,7 @@ public class Roster implements Cacheable {
if (item.isShared() && item.getID() == 0) { if (item.isShared() && item.getID() == 0) {
// Do nothing if item is only shared and it is using the default user name // Do nothing if item is only shared and it is using the default user name
if (item.isOnlyShared()) { if (item.isOnlyShared()) {
String defaultContactName = null; String defaultContactName;
try { try {
defaultContactName = UserNameManager.getUserName(item.getJid()); defaultContactName = UserNameManager.getUserName(item.getJid());
} }
...@@ -942,7 +942,7 @@ public class Roster implements Cacheable { ...@@ -942,7 +942,7 @@ public class Roster implements Cacheable {
// Update the subscription of the item **based on the item groups** // Update the subscription of the item **based on the item groups**
if (item.isOnlyShared()) { if (item.isOnlyShared()) {
Collection<Group> userGroups = Collection<Group> userGroups =
userGroups = GroupManager.getInstance().getGroups(getUserJID()); GroupManager.getInstance().getGroups(getUserJID());
// Set subscription type to BOTH if the roster user belongs to a shared group // Set subscription type to BOTH if the roster user belongs to a shared group
// that is mutually visible with a shared group of the new roster item // that is mutually visible with a shared group of the new roster item
if (rosterManager if (rosterManager
...@@ -985,7 +985,7 @@ public class Roster implements Cacheable { ...@@ -985,7 +985,7 @@ public class Roster implements Cacheable {
if (userJID.equals(user)) { if (userJID.equals(user)) {
continue; continue;
} }
RosterItem item = null; RosterItem item;
try { try {
// Get the RosterItem for the *local* user to add // Get the RosterItem for the *local* user to add
item = getRosterItem(user); item = getRosterItem(user);
......
...@@ -372,12 +372,15 @@ public class RosterManager extends BasicModule implements GroupEventListener { ...@@ -372,12 +372,15 @@ public class RosterManager extends BasicModule implements GroupEventListener {
* @return true if any of the specified groups can see the shared group. * @return true if any of the specified groups can see the shared group.
*/ */
public boolean isSharedGroupVisible(Group sharedGroup, Collection<Group> groups) { public boolean isSharedGroupVisible(Group sharedGroup, Collection<Group> groups) {
if (groups.isEmpty()) {
return false;
}
Map<String, String> properties = sharedGroup.getProperties(); Map<String, String> properties = sharedGroup.getProperties();
String showInRoster = properties.get("sharedRoster.showInRoster"); String showInRoster = properties.get("sharedRoster.showInRoster");
if ("everybody".equals(showInRoster)) { if ("everybody".equals(showInRoster)) {
return true; return true;
} }
if ("onlyGroup".equals(showInRoster) && !groups.isEmpty()) { if ("onlyGroup".equals(showInRoster)) {
Collection<String> groupNames = new ArrayList<String>(groups.size()); Collection<String> groupNames = new ArrayList<String>(groups.size());
for (Group group : groups) { for (Group group : groups) {
groupNames.add(group.getName()); groupNames.add(group.getName());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment