fix systray envelope icon notifications

cusax-fix
Yana Stamcheva 19 years ago
parent e225b66b21
commit d86c11fc15

@ -18,6 +18,7 @@
import net.java.sip.communicator.service.msghistory.*;
import net.java.sip.communicator.service.notification.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.systray.*;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
@ -49,6 +50,8 @@ public class GuiActivator implements BundleActivator
private static BrowserLauncherService browserLauncherService;
private static NotificationService notificationService;
private static SystrayService systrayService;
private static Map providerFactoriesMap = new Hashtable();
@ -271,10 +274,30 @@ public static BrowserLauncherService getBrowserLauncher() {
* Returns the current implementation of the <tt>UIService</tt>.
* @return the current implementation of the <tt>UIService</tt>
*/
public static UIServiceImpl getUIService() {
public static UIServiceImpl getUIService()
{
return uiService;
}
/**
* Returns the <tt>SystrayService</tt> obtained from the bundle context.
*
* @return the <tt>SystrayService</tt> obtained from the bundle context
*/
public static SystrayService getSystrayService()
{
if (systrayService == null)
{
ServiceReference serviceReference = bundleContext
.getServiceReference(SystrayService.class.getName());
systrayService = (SystrayService) bundleContext
.getService(serviceReference);
}
return systrayService;
}
/**
* Returns the <tt>NotificationService</tt> obtained from the bundle context.
*

@ -551,7 +551,9 @@ public void propertyChange(PropertyChangeEvent evt)
.getContactListPanel().getContactList();
ContactListModel clistModel
= (ContactListModel) clist.getModel();
// Remove the envelope from the contact when the chat has
// gained the focus.
if(clistModel.isContactActive(selectedMetaContact))
{
clistModel.removeActiveContact(selectedMetaContact);

@ -569,39 +569,44 @@ protected void close(boolean isEscaped)
{
ChatPanel chatPanel = getCurrentChatPanel();
if(isEscaped) {
if(isEscaped)
{
ChatRightButtonMenu chatRightMenu = getCurrentChatPanel()
.getChatConversationPanel().getRightButtonMenu();
WritePanelRightButtonMenu writePanelRightMenu = getCurrentChatPanel()
.getChatWritePanel().getRightButtonMenu();
SIPCommMenu selectedMenu = menusPanel.getMainMenuBar().getSelectedMenu();
SIPCommMenu selectedMenu
= menusPanel.getMainMenuBar().getSelectedMenu();
//SIPCommMenu contactMenu = getCurrentChatPanel()
// .getProtoContactSelectorBox().getMenu();
MenuSelectionManager menuSelectionManager
= MenuSelectionManager.defaultManager();
if (chatRightMenu.isVisible()) {
if (chatRightMenu.isVisible())
{
chatRightMenu.setVisible(false);
}
else if (writePanelRightMenu.isVisible()) {
else if (writePanelRightMenu.isVisible())
{
writePanelRightMenu.setVisible(false);
}
else if (selectedMenu != null
//|| contactMenu.isPopupMenuVisible()
|| menusPanel.getMainToolBar().hasSelectedMenus()) {
|| menusPanel.getMainToolBar().hasSelectedMenus())
{
menuSelectionManager.clearSelectedPath();
}
else {
else
{
mainFrame.getChatWindowManager().closeChat(chatPanel);
}
}
else {
else
{
mainFrame.getChatWindowManager().closeWindow();
}
}

@ -15,6 +15,7 @@
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.chat.conference.*;
import net.java.sip.communicator.impl.gui.main.contactlist.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.protocol.*;
@ -248,13 +249,7 @@ public void closeWindow()
if (answer == JOptionPane.OK_OPTION)
{
chatWindow.removeAllChats();
chatWindow.dispose();
synchronized (chats)
{
chats.clear();
}
this.disposeChatWindow();
}
}
else if (System.currentTimeMillis() - chatWindow
@ -269,24 +264,12 @@ else if (System.currentTimeMillis() - chatWindow
if (answer == JOptionPane.OK_OPTION)
{
chatWindow.removeAllChats();
chatWindow.dispose();
synchronized (chats)
{
chats.clear();
}
this.disposeChatWindow();
}
}
else
{
chatWindow.removeAllChats();
chatWindow.dispose();
synchronized (chats)
{
chats.clear();
}
this.disposeChatWindow();
}
}
}
@ -647,4 +630,29 @@ private ChatPanel getChat(Object key)
return (ChatPanel) chats.get(key);
}
}
/**
* Disposes the chat window.
*/
private void disposeChatWindow()
{
chatWindow.removeAllChats();
chatWindow.dispose();
synchronized (chats)
{
chats.clear();
}
ContactList clist
= chatWindow.getMainFrame()
.getContactListPanel().getContactList();
ContactListModel clistModel
= (ContactListModel) clist.getModel();
// Remove the envelope from the all active contacts in the contact list.
clistModel.removeAllActiveContacts();
clist.refreshAll();
}
}

@ -1210,6 +1210,14 @@ public void refreshContact(MetaContact contact)
}
}
}
/**
* Refreshes the whole contact list.
*/
public void refreshAll()
{
this.modifyGroup(contactList.getRoot());
}
/**
* Adds the given contact to the contact list.

@ -15,6 +15,7 @@
import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.protocol.*;
@ -601,6 +602,13 @@ public void addActiveContact(MetaContact metaContact)
{
synchronized (activeContacts)
{
if(activeContacts.size() == 0)
{
GuiActivator.getSystrayService().setSystrayIcon(
ImageLoader.getImageInBytes(
ImageLoader.SYSTRAY_ENVELOPE_ICON));
}
this.activeContacts.add(metaContact);
}
}
@ -615,6 +623,27 @@ public void removeActiveContact(MetaContact metaContact)
synchronized (activeContacts)
{
this.activeContacts.remove(metaContact);
if(activeContacts.size() == 0)
GuiActivator.getSystrayService().setSystrayIcon(
ImageLoader.getImageInBytes(ImageLoader.SYSTRAY_ICON));
}
}
/**
* Removes all contacts from the list of active contacts.
*/
public void removeAllActiveContacts()
{
synchronized (activeContacts)
{
if(activeContacts.size() > 0)
{
this.activeContacts.removeAllElements();
GuiActivator.getSystrayService().setSystrayIcon(
ImageLoader.getImageInBytes(ImageLoader.SYSTRAY_ICON));
}
}
}

@ -14,6 +14,7 @@
import javax.swing.*;
import javax.swing.Timer;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.i18n.*;
import net.java.sip.communicator.impl.gui.main.*;
import net.java.sip.communicator.impl.gui.main.chat.*;
@ -214,12 +215,13 @@ public void messageReceived(MessageReceivedEvent evt)
if(metaContact != null)
{
// Show an envelope on the sender contact in the contact list.
// Show an envelope on the sender contact in the contact list and
// in the systray.
ContactListModel clistModel
= (ContactListModel) contactList.getModel();
clistModel.addActiveContact(metaContact);
contactList.refreshContact(metaContact);
contactList.refreshContact(metaContact);
// Obtain the corresponding chat panel.
ChatPanel chatPanel = chatWindowManager.getContactChat(

Binary file not shown.

After

Width:  |  Height:  |  Size: 822 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 792 B

@ -22,6 +22,7 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.callhistory.event,
net.java.sip.communicator.service.browserlauncher,
net.java.sip.communicator.service.notification,
net.java.sip.communicator.service.systray,
javax.swing,
javax.swing.event,
javax.swing.table,

@ -536,6 +536,17 @@ public class ImageLoader {
public static final ImageID MESSAGE_RECEIVED_ICON
= new ImageID("MESSAGE_RECEIVED_ICON");
/**
* The image used to set to the systray when a new message is received.
*/
public static final ImageID SYSTRAY_ICON
= new ImageID("SYSTRAY_ICON");
/**
* The image used to set to the systray when a new message is received.
*/
public static final ImageID SYSTRAY_ENVELOPE_ICON
= new ImageID("SYSTRAY_ENVELOPE_ICON");
// ///////////////////// Edit Text Toolbar icons //////////////////////////

@ -200,4 +200,7 @@ CHAT_SERVER_16x16_ICON=net/java/sip/communicator/impl/gui/resources/common/multi
MESSAGE_RECEIVED_ICON=net/java/sip/communicator/impl/gui/resources/common/envelope.png
REASON_DIALOG_ICON=net/java/sip/communicator/impl/gui/resources/common/reasonDialogIcon.png
REASON_DIALOG_ICON=net/java/sip/communicator/impl/gui/resources/common/reasonDialogIcon.png
SYSTRAY_ICON=net/java/sip/communicator/impl/gui/resources/common/systrayIcon.png
SYSTRAY_ENVELOPE_ICON=net/java/sip/communicator/impl/gui/resources/common/systrayEnvelopeIcon.png

@ -18,7 +18,6 @@
import net.java.sip.communicator.impl.systray.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.gui.event.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.systray.*;
@ -36,8 +35,7 @@
* @author Yana Stamcheva
*/
public class SystrayServiceJdicImpl
implements SystrayService,
ChatFocusListener
implements SystrayService
{
/**
* The systray.
@ -307,6 +305,12 @@ public void removePopupMessageListener(SystrayPopupMessageListener listener)
}
}
/**
* Notifies all interested listeners that a <tt>SystrayPopupMessageEvent</tt>
* has occured
*
* @param sourceObject the source of this event
*/
private void firePopupMessageEvent(Object sourceObject)
{
SystrayPopupMessageEvent evt
@ -329,16 +333,12 @@ private void firePopupMessageEvent(Object sourceObject)
}
}
public void chatFocusGained(ChatFocusEvent event)
{
Chat chat = event.getChat();
chat.removeChatFocusListener(this);
this.trayIcon.setIcon(logoIcon);
}
public void chatFocusLost(ChatFocusEvent event)
/**
* Sets a new systray icon.
* @param image the icon to set.
*/
public void setSystrayIcon(byte[] image)
{
this.trayIcon.setIcon(new ImageIcon(image));
}
}

@ -62,4 +62,11 @@ public void showPopupMessage(String title,
* @param listener the listener to remove
*/
public void removePopupMessageListener(SystrayPopupMessageListener listener);
/**
* Sets a new icon to the systray.
*
* @param image the image to set
*/
public void setSystrayIcon(byte[] image);
}

Loading…
Cancel
Save