aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2014-07-21 11:20:35 +0300
committerDamian Minkov <damencho@jitsi.org>2014-07-21 18:51:51 +0300
commita56bc6cac62efeff8494730281017c439686649a (patch)
treedbf6a930b02ecea3a270a93dd8a36b004ed72afa /src
parent56882c66bdd663fc691693a8c07bfd691d4ade40 (diff)
downloadjitsi-a56bc6cac62efeff8494730281017c439686649a.zip
jitsi-a56bc6cac62efeff8494730281017c439686649a.tar.gz
jitsi-a56bc6cac62efeff8494730281017c439686649a.tar.bz2
Does not try to modify metacontact list storage when adding contact to a non persistent group.
Diffstat (limited to 'src')
-rw-r--r--src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java5
-rw-r--r--src/net/java/sip/communicator/impl/protocol/mock/MockContact.java5
-rw-r--r--src/net/java/sip/communicator/impl/protocol/mock/MockContactGroup.java4
-rw-r--r--src/net/java/sip/communicator/impl/protocol/mock/MockPersistentPresenceOperationSet.java68
4 files changed, 82 insertions, 0 deletions
diff --git a/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java b/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java
index ae89f00..0183ae3 100644
--- a/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java
+++ b/src/net/java/sip/communicator/impl/contactlist/MclStorageManager.java
@@ -1265,6 +1265,11 @@ public class MclStorageManager
*/
public void metaContactAdded(MetaContactEvent evt)
{
+ // if the parent group is not persistent, do not do anything
+ // cause its missing in xml
+ if(!evt.getParentGroup().isPersistent())
+ return;
+
Element parentGroupNode =
findMetaContactGroupNode(evt.getParentGroup().getMetaUID());
diff --git a/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java b/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java
index a2bb441..bb5ab80 100644
--- a/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java
+++ b/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java
@@ -294,4 +294,9 @@ public class MockContact
{
return null;
}
+
+ public void setPersistent(boolean isPersistent)
+ {
+ this.isPersistent = isPersistent;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/protocol/mock/MockContactGroup.java b/src/net/java/sip/communicator/impl/protocol/mock/MockContactGroup.java
index 4287cc6..f1352ae 100644
--- a/src/net/java/sip/communicator/impl/protocol/mock/MockContactGroup.java
+++ b/src/net/java/sip/communicator/impl/protocol/mock/MockContactGroup.java
@@ -495,5 +495,9 @@ public class MockContactGroup
return true;
}
+ public void setPersistent(boolean isPersistent)
+ {
+ this.isPersistent = isPersistent;
+ }
}
diff --git a/src/net/java/sip/communicator/impl/protocol/mock/MockPersistentPresenceOperationSet.java b/src/net/java/sip/communicator/impl/protocol/mock/MockPersistentPresenceOperationSet.java
index dcccdc7..b8371fd 100644
--- a/src/net/java/sip/communicator/impl/protocol/mock/MockPersistentPresenceOperationSet.java
+++ b/src/net/java/sip/communicator/impl/protocol/mock/MockPersistentPresenceOperationSet.java
@@ -529,4 +529,72 @@ public class MockPersistentPresenceOperationSet
return newGroup;
}
+
+ /**
+ * Creates a non persistent contact for the specified id. This would
+ * also create (if necessary) a group for volatile contacts.
+ * @param id the address of the contact to create.
+ * @return the newly created volatile <tt>MockContact</tt>
+ */
+ public MockContact createVolatileContact(
+ String id)
+ {
+ MockContact newVolatileContact
+ = new MockContact(id, parentProvider);
+ newVolatileContact.setResolved(false);
+ newVolatileContact.setPersistent(false);
+
+ //Check whether a volatile group already exists and if not create
+ //one
+ MockContactGroup theVolatileGroup = getNonPersistentGroup();
+
+ //if the parent group is null then add necessary create the group
+ if (theVolatileGroup == null)
+ {
+ theVolatileGroup = new MockContactGroup(
+ "Not-In-Contactlist",
+ parentProvider);
+ theVolatileGroup.setResolved(false);
+ theVolatileGroup.setPersistent(false);
+
+ theVolatileGroup.addContact(newVolatileContact);
+
+ this.contactListRoot.addSubgroup(theVolatileGroup);
+
+ fireServerStoredGroupEvent(theVolatileGroup
+ , ServerStoredGroupEvent.GROUP_CREATED_EVENT);
+ }
+ else
+ {
+ theVolatileGroup.addContact(newVolatileContact);
+
+ fireSubscriptionEvent(
+ newVolatileContact,
+ theVolatileGroup,
+ SubscriptionEvent.SUBSCRIPTION_CREATED);
+ }
+
+ return newVolatileContact;
+ }
+
+ /**
+ * Returns the volatile group that we use when creating volatile contacts.
+ *
+ * @return MockContactGroup
+ */
+ public MockContactGroup getNonPersistentGroup()
+ {
+ String groupName = "Not-In-Contactlist";
+
+ for (int i = 0; i < contactListRoot.countSubgroups(); i++)
+ {
+ MockContactGroup gr =
+ (MockContactGroup)contactListRoot.getGroup(i);
+
+ if(!gr.isPersistent() && gr.getGroupName().equals(groupName))
+ return gr;
+ }
+
+ return null;
+ }
}