diff --git a/resources/images/images.properties b/resources/images/images.properties index df885dab0..3fbb5ee4f 100644 --- a/resources/images/images.properties +++ b/resources/images/images.properties @@ -151,6 +151,12 @@ service.gui.buttons.CHAT_BUTTON_SMALL=resources/images/impl/gui/buttons/chatSmal service.gui.buttons.CHAT_BUTTON_SMALL_PRESSED=resources/images/impl/gui/buttons/chatSmallPressed.png service.gui.buttons.CHAT_BUTTON_SMALL_ROLLOVER=resources/images/impl/gui/buttons/chatSmallRollover.png service.gui.buttons.CHAT_BUTTON_SMALL_WHITE=resources/images/impl/gui/buttons/chatSmallWhite.png +service.gui.buttons.CHAT_BUTTON_ONLINE_ICON=resources/images/impl/gui/buttons/chatSmallOnline.png +service.gui.buttons.CHAT_BUTTON_OFFLINE_ICON=resources/images/impl/gui/buttons/chatSmallOffline.png +service.gui.buttons.CHAT_BUTTON_AWAY_ICON=resources/images/impl/gui/buttons/chatSmallAway.png +service.gui.buttons.CHAT_BUTTON_DND_ICON=resources/images/impl/gui/buttons/chatSmallDND.png +service.gui.buttons.CHAT_BUTTON_FFC_ICON=resources/images/impl/gui/buttons/chatSmallFree.png +service.gui.buttons.CHAT_BUTTON_ON_THE_PHONE_ICON=resources/images/impl/gui/buttons/chatSmallPhone.png service.gui.buttons.ADD_CONTACT_BUTTON_SMALL=resources/images/impl/gui/buttons/addContactSmall.png service.gui.buttons.ADD_CONTACT_BUTTON_SMALL_PRESSED=resources/images/impl/gui/buttons/addContactSmallPressed.png service.gui.buttons.ADD_CONTACT_BUTTON_SMALL_ROLLOVER=resources/images/impl/gui/buttons/addContactSmallRollover.png diff --git a/resources/images/impl/gui/buttons/chatSmallAway.png b/resources/images/impl/gui/buttons/chatSmallAway.png new file mode 100644 index 000000000..d8b035460 Binary files /dev/null and b/resources/images/impl/gui/buttons/chatSmallAway.png differ diff --git a/resources/images/impl/gui/buttons/chatSmallDND.png b/resources/images/impl/gui/buttons/chatSmallDND.png new file mode 100644 index 000000000..c78284cca Binary files /dev/null and b/resources/images/impl/gui/buttons/chatSmallDND.png differ diff --git a/resources/images/impl/gui/buttons/chatSmallFree.png b/resources/images/impl/gui/buttons/chatSmallFree.png new file mode 100644 index 000000000..213155fdc Binary files /dev/null and b/resources/images/impl/gui/buttons/chatSmallFree.png differ diff --git a/resources/images/impl/gui/buttons/chatSmallOffline.png b/resources/images/impl/gui/buttons/chatSmallOffline.png new file mode 100644 index 000000000..5b006e5e4 Binary files /dev/null and b/resources/images/impl/gui/buttons/chatSmallOffline.png differ diff --git a/resources/images/impl/gui/buttons/chatSmallOnline.png b/resources/images/impl/gui/buttons/chatSmallOnline.png new file mode 100644 index 000000000..fed816fd4 Binary files /dev/null and b/resources/images/impl/gui/buttons/chatSmallOnline.png differ diff --git a/resources/images/impl/gui/buttons/chatSmallPhone.png b/resources/images/impl/gui/buttons/chatSmallPhone.png new file mode 100644 index 000000000..ff8c9407a Binary files /dev/null and b/resources/images/impl/gui/buttons/chatSmallPhone.png differ 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 16851ce49..d37d2d741 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 @@ -20,6 +20,7 @@ import net.java.sip.communicator.impl.gui.event.*; import net.java.sip.communicator.impl.gui.main.call.conference.*; import net.java.sip.communicator.impl.gui.utils.*; +import net.java.sip.communicator.impl.gui.utils.Constants; import net.java.sip.communicator.plugin.desktoputil.*; import net.java.sip.communicator.service.contactlist.*; import net.java.sip.communicator.service.gui.*; @@ -67,7 +68,8 @@ public class CallPanel implements ActionListener, PluginComponentListener, Skinnable, - ConferencePeerViewListener + ConferencePeerViewListener, + ContactPresenceStatusListener { /** * The chat button name. @@ -685,6 +687,17 @@ void dispose() ((CallRenderer) callPanel).dispose(); } + // clears the contact status listener + List imContacts = getIMCapableCallPeers(1); + if(imContacts.size() == 1) + { + Contact contact = imContacts.get(0); + OperationSetPresence operationSetPresence = + contact.getProtocolProvider() + .getOperationSet(OperationSetPresence.class); + if(operationSetPresence != null) + operationSetPresence.removeContactPresenceStatusListener(this); + } } /** @@ -746,8 +759,22 @@ private void doUpdateSettingsPanelInEventDispatchThread( * telephony conference at this time so we do not want the chatButton * visible in such a scenario. */ + List imContacts = getIMCapableCallPeers(1); chatButton.setVisible( - !isConference && (getIMCapableCallPeers(1).size() == 1)); + !isConference && (imContacts.size() == 1)); + if(chatButton.isVisible()) + { + Contact contact = imContacts.get(0); + OperationSetPresence operationSetPresence = + contact.getProtocolProvider() + .getOperationSet(OperationSetPresence.class); + if(operationSetPresence != null) + operationSetPresence.addContactPresenceStatusListener(this); + + chatButton.setIconImage( + Constants.getMessageStatusIcon(contact.getPresenceStatus())); + chatButton.repaint(); + } updateHoldButtonState(); updateMergeButtonState(); @@ -2173,6 +2200,24 @@ private void updateViewFromModelInEventDispatchThread() } } + /** + * Listens for contact status changes and updates the image of the + * chat message button. + * @param evt the ContactPresenceStatusChangeEvent describing the status + */ + @Override + public void contactPresenceStatusChanged(ContactPresenceStatusChangeEvent evt) + { + Contact contact = getIMCapableCallPeers(1).get(0); + + if(contact.equals(evt.getSourceContact())) + { + chatButton.setIconImage( + Constants.getMessageStatusIcon(contact.getPresenceStatus())); + chatButton.repaint(); + } + } + /** * Implements the listener which listens to events fired by the * CallConference depicted by this instance, the Calls diff --git a/src/net/java/sip/communicator/impl/gui/utils/Constants.java b/src/net/java/sip/communicator/impl/gui/utils/Constants.java index bc7e2dae5..f19514852 100755 --- a/src/net/java/sip/communicator/impl/gui/utils/Constants.java +++ b/src/net/java/sip/communicator/impl/gui/utils/Constants.java @@ -307,6 +307,63 @@ else if(connectivity < PresenceStatus.MAX_STATUS_VALUE) } } + /** + * Returns the image corresponding to the given presence status. + * @param status The presence status. + * @return the image corresponding to the given presence status. + */ + public static BufferedImage getMessageStatusIcon(PresenceStatus status) + { + if(status != null) + { + int connectivity = status.getStatus(); + + if(connectivity < PresenceStatus.ONLINE_THRESHOLD) + { + return ImageLoader + .getImage(ImageLoader.CHAT_BUTTON_OFFLINE_ICON); + } + else if(connectivity < PresenceStatus.AWAY_THRESHOLD) + { + return ImageLoader + .getImage(ImageLoader.CHAT_BUTTON_DND_ICON); + } + else if(connectivity == PresenceStatus.AWAY_THRESHOLD) + { + // the special status On The Phone is state + // between DND and AWAY states. + return ImageLoader + .getImage(ImageLoader.CHAT_BUTTON_ON_THE_PHONE_ICON); + } + else if(connectivity < PresenceStatus.AVAILABLE_THRESHOLD) + { + return ImageLoader + .getImage(ImageLoader.CHAT_BUTTON_AWAY_ICON); + } + else if(connectivity + < PresenceStatus.EAGER_TO_COMMUNICATE_THRESHOLD) + { + return ImageLoader + .getImage(ImageLoader.CHAT_BUTTON_ONLINE_ICON); + } + else if(connectivity < PresenceStatus.MAX_STATUS_VALUE) + { + return ImageLoader + .getImage(ImageLoader.CHAT_BUTTON_FFC_ICON); + } + else + { + return ImageLoader + .getImage(ImageLoader.CHAT_BUTTON_OFFLINE_ICON); + } + } + else + { + return ImageLoader + .getImage(ImageLoader.CHAT_BUTTON_SMALL_WHITE); + } + } + /** * Loads a chat window style. */ diff --git a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java index eb4e82485..7802329be 100644 --- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java +++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java @@ -1306,6 +1306,42 @@ public class ImageLoader public static final ImageID USER_USER_ON_THE_PHONE_ICON = new ImageID("service.gui.statusicons.USER_ON_THE_PHONE_ICON"); + /** + * Chat button "online" icon. + */ + public static final ImageID CHAT_BUTTON_ONLINE_ICON + = new ImageID("service.gui.buttons.CHAT_BUTTON_ONLINE_ICON"); + + /** + * Chat button "offline" icon. + */ + public static final ImageID CHAT_BUTTON_OFFLINE_ICON + = new ImageID("service.gui.buttons.CHAT_BUTTON_OFFLINE_ICON"); + + /** + * Chat button "away" icon. + */ + public static final ImageID CHAT_BUTTON_AWAY_ICON + = new ImageID("service.gui.buttons.CHAT_BUTTON_AWAY_ICON"); + + /** + * Chat button "free for chat" icon. + */ + public static final ImageID CHAT_BUTTON_FFC_ICON + = new ImageID("service.gui.buttons.CHAT_BUTTON_FFC_ICON"); + + /** + * Chat button "do not disturb" icon. + */ + public static final ImageID CHAT_BUTTON_DND_ICON + = new ImageID("service.gui.buttons.CHAT_BUTTON_DND_ICON"); + + /** + * Chat button "on the phone" icon. + */ + public static final ImageID CHAT_BUTTON_ON_THE_PHONE_ICON + = new ImageID("service.gui.buttons.CHAT_BUTTON_ON_THE_PHONE_ICON"); + /** * Owner chatroom member. */