From 2aa1c430c970ff890b8fcfd61ead3cac0c7a65a9 Mon Sep 17 00:00:00 2001 From: Emil Ivov Date: Thu, 23 Mar 2006 23:06:10 +0000 Subject: [PATCH] cosmetics --- .../protocol/icq/ContactGroupIcqImpl.java | 2 +- ...OperationSetPersistentPresenceIcqImpl.java | 25 +++++++--------- .../protocol/icq/RootContactGroupIcqImpl.java | 6 ++-- .../service/protocol/ContactGroup.java | 2 +- .../protocol/event/MessageListener.java | 30 +++++++++++++++++-- .../event/ServerStoredGroupEvent.java | 14 +++++++++ .../TestOperationSetPersistentPresence.java | 2 +- .../slick/runner/XmlFormatter.java | 1 + 8 files changed, 58 insertions(+), 24 deletions(-) diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ContactGroupIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ContactGroupIcqImpl.java index 613a010f6..055f614ba 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ContactGroupIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ContactGroupIcqImpl.java @@ -240,7 +240,7 @@ public ContactGroup getGroup(String groupName) * * @return an empty iterator */ - public Iterator subGroups() + public Iterator subgroups() { return dummyGroupsList.iterator(); } diff --git a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java index 7186b3c8a..b885d88a8 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/OperationSetPersistentPresenceIcqImpl.java @@ -32,8 +32,6 @@ * status of our buddies. It also offers methods for retrieving and modifying * the buddy contact list and adding listeners for changes in its layout. * - * @todo add consistent logging - * * @author Emil Ivov */ public class OperationSetPersistentPresenceIcqImpl @@ -178,9 +176,6 @@ protected OperationSetPersistentPresenceIcqImpl( //add a listener that'll follow the provider's state. icqProvider.addRegistrationStateChangeListener( registrationStateListener); - /** @todo create local contact here */ - - } /** @@ -259,7 +254,7 @@ public void removeSubscriptionListener(SubscriptionListener listener) public PresenceStatus queryContactStatus(String contactIdentifier) throws IllegalStateException, IllegalArgumentException { - verifyConnected(); + assertConnected(); //these are commented since we now use identifiers. // if (!(contact instanceof ContactIcqImpl)) @@ -379,7 +374,7 @@ public void subscribe(String contactIdentifier) IllegalStateException, OperationFailedException { - verifyConnected(); + assertConnected(); ssContactList.addContact(contactIdentifier); } @@ -412,7 +407,7 @@ public void subscribe(ContactGroup parent, String contactIdentifier) IllegalStateException, OperationFailedException { - verifyConnected(); + assertConnected(); if(! (parent instanceof ContactGroupIcqImpl) ) throw new IllegalArgumentException( @@ -435,7 +430,7 @@ public void subscribe(ContactGroup parent, String contactIdentifier) public void unsubscribe(Contact contact) throws IllegalArgumentException, IllegalStateException, OperationFailedException { - verifyConnected(); + assertConnected(); if(! (contact instanceof ContactIcqImpl) ) throw new IllegalArgumentException( @@ -493,7 +488,7 @@ public void publishPresenceStatus(PresenceStatus status, IllegalArgumentException, IllegalStateException, OperationFailedException { - verifyConnected(); + assertConnected(); if (!(status instanceof IcqStatusEnum)) throw new IllegalArgumentException( @@ -552,7 +547,7 @@ public Contact getLocalContact() public void createServerStoredContactGroup(ContactGroup parent, String groupName) { - verifyConnected(); + assertConnected(); if (!parent.canContainSubgroups()) throw new IllegalArgumentException( @@ -575,7 +570,7 @@ public void createServerStoredContactGroup(ContactGroup parent, */ public void removeServerStoredContactGroup(ContactGroup group) { - verifyConnected(); + assertConnected(); if( !(group instanceof ContactGroupIcqImpl) ) throw new IllegalArgumentException( @@ -603,7 +598,7 @@ public void removeServerStoredContactGroup(ContactGroup group) public void renameServerStoredContactGroup( ContactGroup group, String newName) { - verifyConnected(); + assertConnected(); if( !(group instanceof ContactGroupIcqImpl) ) throw new IllegalArgumentException( @@ -622,7 +617,7 @@ public void renameServerStoredContactGroup( public void moveContactToGroup(Contact contactToMove, ContactGroup newParent) { - verifyConnected(); + assertConnected(); if( !(contactToMove instanceof ContactIcqImpl) ) throw new IllegalArgumentException( @@ -759,7 +754,7 @@ public void handleTimeout(SnacRequestTimeoutEvent event) { * @throws java.lang.IllegalStateException if the underlying ICQ stack is * not registered and initialized. */ - private void verifyConnected() throws IllegalStateException + private void assertConnected() throws IllegalStateException { if (icqProvider == null) throw new IllegalStateException( diff --git a/src/net/java/sip/communicator/impl/protocol/icq/RootContactGroupIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/RootContactGroupIcqImpl.java index 96896fde8..010582673 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/RootContactGroupIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/RootContactGroupIcqImpl.java @@ -141,7 +141,7 @@ public ContactGroup getGroup(int index) */ public ContactGroup getGroup(String groupName) { - Iterator subgroups = subGroups(); + Iterator subgroups = subgroups(); while (subgroups.hasNext()) { ContactGroupIcqImpl grp = (ContactGroupIcqImpl)subgroups.next(); @@ -173,7 +173,7 @@ public Contact getContact(String id) * @return a java.util.Iterator over the ContactGroup * children of this group (i.e. subgroups). */ - public Iterator subGroups() + public Iterator subgroups() { return subGroups.iterator(); } @@ -223,7 +223,7 @@ public String toString() StringBuffer buff = new StringBuffer(getGroupName()); buff.append(".subGroups="+countSubgroups()+":\n"); - Iterator subGroups = subGroups(); + Iterator subGroups = subgroups(); while (subGroups.hasNext()) { ContactGroup group = (ContactGroup) subGroups.next(); diff --git a/src/net/java/sip/communicator/service/protocol/ContactGroup.java b/src/net/java/sip/communicator/service/protocol/ContactGroup.java index 4332b8dbe..4f4170f71 100644 --- a/src/net/java/sip/communicator/service/protocol/ContactGroup.java +++ b/src/net/java/sip/communicator/service/protocol/ContactGroup.java @@ -28,7 +28,7 @@ public interface ContactGroup * @return a java.util.Iterator over the ContactGroup children * of this group (i.e. subgroups). */ - public Iterator subGroups(); + public Iterator subgroups(); /** * Returns the number of subgroups contained by this ContactGroup. diff --git a/src/net/java/sip/communicator/service/protocol/event/MessageListener.java b/src/net/java/sip/communicator/service/protocol/event/MessageListener.java index c128c67f0..09eb7f215 100644 --- a/src/net/java/sip/communicator/service/protocol/event/MessageListener.java +++ b/src/net/java/sip/communicator/service/protocol/event/MessageListener.java @@ -1,3 +1,9 @@ +/* + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ package net.java.sip.communicator.service.protocol.event; import java.util.*; @@ -11,9 +17,27 @@ public interface MessageListener extends EventListener { - public void messageReceived(MessageEvent evt); + /** + * Called when a new incoming Message has been received. + * @param evt the MessageReceivedEvent containing the newly + * received message, its sender and other details. + */ + public void messageReceived(MessageReceivedEvent evt); - public void messageDelivered(MessageEvent evt); + /** + * Called when the underlying implementation has received an indication + * that a message, sent earlier has been successfully received by the + * destination. + * @param evt the MessageDeliveredEvent containing the id of the message + * that has caused the event. + */ + public void messageDelivered(MessageDeliveredEvent evt); - public void messageDeliveryFailed(MessageEvent evt); + /** + * Called to indicated that delivery of a message sent earlier has failed. + * Reason code and phrase are contained by the MessageFailedEvent + * @param evt the MessageFailedEvent containing the ID of the + * message whose delivery has failed. + */ + public void messageDeliveryFailed(MessageDeliveryFailedEvent evt); } diff --git a/src/net/java/sip/communicator/service/protocol/event/ServerStoredGroupEvent.java b/src/net/java/sip/communicator/service/protocol/event/ServerStoredGroupEvent.java index e317a3472..c25d27854 100644 --- a/src/net/java/sip/communicator/service/protocol/event/ServerStoredGroupEvent.java +++ b/src/net/java/sip/communicator/service/protocol/event/ServerStoredGroupEvent.java @@ -25,18 +25,21 @@ public class ServerStoredGroupEvent private int eventID = -1; private ProtocolProviderService sourceProvider = null; private OperationSetPersistentPresence parentOperationSet = null; + private ContactGroup parentGroup = null; /** * Creates a ServerStoredGroupChangeEvent instance. * @param sourceGroup the group that this event is pertaining to. * @param eventID an int describing the cause of the event + * @param parentGroup the group that the source group is a child of. * @param sourceProvider a reference to the protocol provider where this is * happening * @param opSet a reference to the operation set responsible for the event */ public ServerStoredGroupEvent(ContactGroup sourceGroup, int eventID, + ContactGroup parentGroup, ProtocolProviderService sourceProvider, OperationSetPersistentPresence opSet) { @@ -45,6 +48,7 @@ public ServerStoredGroupEvent(ContactGroup sourceGroup, this.eventID = eventID; this.sourceProvider = sourceProvider; this.parentOperationSet = opSet; + this.parentGroup = parentGroup; } /** @@ -87,6 +91,16 @@ public OperationSetPersistentPresence getSourceOperationSet() return this.parentOperationSet; } + /** + * Returns the group containing the event source group + * @return a reference to the ContactGroup instance that is parent + * of the ContactGroup which is the source of this event. + */ + public ContactGroup getParentGroup() + { + return parentGroup; + } + /** * Returns a String representation of this event. * @return a String containing details describin this event. diff --git a/test/net/java/sip/communicator/slick/protocol/icq/TestOperationSetPersistentPresence.java b/test/net/java/sip/communicator/slick/protocol/icq/TestOperationSetPersistentPresence.java index a9917ac51..2dd1cc032 100644 --- a/test/net/java/sip/communicator/slick/protocol/icq/TestOperationSetPersistentPresence.java +++ b/test/net/java/sip/communicator/slick/protocol/icq/TestOperationSetPersistentPresence.java @@ -128,7 +128,7 @@ public void testRetrievingServerStoredContactList() //Go through the contact list retrieved by the persistence presence set //and remove the name of every contact and group that we find there from //the expected contct list hashtable. - Iterator groups = rootGroup.subGroups(); + Iterator groups = rootGroup.subgroups(); while (groups.hasNext() ){ ContactGroup group = (ContactGroup)groups.next(); diff --git a/test/net/java/sip/communicator/slick/runner/XmlFormatter.java b/test/net/java/sip/communicator/slick/runner/XmlFormatter.java index 84775e5b6..164ca4495 100644 --- a/test/net/java/sip/communicator/slick/runner/XmlFormatter.java +++ b/test/net/java/sip/communicator/slick/runner/XmlFormatter.java @@ -206,6 +206,7 @@ public void endTest(Test test) { // even tests with the same name - disambiguate them. currentTest.setAttribute(ATTR_CLASSNAME, test.getClass().getName()); + rootElement.appendChild(currentTest); testElements.put(test, currentTest); } else {