aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2013-12-17 11:12:00 +0200
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2013-12-17 11:12:00 +0200
commit5ddf3390602b828a128d62b53cbf03316305af3b (patch)
tree587daeee3e19ecfb94492904a1dcb6fdde5bd043 /src
parenta2ac6e081c44681aeff8052e1a4ebcdacb8ff252 (diff)
downloadjitsi-5ddf3390602b828a128d62b53cbf03316305af3b.zip
jitsi-5ddf3390602b828a128d62b53cbf03316305af3b.tar.gz
jitsi-5ddf3390602b828a128d62b53cbf03316305af3b.tar.bz2
Fixes an issue with missing or corrupt images which could cause the whole user interface of the application or parts of it to not appear at all.
Diffstat (limited to 'src')
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/MetaUIContact.java31
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/menus/AutoAnswerMenu.java35
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java8
-rw-r--r--src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java79
-rw-r--r--src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java28
-rw-r--r--src/net/java/sip/communicator/impl/osdependent/jdic/StatusSelector.java43
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java7
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/ImageUtils.java59
8 files changed, 168 insertions, 122 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/MetaUIContact.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/MetaUIContact.java
index 3a2bf81..61fe737 100644
--- a/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/MetaUIContact.java
+++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/contactsource/MetaUIContact.java
@@ -471,19 +471,26 @@ public class MetaUIContact
protocolContact = i.next();
// Set the first found status message.
- if (statusMessage == null
- && protocolContact.getStatusMessage() != null
- && protocolContact.getStatusMessage().length() > 0)
+ if (statusMessage == null)
+ {
statusMessage = protocolContact.getStatusMessage();
+ if ((statusMessage != null) && (statusMessage.length() == 0))
+ statusMessage = null;
+ }
if(ConfigurationUtils.isHideAccountStatusSelectorsEnabled())
break;
ImageIcon protocolStatusIcon
- = ImageLoader.getIndexedProtocolIcon(
- ImageUtils.getBytesInImage(
- protocolContact.getPresenceStatus().getStatusIcon()),
- protocolContact.getProtocolProvider());
+ = getContactPresenceStatusIcon(protocolContact);
+
+ if (protocolStatusIcon != null)
+ {
+ protocolStatusIcon
+ = ImageLoader.getIndexedProtocolIcon(
+ protocolStatusIcon.getImage(),
+ protocolContact.getProtocolProvider());
+ }
String contactAddress = protocolContact.getAddress();
//String statusMessage = protocolContact.getStatusMessage();
@@ -682,14 +689,13 @@ public class MetaUIContact
{
super( contact.getAddress(),
contact.getDisplayName(),
- new ImageIcon(contact.getPresenceStatus().getStatusIcon()),
+ getContactPresenceStatusIcon(contact),
contact);
this.contact = contact;
ProtocolProviderService parentProvider
= contact.getProtocolProvider();
-
Iterator<Class<? extends OperationSet>> opSetClasses
= parentProvider.getSupportedOperationSetClasses().iterator();
@@ -736,4 +742,11 @@ public class MetaUIContact
{
return MetaContactListSource.getContactCustomActionButtons(this);
}
+
+ private static ImageIcon getContactPresenceStatusIcon(Contact contact)
+ {
+ byte[] bytes = contact.getPresenceStatus().getStatusIcon();
+
+ return (bytes == null) ? null : new ImageIcon(bytes);
+ }
}
diff --git a/src/net/java/sip/communicator/impl/gui/main/menus/AutoAnswerMenu.java b/src/net/java/sip/communicator/impl/gui/main/menus/AutoAnswerMenu.java
index 6c5a935..edf08d1 100644
--- a/src/net/java/sip/communicator/impl/gui/main/menus/AutoAnswerMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/menus/AutoAnswerMenu.java
@@ -409,20 +409,30 @@ public class AutoAnswerMenu
* @return the image.
*/
private static Image getIconForProvider(
- ProtocolProviderService providerService, Image customProviderImage,
- ImageObserver imageObserver)
+ ProtocolProviderService providerService,
+ Image customProviderImage,
+ ImageObserver imageObserver)
{
- Image left = null;
- if(isAutoAnswerEnabled(providerService))
- left = ImageLoader.getImage(ImageLoader.AUTO_ANSWER_CHECK);
+ Image left
+ = isAutoAnswerEnabled(providerService)
+ ? ImageLoader.getImage(ImageLoader.AUTO_ANSWER_CHECK)
+ : null;
if(customProviderImage == null)
- customProviderImage = ImageUtils.getBytesInImage(
- providerService.getProtocolIcon().getIcon(
- ProtocolIcon.ICON_SIZE_16x16));
+ {
+ byte[] bytes
+ = providerService.getProtocolIcon().getIcon(
+ ProtocolIcon.ICON_SIZE_16x16);
+
+ if (bytes != null)
+ customProviderImage = ImageUtils.getBytesInImage(bytes);
+ }
- return ImageUtils.getComposedImage(
- left, customProviderImage, imageObserver);
+ return
+ ImageUtils.getComposedImage(
+ left,
+ customProviderImage,
+ imageObserver);
}
/**
@@ -526,7 +536,10 @@ public class AutoAnswerMenu
Image onlineImage,
SIPCommMenu parentMenu)
{
- super(displayName, new ImageIcon(onlineImage));
+ super(
+ displayName,
+ (onlineImage == null) ? null : new ImageIcon(onlineImage));
+
this.providerService = provider;
this.parentMenu = parentMenu;
diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java b/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java
index b10e7f7..305b184 100644
--- a/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusMenu.java
@@ -106,10 +106,11 @@ public class PresenceStatusMenu
while (statusIterator.hasNext())
{
PresenceStatus status = statusIterator.next();
+ byte[] statusIcon = status.getStatusIcon();
- this.addItem(
+ addItem(
status.getStatusName(),
- new ImageIcon(status.getStatusIcon()),
+ (statusIcon == null) ? null : new ImageIcon(statusIcon),
this);
}
@@ -133,12 +134,13 @@ public class PresenceStatusMenu
public void addItem(String text, Icon icon, ActionListener actionListener)
{
JCheckBoxMenuItem item = new JCheckBoxMenuItem(text, icon);
+
item.setName(text);
group.add(item);
item.addActionListener(actionListener);
- this.add(item);
+ add(item);
}
/**
diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java b/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java
index de7051e..b6aaf60 100644
--- a/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java
+++ b/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java
@@ -46,11 +46,12 @@ public class SimpleStatusMenu
*/
public SimpleStatusMenu(ProtocolProviderService protocolProvider)
{
- this(protocolProvider,
- protocolProvider.getAccountID().getDisplayName(),
- ImageUtils.getBytesInImage(
- protocolProvider.getProtocolIcon().getIcon(
- ProtocolIcon.ICON_SIZE_16x16)));
+ this(
+ protocolProvider,
+ protocolProvider.getAccountID().getDisplayName(),
+ getProtocolImage(
+ protocolProvider,
+ ProtocolIcon.ICON_SIZE_16x16));
}
/**
@@ -64,27 +65,34 @@ public class SimpleStatusMenu
String displayName,
Image onlineImage)
{
- super(displayName, new ImageIcon(onlineImage), protocolProvider);
+ super(
+ displayName,
+ (onlineImage == null) ? null : new ImageIcon(onlineImage),
+ protocolProvider);
- this.setToolTipText("<html><b>" + displayName
- + "</b><br>Offline</html>");
+ setToolTipText("<html><b>" + displayName + "</b><br>Offline</html>");
JLabel titleLabel = new JLabel(displayName);
titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));
titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD));
- this.add(titleLabel);
- this.addSeparator();
+ add(titleLabel);
+ addSeparator();
onlineItem = createMenuItem(
"service.gui.ONLINE",
getIcon(),
GlobalStatusEnum.ONLINE_STATUS);
- offlineItem = createMenuItem(
- "service.gui.OFFLINE",
- new ImageIcon(LightGrayFilter.createDisabledImage(onlineImage)),
- GlobalStatusEnum.OFFLINE_STATUS);
+ offlineItem
+ = createMenuItem(
+ "service.gui.OFFLINE",
+ (onlineImage == null)
+ ? null
+ : new ImageIcon(
+ LightGrayFilter.createDisabledImage(
+ onlineImage)),
+ GlobalStatusEnum.OFFLINE_STATUS);
group.add(onlineItem);
group.add(offlineItem);
@@ -96,16 +104,18 @@ public class SimpleStatusMenu
}
private JCheckBoxMenuItem createMenuItem(
- String textKey, Icon icon, String name)
+ String textKey,
+ Icon icon,
+ String name)
{
- JCheckBoxMenuItem menuItem =
- new JCheckBoxMenuItem(
- GuiActivator.getResources().getI18NString(textKey),
- icon);
+ JCheckBoxMenuItem menuItem
+ = new JCheckBoxMenuItem(
+ GuiActivator.getResources().getI18NString(textKey),
+ icon);
menuItem.setName(name);
menuItem.addActionListener(this);
- this.add(menuItem);
+ add(menuItem);
return menuItem;
}
@@ -161,18 +171,29 @@ public class SimpleStatusMenu
public void loadSkin()
{
super.loadSkin();
- setIcon(new ImageIcon(ImageUtils.getBytesInImage(
- protocolProvider.getProtocolIcon().getIcon(
- ProtocolIcon.ICON_SIZE_16x16))));
- if(onlineItem != null)
+ Image image
+ = getProtocolImage(protocolProvider, ProtocolIcon.ICON_SIZE_16x16);
+
+ if (image != null)
+ setIcon(new ImageIcon(image));
+
+ if (onlineItem != null)
onlineItem.setIcon(getIcon());
- if(offlineItem != null)
+ if ((offlineItem != null) && (image != null))
+ {
offlineItem.setIcon(
- new ImageIcon(LightGrayFilter.createDisabledImage(
- ImageUtils.getBytesInImage(
- protocolProvider.getProtocolIcon().getIcon(
- ProtocolIcon.ICON_SIZE_16x16)))));
+ new ImageIcon(LightGrayFilter.createDisabledImage(image)));
+ }
+ }
+
+ private static Image getProtocolImage(
+ ProtocolProviderService pps,
+ String iconSize)
+ {
+ byte[] bytes = pps.getProtocolIcon().getIcon(iconSize);
+
+ return (bytes == null) ? null : ImageUtils.getBytesInImage(bytes);
}
}
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 ac82d7f..664d9ae 100644
--- a/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
+++ b/src/net/java/sip/communicator/impl/gui/utils/ImageLoader.java
@@ -1535,16 +1535,13 @@ public class ImageLoader
*/
public static ImageIcon getAccountStatusImage(ProtocolProviderService pps)
{
- ImageIcon statusIcon;
-
OperationSetPresence presence
= pps.getOperationSet(OperationSetPresence.class);
-
+ byte[] protocolStatusIcon
+ = (presence == null)
+ ? null
+ : presence.getPresenceStatus().getStatusIcon();
Image statusImage;
- byte[] protocolStatusIcon = null;
-
- if(presence != null)
- protocolStatusIcon = presence.getPresenceStatus().getStatusIcon();
if (presence != null && protocolStatusIcon != null)
{
@@ -1552,21 +1549,22 @@ public class ImageLoader
}
else
{
- statusImage
- = ImageUtils.getBytesInImage(pps.getProtocolIcon().getIcon(
- ProtocolIcon.ICON_SIZE_16x16));
+ byte[] bytes
+ = pps.getProtocolIcon().getIcon(ProtocolIcon.ICON_SIZE_16x16);
- if (!pps.isRegistered())
+ statusImage
+ = (bytes == null) ? null : ImageUtils.getBytesInImage(bytes);
+ if (!pps.isRegistered() && (statusImage != null))
{
statusImage
= LightGrayFilter.createDisabledImage(statusImage);
}
}
- statusIcon = new ImageIcon(
- getIndexedProtocolImage(statusImage, pps));
-
- return statusIcon;
+ return
+ (statusImage == null)
+ ? null
+ : new ImageIcon(getIndexedProtocolImage(statusImage, pps));
}
/**
diff --git a/src/net/java/sip/communicator/impl/osdependent/jdic/StatusSelector.java b/src/net/java/sip/communicator/impl/osdependent/jdic/StatusSelector.java
index b232f5d..0e3625f 100644
--- a/src/net/java/sip/communicator/impl/osdependent/jdic/StatusSelector.java
+++ b/src/net/java/sip/communicator/impl/osdependent/jdic/StatusSelector.java
@@ -177,49 +177,50 @@ public class StatusSelector
public void updateStatus(PresenceStatus presenceStatus)
{
+ String presenceStatusName = presenceStatus.getStatusName();
+
if (logger.isTraceEnabled())
- logger.trace("Systray update status for provider: "
- + provider.getAccountID().getAccountAddress()
- + ". The new status will be: " + presenceStatus.getStatusName());
+ {
+ logger.trace(
+ "Systray update status for provider: "
+ + provider.getAccountID().getAccountAddress()
+ + ". The new status will be: "
+ + presenceStatusName);
+ }
if (menu instanceof AbstractButton)
- ((AbstractButton) menu).setIcon(new ImageIcon(presenceStatus
- .getStatusIcon()));
+ {
+ byte[] bytes = presenceStatus.getStatusIcon();
+
+ if (bytes != null)
+ ((AbstractButton) menu).setIcon(new ImageIcon());
+ }
if(menu instanceof Menu)
{
Menu theMenu = (Menu) menu;
- for(int i =0; i < theMenu.getItemCount(); i++)
+
+ for(int i = 0, count = theMenu.getItemCount(); i < count; i++)
{
MenuItem item = theMenu.getItem(i);
if(item instanceof CheckboxMenuItem)
{
- if(item.getLabel().equals(presenceStatus.getStatusName()))
- {
- ((CheckboxMenuItem)item).setState(true);
- }
- else
- {
- ((CheckboxMenuItem)item).setState(false);
- }
+ ((CheckboxMenuItem) item).setState(
+ item.getLabel().equals(presenceStatusName));
}
}
}
else if(menu instanceof JMenu)
{
JMenu theMenu = (JMenu) menu;
- for(int i =0; i < theMenu.getItemCount(); i++)
+
+ for(int i = 0, count = theMenu.getItemCount(); i < count; i++)
{
JMenuItem item = theMenu.getItem(i);
if(item instanceof JCheckBoxMenuItem)
- {
- if(item.getText().equals(presenceStatus.getStatusName()))
- item.setSelected(true);
- else
- item.setSelected(false);
- }
+ item.setSelected(item.getText().equals(presenceStatusName));
}
}
}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java b/src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java
index 47fb4aa..f1fbaab 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/ExtendedTooltip.java
@@ -146,12 +146,9 @@ public class ExtendedTooltip
* @param icon the icon to show
* @param text the name to show
*/
- public void addLine(Icon icon,
- String text)
+ public void addLine(Icon icon, String text)
{
- JLabel lineLabel = new JLabel( text,
- icon,
- JLabel.LEFT);
+ JLabel lineLabel = new JLabel(text, icon, JLabel.LEFT);
linesPanel.add(lineLabel);
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/ImageUtils.java b/src/net/java/sip/communicator/plugin/desktoputil/ImageUtils.java
index d84f278..513ef32 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/ImageUtils.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/ImageUtils.java
@@ -503,9 +503,7 @@ public class ImageUtils
Image image = null;
try
{
- image = ImageIO.read(
- new ByteArrayInputStream(imageBytes));
-
+ image = ImageIO.read(new ByteArrayInputStream(imageBytes));
}
catch (Exception e)
{
@@ -523,48 +521,51 @@ public class ImageUtils
* @return the composed image.
*/
public static Image getComposedImage(
- Image leftImage, Image rightImage,
- ImageObserver imageObserver)
+ Image leftImage, Image rightImage,
+ ImageObserver imageObserver)
{
- int height = 0;
- if(leftImage == null && rightImage == null)
- return null;
- if(leftImage != null && rightImage != null)
- height = Math.max(leftImage.getHeight(imageObserver),
- rightImage.getHeight(imageObserver));
- else if(leftImage == null)
- height = rightImage.getHeight(imageObserver);
- else
- height = leftImage.getHeight(imageObserver);
+ int height;
+ int leftWidth;
+ int width;
- int width = 0;
- int leftWidth = 0;
- if(leftImage != null && rightImage != null)
+ if (leftImage == null)
{
- leftWidth = leftImage.getWidth(imageObserver);
- width = leftWidth +
- rightImage.getWidth(imageObserver);
+ if (rightImage == null)
+ {
+ return null;
+ }
+ else
+ {
+ height = rightImage.getHeight(imageObserver);
+ leftWidth = rightImage.getWidth(imageObserver);
+ width = leftWidth * 2;
+ }
}
- else if(leftImage == null)
+ else if (rightImage == null)
{
- leftWidth = rightImage.getWidth(imageObserver);
- width = leftWidth*2;
+ height = leftImage.getHeight(imageObserver);
+ leftWidth = leftImage.getWidth(imageObserver);
+ width = leftWidth * 2;
}
else
{
+ height
+ = Math.max(
+ leftImage.getHeight(imageObserver),
+ rightImage.getHeight(imageObserver));
leftWidth = leftImage.getWidth(imageObserver);
- width = leftWidth*2;
+ width = leftWidth + rightImage.getWidth(imageObserver);
}
- BufferedImage buffImage =
- new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ BufferedImage buffImage
+ = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D) buffImage.getGraphics();
AntialiasingManager.activateAntialiasing(g);
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
- if(leftImage != null)
+ if (leftImage != null)
g.drawImage(leftImage, 0, 0, null);
- if(rightImage != null)
+ if (rightImage != null)
g.drawImage(rightImage, leftWidth + 1, 0, null);
return buffImage;