diff options
author | Yana Stamcheva <yana@jitsi.org> | 2008-03-05 17:01:59 +0000 |
---|---|---|
committer | Yana Stamcheva <yana@jitsi.org> | 2008-03-05 17:01:59 +0000 |
commit | 34414afb2ea4956c67cc39931f7da610c16445d3 (patch) | |
tree | 24675d182223185e149edadf9583db90aa262b4c /src/net/java | |
parent | 3f9cae0699b4ef2a4d6b1424b07f57868b77cb01 (diff) | |
download | jitsi-34414afb2ea4956c67cc39931f7da610c16445d3.zip jitsi-34414afb2ea4956c67cc39931f7da610c16445d3.tar.gz jitsi-34414afb2ea4956c67cc39931f7da610c16445d3.tar.bz2 |
- Added a protocolDisplayName in the ProtocolProviderService, which is now used to display the name of the protocol in the GUI.
- Added a property, where we could specify the icon path for a protocol provider.
Diffstat (limited to 'src/net/java')
29 files changed, 435 insertions, 134 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java index 926c262..96748f6 100755 --- a/src/net/java/sip/communicator/impl/gui/main/MainFrame.java +++ b/src/net/java/sip/communicator/impl/gui/main/MainFrame.java @@ -912,12 +912,11 @@ public class MainFrame while(pproviders.hasNext()) { pps = (ProtocolProviderService)pproviders.next(); - if(pps.getProtocolName().equals( - protocolProvider.getProtocolName()) + if(pps.getProtocolDisplayName().equals( + protocolProvider.getProtocolDisplayName()) && !pps.equals(protocolProvider)) { - int index = ((Integer)protocolProviders.get(pps)) - .intValue(); + int index = ((Integer)protocolProviders.get(pps)).intValue(); if(accountIndex < index) { accountIndex = index; @@ -952,8 +951,8 @@ public class MainFrame ProtocolProviderService pps = (ProtocolProviderService)pproviders.next(); - if(pps.getProtocolName().equals( - removedProvider.getProtocolName())) { + if(pps.getProtocolDisplayName().equals( + removedProvider.getProtocolDisplayName())) { sameProtocolProvidersCount++; if(sameProtocolProvidersCount > 1) { diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/GuiChatRoomEvent.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/GuiChatRoomEvent.java index 428e561..11ba42a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/GuiChatRoomEvent.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/GuiChatRoomEvent.java @@ -85,7 +85,7 @@ public class GuiChatRoomEvent buff.append(getSourceChatRoom().getName()); buff.append(", eventID=").append(getEventID()); buff.append(", ProtocolProvider=") - .append(getProtocolProvider().getProtocolName()); + .append(getProtocolProvider().getProtocolDisplayName()); return buff.toString(); } diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/SelectAccountPanel.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/SelectAccountPanel.java index b014eb3..568da5b 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/SelectAccountPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/createforms/SelectAccountPanel.java @@ -135,7 +135,7 @@ public class SelectAccountPanel extends JPanel if(opSet == null) continue; - String pName = pps.getProtocolName(); + String pName = pps.getProtocolDisplayName(); Image protocolImage = null; try diff --git a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SelectAccountPanel.java b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SelectAccountPanel.java index 44e7f2f..5a075d4 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SelectAccountPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chatroomslist/joinforms/SelectAccountPanel.java @@ -128,7 +128,7 @@ public class SelectAccountPanel extends JPanel if(opSet == null) continue; - String pName = pps.getProtocolName(); + String pName = pps.getProtocolDisplayName(); Image protocolImage = null; try diff --git a/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java b/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java index 120162c..c5a545a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java +++ b/src/net/java/sip/communicator/impl/gui/main/configforms/AccountsConfigurationForm.java @@ -182,7 +182,7 @@ public class AccountsConfigurationForm extends JPanel = (ProtocolProviderService) GuiActivator.bundleContext .getService(serRef); - String pName = protocolProvider.getProtocolName(); + String pName = protocolProvider.getProtocolDisplayName(); Image protocolImage = null; try @@ -357,7 +357,7 @@ public class AccountsConfigurationForm extends JPanel if (event.getType() == ServiceEvent.REGISTERED) { - String pName = pps.getProtocolName(); + String pName = pps.getProtocolDisplayName(); Image protocolImage = null; try diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/SelectAccountPanel.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/SelectAccountPanel.java index 0e53703..83d4114 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/SelectAccountPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/SelectAccountPanel.java @@ -125,7 +125,7 @@ public class SelectAccountPanel if(opSet == null) continue; - String pName = pps.getProtocolName(); + String pName = pps.getProtocolDisplayName(); Image protocolImage = null; try @@ -229,7 +229,7 @@ public class SelectAccountPanel if (event.getType() == ServiceEvent.REGISTERED) { - String pName = sourcePProvider.getProtocolName(); + String pName = sourcePProvider.getProtocolDisplayName(); Image protocolImage = null; try diff --git a/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java b/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java index 1d5e2f7..5ae2c70 100644 --- a/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java +++ b/src/net/java/sip/communicator/impl/gui/main/login/LoginManager.java @@ -254,10 +254,9 @@ public class LoginManager else if (evt.getReasonCode() == RegistrationStateChangeEvent .REASON_NON_EXISTING_USER_ID) { - String msgText = Messages.getI18NString("nonExistingUserId", new String[] - { protocolProvider.getProtocolName() }).getText(); + { protocolProvider.getProtocolDisplayName() }).getText(); new ErrorDialog(null, Messages.getI18NString("error").getText(), @@ -299,7 +298,7 @@ public class LoginManager String msgText = Messages.getI18NString("connectionExpiredMessage", new String[] - { protocolProvider.getProtocolName() }).getText(); + { protocolProvider.getProtocolDisplayName() }).getText(); new ErrorDialog(null, Messages.getI18NString("error").getText(), @@ -338,7 +337,7 @@ public class LoginManager { String msgText = Messages.getI18NString( "limitReachedForIp", new String[] - { protocolProvider.getProtocolName() }).getText(); + { protocolProvider.getProtocolDisplayName() }).getText(); new ErrorDialog(null, Messages.getI18NString("error").getText(), diff --git a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java index c179300..6a415fe 100644 --- a/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java +++ b/src/net/java/sip/communicator/impl/msghistory/MessageHistoryServiceImpl.java @@ -886,7 +886,8 @@ public class MessageHistoryServiceImpl */ private void handleProviderAdded(ProtocolProviderService provider) { - logger.debug("Adding protocol provider " + provider.getProtocolName()); + logger.debug("Adding protocol provider " + + provider.getProtocolDisplayName()); // check whether the provider has a basic im operation set OperationSetBasicInstantMessaging opSetIm diff --git a/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderServiceGibberishImpl.java b/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderServiceGibberishImpl.java index 18152f6..67638a5 100644 --- a/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderServiceGibberishImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/gibberish/ProtocolProviderServiceGibberishImpl.java @@ -250,6 +250,17 @@ public class ProtocolProviderServiceGibberishImpl { return GIBBERISH_PROTOCOL_NAME; } + /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + return GIBBERISH_PROTOCOL_NAME; + } /** * Returns the state of the registration of this protocol provider with diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java index 4e948b7..0fd8216 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java @@ -390,6 +390,21 @@ public class ProtocolProviderServiceIcqImpl } /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + if(USING_ICQ) + return ProtocolNames.ICQ; + else + return ProtocolNames.AIM; + } + + /** * Returns an array containing all operation sets supported by the * current implementation. * diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java index cc910fd..c09986d 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java @@ -234,6 +234,18 @@ public class ProtocolProviderServiceIrcImpl } /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + return ProtocolNames.IRC; + } + + /** * Returns the state of the registration of this protocol provider with * the corresponding registration service. * diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java index e4e7c11..b77c04b 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java @@ -461,6 +461,18 @@ public class ProtocolProviderServiceJabberImpl } /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + return ProtocolNames.JABBER; + } + + /** * Returns an array containing all operation sets supported by the * current implementation. * diff --git a/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java b/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java index 4e43444..97003a9 100644 --- a/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java +++ b/src/net/java/sip/communicator/impl/protocol/mock/MockProvider.java @@ -102,6 +102,16 @@ public class MockProvider /** * Mock implementation of the corresponding ProtocolProviderService method. * + * @return a String describing this mock protocol. + */ + public String getProtocolDisplayName() + { + return PROTO_NAME; + } + + /** + * Mock implementation of the corresponding ProtocolProviderService method. + * * @return a Registered RegistrationState. */ public RegistrationState getRegistrationState() diff --git a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java index 8f2ce0e..f7b6476 100644 --- a/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/msn/ProtocolProviderServiceMsnImpl.java @@ -261,6 +261,18 @@ public class ProtocolProviderServiceMsnImpl } /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + return ProtocolNames.MSN; + } + + /** * Returns an array containing all operation sets supported by the * current implementation. * diff --git a/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderServiceRssImpl.java b/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderServiceRssImpl.java index 47501e1..44d17de 100644 --- a/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderServiceRssImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/rss/ProtocolProviderServiceRssImpl.java @@ -251,6 +251,18 @@ public class ProtocolProviderServiceRssImpl } /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + return RSS_PROTOCOL_NAME; + } + + /** * Returns the state of the registration of this protocol provider with * the corresponding registration service. * diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java index 0526f2b..9909e21 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ContactSipImpl.java @@ -47,7 +47,7 @@ public class ContactSipImpl /** * The presence status of the contact. */ - private PresenceStatus presenceStatus = SipStatusEnum.UNKNOWN; + private PresenceStatus presenceStatus; /** * Determines whether this contact is persistent, i.e. member of the contact diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicInstantMessagingSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicInstantMessagingSipImpl.java index 6aeadd5..58b18a3 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicInstantMessagingSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicInstantMessagingSipImpl.java @@ -64,6 +64,11 @@ public class OperationSetBasicInstantMessagingSipImpl private Hashtable sentMsg = null; /** + * Gives access to presence states for the Sip protocol. + */ + private SipStatusEnum sipStatusEnum; + + /** * Creates an instance of this operation set. * @param provider a ref to the <tt>ProtocolProviderServiceImpl</tt> * that created us and that we'll use for retrieving the underlying aim @@ -79,6 +84,8 @@ public class OperationSetBasicInstantMessagingSipImpl sipProvider.registerMethodProcessor(Request.MESSAGE, new SipMessageListener()); + + this.sipStatusEnum = sipProvider.getSipStatusEnum(); } /** @@ -232,7 +239,8 @@ public class OperationSetBasicInstantMessagingSipImpl assertConnected(); // no offline message - if (to.getPresenceStatus().equals(SipStatusEnum.OFFLINE)) + if (to.getPresenceStatus().equals( + sipStatusEnum.getStatus(SipStatusEnum.OFFLINE))) { logger.debug("trying to send a message to an offline contact"); MessageDeliveryFailedEvent evt = diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java index 0a467f8..0b4b7ae 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetPresenceSipImpl.java @@ -81,7 +81,7 @@ public class OperationSetPresenceSipImpl /** * Our default presence status. */ - private PresenceStatus presenceStatus = SipStatusEnum.OFFLINE; + private PresenceStatus presenceStatus; /** * Hashtable which contains the contacts with which we want to subscribe @@ -183,6 +183,8 @@ public class OperationSetPresenceSipImpl */ private Transformer transformer = null; + private SipStatusEnum sipStatusEnum = null; + /** * The id used in <tt><tuple></tt> and <tt><person></tt> elements * of pidf documents. @@ -277,6 +279,9 @@ public class OperationSetPresenceSipImpl this.subscriptionDuration = subscriptionExpiration; } this.presenceEnabled = isPresenceEnabled; + + this.sipStatusEnum = parentProvider.getSipStatusEnum(); + this.presenceStatus = sipStatusEnum.getStatus(SipStatusEnum.OFFLINE); } /** @@ -1005,8 +1010,9 @@ public class OperationSetPresenceSipImpl * @return Iterator a PresenceStatus array containing "enterable" * status instances. */ - public Iterator getSupportedStatusSet() { - return SipStatusEnum.supportedStatusSet(); + public Iterator getSupportedStatusSet() + { + return sipStatusEnum.getSupportedStatusSet(); } /** @@ -1861,7 +1867,7 @@ public class OperationSetPresenceSipImpl // we probably won't be able to communicate with the contact changePresenceStatusForContact(contact, - SipStatusEnum.UNKNOWN); + sipStatusEnum.getStatus(SipStatusEnum.UNKNOWN)); this.subscribedContacts.remove(idheader.getCallId()); contact.setClientDialog(null); } @@ -1879,10 +1885,10 @@ public class OperationSetPresenceSipImpl .TEMPORARILY_UNAVAILABLE) { changePresenceStatusForContact(contact, - SipStatusEnum.OFFLINE); + sipStatusEnum.getStatus(SipStatusEnum.OFFLINE)); } else { changePresenceStatusForContact(contact, - SipStatusEnum.UNKNOWN); + sipStatusEnum.getStatus(SipStatusEnum.UNKNOWN)); } this.subscribedContacts.remove(idheader.getCallId()); @@ -1893,7 +1899,8 @@ public class OperationSetPresenceSipImpl // we'll never be able to resolve this contact contact.setResolvable(false); - changePresenceStatusForContact(contact, SipStatusEnum.UNKNOWN); + changePresenceStatusForContact(contact, + sipStatusEnum.getStatus(SipStatusEnum.UNKNOWN)); this.subscribedContacts.remove(idheader.getCallId()); contact.setClientDialog(null); } @@ -2203,7 +2210,8 @@ public class OperationSetPresenceSipImpl } // we don't remove the contact - changePresenceStatusForContact(contact, SipStatusEnum.UNKNOWN); + changePresenceStatusForContact(contact, + sipStatusEnum.getStatus(SipStatusEnum.UNKNOWN)); contact.setResolved(false); } @@ -3727,7 +3735,7 @@ public class OperationSetPresenceSipImpl // the namespace used by servers and clients are often wrong so we just // ignore namespaces here - SipStatusEnum personStatus = null; + PresenceStatus personStatus = null; NodeList personList = presence.getElementsByTagNameNS(ANY_NS, PERSON_ELEMENT); @@ -3766,15 +3774,18 @@ public class OperationSetPresenceSipImpl { String statusname = statusNode.getLocalName(); if (statusname.equals(AWAY_ELEMENT)) { - personStatus = SipStatusEnum.AWAY; + personStatus = sipStatusEnum + .getStatus(SipStatusEnum.AWAY); break; } else if (statusname.equals(BUSY_ELEMENT)) { - personStatus = SipStatusEnum.BUSY; + personStatus = sipStatusEnum + .getStatus(SipStatusEnum.BUSY); break; } else if (statusname.equals(OTP_ELEMENT)) { - personStatus = SipStatusEnum.ON_THE_PHONE; + personStatus = sipStatusEnum + .getStatus(SipStatusEnum.ON_THE_PHONE); break; } } @@ -3916,8 +3927,10 @@ public class OperationSetPresenceSipImpl } // if we use RPID, simply ignore the standard PIDF status - if (personStatus != null) { - newPresenceStates = setStatusForContacts(personStatus, + if (personStatus != null) + { + newPresenceStates = setStatusForContacts( + personStatus, sipcontact, newPresenceStates); continue; @@ -3987,9 +4000,9 @@ public class OperationSetPresenceSipImpl String state = getTextContent(note); - Iterator states = SipStatusEnum.supportedStatusSet(); + Iterator states = sipStatusEnum.getSupportedStatusSet(); while (states.hasNext()) { - SipStatusEnum current = (SipStatusEnum) states.next(); + PresenceStatus current = (PresenceStatus) states.next(); if (current.getStatusName().equalsIgnoreCase(state)) { changed = true; @@ -4005,14 +4018,14 @@ public class OperationSetPresenceSipImpl if (getTextContent(basic).equalsIgnoreCase(ONLINE_STATUS)) { newPresenceStates = setStatusForContacts( - SipStatusEnum.ONLINE, + sipStatusEnum.getStatus(SipStatusEnum.ONLINE), sipcontact, newPresenceStates); } else if (getTextContent(basic).equalsIgnoreCase( OFFLINE_STATUS)) { newPresenceStates = setStatusForContacts( - SipStatusEnum.OFFLINE, + sipStatusEnum.getStatus(SipStatusEnum.OFFLINE), sipcontact, newPresenceStates); } @@ -4030,7 +4043,7 @@ public class OperationSetPresenceSipImpl while (iter.hasNext()) { Object tab[] = (Object[]) iter.next(); ContactSipImpl contact = (ContactSipImpl) tab[0]; - SipStatusEnum status = (SipStatusEnum) tab[2]; + PresenceStatus status = (PresenceStatus) tab[2]; changePresenceStatusForContact(contact, status); } @@ -4091,7 +4104,7 @@ public class OperationSetPresenceSipImpl * @return a Vector containing a list of <contact, priority, status> * ordered by priority (highest first). Null if a parameter is null. */ - private Vector setStatusForContacts(SipStatusEnum presenceState, + private Vector setStatusForContacts(PresenceStatus presenceState, Vector contacts, Vector curStatus) { // test parameters @@ -4133,7 +4146,7 @@ public class OperationSetPresenceSipImpl // same contact and same priority // consider the reachability of the status } else { - SipStatusEnum curPresence = (SipStatusEnum) tab2[2]; + PresenceStatus curPresence = (PresenceStatus) tab2[2]; if (curPresence.getStatus() >= presenceState.getStatus()) { @@ -4506,7 +4519,8 @@ public class OperationSetPresenceSipImpl // this will not be called by anyone else, so call it // the method will terminate every active subscription try { - publishPresenceStatus(SipStatusEnum.OFFLINE, ""); + publishPresenceStatus( + sipStatusEnum.getStatus(SipStatusEnum.OFFLINE), ""); } catch (OperationFailedException e) { logger.error("can't set the offline mode", e); } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolIconSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolIconSipImpl.java index aa15733..8c99d27 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolIconSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolIconSipImpl.java @@ -13,28 +13,40 @@ import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; /** - * Reperesents the Sip protocol icon. Implements the <tt>ProtocolIcon</tt> + * Represents the Sip protocol icon. Implements the <tt>ProtocolIcon</tt> * interface in order to provide an sip icon image in two different sizes. * * @author Yana Stamcheva */ public class ProtocolIconSipImpl implements ProtocolIcon -{ +{ private static Logger logger = Logger.getLogger(ProtocolIconSipImpl.class); - + + private String iconPath; + /** * A hash table containing the protocol icon in different sizes. */ - private static Hashtable iconsTable = new Hashtable(); - static { + private Hashtable iconsTable = new Hashtable(); + + /** + * Creates an instance of this class by passing to it the path, where all + * protocol icons are placed. + * + * @param iconPath the protocol icon path + */ + public ProtocolIconSipImpl(String iconPath) + { + this.iconPath = iconPath; + iconsTable.put(ProtocolIcon.ICON_SIZE_16x16, - loadIcon("resources/images/protocol/sip/sip16x16.png")); + loadIcon(iconPath + "/sip16x16.png")); iconsTable.put(ProtocolIcon.ICON_SIZE_64x64, - loadIcon("resources/images/protocol/sip/sip64x64.png")); + loadIcon(iconPath + "/sip64x64.png")); } - + /** * Implements the <tt>ProtocolIcon.getSupportedSizes()</tt> method. Returns * an iterator to a set containing the supported icon sizes. @@ -46,46 +58,61 @@ public class ProtocolIconSipImpl } /** - * Returne TRUE if a icon with the given size is supported, FALSE-otherwise. + * Returns <code>true</code> if an icon with the given size is supported, + * <code>false</code> - otherwise. + * + * @param iconSize the size of the icon to search for. One of ICON_SIZE_XXX + * constants. + * @return <code>true</code> if an icon with the given size is supported, + * <code>false</code> - otherwise. */ public boolean isSizeSupported(String iconSize) { return iconsTable.containsKey(iconSize); } - + /** * Returns the icon image in the given size. - * @param iconSize the icon size; one of ICON_SIZE_XXX constants + * + * @param iconSize the size of the icon we're looking for. One of + * ICON_SIZE_XXX constants. + * @return the byte array representing the icon. */ public byte[] getIcon(String iconSize) { return (byte[])iconsTable.get(iconSize); } - + /** * Returns the icon image used to represent the protocol connecting state. - * @return the icon image used to represent the protocol connecting state + * + * @return the icon image used to represent the protocol connecting state. */ public byte[] getConnectingIcon() { - return loadIcon("resources/images/protocol/sip/sip-connecting.gif"); + return loadIcon(iconPath + "/sip-connecting.gif"); } - + /** * Loads an image from a given image path. + * * @param imagePath The identifier of the image. * @return The image for the given identifier. */ - public static byte[] loadIcon(String imagePath) { + public static byte[] loadIcon(String imagePath) + { InputStream is = ProtocolIconSipImpl.class .getClassLoader().getResourceAsStream(imagePath); - + byte[] icon = null; - try { + try + { icon = new byte[is.available()]; is.read(icon); - } catch (IOException e) { - logger.error("Failed to load icon: " + imagePath, e); + } + catch (IOException e) + { + logger.error("Failed to load protocol icon: " + imagePath, e); } return icon; } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java index c602bb5..6d705cd 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java @@ -69,7 +69,7 @@ public class ProtocolProviderFactorySipImpl } /** - * Initializaed and creates an account corresponding to the specified + * Initializes and creates an account corresponding to the specified * accountProperties and registers the resulting ProtocolProvider in the * <tt>context</tt> BundleContext parameter. * @@ -107,6 +107,9 @@ public class ProtocolProviderFactorySipImpl if(serverAddress == null) throw new NullPointerException("null is not a valid ServerAddress"); + if (!accountProperties.containsKey(PROTOCOL)) + accountProperties.put(PROTOCOL, ProtocolNames.SIP); + AccountID accountID = new SipAccountID(userIDStr, accountProperties, serverAddress); @@ -115,7 +118,6 @@ public class ProtocolProviderFactorySipImpl throw new IllegalStateException( "An account for id " + userIDStr + " was already installed!"); - //first store the account and only then load it as the load generates //an osgi event, the osgi event triggers (trhgough the UI) a call to //the register() method and it needs to acces the configuration service @@ -166,13 +168,16 @@ public class ProtocolProviderFactorySipImpl if(accountProperties == null) throw new NullPointerException("The specified property map was null"); - String serverAddress = (String)accountProperties.get(SERVER_ADDRESS); + String serverAddress = (String) accountProperties.get(SERVER_ADDRESS); if(serverAddress == null) throw new NullPointerException( serverAddress + " is not a valid ServerAddress"); + if (!accountProperties.containsKey(PROTOCOL)) + accountProperties.put(PROTOCOL, ProtocolNames.SIP); + AccountID accountID = new SipAccountID(userIDStr, accountProperties, serverAddress); diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java index f298608..becdcd0 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java @@ -289,8 +289,9 @@ public class ProtocolProviderServiceSipImpl /** * The logo corresponding to the jabber protocol. */ - private ProtocolIconSipImpl sipIcon - = new ProtocolIconSipImpl(); + private ProtocolIconSipImpl protocolIcon; + + private SipStatusEnum sipStatusEnum; /** * Registers the specified listener with this provider so that it would @@ -387,6 +388,19 @@ public class ProtocolProviderServiceSipImpl } /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + return (String) accountID.getAccountProperties() + .get(ProtocolProviderFactory.PROTOCOL); + } + + /** * Register a new event taken in account by this provider. This is usefull * to generate the Allow-Events header of the OPTIONS responses and to * generate 489 responses. @@ -560,13 +574,23 @@ public class ProtocolProviderServiceSipImpl if (!NSPVALUE_DEBUG_LOG.startsWith(logDir)) { NSPVALUE_DEBUG_LOG = logDir + NSPVALUE_DEBUG_LOG; } - + if (!NSPVALUE_SERVER_LOG.startsWith(logDir)) { NSPVALUE_SERVER_LOG = logDir + NSPVALUE_SERVER_LOG; } - + this.accountID = accountID; + String protocolIconPath = (String) accountID.getAccountProperties() + .get(ProtocolProviderFactory.PROTOCOL_ICON_PATH); + + if (protocolIconPath == null) + protocolIconPath = "resources/images/protocol/sip"; + + this.protocolIcon = new ProtocolIconSipImpl(protocolIconPath); + + this.sipStatusEnum = new SipStatusEnum(protocolIconPath); + sipFactory = SipFactory.getInstance(); sipFactory.setPathName("gov.nist"); Properties properties = new Properties(); @@ -1827,7 +1851,7 @@ public class ProtocolProviderServiceSipImpl /** * Extracts all properties concerning the usage of an outbound proxy for * this account. - * @param accountID the acount whose ourbound proxy we are currently + * @param accountID the account whose outbound proxy we are currently * initializing. * @param jainSipProperties the properties that we will be passing to the * jain sip stack when initialize it (that's where we'll put all proxy @@ -2206,6 +2230,16 @@ public class ProtocolProviderServiceSipImpl */ public ProtocolIcon getProtocolIcon() { - return sipIcon; + return protocolIcon; + } + + /** + * Returns the current instance of <tt>SipStatusEnum</tt>. + * + * @return the current instance of <tt>SipStatusEnum</tt>. + */ + SipStatusEnum getSipStatusEnum() + { + return sipStatusEnum; } } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java b/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java index 245f428..eb080fb 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java @@ -33,7 +33,7 @@ public class SipAccountID ? userID.substring(0, userID.indexOf("@")) : userID , accountProperties - , ProtocolNames.SIP + , (String) accountProperties.get(ProtocolProviderFactory.PROTOCOL) , serverName); } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java b/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java index 3243f16..950e782 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipActivator.java @@ -52,14 +52,15 @@ public class SipActivator sipProviderFactory = new ProtocolProviderFactorySipImpl(); - //load all icq providers + //load all sip providers sipProviderFactory.loadStoredAccounts(); - //reg the icq account man. + //reg the sip account man. sipPpFactoryServReg = context.registerService( ProtocolProviderFactory.class.getName(), sipProviderFactory, hashtable); + logger.debug("SIP Protocol Provider Factory ... [REGISTERED]"); } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java b/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java index d7af25a..db5b549 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipStatusEnum.java @@ -6,20 +6,21 @@ */ package net.java.sip.communicator.impl.protocol.sip; +import java.io.*; import java.util.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; -import java.io.*; /** - * An implementation of <tt>PresenceStatus</tt> that enumerates all states that - * a SIP contact can currently have. - * + * The <tt>SipStatusEnum</tt> gives access to presence states for the Sip + * protocol. All status icons corresponding to presence states are located with + * the help of the <tt>imagePath</tt> parameter + * * @author Emil Ivov + * @author Yana Stamcheva */ public class SipStatusEnum - extends PresenceStatus { private static final Logger logger = Logger.getLogger(SipStatusEnum.class); @@ -27,94 +28,154 @@ public class SipStatusEnum /** * Indicates an Offline status or status with 0 connectivity. */ - public static final SipStatusEnum OFFLINE - = new SipStatusEnum( - 0 - , "Offline" - , loadIcon("resources/images/protocol/sip/sip16x16-offline.png")); + public static final String OFFLINE = "Offline"; + + /** + * The Online status. Indicate that the user is able and willing to + * communicate. + */ + public static final String ONLINE = "Online"; /** * The busy status. Indicates that the user has connectivity but is doing * something else. */ - public static final SipStatusEnum BUSY - = new SipStatusEnum( - 30, - "Busy (DND)", - loadIcon("resources/images/protocol/sip/sip16x16-busy.png")); - + public static final String BUSY = "Busy (DND)"; + /** * The On the phone status. Indicates that the user is talking to the phone. */ - public static final SipStatusEnum ON_THE_PHONE - = new SipStatusEnum( - 37, - "On the phone", - loadIcon("resources/images/protocol/sip/sip16x16-phone.png")); - + public static final String ON_THE_PHONE = "On the phone"; + /** * The Away status. Indicates that the user has connectivity but might * not be able to immediately act upon initiation of communication. */ - public static final SipStatusEnum AWAY - = new SipStatusEnum( - 40, - "Away", - loadIcon("resources/images/protocol/sip/sip16x16-away.png")); + public static final String AWAY = "Away"; + + /** + * The Unknown status. Indicate that we don't know if the user is present + * or not. + */ + public static final String UNKNOWN = "Unknown"; + + /** + * The path to the status icons. + */ + private String iconPath; + + /** + * Indicates an Offline status or status with 0 connectivity. + */ + private SipPresenceStatus offlineStatus; /** * The Online status. Indicate that the user is able and willing to * communicate. */ - public static final SipStatusEnum ONLINE - = new SipStatusEnum( - 65 - , "Online" - , loadIcon("resources/images/protocol/sip/sip16x16-online.png")); - + private SipPresenceStatus onlineStatus; + + /** + * The busy status. Indicates that the user has connectivity but is doing + * something else. + */ + private SipPresenceStatus busyStatus; + + /** + * The On the phone status. Indicates that the user is talking to the phone. + */ + private SipPresenceStatus onThePhoneStatus; + + /** + * The Away status. Indicates that the user has connectivity but might + * not be able to immediately act upon initiation of communication. + */ + private SipPresenceStatus awayStatus; + /** * The Unknown status. Indicate that we don't know if the user is present * or not. */ - public static final SipStatusEnum UNKNOWN = new SipStatusEnum( - 1, - "Unknown", - loadIcon("resources/images/protocol/sip/sip16x16-offline.png")); + private SipPresenceStatus unknownStatus; /** - * Initialize the list of supported status states. + * The supported status set stores all statuses supported by this protocol + * implementation. */ - public static List supportedStatusSet = new LinkedList(); - static + public List<SipPresenceStatus> supportedStatusSet + = new LinkedList<SipPresenceStatus>(); + + public SipStatusEnum(String iconPath) { - supportedStatusSet.add(ONLINE); - supportedStatusSet.add(AWAY); - supportedStatusSet.add(ON_THE_PHONE); - supportedStatusSet.add(BUSY); - supportedStatusSet.add(OFFLINE); + this.iconPath = iconPath; + + this.offlineStatus = new SipPresenceStatus( + 0, + OFFLINE, + loadIcon(iconPath + "/sip16x16-offline.png")); + + this.busyStatus = new SipPresenceStatus( + 30, + BUSY, + loadIcon(iconPath + "/sip16x16-busy.png")); + + this.onThePhoneStatus = new SipPresenceStatus( + 37, + ON_THE_PHONE, + loadIcon(iconPath + "/sip16x16-phone.png")); + + this.awayStatus = new SipPresenceStatus( + 40, + AWAY, + loadIcon(iconPath + "/sip16x16-away.png")); + + this.onlineStatus = new SipPresenceStatus( + 65, + ONLINE, + loadIcon(iconPath + "/sip16x16-online.png")); + + this.unknownStatus = new SipPresenceStatus( + 1, + UNKNOWN, + loadIcon(iconPath + "/sip16x16-offline.png")); + + // Initialize the list of supported status states. + supportedStatusSet.add(onlineStatus); + supportedStatusSet.add(awayStatus); + supportedStatusSet.add(onThePhoneStatus); + supportedStatusSet.add(busyStatus); + supportedStatusSet.add(offlineStatus); } /** - * Creates an instance of <tt>SipPresneceStatus</tt> with the - * specified parameters. - * @param status the connectivity level of the new presence status instance - * @param statusName the name of the presence status. - * @param statusIcon the icon associated with this status + * Returns the offline sip status. + * + * @param statusName the name of the status. + * @return the offline sip status. */ - private SipStatusEnum(int status, - String statusName, - byte[] statusIcon) + public SipPresenceStatus getStatus(String statusName) { - super(status, statusName, statusIcon); + if (statusName.equals(ONLINE)) + return onlineStatus; + else if (statusName.equals(OFFLINE)) + return offlineStatus; + else if (statusName.equals(BUSY)) + return busyStatus; + else if (statusName.equals(ON_THE_PHONE)) + return onThePhoneStatus; + else if (statusName.equals(AWAY)) + return awayStatus; + else + return unknownStatus; } /** - * Returns an iterator over all status instances supproted by the sip + * Returns an iterator over all status instances supported by the sip * provider. * @return an <tt>Iterator</tt> over all status instances supported by the * sip provider. */ - static Iterator supportedStatusSet() + public Iterator getSupportedStatusSet() { return supportedStatusSet.iterator(); } @@ -142,4 +203,26 @@ public class SipStatusEnum return icon; } -} + /** + * An implementation of <tt>PresenceStatus</tt> that enumerates all states + * that a SIP contact can currently have. + */ + private class SipPresenceStatus + extends PresenceStatus + { + /** + * Creates an instance of <tt>SipPresneceStatus</tt> with the + * specified parameters. + * @param status the connectivity level of the new presence status + * instance + * @param statusName the name of the presence status. + * @param statusIcon the icon associated with this status + */ + private SipPresenceStatus( int status, + String statusName, + byte[] statusIcon) + { + super(status, statusName, statusIcon); + } + } +}
\ No newline at end of file diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java index d4ee15a..d248ded 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java @@ -20,7 +20,6 @@ import javax.swing.*; import org.osgi.framework.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; -import net.java.sip.communicator.util.*; import net.java.sip.communicator.util.Logger; import net.java.sip.communicator.service.gui.*; @@ -625,7 +624,19 @@ public class ProtocolProviderServiceSSHImpl { return SSH_PROTOCOL_NAME; } - + + /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + return SSH_PROTOCOL_NAME; + } + /** * Returns the state of the registration of this protocol provider with * the corresponding registration service. diff --git a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java index b876ae8..94a3b84 100644 --- a/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/yahoo/ProtocolProviderServiceYahooImpl.java @@ -266,6 +266,18 @@ public class ProtocolProviderServiceYahooImpl } /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + return ProtocolNames.YAHOO; + } + + /** * Returns an array containing all operation sets supported by the * current implementation. * diff --git a/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderServiceZeroconfImpl.java b/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderServiceZeroconfImpl.java index e9c9a2e..99f3197 100644 --- a/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderServiceZeroconfImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/zeroconf/ProtocolProviderServiceZeroconfImpl.java @@ -262,7 +262,19 @@ public class ProtocolProviderServiceZeroconfImpl { return ProtocolNames.ZEROCONF; } - + + /** + * Returns the protocol display name. This is the name that would be used + * by the GUI to display the protocol name. + * + * @return a String containing the display name of the protocol this service + * is implementing + */ + public String getProtocolDisplayName() + { + return ProtocolNames.ZEROCONF; + } + /** * Returns the state of the registration of this protocol provider with * the corresponding registration service. diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccountRegistrationWizard.java index 64046c9..d092249 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccountRegistrationWizard.java +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/SIPAccountRegistrationWizard.java @@ -219,6 +219,12 @@ public class SIPAccountRegistrationWizard accountProperties.put(ProtocolProviderFactory.SUBSCRIPTION_EXPIRATION, registration.getSubscriptionExpiration()); + accountProperties.put(ProtocolProviderFactory.PROTOCOL, + "YOHOHOOHOHOH"); + + accountProperties.put(ProtocolProviderFactory.PROTOCOL_ICON_PATH, + "resources/images/protocol/sip/yohoho"); + if(isModification) { providerFactory.uninstallAccount(protocolProvider.getAccountID()); diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java index 2530b03..4befba8 100644 --- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java +++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java @@ -39,6 +39,11 @@ public abstract class ProtocolProviderFactory public static final String PROTOCOL = "PROTOCOL_NAME"; /** + * The name of a property representing the path to protocol icons. + */ + public static final String PROTOCOL_ICON_PATH = "PROTOCOL_ICON_PATH"; + + /** * The name of a property which represents the AccountID of a * ProtocolProvider and that, together with a password is used to login * on the protocol network.. |