diff --git a/lib/installer-exclude/libjitsi.jar b/lib/installer-exclude/libjitsi.jar index 33b30be69..e2c5cfba1 100644 Binary files a/lib/installer-exclude/libjitsi.jar and b/lib/installer-exclude/libjitsi.jar differ diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java index d3b3c116c..8cd4b405c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallDialog.java @@ -169,9 +169,7 @@ public void dispose() * @throws RuntimeException if the method is not called on the AWT event * dispatching thread */ - public void ensureSize( - final Component component, - final int width, final int height) + public void ensureSize(Component component, int width, int height) { CallManager.assertIsEventDispatchingThread(); @@ -205,10 +203,92 @@ else if (!frame.equals(this)) } else { - Dimension frameSize = frame.getSize(); + /* + * If there is no callPanel, it is unlikely that this CallDialog + * will be asked to ensureSize. Anyway, support the scenario just in + * case. In light of the absence of a callPanel to guide this + * CallDialog about the preferred size, we do not have much of a + * choice but to trust the method arguments. + */ + if (callPanel != null) + { + /* + * If there is a callPanel, we are likely to get a much better + * estimation about the preferred size by asking the callPanel + * rather than by trusting the method arguments. For example, + * the visual Component displaying the video streaming from the + * local user/peer to the remote peer(s) will think that its + * preferred size is the one to base this Frame's size on but + * that may be misleading because the local video may not be + * displayed with its preferred size even if this Frame's size + * will accommodate it. + */ + /* + * Just asking the callPanel about its preferredSize would've + * been terrificly great. Unfortunately, that is presently + * futile because the callPanel may have a preferredSize while + * we are still required to display visual Components displaying + * video in their non-scaled size. The same goes for any + * Container which is an ancestor of the specified component. + */ + Container ancestor + = findClosestAncestorWithSetPreferredSize(component); + + if (ancestor == null) + ancestor = callPanel; + /* + * If the ancestor has a forced preferredSize, its LayoutManager + * may be able to give a good enough estimation. + */ + if (ancestor.isPreferredSizeSet()) + { + LayoutManager ancestorLayout = ancestor.getLayout(); + + if (ancestorLayout != null) + { + Dimension preferredLayoutSize + = ancestorLayout.preferredLayoutSize(ancestor); + + if (preferredLayoutSize != null) + { + component = ancestor; + width = preferredLayoutSize.width; + height = preferredLayoutSize.height; + } + } + } + else + { + /* + * If the ancestor doesn't have a preferredSize forced, then + * we may think that it will calculate an appropriate + * preferredSize itself. + */ + Dimension preferredSize = ancestor.getPreferredSize(); + + if (preferredSize != null) + { + component = ancestor; + width = preferredSize.width; + height = preferredSize.height; + } + } + } + + /* + * If the component (which may be an ancestor of the Component + * specified as an argument to the ensureSize method at this point) + * has not been given a size, we will make a mistake if we try to + * use it for the purposes of determining how much this Frame is to + * be enlarged. + */ Dimension componentSize = component.getSize(); - int newFrameWidth - = frameSize.width + width - componentSize.width; + + if ((componentSize.width < 1) || (componentSize.height < 1)) + return; + + Dimension frameSize = frame.getSize(); + int newFrameWidth = frameSize.width + width - componentSize.width; int newFrameHeight = frameSize.height + height - componentSize.height; @@ -268,6 +348,37 @@ else if (!changeHeight) } } + /** + * Finds a Container which is an ancestor of a specific + * Component, has a set preferredSize and is closest to + * the specified Component up the ancestor hierarchy. + * + * @param component the Component whose ancestor hierarchy is to be + * searched upwards + * @return a Container, if any, which is an ancestor of the + * specified component, has a set preferredSize and is + * closest to the specified component up the ancestor hierarchy + */ + private static Container findClosestAncestorWithSetPreferredSize( + Component component) + { + if ((component instanceof Container) && component.isPreferredSizeSet()) + return (Container) component; + else + { + Container parent; + + while ((parent = component.getParent()) != null) + { + if (parent.isPreferredSizeSet()) + return parent; + else + component = parent; + } + return null; + } + } + /** * Returns the frame of the call window. * diff --git a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java index f53f92a71..fd167c723 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/CallPanel.java @@ -1948,16 +1948,28 @@ private void updateViewFromModelInEventDispatchThread() Dimension newPreferredSize = getPreferredSize(); if ((newPreferredSize != null) - && (newPreferredSize.width - > ((oldPreferredSize == null) - ? 0 - : oldPreferredSize.width)) && ((newPreferredSize.height > getHeight()) || (newPreferredSize.width > getWidth()))) { - ensureSize( - this, - newPreferredSize.width, newPreferredSize.height); + int oldPreferredHeight, oldPreferredWidth; + + if (oldPreferredSize == null) + { + oldPreferredHeight = 0; + oldPreferredWidth = 0; + } + else + { + oldPreferredHeight = oldPreferredSize.height; + oldPreferredWidth = oldPreferredSize.width; + } + if ((newPreferredSize.height != oldPreferredHeight) + || (newPreferredSize.width != oldPreferredWidth)) + { + ensureSize( + this, + newPreferredSize.width, newPreferredSize.height); + } } } diff --git a/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java index 97405d9b1..c31f86e89 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/OneToOneCallPeerPanel.java @@ -240,14 +240,6 @@ public OneToOneCallPeerPanel( if (center != null) { - /* - * Don't let the center dictate the preferred size because it may - * display large videos. Otherwise, the large video will make this - * panel expand and then the panel's container will show scroll - * bars. - */ - center.setPreferredSize(new Dimension(1, 1)); - cnstrnts.fill = GridBagConstraints.BOTH; cnstrnts.gridx = 0; cnstrnts.gridy = 1; diff --git a/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java index ea2ca0713..eeb374427 100644 --- a/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/call/conference/VideoConferenceCallPanel.java @@ -7,7 +7,6 @@ package net.java.sip.communicator.impl.gui.main.call.conference; import java.awt.*; -import java.awt.event.*; import java.util.*; import java.util.List; @@ -240,82 +239,16 @@ public void paintComponent(Graphics g) */ private VideoContainer createVideoContainer() { - final VideoContainer videoContainer = new VideoContainer(null, true); - - videoContainer.setPreferredSize(new Dimension(0, 0)); - + VideoContainer videoContainer = new VideoContainer(null, true); GridBagConstraints videoContainerGridBagConstraints = new GridBagConstraints(); videoContainerGridBagConstraints.fill = GridBagConstraints.BOTH; videoContainerGridBagConstraints.gridx = 0; videoContainerGridBagConstraints.gridy = 0; - videoContainerGridBagConstraints.weightx = 0; + videoContainerGridBagConstraints.weightx = 1; videoContainerGridBagConstraints.weighty = 1; add(videoContainer, videoContainerGridBagConstraints); - /* - * When the videoContainer is empty i.e. it has nothing to show, don't - * show it. - */ - videoContainer.addContainerListener( - new ContainerListener() - { - public void componentAdded(ContainerEvent e) - { - GridBagLayout layout = (GridBagLayout) getLayout(); - boolean videoContainerIsVisible - = (videoContainer.getComponentCount() > 0); - - for (Component component : getComponents()) - { - GridBagConstraints constraints - = layout.getConstraints(component); - - if (videoContainerIsVisible) - { - constraints.weightx - = (component == videoContainer) ? 1 : 0; - } - else - { - constraints.weightx - = (component == videoContainer) ? 0 : 1; - } - layout.setConstraints(component, constraints); - } - - /* - * When the first visual/video Component gets added, this - * videoContainer is still not accommodated by the frame - * size because it has just become visible. So try to resize - * the frame to accommodate this videoContainer. - */ - if (e.getID() == ContainerEvent.COMPONENT_ADDED) - { - Dimension preferredSize - = videoContainer.getLayout().preferredLayoutSize( - videoContainer); - - if ((preferredSize != null) - && (preferredSize.width > 0) - && (preferredSize.height > 0)) - { -// ensureSize( -// videoContainer, -// preferredSize.width, preferredSize.height); - } - } - } - - public void componentRemoved(ContainerEvent e) - { - /* - * It's all the same with respect to the purpose of this - * ContainerListener. - */ - componentAdded(e); - } - }); return videoContainer; } @@ -775,6 +708,17 @@ protected ConferenceCallPeerRenderer updateViewFromModel( return callPeerPanel; } + /** + * {@inheritDoc} + * + * Temporarily disables the use of ConferenceParticipantContainer + * because the functionality implemented in the model at the time of this + * writing does not fully support mapping of visual Components + * displaying video to telephony conference participants (e.g. in telephony + * conferences utilizing the Jitsi VideoBridge server-side technology). + * Instead displays the videos only, does not map videos to participants and + * does not display participants who do not have videos. + */ @Override protected void updateViewFromModelInEventDispatchThread() { @@ -868,7 +812,11 @@ protected void updateViewFromModelInEventDispatchThread() if (!UIVideoHandler2.isAncestor(videoContainer, video)) { this.videos.add(video); - videoContainer.add(video, VideoLayout.CENTER_REMOTE); + videoContainer.add( + video, + (video == localVideo) + ? VideoLayout.LOCAL + : VideoLayout.CENTER_REMOTE); } } } diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java index 35dd371aa..d6bd1284f 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/AddContactDialog.java @@ -40,9 +40,6 @@ public class AddContactDialog WindowFocusListener, Skinnable { - private final Logger logger - = Logger.getLogger(AddContactDialog.class.getName()); - private final JLabel accountLabel = new JLabel( GuiActivator.getResources().getI18NString( "service.gui.SELECT_ACCOUNT") + ": "); @@ -503,7 +500,8 @@ else if (value instanceof ProtocolProviderService) /** * A custom renderer displaying groups in a combo box. */ - private static class GroupComboRenderer extends DefaultListCellRenderer + private static class GroupComboRenderer + extends DefaultListCellRenderer { @Override public Component getListCellRendererComponent( JList list, @@ -547,11 +545,11 @@ public Component getListCellRendererComponent( JList list, } /** - * Brings this window to front. + * Brings this window to the front. */ public void bringToFront() { - super.toFront(); + toFront(); } /** diff --git a/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java b/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java index 4490ef3da..6e48b14d3 100644 --- a/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/dict/ContactDictImpl.java @@ -17,7 +17,7 @@ * @author LITZELMANN Cedric */ public class ContactDictImpl - implements Contact + extends AbstractContact { private Logger logger = Logger.getLogger(ContactDictImpl.class); @@ -315,28 +315,6 @@ public void setResolved(boolean resolved) this.isResolved = resolved; } - /** - * Indicates whether some other object is "equal to" this one which in terms - * of contacts translates to having equal ids. The resolved status of the - * contacts deliberately ignored so that contacts would be declared equal - * even if it differs. - *
- * @param obj the reference object with which to compare.
- * @return true if this contact has the same id as that of the
- * obj argument.
- */
- public boolean equals(Object obj)
- {
- if (obj == null || ! (obj instanceof ContactDictImpl)) {
- return false;
- }
-
- ContactDictImpl dictContact = (ContactDictImpl) obj;
-
- return this.getAddress().equals(dictContact.getAddress());
- }
-
-
/**
* Returns the persistent presence operation set that this contact belongs
* to.
diff --git a/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGibberishImpl.java b/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGibberishImpl.java
index b17b1e8e0..8bae28c03 100644
--- a/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGibberishImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/gibberish/ContactGibberishImpl.java
@@ -19,7 +19,7 @@
* @author Emil Ivov
*/
public class ContactGibberishImpl
- implements Contact
+ extends AbstractContact
{
/**
@@ -265,28 +265,6 @@ public void setResolved(boolean resolved)
this.isResolved = resolved;
}
- /**
- * Indicates whether some other object is "equal to" this one which in terms
- * of contacts translates to having equal ids. The resolved status of the
- * contacts deliberately ignored so that contacts would be declared equal
- * even if it differs.
- *
- * @param obj the reference object with which to compare.
- * @return true if this contact has the same id as that of the
- * obj argument.
- */
- public boolean equals(Object obj)
- {
- if (obj == null
- || ! (obj instanceof ContactGibberishImpl))
- return false;
-
- ContactGibberishImpl gibberishContact = (ContactGibberishImpl) obj;
-
- return this.getAddress().equals(gibberishContact.getAddress());
- }
-
-
/**
* Returns the persistent presence operation set that this contact belongs
* to.
diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ContactIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ContactIcqImpl.java
index 99b49f7ca..ed66105e0 100644
--- a/src/net/java/sip/communicator/impl/protocol/icq/ContactIcqImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/icq/ContactIcqImpl.java
@@ -8,10 +8,11 @@
/**
* The ICQ implementation of the service.protocol.Contact interface.
+ *
* @author Emil Ivov
*/
public class ContactIcqImpl
- implements Contact
+ extends AbstractContact
{
Buddy joustSimBuddy = null;
private boolean isLocal = false;
@@ -82,37 +83,6 @@ public byte[] getImage()
return image;
}
- /**
- * Returns a hashCode for this contact. The returned hashcode is actually
- * that of the Contact's UIN
- * @return the hashcode of this Contact
- */
- public int hashCode()
- {
- return getUIN().hashCode();
- }
-
- /**
- * Indicates whether some other object is "equal to" this one.
- *
- * - * @param obj the reference object with which to compare. - * @return true if this object is the same as the obj - * argument; false otherwise. - */ - public boolean equals(Object obj) - { - if (obj == null - || !(obj instanceof ContactIcqImpl) - || !(((ContactIcqImpl)obj).getAddress().equals(getAddress()) - && ((ContactIcqImpl)obj).getProtocolProvider() - == getProtocolProvider())) - - return false; - - return true; - } - /** * Returns the joust sim buddy that this Contact is encapsulating. * @return Buddy diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/AbstractCallPeerJabberGTalkImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/AbstractCallPeerJabberGTalkImpl.java index 0d5b63e31..2d6b9eed5 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/AbstractCallPeerJabberGTalkImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/AbstractCallPeerJabberGTalkImpl.java @@ -89,11 +89,11 @@ public String getAddress() */ public Contact getContact() { - ProtocolProviderService pps = getCall().getProtocolProvider(); - OperationSetPresence opSetPresence - = pps.getOperationSet(OperationSetPresence.class); + OperationSetPresence presence + = getProtocolProvider().getOperationSet(OperationSetPresence.class); - return opSetPresence.findContactByID(getAddress()); + return + (presence == null) ? null : presence.findContactByID(getAddress()); } /** @@ -155,19 +155,18 @@ public boolean isInitiator() */ protected void retrieveDiscoverInfo(String calleeURI) { - DiscoverInfo tmpDiscoverInfo = null; try { - tmpDiscoverInfo = this.getCall().getProtocolProvider() - .getDiscoveryManager().discoverInfo(calleeURI); - if(tmpDiscoverInfo != null) - { - this.setDiscoverInfo(tmpDiscoverInfo); - } + DiscoverInfo discoverInfo + = getProtocolProvider().getDiscoveryManager().discoverInfo( + calleeURI); + + if(discoverInfo != null) + setDiscoverInfo(discoverInfo); } - catch (XMPPException ex) + catch (XMPPException xmppex) { - logger.warn("could not retrieve info for " + calleeURI, ex); + logger.warn("Could not retrieve info for " + calleeURI, xmppex); } } 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 3041e4f5c..6fc1a0060 100644 --- a/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java +++ b/src/net/java/sip/communicator/impl/protocol/mock/MockContact.java @@ -16,7 +16,7 @@ * @author Emil Ivov */ public class MockContact - implements Contact + extends AbstractContact { private String contactID = null; private MockProvider parentProvider = null; @@ -215,27 +215,6 @@ public void setResolved(boolean resolved) this.isResolved = resolved; } - /** - * Indicates whether some other object is "equal to" this one which in terms - * of contacts translates to having equal ids. The resolved status of the - * contacts deliberately ignored so that contacts would be declared equal - * even if it differs. - *
- * @param obj the reference object with which to compare.
- * @return true if this contact has the same id as that of the
- * obj argument.
- */
- public boolean equals(Object obj)
- {
- if (obj == null
- || ! (obj instanceof MockContact))
- return false;
-
- MockContact mockContact = (MockContact) obj;
-
- return this.getAddress().equals(mockContact.getAddress());
- }
-
/**
* Return the current status message of this contact.
*
diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ContactMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ContactMsnImpl.java
index d947a5f5d..5511448b2 100644
--- a/src/net/java/sip/communicator/impl/protocol/msn/ContactMsnImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/msn/ContactMsnImpl.java
@@ -15,7 +15,7 @@
* @author Damian Minkov
*/
public class ContactMsnImpl
- implements Contact
+ extends AbstractContact
{
private MsnContact contact = null;
private byte[] image = null;
@@ -101,36 +101,6 @@ void setImage(byte[] imgBytes)
this.image = imgBytes;
}
- /**
- * Returns a hashCode for this contact. The returned hashcode is actually
- * that of the Contact's Address
- * @return the hashcode of this Contact
- */
- public int hashCode()
- {
- return getAddress().hashCode();
- }
-
- /**
- * Indicates whether some other object is "equal to" this one.
- *
- * - * @param obj the reference object with which to compare. - * @return true if this object is the same as the obj - * argument; false otherwise. - */ - public boolean equals(Object obj) - { - if (obj == null - || !(obj instanceof ContactMsnImpl) - || !(((ContactMsnImpl)obj).getAddress().equals(getAddress()) - && ((ContactMsnImpl)obj).getProtocolProvider() - == getProtocolProvider())) - return false; - else - return true; - } - /** * Returns a string representation of this contact, containing most of its * representative details. diff --git a/src/net/java/sip/communicator/impl/protocol/rss/ContactRssImpl.java b/src/net/java/sip/communicator/impl/protocol/rss/ContactRssImpl.java index 6470e4aa9..8ff4f4eac 100644 --- a/src/net/java/sip/communicator/impl/protocol/rss/ContactRssImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/rss/ContactRssImpl.java @@ -18,7 +18,7 @@ * @author Mihai Balan */ public class ContactRssImpl - implements Contact + extends AbstractContact { /** @@ -397,37 +397,6 @@ public void setResolved(boolean resolved) this.isResolved = resolved; } - /** - * Indicates whether some other object is "equal to" this one which in terms - * of contacts translates to having equal IDs. The resolved status of the - * contacts is deliberately ignored so that contacts would be declared equal - * even if one contact is resolved and the other is not. - *
- * @param obj the reference object with which to compare.
- * @return true if this contact has the same ID as that of the
- * obj argument.
- */
- public boolean equals(Object obj)
- {
- if (obj == null
- || ! (obj instanceof ContactRssImpl))
- return false;
-
- ContactRssImpl rssContact = (ContactRssImpl) obj;
-
- return this.getAddress().equals(rssContact.getAddress());
- }
-
- /**
- * Overrides hashCode from Object to ensure that
- * equal objects have same hashcode
- *
- * http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#equals(java.lang.Object)
- */
- public int hashCode() {
- return getAddress().hashCode();
- }
-
/**
* Returns the persistent presence operation set that this contact belongs
* to.
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetIncomingDTMFSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetIncomingDTMFSipImpl.java
index 506ecbb78..4cb651b1b 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetIncomingDTMFSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetIncomingDTMFSipImpl.java
@@ -18,11 +18,6 @@
public class OperationSetIncomingDTMFSipImpl
implements OperationSetIncomingDTMF
{
- /**
- * The parent provider.
- */
- private ProtocolProviderServiceSipImpl provider;
-
/**
* The send DTMF operation set holding dtmf implementations.
*/
@@ -36,8 +31,6 @@ public class OperationSetIncomingDTMFSipImpl
OperationSetIncomingDTMFSipImpl(ProtocolProviderServiceSipImpl provider,
OperationSetDTMFSipImpl opsetDTMFSip)
{
- this.provider = provider;
-
this.opsetDTMFSip = opsetDTMFSip;
}
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 d355e8d9f..0560067a2 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java
@@ -215,7 +215,7 @@ public class OperationSetPresenceSipImpl
/**
* Watcher status from the watchers info list.
*/
- private enum WatcherStatus
+ private static enum WatcherStatus
{
PENDING("pending"),
ACTIVE("active"),
@@ -225,7 +225,7 @@ private enum WatcherStatus
/**
* The value.
*/
- private String value;
+ private final String value;
/**
* Creates <>tt WatcherStatus
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactList.java b/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactList.java
index 6299934f7..4629fa1d8 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactList.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/ServerStoredContactList.java
@@ -402,9 +402,7 @@ private boolean isContactExists(String contactUri)
for (ContactSipImpl uniqueContact : getUniqueContacts(rootGroup))
{
if (uniqueContact.getUri().equals(contactUri))
- {
return true;
- }
}
return false;
}
@@ -439,9 +437,7 @@ private boolean isContactPersistent(String contactUri)
for (ContactSipImpl contact : getContacts(contactUri))
{
if (contact.isPersistent())
- {
return true;
- }
}
return false;
}
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipStackProperties.java b/src/net/java/sip/communicator/impl/protocol/sip/SipStackProperties.java
index ec87c51a5..bca91a530 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/SipStackProperties.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/SipStackProperties.java
@@ -13,7 +13,6 @@
import javax.net.ssl.*;
import net.java.sip.communicator.impl.protocol.sip.net.*;
-import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.Logger;
import org.jitsi.util.*;
diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java
index f4e3a110d..3df752240 100644
--- a/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/ssh/ContactSSHImpl.java
@@ -25,7 +25,8 @@
* @author Shobhit Jindal
*/
public class ContactSSHImpl
- implements ContactSSH
+ extends AbstractContact
+ implements ContactSSH
{
private static final Logger logger
= Logger.getLogger(ContactSSHImpl.class);
@@ -679,28 +680,7 @@ public void setResolved(boolean resolved)
{
this.isResolved = resolved;
}
-
- /**
- * Indicates whether some other object is "equal to" this one which in terms
- * of contacts translates to having equal ids. The resolved status of the
- * contacts deliberately ignored so that contacts would be declared equal
- * even if it differs.
- *
- * @param obj the reference object with which to compare.
- * @return true if this contact has the same id as that of the
- * obj argument.
- */
- public boolean equals(Object obj)
- {
- if (obj == null
- || ! (obj instanceof ContactSSHImpl))
- return false;
-
- ContactSSHImpl sshContact = (ContactSSHImpl) obj;
-
- return this.getAddress().equals(sshContact.getAddress());
- }
-
+
/**
* Returns the persistent presence operation set that this contact belongs
* to.
diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ContactYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ContactYahooImpl.java
index 799c1ad78..2c430391a 100644
--- a/src/net/java/sip/communicator/impl/protocol/yahoo/ContactYahooImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/yahoo/ContactYahooImpl.java
@@ -17,7 +17,7 @@
* @author Emil Ivov
*/
public class ContactYahooImpl
- implements Contact
+ extends AbstractContact
{
private static final Logger logger =
Logger.getLogger(ContactYahooImpl.class);
@@ -211,36 +211,6 @@ protected void setImage(byte[] image)
this.image = image;
}
- /**
- * Returns a hashCode for this contact. The returned hashcode is actually
- * that of the Contact's Address
- * @return the hashcode of this Contact
- */
- public int hashCode()
- {
- return getAddress().hashCode();
- }
-
- /**
- * Indicates whether some other object is "equal to" this one.
- *
- * - * @param obj the reference object with which to compare. - * @return true if this object is the same as the obj - * argument; false otherwise. - */ - public boolean equals(Object obj) - { - if (obj == null - || !(obj instanceof ContactYahooImpl) - || !( ((ContactYahooImpl)obj).getID().equals(getID()) ) - && ((ContactYahooImpl)obj).getProtocolProvider() - == getProtocolProvider()) - return false; - else - return true; - } - /** * Returns a string representation of this contact, containing most of its * representative details. diff --git a/src/net/java/sip/communicator/impl/protocol/zeroconf/ContactZeroconfImpl.java b/src/net/java/sip/communicator/impl/protocol/zeroconf/ContactZeroconfImpl.java index 423e60161..2390f463f 100644 --- a/src/net/java/sip/communicator/impl/protocol/zeroconf/ContactZeroconfImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/zeroconf/ContactZeroconfImpl.java @@ -24,7 +24,7 @@ * @author Jonathan Martin */ public class ContactZeroconfImpl - implements Contact + extends AbstractContact { private static final Logger logger = Logger.getLogger(ContactZeroconfImpl.class); @@ -430,28 +430,6 @@ public void setResolved(boolean resolved) this.isResolved = resolved; } - /** - * Indicates whether some other object is "equal to" this one which in terms - * of contacts translates to having equal ids. The resolved status of the - * contacts deliberately ignored so that contacts would be declared equal - * even if it differs. - *
- * @param obj the reference object with which to compare.
- * @return true if this contact has the same id as that of the
- * obj argument.
- */
- public boolean equals(Object obj)
- {
- if (obj == null
- || ! (obj instanceof ContactZeroconfImpl))
- return false;
-
- ContactZeroconfImpl zeroconfContact = (ContactZeroconfImpl) obj;
-
- return this.getAddress().equals(zeroconfContact.getAddress());
- }
-
-
/**
* Returns the persistent presence operation set that this contact belongs
* to.
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractContact.java b/src/net/java/sip/communicator/service/protocol/AbstractContact.java
new file mode 100644
index 000000000..b9164e6d2
--- /dev/null
+++ b/src/net/java/sip/communicator/service/protocol/AbstractContact.java
@@ -0,0 +1,69 @@
+/*
+ * Jitsi, 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;
+
+/**
+ * An abstract base implementation of the {@link Contact} interface which is to
+ * aid implementers.
+ *
+ * @author Lyubomir Marinov
+ */
+public abstract class AbstractContact
+ implements Contact
+{
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ return false;
+ else if (obj == this)
+ return true;
+ else if (!obj.getClass().equals(getClass()))
+ return false;
+ else
+ {
+ Contact contact = (Contact) obj;
+ ProtocolProviderService protocolProvider
+ = contact.getProtocolProvider();
+ ProtocolProviderService thisProtocolProvider
+ = getProtocolProvider();
+
+ if ((protocolProvider == null)
+ ? (thisProtocolProvider == null)
+ : protocolProvider.equals(thisProtocolProvider))
+ {
+ String address = contact.getAddress();
+ String thisAddress = getAddress();
+
+ return
+ (address == null)
+ ? (thisAddress == null)
+ : address.equals(thisAddress);
+ }
+ else
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hashCode = 0;
+
+ ProtocolProviderService protocolProvider = getProtocolProvider();
+
+ if (protocolProvider != null)
+ hashCode += protocolProvider.hashCode();
+
+ String address = getAddress();
+
+ if (address != null)
+ hashCode += address.hashCode();
+
+ return hashCode;
+ }
+}
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetBasicAutoAnswer.java b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetBasicAutoAnswer.java
index 5e5ef125d..bd943b21d 100644
--- a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetBasicAutoAnswer.java
+++ b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetBasicAutoAnswer.java
@@ -239,10 +239,7 @@ public AutoAnswerThread(CallPeer peer, boolean isVideoCall)
*/
public void run()
{
- OperationSetBasicAutoAnswer opSetBasicAutoAnswer
- = protocolProvider.getOperationSet(
- OperationSetBasicAutoAnswer.class);
- OperationSetBasicTelephony opSetBasicTelephony
+ OperationSetBasicTelephony> opSetBasicTelephony
= protocolProvider.getOperationSet(
OperationSetBasicTelephony.class);
OperationSetVideoTelephony opSetVideoTelephony
@@ -251,14 +248,14 @@ public void run()
try
{
// If this is a video call and that the user has configured to
- // answer it with wideo, then create a video call.
+ // answer it with video, then create a video call.
if(this.isVideoCall
&& answerWithVideo
&& opSetVideoTelephony != null)
{
opSetVideoTelephony.answerVideoCallPeer(peer);
}
- // Else sends only audio to the repote peer (the remote peer is
+ // Else sends only audio to the remote peer (the remote peer is
// still able to send us its video stream).
else if(opSetBasicTelephony != null)
{
@@ -277,6 +274,7 @@ else if(opSetBasicTelephony != null)
*
* @param evt the CallPeerChangeEvent instance containing the
*/
+ @Override
public void peerStateChanged(CallPeerChangeEvent evt)
{
CallPeerState newState = (CallPeerState) evt.getNewValue();
diff --git a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetBasicInstantMessaging.java b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetBasicInstantMessaging.java
index 2a32ab481..6e49f1581 100644
--- a/src/net/java/sip/communicator/service/protocol/AbstractOperationSetBasicInstantMessaging.java
+++ b/src/net/java/sip/communicator/service/protocol/AbstractOperationSetBasicInstantMessaging.java
@@ -18,7 +18,7 @@
* implementers to provide complete solutions while focusing on
* implementation-specific details.
*
- * @author Lubomir Marinov
+ * @author Lyubomir Marinov
*/
public abstract class AbstractOperationSetBasicInstantMessaging
implements OperationSetBasicInstantMessaging
@@ -189,16 +189,22 @@ else if (evt instanceof MessageDeliveryFailedEvent)
{
switch (eventType)
{
- case MessageDelivered:
- listener.messageDelivered((MessageDeliveredEvent) evt);
- break;
- case MessageDeliveryFailed:
- listener
- .messageDeliveryFailed((MessageDeliveryFailedEvent)evt);
- break;
- case MessageReceived:
- listener.messageReceived((MessageReceivedEvent) evt);
- break;
+ case MessageDelivered:
+ listener.messageDelivered((MessageDeliveredEvent) evt);
+ break;
+ case MessageDeliveryFailed:
+ listener.messageDeliveryFailed(
+ (MessageDeliveryFailedEvent)evt);
+ break;
+ case MessageReceived:
+ listener.messageReceived((MessageReceivedEvent) evt);
+ break;
+ default:
+ /*
+ * We either have nothing to do or we do not know what to
+ * do. Anyway, we'll silence the compiler.
+ */
+ break;
}
}
}
@@ -257,7 +263,7 @@ private EventObject messageTransform(EventObject evt, MessageEventType eventType
protocolProvider = ((MessageReceivedEvent)evt).getSourceContact().getProtocolProvider();
break;
default:
- return evt;
+ return evt;
}
OperationSetInstantMessageTransformImpl opSetMessageTransform =
@@ -295,6 +301,12 @@ private EventObject messageTransform(EventObject evt, MessageEventType eventType
= transformLayer
.messageReceived((MessageReceivedEvent)evt);
break;
+ default:
+ /*
+ * We either have nothing to do or we do not know what
+ * to do. Anyway, we'll silence the compiler.
+ */
+ break;
}
}
}