aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2011-04-19 09:29:56 +0000
committerDamian Minkov <damencho@jitsi.org>2011-04-19 09:29:56 +0000
commit01248b564c6f538bf2bfa304ca3300ee24e284a8 (patch)
tree507983d0042d3810a8b803043f70a1e8ea828184
parentf7fcd1d03598041044727aa4097dbcbf02bb742e (diff)
downloadjitsi-01248b564c6f538bf2bfa304ca3300ee24e284a8.zip
jitsi-01248b564c6f538bf2bfa304ca3300ee24e284a8.tar.gz
jitsi-01248b564c6f538bf2bfa304ca3300ee24e284a8.tar.bz2
Rename protocol contacts where possible.
-rw-r--r--src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java27
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java21
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java21
-rw-r--r--src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java10
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java23
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactListSipImpl.java6
-rw-r--r--src/net/java/sip/communicator/service/contactlist/MetaContactListService.java2
-rw-r--r--src/net/java/sip/communicator/service/protocol/AbstractOperationSetPersistentPresence.java14
-rw-r--r--src/net/java/sip/communicator/service/protocol/OperationSetPersistentPresence.java13
9 files changed, 131 insertions, 6 deletions
diff --git a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java
index 827b395..c1d68ee 100644
--- a/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java
+++ b/src/net/java/sip/communicator/impl/contactlist/MetaContactListServiceImpl.java
@@ -798,6 +798,33 @@ public class MetaContactListServiceImpl
((MetaContactImpl)metaContact).setDisplayName(newDisplayName);
+ Iterator<Contact> contacts = metaContact.getContacts();
+
+ while (contacts.hasNext())
+ {
+ Contact protoContact = contacts.next();
+
+ //get a persistent presence operation set
+ OperationSetPersistentPresence opSetPresence
+ = protoContact
+ .getProtocolProvider()
+ .getOperationSet(
+ OperationSetPersistentPresence.class);
+
+ if (opSetPresence != null)
+ {
+ try
+ {
+ opSetPresence.setDisplayName(protoContact, newDisplayName);
+ }
+ catch(Throwable t)
+ {
+ logger.error("Error renaming protocol contact: "
+ + protoContact, t);
+ }
+ }
+ }
+
fireMetaContactEvent(new MetaContactRenamedEvent(
metaContact, oldDisplayName, newDisplayName));
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
index d7ca13e..14269df 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/OperationSetPersistentPresenceJabberImpl.java
@@ -773,6 +773,27 @@ public class OperationSetPersistentPresenceJabberImpl
}
/**
+ * Sets the display name for <tt>contact</tt> to be <tt>newName</tt>.
+ * <p>
+ * @param contact the <tt>Contact</tt> that we are renaming
+ * @param newName a <tt>String</tt> containing the new display name for
+ * <tt>metaContact</tt>.
+ * @throws IllegalArgumentException if <tt>contact</tt> is not an
+ * instance that belongs to the underlying implementation.
+ */
+ public void setDisplayName(Contact contact, String newName)
+ throws IllegalArgumentException
+ {
+ assertConnected();
+
+ if(! (contact instanceof ContactJabberImpl) )
+ throw new IllegalArgumentException(
+ "Argument is not an jabber contact (contact=" + contact + ")");
+
+ ((ContactJabberImpl)contact).getSourceEntry().setName(newName);
+ }
+
+ /**
* Our listener that will tell us when we're registered to server
* and is ready to accept us as a listener.
*/
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java
index 92175d6..451126d 100644
--- a/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/msn/OperationSetPersistentPresenceMsnImpl.java
@@ -651,6 +651,27 @@ public class OperationSetPersistentPresenceMsnImpl
}
/**
+ * Sets the display name for <tt>contact</tt> to be <tt>newName</tt>.
+ * <p>
+ * @param contact the <tt>Contact</tt> that we are renaming
+ * @param newName a <tt>String</tt> containing the new display name for
+ * <tt>metaContact</tt>.
+ * @throws IllegalArgumentException if <tt>contact</tt> is not an
+ * instance that belongs to the underlying implementation.
+ */
+ public void setDisplayName(Contact contact, String newName)
+ throws IllegalArgumentException
+ {
+ assertConnected();
+
+ if( !(contact instanceof ContactMsnImpl) )
+ throw new IllegalArgumentException(
+ "The specified contact is not an msn contact." + contact);
+
+ ssContactList.setDisplayName((ContactMsnImpl)contact, newName);
+ }
+
+ /**
* Our listener that will tell us when we're registered to server
* and is ready to accept us as a listener.
*/
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java
index 449b3dd..13dbfcd 100644
--- a/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/msn/ServerStoredContactListMsnImpl.java
@@ -826,6 +826,16 @@ public class ServerStoredContactListMsnImpl
}
/**
+ * Changes the contact display name on the server.
+ * @param contact the contact to change,
+ * @param newName the new name.
+ */
+ void setDisplayName(ContactMsnImpl contact, String newName)
+ {
+ messenger.renameFriend(contact.getSourceContact().getEmail(), newName);
+ }
+
+ /**
* Waits for init in the contact list and populates the contacts and fills
* or resolves our contact list
*/
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java
index 60f9992..ecbdc2d 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java
@@ -2882,6 +2882,29 @@ public class OperationSetPresenceSipImpl
}
}
+ /**
+ * Sets the display name for <tt>contact</tt> to be <tt>newName</tt>.
+ * <p>
+ * @param contact the <tt>Contact</tt> that we are renaming
+ * @param newName a <tt>String</tt> containing the new display name for
+ * <tt>metaContact</tt>.
+ * @throws IllegalArgumentException if <tt>contact</tt> is not an
+ * instance that belongs to the underlying implementation.
+ */
+ public void setDisplayName(Contact contact, String newName)
+ throws IllegalArgumentException
+ {
+ assertConnected();
+
+ if (!(contact instanceof ContactSipImpl))
+ {
+ throw new IllegalArgumentException("The contact is not a SIP " +
+ "contact");
+ }
+
+ ssContactList.renameContact((ContactSipImpl) contact, newName);
+ }
+
/**
* Cancels the timer which handles all scheduled tasks and disposes of the
* currently existing tasks scheduled with it.
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactListSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactListSipImpl.java
index 35f4f76..8c1fa39 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactListSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactListSipImpl.java
@@ -480,7 +480,6 @@ public class ServerStoredContactListSipImpl
synchronized public void renameContact(
ContactSipImpl contact,
String newName)
- throws OperationFailedException
{
if (contact == null)
{
@@ -502,9 +501,8 @@ public class ServerStoredContactListSipImpl
catch (XCapException e)
{
contact.setDisplayName(oldName);
- throw new OperationFailedException(
- "Error while renaming XCAP group",
- OperationFailedException.NETWORK_FAILURE, e);
+ throw new IllegalStateException(
+ "Error while renaming XCAP group", e);
}
}
parentOperationSet.fireContactPropertyChangeEvent(
diff --git a/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java b/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java
index 463ece1..6d56a11 100644
--- a/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java
+++ b/src/net/java/sip/communicator/service/contactlist/MetaContactListService.java
@@ -299,8 +299,6 @@ public interface MetaContactListService
/**
* Sets the display name for <tt>metaContact</tt> to be <tt>newName</tt>.
- * The method will not in any way change any of the contacts wrapped by
- * this meta contact.
* <p>
* @param metaContact the <tt>MetaContact</tt> that we are renaming
* @param newName a <tt>String</tt> containing the new display name for
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetPersistentPresence.java b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetPersistentPresence.java
index 361321e..b153044 100644
--- a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetPersistentPresence.java
+++ b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetPersistentPresence.java
@@ -500,4 +500,18 @@ public abstract class AbstractOperationSetPersistentPresence<T extends ProtocolP
subscriptionListeners.remove(listener);
}
}
+
+ /**
+ * Sets the display name for <tt>contact</tt> to be <tt>newName</tt>.
+ * <p>
+ * @param contact the <tt>Contact</tt> that we are renaming
+ * @param newName a <tt>String</tt> containing the new display name for
+ * <tt>metaContact</tt>.
+ * @throws IllegalArgumentException if <tt>contact</tt> is not an
+ * instance that belongs to the underlying implementation.
+ */
+ public void setDisplayName(Contact contact, String newName)
+ throws IllegalArgumentException
+ {
+ }
}
diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetPersistentPresence.java b/src/net/java/sip/communicator/service/protocol/OperationSetPersistentPresence.java
index 51a4470..391349c 100644
--- a/src/net/java/sip/communicator/service/protocol/OperationSetPersistentPresence.java
+++ b/src/net/java/sip/communicator/service/protocol/OperationSetPersistentPresence.java
@@ -240,4 +240,17 @@ public interface OperationSetPersistentPresence
*/
public ContactGroup createUnresolvedContactGroup(String groupUID,
String persistentData, ContactGroup parentGroup);
+
+ /**
+ * Sets the display name for <tt>contact</tt> to be <tt>newName</tt>.
+ * <p>
+ * @param contact the <tt>Contact</tt> that we are renaming
+ * @param newName a <tt>String</tt> containing the new display name for
+ * <tt>metaContact</tt>.
+ * @throws IllegalArgumentException if <tt>contact</tt> is not an
+ * instance that belongs to the underlying implementation.
+ */
+ public void setDisplayName(Contact contact, String newName)
+ throws IllegalArgumentException;
+
}