diff options
author | Yana Stamcheva <yana@jitsi.org> | 2007-12-11 13:55:36 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2007-12-11 13:55:36 +0000 |
commit | 8d68be927f67dd938c4eb472767eae5eb3bbd6a5 (patch) | |
tree | 17ffc011433d2922c0959c4c38453ead5d2c97e1 | |
parent | c3044ea4be504f4e2c277cc7bc9ce776cad12b14 (diff) | |
download | jitsi-8d68be927f67dd938c4eb472767eae5eb3bbd6a5.zip jitsi-8d68be927f67dd938c4eb472767eae5eb3bbd6a5.tar.gz jitsi-8d68be927f67dd938c4eb472767eae5eb3bbd6a5.tar.bz2 |
Change status message interface added
9 files changed, 135 insertions, 69 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/i18n/messages.properties b/src/net/java/sip/communicator/impl/gui/i18n/messages.properties index 2ad6810..ba077d9 100644 --- a/src/net/java/sip/communicator/impl/gui/i18n/messages.properties +++ b/src/net/java/sip/communicator/impl/gui/i18n/messages.properties @@ -66,6 +66,8 @@ banFailed=Ban failed banFailedGeneralError=Failed to ban {0}. A general server error occured. banFailedNotAllowed=Failed to ban {0}. The owner and the administratior of the room could not be banned. banFailedNotEnoughPermissions=Failed to ban {0}. You don't have enough privileges to do that. +brbMessage=I'm gone right now, but I'll be back. +busyMessage=Sorry, I'm busy right now. call=Call callVia=Call via: callList=Call list @@ -199,15 +201,18 @@ networkFailure=Network failure next=&Next new=&New newAccount=&New account +newMessage=New message... newName=New name: +newStatusMessage=New status message no=No noAccountFound=In order to use the SIP-Communicator you need at least one registered account. The following pages will guide you through the process of creating an account. noAvailableRooms=The list of rooms for this server is currently not available. +noMessage=No message noMultiChatAccountAvailable=No accounts, supporting multi user chat found. Check sip-communicator.org for more information on which protocols support multi user chat. nonEmptyChatWindowClose=You're trying to close a chat with a non-sent message. Are you sure you want to close this chat? nonExistingUserId=The {0} server does not recognize specified user id. notifications=Notifications -ok=&OK +ok=&Ok offline=Offline olderCalls=Older calls online=Online @@ -263,6 +268,7 @@ sendFile=S&end file selectContactSupportingInfo=There is no info for this contact. sendMessage=&Send a message sendVia=Send via +setStatusMessage=Set status message settings=&Settings showCallPanel=Show call panel showChannelsList=Show channels list @@ -273,6 +279,7 @@ soundOnOff=Turn sound on/off statusChangedChatMessage=has become {0} statusChangeGeneralError=Failed to change status for account: User name: {0}, Server name: {1}, due to a general error. statusChangeNetworkFailure=Failed to change status for account: User name: {0}, Server name: {1}, due to a network problem. +statusMessageInfo=In the field below you can specify the new message you would like to use. subject=Subject summary=Summary today=Today diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusSelectorBox.java index 6a3108a..5fdffee 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/PresenceStatusSelectorBox.java @@ -18,6 +18,7 @@ import net.java.sip.communicator.impl.gui.customcontrols.*; import net.java.sip.communicator.impl.gui.i18n.*; import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.main.login.*; +import net.java.sip.communicator.impl.gui.main.presence.message.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -113,6 +114,11 @@ public class PresenceStatusSelectorBox .getBytesInImage(status.getStatusIcon())), new ItemActionListener()); } + + this.addSeparator(); + + this.add(new StatusMessageMenu(protocolProvider)); + this.setSelectedStatus(offlineStatus); } @@ -127,7 +133,6 @@ public class PresenceStatusSelectorBox { if (e.getSource() instanceof JMenuItem) { - JMenuItem menuItem = (JMenuItem) e.getSource(); LoginManager loginManager = mainFrame.getLoginManager(); diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorBox.java index 1a49696..2963a32 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/StatusSelectorBox.java @@ -27,23 +27,27 @@ public abstract class StatusSelectorBox extends SIPCommMenu { /** + * Starts the connecting animation. * - * @param images + * @param images the animated image to play */ public void startConnecting(BufferedImage[] images){} /** - * + * Updates the current status. */ public void updateStatus(){} /** + * Returns the account index (In case of more than one account for one and + * the same protocol). * - * @return + * @return the account index */ public int getAccountIndex(){return -1;} /** + * Sets the account index. * * @param index */ diff --git a/src/net/java/sip/communicator/impl/systray/Resources.java b/src/net/java/sip/communicator/impl/systray/Resources.java index a90f1ae..5b44a59 100644 --- a/src/net/java/sip/communicator/impl/systray/Resources.java +++ b/src/net/java/sip/communicator/impl/systray/Resources.java @@ -7,9 +7,13 @@ package net.java.sip.communicator.impl.systray; +import java.awt.image.*; import java.io.*; import java.util.*; +import javax.imageio.*; +import javax.swing.*; + import net.java.sip.communicator.util.*; /** * The Messages class manages the access to the internationalization @@ -31,43 +35,82 @@ public class Resources /** * Returns an internationalized string corresponding to the given key. + * * @param key The key of the string. * @return An internationalized string corresponding to the given key. */ - public static String getString(String key) + public static String getString(String key) { - try + try { - return RESOURCE_BUNDLE.getString(key); + String resourceString = RESOURCE_BUNDLE.getString(key); + + int mnemonicIndex = resourceString.indexOf('&'); + + if(mnemonicIndex > -1) + { + String firstPart = resourceString.substring(0, mnemonicIndex); + String secondPart = resourceString.substring(mnemonicIndex + 1); + + resourceString = firstPart.concat(secondPart); + } - } catch (MissingResourceException e) + return resourceString; + } + catch (MissingResourceException e) { return '!' + key + '!'; } - } - + } + + /** + * Returns an internationalized string corresponding to the given key. + * + * @param key The key of the string. + * @return An internationalized string corresponding to the given key. + */ + public static char getMnemonic(String key) + { + try + { + String resourceString = RESOURCE_BUNDLE.getString(key); + + int mnemonicIndex = resourceString.indexOf('&'); + + if(mnemonicIndex > -1) + return resourceString.charAt(mnemonicIndex + 1); + } + catch (MissingResourceException e) + { + return 0; + } + + return 0; + } + /** * Loads an image from a given image identifier. - * @param key The key of the image. + * + * @param imageID The identifier of the image. * @return The image for the given identifier. */ - public static byte[] getImage(String key) + public static ImageIcon getImage(String imageID) { - byte[] image = new byte[100000]; - - String path=Resources.getString(key); - - try - { - Resources.class.getClassLoader() - .getResourceAsStream(path).read(image); - - } catch (IOException e) + BufferedImage image = null; + + String path = Resources.getString(imageID); + try { - log.error("Failed to load image:" + key, e); + image = + ImageIO.read(Resources.class.getClassLoader() + .getResourceAsStream(path)); + + } + catch (IOException e) + { + log.error("Failed to load image:" + path, e); } - - return image; - } + return new ImageIcon(image); + } } diff --git a/src/net/java/sip/communicator/impl/systray/jdic/StatusSelector.java b/src/net/java/sip/communicator/impl/systray/jdic/StatusSelector.java index a3a49d4..3897c4a 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/StatusSelector.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/StatusSelector.java @@ -13,6 +13,7 @@ import java.util.*; import javax.swing.*; +import net.java.sip.communicator.impl.systray.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; @@ -47,6 +48,8 @@ public class StatusSelector private Logger logger = Logger.getLogger( StatusSelector.class.getName()); + private StatusMessageMenu statusMessageMenu; + /** * Creates an instance of StatusSelector * @@ -58,34 +61,38 @@ public class StatusSelector ProtocolProviderService provider, OperationSetPresence presence) { - this.parentSystray = jdicSystray; this.provider = provider; this.presence = presence; - + + this.statusMessageMenu = new StatusMessageMenu(provider); /* the parent item */ - + this.setText(provider.getAccountID().getUserID()); this.setIcon(new ImageIcon( presence.getPresenceStatus().getStatusIcon())); - + /* the submenu itself */ - + Iterator statusIterator = this.presence.getSupportedStatusSet(); - + while(statusIterator.hasNext()) { PresenceStatus status = (PresenceStatus) statusIterator.next(); ImageIcon icon = new ImageIcon(status.getStatusIcon()); JMenuItem item = new JMenuItem(status.getStatusName(),icon); - + item.addActionListener(this); - + this.add(item); } + + this.addSeparator(); + + this.add(statusMessageMenu); } - + /** * Change the status of the protocol according to * the menu item selected @@ -93,7 +100,6 @@ public class StatusSelector */ public void actionPerformed(ActionEvent evt) { - JMenuItem menuItem = (JMenuItem) evt.getSource(); Iterator statusSet = presence.getSupportedStatusSet(); @@ -110,14 +116,14 @@ public class StatusSelector && !presence.getPresenceStatus().equals(status)) { if (status.isOnline()) - { + { new PublishPresenceStatusThread(status).start(); } - else + else { new ProviderUnRegistration(this.provider).start(); } - } + } else if (this.provider.getRegistrationState() != RegistrationState.REGISTERED && this.provider.getRegistrationState() @@ -175,28 +181,28 @@ public class StatusSelector try { presence.publishPresenceStatus(status, ""); } - catch (IllegalArgumentException e1) + catch (IllegalArgumentException e1) { logger.error("Error - changing status", e1); } - catch (IllegalStateException e1) + catch (IllegalStateException e1) { logger.error("Error - changing status", e1); } - catch (OperationFailedException e1) + catch (OperationFailedException e1) { - if (e1.getErrorCode() - == OperationFailedException.GENERAL_ERROR) + if (e1.getErrorCode() + == OperationFailedException.GENERAL_ERROR) { logger.error( "General error occured while " + "publishing presence status.", e1); } - else if (e1.getErrorCode() + else if (e1.getErrorCode() == OperationFailedException .NETWORK_FAILURE) { diff --git a/src/net/java/sip/communicator/impl/systray/jdic/StatusSubMenu.java b/src/net/java/sip/communicator/impl/systray/jdic/StatusSubMenu.java index 8a0596f..7f41ecd 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/StatusSubMenu.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/StatusSubMenu.java @@ -52,11 +52,10 @@ public class StatusSubMenu { parentSystray = tray; - + this.setText(Resources.getString("setStatus")); - this.setIcon( - new ImageIcon(Resources.getImage("statusMenuIcon"))); - + this.setIcon(Resources.getImage("statusMenuIcon")); + /* makes the menu look better */ this.setPreferredSize(new java.awt.Dimension(28, 24)); diff --git a/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java b/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java index 7e60c83..bc7bf60 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/SystrayServiceJdicImpl.java @@ -123,30 +123,22 @@ public class SystrayServiceJdicImpl // background. if (osName.startsWith("Windows")) { - logoIcon = new ImageIcon( - Resources.getImage("trayIconWindows")); - envelopeIcon = new ImageIcon( - Resources.getImage("messageIconWindows")); + logoIcon = Resources.getImage("trayIconWindows"); + envelopeIcon = Resources.getImage("messageIconWindows"); } // If we're running under MacOSX, we use a special black and // white icons without background. else if (osName.startsWith("Mac OS X")) { - logoIcon = new ImageIcon( - Resources.getImage("trayIconMacOSX")); - logoIconWhite = new ImageIcon( - Resources.getImage("trayIconMacOSXWhite")); - envelopeIcon = new ImageIcon( - Resources.getImage("messageIconMacOSX")); - envelopeIconWhite = new ImageIcon( - Resources.getImage("messageIconMacOSXWhite")); + logoIcon = Resources.getImage("trayIconMacOSX"); + logoIconWhite = Resources.getImage("trayIconMacOSXWhite"); + envelopeIcon = Resources.getImage("messageIconMacOSX"); + envelopeIconWhite = Resources.getImage("messageIconMacOSXWhite"); } else { - logoIcon = new ImageIcon( - Resources.getImage("trayIcon")); - envelopeIcon = new ImageIcon( - Resources.getImage("messageIcon")); + logoIcon = Resources.getImage("trayIcon"); + envelopeIcon = Resources.getImage("messageIcon"); } currentIcon = logoIcon; diff --git a/src/net/java/sip/communicator/impl/systray/jdic/TrayMenu.java b/src/net/java/sip/communicator/impl/systray/jdic/TrayMenu.java index e46baa7..a1582ff 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/TrayMenu.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/TrayMenu.java @@ -39,15 +39,15 @@ public class TrayMenu private JMenuItem settingsItem = new JMenuItem( Resources.getString("settings"), - new ImageIcon(Resources.getImage("settingsMenuIcon"))); + Resources.getImage("settingsMenuIcon")); private JMenuItem closeItem = new JMenuItem( Resources.getString("close"), - new ImageIcon(Resources.getImage("closeMenuIcon"))); + Resources.getImage("closeMenuIcon")); private JMenuItem addContactMenuItem = new JMenuItem( Resources.getString("addContact"), - new ImageIcon(Resources.getImage("addContactIcon"))); + Resources.getImage("addContactIcon")); private StatusSubMenu statusMenu; diff --git a/src/net/java/sip/communicator/impl/systray/resources.properties b/src/net/java/sip/communicator/impl/systray/resources.properties index 65e7c8c..cded3a1 100644 --- a/src/net/java/sip/communicator/impl/systray/resources.properties +++ b/src/net/java/sip/communicator/impl/systray/resources.properties @@ -17,6 +17,7 @@ messageIcon=net/java/sip/communicator/impl/systray/resources/envelope.png messageIconWindows=net/java/sip/communicator/impl/systray/resources/envelopeWindows.png messageIconMacOSX=net/java/sip/communicator/impl/systray/resources/envelopeMacOSX.png messageIconMacOSXWhite=net/java/sip/communicator/impl/systray/resources/envelopeMacOSXWhite.png +newStatusMessageIcon=resources/images/impl/gui/common/renameDialogIcon.png settings=Settings... addContact=Add contact... setStatus=Set Status @@ -26,3 +27,12 @@ offlineStatus=Offline messageReceived=Message received from failedToLoadAddContactDialog=Failed to load the "Add contact" wizard dialog. systrayToolTip=SIP Communicator +setStatusMessage=Set status message +newStatusMessage=New status message +statusMessageInfo=In the field below you can specify the new message you would like to use. +noMessage=No message +newMessage=New message... +busyMessage=Sorry, I'm busy right now. +brbMessage=I'm gone right now, but I'll be back. +ok=&Ok +cancel=&Cancel |