diff options
author | Ingo Bauersachs <ingo@jitsi.org> | 2016-05-29 23:12:37 +0200 |
---|---|---|
committer | Ingo Bauersachs <ingo@jitsi.org> | 2016-05-29 23:14:13 +0200 |
commit | 7f08c0d239e1c63ebb44dc025d7507017d5d1add (patch) | |
tree | fd37e361f7b1cc24c95c9e998eb6821b3a879d5d /src | |
parent | 8c1b1b17cde4acdf75220f18b559b4ca616601d4 (diff) | |
download | jitsi-7f08c0d239e1c63ebb44dc025d7507017d5d1add.zip jitsi-7f08c0d239e1c63ebb44dc025d7507017d5d1add.tar.gz jitsi-7f08c0d239e1c63ebb44dc025d7507017d5d1add.tar.bz2 |
Forward pending notification count to the systray service
Diffstat (limited to 'src')
3 files changed, 55 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); + } } diff --git a/src/net/java/sip/communicator/service/systray/AbstractSystrayService.java b/src/net/java/sip/communicator/service/systray/AbstractSystrayService.java index 6b4c430..60114f9 100644 --- a/src/net/java/sip/communicator/service/systray/AbstractSystrayService.java +++ b/src/net/java/sip/communicator/service/systray/AbstractSystrayService.java @@ -128,6 +128,15 @@ public abstract class AbstractSystrayService } /** + * Stub method that does nothing. + * @param count ignored + */ + @Override + public void setNotificationCount(int count) + { + } + + /** * Implements the <tt>SystrayService.addPopupMessageListener</tt> method. * If <tt>activePopupHandler</tt> is still not available record the listener * so we can add him later. diff --git a/src/net/java/sip/communicator/service/systray/SystrayService.java b/src/net/java/sip/communicator/service/systray/SystrayService.java index 4cabe2d..bcde841 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 interface SystrayService * @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); } |