diff options
Diffstat (limited to 'src/net/java/sip/communicator/impl/gui/UIServiceImpl.java')
-rw-r--r-- | src/net/java/sip/communicator/impl/gui/UIServiceImpl.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java b/src/net/java/sip/communicator/impl/gui/UIServiceImpl.java index 2e8735f..838e86e 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 <tt>Logger</tt> used by the <tt>UIServiceImpl</tt> class and its @@ -140,6 +141,7 @@ public class UIServiceImpl */ public UIServiceImpl() { + UINotificationManager.addNotificationListener(this); } /** @@ -1642,4 +1644,41 @@ public class UIServiceImpl 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<UINotification> it = + UINotificationManager.getUnreadNotifications(g); + while (it.hasNext()) + { + count += it.next().getUnreadObjects(); + } + } + + GuiActivator.getSystrayService().setNotificationCount(count); + } } |