diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index 2e8735f54..838e86e6d 100644 --- a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java +++ b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java @@ -74,7 +74,8 @@ public class UIServiceImpl implements UIService, ShutdownService, ServiceListener, - PropertyChangeListener + PropertyChangeListener, + UINotificationListener { /** * The Logger used by the UIServiceImpl class and its @@ -140,6 +141,7 @@ public class UIServiceImpl */ public UIServiceImpl() { + UINotificationManager.addNotificationListener(this); } /** @@ -1642,4 +1644,41 @@ public void showChatRoomAutoOpenConfigDialog( ChatRoomAutoOpenConfigDialog.showChatRoomAutoOpenConfigDialog( pps, chatRoomId); } + + /** + * Counts the number of unread notifications and forwards the sum to the + * systray service. + */ + @Override + public void notificationReceived(UINotification notification) + { + forwardNotificationCount(); + } + + /** + * Counts the number of unread notifications and forwards the sum to the + * systray service. + */ + @Override + public void notificationCleared(UINotification notification) + { + forwardNotificationCount(); + } + + private void forwardNotificationCount() + { + int count = 0; + for (UINotificationGroup g : UINotificationManager + .getNotificationGroups()) + { + Iterator it = + UINotificationManager.getUnreadNotifications(g); + while (it.hasNext()) + { + count += it.next().getUnreadObjects(); + } + } + + GuiActivator.getSystrayService().setNotificationCount(count); + } } diff --git a/src/net/java/sip/communicator/service/systray/AbstractSystrayService.java b/src/net/java/sip/communicator/service/systray/AbstractSystrayService.java index 6b4c430c7..60114f955 100644 --- a/src/net/java/sip/communicator/service/systray/AbstractSystrayService.java +++ b/src/net/java/sip/communicator/service/systray/AbstractSystrayService.java @@ -127,6 +127,15 @@ public void showPopupMessage(PopupMessage popupMessage) activePopupHandler.showPopupMessage(popupMessage); } + /** + * Stub method that does nothing. + * @param count ignored + */ + @Override + public void setNotificationCount(int count) + { + } + /** * Implements the SystrayService.addPopupMessageListener method. * If activePopupHandler is still not available record the listener diff --git a/src/net/java/sip/communicator/service/systray/SystrayService.java b/src/net/java/sip/communicator/service/systray/SystrayService.java index 4cabe2dc4..bcde84159 100644 --- a/src/net/java/sip/communicator/service/systray/SystrayService.java +++ b/src/net/java/sip/communicator/service/systray/SystrayService.java @@ -130,4 +130,10 @@ public PopupMessageHandler setActivePopupMessageHandler( * @return True if the systray is initialized, false otherwise. */ public boolean checkInitialized(); + + /** + * Set the number that should be shown as an overlay on the try icon. + * @param count The number of pending notifications. + */ + public void setNotificationCount(int count); }