aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin
diff options
context:
space:
mode:
authorWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-03-11 22:15:03 +0100
committerWolfgang Wiedmeyer <wolfgit@wiedmeyer.de>2017-03-11 22:15:03 +0100
commit85901329b0794b136b96bf745f4ab1572806fc89 (patch)
treef23da7e97cae727f39d825f0fef8348cffb238e4 /src/net/java/sip/communicator/plugin
parent3db2e44f186c59429901b2c899e139ea60117a55 (diff)
parentcf5da997da8820b4050f5b87ee9440a0ede36d1f (diff)
downloadjitsi-master.zip
jitsi-master.tar.gz
jitsi-master.tar.bz2
Merge commit 'cf5da99'HEADmaster
Signed-off-by: Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
Diffstat (limited to 'src/net/java/sip/communicator/plugin')
-rw-r--r--src/net/java/sip/communicator/plugin/accountinfo/AccountInfoActivator.java322
-rw-r--r--src/net/java/sip/communicator/plugin/accountinfo/AccountInfoPanel.java694
-rw-r--r--src/net/java/sip/communicator/plugin/accountinfo/Resources.java126
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java19
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/PtrCallback.java42
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java10
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/msoutlook/DefaultMailClientMessageDialog.java184
-rw-r--r--src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookMAPIHResultException.java216
-rw-r--r--src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf1
-rw-r--r--src/net/java/sip/communicator/plugin/branding/AboutWindow.java909
-rw-r--r--src/net/java/sip/communicator/plugin/branding/AboutWindowPluginComponent.java174
-rw-r--r--src/net/java/sip/communicator/plugin/branding/BrandingActivator.java138
-rw-r--r--src/net/java/sip/communicator/plugin/branding/Constants.java126
-rw-r--r--src/net/java/sip/communicator/plugin/branding/JitsiWarningWindow.java203
-rw-r--r--src/net/java/sip/communicator/plugin/branding/MacOSXAboutRegistration.java64
-rw-r--r--src/net/java/sip/communicator/plugin/branding/StyledHTMLEditorPane.java124
-rw-r--r--src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java443
-rw-r--r--src/net/java/sip/communicator/plugin/busylampfield/BLFActivator.java10
-rw-r--r--src/net/java/sip/communicator/plugin/certconfig/CertConfigEntryDialog.java1142
-rw-r--r--src/net/java/sip/communicator/plugin/certconfig/CertConfigPanel.java530
-rw-r--r--src/net/java/sip/communicator/plugin/certconfig/CertConfigTableModel.java194
-rw-r--r--src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java416
-rw-r--r--src/net/java/sip/communicator/plugin/contactinfo/ContactInfoContactPanel.java392
-rw-r--r--src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java1352
-rw-r--r--src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDialog.java172
-rw-r--r--src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java326
-rw-r--r--src/net/java/sip/communicator/plugin/contactinfo/Resources.java154
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/ColoredDefaultText.java80
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/SIPCommCheckBox.java86
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/SIPCommRadioButton.java86
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/X509CertificatePanel.java1032
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java346
-rw-r--r--src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java344
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccRegWizzActivator.java151
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistration.java104
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistrationWizard.java429
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/FirstWizardPage.java637
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/ProgressPanel.java156
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java75
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/StrategiesList.java240
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/ThreadManager.java199
-rw-r--r--src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf34
-rw-r--r--src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java2
-rw-r--r--src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccRegWizzActivator.java213
-rw-r--r--src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccountRegistrationWizard.java300
-rw-r--r--src/net/java/sip/communicator/plugin/facebookaccregwizz/facebookaccregwizz.manifest.mf34
-rw-r--r--src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java24
-rw-r--r--src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java178
-rw-r--r--src/net/java/sip/communicator/plugin/generalconfig/XMPPConfigForm.java101
-rw-r--r--src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java920
-rw-r--r--src/net/java/sip/communicator/plugin/generalconfig/autoaway/Preferences.java262
-rw-r--r--src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyPluginActivator.java10
-rw-r--r--src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccRegWizzActivator.java322
-rw-r--r--src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java504
-rw-r--r--src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccRegWizzActivator.java304
-rw-r--r--src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccountRegistrationWizard.java406
-rw-r--r--src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java3
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java11
-rw-r--r--src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountCreationForm.java2
-rw-r--r--src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingChooser.java44
-rw-r--r--src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutDialog.java974
-rw-r--r--src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java18
-rw-r--r--src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java1
-rw-r--r--src/net/java/sip/communicator/plugin/msofficecomm/OutOfProcessServer.java5
-rw-r--r--src/net/java/sip/communicator/plugin/msofficecomm/RegistryHandler.java262
-rw-r--r--src/net/java/sip/communicator/plugin/msofficecomm/msofficecomm.manifest.mf1
-rw-r--r--src/net/java/sip/communicator/plugin/otr/OtrConfigurator.java338
-rw-r--r--src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java2652
-rw-r--r--src/net/java/sip/communicator/plugin/otr/ScOtrKeyManager.java82
-rw-r--r--src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerImpl.java618
-rw-r--r--src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerListener.java26
-rw-r--r--src/net/java/sip/communicator/plugin/otr/ScSessionID.java162
-rw-r--r--src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberContactSource.java154
-rw-r--r--src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberSourceContact.java12
-rw-r--r--src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java4
-rw-r--r--src/net/java/sip/communicator/plugin/profiler4j/ProfilerActivator.java78
-rw-r--r--src/net/java/sip/communicator/plugin/profiler4j/Resources.java58
-rw-r--r--src/net/java/sip/communicator/plugin/profiler4j/SettingsWindowMenuEntry.java72
-rw-r--r--src/net/java/sip/communicator/plugin/profiler4j/profiler4j.manifest.mf24
-rw-r--r--src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java1468
-rw-r--r--src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java180
-rw-r--r--src/net/java/sip/communicator/plugin/sip2sipaccregwizz/CreateSip2SipAccountForm.java382
-rw-r--r--src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccRegWizzActivator.java136
-rw-r--r--src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccountRegistrationWizard.java269
-rw-r--r--src/net/java/sip/communicator/plugin/sip2sipaccregwizz/sip2sipaccregwizz.manifest.mf43
-rw-r--r--src/net/java/sip/communicator/plugin/skinmanager/BundleComparator.java4
-rw-r--r--src/net/java/sip/communicator/plugin/spellcheck/SpellCheckerConfigDialog.java842
-rw-r--r--src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java423
-rw-r--r--src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java74
-rw-r--r--src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccRegWizzActivator.java145
-rw-r--r--src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccountRegistration.java101
-rw-r--r--src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccountRegistrationWizard.java342
-rw-r--r--src/net/java/sip/communicator/plugin/sshaccregwizz/sshaccregwizz.manifest.mf32
-rw-r--r--src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdActivator.java336
-rw-r--r--src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdContactQuery.java530
-rw-r--r--src/net/java/sip/communicator/plugin/update/CheckForUpdatesMenuItemComponent.java150
-rw-r--r--src/net/java/sip/communicator/plugin/update/UpdateActivator.java608
-rw-r--r--src/net/java/sip/communicator/plugin/update/UpdateServiceImpl.java32
-rw-r--r--src/net/java/sip/communicator/plugin/yahooaccregwizz/FirstWizardPage.java299
-rw-r--r--src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java73
-rw-r--r--src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccRegWizzActivator.java160
-rw-r--r--src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistration.java83
-rw-r--r--src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java379
-rw-r--r--src/net/java/sip/communicator/plugin/yahooaccregwizz/yahooaccregwizz.manifest.mf33
-rw-r--r--src/net/java/sip/communicator/plugin/zeroconfaccregwizz/FirstWizardPage.java368
-rw-r--r--src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java74
-rw-r--r--src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccRegWizzActivator.java147
-rw-r--r--src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccountRegistration.java130
-rw-r--r--src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccountRegistrationWizard.java392
-rw-r--r--src/net/java/sip/communicator/plugin/zeroconfaccregwizz/zeroconfaccregwizz.manifest.mf32
110 files changed, 11072 insertions, 18858 deletions
diff --git a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoActivator.java b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoActivator.java
index f2181cd..06b595e 100644
--- a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoActivator.java
+++ b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoActivator.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,163 +15,163 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.accountinfo;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.globaldisplaydetails.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.configuration.*;
-import org.osgi.framework.*;
-
-/**
- * Starts the account info bundle.
- *
- * @author Adam Glodstein
- * @author Marin Dzhigarov
- */
-public class AccountInfoActivator
- implements BundleActivator
-{
- private static final Logger logger =
- Logger.getLogger(AccountInfoActivator.class);
-
- /**
- * Property to disable account info in tools menu.
- */
- private static final String ACCOUNT_INFO_TOOLS_MENU_DISABLED_PROP =
- "net.java.sip.communicator.plugin.accountinfo" +
- ".ACCOUNT_INFO_TOOLS_MENU_DISABLED_PROP";
-
- /**
- * Property to disable account info in account config.
- */
- private static final String ACCOUNT_INFO_ACC_CONFIG_DISABLED_PROP =
- "net.java.sip.communicator.plugin.accountinfo" +
- ".ACCOUNT_INFO_ACC_CONFIG_DISABLED_PROP";
-
- /**
- * The OSGi bundle context.
- */
- public static BundleContext bundleContext;
-
- private static GlobalDisplayDetailsService globalDisplayDetailsService;
-
- public void start(BundleContext bc) throws Exception
- {
- AccountInfoActivator.bundleContext = bc;
-
- ConfigurationService config = ServiceUtils.getService(
- bundleContext, ConfigurationService.class);
-
- if(!config.getBoolean(ACCOUNT_INFO_TOOLS_MENU_DISABLED_PROP, false))
- {
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
- containerFilter.put(
- Container.CONTAINER_ID,
- Container.CONTAINER_TOOLS_MENU.getID());
-
- bundleContext.registerService(
- PluginComponentFactory.class.getName(),
- new PluginComponentFactory(Container.CONTAINER_TOOLS_MENU)
- {
- @Override
- protected PluginComponent getPluginInstance()
- {
- return new AccountInfoMenuItemComponent(
- getContainer(), this);
- }
- },
- containerFilter);
- }
-
- if(!config.getBoolean(ACCOUNT_INFO_ACC_CONFIG_DISABLED_PROP, false))
- {
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
- containerFilter.put(
- Container.CONTAINER_ID,
- Container.CONTAINER_ACCOUNT_RIGHT_BUTTON_MENU.getID());
-
- bundleContext.registerService(
- PluginComponentFactory.class.getName(),
- new PluginComponentFactory(
- Container.CONTAINER_ACCOUNT_RIGHT_BUTTON_MENU)
- {
- @Override
- protected PluginComponent getPluginInstance()
- {
- return new AccountInfoMenuItemComponent(
- getContainer(), this);
- }
- },
- containerFilter);
- }
- }
-
- public void stop(BundleContext bc) throws Exception {}
-
- /**
- * Returns all <tt>ProtocolProviderFactory</tt>s obtained from the bundle
- * context.
- *
- * @return all <tt>ProtocolProviderFactory</tt>s obtained from the bundle
- * context
- */
- public static Map<Object, ProtocolProviderFactory>
- getProtocolProviderFactories()
- {
- Map<Object, ProtocolProviderFactory> providerFactoriesMap =
- new Hashtable<Object, ProtocolProviderFactory>();
-
- ServiceReference[] serRefs = null;
- try
- {
- // get all registered provider factories
- serRefs =
- bundleContext.getServiceReferences(
- ProtocolProviderFactory.class.getName(), null);
-
- }
- catch (InvalidSyntaxException e)
- {
- logger.error("LoginManager : " + e);
- }
-
- for (int i = 0; i < serRefs.length; i++)
- {
-
- ProtocolProviderFactory providerFactory =
- (ProtocolProviderFactory) bundleContext.getService(serRefs[i]);
-
- providerFactoriesMap
- .put(serRefs[i].getProperty(ProtocolProviderFactory.PROTOCOL),
- providerFactory);
- }
-
- return providerFactoriesMap;
- }
-
- /**
- * Returns the <tt>GlobalDisplayDetailsService</tt> obtained from the bundle
- * context.
- *
- * @return the <tt>GlobalDisplayDetailsService</tt> obtained from the bundle
- * context
- */
- public static GlobalDisplayDetailsService getGlobalDisplayDetailsService()
- {
- if (globalDisplayDetailsService == null)
- {
- globalDisplayDetailsService
- = ServiceUtils.getService(
- bundleContext,
- GlobalDisplayDetailsService.class);
- }
- return globalDisplayDetailsService;
- }
-}
+package net.java.sip.communicator.plugin.accountinfo;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.globaldisplaydetails.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+import org.jitsi.service.configuration.*;
+import org.osgi.framework.*;
+
+/**
+ * Starts the account info bundle.
+ *
+ * @author Adam Glodstein
+ * @author Marin Dzhigarov
+ */
+public class AccountInfoActivator
+ implements BundleActivator
+{
+ private static final Logger logger =
+ Logger.getLogger(AccountInfoActivator.class);
+
+ /**
+ * Property to disable account info in tools menu.
+ */
+ private static final String ACCOUNT_INFO_TOOLS_MENU_DISABLED_PROP =
+ "net.java.sip.communicator.plugin.accountinfo" +
+ ".ACCOUNT_INFO_TOOLS_MENU_DISABLED_PROP";
+
+ /**
+ * Property to disable account info in account config.
+ */
+ private static final String ACCOUNT_INFO_ACC_CONFIG_DISABLED_PROP =
+ "net.java.sip.communicator.plugin.accountinfo" +
+ ".ACCOUNT_INFO_ACC_CONFIG_DISABLED_PROP";
+
+ /**
+ * The OSGi bundle context.
+ */
+ public static BundleContext bundleContext;
+
+ private static GlobalDisplayDetailsService globalDisplayDetailsService;
+
+ public void start(BundleContext bc) throws Exception
+ {
+ AccountInfoActivator.bundleContext = bc;
+
+ ConfigurationService config = ServiceUtils.getService(
+ bundleContext, ConfigurationService.class);
+
+ if(!config.getBoolean(ACCOUNT_INFO_TOOLS_MENU_DISABLED_PROP, false))
+ {
+ Hashtable<String, String> containerFilter
+ = new Hashtable<String, String>();
+ containerFilter.put(
+ Container.CONTAINER_ID,
+ Container.CONTAINER_TOOLS_MENU.getID());
+
+ bundleContext.registerService(
+ PluginComponentFactory.class.getName(),
+ new PluginComponentFactory(Container.CONTAINER_TOOLS_MENU)
+ {
+ @Override
+ protected PluginComponent getPluginInstance()
+ {
+ return new AccountInfoMenuItemComponent(
+ getContainer(), this);
+ }
+ },
+ containerFilter);
+ }
+
+ if(!config.getBoolean(ACCOUNT_INFO_ACC_CONFIG_DISABLED_PROP, false))
+ {
+ Hashtable<String, String> containerFilter
+ = new Hashtable<String, String>();
+ containerFilter.put(
+ Container.CONTAINER_ID,
+ Container.CONTAINER_ACCOUNT_RIGHT_BUTTON_MENU.getID());
+
+ bundleContext.registerService(
+ PluginComponentFactory.class.getName(),
+ new PluginComponentFactory(
+ Container.CONTAINER_ACCOUNT_RIGHT_BUTTON_MENU)
+ {
+ @Override
+ protected PluginComponent getPluginInstance()
+ {
+ return new AccountInfoMenuItemComponent(
+ getContainer(), this);
+ }
+ },
+ containerFilter);
+ }
+ }
+
+ public void stop(BundleContext bc) throws Exception {}
+
+ /**
+ * Returns all <tt>ProtocolProviderFactory</tt>s obtained from the bundle
+ * context.
+ *
+ * @return all <tt>ProtocolProviderFactory</tt>s obtained from the bundle
+ * context
+ */
+ public static Map<Object, ProtocolProviderFactory>
+ getProtocolProviderFactories()
+ {
+ Map<Object, ProtocolProviderFactory> providerFactoriesMap =
+ new Hashtable<Object, ProtocolProviderFactory>();
+
+ ServiceReference[] serRefs = null;
+ try
+ {
+ // get all registered provider factories
+ serRefs =
+ bundleContext.getServiceReferences(
+ ProtocolProviderFactory.class.getName(), null);
+
+ }
+ catch (InvalidSyntaxException e)
+ {
+ logger.error("LoginManager : " + e);
+ }
+
+ for (int i = 0; i < serRefs.length; i++)
+ {
+
+ ProtocolProviderFactory providerFactory =
+ (ProtocolProviderFactory) bundleContext.getService(serRefs[i]);
+
+ providerFactoriesMap
+ .put(serRefs[i].getProperty(ProtocolProviderFactory.PROTOCOL),
+ providerFactory);
+ }
+
+ return providerFactoriesMap;
+ }
+
+ /**
+ * Returns the <tt>GlobalDisplayDetailsService</tt> obtained from the bundle
+ * context.
+ *
+ * @return the <tt>GlobalDisplayDetailsService</tt> obtained from the bundle
+ * context
+ */
+ public static GlobalDisplayDetailsService getGlobalDisplayDetailsService()
+ {
+ if (globalDisplayDetailsService == null)
+ {
+ globalDisplayDetailsService
+ = ServiceUtils.getService(
+ bundleContext,
+ GlobalDisplayDetailsService.class);
+ }
+ return globalDisplayDetailsService;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoPanel.java b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoPanel.java
index 075aa33..92f0b9a 100644
--- a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoPanel.java
+++ b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoPanel.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,349 +15,349 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.accountinfo;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.util.*;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.plugin.accountinfo.AccountInfoMenuItemComponent.*;
-
-import org.osgi.framework.*;
-
-/**
- * A GUI plug-in for Jitsi that will allow users to set cross
- * protocol account information.
- *
- * @author Adam Goldstein
- * @author Marin Dzhigarov
- */
-public class AccountInfoPanel
- extends TransparentPanel
- implements ServiceListener,
- RegistrationStateChangeListener
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * The panel that contains the currently active <tt>AccountDetailsPanel</tt>
- */
- private final JPanel centerPanel =
- new TransparentPanel(new BorderLayout(10, 10));
-
- /**
- * The currently active <tt>AccountDetailsPanel</tt>
- */
- private AccountDetailsPanel currentDetailsPanel;
-
- /**
- * Combo box that is used for switching between accounts.
- */
- private final JComboBox accountsComboBox;
-
- /**
- * Instances of the <tt>AccountDetailsPanel</tt> are created for every
- * registered <tt>AccountID</tt>. All such pairs are stored in
- * this map.
- */
- private final Map<AccountID, AccountDetailsPanel>
- accountsTable =
- new HashMap<AccountID, AccountDetailsPanel>();
-
- /**
- * The parent dialog.
- */
- private AccountInfoDialog dialog;
-
- /**
- * Creates an instance of <tt>AccountInfoPanel</tt> that contains combo box
- * component with active user accounts and <tt>AccountDetailsPanel</tt> to
- * display and edit account information.
- */
- public AccountInfoPanel(AccountInfoDialog dialog)
- {
- this.dialog = dialog;
-
- setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
-
- accountsComboBox = new JComboBox();
- accountsComboBox.setOpaque(false);
- accountsComboBox.addItemListener(new ItemListener()
- {
- @Override
- public void itemStateChanged(ItemEvent e)
- {
- if (e.getStateChange() == ItemEvent.SELECTED)
- {
- AccountDetailsPanel panel =
- (AccountDetailsPanel) e.getItem();
- panel.setOpaque(false);
- centerPanel.removeAll();
- centerPanel.add(panel, BorderLayout.CENTER);
- centerPanel.revalidate();
- centerPanel.repaint();
- currentDetailsPanel = panel;
- }
- }
- });
-
- init();
-
- centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- ComboBoxRenderer renderer = new ComboBoxRenderer();
- accountsComboBox.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
- accountsComboBox.setRenderer(renderer);
-
- JLabel comboLabel = new JLabel(
- Resources.getString(
- "plugin.accountinfo.SELECT_ACCOUNT"));
- comboLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
-
- JPanel comboBoxPanel = new TransparentPanel();
- comboBoxPanel.setLayout(new BoxLayout(comboBoxPanel, BoxLayout.X_AXIS));
- comboBoxPanel.setBorder(
- BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- comboBoxPanel.add(comboLabel);
- comboBoxPanel.add(accountsComboBox);
-
- add(comboBoxPanel);
- add(centerPanel);
- }
-
- /**
- * Initialize.
- */
- private void init()
- {
- AccountInfoActivator.bundleContext.addServiceListener(this);
-
- for (ProtocolProviderFactory providerFactory : AccountInfoActivator
- .getProtocolProviderFactories().values())
- {
- ArrayList<AccountID> accountsList =
- providerFactory.getRegisteredAccounts();
-
- ServiceReference serRef;
- ProtocolProviderService protocolProvider;
-
- for (AccountID accountID : accountsList)
- {
- serRef = providerFactory.getProviderForAccount(accountID);
-
- protocolProvider = (ProtocolProviderService)AccountInfoActivator
- .bundleContext.getService(serRef);
-
- currentDetailsPanel = new AccountDetailsPanel(
- dialog,
- protocolProvider);
-
- accountsTable.put(
- protocolProvider.getAccountID(), currentDetailsPanel);
-
- accountsComboBox.addItem(currentDetailsPanel);
-
- protocolProvider.addRegistrationStateChangeListener(this);
- }
- }
- }
-
- /**
- * Clears all listeners.
- */
- public void dispose()
- {
- AccountInfoActivator.bundleContext.removeServiceListener(this);
-
- for(AccountDetailsPanel pan : accountsTable.values())
- {
- pan.getProtocolProvider()
- .removeRegistrationStateChangeListener(this);
- }
- }
-
- /**
- * A custom renderer to display properly <tt>AccountDetailsPanel</tt>
- * in a combo box.
- */
- private class ComboBoxRenderer extends DefaultListCellRenderer
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- @Override
- public Component getListCellRendererComponent(
- JList list, Object value, int index,
- boolean isSelected, boolean hasFocus)
- {
- JLabel renderer
- = (JLabel) super.getListCellRendererComponent(
- list, value, index, isSelected, hasFocus);
-
- if (value != null)
- {
- AccountDetailsPanel panel = (AccountDetailsPanel) value;
-
- renderer.setText(
- panel.protocolProvider.getAccountID().getUserID());
- ImageIcon protocolIcon =
- new ImageIcon(panel.protocolProvider.getProtocolIcon().
- getIcon((ProtocolIcon.ICON_SIZE_16x16)));
- renderer.setIcon(protocolIcon);
- }
-
- return renderer;
- }
- }
-
- public void registrationStateChanged(final RegistrationStateChangeEvent evt)
- {
- if(!SwingUtilities.isEventDispatchThread())
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- registrationStateChanged(evt);
- }
- });
- return;
- }
-
- ProtocolProviderService protocolProvider = evt.getProvider();
-
- if (evt.getNewState() == RegistrationState.REGISTERED)
- {
- if (accountsTable.containsKey(protocolProvider.getAccountID()))
- {
- AccountDetailsPanel detailsPanel
- = accountsTable.get(protocolProvider.getAccountID());
- detailsPanel.loadDetails();
- }
- else
- {
- AccountDetailsPanel panel =
- new AccountDetailsPanel(dialog, protocolProvider);
- accountsTable.put(protocolProvider.getAccountID(), panel);
- accountsComboBox.addItem(panel);
- }
- }
- else if (evt.getNewState() == RegistrationState.UNREGISTERING)
- {
- AccountDetailsPanel panel
- = accountsTable.get(protocolProvider.getAccountID());
- if (panel != null)
- {
- accountsTable.remove(protocolProvider.getAccountID());
- accountsComboBox.removeItem(panel);
- if (currentDetailsPanel == panel)
- {
- currentDetailsPanel = null;
- centerPanel.removeAll();
- centerPanel.revalidate();
- centerPanel.repaint();
- }
- }
- }
- }
-
- /**
- * Handles registration and unregistration of
- * <tt>ProtocolProviderService</tt>
- *
- * @param event
- */
- @Override
- public void serviceChanged(final ServiceEvent event)
- {
- if(!SwingUtilities.isEventDispatchThread())
- {
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- serviceChanged(event);
- }
- });
- return;
- }
-
- // Get the service from the event.
- Object service
- = AccountInfoActivator.bundleContext.getService(
- event.getServiceReference());
-
- // We are not interested in any services
- // other than ProtocolProviderService
- if (!(service instanceof ProtocolProviderService))
- return;
-
- ProtocolProviderService protocolProvider =
- (ProtocolProviderService) service;
-
- // If a new protocol provider is registered we to add new
- // AccountDetailsPanel to the combo box containing active accounts.
- if (event.getType() == ServiceEvent.REGISTERED)
- {
- if (accountsTable.get(protocolProvider.getAccountID()) == null)
- {
- AccountDetailsPanel panel =
- new AccountDetailsPanel(dialog, protocolProvider);
- accountsTable.put(protocolProvider.getAccountID(), panel);
- accountsComboBox.addItem(panel);
- protocolProvider.addRegistrationStateChangeListener(this);
- }
- }
- // If the protocol provider is being unregistered we have to remove
- // a AccountDetailsPanel from the combo box containing active accounts.
- else if (event.getType() == ServiceEvent.UNREGISTERING)
- {
- AccountDetailsPanel panel
- = accountsTable.get(protocolProvider.getAccountID());
- if (panel != null)
- {
- accountsTable.remove(protocolProvider.getAccountID());
- accountsComboBox.removeItem(panel);
- if (currentDetailsPanel == panel)
- {
- currentDetailsPanel = null;
- centerPanel.removeAll();
- centerPanel.revalidate();
- centerPanel.repaint();
- }
- }
- }
- }
-
- /**
- * Returns the combo box that switches between account detail panels.
- *
- * @return The combo box that switches between account detail panels.
- */
- public JComboBox getAccountsComboBox()
- {
- return accountsComboBox;
- }
-
- /**
- * Returns mapping between registered AccountIDs and their respective
- * AccountDetailsPanel that contains all the details for the account.
- *
- * @return mapping between registered AccountIDs and AccountDetailsPanel.
- */
- public Map<AccountID, AccountDetailsPanel> getAccountsTable()
- {
- return accountsTable;
- }
-}
+package net.java.sip.communicator.plugin.accountinfo;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.event.*;
+import net.java.sip.communicator.plugin.accountinfo.AccountInfoMenuItemComponent.*;
+
+import org.osgi.framework.*;
+
+/**
+ * A GUI plug-in for Jitsi that will allow users to set cross
+ * protocol account information.
+ *
+ * @author Adam Goldstein
+ * @author Marin Dzhigarov
+ */
+public class AccountInfoPanel
+ extends TransparentPanel
+ implements ServiceListener,
+ RegistrationStateChangeListener
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * The panel that contains the currently active <tt>AccountDetailsPanel</tt>
+ */
+ private final JPanel centerPanel =
+ new TransparentPanel(new BorderLayout(10, 10));
+
+ /**
+ * The currently active <tt>AccountDetailsPanel</tt>
+ */
+ private AccountDetailsPanel currentDetailsPanel;
+
+ /**
+ * Combo box that is used for switching between accounts.
+ */
+ private final JComboBox accountsComboBox;
+
+ /**
+ * Instances of the <tt>AccountDetailsPanel</tt> are created for every
+ * registered <tt>AccountID</tt>. All such pairs are stored in
+ * this map.
+ */
+ private final Map<AccountID, AccountDetailsPanel>
+ accountsTable =
+ new HashMap<AccountID, AccountDetailsPanel>();
+
+ /**
+ * The parent dialog.
+ */
+ private AccountInfoDialog dialog;
+
+ /**
+ * Creates an instance of <tt>AccountInfoPanel</tt> that contains combo box
+ * component with active user accounts and <tt>AccountDetailsPanel</tt> to
+ * display and edit account information.
+ */
+ public AccountInfoPanel(AccountInfoDialog dialog)
+ {
+ this.dialog = dialog;
+
+ setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+
+ accountsComboBox = new JComboBox();
+ accountsComboBox.setOpaque(false);
+ accountsComboBox.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent e)
+ {
+ if (e.getStateChange() == ItemEvent.SELECTED)
+ {
+ AccountDetailsPanel panel =
+ (AccountDetailsPanel) e.getItem();
+ panel.setOpaque(false);
+ centerPanel.removeAll();
+ centerPanel.add(panel, BorderLayout.CENTER);
+ centerPanel.revalidate();
+ centerPanel.repaint();
+ currentDetailsPanel = panel;
+ }
+ }
+ });
+
+ init();
+
+ centerPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ ComboBoxRenderer renderer = new ComboBoxRenderer();
+ accountsComboBox.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
+ accountsComboBox.setRenderer(renderer);
+
+ JLabel comboLabel = new JLabel(
+ Resources.getString(
+ "plugin.accountinfo.SELECT_ACCOUNT"));
+ comboLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
+
+ JPanel comboBoxPanel = new TransparentPanel();
+ comboBoxPanel.setLayout(new BoxLayout(comboBoxPanel, BoxLayout.X_AXIS));
+ comboBoxPanel.setBorder(
+ BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ comboBoxPanel.add(comboLabel);
+ comboBoxPanel.add(accountsComboBox);
+
+ add(comboBoxPanel);
+ add(centerPanel);
+ }
+
+ /**
+ * Initialize.
+ */
+ private void init()
+ {
+ AccountInfoActivator.bundleContext.addServiceListener(this);
+
+ for (ProtocolProviderFactory providerFactory : AccountInfoActivator
+ .getProtocolProviderFactories().values())
+ {
+ ArrayList<AccountID> accountsList =
+ providerFactory.getRegisteredAccounts();
+
+ ServiceReference serRef;
+ ProtocolProviderService protocolProvider;
+
+ for (AccountID accountID : accountsList)
+ {
+ serRef = providerFactory.getProviderForAccount(accountID);
+
+ protocolProvider = (ProtocolProviderService)AccountInfoActivator
+ .bundleContext.getService(serRef);
+
+ currentDetailsPanel = new AccountDetailsPanel(
+ dialog,
+ protocolProvider);
+
+ accountsTable.put(
+ protocolProvider.getAccountID(), currentDetailsPanel);
+
+ accountsComboBox.addItem(currentDetailsPanel);
+
+ protocolProvider.addRegistrationStateChangeListener(this);
+ }
+ }
+ }
+
+ /**
+ * Clears all listeners.
+ */
+ public void dispose()
+ {
+ AccountInfoActivator.bundleContext.removeServiceListener(this);
+
+ for(AccountDetailsPanel pan : accountsTable.values())
+ {
+ pan.getProtocolProvider()
+ .removeRegistrationStateChangeListener(this);
+ }
+ }
+
+ /**
+ * A custom renderer to display properly <tt>AccountDetailsPanel</tt>
+ * in a combo box.
+ */
+ private class ComboBoxRenderer extends DefaultListCellRenderer
+ {
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ @Override
+ public Component getListCellRendererComponent(
+ JList list, Object value, int index,
+ boolean isSelected, boolean hasFocus)
+ {
+ JLabel renderer
+ = (JLabel) super.getListCellRendererComponent(
+ list, value, index, isSelected, hasFocus);
+
+ if (value != null)
+ {
+ AccountDetailsPanel panel = (AccountDetailsPanel) value;
+
+ renderer.setText(
+ panel.protocolProvider.getAccountID().getUserID());
+ ImageIcon protocolIcon =
+ new ImageIcon(panel.protocolProvider.getProtocolIcon().
+ getIcon((ProtocolIcon.ICON_SIZE_16x16)));
+ renderer.setIcon(protocolIcon);
+ }
+
+ return renderer;
+ }
+ }
+
+ public void registrationStateChanged(final RegistrationStateChangeEvent evt)
+ {
+ if(!SwingUtilities.isEventDispatchThread())
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ registrationStateChanged(evt);
+ }
+ });
+ return;
+ }
+
+ ProtocolProviderService protocolProvider = evt.getProvider();
+
+ if (evt.getNewState() == RegistrationState.REGISTERED)
+ {
+ if (accountsTable.containsKey(protocolProvider.getAccountID()))
+ {
+ AccountDetailsPanel detailsPanel
+ = accountsTable.get(protocolProvider.getAccountID());
+ detailsPanel.loadDetails();
+ }
+ else
+ {
+ AccountDetailsPanel panel =
+ new AccountDetailsPanel(dialog, protocolProvider);
+ accountsTable.put(protocolProvider.getAccountID(), panel);
+ accountsComboBox.addItem(panel);
+ }
+ }
+ else if (evt.getNewState() == RegistrationState.UNREGISTERING)
+ {
+ AccountDetailsPanel panel
+ = accountsTable.get(protocolProvider.getAccountID());
+ if (panel != null)
+ {
+ accountsTable.remove(protocolProvider.getAccountID());
+ accountsComboBox.removeItem(panel);
+ if (currentDetailsPanel == panel)
+ {
+ currentDetailsPanel = null;
+ centerPanel.removeAll();
+ centerPanel.revalidate();
+ centerPanel.repaint();
+ }
+ }
+ }
+ }
+
+ /**
+ * Handles registration and unregistration of
+ * <tt>ProtocolProviderService</tt>
+ *
+ * @param event
+ */
+ @Override
+ public void serviceChanged(final ServiceEvent event)
+ {
+ if(!SwingUtilities.isEventDispatchThread())
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ serviceChanged(event);
+ }
+ });
+ return;
+ }
+
+ // Get the service from the event.
+ Object service
+ = AccountInfoActivator.bundleContext.getService(
+ event.getServiceReference());
+
+ // We are not interested in any services
+ // other than ProtocolProviderService
+ if (!(service instanceof ProtocolProviderService))
+ return;
+
+ ProtocolProviderService protocolProvider =
+ (ProtocolProviderService) service;
+
+ // If a new protocol provider is registered we to add new
+ // AccountDetailsPanel to the combo box containing active accounts.
+ if (event.getType() == ServiceEvent.REGISTERED)
+ {
+ if (accountsTable.get(protocolProvider.getAccountID()) == null)
+ {
+ AccountDetailsPanel panel =
+ new AccountDetailsPanel(dialog, protocolProvider);
+ accountsTable.put(protocolProvider.getAccountID(), panel);
+ accountsComboBox.addItem(panel);
+ protocolProvider.addRegistrationStateChangeListener(this);
+ }
+ }
+ // If the protocol provider is being unregistered we have to remove
+ // a AccountDetailsPanel from the combo box containing active accounts.
+ else if (event.getType() == ServiceEvent.UNREGISTERING)
+ {
+ AccountDetailsPanel panel
+ = accountsTable.get(protocolProvider.getAccountID());
+ if (panel != null)
+ {
+ accountsTable.remove(protocolProvider.getAccountID());
+ accountsComboBox.removeItem(panel);
+ if (currentDetailsPanel == panel)
+ {
+ currentDetailsPanel = null;
+ centerPanel.removeAll();
+ centerPanel.revalidate();
+ centerPanel.repaint();
+ }
+ }
+ }
+ }
+
+ /**
+ * Returns the combo box that switches between account detail panels.
+ *
+ * @return The combo box that switches between account detail panels.
+ */
+ public JComboBox getAccountsComboBox()
+ {
+ return accountsComboBox;
+ }
+
+ /**
+ * Returns mapping between registered AccountIDs and their respective
+ * AccountDetailsPanel that contains all the details for the account.
+ *
+ * @return mapping between registered AccountIDs and AccountDetailsPanel.
+ */
+ public Map<AccountID, AccountDetailsPanel> getAccountsTable()
+ {
+ return accountsTable;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/accountinfo/Resources.java b/src/net/java/sip/communicator/plugin/accountinfo/Resources.java
index 4557782..7c5987a 100644
--- a/src/net/java/sip/communicator/plugin/accountinfo/Resources.java
+++ b/src/net/java/sip/communicator/plugin/accountinfo/Resources.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,65 +15,65 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.accountinfo;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.service.resources.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The <tt>Resources</tt> class manages the access to the internationalization
- * properties files and the image resources used in this plugin.
- *
- * @author Yana Stamcheva
- */
-public class Resources
-{
- private static ResourceManagementService resourcesService;
-
- /**
- * 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)
- {
- return getResources().getI18NString(key);
- }
-
- /**
- * Loads an image from a given image identifier.
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static ImageIcon getImage(String imageID)
- {
- return getResources().getImage(imageID);
- }
-
- /**
- * Loads an image from a given image identifier.
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static byte[] getImageInBytes(String imageID)
- {
- return getResources().getImageInBytes(imageID);
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(AccountInfoActivator.bundleContext);
- return resourcesService;
- }
-}
+package net.java.sip.communicator.plugin.accountinfo;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.service.resources.*;
+
+import org.jitsi.service.resources.*;
+
+/**
+ * The <tt>Resources</tt> class manages the access to the internationalization
+ * properties files and the image resources used in this plugin.
+ *
+ * @author Yana Stamcheva
+ */
+public class Resources
+{
+ private static ResourceManagementService resourcesService;
+
+ /**
+ * 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)
+ {
+ return getResources().getI18NString(key);
+ }
+
+ /**
+ * Loads an image from a given image identifier.
+ * @param imageID The identifier of the image.
+ * @return The image for the given identifier.
+ */
+ public static ImageIcon getImage(String imageID)
+ {
+ return getResources().getImage(imageID);
+ }
+
+ /**
+ * Loads an image from a given image identifier.
+ * @param imageID The identifier of the image.
+ * @return The image for the given identifier.
+ */
+ public static byte[] getImageInBytes(String imageID)
+ {
+ return getResources().getImageInBytes(imageID);
+ }
+
+ /**
+ * Returns the <tt>ResourceManagementService</tt>.
+ *
+ * @return the <tt>ResourceManagementService</tt>.
+ */
+ public static ResourceManagementService getResources()
+ {
+ if (resourcesService == null)
+ resourcesService =
+ ResourceManagementServiceUtils
+ .getService(AccountInfoActivator.bundleContext);
+ return resourcesService;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java b/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java
index 402f549..85ccd76 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/AdvancedConfigForm.java
@@ -25,6 +25,7 @@ import javax.swing.*;
import net.java.sip.communicator.plugin.addrbook.macosx.*;
import net.java.sip.communicator.plugin.addrbook.msoutlook.*;
import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.calendar.CalendarService;
import org.jitsi.util.*;
@@ -67,13 +68,16 @@ public class AdvancedConfigForm
if (OSUtils.IS_MAC)
propertiesPanel.add(createEnableCheckBox(
AddrBookActivator.PNAME_ENABLE_MACOSX_ADDRESS_BOOK_SEARCH,
- "plugin.addrbook.ENABLE_MACOSX_ADDRESSBOOK"));
+ "plugin.addrbook.ENABLE_MACOSX_ADDRESSBOOK", true));
if (OSUtils.IS_WINDOWS)
{
propertiesPanel.add(createEnableCheckBox(
AddrBookActivator.PNAME_ENABLE_MICROSOFT_OUTLOOK_SEARCH,
- "plugin.addrbook.ENABLE_MICROSOFT_OUTLOOK"));
+ "plugin.addrbook.ENABLE_MICROSOFT_OUTLOOK", true));
+ propertiesPanel.add(createEnableCheckBox(
+ CalendarService.PNAME_FREE_BUSY_STATUS_DISABLED,
+ "plugin.addrbook.ENABLE_OUTLOOK_CALENDAR", false));
if(AddrBookActivator.getConfigService().getBoolean(
AddrBookActivator.PNAME_ENABLE_DEFAULT_IM_APPLICATION_CHANGE,
true))
@@ -95,13 +99,14 @@ public class AdvancedConfigForm
* @return the created enable check box
*/
private Component createEnableCheckBox(final String configPropName,
- String labelNameKey)
+ String labelNameKey,
+ boolean defaultValue)
{
final JCheckBox checkBox = new SIPCommCheckBox(AddrBookActivator
.getResources().getI18NString(
labelNameKey),
AddrBookActivator.getConfigService().getBoolean(configPropName,
- true));
+ defaultValue));
checkBox.setAlignmentX(Component.LEFT_ALIGNMENT);
checkBox.addActionListener(new ActionListener()
@@ -113,9 +118,15 @@ public class AdvancedConfigForm
new Boolean(checkBox.isSelected()).toString());
if (checkBox.isSelected())
+ {
AddrBookActivator.startService();
+ AddrBookActivator.startCalendarService();
+ }
else
+ {
AddrBookActivator.stopService();
+ AddrBookActivator.stopCalendarService();
+ }
}
});
return checkBox;
diff --git a/src/net/java/sip/communicator/plugin/addrbook/PtrCallback.java b/src/net/java/sip/communicator/plugin/addrbook/PtrCallback.java
index a06c778..674f261 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/PtrCallback.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/PtrCallback.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,23 +15,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.addrbook;
-
-/**
- * Defines the interface for a callback function which is called by the native
- * counterpart of the support for the OS-specific Address Book with a pointer as
- * its argument.
- *
- * @author Lyubomir Marinov
- */
-public interface PtrCallback
-{
- /**
- * Notifies this <tt>PtrCallback</tt> about a specific pointer.
- *
- * @param ptr the pointer to notify this <tt>PtrCallback</tt> about
- * @return <tt>true</tt> if this <tt>PtrCallback</tt> is to continue being
- * called; otherwise, <tt>false</tt>
- */
- boolean callback(long ptr);
-}
+package net.java.sip.communicator.plugin.addrbook;
+
+/**
+ * Defines the interface for a callback function which is called by the native
+ * counterpart of the support for the OS-specific Address Book with a pointer as
+ * its argument.
+ *
+ * @author Lyubomir Marinov
+ */
+public interface PtrCallback
+{
+ /**
+ * Notifies this <tt>PtrCallback</tt> about a specific pointer.
+ *
+ * @param ptr the pointer to notify this <tt>PtrCallback</tt> about
+ * @return <tt>true</tt> if this <tt>PtrCallback</tt> is to continue being
+ * called; otherwise, <tt>false</tt>
+ */
+ boolean callback(long ptr);
+}
diff --git a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java
index 0658d59..81a4aad 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/macosx/MacOSXAddrBookContactQuery.java
@@ -419,7 +419,7 @@ public class MacOSXAddrBookContactQuery
c = Category.InstantMessaging;
break;
case kABMSNInstantProperty:
- sc = SubCategory.MSN;
+ sc = SubCategory.Skype;
c = Category.InstantMessaging;
break;
case kABYahooInstantProperty:
@@ -1240,12 +1240,6 @@ public class MacOSXAddrBookContactQuery
case kABPhoneProperty:
supportedOpSets.add(OperationSetBasicTelephony.class);
break;
- case kABYahooInstantProperty:
- supportedOpSets.add(OperationSetBasicInstantMessaging.class);
- preferredProtocols.put(
- OperationSetBasicInstantMessaging.class,
- ProtocolNames.YAHOO);
- break;
default:
break;
}
@@ -1339,7 +1333,7 @@ public class MacOSXAddrBookContactQuery
return kABAIMInstantProperty;
else if(subCategories.contains(SubCategory.ICQ))
return kABICQInstantProperty;
- else if(subCategories.contains(SubCategory.MSN))
+ else if(subCategories.contains(SubCategory.Skype))
return kABMSNInstantProperty;
else if(subCategories.contains(SubCategory.Jabber))
return kABJabberInstantProperty;
diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/DefaultMailClientMessageDialog.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/DefaultMailClientMessageDialog.java
index 84d9525..afec158 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/DefaultMailClientMessageDialog.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/DefaultMailClientMessageDialog.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,94 +15,94 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.addrbook.msoutlook;
-
-import java.awt.event.*;
-
-import javax.swing.*;
-
-import org.jitsi.service.resources.*;
-
-import net.java.sip.communicator.plugin.addrbook.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-/**
- * A dialog with warning message that Outlook is not the default mail client
- * shown when the contact source is started.
- *
- * @author Hristo Terezov
- */
-public class DefaultMailClientMessageDialog
- extends MessageDialog
-{
-
- /**
- * Serial ID.
- */
- private static final long serialVersionUID = -6321186451307613417L;
-
- /**
- * The <tt>ResourceManagementService</tt>
- */
- private static ResourceManagementService resources
- = AddrBookActivator.getResources();
-
- /**
- * Make Outlook default mail client check box.
- */
- private JCheckBox defaultMailClientCheckBox = new SIPCommCheckBox(
- resources
- .getI18NString("plugin.addrbook.MAKE_OUTLOOK_DEFAULT_MAIL_CLIENT"));
-
- public static int DONT_ASK_SELECTED_MASK = 1;
-
- public static int DEFAULT_MAIL_CLIENT_SELECTED_MASK = 2;
-
- /**
- * Creates an instance of <tt>DefaultMailClientMessageDialog</tt>.
- */
- public DefaultMailClientMessageDialog()
- {
- super(null,
- AddrBookActivator.getResources().getI18NString(
- "plugin.addrbook.OUTLOOK_IS_NOT_DEFAULT_MAIL_CLIENT_TITLE"),
- resources.getI18NString(
- "plugin.addrbook.OUTLOOK_IS_NOT_DEFAULT_MAIL_CLIENT",
- new String[]{
- resources.getSettingsString(
- "service.gui.APPLICATION_NAME")}), false);
- checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS));
- checkBoxPanel.add(defaultMailClientCheckBox);
- }
-
-
- /**
- * Handles the <tt>ActionEvent</tt>. Depending on the user choice sets
- * the return code to the appropriate value.
- *
- * @param e the <tt>ActionEvent</tt> that notified us
- */
- public void actionPerformed(ActionEvent e)
- {
- JButton button = (JButton)e.getSource();
-
- if(!button.equals(okButton))
- return;
-
- this.returnCode = 0;
-
- if (doNotAskAgain.isSelected())
- {
- this.returnCode = this.returnCode | DONT_ASK_SELECTED_MASK;
- }
-
- if (defaultMailClientCheckBox.isSelected())
- {
- this.returnCode
- = this.returnCode | DEFAULT_MAIL_CLIENT_SELECTED_MASK;
- }
-
- this.dispose();
- }
-
-}
+package net.java.sip.communicator.plugin.addrbook.msoutlook;
+
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import org.jitsi.service.resources.*;
+
+import net.java.sip.communicator.plugin.addrbook.*;
+import net.java.sip.communicator.plugin.desktoputil.*;
+
+/**
+ * A dialog with warning message that Outlook is not the default mail client
+ * shown when the contact source is started.
+ *
+ * @author Hristo Terezov
+ */
+public class DefaultMailClientMessageDialog
+ extends MessageDialog
+{
+
+ /**
+ * Serial ID.
+ */
+ private static final long serialVersionUID = -6321186451307613417L;
+
+ /**
+ * The <tt>ResourceManagementService</tt>
+ */
+ private static ResourceManagementService resources
+ = AddrBookActivator.getResources();
+
+ /**
+ * Make Outlook default mail client check box.
+ */
+ private JCheckBox defaultMailClientCheckBox = new SIPCommCheckBox(
+ resources
+ .getI18NString("plugin.addrbook.MAKE_OUTLOOK_DEFAULT_MAIL_CLIENT"));
+
+ public static int DONT_ASK_SELECTED_MASK = 1;
+
+ public static int DEFAULT_MAIL_CLIENT_SELECTED_MASK = 2;
+
+ /**
+ * Creates an instance of <tt>DefaultMailClientMessageDialog</tt>.
+ */
+ public DefaultMailClientMessageDialog()
+ {
+ super(null,
+ AddrBookActivator.getResources().getI18NString(
+ "plugin.addrbook.OUTLOOK_IS_NOT_DEFAULT_MAIL_CLIENT_TITLE"),
+ resources.getI18NString(
+ "plugin.addrbook.OUTLOOK_IS_NOT_DEFAULT_MAIL_CLIENT",
+ new String[]{
+ resources.getSettingsString(
+ "service.gui.APPLICATION_NAME")}), false);
+ checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS));
+ checkBoxPanel.add(defaultMailClientCheckBox);
+ }
+
+
+ /**
+ * Handles the <tt>ActionEvent</tt>. Depending on the user choice sets
+ * the return code to the appropriate value.
+ *
+ * @param e the <tt>ActionEvent</tt> that notified us
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ JButton button = (JButton)e.getSource();
+
+ if(!button.equals(okButton))
+ return;
+
+ this.returnCode = 0;
+
+ if (doNotAskAgain.isSelected())
+ {
+ this.returnCode = this.returnCode | DONT_ASK_SELECTED_MASK;
+ }
+
+ if (defaultMailClientCheckBox.isSelected())
+ {
+ this.returnCode
+ = this.returnCode | DEFAULT_MAIL_CLIENT_SELECTED_MASK;
+ }
+
+ this.dispose();
+ }
+
+}
diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookMAPIHResultException.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookMAPIHResultException.java
index ff4a614..f27b77d 100644
--- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookMAPIHResultException.java
+++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookMAPIHResultException.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,110 +15,110 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.addrbook.msoutlook;
-
-/**
- * Represents a specific Microsoft Outlook MAPI <tt>HRESULT</tt> as an
- * <tt>Exception</tt>.
- *
- * @author Lyubomir Marinov
- */
-public class MsOutlookMAPIHResultException
- extends Exception
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * The <tt>HRESULT</tt> which is represented by this <tt>Exception</tt>.
- */
- private final long hResult;
-
- /**
- * Initializes a new <tt>MsOutlookMAPIHResultException</tt> instance which
- * is to represent a specific <tt>HRESULT</tt>.
- *
- * @param hResult the <tt>HRESULT</tt> to be represented by the new instance
- */
- public MsOutlookMAPIHResultException(long hResult)
- {
- this(hResult, toString(hResult));
- }
-
- /**
- * Initializes a new <tt>MsOutlookMAPIHResultException</tt> instance which
- * is to represent a specific <tt>HRESULT</tt> and to provide a specific
- * <tt>String</tt> message.
- *
- * @param hResult the <tt>HRESULT</tt> to be represented by the new instance
- * @param message the <tt>String</tt> message to be provided by the new
- * instance
- */
- public MsOutlookMAPIHResultException(long hResult, String message)
- {
- super(message);
-
- this.hResult = hResult;
- }
-
- /**
- * Initializes a new <tt>MsOutlookMAPIHResultException</tt> instance with a
- * specific <tt>String</tt> message.
- *
- * @param message the <tt>String</tt> message to be provided by the new
- * instance
- */
- public MsOutlookMAPIHResultException(String message)
- {
- this(0, message);
- }
-
- /**
- * Gets the <tt>HRESULT</tt> which is represented by this
- * <tt>Exception</tt>.
- *
- * @return the <tt>HRESULT</tt> which is represented by this
- * <tt>Exception</tt>
- */
- public long getHResult()
- {
- return hResult;
- }
-
- /**
- * Converts a specific <tt>HRESULT</tt> to a touch more readable
- * <tt>String</tt> in accord with the rule of constructing MAPI
- * <tt>HRESULT</tt> values.
- *
- * @param hResult the <tt>HRESULT</tt> to convert
- * @return a <tt>String</tt> which represents the specified <tt>hResult</tt>
- * in a touch more readable form
- */
- private static String toString(long hResult)
- {
- if (hResult == 0)
- return "S_OK";
- else
- {
- StringBuilder s = new StringBuilder("MAPI_");
-
- s.append(((hResult & 0x80000000L) == 0) ? 'W' : 'E');
- s.append("_0x");
- s.append(Long.toHexString(hResult & 0xFFFL));
- s.append(" (" + Long.toHexString(hResult) + ")");
- return s.toString();
- }
- }
-
- /**
- * Returns the string representation for the current hResult code.
- *
- * @return The string representation for the current hResult code.
- */
- public String getHresultString()
- {
- return MsOutlookMAPIHResultException.toString(this.getHResult());
- }
-}
+package net.java.sip.communicator.plugin.addrbook.msoutlook;
+
+/**
+ * Represents a specific Microsoft Outlook MAPI <tt>HRESULT</tt> as an
+ * <tt>Exception</tt>.
+ *
+ * @author Lyubomir Marinov
+ */
+public class MsOutlookMAPIHResultException
+ extends Exception
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * The <tt>HRESULT</tt> which is represented by this <tt>Exception</tt>.
+ */
+ private final long hResult;
+
+ /**
+ * Initializes a new <tt>MsOutlookMAPIHResultException</tt> instance which
+ * is to represent a specific <tt>HRESULT</tt>.
+ *
+ * @param hResult the <tt>HRESULT</tt> to be represented by the new instance
+ */
+ public MsOutlookMAPIHResultException(long hResult)
+ {
+ this(hResult, toString(hResult));
+ }
+
+ /**
+ * Initializes a new <tt>MsOutlookMAPIHResultException</tt> instance which
+ * is to represent a specific <tt>HRESULT</tt> and to provide a specific
+ * <tt>String</tt> message.
+ *
+ * @param hResult the <tt>HRESULT</tt> to be represented by the new instance
+ * @param message the <tt>String</tt> message to be provided by the new
+ * instance
+ */
+ public MsOutlookMAPIHResultException(long hResult, String message)
+ {
+ super(message);
+
+ this.hResult = hResult;
+ }
+
+ /**
+ * Initializes a new <tt>MsOutlookMAPIHResultException</tt> instance with a
+ * specific <tt>String</tt> message.
+ *
+ * @param message the <tt>String</tt> message to be provided by the new
+ * instance
+ */
+ public MsOutlookMAPIHResultException(String message)
+ {
+ this(0, message);
+ }
+
+ /**
+ * Gets the <tt>HRESULT</tt> which is represented by this
+ * <tt>Exception</tt>.
+ *
+ * @return the <tt>HRESULT</tt> which is represented by this
+ * <tt>Exception</tt>
+ */
+ public long getHResult()
+ {
+ return hResult;
+ }
+
+ /**
+ * Converts a specific <tt>HRESULT</tt> to a touch more readable
+ * <tt>String</tt> in accord with the rule of constructing MAPI
+ * <tt>HRESULT</tt> values.
+ *
+ * @param hResult the <tt>HRESULT</tt> to convert
+ * @return a <tt>String</tt> which represents the specified <tt>hResult</tt>
+ * in a touch more readable form
+ */
+ private static String toString(long hResult)
+ {
+ if (hResult == 0)
+ return "S_OK";
+ else
+ {
+ StringBuilder s = new StringBuilder("MAPI_");
+
+ s.append(((hResult & 0x80000000L) == 0) ? 'W' : 'E');
+ s.append("_0x");
+ s.append(Long.toHexString(hResult & 0xFFFL));
+ s.append(" (" + Long.toHexString(hResult) + ")");
+ return s.toString();
+ }
+ }
+
+ /**
+ * Returns the string representation for the current hResult code.
+ *
+ * @return The string representation for the current hResult code.
+ */
+ public String getHresultString()
+ {
+ return MsOutlookMAPIHResultException.toString(this.getHResult());
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf
index 274310a..b5d678f 100644
--- a/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/aimaccregwizz.manifest.mf
@@ -12,7 +12,6 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.gui.event,
net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.aimconstants,
net.java.sip.communicator.service.protocol.event,
net.java.sip.communicator.service.protocol.icqconstants,
org.jitsi.service.resources, net.java.sip.communicator.service.resources,
diff --git a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java
index 086d891..1f75f1d 100644
--- a/src/net/java/sip/communicator/plugin/branding/AboutWindow.java
+++ b/src/net/java/sip/communicator/plugin/branding/AboutWindow.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,473 +15,440 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.branding;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-
-import javax.imageio.*;
-import javax.swing.*;
-import javax.swing.event.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.plugin.desktoputil.plaf.*;
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.util.Logger;
-import net.java.sip.communicator.util.skin.*;
-
-import org.jitsi.service.resources.*;
-import org.jitsi.util.*;
-import org.osgi.framework.*;
-
-/**
- * The <tt>AboutWindow</tt> is containing information about the application
- * name, version, license etc..
- *
- * @author Yana Stamcheva
- * @author Adam Netocny
- * @author Lyubomir Marinov
- */
-public class AboutWindow
- extends JDialog
- implements HyperlinkListener,
- ActionListener,
- ExportedWindow,
- Skinnable
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * The global/shared <code>AboutWindow</code> currently showing.
- */
- private static AboutWindow aboutWindow;
-
- /**
- * Class id key used in UIDefaults for the version label.
- */
- private static final String uiClassID =
- AboutWindow.class.getName() + "$VersionTextFieldUI";
-
- /**
- * Adds the ui class to UIDefaults.
- */
- static
- {
- UIManager.getDefaults().put(uiClassID,
- SIPCommTextFieldUI.class.getName());
- }
-
- private final JTextField versionLabel;
-
- /**
- * Shows a <code>AboutWindow</code> creating it first if necessary. The
- * shown instance is shared in order to prevent displaying multiple
- * instances of one and the same <code>AboutWindow</code>.
- */
- public static void showAboutWindow()
- {
- if (aboutWindow == null)
- {
- aboutWindow = new AboutWindow(null);
-
- /*
- * When the global/shared AboutWindow closes, don't keep a reference
- * to it and let it be garbage-collected.
- */
- aboutWindow.addWindowListener(new WindowAdapter()
- {
- @Override
- public void windowClosed(WindowEvent e)
- {
- if (aboutWindow == e.getWindow())
- aboutWindow = null;
- }
- });
- }
- aboutWindow.setVisible(true);
- }
-
- private static final int DEFAULT_TEXT_INDENT
- = BrandingActivator.getResources()
- .getSettingsInt("plugin.branding.ABOUT_TEXT_INDENT");
-
- /**
- * Creates an <tt>AboutWindow</tt> by specifying the parent frame owner.
- * @param owner the parent owner
- */
- public AboutWindow(Frame owner)
- {
- super(owner);
-
- ResourceManagementService resources = BrandingActivator.getResources();
-
- String applicationName
- = resources.getSettingsString("service.gui.APPLICATION_NAME");
-
- this.setTitle(
- resources.getI18NString("plugin.branding.ABOUT_WINDOW_TITLE",
- new String[]{applicationName}));
-
- setModal(false);
- setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- setResizable(false);
-
- JPanel mainPanel = new WindowBackground();
- mainPanel.setLayout(new BorderLayout());
-
- JPanel textPanel = new JPanel();
- textPanel.setPreferredSize(new Dimension(470, 280));
- textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
- textPanel.setBorder(BorderFactory
- .createEmptyBorder(15, 15, 15, 15));
- textPanel.setOpaque(false);
-
- JLabel titleLabel = null;
- if (isApplicationNameShown())
- {
- titleLabel = new JLabel(applicationName);
- titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 28));
- titleLabel.setForeground(Constants.TITLE_COLOR);
- titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
-
- // Force the use of the custom text field UI in order to fix an
- // incorrect rendering on Ubuntu.
- versionLabel
- = new JTextField(" "
- + System.getProperty("sip-communicator.version"))
- {
- /**
- * Returns the name of the L&F class that renders this component.
- *
- * @return the string "TreeUI"
- * @see JComponent#getUIClassID
- * @see UIDefaults#getUI
- */
- @Override
- public String getUIClassID()
- {
- return uiClassID;
- }
- };
-
- versionLabel.setBorder(null);
- versionLabel.setOpaque(false);
- versionLabel.setEditable(false);
- versionLabel.setFont(versionLabel.getFont().deriveFont(Font.BOLD, 18));
- versionLabel.setForeground(Constants.TITLE_COLOR);
- versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
- versionLabel.setHorizontalAlignment(JTextField.RIGHT);
-
- int logoAreaFontSize
- = resources.getSettingsInt("plugin.branding.ABOUT_LOGO_FONT_SIZE");
-
- // FIXME: the message exceeds the window length
- JTextArea logoArea =
- new JTextArea(resources.getI18NString(
- "plugin.branding.LOGO_MESSAGE"));
- logoArea.setFont(
- logoArea.getFont().deriveFont(Font.BOLD, logoAreaFontSize));
- logoArea.setForeground(Constants.TITLE_COLOR);
- logoArea.setOpaque(false);
- logoArea.setLineWrap(true);
- logoArea.setWrapStyleWord(true);
- logoArea.setEditable(false);
- logoArea.setPreferredSize(new Dimension(100, 20));
- logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- logoArea.setBorder(BorderFactory
- .createEmptyBorder(30, DEFAULT_TEXT_INDENT, 0, 0));
-
- StyledHTMLEditorPane rightsArea = new StyledHTMLEditorPane();
- rightsArea.setContentType("text/html");
-
- rightsArea.appendToEnd(resources.getI18NString(
- "plugin.branding.COPYRIGHT",
- new String[]
- { Constants.TEXT_COLOR }));
-
- rightsArea.setPreferredSize(new Dimension(50, 20));
- rightsArea
- .setBorder(BorderFactory
- .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0));
- rightsArea.setOpaque(false);
- rightsArea.setEditable(false);
- rightsArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- rightsArea.addHyperlinkListener(this);
-
- StyledHTMLEditorPane licenseArea = new StyledHTMLEditorPane();
- licenseArea.setContentType("text/html");
- licenseArea.appendToEnd(resources.
- getI18NString("plugin.branding.LICENSE",
- new String[]{Constants.TEXT_COLOR}));
-
- licenseArea.setPreferredSize(new Dimension(50, 20));
- licenseArea.setBorder(
- BorderFactory.createEmptyBorder(
- resources.getSettingsInt("plugin.branding.ABOUT_PARAGRAPH_GAP"),
- DEFAULT_TEXT_INDENT,
- 0, 0));
- licenseArea.setOpaque(false);
- licenseArea.setEditable(false);
- licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- licenseArea.addHyperlinkListener(this);
-
- if (titleLabel != null)
- textPanel.add(titleLabel);
-
- textPanel.add(versionLabel);
- textPanel.add(logoArea);
- textPanel.add(rightsArea);
- textPanel.add(licenseArea);
-
- JButton okButton
- = new JButton(resources.getI18NString("service.gui.OK"));
-
- this.getRootPane().setDefaultButton(okButton);
-
- okButton.setMnemonic(resources.getI18nMnemonic("service.gui.OK"));
- okButton.addActionListener(this);
-
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- buttonPanel.add(okButton);
- buttonPanel.setOpaque(false);
-
- mainPanel.add(textPanel, BorderLayout.CENTER);
- mainPanel.add(buttonPanel, BorderLayout.SOUTH);
-
- this.getContentPane().add(mainPanel);
-
- this.pack();
-
- setLocationRelativeTo(getParent());
-
- this.getRootPane().getActionMap().put("close", new CloseAction());
-
- InputMap imap = this.getRootPane().getInputMap(
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
-
- imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
-
- if(OSUtils.IS_MAC)
- {
- imap.put(
- KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_DOWN_MASK),
- "close");
- imap.put(
- KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK),
- "close");
- }
-
- WindowUtils.addWindow(this);
- }
-
- /**
- * Reloads text field UI.
- */
- public void loadSkin()
- {
- if(versionLabel.getUI() instanceof Skinnable)
- ((Skinnable)versionLabel.getUI()).loadSkin();
- }
-
- /**
- * Constructs the window background in order to have a background image.
- */
- private static class WindowBackground
- extends JPanel
- implements Skinnable
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private static final Logger logger
- = Logger.getLogger(WindowBackground.class);
-
- private Image bgImage = null;
-
- public WindowBackground()
- {
- loadSkin();
- }
-
- /**
- * Reloads resources for this component.
- */
- public void loadSkin()
- {
- try
- {
- bgImage = ImageIO.read(BrandingActivator.getResources().
- getImageURL("plugin.branding.ABOUT_WINDOW_BACKGROUND"));
-
- this.setPreferredSize(new Dimension(bgImage.getWidth(this),
- bgImage.getHeight(this)));
- }
- catch (IOException e)
- {
- logger.error("Error cannot obtain background image", e);
- bgImage = null;
- }
- }
-
- @Override
- protected void paintComponent(Graphics g)
- {
- super.paintComponent(g);
-
- g = g.create();
- try
- {
- AntialiasingManager.activateAntialiasing(g);
-
- int bgImageWidth = bgImage.getWidth(null);
- int bgImageHeight = bgImage.getHeight(null);
- boolean bgImageHasBeenDrawn = false;
-
- if ((bgImageWidth != -1) && (bgImageHeight != -1))
- {
- int width = getWidth();
- int height = getHeight();
-
- if ((bgImageWidth < width) || (bgImageHeight < height))
- {
- g.drawImage(bgImage, 0, 0, width, height, null);
- bgImageHasBeenDrawn = true;
- }
- }
-
- if (!bgImageHasBeenDrawn)
- g.drawImage(bgImage, 0, 0, null);
- }
- finally
- {
- g.dispose();
- }
- }
- }
-
- /**
- * Opens a browser when the link has been activated (clicked).
- * @param e the <tt>HyperlinkEvent</tt> that notified us
- */
- public void hyperlinkUpdate(HyperlinkEvent e)
- {
- if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
- {
- String href = e.getDescription();
- ServiceReference serviceReference = BrandingActivator
- .getBundleContext().getServiceReference(
- BrowserLauncherService.class.getName());
-
- if (serviceReference != null)
- {
- BrowserLauncherService browserLauncherService
- = (BrowserLauncherService) BrandingActivator
- .getBundleContext().getService(serviceReference);
-
- browserLauncherService.openURL(href);
- }
- }
- }
-
- /**
- * Indicates that the ok button has been pressed. Closes the window.
- * @param e the <tt>ActionEvent</tt> that notified us
- */
- public void actionPerformed(ActionEvent e)
- {
- setVisible(false);
- dispose();
- }
-
- /**
- * Implements the <tt>ExportedWindow.getIdentifier()</tt> method.
- * @return the identifier of this exported window
- */
- public WindowID getIdentifier()
- {
- return ExportedWindow.ABOUT_WINDOW;
- }
-
- /**
- * This dialog could not be minimized.
- */
- public void minimize()
- {
- }
-
- /**
- * This dialog could not be maximized.
- */
- public void maximize()
- {
- }
-
- /**
- * Implements the <tt>ExportedWindow.bringToFront()</tt> method. Brings
- * this window to front.
- */
- public void bringToFront()
- {
- this.toFront();
- }
-
- /**
- * The source of the window
- * @return the source of the window
- */
- public Object getSource()
- {
- return this;
- }
-
- /**
- * Implementation of {@link ExportedWindow#setParams(Object[])}.
- */
- public void setParams(Object[] windowParams) {}
-
- /**
- * The action invoked when user presses Escape key.
- */
- private class CloseAction extends UIAction
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- public void actionPerformed(ActionEvent e)
- {
- setVisible(false);
- dispose();
- }
- }
-
- /**
- * Indicates if the application name should be shown.
- *
- * @return <tt>true</tt> if the application name should be shown,
- * <tt>false</tt> - otherwise
- */
- private boolean isApplicationNameShown()
- {
- String showApplicationNameProp
- = BrandingActivator.getResources().getSettingsString(
- "plugin.branding.IS_APPLICATION_NAME_SHOWN");
-
- if (showApplicationNameProp != null
- && showApplicationNameProp.length() > 0)
- {
- return Boolean.parseBoolean(showApplicationNameProp);
- }
-
- return true;
- }
-}
+package net.java.sip.communicator.plugin.branding;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+import javax.imageio.*;
+import javax.swing.*;
+import javax.swing.event.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.plugin.desktoputil.plaf.*;
+import net.java.sip.communicator.service.browserlauncher.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.util.Logger;
+import net.java.sip.communicator.util.skin.*;
+
+import org.jitsi.service.resources.*;
+import org.jitsi.util.*;
+import org.osgi.framework.*;
+
+/**
+ * The <tt>AboutWindow</tt> is containing information about the application
+ * name, version, license etc..
+ *
+ * @author Yana Stamcheva
+ * @author Adam Netocny
+ * @author Lyubomir Marinov
+ */
+public class AboutWindow
+ extends JDialog
+ implements HyperlinkListener,
+ ActionListener,
+ ExportedWindow,
+ Skinnable
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ private static AboutWindow aboutWindow;
+
+ /**
+ * Class id key used in UIDefaults for the version label.
+ */
+ private static final String uiClassID =
+ AboutWindow.class.getName() + "$VersionTextFieldUI";
+
+ /**
+ * Adds the ui class to UIDefaults.
+ */
+ static
+ {
+ UIManager.getDefaults().put(uiClassID,
+ SIPCommTextFieldUI.class.getName());
+ }
+
+ private final JTextField versionLabel;
+
+ /**
+ * Shows a <code>AboutWindow</code> creating it first if necessary. The
+ * shown instance is shared in order to prevent displaying multiple
+ * instances of one and the same <code>AboutWindow</code>.
+ */
+ public static void showAboutWindow()
+ {
+ if (aboutWindow == null)
+ {
+ aboutWindow = new AboutWindow(null);
+
+ /*
+ * When the global/shared AboutWindow closes, don't keep a reference
+ * to it and let it be garbage-collected.
+ */
+ aboutWindow.addWindowListener(new WindowAdapter()
+ {
+ @Override
+ public void windowClosed(WindowEvent e)
+ {
+ if (aboutWindow == e.getWindow())
+ aboutWindow = null;
+ }
+ });
+ }
+ aboutWindow.setVisible(true);
+ }
+
+ private static final int DEFAULT_TEXT_INDENT
+ = BrandingActivator.getResources()
+ .getSettingsInt("plugin.branding.ABOUT_TEXT_INDENT");
+
+ /**
+ * Creates an <tt>AboutWindow</tt> by specifying the parent frame owner.
+ * @param owner the parent owner
+ */
+ public AboutWindow(Frame owner)
+ {
+ super(owner);
+
+ ResourceManagementService resources = BrandingActivator.getResources();
+
+ String applicationName =
+ resources.getSettingsString("service.gui.APPLICATION_NAME");
+ String website =
+ resources.getSettingsString("service.gui.APPLICATION_WEB_SITE");
+
+ this.setTitle(
+ resources.getI18NString("plugin.branding.ABOUT_WINDOW_TITLE",
+ new String[]{applicationName}));
+
+ setModal(false);
+ setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+ setResizable(false);
+
+ JPanel mainPanel = new WindowBackground();
+ mainPanel.setLayout(new BorderLayout());
+
+ JPanel textPanel = new JPanel();
+ textPanel.setPreferredSize(new Dimension(470, 280));
+ textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
+ textPanel.setBorder(BorderFactory
+ .createEmptyBorder(15, 15, 15, 15));
+ textPanel.setOpaque(false);
+
+ JLabel titleLabel = new JLabel(applicationName);
+ titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 28));
+ titleLabel.setForeground(Constants.TITLE_COLOR);
+ titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
+
+ // Force the use of the custom text field UI in order to fix an
+ // incorrect rendering on Ubuntu.
+ versionLabel
+ = new JTextField(" "
+ + System.getProperty("sip-communicator.version"))
+ {
+ /**
+ * Returns the name of the L&F class that renders this component.
+ *
+ * @return the string "TreeUI"
+ * @see JComponent#getUIClassID
+ * @see UIDefaults#getUI
+ */
+ @Override
+ public String getUIClassID()
+ {
+ return uiClassID;
+ }
+ };
+
+ versionLabel.setBorder(null);
+ versionLabel.setOpaque(false);
+ versionLabel.setEditable(false);
+ versionLabel.setFont(versionLabel.getFont().deriveFont(Font.BOLD, 18));
+ versionLabel.setForeground(Constants.TITLE_COLOR);
+ versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
+ versionLabel.setHorizontalAlignment(JTextField.RIGHT);
+
+ int logoAreaFontSize
+ = resources.getSettingsInt("plugin.branding.ABOUT_LOGO_FONT_SIZE");
+
+ JTextArea logoArea =
+ new JTextArea(resources.getI18NString(
+ "plugin.branding.LOGO_MESSAGE"));
+ logoArea.setFont(
+ logoArea.getFont().deriveFont(Font.BOLD, logoAreaFontSize));
+ logoArea.setForeground(Constants.TITLE_COLOR);
+ logoArea.setOpaque(false);
+ logoArea.setLineWrap(true);
+ logoArea.setWrapStyleWord(true);
+ logoArea.setEditable(false);
+ logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
+ logoArea.setBorder(BorderFactory
+ .createEmptyBorder(30, DEFAULT_TEXT_INDENT, 0, 0));
+
+ StyledHTMLEditorPane rightsArea = new StyledHTMLEditorPane();
+ rightsArea.setContentType("text/html");
+
+ String host = website;
+ try
+ {
+ host = new URL(website).getHost();
+ }
+ catch (Exception ex)
+ {}
+
+ rightsArea.appendToEnd(resources.getI18NString(
+ "plugin.branding.COPYRIGHT_LICENSE",
+ new String[]
+ {
+ Constants.TEXT_COLOR,
+ Integer.toString(Calendar.getInstance().get(Calendar.YEAR)),
+ website,
+ host,
+ applicationName,
+ "http://www.apache.org/licenses/LICENSE-2.0",
+ "Apache License 2.0"
+ }));
+
+ rightsArea.setBorder(BorderFactory
+ .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0));
+ rightsArea.setOpaque(false);
+ rightsArea.setEditable(false);
+ rightsArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
+ rightsArea.addHyperlinkListener(this);
+
+ textPanel.add(titleLabel);
+ textPanel.add(versionLabel);
+ textPanel.add(logoArea);
+ textPanel.add(rightsArea);
+
+ JButton okButton
+ = new JButton(resources.getI18NString("service.gui.OK"));
+
+ this.getRootPane().setDefaultButton(okButton);
+
+ okButton.setMnemonic(resources.getI18nMnemonic("service.gui.OK"));
+ okButton.addActionListener(this);
+
+ JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+ buttonPanel.add(okButton);
+ buttonPanel.setOpaque(false);
+
+ mainPanel.add(textPanel, BorderLayout.CENTER);
+ mainPanel.add(buttonPanel, BorderLayout.SOUTH);
+
+ this.getContentPane().add(mainPanel);
+
+ this.pack();
+
+ setLocationRelativeTo(getParent());
+
+ this.getRootPane().getActionMap().put("close", new CloseAction());
+
+ InputMap imap = this.getRootPane().getInputMap(
+ JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+
+ imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
+
+ if(OSUtils.IS_MAC)
+ {
+ imap.put(
+ KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_DOWN_MASK),
+ "close");
+ imap.put(
+ KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK),
+ "close");
+ }
+
+ WindowUtils.addWindow(this);
+ }
+
+ /**
+ * Reloads text field UI.
+ */
+ public void loadSkin()
+ {
+ if(versionLabel.getUI() instanceof Skinnable)
+ ((Skinnable)versionLabel.getUI()).loadSkin();
+ }
+
+ /**
+ * Constructs the window background in order to have a background image.
+ */
+ private static class WindowBackground
+ extends JPanel
+ implements Skinnable
+ {
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ private static final Logger logger
+ = Logger.getLogger(WindowBackground.class);
+
+ private Image bgImage = null;
+
+ public WindowBackground()
+ {
+ loadSkin();
+ }
+
+ /**
+ * Reloads resources for this component.
+ */
+ public void loadSkin()
+ {
+ try
+ {
+ bgImage = ImageIO.read(BrandingActivator.getResources().
+ getImageURL("plugin.branding.ABOUT_WINDOW_BACKGROUND"));
+
+ this.setPreferredSize(new Dimension(bgImage.getWidth(this),
+ bgImage.getHeight(this)));
+ }
+ catch (IOException e)
+ {
+ logger.error("Error cannot obtain background image", e);
+ bgImage = null;
+ }
+ }
+
+ @Override
+ protected void paintComponent(Graphics g)
+ {
+ super.paintComponent(g);
+
+ g = g.create();
+ try
+ {
+ AntialiasingManager.activateAntialiasing(g);
+
+ int bgImageWidth = bgImage.getWidth(null);
+ int bgImageHeight = bgImage.getHeight(null);
+ boolean bgImageHasBeenDrawn = false;
+
+ if ((bgImageWidth != -1) && (bgImageHeight != -1))
+ {
+ int width = getWidth();
+ int height = getHeight();
+
+ if ((bgImageWidth < width) || (bgImageHeight < height))
+ {
+ g.drawImage(bgImage, 0, 0, width, height, null);
+ bgImageHasBeenDrawn = true;
+ }
+ }
+
+ if (!bgImageHasBeenDrawn)
+ g.drawImage(bgImage, 0, 0, null);
+ }
+ finally
+ {
+ g.dispose();
+ }
+ }
+ }
+
+ /**
+ * Opens a browser when the link has been activated (clicked).
+ * @param e the <tt>HyperlinkEvent</tt> that notified us
+ */
+ public void hyperlinkUpdate(HyperlinkEvent e)
+ {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
+ {
+ ServiceReference<BrowserLauncherService> serviceReference =
+ BrandingActivator.getBundleContext().getServiceReference(
+ BrowserLauncherService.class);
+
+ if (serviceReference != null)
+ {
+ BrowserLauncherService browserLauncherService
+ = BrandingActivator
+ .getBundleContext().getService(serviceReference);
+
+ browserLauncherService.openURL(e.getDescription());
+ }
+ }
+ }
+
+ /**
+ * Indicates that the ok button has been pressed. Closes the window.
+ * @param e the <tt>ActionEvent</tt> that notified us
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ setVisible(false);
+ dispose();
+ }
+
+ /**
+ * Implements the <tt>ExportedWindow.getIdentifier()</tt> method.
+ * @return the identifier of this exported window
+ */
+ public WindowID getIdentifier()
+ {
+ return ExportedWindow.ABOUT_WINDOW;
+ }
+
+ /**
+ * This dialog could not be minimized.
+ */
+ public void minimize()
+ {
+ }
+
+ /**
+ * This dialog could not be maximized.
+ */
+ public void maximize()
+ {
+ }
+
+ /**
+ * Implements the <tt>ExportedWindow.bringToFront()</tt> method. Brings
+ * this window to front.
+ */
+ public void bringToFront()
+ {
+ this.toFront();
+ }
+
+ /**
+ * The source of the window
+ * @return the source of the window
+ */
+ public Object getSource()
+ {
+ return this;
+ }
+
+ /**
+ * Implementation of {@link ExportedWindow#setParams(Object[])}.
+ */
+ public void setParams(Object[] windowParams) {}
+
+ /**
+ * The action invoked when user presses Escape key.
+ */
+ private class CloseAction extends UIAction
+ {
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ public void actionPerformed(ActionEvent e)
+ {
+ setVisible(false);
+ dispose();
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/branding/AboutWindowPluginComponent.java b/src/net/java/sip/communicator/plugin/branding/AboutWindowPluginComponent.java
index 333781d..eb2d61a 100644
--- a/src/net/java/sip/communicator/plugin/branding/AboutWindowPluginComponent.java
+++ b/src/net/java/sip/communicator/plugin/branding/AboutWindowPluginComponent.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,89 +15,89 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.branding;
-
-import java.awt.event.*;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.service.gui.*;
-
-/**
- * Implements an About menu item for the Help menu of the application in the
- * form of a <tt>PluginComponent</tt>.
- *
- * @author Lyubomir Marinov
- */
-public class AboutWindowPluginComponent
- extends AbstractPluginComponent
-{
-
- /**
- * Invokes the default action associated with Help > About regardless of the
- * specifics of its visual representation.
- */
- public static void actionPerformed()
- {
- AboutWindow.showAboutWindow();
- }
-
- private JMenuItem aboutMenuItem;
-
- /**
- * Constructor.
- *
- * @param container parent container
- */
- public AboutWindowPluginComponent(Container container,
- PluginComponentFactory parentFactory)
- {
- super(container, parentFactory);
- }
-
- public Object getComponent()
- {
- if (aboutMenuItem == null)
- {
- aboutMenuItem = new JMenuItem(getName());
- aboutMenuItem
- .setMnemonic(
- BrandingActivator
- .getResources()
- .getI18nMnemonic(
- "plugin.branding.ABOUT_MENU_ENTRY"));
-
- aboutMenuItem.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- AboutWindowPluginComponent.actionPerformed();
- }
- });
- }
- return aboutMenuItem;
- }
-
- public String getName()
- {
- return
- BrandingActivator
- .getResources()
- .getI18NString("plugin.branding.ABOUT_MENU_ENTRY");
- }
-
- /**
- * Implements {@link PluginComponent#getPositionIndex()}. Returns
- * <tt>Integer#MAX_VALUE</tt> in order to indicate that the About menu item
- * in the Help menu is conventionally displayed at the very bottom.
- *
- * @return <tt>Integer#MAX_VALUE</tt> in order to indicate that the About
- * menu item in the Help menu is conventionally displayed at the very bottom
- * @see AbstractPluginComponent#getPositionIndex()
- */
- @Override
- public int getPositionIndex()
- {
- return Integer.MAX_VALUE;
- }
-}
+package net.java.sip.communicator.plugin.branding;
+
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.service.gui.*;
+
+/**
+ * Implements an About menu item for the Help menu of the application in the
+ * form of a <tt>PluginComponent</tt>.
+ *
+ * @author Lyubomir Marinov
+ */
+public class AboutWindowPluginComponent
+ extends AbstractPluginComponent
+{
+
+ /**
+ * Invokes the default action associated with Help > About regardless of the
+ * specifics of its visual representation.
+ */
+ public static void actionPerformed()
+ {
+ AboutWindow.showAboutWindow();
+ }
+
+ private JMenuItem aboutMenuItem;
+
+ /**
+ * Constructor.
+ *
+ * @param container parent container
+ */
+ public AboutWindowPluginComponent(Container container,
+ PluginComponentFactory parentFactory)
+ {
+ super(container, parentFactory);
+ }
+
+ public Object getComponent()
+ {
+ if (aboutMenuItem == null)
+ {
+ aboutMenuItem = new JMenuItem(getName());
+ aboutMenuItem
+ .setMnemonic(
+ BrandingActivator
+ .getResources()
+ .getI18nMnemonic(
+ "plugin.branding.ABOUT_MENU_ENTRY"));
+
+ aboutMenuItem.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ AboutWindowPluginComponent.actionPerformed();
+ }
+ });
+ }
+ return aboutMenuItem;
+ }
+
+ public String getName()
+ {
+ return
+ BrandingActivator
+ .getResources()
+ .getI18NString("plugin.branding.ABOUT_MENU_ENTRY");
+ }
+
+ /**
+ * Implements {@link PluginComponent#getPositionIndex()}. Returns
+ * <tt>Integer#MAX_VALUE</tt> in order to indicate that the About menu item
+ * in the Help menu is conventionally displayed at the very bottom.
+ *
+ * @return <tt>Integer#MAX_VALUE</tt> in order to indicate that the About
+ * menu item in the Help menu is conventionally displayed at the very bottom
+ * @see AbstractPluginComponent#getPositionIndex()
+ */
+ @Override
+ public int getPositionIndex()
+ {
+ return Integer.MAX_VALUE;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java b/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java
index 6d8bdfd..f6de958 100644
--- a/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java
+++ b/src/net/java/sip/communicator/plugin/branding/BrandingActivator.java
@@ -33,91 +33,12 @@ import org.osgi.framework.*;
*/
public class BrandingActivator
extends AbstractServiceDependentActivator
- implements BundleListener
{
private final Logger logger = Logger.getLogger(BrandingActivator.class);
-
- /**
- * The name of the boolean property which indicates whether the splash
- * screen (i.e. <code>WelcomeWindow</code>) is to be shown or to not be
- * utilized for the sake of better memory consumption and faster startup.
- */
- private static final String PNAME_SHOW_SPLASH_SCREEN
- = "net.java.sip.communicator.plugin.branding.SHOW_SPLASH_SCREEN";
-
private static BundleContext bundleContext;
-
private static ResourceManagementService resourcesService;
/**
- * The welcome window.
- */
- private WelcomeWindow welcomeWindow;
-
- @Override
- public void start(BundleContext bc) throws Exception
- {
- super.start(bc);
-
- ConfigurationService config = getConfigurationService();
- boolean showSplashScreen
- = (config == null)
- ? true /*
- * Having no ConfigurationService reference is not good
- * for the application so we are better off with the
- * splash screen to actually see which bundles get loaded
- * and maybe be able to debug the problem.
- */
- : config.getBoolean(PNAME_SHOW_SPLASH_SCREEN, false);
-
- /*
- * WelcomeWindow is huge because it has a large image spread all over it
- * so, given it's only necessary before the UIService gets activated, we
- * certainly don't want to keep it around (e.g. as an instance field or
- * as a final variable used inside a BundleListener which never gets
- * removed).
- */
- if (showSplashScreen)
- {
- welcomeWindow = new WelcomeWindow();
- welcomeWindow.pack();
- welcomeWindow.setVisible(true);
- }
- else
- welcomeWindow = null;
-
- if (getResources().getSettingsString(
- "service.gui.APPLICATION_NAME").equals("SIP Communicator"))
- new JitsiWarningWindow(null).setVisible(true);
-
- bundleContext.addBundleListener(this);
- }
-
- /**
- * Bundle has been started if welcome window is available and visible
- * update it to show the bundle activity.
- * @param evt
- */
- public synchronized void bundleChanged(BundleEvent evt)
- {
- if (welcomeWindow != null
- && welcomeWindow.isShowing()
- && (evt.getType() == BundleEvent.STARTED))
- {
- /*
- * The IBM JRE on GNU/Linux reports the Bundle-Name as null while
- * the SUN JRE reports it as non-null. Just prevent the throwing of
- * a NullPointerException because displaying the Bundle-Name isn't
- * vital anyway.
- */
- Object bundleName = evt.getBundle().getHeaders().get("Bundle-Name");
-
- welcomeWindow.setBundle(
- (bundleName == null) ? null : bundleName.toString());
- }
- }
-
- /**
* Setting context to the activator, as soon as we have one.
*
* @param context the context to set.
@@ -145,31 +66,12 @@ public class BrandingActivator
@Override
public void start(Object dependentService)
{
- // UI-Service started.
-
- /*
- * Don't let bundleContext retain a reference to this
- * listener because it'll retain a reference to
- * welcomeWindow. Besides, we're no longer interested in
- * handling events so it doesn't make sense to even retain
- * this listener.
- */
- bundleContext.removeBundleListener(this);
-
// register the about dialog menu entry
registerMenuEntry((UIService)dependentService);
-
- if (welcomeWindow != null)
- {
- synchronized(this)
- {
- welcomeWindow.close();
- welcomeWindow = null;
- }
- }
}
- public void stop(BundleContext arg0) throws Exception
+ @Override
+ public void stop(BundleContext context) throws Exception
{
}
@@ -189,7 +91,6 @@ public class BrandingActivator
private boolean registerMenuEntryMacOSX(UIService uiService)
{
- Exception exception = null;
try
{
Class<?> clazz =
@@ -199,28 +100,16 @@ public class BrandingActivator
Object result = method.invoke(null, (Object[]) null);
if (result instanceof Boolean)
+ {
return ((Boolean) result).booleanValue();
+ }
}
- catch (ClassNotFoundException ex)
- {
- exception = ex;
- }
- catch (IllegalAccessException ex)
- {
- exception = ex;
- }
- catch (InvocationTargetException ex)
- {
- exception = ex;
- }
- catch (NoSuchMethodException ex)
+ catch (Exception ex)
{
- exception = ex;
+ logger.error("Failed to register Mac OS X-specific About handling.",
+ ex);
}
- if (exception != null)
- logger.error(
- "Failed to register Mac OS X-specific About handling.",
- exception);
+
return false;
}
@@ -276,17 +165,6 @@ public class BrandingActivator
return bundleContext;
}
- private static ConfigurationService getConfigurationService()
- {
- ServiceReference serRef
- = bundleContext
- .getServiceReference(ConfigurationService.class.getName());
- return
- (serRef == null)
- ? null
- : (ConfigurationService) bundleContext.getService(serRef);
- }
-
/**
* Returns the <tt>ResourceManagementService</tt>.
*
diff --git a/src/net/java/sip/communicator/plugin/branding/Constants.java b/src/net/java/sip/communicator/plugin/branding/Constants.java
index 9d15df4..b098e4d 100644
--- a/src/net/java/sip/communicator/plugin/branding/Constants.java
+++ b/src/net/java/sip/communicator/plugin/branding/Constants.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,65 +15,65 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.branding;
-
-import java.awt.*;
-import java.io.*;
-
-import javax.swing.text.html.*;
-
-/**
- * All look and feel related constants are stored here.
- *
- * @author Yana Stamcheva
- */
-public class Constants
-{
- /*
- * ======================================================================
- * -------------------- FONTS AND COLOR CONSTANTS ------------------------
- * ======================================================================
- */
-
- /**
- * Dark blue color used in the about window and the splash screen.
- */
- public static final Color TITLE_COLOR
- = new Color(BrandingActivator.getResources()
- .getColor("service.gui.SPLASH_SCREEN_TITLE_COLOR"));
-
- /**
- * Text color used in the about window and the splash screen.
- */
- public static final String TEXT_COLOR
- = BrandingActivator.getResources()
- .getColorString("service.gui.SPLASH_SCREEN_TEXT_COLOR");
-
-
- /*
- * ======================================================================
- * --------------------------- FONT CONSTANTS ---------------------------
- * ======================================================================
- */
-
- /**
- * Temporary method to load the css style used in the chat window.
- *
- * @param style
- */
- public static void loadSimpleStyle(StyleSheet style)
- {
- InputStream is = BrandingActivator.getResources().
- getSettingsInputStream("service.gui.HTML_TEXT_STYLE");
-
- Reader r = new BufferedReader(new InputStreamReader(is));
- try
- {
- style.loadRules(r, null);
- r.close();
- }
- catch (IOException e)
- {
- }
- }
-}
+package net.java.sip.communicator.plugin.branding;
+
+import java.awt.*;
+import java.io.*;
+
+import javax.swing.text.html.*;
+
+/**
+ * All look and feel related constants are stored here.
+ *
+ * @author Yana Stamcheva
+ */
+public class Constants
+{
+ /*
+ * ======================================================================
+ * -------------------- FONTS AND COLOR CONSTANTS ------------------------
+ * ======================================================================
+ */
+
+ /**
+ * Dark blue color used in the about window and the splash screen.
+ */
+ public static final Color TITLE_COLOR
+ = new Color(BrandingActivator.getResources()
+ .getColor("service.gui.SPLASH_SCREEN_TITLE_COLOR"));
+
+ /**
+ * Text color used in the about window and the splash screen.
+ */
+ public static final String TEXT_COLOR
+ = BrandingActivator.getResources()
+ .getColorString("service.gui.SPLASH_SCREEN_TEXT_COLOR");
+
+
+ /*
+ * ======================================================================
+ * --------------------------- FONT CONSTANTS ---------------------------
+ * ======================================================================
+ */
+
+ /**
+ * Temporary method to load the css style used in the chat window.
+ *
+ * @param style
+ */
+ public static void loadSimpleStyle(StyleSheet style)
+ {
+ InputStream is = BrandingActivator.getResources().
+ getSettingsInputStream("service.gui.HTML_TEXT_STYLE");
+
+ Reader r = new BufferedReader(new InputStreamReader(is));
+ try
+ {
+ style.loadRules(r, null);
+ r.close();
+ }
+ catch (IOException e)
+ {
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/branding/JitsiWarningWindow.java b/src/net/java/sip/communicator/plugin/branding/JitsiWarningWindow.java
deleted file mode 100644
index 0ca6a89..0000000
--- a/src/net/java/sip/communicator/plugin/branding/JitsiWarningWindow.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.branding;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.browserlauncher.*;
-
-import org.jitsi.service.resources.*;
-import org.jitsi.util.*;
-import org.osgi.framework.*;
-
-/**
- * The <tt>JitsiWarningWindow</tt>.
- *
- * @author Yana Stamcheva
- */
-public class JitsiWarningWindow
- extends SIPCommDialog
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * Creates an <tt>JitsiWarningWindow</tt> by specifying the parent frame
- * owner.
- * @param owner the parent owner
- */
- public JitsiWarningWindow(Frame owner)
- {
- super(owner, false);
-
- ResourceManagementService resources = BrandingActivator.getResources();
-
- this.setTitle(
- resources.getI18NString("service.gui.UPDATE")
- + " " + resources.getSettingsString(
- "service.gui.APPLICATION_NAME"));
-
- setModal(false);
- setDefaultCloseOperation(DISPOSE_ON_CLOSE);
-
- StyledHTMLEditorPane textArea = new StyledHTMLEditorPane();
- textArea.setContentType("text/html");
- textArea.setText(resources.getI18NString("service.gui.JITSI_WARNING"));
- textArea.setOpaque(false);
- textArea.setEditable(false);
-
- JLabel titleLabel = new JLabel(
- resources.getI18NString("service.gui.JITSI_WARNING_TITLE"));
- titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 14f));
- titleLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
- titleLabel.setMaximumSize(new Dimension(400, 50));
-
- JPanel textPanel = new TransparentPanel();
- textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
-
- textPanel.add(titleLabel);
- textPanel.add(Box.createRigidArea(new Dimension(20, 20)));
- textPanel.add(textArea);
-
- JButton downloadButton = new JButton(
- resources.getI18NString("service.gui.DOWNLOAD_NOW"));
- JButton remindButton = new JButton(
- resources.getI18NString("service.gui.REMIND_ME_LATER"));
-
- this.getRootPane().setDefaultButton(downloadButton);
-
- downloadButton.setMnemonic(
- resources.getI18nMnemonic("service.gui.DOWNLOAD_NOW"));
- downloadButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- openURL(getDownloadLink());
- dispose();
- }
- });
- remindButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- dispose();
- }
- });
-
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- buttonPanel.add(remindButton);
- buttonPanel.add(downloadButton);
- buttonPanel.setOpaque(false);
-
- JPanel mainPanel = new TransparentPanel(new BorderLayout(10, 10));
- mainPanel.add(new JLabel(resources.getImage(
- "service.gui.SIP_COMMUNICATOR_LOGO_128x128")), BorderLayout.WEST);
- mainPanel.add(textPanel, BorderLayout.CENTER);
- mainPanel.add(buttonPanel, BorderLayout.SOUTH);
- mainPanel.setPreferredSize(new Dimension(500, 200));
- mainPanel.setBorder(
- BorderFactory.createEmptyBorder(20, 20, 20, 20));
-
- getContentPane().add(mainPanel);
-
- this.pack();
- this.setResizable(false);
-
- setLocationRelativeTo(getParent());
-
- this.getRootPane().getActionMap().put("close", new CloseAction());
-
- InputMap imap = this.getRootPane().getInputMap(
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
-
- imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
-
- if(OSUtils.IS_MAC)
- {
- imap.put(
- KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_DOWN_MASK),
- "close");
- imap.put(
- KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK),
- "close");
- }
- }
-
- /**
- * The action invoked when user presses Escape key.
- */
- private class CloseAction extends UIAction
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- public void actionPerformed(ActionEvent e)
- {
- setVisible(false);
- dispose();
- }
- }
-
- /**
- * Opens the given url in a new browser window.
- * @param url the url to open
- */
- private void openURL(String url)
- {
- ServiceReference serviceReference = BrandingActivator
- .getBundleContext().getServiceReference(
- BrowserLauncherService.class.getName());
-
- if (serviceReference != null)
- {
- BrowserLauncherService browserLauncherService
- = (BrowserLauncherService) BrandingActivator
- .getBundleContext().getService(
- serviceReference);
-
- browserLauncherService.openURL(url);
- }
- }
-
- /**
- * Indicates if the application name should be shown.
- *
- * @return <tt>true</tt> if the application name should be shown,
- * <tt>false</tt> - otherwise
- */
- private String getDownloadLink()
- {
- if (OSUtils.IS_WINDOWS)
- return "http://download.jitsi.org/jitsi/windows/";
- else if (OSUtils.IS_MAC)
- return "http://download.jitsi.org/jitsi/macosx/";
-
- return "http://download.jitsi.org";
- }
-
- @Override
- protected void close(boolean escaped) {}
-}
diff --git a/src/net/java/sip/communicator/plugin/branding/MacOSXAboutRegistration.java b/src/net/java/sip/communicator/plugin/branding/MacOSXAboutRegistration.java
index 22ce126..0648e4b 100644
--- a/src/net/java/sip/communicator/plugin/branding/MacOSXAboutRegistration.java
+++ b/src/net/java/sip/communicator/plugin/branding/MacOSXAboutRegistration.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,34 +15,34 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.branding;
-
-import com.apple.eawt.*;
-
-/**
- * @author Lubomir Marinov
- */
-public final class MacOSXAboutRegistration
-{
- /**
- * Show the about dialog on Mac OS X.
- *
- * @return true if the Mac OS X application is not null
- */
- public static boolean run()
- {
- Application application = Application.getApplication();
- if (application != null)
- {
- application.setAboutHandler(new AboutHandler()
- {
- public void handleAbout(AppEvent.AboutEvent aboutEvent)
- {
- AboutWindowPluginComponent.actionPerformed();
- }
- });
- return true;
- }
- return false;
- }
-}
+package net.java.sip.communicator.plugin.branding;
+
+import com.apple.eawt.*;
+
+/**
+ * @author Lubomir Marinov
+ */
+public final class MacOSXAboutRegistration
+{
+ /**
+ * Show the about dialog on Mac OS X.
+ *
+ * @return true if the Mac OS X application is not null
+ */
+ public static boolean run()
+ {
+ Application application = Application.getApplication();
+ if (application != null)
+ {
+ application.setAboutHandler(new AboutHandler()
+ {
+ public void handleAbout(AppEvent.AboutEvent aboutEvent)
+ {
+ AboutWindowPluginComponent.actionPerformed();
+ }
+ });
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/branding/StyledHTMLEditorPane.java b/src/net/java/sip/communicator/plugin/branding/StyledHTMLEditorPane.java
index 7eb02bc..d67050e 100644
--- a/src/net/java/sip/communicator/plugin/branding/StyledHTMLEditorPane.java
+++ b/src/net/java/sip/communicator/plugin/branding/StyledHTMLEditorPane.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,64 +15,64 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.branding;
-
-import java.io.*;
-
-import javax.swing.*;
-import javax.swing.text.*;
-import javax.swing.text.html.*;
-
-import net.java.sip.communicator.util.*;
-
-public class StyledHTMLEditorPane
- extends JEditorPane
-{
- private final Logger logger = Logger.getLogger(StyledHTMLEditorPane.class);
-
- private final HTMLDocument document;
-
- public StyledHTMLEditorPane()
- {
- this.setContentType("text/html");
-
- this.document
- = (HTMLDocument) this.getDocument();
-
- this.setDocument(document);
-
- Constants.loadSimpleStyle(document.getStyleSheet());
- }
-
- public void appendToEnd(String text)
- {
- Element root = document.getDefaultRootElement();
- try
- {
- document.insertAfterEnd(root
- .getElement(root.getElementCount() - 1), text);
- }
- catch (BadLocationException e)
- {
- logger.error("Insert in the HTMLDocument failed.", e);
- }
- catch (IOException e)
- {
- logger.error("Insert in the HTMLDocument failed.", e);
- }
- }
-
- public void insertAfterStart(String text)
- {
- Element root = this.document.getDefaultRootElement();
-
- try {
- this.document.insertBeforeStart(root
- .getElement(0), text);
- } catch (BadLocationException e) {
- logger.error("Insert in the HTMLDocument failed.", e);
- } catch (IOException e) {
- logger.error("Insert in the HTMLDocument failed.", e);
- }
- }
-}
+package net.java.sip.communicator.plugin.branding;
+
+import java.io.*;
+
+import javax.swing.*;
+import javax.swing.text.*;
+import javax.swing.text.html.*;
+
+import net.java.sip.communicator.util.*;
+
+public class StyledHTMLEditorPane
+ extends JEditorPane
+{
+ private final Logger logger = Logger.getLogger(StyledHTMLEditorPane.class);
+
+ private final HTMLDocument document;
+
+ public StyledHTMLEditorPane()
+ {
+ this.setContentType("text/html");
+
+ this.document
+ = (HTMLDocument) this.getDocument();
+
+ this.setDocument(document);
+
+ Constants.loadSimpleStyle(document.getStyleSheet());
+ }
+
+ public void appendToEnd(String text)
+ {
+ Element root = document.getDefaultRootElement();
+ try
+ {
+ document.insertAfterEnd(root
+ .getElement(root.getElementCount() - 1), text);
+ }
+ catch (BadLocationException e)
+ {
+ logger.error("Insert in the HTMLDocument failed.", e);
+ }
+ catch (IOException e)
+ {
+ logger.error("Insert in the HTMLDocument failed.", e);
+ }
+ }
+
+ public void insertAfterStart(String text)
+ {
+ Element root = this.document.getDefaultRootElement();
+
+ try {
+ this.document.insertBeforeStart(root
+ .getElement(0), text);
+ } catch (BadLocationException e) {
+ logger.error("Insert in the HTMLDocument failed.", e);
+ } catch (IOException e) {
+ logger.error("Insert in the HTMLDocument failed.", e);
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java b/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java
deleted file mode 100644
index 7cc78b8..0000000
--- a/src/net/java/sip/communicator/plugin/branding/WelcomeWindow.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.branding;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.awt.image.*;
-import java.io.*;
-
-import javax.imageio.*;
-import javax.swing.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The <tt>WelcomeWindow</tt> is actually the splash screen shown while the
- * application is loading. It displays the status of the loading process and
- * some general information about the version, licenses and contact details.
- *
- * @author Yana Stamcheva
- */
-public class WelcomeWindow extends JDialog
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private static final String APPLICATION_NAME
- = BrandingActivator.getResources()
- .getSettingsString("service.gui.APPLICATION_NAME");
-
- private static final int DEFAULT_TEXT_INDENT
- = BrandingActivator.getResources()
- .getSettingsInt("plugin.branding.SPLASH_SCREEN_TEXT_INDENT");
-
- private static final int PREFERRED_HEIGHT = 330;
-
- private static final int PREFERRED_WIDTH = 570;
-
- private final JLabel bundleLabel = new JLabel();
-
- /**
- * Constructor.
- */
- public WelcomeWindow()
- {
- JLabel titleLabel = new JLabel(APPLICATION_NAME);
-
- JLabel versionLabel = new JLabel(" "
- + System.getProperty("sip-communicator.version"));
-
- JTextArea logoArea = new JTextArea(
- BrandingActivator.getResources()
- .getI18NString("plugin.branding.LOGO_MESSAGE"));
-
- StyledHTMLEditorPane rightsArea = new StyledHTMLEditorPane();
-
- StyledHTMLEditorPane licenseArea = new StyledHTMLEditorPane();
-
- JPanel textPanel = new JPanel();
-
- Container mainPanel = new WindowBackground();
-
- this.setTitle(APPLICATION_NAME);
-
- this.setModal(false);
- this.setUndecorated(true);
-
- mainPanel.setLayout(new BorderLayout());
-
- textPanel.setPreferredSize(new Dimension(470, 280));
- textPanel.setLayout(new BoxLayout(textPanel, BoxLayout.Y_AXIS));
- textPanel
- .setBorder(BorderFactory.createEmptyBorder(15, 15, 0, 15));
- textPanel.setOpaque(false);
-
- this.initTitleLabel(titleLabel);
-
- this.initVersionLabel(versionLabel);
-
- this.initLogoArea(logoArea);
-
- this.initRightsArea(rightsArea);
-
- this.initLicenseArea(licenseArea);
-
- Component loadingPanel = initLoadingPanel();
-
- textPanel.add(titleLabel);
- textPanel.add(versionLabel);
- textPanel.add(logoArea);
- textPanel.add(rightsArea);
- textPanel.add(licenseArea);
-
- mainPanel.add(textPanel, BorderLayout.CENTER);
- mainPanel.add(loadingPanel, BorderLayout.SOUTH);
-
- this.getContentPane().add(mainPanel);
-
- this.setResizable(false);
-
- mainPanel.setPreferredSize(
- new Dimension(PREFERRED_WIDTH, PREFERRED_HEIGHT));
-
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- this.setLocation(screenSize.width / 2 - 527 / 2,
- screenSize.height / 2 - 305 / 2);
-
- this.initCloseActions();
- }
-
- /**
- * Initializes the title label.
- *
- * @param titleLabel the title label
- */
- private void initTitleLabel(JLabel titleLabel)
- {
- titleLabel.setFont(
- titleLabel.getFont().deriveFont(Font.BOLD, 28));
- titleLabel.setForeground(Constants.TITLE_COLOR);
- titleLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
-
- /**
- * Initializes the version label.
- *
- * @param versionLabel the version label
- */
- private void initVersionLabel(JLabel versionLabel)
- {
- versionLabel.setFont(
- versionLabel.getFont().deriveFont(Font.BOLD, 18));
- versionLabel.setForeground(Constants.TITLE_COLOR);
- versionLabel.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
-
- /**
- * Initializes the logo area.
- *
- * @param logoArea the logo area
- */
- private void initLogoArea(JTextArea logoArea)
- {
- int logoAreaFontSize = BrandingActivator.getResources().
- getSettingsInt("plugin.branding.ABOUT_LOGO_FONT_SIZE");
-
- logoArea.setFont(
- logoArea.getFont().deriveFont(Font.BOLD, logoAreaFontSize));
- logoArea.setForeground(Constants.TITLE_COLOR);
- logoArea.setOpaque(false);
- logoArea.setLineWrap(true);
- logoArea.setWrapStyleWord(true);
- logoArea.setEditable(false);
- logoArea.setPreferredSize(new Dimension(100, 20));
- logoArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- logoArea.setBorder(BorderFactory
- .createEmptyBorder(20, DEFAULT_TEXT_INDENT, 0, 0));
- }
-
- /**
- * Initializes the copyright area.
- *
- * @param rightsArea the copyright area.
- */
- private void initRightsArea(StyledHTMLEditorPane rightsArea)
- {
- rightsArea.setContentType("text/html");
- rightsArea.appendToEnd(
- BrandingActivator.getResources().getI18NString(
- "plugin.branding.WELCOME_MESSAGE",
- new String[]{
- Constants.TEXT_COLOR,
- APPLICATION_NAME,
- BrandingActivator.getResources()
- .getSettingsString("service.gui.APPLICATION_WEB_SITE")
- }));
-
- rightsArea.setPreferredSize(new Dimension(50, 50));
- rightsArea
- .setBorder(BorderFactory
- .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0));
- rightsArea.setOpaque(false);
- rightsArea.setEditable(false);
- rightsArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
-
- /**
- * Initializes the license area.
- *
- * @param licenseArea the license area.
- */
- private void initLicenseArea(StyledHTMLEditorPane licenseArea)
- {
- licenseArea.setContentType("text/html");
- licenseArea.appendToEnd(
- BrandingActivator.getResources().getI18NString(
- "plugin.branding.LICENSE",
- new String[]
- {
- Constants.TEXT_COLOR
- }));
-
- licenseArea.setPreferredSize(new Dimension(50, 20));
- licenseArea.setBorder(BorderFactory
- .createEmptyBorder(0, DEFAULT_TEXT_INDENT, 0, 0));
- licenseArea.setOpaque(false);
- licenseArea.setEditable(false);
- licenseArea.setAlignmentX(Component.RIGHT_ALIGNMENT);
- }
-
- private JPanel initLoadingPanel()
- {
- ResourceManagementService resources = BrandingActivator.getResources();
- JLabel loadingLabel
- = new JLabel(
- resources.getI18NString("plugin.branding.LOADING") + ": ");
- JPanel loadingPanel = new JPanel(new BorderLayout());
-
- this.bundleLabel.setFont(loadingLabel.getFont().deriveFont(Font.PLAIN));
-
- loadingPanel.setOpaque(false);
- loadingPanel.add(loadingLabel, BorderLayout.WEST);
- loadingPanel.add(bundleLabel, BorderLayout.CENTER);
-
- int loadingPanelBorder
- = resources
- .getSettingsInt("plugin.branding.LOADING_BUNDLE_PANEL_BORDER");
-
- loadingPanel.setBorder(
- BorderFactory.createEmptyBorder(loadingPanelBorder,
- loadingPanelBorder,
- loadingPanelBorder,
- loadingPanelBorder));
-
- int loadingPanelHeight
- = resources
- .getSettingsInt("plugin.branding.LOADING_BUNDLE_PANEL_HEIGHT");
-
- loadingPanel.setPreferredSize(
- new Dimension(PREFERRED_WIDTH, loadingPanelHeight));
-
- return loadingPanel;
- }
-
- /**
- * Initializes close actions on mouse click and esc key.
- */
- private void initCloseActions()
- {
- // Close the splash screen on simple click or Esc.
- this.getGlassPane().addMouseListener(new MouseAdapter()
- {
- @Override
- public void mouseClicked(MouseEvent e)
- {
- WelcomeWindow.this.close();
- }
- });
-
- this.getGlassPane().setVisible(true);
-
- ActionMap amap = this.getRootPane().getActionMap();
-
- amap.put("close", new CloseAction());
-
- InputMap imap = this.getRootPane().getInputMap(
- JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
-
- imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
- }
-
- /**
- * Disposes this window.
- */
- protected void close()
- {
- this.dispose();
- }
-
- /**
- * Sets the name of the currently loading bundle.
- *
- * @param bundleName the name of the bundle to display
- */
- public void setBundle(String bundleName)
- {
- bundleLabel.setText(bundleName);
-
- bundleLabel.revalidate();
- bundleLabel.getParent().repaint();
- }
-
- /**
- * The action invoked when user presses Escape key.
- */
- private class CloseAction extends UIAction
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- public void actionPerformed(ActionEvent e)
- {
- WelcomeWindow.this.close();
- }
- }
-
- /**
- * Constructs the window background in order to have a background image.
- */
- private static class WindowBackground
- extends JPanel
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private BufferedImage cache;
-
- private int cacheHeight;
-
- private int cacheWidth;
-
- private final Image image;
-
- public WindowBackground()
- {
- setOpaque(true);
-
- Image image = null;
- try
- {
- image =
- ImageIO.read(BrandingActivator.getResources().getImageURL(
- "plugin.branding.SPLASH_SCREEN_BACKGROUND"));
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- this.image = image;
-
- if (image != null)
- {
- setPreferredSize(new Dimension(image.getWidth(this), image
- .getHeight(this)));
- }
- }
-
- @Override
- protected void paintComponent(Graphics g)
- {
- super.paintComponent(g);
-
- g = g.create();
- try
- {
- internalPaintComponent(g);
- }
- finally
- {
- g.dispose();
- }
- }
-
- private void internalPaintComponent(Graphics g)
- {
- AntialiasingManager.activateAntialiasing(g);
-
- Graphics2D g2 = (Graphics2D) g;
-
- /*
- * Drawing an Image with a data layout and color model compatible
- * with this JPanel is magnitudes faster so create and use such an
- * Image from the original drawn by this instance.
- */
- int width = getWidth();
- int height = getHeight();
- boolean imageIsChanging = false;
- if ((cache == null) || (cacheWidth != width)
- || (cacheHeight != height))
- {
- cache =
- g2.getDeviceConfiguration().createCompatibleImage(width,
- height);
- cacheWidth = width;
- cacheHeight = height;
-
- Graphics2D cacheGraphics = cache.createGraphics();
- try
- {
- super.paintComponent(cacheGraphics);
-
- AntialiasingManager.activateAntialiasing(cacheGraphics);
-
- imageIsChanging =
- !cacheGraphics.drawImage(image, 0, 0, null);
-
- cacheGraphics.setColor(new Color(150, 150, 150));
- cacheGraphics.drawRoundRect(0, 0, width - 1, height - 1, 5,
- 5);
- }
- finally
- {
- cacheGraphics.dispose();
- }
- }
-
- g2.drawImage(cache, 0, 0, null);
-
- /*
- * Once the original Image drawn by this instance has been fully
- * loaded, we're free to use its "compatible" caching representation
- * for the purposes of optimized execution speed.
- */
- if (imageIsChanging)
- {
- cache = null;
- }
- }
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/busylampfield/BLFActivator.java b/src/net/java/sip/communicator/plugin/busylampfield/BLFActivator.java
index 036442b..94ea374 100644
--- a/src/net/java/sip/communicator/plugin/busylampfield/BLFActivator.java
+++ b/src/net/java/sip/communicator/plugin/busylampfield/BLFActivator.java
@@ -181,15 +181,11 @@ public class BLFActivator
}
else
{
- BLFContactSourceService css
- = new BLFContactSourceService(
+ BLFContactSourceService css = new BLFContactSourceService(
groupName, currentBLFGroups.size() + 1);
- serviceReg = (ServiceRegistration<ContactSourceService>)
- bundleContext.registerService(
- ContactSourceService.class.getName(),
- css,
- null);
+ serviceReg = bundleContext.registerService(
+ ContactSourceService.class, css, null);
currentBLFGroups.put(groupName, serviceReg);
css.addLine(line);
diff --git a/src/net/java/sip/communicator/plugin/certconfig/CertConfigEntryDialog.java b/src/net/java/sip/communicator/plugin/certconfig/CertConfigEntryDialog.java
index 278af62..b729b35 100644
--- a/src/net/java/sip/communicator/plugin/certconfig/CertConfigEntryDialog.java
+++ b/src/net/java/sip/communicator/plugin/certconfig/CertConfigEntryDialog.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,573 +15,573 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.certconfig;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-import java.lang.reflect.*;
-import java.security.*;
-import java.security.cert.*;
-import java.util.*;
-
-import javax.security.auth.callback.*;
-import javax.swing.*;
-import javax.swing.event.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.certificate.*;
-import net.java.sip.communicator.util.Logger;
-
-import org.jitsi.service.resources.*;
-import org.jitsi.util.*;
-
-/**
- * Dialog window to add/edit client certificate configuration entries.
- *
- * @author Ingo Bauersachs
- */
-public class CertConfigEntryDialog
- extends SIPCommDialog
- implements ActionListener, ItemListener, ChangeListener
-{
- // ------------------------------------------------------------------------
- // Fields and services
- // ------------------------------------------------------------------------
- private static final long serialVersionUID = 8361336563239745007L;
- private static final Logger logger = Logger
- .getLogger(CertConfigEntryDialog.class);
- private ResourceManagementService R = CertConfigActivator.R;
- private CertificateService cs = CertConfigActivator.getCertService();
- private CertificateConfigEntry entry;
- private boolean success = false;
-
- // ------------------------------------------------------------------------
- // GUI members
- // ------------------------------------------------------------------------
- private JButton cmdOk;
- private JButton cmdCancel;
- private JButton cmdBrowse;
- private JTextField txtDisplayName;
- private JTextField txtKeyStore;
- private JComboBox cboKeyStoreTypes;
- private JCheckBox chkSavePassword;
- private JPasswordField txtKeyStorePassword;
- private JComboBox cboAlias;
- private JButton cmdShowCert;
- private KeyStore keyStore;
-
- // ------------------------------------------------------------------------
- // Initialization
- // ------------------------------------------------------------------------
- /**
- * Constructor.
- *
- * @param e the <tt>CertificateConfigEntry</tt>
- */
- public CertConfigEntryDialog(CertificateConfigEntry e)
- {
- super(false);
- entry = e;
- initComponents();
- setPreferredSize(new Dimension(650, 270));
-
- try
- {
- if(entry.getKeyStore() != null)
- {
- txtKeyStorePassword.setText(entry.getKeyStorePassword());
- chkSavePassword.setSelected(entry.isSavePassword());
- cboKeyStoreTypes.setEnabled(true);
- cboKeyStoreTypes.setSelectedItem(entry.getKeyStoreType());
- if(keyStore == null)
- keyStore = loadKeyStore();
- cboAlias.setEnabled(true);
- loadAliases();
- cboAlias.setSelectedItem(entry.getAlias());
- }
- }
- catch (KeyStoreException ex)
- {
- logger.error("Unable to load all data", ex);
- showGenericError("plugin.certconfig.KEYSTORE_EXCEPTION", ex);
- }
- catch (ProviderException ex)
- {
- logger.error("Unable to load all data", ex);
- showGenericError("plugin.certconfig.KEYSTORE_EXCEPTION", ex);
- }
- }
-
- private void initComponents()
- {
- setTitle(R.getI18NString("plugin.certconfig.EDIT_ENTRY"));
- setLayout(new BorderLayout());
- JPanel fields = new TransparentPanel();
- fields.setLayout(new GridBagLayout());
-
- JLabel lblDisplayName = new JLabel();
- lblDisplayName.setText(R.getI18NString("service.gui.DISPLAY_NAME"));
- txtDisplayName = new JTextField();
- txtDisplayName.setText(entry.getDisplayName());
-
- JLabel lblKeyStore = new JLabel();
- lblKeyStore.setText(R.getI18NString("plugin.certconfig.KEYSTORE"));
- txtKeyStore = new JTextField();
- txtKeyStore.setText(entry.getKeyStore());
- txtKeyStore.setEditable(false);
-
- cmdBrowse = new JButton();
- cmdBrowse.setText(R.getI18NString("service.gui.BROWSE"));
- cmdBrowse.addActionListener(this);
-
- JLabel lblKeyStorePassword = new JLabel();
- lblKeyStorePassword.setText(
- R.getI18NString("plugin.certconfig.KEYSTORE_PASSWORD"));
- txtKeyStorePassword = new JPasswordField();
- txtKeyStorePassword.setEditable(false);
-
- chkSavePassword = new SIPCommCheckBox();
- chkSavePassword.setText(
- R.getI18NString("service.gui.REMEMBER_PASSWORD"));
- chkSavePassword.addChangeListener(this);
- chkSavePassword.setEnabled(false);
-
- JLabel lblKeyStoreType = new JLabel();
- lblKeyStoreType.setText(
- R.getI18NString("plugin.certconfig.KEYSTORE_TYPE"));
- cboKeyStoreTypes =
- new JComboBox(cs.getSupportedKeyStoreTypes().toArray());
- cboKeyStoreTypes.addItemListener(this);
- cboKeyStoreTypes.setEnabled(false);
-
- JLabel lblAlias = new JLabel();
- lblAlias.setText(R.getI18NString("plugin.certconfig.ALIAS"));
- cboAlias = new JComboBox();
- cboAlias.addItemListener(this);
- cboAlias.setEnabled(false);
-
- cmdShowCert = new JButton();
- cmdShowCert.setText(R.getI18NString("service.gui.SHOW_CERT") + "...");
- cmdShowCert.addActionListener(this);
- cmdShowCert.setEnabled(false);
-
- cmdCancel = new JButton();
- cmdCancel.setText(R.getI18NString("service.gui.CANCEL"));
- cmdCancel.addActionListener(this);
-
- cmdOk = new JButton();
- cmdOk.setText(R.getI18NString("service.gui.OK"));
- cmdOk.addActionListener(this);
- cmdOk.setPreferredSize(cmdCancel.getPreferredSize());
-
- TransparentPanel buttons = new TransparentPanel();
- buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
- buttons.add(cmdOk);
- buttons.add(cmdCancel);
-
- GridBagConstraints first = new GridBagConstraints();
- first.gridx = 0;
- first.gridy = 0;
- first.weightx = 0;
- first.anchor = GridBagConstraints.LINE_START;
- first.gridwidth = 1;
- first.insets = new Insets(2,4,2,4);
- first.fill = GridBagConstraints.HORIZONTAL;
-
- GridBagConstraints second = new GridBagConstraints();
- second.gridx = 1;
- second.gridy = 0;
- second.weightx = 2;
- second.anchor = GridBagConstraints.LINE_START;
- second.gridwidth = 1; //GridBagConstraints.REMAINDER;
- second.insets = first.insets;
- second.fill = GridBagConstraints.HORIZONTAL;
-
- GridBagConstraints third = new GridBagConstraints();
- third.gridx = 2;
- third.gridy = 0;
- third.weightx = 1;
- third.anchor = GridBagConstraints.LINE_END;
- third.gridwidth = 1;
- third.insets = first.insets;
- third.fill = GridBagConstraints.HORIZONTAL;
-
- fields.add(lblDisplayName, first);
- fields.add(txtDisplayName, second);
-
- first.gridy = second.gridy = ++third.gridy;
- fields.add(lblKeyStore, first);
- fields.add(txtKeyStore, second);
- fields.add(cmdBrowse, third);
-
- first.gridy = second.gridy = ++third.gridy;
- fields.add(lblKeyStoreType, first);
- fields.add(cboKeyStoreTypes, second);
-
- first.gridy = second.gridy = ++third.gridy;
- fields.add(lblKeyStorePassword, first);
- fields.add(txtKeyStorePassword, second);
-
- first.gridy = second.gridy = ++third.gridy;
- fields.add(chkSavePassword, second);
-
- first.gridy = second.gridy = ++third.gridy;
- fields.add(lblAlias, first);
- fields.add(cboAlias, second);
- fields.add(cmdShowCert, third);
-
- add(fields, BorderLayout.CENTER);
- add(buttons, BorderLayout.SOUTH);
- }
-
- // ------------------------------------------------------------------------
- // Event handling
- // ------------------------------------------------------------------------
- @Override
- protected void close(boolean escaped)
- {
- cmdCancel.doClick();
- }
-
- public void actionPerformed(ActionEvent e)
- {
- if(e.getSource() == cmdOk)
- {
- if(cboAlias.getSelectedItem() == null
- || StringUtils.isNullOrEmpty(txtDisplayName.getText())
- || StringUtils.isNullOrEmpty(txtKeyStore.getText()))
- {
- JOptionPane.showMessageDialog(this,
- R.getI18NString("plugin.certconfig.INCOMPLETE"),
- R.getI18NString("service.gui.ERROR"),
- JOptionPane.ERROR_MESSAGE);
- return;
- }
- entry.setAlias(cboAlias.getSelectedItem().toString());
- entry.setDisplayName(txtDisplayName.getText());
- entry.setSavePassword(chkSavePassword.isSelected());
- entry.setKeyStorePassword(
- new String(txtKeyStorePassword.getPassword()));
- entry.setKeyStoreType(
- (KeyStoreType) cboKeyStoreTypes.getSelectedItem());
- entry.setKeyStore(txtKeyStore.getText());
- success = true;
- dispose();
- }
- if(e.getSource() == cmdCancel)
- {
- dispose();
- }
- if(e.getSource() == cmdBrowse)
- {
- browseKeyStore();
- }
- if(e.getSource() == cmdShowCert)
- {
- showSelectedCertificate();
- }
- }
-
- private void showSelectedCertificate()
- {
- try
- {
- @SuppressWarnings("serial")
- SIPCommDialog dlg = new SIPCommDialog(this, false)
- {
- private JButton cmdClose;
- {
- setTitle(cboAlias.getSelectedItem().toString());
- setLayout(new BorderLayout());
- final JScrollPane certScroll =
- new JScrollPane(new X509CertificatePanel(
- (X509Certificate) keyStore.getCertificate(cboAlias
- .getSelectedItem().toString())));
- certScroll.setPreferredSize(new Dimension(600, 300));
- certScroll.getVerticalScrollBar().setValue(0);
- add(certScroll, BorderLayout.CENTER);
-
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- certScroll.getVerticalScrollBar().setValue(0);
- }
- });
-
- cmdClose = new JButton();
- cmdClose.setText(R.getI18NString("service.gui.CLOSE"));
- cmdClose.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- dispose();
- }
- });
-
- TransparentPanel buttons =
- new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
- buttons.add(cmdClose);
- add(buttons, BorderLayout.SOUTH);
-
- setLocationRelativeTo(cmdShowCert);
- }
-
- @Override
- protected void close(boolean escaped)
- {
- cmdClose.doClick();
- }
- };
- dlg.setModal(true);
- dlg.setVisible(true);
- }
- catch (KeyStoreException e1)
- {
- logger.error("Unable to show the selected certificate", e1);
- showGenericError("plugin.certconfig.SHOW_CERT_EXCEPTION", e1);
- }
- }
-
- /**
- * Opens a FileChoserDialog to let the user pick a keystore and tries to
- * auto-detect the keystore type using the file extension
- */
- private void browseKeyStore()
- {
- SipCommFileChooser dlg =
- GenericFileDialog.create(null,
- R.getI18NString("plugin.certconfig.BROWSE_KEYSTORE"),
- SipCommFileChooser.LOAD_FILE_OPERATION);
- dlg.setSelectionMode(SipCommFileChooser.FILES_ONLY);
- dlg.addFilter(new SipCommFileFilter()
- {
- @Override
- public String getDescription()
- {
- return R
- .getI18NString("plugin.certconfig.FILE_TYPE_DESCRIPTION");
- }
-
- @Override
- public boolean accept(File f)
- {
- for(KeyStoreType kt : cs.getSupportedKeyStoreTypes())
- for(String ext : kt.getFileExtensions())
- if(f.getName().endsWith(ext))
- return true;
-
- return false;
- }
- });
- File f = dlg.getFileFromDialog();
- if(f != null)
- {
- cboKeyStoreTypes.setEnabled(true);
- cboKeyStoreTypes.setSelectedItem(null);
- cboAlias.setEnabled(true);
-
- txtKeyStore.setText(f.getAbsolutePath());
- for(KeyStoreType kt: cs.getSupportedKeyStoreTypes())
- for(String ext : kt.getFileExtensions())
- if(f.getName().endsWith(ext))
- cboKeyStoreTypes.setSelectedItem(kt);
- }
- }
-
- /**
- * Open the keystore selected by the user. If the type is set as PKCS#11,
- * the file is loaded as a provider. If the store is protected by a
- * password, the user is being asked by an authentication dialog.
- *
- * @return The loaded keystore
- * @throws KeyStoreException when something goes wrong
- */
- private KeyStore loadKeyStore() throws KeyStoreException
- {
- final File f = new File(txtKeyStore.getText());
- final KeyStoreType kt =
- (KeyStoreType) cboKeyStoreTypes.getSelectedItem();
- if("PKCS11".equals(kt.getName()))
- {
- String config =
- "name=" + f.getName() + "\nlibrary=" + f.getAbsoluteFile();
- try
- {
- Class<?> pkcs11c =
- Class.forName("sun.security.pkcs11.SunPKCS11");
- Constructor<?> c = pkcs11c.getConstructor(InputStream.class);
- Provider p =
- (Provider) c.newInstance(new ByteArrayInputStream(config
- .getBytes()));
- Security.insertProviderAt(p, 0);
- }
- catch (Exception e)
- {
- logger.error("Tried to access the PKCS11 provider on an "
- + "unsupported platform or the load failed", e);
- }
- }
- KeyStore.Builder ksBuilder = KeyStore.Builder.newInstance(
- kt.getName(),
- null,
- f,
- new KeyStore.CallbackHandlerProtection(new CallbackHandler()
- {
- public void handle(Callback[] callbacks)
- throws IOException,
- UnsupportedCallbackException
- {
- for(Callback cb : callbacks)
- {
- if(!(cb instanceof PasswordCallback))
- throw new UnsupportedCallbackException(cb);
- PasswordCallback pwcb = (PasswordCallback)cb;
- if(
- (
- txtKeyStorePassword.getPassword() != null
- && txtKeyStorePassword.getPassword().length>0
- )
- || chkSavePassword.isSelected())
- {
- pwcb.setPassword(txtKeyStorePassword.getPassword());
- return;
- }
- AuthenticationWindow aw = new AuthenticationWindow(
- CertConfigEntryDialog.this,
- f.getName(),
- null,
- kt.getName(),
- false,
- null
- );
- aw.setAllowSavePassword(!"PKCS11".equals(kt.getName()));
- aw.setVisible(true);
- if(!aw.isCanceled())
- {
- pwcb.setPassword(aw.getPassword());
- if (!"PKCS11".equals(kt.getName())
- && aw.isRememberPassword())
- {
- txtKeyStorePassword.setText(new String(aw
- .getPassword()));
- }
- chkSavePassword.setSelected(aw
- .isRememberPassword());
- }
- else
- throw new IOException("User cancel");
- }
- }
- }));
- return ksBuilder.getKeyStore();
- }
-
- /**
- * Load the certificate entry aliases from the chosen keystore.
- */
- private void loadAliases()
- {
- String currentDisplayName = txtDisplayName.getText();
- String currentAlias =
- cboAlias.getSelectedItem() == null ? null : cboAlias
- .getSelectedItem().toString();
- try
- {
- cboAlias.removeAllItems();
- Enumeration<String> e = keyStore.aliases();
- while(e.hasMoreElements())
- {
- cboAlias.addItem(e.nextElement());
- }
- // if the display name is empty or identical to the alias, set it
- // to the alias of the newly selected cert
- if(
- (
- StringUtils.isNullOrEmpty(currentDisplayName)
- || (
- currentDisplayName != null
- && currentDisplayName.equals(currentAlias)
- )
- )
- && cboAlias.getSelectedItem() != null)
- {
- txtDisplayName.setText(cboAlias.getSelectedItem().toString());
- }
-
- }
- catch (KeyStoreException e)
- {
- cboAlias.removeAllItems();
- logger.error("Unable to obtain aliases from keystore", e);
- showGenericError("plugin.certconfig.ALIAS_LOAD_EXCEPTION", e);
- }
- }
-
- private void showGenericError(String msg, Throwable e)
- {
- JOptionPane.showMessageDialog(
- this,
- R.getI18NString(msg, new String[]{e.getMessage()}),
- R.getI18NString("service.gui.ERROR"),
- JOptionPane.ERROR_MESSAGE
- );
- }
-
- /**
- * Show this dialog.
- *
- * @return true if OK has been pressed, false otherwise
- */
- public boolean showDialog()
- {
- setModal(true);
- setVisible(true);
- setVisible(false);
- return success;
- }
-
- public void itemStateChanged(ItemEvent e)
- {
- if(e.getStateChange() != ItemEvent.SELECTED)
- return;
- if(e.getSource() == cboKeyStoreTypes)
- {
- KeyStoreType kt = (KeyStoreType)cboKeyStoreTypes.getSelectedItem();
- if(kt == null)
- return;
- try
- {
- if(!"PKCS11".equals(kt.getName()))
- chkSavePassword.setEnabled(true);
- txtKeyStorePassword.setEditable(kt.hasKeyStorePassword()
- && chkSavePassword.isSelected());
-
- keyStore = loadKeyStore();
- loadAliases();
- }
- catch (KeyStoreException ex)
- {
- cboAlias.removeAllItems();
- showGenericError("plugin.certconfig.INVALID_KEYSTORE_TYPE", ex);
- }
- }
- if(e.getSource() == cboAlias)
- {
- cmdShowCert.setEnabled(cboAlias.getSelectedItem() != null);
- }
- }
-
- public void stateChanged(ChangeEvent e)
- {
- if(e.getSource() == chkSavePassword)
- {
- txtKeyStorePassword.setEditable(
- chkSavePassword.isSelected()
- && ((KeyStoreType) cboKeyStoreTypes.getSelectedItem())
- .hasKeyStorePassword()
- );
- }
- }
-}
+package net.java.sip.communicator.plugin.certconfig;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import java.lang.reflect.*;
+import java.security.*;
+import java.security.cert.*;
+import java.util.*;
+
+import javax.security.auth.callback.*;
+import javax.swing.*;
+import javax.swing.event.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.certificate.*;
+import net.java.sip.communicator.util.Logger;
+
+import org.jitsi.service.resources.*;
+import org.jitsi.util.*;
+
+/**
+ * Dialog window to add/edit client certificate configuration entries.
+ *
+ * @author Ingo Bauersachs
+ */
+public class CertConfigEntryDialog
+ extends SIPCommDialog
+ implements ActionListener, ItemListener, ChangeListener
+{
+ // ------------------------------------------------------------------------
+ // Fields and services
+ // ------------------------------------------------------------------------
+ private static final long serialVersionUID = 8361336563239745007L;
+ private static final Logger logger = Logger
+ .getLogger(CertConfigEntryDialog.class);
+ private ResourceManagementService R = CertConfigActivator.R;
+ private CertificateService cs = CertConfigActivator.getCertService();
+ private CertificateConfigEntry entry;
+ private boolean success = false;
+
+ // ------------------------------------------------------------------------
+ // GUI members
+ // ------------------------------------------------------------------------
+ private JButton cmdOk;
+ private JButton cmdCancel;
+ private JButton cmdBrowse;
+ private JTextField txtDisplayName;
+ private JTextField txtKeyStore;
+ private JComboBox cboKeyStoreTypes;
+ private JCheckBox chkSavePassword;
+ private JPasswordField txtKeyStorePassword;
+ private JComboBox cboAlias;
+ private JButton cmdShowCert;
+ private KeyStore keyStore;
+
+ // ------------------------------------------------------------------------
+ // Initialization
+ // ------------------------------------------------------------------------
+ /**
+ * Constructor.
+ *
+ * @param e the <tt>CertificateConfigEntry</tt>
+ */
+ public CertConfigEntryDialog(CertificateConfigEntry e)
+ {
+ super(false);
+ entry = e;
+ initComponents();
+ setPreferredSize(new Dimension(650, 270));
+
+ try
+ {
+ if(entry.getKeyStore() != null)
+ {
+ txtKeyStorePassword.setText(entry.getKeyStorePassword());
+ chkSavePassword.setSelected(entry.isSavePassword());
+ cboKeyStoreTypes.setEnabled(true);
+ cboKeyStoreTypes.setSelectedItem(entry.getKeyStoreType());
+ if(keyStore == null)
+ keyStore = loadKeyStore();
+ cboAlias.setEnabled(true);
+ loadAliases();
+ cboAlias.setSelectedItem(entry.getAlias());
+ }
+ }
+ catch (KeyStoreException ex)
+ {
+ logger.error("Unable to load all data", ex);
+ showGenericError("plugin.certconfig.KEYSTORE_EXCEPTION", ex);
+ }
+ catch (ProviderException ex)
+ {
+ logger.error("Unable to load all data", ex);
+ showGenericError("plugin.certconfig.KEYSTORE_EXCEPTION", ex);
+ }
+ }
+
+ private void initComponents()
+ {
+ setTitle(R.getI18NString("plugin.certconfig.EDIT_ENTRY"));
+ setLayout(new BorderLayout());
+ JPanel fields = new TransparentPanel();
+ fields.setLayout(new GridBagLayout());
+
+ JLabel lblDisplayName = new JLabel();
+ lblDisplayName.setText(R.getI18NString("service.gui.DISPLAY_NAME"));
+ txtDisplayName = new JTextField();
+ txtDisplayName.setText(entry.getDisplayName());
+
+ JLabel lblKeyStore = new JLabel();
+ lblKeyStore.setText(R.getI18NString("plugin.certconfig.KEYSTORE"));
+ txtKeyStore = new JTextField();
+ txtKeyStore.setText(entry.getKeyStore());
+ txtKeyStore.setEditable(false);
+
+ cmdBrowse = new JButton();
+ cmdBrowse.setText(R.getI18NString("service.gui.BROWSE"));
+ cmdBrowse.addActionListener(this);
+
+ JLabel lblKeyStorePassword = new JLabel();
+ lblKeyStorePassword.setText(
+ R.getI18NString("plugin.certconfig.KEYSTORE_PASSWORD"));
+ txtKeyStorePassword = new JPasswordField();
+ txtKeyStorePassword.setEditable(false);
+
+ chkSavePassword = new SIPCommCheckBox();
+ chkSavePassword.setText(
+ R.getI18NString("service.gui.REMEMBER_PASSWORD"));
+ chkSavePassword.addChangeListener(this);
+ chkSavePassword.setEnabled(false);
+
+ JLabel lblKeyStoreType = new JLabel();
+ lblKeyStoreType.setText(
+ R.getI18NString("plugin.certconfig.KEYSTORE_TYPE"));
+ cboKeyStoreTypes =
+ new JComboBox(cs.getSupportedKeyStoreTypes().toArray());
+ cboKeyStoreTypes.addItemListener(this);
+ cboKeyStoreTypes.setEnabled(false);
+
+ JLabel lblAlias = new JLabel();
+ lblAlias.setText(R.getI18NString("plugin.certconfig.ALIAS"));
+ cboAlias = new JComboBox();
+ cboAlias.addItemListener(this);
+ cboAlias.setEnabled(false);
+
+ cmdShowCert = new JButton();
+ cmdShowCert.setText(R.getI18NString("service.gui.SHOW_CERT") + "...");
+ cmdShowCert.addActionListener(this);
+ cmdShowCert.setEnabled(false);
+
+ cmdCancel = new JButton();
+ cmdCancel.setText(R.getI18NString("service.gui.CANCEL"));
+ cmdCancel.addActionListener(this);
+
+ cmdOk = new JButton();
+ cmdOk.setText(R.getI18NString("service.gui.OK"));
+ cmdOk.addActionListener(this);
+ cmdOk.setPreferredSize(cmdCancel.getPreferredSize());
+
+ TransparentPanel buttons = new TransparentPanel();
+ buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
+ buttons.add(cmdOk);
+ buttons.add(cmdCancel);
+
+ GridBagConstraints first = new GridBagConstraints();
+ first.gridx = 0;
+ first.gridy = 0;
+ first.weightx = 0;
+ first.anchor = GridBagConstraints.LINE_START;
+ first.gridwidth = 1;
+ first.insets = new Insets(2,4,2,4);
+ first.fill = GridBagConstraints.HORIZONTAL;
+
+ GridBagConstraints second = new GridBagConstraints();
+ second.gridx = 1;
+ second.gridy = 0;
+ second.weightx = 2;
+ second.anchor = GridBagConstraints.LINE_START;
+ second.gridwidth = 1; //GridBagConstraints.REMAINDER;
+ second.insets = first.insets;
+ second.fill = GridBagConstraints.HORIZONTAL;
+
+ GridBagConstraints third = new GridBagConstraints();
+ third.gridx = 2;
+ third.gridy = 0;
+ third.weightx = 1;
+ third.anchor = GridBagConstraints.LINE_END;
+ third.gridwidth = 1;
+ third.insets = first.insets;
+ third.fill = GridBagConstraints.HORIZONTAL;
+
+ fields.add(lblDisplayName, first);
+ fields.add(txtDisplayName, second);
+
+ first.gridy = second.gridy = ++third.gridy;
+ fields.add(lblKeyStore, first);
+ fields.add(txtKeyStore, second);
+ fields.add(cmdBrowse, third);
+
+ first.gridy = second.gridy = ++third.gridy;
+ fields.add(lblKeyStoreType, first);
+ fields.add(cboKeyStoreTypes, second);
+
+ first.gridy = second.gridy = ++third.gridy;
+ fields.add(lblKeyStorePassword, first);
+ fields.add(txtKeyStorePassword, second);
+
+ first.gridy = second.gridy = ++third.gridy;
+ fields.add(chkSavePassword, second);
+
+ first.gridy = second.gridy = ++third.gridy;
+ fields.add(lblAlias, first);
+ fields.add(cboAlias, second);
+ fields.add(cmdShowCert, third);
+
+ add(fields, BorderLayout.CENTER);
+ add(buttons, BorderLayout.SOUTH);
+ }
+
+ // ------------------------------------------------------------------------
+ // Event handling
+ // ------------------------------------------------------------------------
+ @Override
+ protected void close(boolean escaped)
+ {
+ cmdCancel.doClick();
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if(e.getSource() == cmdOk)
+ {
+ if(cboAlias.getSelectedItem() == null
+ || StringUtils.isNullOrEmpty(txtDisplayName.getText())
+ || StringUtils.isNullOrEmpty(txtKeyStore.getText()))
+ {
+ JOptionPane.showMessageDialog(this,
+ R.getI18NString("plugin.certconfig.INCOMPLETE"),
+ R.getI18NString("service.gui.ERROR"),
+ JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+ entry.setAlias(cboAlias.getSelectedItem().toString());
+ entry.setDisplayName(txtDisplayName.getText());
+ entry.setSavePassword(chkSavePassword.isSelected());
+ entry.setKeyStorePassword(
+ new String(txtKeyStorePassword.getPassword()));
+ entry.setKeyStoreType(
+ (KeyStoreType) cboKeyStoreTypes.getSelectedItem());
+ entry.setKeyStore(txtKeyStore.getText());
+ success = true;
+ dispose();
+ }
+ if(e.getSource() == cmdCancel)
+ {
+ dispose();
+ }
+ if(e.getSource() == cmdBrowse)
+ {
+ browseKeyStore();
+ }
+ if(e.getSource() == cmdShowCert)
+ {
+ showSelectedCertificate();
+ }
+ }
+
+ private void showSelectedCertificate()
+ {
+ try
+ {
+ @SuppressWarnings("serial")
+ SIPCommDialog dlg = new SIPCommDialog(this, false)
+ {
+ private JButton cmdClose;
+ {
+ setTitle(cboAlias.getSelectedItem().toString());
+ setLayout(new BorderLayout());
+ final JScrollPane certScroll =
+ new JScrollPane(new X509CertificatePanel(
+ (X509Certificate) keyStore.getCertificate(cboAlias
+ .getSelectedItem().toString())));
+ certScroll.setPreferredSize(new Dimension(600, 300));
+ certScroll.getVerticalScrollBar().setValue(0);
+ add(certScroll, BorderLayout.CENTER);
+
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ certScroll.getVerticalScrollBar().setValue(0);
+ }
+ });
+
+ cmdClose = new JButton();
+ cmdClose.setText(R.getI18NString("service.gui.CLOSE"));
+ cmdClose.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ dispose();
+ }
+ });
+
+ TransparentPanel buttons =
+ new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
+ buttons.add(cmdClose);
+ add(buttons, BorderLayout.SOUTH);
+
+ setLocationRelativeTo(cmdShowCert);
+ }
+
+ @Override
+ protected void close(boolean escaped)
+ {
+ cmdClose.doClick();
+ }
+ };
+ dlg.setModal(true);
+ dlg.setVisible(true);
+ }
+ catch (KeyStoreException e1)
+ {
+ logger.error("Unable to show the selected certificate", e1);
+ showGenericError("plugin.certconfig.SHOW_CERT_EXCEPTION", e1);
+ }
+ }
+
+ /**
+ * Opens a FileChoserDialog to let the user pick a keystore and tries to
+ * auto-detect the keystore type using the file extension
+ */
+ private void browseKeyStore()
+ {
+ SipCommFileChooser dlg =
+ GenericFileDialog.create(null,
+ R.getI18NString("plugin.certconfig.BROWSE_KEYSTORE"),
+ SipCommFileChooser.LOAD_FILE_OPERATION);
+ dlg.setSelectionMode(SipCommFileChooser.FILES_ONLY);
+ dlg.addFilter(new SipCommFileFilter()
+ {
+ @Override
+ public String getDescription()
+ {
+ return R
+ .getI18NString("plugin.certconfig.FILE_TYPE_DESCRIPTION");
+ }
+
+ @Override
+ public boolean accept(File f)
+ {
+ for(KeyStoreType kt : cs.getSupportedKeyStoreTypes())
+ for(String ext : kt.getFileExtensions())
+ if(f.getName().endsWith(ext))
+ return true;
+
+ return false;
+ }
+ });
+ File f = dlg.getFileFromDialog();
+ if(f != null)
+ {
+ cboKeyStoreTypes.setEnabled(true);
+ cboKeyStoreTypes.setSelectedItem(null);
+ cboAlias.setEnabled(true);
+
+ txtKeyStore.setText(f.getAbsolutePath());
+ for(KeyStoreType kt: cs.getSupportedKeyStoreTypes())
+ for(String ext : kt.getFileExtensions())
+ if(f.getName().endsWith(ext))
+ cboKeyStoreTypes.setSelectedItem(kt);
+ }
+ }
+
+ /**
+ * Open the keystore selected by the user. If the type is set as PKCS#11,
+ * the file is loaded as a provider. If the store is protected by a
+ * password, the user is being asked by an authentication dialog.
+ *
+ * @return The loaded keystore
+ * @throws KeyStoreException when something goes wrong
+ */
+ private KeyStore loadKeyStore() throws KeyStoreException
+ {
+ final File f = new File(txtKeyStore.getText());
+ final KeyStoreType kt =
+ (KeyStoreType) cboKeyStoreTypes.getSelectedItem();
+ if("PKCS11".equals(kt.getName()))
+ {
+ String config =
+ "name=" + f.getName() + "\nlibrary=" + f.getAbsoluteFile();
+ try
+ {
+ Class<?> pkcs11c =
+ Class.forName("sun.security.pkcs11.SunPKCS11");
+ Constructor<?> c = pkcs11c.getConstructor(InputStream.class);
+ Provider p =
+ (Provider) c.newInstance(new ByteArrayInputStream(config
+ .getBytes()));
+ Security.insertProviderAt(p, 0);
+ }
+ catch (Exception e)
+ {
+ logger.error("Tried to access the PKCS11 provider on an "
+ + "unsupported platform or the load failed", e);
+ }
+ }
+ KeyStore.Builder ksBuilder = KeyStore.Builder.newInstance(
+ kt.getName(),
+ null,
+ f,
+ new KeyStore.CallbackHandlerProtection(new CallbackHandler()
+ {
+ public void handle(Callback[] callbacks)
+ throws IOException,
+ UnsupportedCallbackException
+ {
+ for(Callback cb : callbacks)
+ {
+ if(!(cb instanceof PasswordCallback))
+ throw new UnsupportedCallbackException(cb);
+ PasswordCallback pwcb = (PasswordCallback)cb;
+ if(
+ (
+ txtKeyStorePassword.getPassword() != null
+ && txtKeyStorePassword.getPassword().length>0
+ )
+ || chkSavePassword.isSelected())
+ {
+ pwcb.setPassword(txtKeyStorePassword.getPassword());
+ return;
+ }
+ AuthenticationWindow aw = new AuthenticationWindow(
+ CertConfigEntryDialog.this,
+ f.getName(),
+ null,
+ kt.getName(),
+ false,
+ null
+ );
+ aw.setAllowSavePassword(!"PKCS11".equals(kt.getName()));
+ aw.setVisible(true);
+ if(!aw.isCanceled())
+ {
+ pwcb.setPassword(aw.getPassword());
+ if (!"PKCS11".equals(kt.getName())
+ && aw.isRememberPassword())
+ {
+ txtKeyStorePassword.setText(new String(aw
+ .getPassword()));
+ }
+ chkSavePassword.setSelected(aw
+ .isRememberPassword());
+ }
+ else
+ throw new IOException("User cancel");
+ }
+ }
+ }));
+ return ksBuilder.getKeyStore();
+ }
+
+ /**
+ * Load the certificate entry aliases from the chosen keystore.
+ */
+ private void loadAliases()
+ {
+ String currentDisplayName = txtDisplayName.getText();
+ String currentAlias =
+ cboAlias.getSelectedItem() == null ? null : cboAlias
+ .getSelectedItem().toString();
+ try
+ {
+ cboAlias.removeAllItems();
+ Enumeration<String> e = keyStore.aliases();
+ while(e.hasMoreElements())
+ {
+ cboAlias.addItem(e.nextElement());
+ }
+ // if the display name is empty or identical to the alias, set it
+ // to the alias of the newly selected cert
+ if(
+ (
+ StringUtils.isNullOrEmpty(currentDisplayName)
+ || (
+ currentDisplayName != null
+ && currentDisplayName.equals(currentAlias)
+ )
+ )
+ && cboAlias.getSelectedItem() != null)
+ {
+ txtDisplayName.setText(cboAlias.getSelectedItem().toString());
+ }
+
+ }
+ catch (KeyStoreException e)
+ {
+ cboAlias.removeAllItems();
+ logger.error("Unable to obtain aliases from keystore", e);
+ showGenericError("plugin.certconfig.ALIAS_LOAD_EXCEPTION", e);
+ }
+ }
+
+ private void showGenericError(String msg, Throwable e)
+ {
+ JOptionPane.showMessageDialog(
+ this,
+ R.getI18NString(msg, new String[]{e.getMessage()}),
+ R.getI18NString("service.gui.ERROR"),
+ JOptionPane.ERROR_MESSAGE
+ );
+ }
+
+ /**
+ * Show this dialog.
+ *
+ * @return true if OK has been pressed, false otherwise
+ */
+ public boolean showDialog()
+ {
+ setModal(true);
+ setVisible(true);
+ setVisible(false);
+ return success;
+ }
+
+ public void itemStateChanged(ItemEvent e)
+ {
+ if(e.getStateChange() != ItemEvent.SELECTED)
+ return;
+ if(e.getSource() == cboKeyStoreTypes)
+ {
+ KeyStoreType kt = (KeyStoreType)cboKeyStoreTypes.getSelectedItem();
+ if(kt == null)
+ return;
+ try
+ {
+ if(!"PKCS11".equals(kt.getName()))
+ chkSavePassword.setEnabled(true);
+ txtKeyStorePassword.setEditable(kt.hasKeyStorePassword()
+ && chkSavePassword.isSelected());
+
+ keyStore = loadKeyStore();
+ loadAliases();
+ }
+ catch (KeyStoreException ex)
+ {
+ cboAlias.removeAllItems();
+ showGenericError("plugin.certconfig.INVALID_KEYSTORE_TYPE", ex);
+ }
+ }
+ if(e.getSource() == cboAlias)
+ {
+ cmdShowCert.setEnabled(cboAlias.getSelectedItem() != null);
+ }
+ }
+
+ public void stateChanged(ChangeEvent e)
+ {
+ if(e.getSource() == chkSavePassword)
+ {
+ txtKeyStorePassword.setEditable(
+ chkSavePassword.isSelected()
+ && ((KeyStoreType) cboKeyStoreTypes.getSelectedItem())
+ .hasKeyStorePassword()
+ );
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/certconfig/CertConfigPanel.java b/src/net/java/sip/communicator/plugin/certconfig/CertConfigPanel.java
index 57c7606..6f7bf67 100644
--- a/src/net/java/sip/communicator/plugin/certconfig/CertConfigPanel.java
+++ b/src/net/java/sip/communicator/plugin/certconfig/CertConfigPanel.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,267 +15,267 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.certconfig;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.security.*;
-
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.event.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.certificate.*;
-import net.java.sip.communicator.service.gui.*;
-
-import org.jitsi.service.resources.*;
-import org.jitsi.util.*;
-
-/**
- * Advanced configuration form to define client TLS certificate templates.
- *
- * @author Ingo Bauersachs
- */
-public class CertConfigPanel
- extends TransparentPanel
- implements ConfigurationForm, ActionListener, ListSelectionListener
-{
- // ------------------------------------------------------------------------
- // Fields
- // ------------------------------------------------------------------------
- private static final long serialVersionUID = 2324122652952574574L;
- private ResourceManagementService R;
- private CertConfigTableModel model;
-
- // ------------------------------------------------------------------------
- // GUI members
- // ------------------------------------------------------------------------
- private JButton cmdAdd;
- private JButton cmdRemove;
- private JButton cmdEdit;
- private JTable tblCertList;
- private JRadioButton rdoUseWindows;
- private JRadioButton rdoUseJava;
- private SIPCommCheckBox chkEnableRevocationCheck;
- private SIPCommCheckBox chkEnableOcsp;
-
- // ------------------------------------------------------------------------
- // initialization
- // ------------------------------------------------------------------------
- /**
- * Creates a new instance of this class.
- */
- public CertConfigPanel()
- {
- R = CertConfigActivator.R;
- model = new CertConfigTableModel();
- initComponents();
- valueChanged(null);
- }
-
- private void initComponents()
- {
- this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
-
- // trusted root CA source selection
- if (OSUtils.IS_WINDOWS)
- {
- JPanel pnlCertConfig = new TransparentPanel(new GridLayout(2, 1));
- pnlCertConfig.setBorder(BorderFactory.createTitledBorder(
- R.getI18NString("plugin.certconfig.TRUSTSTORE_CONFIG")));
- add(pnlCertConfig);
-
- ButtonGroup grpTrustStore = new ButtonGroup();
-
- rdoUseJava = new SIPCommRadioButton();
- rdoUseJava.setText(
- R.getI18NString("plugin.certconfig.JAVA_TRUSTSTORE"));
- rdoUseJava.addActionListener(this);
- grpTrustStore.add(rdoUseJava);
- pnlCertConfig.add(rdoUseJava);
-
- rdoUseWindows = new SIPCommRadioButton();
- rdoUseWindows.setText(
- R.getI18NString("plugin.certconfig.WINDOWS_TRUSTSTORE"));
- rdoUseWindows.addActionListener(this);
- grpTrustStore.add(rdoUseWindows);
- pnlCertConfig.add(rdoUseWindows);
-
- if ("Windows-ROOT".equals(CertConfigActivator.getConfigService()
- .getProperty(CertificateService.PNAME_TRUSTSTORE_TYPE)))
- {
- rdoUseWindows.setSelected(true);
- }
- else
- {
- rdoUseJava.setSelected(true);
- }
- }
-
- // revocation options
- JPanel pnlRevocation = new TransparentPanel(new GridLayout(2, 1));
- pnlRevocation.setBorder(BorderFactory.createTitledBorder(
- R.getI18NString("plugin.certconfig.REVOCATION_TITLE")));
- add(pnlRevocation);
-
- chkEnableRevocationCheck = new SIPCommCheckBox(
- R.getI18NString("plugin.certconfig.REVOCATION_CHECK_ENABLED"));
- chkEnableRevocationCheck.addActionListener(this);
- chkEnableRevocationCheck.setSelected(
- "true".equals(
- System.getProperty("com.sun.net.ssl.checkRevocation")));
- pnlRevocation.add(chkEnableRevocationCheck);
-
- chkEnableOcsp = new SIPCommCheckBox(
- R.getI18NString("plugin.certconfig.REVOCATION_OCSP_ENABLED"));
- chkEnableOcsp.addActionListener(this);
- chkEnableOcsp.setSelected(
- "true".equals(Security.getProperty("ocsp.enable")));
- chkEnableOcsp.setEnabled(chkEnableRevocationCheck.isSelected());
- pnlRevocation.add(chkEnableOcsp);
-
- // Client certificate authentication list
- JPanel pnlCertList = new TransparentPanel(new BorderLayout());
- pnlCertList.setBorder(BorderFactory.createTitledBorder(
- R.getI18NString("plugin.certconfig.CERT_LIST_TITLE")));
- add(pnlCertList);
-
- JLabel lblNote = new JLabel();
- lblNote.setText(
- R.getI18NString("plugin.certconfig.CERT_LIST_DESCRIPTION"));
- lblNote.setBorder(new EmptyBorder(7, 7, 7, 7));
- pnlCertList.add(lblNote, BorderLayout.NORTH);
-
- tblCertList = new JTable();
- tblCertList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- tblCertList.getSelectionModel().addListSelectionListener(this);
- tblCertList.setModel(model);
- pnlCertList.add(new JScrollPane(tblCertList), BorderLayout.CENTER);
-
- TransparentPanel buttons = new TransparentPanel();
- buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
- pnlCertList.add(buttons, BorderLayout.SOUTH);
-
- cmdAdd = new JButton();
- cmdAdd.setText(R.getI18NString("service.gui.ADD"));
- cmdAdd.addActionListener(this);
- buttons.add(cmdAdd);
-
- cmdRemove = new JButton();
- cmdRemove.setText(R.getI18NString("service.gui.REMOVE"));
- cmdRemove.addActionListener(this);
- buttons.add(cmdRemove);
-
- cmdEdit = new JButton();
- cmdEdit.setText(R.getI18NString("service.gui.EDIT"));
- cmdEdit.addActionListener(this);
- buttons.add(cmdEdit);
- }
-
- // ------------------------------------------------------------------------
- // event handling
- // ------------------------------------------------------------------------
- public void valueChanged(ListSelectionEvent e)
- {
- int row = tblCertList.getSelectedRow();
- cmdRemove.setEnabled(row > -1);
- cmdEdit.setEnabled(row > -1);
- }
-
- public void actionPerformed(ActionEvent e)
- {
- if (e.getSource() == cmdAdd)
- {
- CertificateConfigEntry newEntry = new CertificateConfigEntry();
- CertConfigEntryDialog dlg = new CertConfigEntryDialog(newEntry);
- if (dlg.showDialog())
- CertConfigActivator.getCertService()
- .setClientAuthCertificateConfig(newEntry);
- }
- if (e.getSource() == cmdRemove)
- {
- CertConfigActivator.getCertService()
- .removeClientAuthCertificateConfig(
- model.getItem(tblCertList.getSelectedRow()).getId());
- }
- if (e.getSource() == cmdEdit)
- {
- CertificateConfigEntry entry =
- model.getItem(tblCertList.getSelectedRow());
- CertConfigEntryDialog dlg = new CertConfigEntryDialog(entry);
- if (dlg.showDialog())
- CertConfigActivator.getCertService()
- .setClientAuthCertificateConfig(entry);
- }
- if (e.getSource() == rdoUseJava)
- {
- CertConfigActivator.getConfigService().setProperty(
- CertificateService.PNAME_TRUSTSTORE_TYPE,
- "meta:default");
- CertConfigActivator.getConfigService().removeProperty(
- CertificateService.PNAME_TRUSTSTORE_FILE);
- CertConfigActivator.getCredService().removePassword(
- CertificateService.PNAME_TRUSTSTORE_PASSWORD);
- }
- if (e.getSource() == rdoUseWindows)
- {
- CertConfigActivator.getConfigService().setProperty(
- CertificateService.PNAME_TRUSTSTORE_TYPE, "Windows-ROOT");
- CertConfigActivator.getConfigService().removeProperty(
- CertificateService.PNAME_TRUSTSTORE_FILE);
- CertConfigActivator.getCredService().removePassword(
- CertificateService.PNAME_TRUSTSTORE_PASSWORD);
- }
- if (e.getSource() == chkEnableRevocationCheck)
- {
- CertConfigActivator.getConfigService().setProperty(
- CertificateService.PNAME_REVOCATION_CHECK_ENABLED,
- chkEnableRevocationCheck.isSelected());
-
- String enabled = new Boolean(
- chkEnableRevocationCheck.isSelected()).toString();
- System.setProperty("com.sun.security.enableCRLDP", enabled);
- System.setProperty("com.sun.net.ssl.checkRevocation", enabled);
- chkEnableOcsp.setEnabled(chkEnableRevocationCheck.isSelected());
- }
- if (e.getSource() == chkEnableOcsp)
- {
- CertConfigActivator.getConfigService().setProperty(
- CertificateService.PNAME_OCSP_ENABLED,
- chkEnableOcsp.isSelected());
-
- Security.setProperty("ocsp.enable",
- new Boolean(chkEnableOcsp.isSelected()).toString());
- }
- }
-
- // ------------------------------------------------------------------------
- // Configuration form members
- // ------------------------------------------------------------------------
- public String getTitle()
- {
- return CertConfigActivator.R.getI18NString("plugin.certconfig.TITLE");
- }
-
- public byte[] getIcon()
- {
- return null;
- }
-
- public Object getForm()
- {
- return this;
- }
-
- public int getIndex()
- {
- return -1;
- }
-
- public boolean isAdvanced()
- {
- return true;
- }
-
-}
+package net.java.sip.communicator.plugin.certconfig;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.security.*;
+
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.event.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.certificate.*;
+import net.java.sip.communicator.service.gui.*;
+
+import org.jitsi.service.resources.*;
+import org.jitsi.util.*;
+
+/**
+ * Advanced configuration form to define client TLS certificate templates.
+ *
+ * @author Ingo Bauersachs
+ */
+public class CertConfigPanel
+ extends TransparentPanel
+ implements ConfigurationForm, ActionListener, ListSelectionListener
+{
+ // ------------------------------------------------------------------------
+ // Fields
+ // ------------------------------------------------------------------------
+ private static final long serialVersionUID = 2324122652952574574L;
+ private ResourceManagementService R;
+ private CertConfigTableModel model;
+
+ // ------------------------------------------------------------------------
+ // GUI members
+ // ------------------------------------------------------------------------
+ private JButton cmdAdd;
+ private JButton cmdRemove;
+ private JButton cmdEdit;
+ private JTable tblCertList;
+ private JRadioButton rdoUseWindows;
+ private JRadioButton rdoUseJava;
+ private SIPCommCheckBox chkEnableRevocationCheck;
+ private SIPCommCheckBox chkEnableOcsp;
+
+ // ------------------------------------------------------------------------
+ // initialization
+ // ------------------------------------------------------------------------
+ /**
+ * Creates a new instance of this class.
+ */
+ public CertConfigPanel()
+ {
+ R = CertConfigActivator.R;
+ model = new CertConfigTableModel();
+ initComponents();
+ valueChanged(null);
+ }
+
+ private void initComponents()
+ {
+ this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+
+ // trusted root CA source selection
+ if (OSUtils.IS_WINDOWS)
+ {
+ JPanel pnlCertConfig = new TransparentPanel(new GridLayout(2, 1));
+ pnlCertConfig.setBorder(BorderFactory.createTitledBorder(
+ R.getI18NString("plugin.certconfig.TRUSTSTORE_CONFIG")));
+ add(pnlCertConfig);
+
+ ButtonGroup grpTrustStore = new ButtonGroup();
+
+ rdoUseJava = new SIPCommRadioButton();
+ rdoUseJava.setText(
+ R.getI18NString("plugin.certconfig.JAVA_TRUSTSTORE"));
+ rdoUseJava.addActionListener(this);
+ grpTrustStore.add(rdoUseJava);
+ pnlCertConfig.add(rdoUseJava);
+
+ rdoUseWindows = new SIPCommRadioButton();
+ rdoUseWindows.setText(
+ R.getI18NString("plugin.certconfig.WINDOWS_TRUSTSTORE"));
+ rdoUseWindows.addActionListener(this);
+ grpTrustStore.add(rdoUseWindows);
+ pnlCertConfig.add(rdoUseWindows);
+
+ if ("Windows-ROOT".equals(CertConfigActivator.getConfigService()
+ .getProperty(CertificateService.PNAME_TRUSTSTORE_TYPE)))
+ {
+ rdoUseWindows.setSelected(true);
+ }
+ else
+ {
+ rdoUseJava.setSelected(true);
+ }
+ }
+
+ // revocation options
+ JPanel pnlRevocation = new TransparentPanel(new GridLayout(2, 1));
+ pnlRevocation.setBorder(BorderFactory.createTitledBorder(
+ R.getI18NString("plugin.certconfig.REVOCATION_TITLE")));
+ add(pnlRevocation);
+
+ chkEnableRevocationCheck = new SIPCommCheckBox(
+ R.getI18NString("plugin.certconfig.REVOCATION_CHECK_ENABLED"));
+ chkEnableRevocationCheck.addActionListener(this);
+ chkEnableRevocationCheck.setSelected(
+ "true".equals(
+ System.getProperty("com.sun.net.ssl.checkRevocation")));
+ pnlRevocation.add(chkEnableRevocationCheck);
+
+ chkEnableOcsp = new SIPCommCheckBox(
+ R.getI18NString("plugin.certconfig.REVOCATION_OCSP_ENABLED"));
+ chkEnableOcsp.addActionListener(this);
+ chkEnableOcsp.setSelected(
+ "true".equals(Security.getProperty("ocsp.enable")));
+ chkEnableOcsp.setEnabled(chkEnableRevocationCheck.isSelected());
+ pnlRevocation.add(chkEnableOcsp);
+
+ // Client certificate authentication list
+ JPanel pnlCertList = new TransparentPanel(new BorderLayout());
+ pnlCertList.setBorder(BorderFactory.createTitledBorder(
+ R.getI18NString("plugin.certconfig.CERT_LIST_TITLE")));
+ add(pnlCertList);
+
+ JLabel lblNote = new JLabel();
+ lblNote.setText(
+ R.getI18NString("plugin.certconfig.CERT_LIST_DESCRIPTION"));
+ lblNote.setBorder(new EmptyBorder(7, 7, 7, 7));
+ pnlCertList.add(lblNote, BorderLayout.NORTH);
+
+ tblCertList = new JTable();
+ tblCertList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ tblCertList.getSelectionModel().addListSelectionListener(this);
+ tblCertList.setModel(model);
+ pnlCertList.add(new JScrollPane(tblCertList), BorderLayout.CENTER);
+
+ TransparentPanel buttons = new TransparentPanel();
+ buttons.setLayout(new FlowLayout(FlowLayout.RIGHT));
+ pnlCertList.add(buttons, BorderLayout.SOUTH);
+
+ cmdAdd = new JButton();
+ cmdAdd.setText(R.getI18NString("service.gui.ADD"));
+ cmdAdd.addActionListener(this);
+ buttons.add(cmdAdd);
+
+ cmdRemove = new JButton();
+ cmdRemove.setText(R.getI18NString("service.gui.REMOVE"));
+ cmdRemove.addActionListener(this);
+ buttons.add(cmdRemove);
+
+ cmdEdit = new JButton();
+ cmdEdit.setText(R.getI18NString("service.gui.EDIT"));
+ cmdEdit.addActionListener(this);
+ buttons.add(cmdEdit);
+ }
+
+ // ------------------------------------------------------------------------
+ // event handling
+ // ------------------------------------------------------------------------
+ public void valueChanged(ListSelectionEvent e)
+ {
+ int row = tblCertList.getSelectedRow();
+ cmdRemove.setEnabled(row > -1);
+ cmdEdit.setEnabled(row > -1);
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (e.getSource() == cmdAdd)
+ {
+ CertificateConfigEntry newEntry = new CertificateConfigEntry();
+ CertConfigEntryDialog dlg = new CertConfigEntryDialog(newEntry);
+ if (dlg.showDialog())
+ CertConfigActivator.getCertService()
+ .setClientAuthCertificateConfig(newEntry);
+ }
+ if (e.getSource() == cmdRemove)
+ {
+ CertConfigActivator.getCertService()
+ .removeClientAuthCertificateConfig(
+ model.getItem(tblCertList.getSelectedRow()).getId());
+ }
+ if (e.getSource() == cmdEdit)
+ {
+ CertificateConfigEntry entry =
+ model.getItem(tblCertList.getSelectedRow());
+ CertConfigEntryDialog dlg = new CertConfigEntryDialog(entry);
+ if (dlg.showDialog())
+ CertConfigActivator.getCertService()
+ .setClientAuthCertificateConfig(entry);
+ }
+ if (e.getSource() == rdoUseJava)
+ {
+ CertConfigActivator.getConfigService().setProperty(
+ CertificateService.PNAME_TRUSTSTORE_TYPE,
+ "meta:default");
+ CertConfigActivator.getConfigService().removeProperty(
+ CertificateService.PNAME_TRUSTSTORE_FILE);
+ CertConfigActivator.getCredService().removePassword(
+ CertificateService.PNAME_TRUSTSTORE_PASSWORD);
+ }
+ if (e.getSource() == rdoUseWindows)
+ {
+ CertConfigActivator.getConfigService().setProperty(
+ CertificateService.PNAME_TRUSTSTORE_TYPE, "Windows-ROOT");
+ CertConfigActivator.getConfigService().removeProperty(
+ CertificateService.PNAME_TRUSTSTORE_FILE);
+ CertConfigActivator.getCredService().removePassword(
+ CertificateService.PNAME_TRUSTSTORE_PASSWORD);
+ }
+ if (e.getSource() == chkEnableRevocationCheck)
+ {
+ CertConfigActivator.getConfigService().setProperty(
+ CertificateService.PNAME_REVOCATION_CHECK_ENABLED,
+ chkEnableRevocationCheck.isSelected());
+
+ String enabled = new Boolean(
+ chkEnableRevocationCheck.isSelected()).toString();
+ System.setProperty("com.sun.security.enableCRLDP", enabled);
+ System.setProperty("com.sun.net.ssl.checkRevocation", enabled);
+ chkEnableOcsp.setEnabled(chkEnableRevocationCheck.isSelected());
+ }
+ if (e.getSource() == chkEnableOcsp)
+ {
+ CertConfigActivator.getConfigService().setProperty(
+ CertificateService.PNAME_OCSP_ENABLED,
+ chkEnableOcsp.isSelected());
+
+ Security.setProperty("ocsp.enable",
+ new Boolean(chkEnableOcsp.isSelected()).toString());
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Configuration form members
+ // ------------------------------------------------------------------------
+ public String getTitle()
+ {
+ return CertConfigActivator.R.getI18NString("plugin.certconfig.TITLE");
+ }
+
+ public byte[] getIcon()
+ {
+ return null;
+ }
+
+ public Object getForm()
+ {
+ return this;
+ }
+
+ public int getIndex()
+ {
+ return -1;
+ }
+
+ public boolean isAdvanced()
+ {
+ return true;
+ }
+
+}
diff --git a/src/net/java/sip/communicator/plugin/certconfig/CertConfigTableModel.java b/src/net/java/sip/communicator/plugin/certconfig/CertConfigTableModel.java
index 7ef76d5..99391bf 100644
--- a/src/net/java/sip/communicator/plugin/certconfig/CertConfigTableModel.java
+++ b/src/net/java/sip/communicator/plugin/certconfig/CertConfigTableModel.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,99 +15,99 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.certconfig;
-
-import java.beans.*;
-import java.util.*;
-
-import javax.swing.table.*;
-
-import net.java.sip.communicator.service.certificate.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * Backing data model for a JTable that displays the client certificate
- * configuration entries.
- *
- * @author Ingo Bauersachs
- */
-public class CertConfigTableModel
- extends AbstractTableModel
- implements PropertyChangeListener
-{
- private static final long serialVersionUID = -6369348252411082340L;
- private CertificateService cvs;
- private List<CertificateConfigEntry> model;
- private ResourceManagementService R = CertConfigActivator.R;
-
- /**
- * Constructor.
- */
- public CertConfigTableModel()
- {
- CertConfigActivator.getConfigService().addPropertyChangeListener(this);
- cvs = CertConfigActivator.getCertService();
- model = cvs.getClientAuthCertificateConfigs();
- }
-
- public int getRowCount()
- {
- return model.size();
- }
-
- public int getColumnCount()
- {
- return 3;
- }
-
- public Object getValueAt(int rowIndex, int columnIndex)
- {
- switch(columnIndex)
- {
- case 0:
- return model.get(rowIndex).getDisplayName();
- case 1:
- return model.get(rowIndex).getAlias();
- case 2:
- return model.get(rowIndex).getKeyStoreType();
- }
- return null;
- }
-
- /**
- * Get <tt>CertificateConfigEntry</tt> located at <tt>rowIndex</tt>.
- *
- * @param rowIndex row index
- * @return <tt>CertificateConfigEntry</tt>
- */
- public CertificateConfigEntry getItem(int rowIndex)
- {
- return model.get(rowIndex);
- }
-
- @Override
- public String getColumnName(int column)
- {
- switch(column)
- {
- case 0:
- return R.getI18NString("service.gui.DISPLAY_NAME");
- case 1:
- return R.getI18NString("plugin.certconfig.ALIAS");
- case 2:
- return R.getI18NString("plugin.certconfig.KEYSTORE_TYPE");
- }
- return super.getColumnName(column);
- }
-
- public void propertyChange(PropertyChangeEvent evt)
- {
- if (evt.getPropertyName().startsWith(
- CertificateService.PNAME_CLIENTAUTH_CERTCONFIG_BASE))
- {
- model = cvs.getClientAuthCertificateConfigs();
- super.fireTableDataChanged();
- }
- }
-}
+package net.java.sip.communicator.plugin.certconfig;
+
+import java.beans.*;
+import java.util.*;
+
+import javax.swing.table.*;
+
+import net.java.sip.communicator.service.certificate.*;
+
+import org.jitsi.service.resources.*;
+
+/**
+ * Backing data model for a JTable that displays the client certificate
+ * configuration entries.
+ *
+ * @author Ingo Bauersachs
+ */
+public class CertConfigTableModel
+ extends AbstractTableModel
+ implements PropertyChangeListener
+{
+ private static final long serialVersionUID = -6369348252411082340L;
+ private CertificateService cvs;
+ private List<CertificateConfigEntry> model;
+ private ResourceManagementService R = CertConfigActivator.R;
+
+ /**
+ * Constructor.
+ */
+ public CertConfigTableModel()
+ {
+ CertConfigActivator.getConfigService().addPropertyChangeListener(this);
+ cvs = CertConfigActivator.getCertService();
+ model = cvs.getClientAuthCertificateConfigs();
+ }
+
+ public int getRowCount()
+ {
+ return model.size();
+ }
+
+ public int getColumnCount()
+ {
+ return 3;
+ }
+
+ public Object getValueAt(int rowIndex, int columnIndex)
+ {
+ switch(columnIndex)
+ {
+ case 0:
+ return model.get(rowIndex).getDisplayName();
+ case 1:
+ return model.get(rowIndex).getAlias();
+ case 2:
+ return model.get(rowIndex).getKeyStoreType();
+ }
+ return null;
+ }
+
+ /**
+ * Get <tt>CertificateConfigEntry</tt> located at <tt>rowIndex</tt>.
+ *
+ * @param rowIndex row index
+ * @return <tt>CertificateConfigEntry</tt>
+ */
+ public CertificateConfigEntry getItem(int rowIndex)
+ {
+ return model.get(rowIndex);
+ }
+
+ @Override
+ public String getColumnName(int column)
+ {
+ switch(column)
+ {
+ case 0:
+ return R.getI18NString("service.gui.DISPLAY_NAME");
+ case 1:
+ return R.getI18NString("plugin.certconfig.ALIAS");
+ case 2:
+ return R.getI18NString("plugin.certconfig.KEYSTORE_TYPE");
+ }
+ return super.getColumnName(column);
+ }
+
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ if (evt.getPropertyName().startsWith(
+ CertificateService.PNAME_CLIENTAUTH_CERTCONFIG_BASE))
+ {
+ model = cvs.getClientAuthCertificateConfigs();
+ super.fireTableDataChanged();
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java
index ce1fc18..7783de8 100644
--- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java
+++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoActivator.java
@@ -1,208 +1,208 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.contactinfo;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.contactlist.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.configuration.*;
-import org.osgi.framework.*;
-
-/**
- * The Activator of the Contact Info bundle.
- *
- * @author Adam Goldstein
- * @author Yana Stamcheva
- */
-public class ContactInfoActivator implements BundleActivator
-{
- private Logger logger = Logger.getLogger(ContactInfoActivator.class);
-
- /**
- * Indicates if the contact info button is enabled in the chat window.
- */
- private static final String ENABLED_IN_CHAT_WINDOW_PROP
- = "net.java.sip.communicator.plugin.contactinfo." +
- "ENABLED_IN_CHAT_WINDOW_PROP";
-
- /**
- * Indicates if the contact info button is enabled in the call window.
- */
- private static final String ENABLED_IN_CALL_WINDOW_PROP
- = "net.java.sip.communicator.plugin.contactinfo." +
- "ENABLED_IN_CALL_WINDOW_PROP";
-
- private static BrowserLauncherService browserLauncherService;
-
- /**
- * The image loader service implementation.
- */
- private static ImageLoaderService<?> imageLoaderService = null;
-
- /**
- * The contact list service implementation.
- */
- private static MetaContactListService metaCListService;
-
- static BundleContext bundleContext;
-
- /**
- * Starts this bundle.
- */
- public void start(BundleContext bc) throws Exception
- {
- bundleContext = bc;
-
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
- containerFilter.put(
- Container.CONTAINER_ID,
- Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID());
-
- bundleContext.registerService(
- PluginComponentFactory.class.getName(),
- new ContactInfoPluginComponentFactory(
- Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU),
- containerFilter);
-
- if(getConfigService().getBoolean(ENABLED_IN_CHAT_WINDOW_PROP, false))
- {
- containerFilter = new Hashtable<String, String>();
- containerFilter.put(
- Container.CONTAINER_ID,
- Container.CONTAINER_CHAT_TOOL_BAR.getID());
-
- bundleContext.registerService(
- PluginComponentFactory.class.getName(),
- new ContactInfoPluginComponentFactory(
- Container.CONTAINER_CHAT_TOOL_BAR),
- containerFilter);
- }
-
- if(getConfigService().getBoolean(ENABLED_IN_CALL_WINDOW_PROP, false))
- {
- containerFilter = new Hashtable<String, String>();
- containerFilter.put(
- Container.CONTAINER_ID,
- Container.CONTAINER_CALL_DIALOG.getID());
-
- bundleContext.registerService(
- PluginComponentFactory.class.getName(),
- new ContactInfoPluginComponentFactory(
- Container.CONTAINER_CALL_DIALOG),
- containerFilter);
- }
-
- if (logger.isInfoEnabled())
- logger.info("CONTACT INFO... [REGISTERED]");
- }
-
- public void stop(BundleContext bc) throws Exception
- {
- }
-
- /**
- * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context.
- * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context
- */
- public static BrowserLauncherService getBrowserLauncher()
- {
- if (browserLauncherService == null)
- {
- ServiceReference serviceReference = bundleContext
- .getServiceReference(BrowserLauncherService.class.getName());
-
- browserLauncherService = (BrowserLauncherService) bundleContext
- .getService(serviceReference);
- }
-
- return browserLauncherService;
- }
-
- /**
- * Returns the imageLoaderService instance, if missing query osgi for it.
- * @return the imageLoaderService.
- */
- public static ImageLoaderService<?> getImageLoaderService()
- {
- if(imageLoaderService == null)
- {
- imageLoaderService
- = ServiceUtils.getService(
- bundleContext,
- ImageLoaderService.class);
- }
-
- return imageLoaderService;
- }
-
- /**
- * Returns the <tt>MetaContactListService</tt> obtained from the bundle
- * context.
- * @return the <tt>MetaContactListService</tt> obtained from the bundle
- * context
- */
- public static MetaContactListService getContactListService()
- {
- if (metaCListService == null)
- {
- metaCListService
- = ServiceUtils.getService(
- bundleContext,
- MetaContactListService.class);
- }
- return metaCListService;
- }
-
- /**
- * Returns a reference to a ConfigurationService implementation currently
- * registered in the bundle context or null if no such implementation was
- * found.
- *
- * @return a currently valid implementation of the ConfigurationService.
- */
- public static ConfigurationService getConfigService()
- {
- return ServiceUtils.getService(bundleContext,
- ConfigurationService.class);
- }
-
- /**
- * Contact info create factory.
- */
- private class ContactInfoPluginComponentFactory
- extends PluginComponentFactory
- {
- ContactInfoPluginComponentFactory(Container c)
- {
- super(c);
- }
-
- @Override
- protected PluginComponent getPluginInstance()
- {
- return new ContactInfoMenuItem(getContainer(), this);
- }
- }
-}
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Copyright @ 2015 Atlassian Pty Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.java.sip.communicator.plugin.contactinfo;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.browserlauncher.*;
+import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.util.*;
+
+import org.jitsi.service.configuration.*;
+import org.osgi.framework.*;
+
+/**
+ * The Activator of the Contact Info bundle.
+ *
+ * @author Adam Goldstein
+ * @author Yana Stamcheva
+ */
+public class ContactInfoActivator implements BundleActivator
+{
+ private Logger logger = Logger.getLogger(ContactInfoActivator.class);
+
+ /**
+ * Indicates if the contact info button is enabled in the chat window.
+ */
+ private static final String ENABLED_IN_CHAT_WINDOW_PROP
+ = "net.java.sip.communicator.plugin.contactinfo." +
+ "ENABLED_IN_CHAT_WINDOW_PROP";
+
+ /**
+ * Indicates if the contact info button is enabled in the call window.
+ */
+ private static final String ENABLED_IN_CALL_WINDOW_PROP
+ = "net.java.sip.communicator.plugin.contactinfo." +
+ "ENABLED_IN_CALL_WINDOW_PROP";
+
+ private static BrowserLauncherService browserLauncherService;
+
+ /**
+ * The image loader service implementation.
+ */
+ private static ImageLoaderService<?> imageLoaderService = null;
+
+ /**
+ * The contact list service implementation.
+ */
+ private static MetaContactListService metaCListService;
+
+ static BundleContext bundleContext;
+
+ /**
+ * Starts this bundle.
+ */
+ public void start(BundleContext bc) throws Exception
+ {
+ bundleContext = bc;
+
+ Hashtable<String, String> containerFilter
+ = new Hashtable<String, String>();
+ containerFilter.put(
+ Container.CONTAINER_ID,
+ Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU.getID());
+
+ bundleContext.registerService(
+ PluginComponentFactory.class.getName(),
+ new ContactInfoPluginComponentFactory(
+ Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU),
+ containerFilter);
+
+ if(getConfigService().getBoolean(ENABLED_IN_CHAT_WINDOW_PROP, false))
+ {
+ containerFilter = new Hashtable<String, String>();
+ containerFilter.put(
+ Container.CONTAINER_ID,
+ Container.CONTAINER_CHAT_TOOL_BAR.getID());
+
+ bundleContext.registerService(
+ PluginComponentFactory.class.getName(),
+ new ContactInfoPluginComponentFactory(
+ Container.CONTAINER_CHAT_TOOL_BAR),
+ containerFilter);
+ }
+
+ if(getConfigService().getBoolean(ENABLED_IN_CALL_WINDOW_PROP, false))
+ {
+ containerFilter = new Hashtable<String, String>();
+ containerFilter.put(
+ Container.CONTAINER_ID,
+ Container.CONTAINER_CALL_DIALOG.getID());
+
+ bundleContext.registerService(
+ PluginComponentFactory.class.getName(),
+ new ContactInfoPluginComponentFactory(
+ Container.CONTAINER_CALL_DIALOG),
+ containerFilter);
+ }
+
+ if (logger.isInfoEnabled())
+ logger.info("CONTACT INFO... [REGISTERED]");
+ }
+
+ public void stop(BundleContext bc) throws Exception
+ {
+ }
+
+ /**
+ * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
+ * context.
+ * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
+ * context
+ */
+ public static BrowserLauncherService getBrowserLauncher()
+ {
+ if (browserLauncherService == null)
+ {
+ ServiceReference serviceReference = bundleContext
+ .getServiceReference(BrowserLauncherService.class.getName());
+
+ browserLauncherService = (BrowserLauncherService) bundleContext
+ .getService(serviceReference);
+ }
+
+ return browserLauncherService;
+ }
+
+ /**
+ * Returns the imageLoaderService instance, if missing query osgi for it.
+ * @return the imageLoaderService.
+ */
+ public static ImageLoaderService<?> getImageLoaderService()
+ {
+ if(imageLoaderService == null)
+ {
+ imageLoaderService
+ = ServiceUtils.getService(
+ bundleContext,
+ ImageLoaderService.class);
+ }
+
+ return imageLoaderService;
+ }
+
+ /**
+ * Returns the <tt>MetaContactListService</tt> obtained from the bundle
+ * context.
+ * @return the <tt>MetaContactListService</tt> obtained from the bundle
+ * context
+ */
+ public static MetaContactListService getContactListService()
+ {
+ if (metaCListService == null)
+ {
+ metaCListService
+ = ServiceUtils.getService(
+ bundleContext,
+ MetaContactListService.class);
+ }
+ return metaCListService;
+ }
+
+ /**
+ * Returns a reference to a ConfigurationService implementation currently
+ * registered in the bundle context or null if no such implementation was
+ * found.
+ *
+ * @return a currently valid implementation of the ConfigurationService.
+ */
+ public static ConfigurationService getConfigService()
+ {
+ return ServiceUtils.getService(bundleContext,
+ ConfigurationService.class);
+ }
+
+ /**
+ * Contact info create factory.
+ */
+ private class ContactInfoPluginComponentFactory
+ extends PluginComponentFactory
+ {
+ ContactInfoPluginComponentFactory(Container c)
+ {
+ super(c);
+ }
+
+ @Override
+ protected PluginComponent getPluginInstance()
+ {
+ return new ContactInfoMenuItem(getContainer(), this);
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoContactPanel.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoContactPanel.java
index 9fd1bb6..4eba597 100644
--- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoContactPanel.java
+++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoContactPanel.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,198 +15,198 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.contactinfo;
-
-import java.awt.*;
-import java.util.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The left side panel of ContactInfoDialog. Display all associated subcontacts
- * and their respective protocols in a JList. If a user is selected, the
- * ContactInfoDetailsPanel will be updated to the current contact.
- *
- * @author Adam Goldstein
- * @author Yana Stamcheva
- */
-public class ContactInfoContactPanel
- extends TransparentPanel
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * The list of all subcontacts related to the selected contact.
- */
- private JList contactList = new JList();
-
- /**
- * The scroll pane containing the list of all sub contacts of a selected
- * contact.
- */
- private JScrollPane contactScrollPane = new JScrollPane();
-
- private DefaultListModel contactListModel = new DefaultListModel();
-
- /**
- * The parent dialog that makes the connection between the contacts and
- * the details panel.
- */
- private ContactInfoDialog contactInfoDialog;
-
- /**
- * Create a panel with a list of all sub-contacts associated with the
- * contact that was originally selected. Whenever a sub-contact is picked,
- * notifies the protocolPanel of the change and it will update the displayed
- * details.
- *
- * @param contacts the list of contacts
- * @param dialog the contact info dialog
- */
- public ContactInfoContactPanel( Iterator<Contact> contacts,
- ContactInfoDialog dialog)
- {
- super(new BorderLayout());
-
- this.contactInfoDialog = dialog;
-
- this.setBorder(BorderFactory.createCompoundBorder(BorderFactory
- .createTitledBorder(Resources.getString("service.gui.CONTACTS")),
- BorderFactory.createEmptyBorder(5, 5, 5, 5)));
-
- this.contactList.setOpaque(false);
- this.contactList.setModel(contactListModel);
- this.contactList.setCellRenderer(new ContactPanelCellRenderer());
- this.contactList.addListSelectionListener(new ListSelectionListener()
- {
- public void valueChanged(ListSelectionEvent e)
- {
- // When the user release the mouse button and completes the
- // selection, getValueIsAdjusting() becomes false
- if (!e.getValueIsAdjusting())
- {
- JList list = (JList) e.getSource();
-
- Contact selectedContact
- = (Contact) list.getSelectedValue();
-
- contactInfoDialog.loadContactDetails(selectedContact);
- }
- }
- });
-
- boolean isFirstIter = true;
- while (contacts.hasNext())
- {
- Contact contact = contacts.next();
-
- this.contactListModel.addElement(contact);
-
- if (isFirstIter)
- {
- isFirstIter = false;
- contactInfoDialog.loadContactDetails(contact);
- contactList.setSelectedIndex(0);
- }
- }
-
- this.contactScrollPane.setPreferredSize(new Dimension(100, 200));
- this.contactScrollPane.getViewport().add(contactList);
- this.add(contactScrollPane);
- }
-
- /**
- * A cell renderer that allows both text and icons in our contactList.
- */
- private static class ContactPanelCellRenderer
- extends DefaultListCellRenderer
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private boolean isSelected;
-
- private Color blueGreyBorderColor = new Color(131, 149, 178);
-
- private Color selectedColor = new Color(209, 212, 225);
-
- public ContactPanelCellRenderer()
- {
- this.setOpaque(false);
- }
-
- /**
- * Renders a <tt>Contact</tt> object in a JList, by visualizing
- * the contact name and the protocol icon.
- *
- * @param list the rendered JList
- * @param value the object to be rendered
- * @param index the index of the object in the list
- * @param isSelected indicates if the rendered object is selected
- * @param cellHasFocus indicates if the rendered object is in a focused
- * cell
- */
- @Override
- public Component getListCellRendererComponent( JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus)
- {
- super.getListCellRendererComponent(list, value, index, isSelected,
- cellHasFocus);
-
- this.isSelected = isSelected;
-
- Contact contact = (Contact) value;
-
- this.setIcon(new ImageIcon(contact.getProtocolProvider()
- .getProtocolIcon().getIcon(ProtocolIcon.ICON_SIZE_16x16)));
- this.setText(((Contact) value).getDisplayName());
-
- return this;
- }
-
- /**
- * Paint a round blue border and background when a cell is selected.
- */
- @Override
- public void paintComponent(Graphics g)
- {
- if (this.isSelected)
- {
- Graphics2D g2 = (Graphics2D) g.create();
-
- try
- {
- AntialiasingManager.activateAntialiasing(g2);
-
- int width = getWidth();
- int height = getHeight();
-
- g2.setColor(selectedColor);
- g2.fillRoundRect(1, 0, width, height, 7, 7);
-
- g2.setColor(blueGreyBorderColor);
- g2.setStroke(new BasicStroke(1.5f));
- g2.drawRoundRect(1, 0, width - 2, height - 1, 7, 7);
- }
- finally
- {
- g2.dispose();
- }
- }
-
- super.paintComponent(g);
- }
- }
-}
+package net.java.sip.communicator.plugin.contactinfo;
+
+import java.awt.*;
+import java.util.*;
+
+import javax.swing.*;
+import javax.swing.event.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ * The left side panel of ContactInfoDialog. Display all associated subcontacts
+ * and their respective protocols in a JList. If a user is selected, the
+ * ContactInfoDetailsPanel will be updated to the current contact.
+ *
+ * @author Adam Goldstein
+ * @author Yana Stamcheva
+ */
+public class ContactInfoContactPanel
+ extends TransparentPanel
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * The list of all subcontacts related to the selected contact.
+ */
+ private JList contactList = new JList();
+
+ /**
+ * The scroll pane containing the list of all sub contacts of a selected
+ * contact.
+ */
+ private JScrollPane contactScrollPane = new JScrollPane();
+
+ private DefaultListModel contactListModel = new DefaultListModel();
+
+ /**
+ * The parent dialog that makes the connection between the contacts and
+ * the details panel.
+ */
+ private ContactInfoDialog contactInfoDialog;
+
+ /**
+ * Create a panel with a list of all sub-contacts associated with the
+ * contact that was originally selected. Whenever a sub-contact is picked,
+ * notifies the protocolPanel of the change and it will update the displayed
+ * details.
+ *
+ * @param contacts the list of contacts
+ * @param dialog the contact info dialog
+ */
+ public ContactInfoContactPanel( Iterator<Contact> contacts,
+ ContactInfoDialog dialog)
+ {
+ super(new BorderLayout());
+
+ this.contactInfoDialog = dialog;
+
+ this.setBorder(BorderFactory.createCompoundBorder(BorderFactory
+ .createTitledBorder(Resources.getString("service.gui.CONTACTS")),
+ BorderFactory.createEmptyBorder(5, 5, 5, 5)));
+
+ this.contactList.setOpaque(false);
+ this.contactList.setModel(contactListModel);
+ this.contactList.setCellRenderer(new ContactPanelCellRenderer());
+ this.contactList.addListSelectionListener(new ListSelectionListener()
+ {
+ public void valueChanged(ListSelectionEvent e)
+ {
+ // When the user release the mouse button and completes the
+ // selection, getValueIsAdjusting() becomes false
+ if (!e.getValueIsAdjusting())
+ {
+ JList list = (JList) e.getSource();
+
+ Contact selectedContact
+ = (Contact) list.getSelectedValue();
+
+ contactInfoDialog.loadContactDetails(selectedContact);
+ }
+ }
+ });
+
+ boolean isFirstIter = true;
+ while (contacts.hasNext())
+ {
+ Contact contact = contacts.next();
+
+ this.contactListModel.addElement(contact);
+
+ if (isFirstIter)
+ {
+ isFirstIter = false;
+ contactInfoDialog.loadContactDetails(contact);
+ contactList.setSelectedIndex(0);
+ }
+ }
+
+ this.contactScrollPane.setPreferredSize(new Dimension(100, 200));
+ this.contactScrollPane.getViewport().add(contactList);
+ this.add(contactScrollPane);
+ }
+
+ /**
+ * A cell renderer that allows both text and icons in our contactList.
+ */
+ private static class ContactPanelCellRenderer
+ extends DefaultListCellRenderer
+ {
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ private boolean isSelected;
+
+ private Color blueGreyBorderColor = new Color(131, 149, 178);
+
+ private Color selectedColor = new Color(209, 212, 225);
+
+ public ContactPanelCellRenderer()
+ {
+ this.setOpaque(false);
+ }
+
+ /**
+ * Renders a <tt>Contact</tt> object in a JList, by visualizing
+ * the contact name and the protocol icon.
+ *
+ * @param list the rendered JList
+ * @param value the object to be rendered
+ * @param index the index of the object in the list
+ * @param isSelected indicates if the rendered object is selected
+ * @param cellHasFocus indicates if the rendered object is in a focused
+ * cell
+ */
+ @Override
+ public Component getListCellRendererComponent( JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus)
+ {
+ super.getListCellRendererComponent(list, value, index, isSelected,
+ cellHasFocus);
+
+ this.isSelected = isSelected;
+
+ Contact contact = (Contact) value;
+
+ this.setIcon(new ImageIcon(contact.getProtocolProvider()
+ .getProtocolIcon().getIcon(ProtocolIcon.ICON_SIZE_16x16)));
+ this.setText(((Contact) value).getDisplayName());
+
+ return this;
+ }
+
+ /**
+ * Paint a round blue border and background when a cell is selected.
+ */
+ @Override
+ public void paintComponent(Graphics g)
+ {
+ if (this.isSelected)
+ {
+ Graphics2D g2 = (Graphics2D) g.create();
+
+ try
+ {
+ AntialiasingManager.activateAntialiasing(g2);
+
+ int width = getWidth();
+ int height = getHeight();
+
+ g2.setColor(selectedColor);
+ g2.fillRoundRect(1, 0, width, height, 7, 7);
+
+ g2.setColor(blueGreyBorderColor);
+ g2.setStroke(new BasicStroke(1.5f));
+ g2.drawRoundRect(1, 0, width - 2, height - 1, 7, 7);
+ }
+ finally
+ {
+ g2.dispose();
+ }
+ }
+
+ super.paintComponent(g);
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java
index 49fdccb..941160a 100644
--- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java
+++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDetailsPanel.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,678 +15,678 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.contactinfo;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.text.*;
-import java.util.*;
-import java.util.regex.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.text.html.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.BinaryDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.BirthDateDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.CalendarDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.EmailAddressDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.FirstNameDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.GenderDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.GenericDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.LastNameDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.LocaleDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.MiddleNameDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.PhoneNumberDetail;
-import net.java.sip.communicator.service.protocol.ServerStoredDetails.TimeZoneDetail;
-
-/**
- * The right side panel of ContactInfoDialog. Shows one tab of a summary of
- * contact information for the selected subcontact, and has an extended tab
- * listing all of the details.
- *
- * @author Adam Goldstein
- * @author Yana Stamcheva
- */
-public class ContactInfoDetailsPanel
- extends TransparentPanel
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * The tabbed pane containing the two different tabs for details.
- */
- private final JTabbedPane tabbedPane = new SIPCommTabbedPane();
-
- /**
- * The operation set giving access to the server stored contact details.
- */
- private OperationSetServerStoredContactInfo contactInfoOpSet;
-
- /**
- * The currently selected sub-contact we are displaying information about.
- */
- private Contact contact;
-
- /**
- * The default width of hte avater area.
- */
- private static final int AVATAR_AREA_WIDTH = 105;
-
- /**
- * The default height of hte avater area.
- */
- private static final int AVATAR_AREA_HEIGHT = 130;
-
- /**
- * Construct a tabbed pane that will have one tab with a summary of info for
- * the selected subcontact and one tab for all of the extended details.
- */
- public ContactInfoDetailsPanel()
- {
- this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
- this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- this.setPreferredSize(new Dimension(400, 300));
-
- this.tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
- }
-
- /**
- * Retrieve and display the information for the newly selected contact, c.
- *
- * @param c the sub-contact we are now focusing on.
- */
- public void loadContactDetails(Contact c)
- {
- this.contact = c;
-
- ProtocolProviderService pps = contact.getProtocolProvider();
- contactInfoOpSet
- = pps.getOperationSet(OperationSetServerStoredContactInfo.class);
-
- this.removeAll();
-
- if (contactInfoOpSet == null || !pps.isRegistered())
- {
- JPanel unsupportedPanel = createUnsupportedPanel();
-
- this.add(unsupportedPanel);
-
- this.revalidate();
- this.repaint();
-
- return;
- }
-
- this.tabbedPane.removeAll();
-
- ImageIcon icon =
- new ImageIcon(contact.getProtocolProvider().getProtocolIcon()
- .getIcon(ProtocolIcon.ICON_SIZE_16x16));
-
- JPanel summaryPanel = createSummaryInfoPanel();
-
- JPanel extendedPanel = createExtendedInfoPanel();
-
- JScrollPane extendedScrollPane = new JScrollPane(extendedPanel);
-
- this.tabbedPane.addTab(
- Resources.getString("service.gui.SUMMARY"), icon,
- summaryPanel,
- Resources.getString(
- "plugin.contactinfo.CONTACT_SUMMARY_DESCRIPTION")
- + contact.getDisplayName());
-
- this.tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
-
- this.tabbedPane.addTab(
- Resources.getString("plugin.accountinfo.EXTENDED"), icon,
- extendedScrollPane,
- Resources.getString(
- "plugin.contactinfo.CONTACT_EXTENDED_DESCRIPTION")
- + contact.getDisplayName());
-
- this.tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
-
- this.add(tabbedPane);
-
- this.revalidate();
- this.repaint();
- }
-
- /**
- * Creates the panel that indicates to the user that the currently selected
- * contact does not support server stored contact info.
- *
- * @return the panel that is added and shows a message that the selected
- * sub-contact does not have the operation set for server stored
- * contact info supported.
- */
- private JPanel createUnsupportedPanel()
- {
- JTextArea unsupportedTextArea = new JTextArea(
- Resources.getString("service.gui.CONTACT_INFO_NOT_SUPPORTED"));
-
- unsupportedTextArea.setEditable(false);
- unsupportedTextArea.setLineWrap(true);
-
- JPanel unsupportedPanel = new TransparentPanel(new BorderLayout());
-
- unsupportedPanel.add(unsupportedTextArea);
-
- return unsupportedPanel;
- }
-
- /**
- * Creates a panel that can be added as the summary tab that displays the
- * following details: -
- * <p>
- * Avatar(Contact image) - FirstNameDetail - MiddleNameDetail -
- * LastNameDetail - BirthdateDetail (and calculate age) - GenderDetail -
- * EmailAddressDetail - PhoneNumberDetail. All other details will be* added
- * to our list of extended details.
- *
- * @return the panel that will be added as the summary tab.
- */
- private JPanel createSummaryInfoPanel()
- {
- JPanel summaryPanel = new TransparentPanel();
-
- summaryPanel.setLayout(new BorderLayout(10, 5));
- summaryPanel.setSize(this.getWidth(), this.getHeight());
-
- // Create the avatar panel.
- JPanel avatarPanel = new TransparentPanel();
-
- avatarPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- byte[] bytes = this.contact.getImage();
-
- ImageIcon scaledImage = null;
- // If the user has a contact image, let's use it. If not, add the
- // default
- if (bytes != null)
- {
- scaledImage = ImageUtils.getScaledRoundedIcon(
- bytes,
- AVATAR_AREA_WIDTH,
- AVATAR_AREA_HEIGHT
- );
- }
- else
- scaledImage =
- ImageUtils.getScaledRoundedIcon(Resources
- .getImage("service.gui.DEFAULT_USER_PHOTO"),
- AVATAR_AREA_WIDTH, AVATAR_AREA_HEIGHT);
-
- JLabel label = new JLabel(scaledImage);
- label.setVerticalAlignment(JLabel.CENTER);
- label.setHorizontalAlignment(JLabel.CENTER);
- label.setPreferredSize(new Dimension(
- AVATAR_AREA_WIDTH,
- AVATAR_AREA_HEIGHT)
- );
- avatarPanel.add(label);
- summaryPanel.add(avatarPanel, BorderLayout.WEST);
-
- // Create the summary details panel.
- JPanel detailsPanel = new TransparentPanel();
- detailsPanel.setLayout(new BorderLayout());
- detailsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- summaryPanel.add(detailsPanel);
-
- // Labels panel.
- JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1, 5, 5));
- labelsPanel.add(new JLabel(
- Resources.getString("plugin.accountinfo.FIRST_NAME")));
- labelsPanel.add(new JLabel(
- Resources.getString("plugin.accountinfo.MIDDLE_NAME")));
- labelsPanel.add(new JLabel(
- Resources.getString("plugin.accountinfo.LAST_NAME")));
- labelsPanel.add(new JLabel(
- Resources.getString("plugin.accountinfo.GENDER")));
- labelsPanel.add(new JLabel(
- Resources.getString("plugin.accountinfo.BDAY")));
- labelsPanel.add(new JLabel(
- Resources.getString("plugin.accountinfo.AGE")));
- labelsPanel.add(new JLabel(
- Resources.getString("plugin.accountinfo.EMAIL")));
- labelsPanel.add(new JLabel(
- Resources.getString("plugin.accountinfo.PHONE")));
-
- detailsPanel.add(labelsPanel, BorderLayout.WEST);
-
- // Values panel.
- JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1, 5, 5));
-
- detailsPanel.add(valuesPanel, BorderLayout.CENTER);
-
- Iterator<GenericDetail> contactDetails;
- GenericDetail genericDetail;
-
- // First name details.
- contactDetails =
- contactInfoOpSet.getDetails(contact, FirstNameDetail.class);
-
- String firstNameDetail = "";
- while (contactDetails.hasNext())
- {
- genericDetail = contactDetails.next();
-
- firstNameDetail =
- firstNameDetail + " " + genericDetail.getDetailValue();
- }
-
- if (firstNameDetail.equals(""))
- firstNameDetail
- = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
-
- valuesPanel.add(new JLabel(firstNameDetail));
-
- // Middle name details.
- contactDetails =
- contactInfoOpSet.getDetails(contact, MiddleNameDetail.class);
-
- String middleNameDetail = "";
- while (contactDetails.hasNext())
- {
- genericDetail = contactDetails.next();
- middleNameDetail =
- middleNameDetail + " " + genericDetail.getDetailValue();
- }
-
- if (middleNameDetail.trim().equals(""))
- middleNameDetail
- = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
-
- valuesPanel.add(new JLabel(middleNameDetail));
-
- // Last name details.
- contactDetails =
- contactInfoOpSet.getDetails(contact, LastNameDetail.class);
-
- String lastNameDetail = "";
- while (contactDetails.hasNext())
- {
- genericDetail = contactDetails.next();
-
- lastNameDetail =
- lastNameDetail + " " + genericDetail.getDetailValue();
- }
-
- if (lastNameDetail.trim().equals(""))
- lastNameDetail
- = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
-
- valuesPanel.add(new JLabel(lastNameDetail));
-
- // Gender details.
- contactDetails =
- contactInfoOpSet.getDetails(contact, GenderDetail.class);
-
- String genderDetail = "";
- while (contactDetails.hasNext())
- {
- genericDetail = contactDetails.next();
- genderDetail = genderDetail + " " + genericDetail.getDetailValue();
- }
-
- if (genderDetail.trim().equals(""))
- genderDetail
- = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
-
- valuesPanel.add(new JLabel(genderDetail));
-
- // Birthday details.
- contactDetails =
- contactInfoOpSet.getDetails(contact, BirthDateDetail.class);
-
- String birthDateDetail = "";
- String ageDetail = "";
- if (contactDetails.hasNext())
- {
- genericDetail = contactDetails.next();
-
- Calendar calendarDetail =
- (Calendar) genericDetail.getDetailValue();
-
- Date birthDate = calendarDetail.getTime();
- DateFormat dateFormat = DateFormat.getDateInstance();
-
- birthDateDetail = dateFormat.format(birthDate).trim();
-
- Calendar c = Calendar.getInstance();
- int age = c.get(Calendar.YEAR) - calendarDetail.get(Calendar.YEAR);
-
- if (c.get(Calendar.MONTH) < calendarDetail.get(Calendar.MONTH))
- age--;
-
- ageDetail = Integer.toString(age).trim();
- }
-
- if (birthDateDetail.equals(""))
- birthDateDetail
- = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
-
- if (ageDetail.equals(""))
- ageDetail = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
-
- valuesPanel.add(new JLabel(birthDateDetail));
- valuesPanel.add(new JLabel(ageDetail));
-
- // Email details.
- contactDetails =
- contactInfoOpSet.getDetails(contact, EmailAddressDetail.class);
-
- String emailDetail = "";
- while (contactDetails.hasNext())
- {
- genericDetail = contactDetails.next();
- emailDetail = emailDetail + " " + genericDetail.getDetailValue();
- }
-
- if (emailDetail.trim().equals(""))
- emailDetail
- = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
-
- valuesPanel.add(new JLabel(emailDetail));
-
- // Phone number details.
- contactDetails =
- contactInfoOpSet.getDetails(contact, PhoneNumberDetail.class);
-
- String phoneNumberDetail = "";
- while (contactDetails.hasNext())
- {
- genericDetail = contactDetails.next();
- phoneNumberDetail =
- phoneNumberDetail + " " + genericDetail.getDetailValue();
- }
-
- if (phoneNumberDetail.trim().equals(""))
- phoneNumberDetail
- = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
-
- valuesPanel.add(new JLabel(phoneNumberDetail));
-
- return summaryPanel;
- }
-
- /**
- * A panel that displays all of the details retrieved from the opSet.
- *
- * @return a panel that will be added as the extended tab.
- */
- private JPanel createExtendedInfoPanel()
- {
- JPanel mainExtendedPanel = new TransparentPanel(new BorderLayout());
-
- JPanel extendedPanel = new TransparentPanel();
- extendedPanel.setLayout(new BoxLayout(extendedPanel, BoxLayout.Y_AXIS));
-
- JPanel imagePanel = new TransparentPanel();
-
- // The imagePanel will be used for any BinaryDetails and will be added at
- // the bottom so we don't disrupt the standard look of the other details
- imagePanel.setLayout(new BoxLayout(imagePanel, BoxLayout.LINE_AXIS));
- imagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
- .createTitledBorder(
- Resources.getString("plugin.contactinfo.USER_PICTURES")),
-
- BorderFactory.createEmptyBorder(0, 5, 5, 5)));
-
- // Obtain all the details for a contact.
- Iterator<GenericDetail> iter
- = contactInfoOpSet.getAllDetailsForContact(contact);
-
- GenericDetail detail;
- JLabel detailLabel;
- JTextArea detailValueArea;
- JPanel detailPanel;
-
- while (iter.hasNext())
- {
- detail = iter.next();
-
- if (detail.getDetailValue().toString().equals(""))
- continue;
-
- detailLabel = new JLabel();
- detailValueArea = new JTextArea();
- detailPanel = new TransparentPanel(new BorderLayout(10, 10));
-
- detailValueArea.setAlignmentX(JTextArea.CENTER_ALIGNMENT);
- detailValueArea.setEditable(false);
- detailValueArea.setLineWrap(true);
-
- detailPanel.add(detailLabel, BorderLayout.WEST);
- detailPanel.add(detailValueArea, BorderLayout.CENTER);
- detailPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- extendedPanel.add(detailPanel);
-
- if (detail instanceof BinaryDetail)
- {
- JLabel imageLabel =
- new JLabel(new ImageIcon((byte[]) detail
- .getDetailValue()));
-
- imagePanel.add(imageLabel);
- }
- else if (detail instanceof CalendarDetail)
- {
- detailLabel.setText(detail.getDetailDisplayName() + ": ");
-
- Date detailDate =
- ((Calendar) detail.getDetailValue()).getTime();
- DateFormat df = DateFormat.getDateInstance();
-
- detailValueArea.setText(df.format(detailDate).trim());
- }
- else if (detail instanceof LocaleDetail)
- {
- detailLabel.setText(detail.getDetailDisplayName() + ": ");
-
- Object value = detail.getDetailValue();
- String valueStr = "";
-
- if(value instanceof Locale)
- valueStr = ((Locale) value).getDisplayName().trim();
- else if(value instanceof String)
- valueStr = (String)value;
-
- detailValueArea.setText(valueStr);
- }
- else if (detail instanceof TimeZoneDetail)
- {
- detailLabel.setText(detail.getDetailDisplayName() + ": ");
-
- detailValueArea.setText(((TimeZone) detail.getDetailValue())
- .getDisplayName().trim());
- }
- else
- {
- detailLabel.setText(detail.getDetailDisplayName() + ": ");
-
- detailValueArea.setText(
- detail.getDetailValue().toString().trim());
- }
- }
-
- // Add users status message to extended details if it exists
- String statusMessage = contact.getStatusMessage();
- if(statusMessage != null && statusMessage.length() > 0)
- {
- detailLabel = new JLabel();
- HTMLTextPane detailValuePane = new HTMLTextPane();
- detailPanel = new TransparentPanel(new BorderLayout(10, 10));
-
- detailValuePane.setEditable(false);
- detailValuePane.setOpaque(false);
-
- detailPanel.add(detailLabel, BorderLayout.WEST);
- detailPanel.add(detailValuePane, BorderLayout.CENTER);
- detailPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- extendedPanel.add(detailPanel);
-
- detailLabel.setText(Resources.getString(
- "plugin.contactinfo.USER_STATUS_MESSAGE") + ": ");
-
- detailValuePane.setText(statusMessage);
- }
-
- // If the contact's protocol supports web info, give them a button to
- // get it
- OperationSetWebContactInfo webContactInfo
- = contact
- .getProtocolProvider()
- .getOperationSet(OperationSetWebContactInfo.class);
-
- if (webContactInfo != null)
- {
- final String urlString
- = webContactInfo.getWebContactInfo(contact).toString();
-
- JLabel webInfoLabel = new JLabel("Click to see web info: ");
- JEditorPane webInfoValue = new JEditorPane();
- JPanel webInfoPanel = new TransparentPanel(new BorderLayout());
-
- webInfoPanel.add(webInfoLabel, BorderLayout.WEST);
- webInfoPanel.add(webInfoValue, BorderLayout.CENTER);
-
- extendedPanel.add(webInfoPanel);
-
- webInfoValue.setOpaque(false);
- webInfoValue.setContentType("text/html");
- webInfoValue.setEditable(false);
- webInfoValue.setText( "<a href='"
- + urlString + "'>"
- + contact.getDisplayName()
- + " web info</a>");
-
- webInfoValue.addHyperlinkListener(new HyperlinkListener()
- {
- public void hyperlinkUpdate(HyperlinkEvent e)
- {
- if (e.getEventType()
- .equals(HyperlinkEvent.EventType.ACTIVATED))
- {
- ContactInfoActivator
- .getBrowserLauncher().openURL(urlString);
- }
- }
- });
- }
-
- if (imagePanel.getComponentCount() > 0)
- mainExtendedPanel.add(imagePanel, BorderLayout.CENTER);
-
- mainExtendedPanel.add(extendedPanel, BorderLayout.NORTH);
-
- return mainExtendedPanel;
- }
-
- /**
- * The <tt>HTMLTextPane</tt> is a pane that handles displaying HTML and
- * hyperlinking urls found in the text.
- */
- private class HTMLTextPane
- extends JTextPane
- implements HyperlinkListener
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * The regular expression (in the form of compiled <tt>Pattern</tt>)
- * which matches URLs for the purposed of turning them into links.
- */
- private final Pattern URL_PATTERN = Pattern.compile("("
- + "(\\bwww\\.[^\\s<>\"]+\\.[^\\s<>\"]+/*[?#]*(\\w+[&=;?]\\w+)*\\b)" // wwwURL
- + "|" + "(\\b\\w+://[^\\s<>\"]+/*[?#]*(\\w+[&=;?]\\w+)*\\b)" // protocolURL
- + ")");
-
- private SIPCommHTMLEditorKit editorKit;
- private HTMLDocument document;
-
- /**
- * Creates and instance of <tt>HTMLTextPane</tt>
- */
- public HTMLTextPane()
- {
- editorKit = new SIPCommHTMLEditorKit(this);
-
- this.document = (HTMLDocument) editorKit.createDefaultDocument();
-
- this.addHyperlinkListener(this);
-
- this.setContentType("text/html");
- this.setEditorKitForContentType("text/html", editorKit);
- this.setEditorKit(editorKit);
- this.setDocument(document);
-
- putClientProperty(
- JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
- }
-
-
- /**
- * Override of parent <tt>setText(String)</tt> to search for URLs and
- * set as hyperlinks.
- * @param string <tt>String</tt> to display.
- */
- @Override
- public void setText(String string)
- {
-
- Matcher m = URL_PATTERN.matcher(string);
- StringBuffer msgBuffer = new StringBuffer();
- int prevEnd = 0;
-
- while (m.find())
- {
- String fromPrevEndToStart = string.substring(prevEnd, m.start());
-
- msgBuffer.append(fromPrevEndToStart);
- prevEnd = m.end();
-
- String url = m.group().trim();
-
- msgBuffer.append("<A href=\"");
- if (url.startsWith("www"))
- msgBuffer.append("http://");
- msgBuffer.append(url);
- msgBuffer.append("\">");
- msgBuffer.append(url);
- msgBuffer.append("</A>");
- }
-
- String fromPrevEndToEnd = string.substring(prevEnd);
-
- msgBuffer.append(fromPrevEndToEnd);
-
- super.setText(msgBuffer.toString());
-
- }
-
- /**
- * Handles activations of hyperlinks
- * @param e <tt>HyperlinkEvent</tt> to handle.
- */
- public void hyperlinkUpdate(HyperlinkEvent e)
- {
- if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
- ContactInfoActivator.getBrowserLauncher()
- .openURL(e.getURL().toString());
- }
- }
-}
+package net.java.sip.communicator.plugin.contactinfo;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.text.*;
+import java.util.*;
+import java.util.regex.*;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.html.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.BinaryDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.BirthDateDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.CalendarDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.EmailAddressDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.FirstNameDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.GenderDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.GenericDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.LastNameDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.LocaleDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.MiddleNameDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.PhoneNumberDetail;
+import net.java.sip.communicator.service.protocol.ServerStoredDetails.TimeZoneDetail;
+
+/**
+ * The right side panel of ContactInfoDialog. Shows one tab of a summary of
+ * contact information for the selected subcontact, and has an extended tab
+ * listing all of the details.
+ *
+ * @author Adam Goldstein
+ * @author Yana Stamcheva
+ */
+public class ContactInfoDetailsPanel
+ extends TransparentPanel
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * The tabbed pane containing the two different tabs for details.
+ */
+ private final JTabbedPane tabbedPane = new SIPCommTabbedPane();
+
+ /**
+ * The operation set giving access to the server stored contact details.
+ */
+ private OperationSetServerStoredContactInfo contactInfoOpSet;
+
+ /**
+ * The currently selected sub-contact we are displaying information about.
+ */
+ private Contact contact;
+
+ /**
+ * The default width of hte avater area.
+ */
+ private static final int AVATAR_AREA_WIDTH = 105;
+
+ /**
+ * The default height of hte avater area.
+ */
+ private static final int AVATAR_AREA_HEIGHT = 130;
+
+ /**
+ * Construct a tabbed pane that will have one tab with a summary of info for
+ * the selected subcontact and one tab for all of the extended details.
+ */
+ public ContactInfoDetailsPanel()
+ {
+ this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+ this.setPreferredSize(new Dimension(400, 300));
+
+ this.tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
+ }
+
+ /**
+ * Retrieve and display the information for the newly selected contact, c.
+ *
+ * @param c the sub-contact we are now focusing on.
+ */
+ public void loadContactDetails(Contact c)
+ {
+ this.contact = c;
+
+ ProtocolProviderService pps = contact.getProtocolProvider();
+ contactInfoOpSet
+ = pps.getOperationSet(OperationSetServerStoredContactInfo.class);
+
+ this.removeAll();
+
+ if (contactInfoOpSet == null || !pps.isRegistered())
+ {
+ JPanel unsupportedPanel = createUnsupportedPanel();
+
+ this.add(unsupportedPanel);
+
+ this.revalidate();
+ this.repaint();
+
+ return;
+ }
+
+ this.tabbedPane.removeAll();
+
+ ImageIcon icon =
+ new ImageIcon(contact.getProtocolProvider().getProtocolIcon()
+ .getIcon(ProtocolIcon.ICON_SIZE_16x16));
+
+ JPanel summaryPanel = createSummaryInfoPanel();
+
+ JPanel extendedPanel = createExtendedInfoPanel();
+
+ JScrollPane extendedScrollPane = new JScrollPane(extendedPanel);
+
+ this.tabbedPane.addTab(
+ Resources.getString("service.gui.SUMMARY"), icon,
+ summaryPanel,
+ Resources.getString(
+ "plugin.contactinfo.CONTACT_SUMMARY_DESCRIPTION")
+ + contact.getDisplayName());
+
+ this.tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
+
+ this.tabbedPane.addTab(
+ Resources.getString("plugin.accountinfo.EXTENDED"), icon,
+ extendedScrollPane,
+ Resources.getString(
+ "plugin.contactinfo.CONTACT_EXTENDED_DESCRIPTION")
+ + contact.getDisplayName());
+
+ this.tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
+
+ this.add(tabbedPane);
+
+ this.revalidate();
+ this.repaint();
+ }
+
+ /**
+ * Creates the panel that indicates to the user that the currently selected
+ * contact does not support server stored contact info.
+ *
+ * @return the panel that is added and shows a message that the selected
+ * sub-contact does not have the operation set for server stored
+ * contact info supported.
+ */
+ private JPanel createUnsupportedPanel()
+ {
+ JTextArea unsupportedTextArea = new JTextArea(
+ Resources.getString("service.gui.CONTACT_INFO_NOT_SUPPORTED"));
+
+ unsupportedTextArea.setEditable(false);
+ unsupportedTextArea.setLineWrap(true);
+
+ JPanel unsupportedPanel = new TransparentPanel(new BorderLayout());
+
+ unsupportedPanel.add(unsupportedTextArea);
+
+ return unsupportedPanel;
+ }
+
+ /**
+ * Creates a panel that can be added as the summary tab that displays the
+ * following details: -
+ * <p>
+ * Avatar(Contact image) - FirstNameDetail - MiddleNameDetail -
+ * LastNameDetail - BirthdateDetail (and calculate age) - GenderDetail -
+ * EmailAddressDetail - PhoneNumberDetail. All other details will be* added
+ * to our list of extended details.
+ *
+ * @return the panel that will be added as the summary tab.
+ */
+ private JPanel createSummaryInfoPanel()
+ {
+ JPanel summaryPanel = new TransparentPanel();
+
+ summaryPanel.setLayout(new BorderLayout(10, 5));
+ summaryPanel.setSize(this.getWidth(), this.getHeight());
+
+ // Create the avatar panel.
+ JPanel avatarPanel = new TransparentPanel();
+
+ avatarPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ byte[] bytes = this.contact.getImage();
+
+ ImageIcon scaledImage = null;
+ // If the user has a contact image, let's use it. If not, add the
+ // default
+ if (bytes != null)
+ {
+ scaledImage = ImageUtils.getScaledRoundedIcon(
+ bytes,
+ AVATAR_AREA_WIDTH,
+ AVATAR_AREA_HEIGHT
+ );
+ }
+ else
+ scaledImage =
+ ImageUtils.getScaledRoundedIcon(Resources
+ .getImage("service.gui.DEFAULT_USER_PHOTO"),
+ AVATAR_AREA_WIDTH, AVATAR_AREA_HEIGHT);
+
+ JLabel label = new JLabel(scaledImage);
+ label.setVerticalAlignment(JLabel.CENTER);
+ label.setHorizontalAlignment(JLabel.CENTER);
+ label.setPreferredSize(new Dimension(
+ AVATAR_AREA_WIDTH,
+ AVATAR_AREA_HEIGHT)
+ );
+ avatarPanel.add(label);
+ summaryPanel.add(avatarPanel, BorderLayout.WEST);
+
+ // Create the summary details panel.
+ JPanel detailsPanel = new TransparentPanel();
+ detailsPanel.setLayout(new BorderLayout());
+ detailsPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ summaryPanel.add(detailsPanel);
+
+ // Labels panel.
+ JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1, 5, 5));
+ labelsPanel.add(new JLabel(
+ Resources.getString("plugin.accountinfo.FIRST_NAME")));
+ labelsPanel.add(new JLabel(
+ Resources.getString("plugin.accountinfo.MIDDLE_NAME")));
+ labelsPanel.add(new JLabel(
+ Resources.getString("plugin.accountinfo.LAST_NAME")));
+ labelsPanel.add(new JLabel(
+ Resources.getString("plugin.accountinfo.GENDER")));
+ labelsPanel.add(new JLabel(
+ Resources.getString("plugin.accountinfo.BDAY")));
+ labelsPanel.add(new JLabel(
+ Resources.getString("plugin.accountinfo.AGE")));
+ labelsPanel.add(new JLabel(
+ Resources.getString("plugin.accountinfo.EMAIL")));
+ labelsPanel.add(new JLabel(
+ Resources.getString("plugin.accountinfo.PHONE")));
+
+ detailsPanel.add(labelsPanel, BorderLayout.WEST);
+
+ // Values panel.
+ JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1, 5, 5));
+
+ detailsPanel.add(valuesPanel, BorderLayout.CENTER);
+
+ Iterator<GenericDetail> contactDetails;
+ GenericDetail genericDetail;
+
+ // First name details.
+ contactDetails =
+ contactInfoOpSet.getDetails(contact, FirstNameDetail.class);
+
+ String firstNameDetail = "";
+ while (contactDetails.hasNext())
+ {
+ genericDetail = contactDetails.next();
+
+ firstNameDetail =
+ firstNameDetail + " " + genericDetail.getDetailValue();
+ }
+
+ if (firstNameDetail.equals(""))
+ firstNameDetail
+ = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
+
+ valuesPanel.add(new JLabel(firstNameDetail));
+
+ // Middle name details.
+ contactDetails =
+ contactInfoOpSet.getDetails(contact, MiddleNameDetail.class);
+
+ String middleNameDetail = "";
+ while (contactDetails.hasNext())
+ {
+ genericDetail = contactDetails.next();
+ middleNameDetail =
+ middleNameDetail + " " + genericDetail.getDetailValue();
+ }
+
+ if (middleNameDetail.trim().equals(""))
+ middleNameDetail
+ = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
+
+ valuesPanel.add(new JLabel(middleNameDetail));
+
+ // Last name details.
+ contactDetails =
+ contactInfoOpSet.getDetails(contact, LastNameDetail.class);
+
+ String lastNameDetail = "";
+ while (contactDetails.hasNext())
+ {
+ genericDetail = contactDetails.next();
+
+ lastNameDetail =
+ lastNameDetail + " " + genericDetail.getDetailValue();
+ }
+
+ if (lastNameDetail.trim().equals(""))
+ lastNameDetail
+ = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
+
+ valuesPanel.add(new JLabel(lastNameDetail));
+
+ // Gender details.
+ contactDetails =
+ contactInfoOpSet.getDetails(contact, GenderDetail.class);
+
+ String genderDetail = "";
+ while (contactDetails.hasNext())
+ {
+ genericDetail = contactDetails.next();
+ genderDetail = genderDetail + " " + genericDetail.getDetailValue();
+ }
+
+ if (genderDetail.trim().equals(""))
+ genderDetail
+ = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
+
+ valuesPanel.add(new JLabel(genderDetail));
+
+ // Birthday details.
+ contactDetails =
+ contactInfoOpSet.getDetails(contact, BirthDateDetail.class);
+
+ String birthDateDetail = "";
+ String ageDetail = "";
+ if (contactDetails.hasNext())
+ {
+ genericDetail = contactDetails.next();
+
+ Calendar calendarDetail =
+ (Calendar) genericDetail.getDetailValue();
+
+ Date birthDate = calendarDetail.getTime();
+ DateFormat dateFormat = DateFormat.getDateInstance();
+
+ birthDateDetail = dateFormat.format(birthDate).trim();
+
+ Calendar c = Calendar.getInstance();
+ int age = c.get(Calendar.YEAR) - calendarDetail.get(Calendar.YEAR);
+
+ if (c.get(Calendar.MONTH) < calendarDetail.get(Calendar.MONTH))
+ age--;
+
+ ageDetail = Integer.toString(age).trim();
+ }
+
+ if (birthDateDetail.equals(""))
+ birthDateDetail
+ = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
+
+ if (ageDetail.equals(""))
+ ageDetail = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
+
+ valuesPanel.add(new JLabel(birthDateDetail));
+ valuesPanel.add(new JLabel(ageDetail));
+
+ // Email details.
+ contactDetails =
+ contactInfoOpSet.getDetails(contact, EmailAddressDetail.class);
+
+ String emailDetail = "";
+ while (contactDetails.hasNext())
+ {
+ genericDetail = contactDetails.next();
+ emailDetail = emailDetail + " " + genericDetail.getDetailValue();
+ }
+
+ if (emailDetail.trim().equals(""))
+ emailDetail
+ = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
+
+ valuesPanel.add(new JLabel(emailDetail));
+
+ // Phone number details.
+ contactDetails =
+ contactInfoOpSet.getDetails(contact, PhoneNumberDetail.class);
+
+ String phoneNumberDetail = "";
+ while (contactDetails.hasNext())
+ {
+ genericDetail = contactDetails.next();
+ phoneNumberDetail =
+ phoneNumberDetail + " " + genericDetail.getDetailValue();
+ }
+
+ if (phoneNumberDetail.trim().equals(""))
+ phoneNumberDetail
+ = Resources.getString("plugin.contactinfo.NOT_SPECIFIED");
+
+ valuesPanel.add(new JLabel(phoneNumberDetail));
+
+ return summaryPanel;
+ }
+
+ /**
+ * A panel that displays all of the details retrieved from the opSet.
+ *
+ * @return a panel that will be added as the extended tab.
+ */
+ private JPanel createExtendedInfoPanel()
+ {
+ JPanel mainExtendedPanel = new TransparentPanel(new BorderLayout());
+
+ JPanel extendedPanel = new TransparentPanel();
+ extendedPanel.setLayout(new BoxLayout(extendedPanel, BoxLayout.Y_AXIS));
+
+ JPanel imagePanel = new TransparentPanel();
+
+ // The imagePanel will be used for any BinaryDetails and will be added at
+ // the bottom so we don't disrupt the standard look of the other details
+ imagePanel.setLayout(new BoxLayout(imagePanel, BoxLayout.LINE_AXIS));
+ imagePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
+ .createTitledBorder(
+ Resources.getString("plugin.contactinfo.USER_PICTURES")),
+
+ BorderFactory.createEmptyBorder(0, 5, 5, 5)));
+
+ // Obtain all the details for a contact.
+ Iterator<GenericDetail> iter
+ = contactInfoOpSet.getAllDetailsForContact(contact);
+
+ GenericDetail detail;
+ JLabel detailLabel;
+ JTextArea detailValueArea;
+ JPanel detailPanel;
+
+ while (iter.hasNext())
+ {
+ detail = iter.next();
+
+ if (detail.getDetailValue().toString().equals(""))
+ continue;
+
+ detailLabel = new JLabel();
+ detailValueArea = new JTextArea();
+ detailPanel = new TransparentPanel(new BorderLayout(10, 10));
+
+ detailValueArea.setAlignmentX(JTextArea.CENTER_ALIGNMENT);
+ detailValueArea.setEditable(false);
+ detailValueArea.setLineWrap(true);
+
+ detailPanel.add(detailLabel, BorderLayout.WEST);
+ detailPanel.add(detailValueArea, BorderLayout.CENTER);
+ detailPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ extendedPanel.add(detailPanel);
+
+ if (detail instanceof BinaryDetail)
+ {
+ JLabel imageLabel =
+ new JLabel(new ImageIcon((byte[]) detail
+ .getDetailValue()));
+
+ imagePanel.add(imageLabel);
+ }
+ else if (detail instanceof CalendarDetail)
+ {
+ detailLabel.setText(detail.getDetailDisplayName() + ": ");
+
+ Date detailDate =
+ ((Calendar) detail.getDetailValue()).getTime();
+ DateFormat df = DateFormat.getDateInstance();
+
+ detailValueArea.setText(df.format(detailDate).trim());
+ }
+ else if (detail instanceof LocaleDetail)
+ {
+ detailLabel.setText(detail.getDetailDisplayName() + ": ");
+
+ Object value = detail.getDetailValue();
+ String valueStr = "";
+
+ if(value instanceof Locale)
+ valueStr = ((Locale) value).getDisplayName().trim();
+ else if(value instanceof String)
+ valueStr = (String)value;
+
+ detailValueArea.setText(valueStr);
+ }
+ else if (detail instanceof TimeZoneDetail)
+ {
+ detailLabel.setText(detail.getDetailDisplayName() + ": ");
+
+ detailValueArea.setText(((TimeZone) detail.getDetailValue())
+ .getDisplayName().trim());
+ }
+ else
+ {
+ detailLabel.setText(detail.getDetailDisplayName() + ": ");
+
+ detailValueArea.setText(
+ detail.getDetailValue().toString().trim());
+ }
+ }
+
+ // Add users status message to extended details if it exists
+ String statusMessage = contact.getStatusMessage();
+ if(statusMessage != null && statusMessage.length() > 0)
+ {
+ detailLabel = new JLabel();
+ HTMLTextPane detailValuePane = new HTMLTextPane();
+ detailPanel = new TransparentPanel(new BorderLayout(10, 10));
+
+ detailValuePane.setEditable(false);
+ detailValuePane.setOpaque(false);
+
+ detailPanel.add(detailLabel, BorderLayout.WEST);
+ detailPanel.add(detailValuePane, BorderLayout.CENTER);
+ detailPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ extendedPanel.add(detailPanel);
+
+ detailLabel.setText(Resources.getString(
+ "plugin.contactinfo.USER_STATUS_MESSAGE") + ": ");
+
+ detailValuePane.setText(statusMessage);
+ }
+
+ // If the contact's protocol supports web info, give them a button to
+ // get it
+ OperationSetWebContactInfo webContactInfo
+ = contact
+ .getProtocolProvider()
+ .getOperationSet(OperationSetWebContactInfo.class);
+
+ if (webContactInfo != null)
+ {
+ final String urlString
+ = webContactInfo.getWebContactInfo(contact).toString();
+
+ JLabel webInfoLabel = new JLabel("Click to see web info: ");
+ JEditorPane webInfoValue = new JEditorPane();
+ JPanel webInfoPanel = new TransparentPanel(new BorderLayout());
+
+ webInfoPanel.add(webInfoLabel, BorderLayout.WEST);
+ webInfoPanel.add(webInfoValue, BorderLayout.CENTER);
+
+ extendedPanel.add(webInfoPanel);
+
+ webInfoValue.setOpaque(false);
+ webInfoValue.setContentType("text/html");
+ webInfoValue.setEditable(false);
+ webInfoValue.setText( "<a href='"
+ + urlString + "'>"
+ + contact.getDisplayName()
+ + " web info</a>");
+
+ webInfoValue.addHyperlinkListener(new HyperlinkListener()
+ {
+ public void hyperlinkUpdate(HyperlinkEvent e)
+ {
+ if (e.getEventType()
+ .equals(HyperlinkEvent.EventType.ACTIVATED))
+ {
+ ContactInfoActivator
+ .getBrowserLauncher().openURL(urlString);
+ }
+ }
+ });
+ }
+
+ if (imagePanel.getComponentCount() > 0)
+ mainExtendedPanel.add(imagePanel, BorderLayout.CENTER);
+
+ mainExtendedPanel.add(extendedPanel, BorderLayout.NORTH);
+
+ return mainExtendedPanel;
+ }
+
+ /**
+ * The <tt>HTMLTextPane</tt> is a pane that handles displaying HTML and
+ * hyperlinking urls found in the text.
+ */
+ private class HTMLTextPane
+ extends JTextPane
+ implements HyperlinkListener
+ {
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * The regular expression (in the form of compiled <tt>Pattern</tt>)
+ * which matches URLs for the purposed of turning them into links.
+ */
+ private final Pattern URL_PATTERN = Pattern.compile("("
+ + "(\\bwww\\.[^\\s<>\"]+\\.[^\\s<>\"]+/*[?#]*(\\w+[&=;?]\\w+)*\\b)" // wwwURL
+ + "|" + "(\\b\\w+://[^\\s<>\"]+/*[?#]*(\\w+[&=;?]\\w+)*\\b)" // protocolURL
+ + ")");
+
+ private SIPCommHTMLEditorKit editorKit;
+ private HTMLDocument document;
+
+ /**
+ * Creates and instance of <tt>HTMLTextPane</tt>
+ */
+ public HTMLTextPane()
+ {
+ editorKit = new SIPCommHTMLEditorKit(this);
+
+ this.document = (HTMLDocument) editorKit.createDefaultDocument();
+
+ this.addHyperlinkListener(this);
+
+ this.setContentType("text/html");
+ this.setEditorKitForContentType("text/html", editorKit);
+ this.setEditorKit(editorKit);
+ this.setDocument(document);
+
+ putClientProperty(
+ JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
+ }
+
+
+ /**
+ * Override of parent <tt>setText(String)</tt> to search for URLs and
+ * set as hyperlinks.
+ * @param string <tt>String</tt> to display.
+ */
+ @Override
+ public void setText(String string)
+ {
+
+ Matcher m = URL_PATTERN.matcher(string);
+ StringBuffer msgBuffer = new StringBuffer();
+ int prevEnd = 0;
+
+ while (m.find())
+ {
+ String fromPrevEndToStart = string.substring(prevEnd, m.start());
+
+ msgBuffer.append(fromPrevEndToStart);
+ prevEnd = m.end();
+
+ String url = m.group().trim();
+
+ msgBuffer.append("<A href=\"");
+ if (url.startsWith("www"))
+ msgBuffer.append("http://");
+ msgBuffer.append(url);
+ msgBuffer.append("\">");
+ msgBuffer.append(url);
+ msgBuffer.append("</A>");
+ }
+
+ String fromPrevEndToEnd = string.substring(prevEnd);
+
+ msgBuffer.append(fromPrevEndToEnd);
+
+ super.setText(msgBuffer.toString());
+
+ }
+
+ /**
+ * Handles activations of hyperlinks
+ * @param e <tt>HyperlinkEvent</tt> to handle.
+ */
+ public void hyperlinkUpdate(HyperlinkEvent e)
+ {
+ if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
+ ContactInfoActivator.getBrowserLauncher()
+ .openURL(e.getURL().toString());
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDialog.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDialog.java
index 8e7d9db..3176533 100644
--- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDialog.java
+++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoDialog.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,88 +15,88 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.contactinfo;
-
-import java.awt.*;
-import java.util.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.contactlist.*;
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * A GUI plug-in for SIP Communicator that will allow cross protocol contact
- * information viewing and editing.
- *
- * @author Adam Goldstein
- * @author Yana Stamcheva
- */
-public class ContactInfoDialog
- extends SIPCommFrame
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * The right side of this frame that contains protocol specific contact
- * details.
- */
- protected ContactInfoDetailsPanel detailsPanel
- = new ContactInfoDetailsPanel();
-
- /**
- * The left side of this frame that contains a list of all sub-contacts
- * associated with the selected contact.
- */
- protected ContactInfoContactPanel contactPanel;
-
- /**
- * The contact that was right clicked on. The sub-contacts of contactItem
- * will be the ones selectable in contactPanel.
- */
- protected MetaContact metaContact;
-
- /**
- * Accepts a MetaContact and constructs a frame with ContactInfoSearchPanel
- * on the left and an information interface, ContactInfoDetailsPanel,
- * on the right.
- * @param metaContact the sub-contacts of this MetaContact that was right
- * clicked on will be the ones selectable in contactPanel.
- */
- public ContactInfoDialog(MetaContact metaContact)
- {
- this.metaContact = metaContact;
-
- this.setTitle(Resources.getString("plugin.contactinfo.TITLE")
- + ": "
- + metaContact.getDisplayName());
-
- Iterator<Contact> subContacts = metaContact.getContacts();
-
- this.contactPanel
- = new ContactInfoContactPanel(subContacts, this);
-
- Container contentPane = getContentPane();
- contentPane.add(contactPanel, BorderLayout.WEST);
- contentPane.add(detailsPanel, BorderLayout.CENTER);
-
- this.pack();
- }
-
- /**
- * Loads the details of the given contact.
- *
- * @param contact the <tt>Contact</tt>, which details we load
- */
- public void loadContactDetails(Contact contact)
- {
- this.detailsPanel.loadContactDetails(contact);
- }
-
- @Override
- protected void close(boolean isEscaped)
- {
- }
-}
+package net.java.sip.communicator.plugin.contactinfo;
+
+import java.awt.*;
+import java.util.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ * A GUI plug-in for SIP Communicator that will allow cross protocol contact
+ * information viewing and editing.
+ *
+ * @author Adam Goldstein
+ * @author Yana Stamcheva
+ */
+public class ContactInfoDialog
+ extends SIPCommFrame
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * The right side of this frame that contains protocol specific contact
+ * details.
+ */
+ protected ContactInfoDetailsPanel detailsPanel
+ = new ContactInfoDetailsPanel();
+
+ /**
+ * The left side of this frame that contains a list of all sub-contacts
+ * associated with the selected contact.
+ */
+ protected ContactInfoContactPanel contactPanel;
+
+ /**
+ * The contact that was right clicked on. The sub-contacts of contactItem
+ * will be the ones selectable in contactPanel.
+ */
+ protected MetaContact metaContact;
+
+ /**
+ * Accepts a MetaContact and constructs a frame with ContactInfoSearchPanel
+ * on the left and an information interface, ContactInfoDetailsPanel,
+ * on the right.
+ * @param metaContact the sub-contacts of this MetaContact that was right
+ * clicked on will be the ones selectable in contactPanel.
+ */
+ public ContactInfoDialog(MetaContact metaContact)
+ {
+ this.metaContact = metaContact;
+
+ this.setTitle(Resources.getString("plugin.contactinfo.TITLE")
+ + ": "
+ + metaContact.getDisplayName());
+
+ Iterator<Contact> subContacts = metaContact.getContacts();
+
+ this.contactPanel
+ = new ContactInfoContactPanel(subContacts, this);
+
+ Container contentPane = getContentPane();
+ contentPane.add(contactPanel, BorderLayout.WEST);
+ contentPane.add(detailsPanel, BorderLayout.CENTER);
+
+ this.pack();
+ }
+
+ /**
+ * Loads the details of the given contact.
+ *
+ * @param contact the <tt>Contact</tt>, which details we load
+ */
+ public void loadContactDetails(Contact contact)
+ {
+ this.detailsPanel.loadContactDetails(contact);
+ }
+
+ @Override
+ protected void close(boolean isEscaped)
+ {
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java
index abf4e25..11cea23 100644
--- a/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java
+++ b/src/net/java/sip/communicator/plugin/contactinfo/ContactInfoMenuItem.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,165 +15,165 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.contactinfo;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.contactlist.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.gui.Container;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.resources.*;
-
-/**
- *
- * @author Adam Goldstein
- */
-public class ContactInfoMenuItem
- extends AbstractPluginComponent
- implements ActionListener
-{
- private AbstractButton menuItem = null;
-
- private MetaContact metaContact;
-
- /**
- * The button index, for now placed on last position.
- */
- private final static int CONTACT_INFO_BUTTON_IX = 50;
-
- /**
- * Creates a <tt>ContactInfoMenuItem</tt>.
- */
- public ContactInfoMenuItem(PluginComponentFactory parentFactory)
- {
- this(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU, parentFactory);
- }
-
- /**
- * Creates a <tt>ContactInfoMenuItem</tt>.
- */
- public ContactInfoMenuItem(Container container,
- PluginComponentFactory parentFactory)
- {
- super(container, parentFactory);
- }
-
- /**
- * Sets the currently selected <tt>MetaContact</tt>.
- * @param metaContact the currently selected meta contact
- */
- @Override
- public void setCurrentContact(MetaContact metaContact)
- {
- this.metaContact = metaContact;
- }
-
- /*
- * Implements PluginComponent#setCurrentContact(Contact).
- * @param contact the currently selected contact
- */
- @Override
- public void setCurrentContact(Contact contact)
- {
- if(metaContact == null)
- {
- // search for the metacontact
- MetaContactListService mcs =
- ContactInfoActivator.getContactListService();
-
- metaContact =
- mcs.findMetaContactByContact(contact);
- }
- }
-
- /**
- * Initializes and shows the contact details dialog.
- */
- public void actionPerformed(ActionEvent e)
- {
- if(metaContact == null)
- return;
-
- ContactInfoDialog cinfoDialog = new ContactInfoDialog(metaContact);
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-
- cinfoDialog.setLocation(
- screenSize.width/2 - cinfoDialog.getWidth()/2,
- screenSize.height/2 - cinfoDialog.getHeight()/2);
- cinfoDialog.setVisible(true);
- }
-
- public Object getComponent()
- {
- return getMenuItem();
- }
-
- public String getName()
- {
- return getMenuItem().getText();
- }
-
- private AbstractButton getMenuItem()
- {
- if(menuItem == null)
- {
- if(getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR))
- {
- menuItem =
- new SIPCommButton(null,
- (Image)ContactInfoActivator.getImageLoaderService()
- .getImage(new ImageID(
- "plugin.contactinfo.CONTACT_INFO_TOOLBAR")))
- {
- /**
- * Returns the button index.
- * @return the button index.
- */
- public int getIndex()
- {
- return CONTACT_INFO_BUTTON_IX;
- }
- };
-
- menuItem.setPreferredSize(new Dimension(25, 25));
- menuItem.setToolTipText(
- Resources.getString("service.gui.CONTACT_INFO"));
- }
- else if(getContainer().equals(Container.CONTAINER_CALL_DIALOG))
- {
- menuItem =
- new SIPCommButton(null,
- (Image)ContactInfoActivator.getImageLoaderService()
- .getImage(new ImageID(
- "plugin.contactinfo.CONTACT_INFO_CALL_WINDOW")))
- {
- /**
- * Returns the button index.
- * @return the button index.
- */
- public int getIndex()
- {
- return CONTACT_INFO_BUTTON_IX;
- }
- };
- menuItem.setPreferredSize(new Dimension(44, 38));
- menuItem.setToolTipText(
- Resources.getString("service.gui.CONTACT_INFO"));
- }
- else
- menuItem =
- new JMenuItem(
- Resources.getString("service.gui.CONTACT_INFO"),
- new ImageIcon(Resources.getImage(
- "plugin.contactinfo.CONTACT_INFO_ICON")));
- menuItem.addActionListener(this);
- }
-
- return menuItem;
- }
-}
+package net.java.sip.communicator.plugin.contactinfo;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.gui.Container;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.resources.*;
+
+/**
+ *
+ * @author Adam Goldstein
+ */
+public class ContactInfoMenuItem
+ extends AbstractPluginComponent
+ implements ActionListener
+{
+ private AbstractButton menuItem = null;
+
+ private MetaContact metaContact;
+
+ /**
+ * The button index, for now placed on last position.
+ */
+ private final static int CONTACT_INFO_BUTTON_IX = 50;
+
+ /**
+ * Creates a <tt>ContactInfoMenuItem</tt>.
+ */
+ public ContactInfoMenuItem(PluginComponentFactory parentFactory)
+ {
+ this(Container.CONTAINER_CONTACT_RIGHT_BUTTON_MENU, parentFactory);
+ }
+
+ /**
+ * Creates a <tt>ContactInfoMenuItem</tt>.
+ */
+ public ContactInfoMenuItem(Container container,
+ PluginComponentFactory parentFactory)
+ {
+ super(container, parentFactory);
+ }
+
+ /**
+ * Sets the currently selected <tt>MetaContact</tt>.
+ * @param metaContact the currently selected meta contact
+ */
+ @Override
+ public void setCurrentContact(MetaContact metaContact)
+ {
+ this.metaContact = metaContact;
+ }
+
+ /*
+ * Implements PluginComponent#setCurrentContact(Contact).
+ * @param contact the currently selected contact
+ */
+ @Override
+ public void setCurrentContact(Contact contact)
+ {
+ if(metaContact == null)
+ {
+ // search for the metacontact
+ MetaContactListService mcs =
+ ContactInfoActivator.getContactListService();
+
+ metaContact =
+ mcs.findMetaContactByContact(contact);
+ }
+ }
+
+ /**
+ * Initializes and shows the contact details dialog.
+ */
+ public void actionPerformed(ActionEvent e)
+ {
+ if(metaContact == null)
+ return;
+
+ ContactInfoDialog cinfoDialog = new ContactInfoDialog(metaContact);
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+
+ cinfoDialog.setLocation(
+ screenSize.width/2 - cinfoDialog.getWidth()/2,
+ screenSize.height/2 - cinfoDialog.getHeight()/2);
+ cinfoDialog.setVisible(true);
+ }
+
+ public Object getComponent()
+ {
+ return getMenuItem();
+ }
+
+ public String getName()
+ {
+ return getMenuItem().getText();
+ }
+
+ private AbstractButton getMenuItem()
+ {
+ if(menuItem == null)
+ {
+ if(getContainer().equals(Container.CONTAINER_CHAT_TOOL_BAR))
+ {
+ menuItem =
+ new SIPCommButton(null,
+ (Image)ContactInfoActivator.getImageLoaderService()
+ .getImage(new ImageID(
+ "plugin.contactinfo.CONTACT_INFO_TOOLBAR")))
+ {
+ /**
+ * Returns the button index.
+ * @return the button index.
+ */
+ public int getIndex()
+ {
+ return CONTACT_INFO_BUTTON_IX;
+ }
+ };
+
+ menuItem.setPreferredSize(new Dimension(25, 25));
+ menuItem.setToolTipText(
+ Resources.getString("service.gui.CONTACT_INFO"));
+ }
+ else if(getContainer().equals(Container.CONTAINER_CALL_DIALOG))
+ {
+ menuItem =
+ new SIPCommButton(null,
+ (Image)ContactInfoActivator.getImageLoaderService()
+ .getImage(new ImageID(
+ "plugin.contactinfo.CONTACT_INFO_CALL_WINDOW")))
+ {
+ /**
+ * Returns the button index.
+ * @return the button index.
+ */
+ public int getIndex()
+ {
+ return CONTACT_INFO_BUTTON_IX;
+ }
+ };
+ menuItem.setPreferredSize(new Dimension(44, 38));
+ menuItem.setToolTipText(
+ Resources.getString("service.gui.CONTACT_INFO"));
+ }
+ else
+ menuItem =
+ new JMenuItem(
+ Resources.getString("service.gui.CONTACT_INFO"),
+ new ImageIcon(Resources.getImage(
+ "plugin.contactinfo.CONTACT_INFO_ICON")));
+ menuItem.addActionListener(this);
+ }
+
+ return menuItem;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/contactinfo/Resources.java b/src/net/java/sip/communicator/plugin/contactinfo/Resources.java
index 0c8f870..f0f31f1 100644
--- a/src/net/java/sip/communicator/plugin/contactinfo/Resources.java
+++ b/src/net/java/sip/communicator/plugin/contactinfo/Resources.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,79 +15,79 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.contactinfo;
-
-import java.awt.*;
-import java.awt.image.*;
-import java.io.*;
-
-import javax.imageio.*;
-
-import net.java.sip.communicator.service.resources.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The <tt>Resources</tt> class manages the access to the internationalization
- * properties files and the image resources used in this plugin.
- *
- * @author Yana Stamcheva
- */
-public class Resources {
-
- private static Logger log = Logger.getLogger(Resources.class);
-
- private static ResourceManagementService resourcesService;
-
- /**
- * 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)
- {
- return getResources().getI18NString(key);
- }
-
- /**
- * Loads an image from a given image identifier.
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static Image getImage(String imageID)
- {
- BufferedImage image = null;
-
- InputStream in =
- getResources().getImageInputStream(imageID);
-
- if(in == null)
- return null;
-
- try
- {
- image = ImageIO.read(in);
- }
- catch (IOException e)
- {
- log.error("Failed to load image:" + imageID, e);
- }
-
- return image;
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(ContactInfoActivator.bundleContext);
- return resourcesService;
- }
-}
+package net.java.sip.communicator.plugin.contactinfo;
+
+import java.awt.*;
+import java.awt.image.*;
+import java.io.*;
+
+import javax.imageio.*;
+
+import net.java.sip.communicator.service.resources.*;
+import net.java.sip.communicator.util.*;
+
+import org.jitsi.service.resources.*;
+
+/**
+ * The <tt>Resources</tt> class manages the access to the internationalization
+ * properties files and the image resources used in this plugin.
+ *
+ * @author Yana Stamcheva
+ */
+public class Resources {
+
+ private static Logger log = Logger.getLogger(Resources.class);
+
+ private static ResourceManagementService resourcesService;
+
+ /**
+ * 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)
+ {
+ return getResources().getI18NString(key);
+ }
+
+ /**
+ * Loads an image from a given image identifier.
+ * @param imageID The identifier of the image.
+ * @return The image for the given identifier.
+ */
+ public static Image getImage(String imageID)
+ {
+ BufferedImage image = null;
+
+ InputStream in =
+ getResources().getImageInputStream(imageID);
+
+ if(in == null)
+ return null;
+
+ try
+ {
+ image = ImageIO.read(in);
+ }
+ catch (IOException e)
+ {
+ log.error("Failed to load image:" + imageID, e);
+ }
+
+ return image;
+ }
+
+ /**
+ * Returns the <tt>ResourceManagementService</tt>.
+ *
+ * @return the <tt>ResourceManagementService</tt>.
+ */
+ public static ResourceManagementService getResources()
+ {
+ if (resourcesService == null)
+ resourcesService =
+ ResourceManagementServiceUtils
+ .getService(ContactInfoActivator.bundleContext);
+ return resourcesService;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/ColoredDefaultText.java b/src/net/java/sip/communicator/plugin/desktoputil/ColoredDefaultText.java
index 59dcb5d..e70f57e 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/ColoredDefaultText.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/ColoredDefaultText.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,43 +15,43 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.desktoputil;
-
-import java.awt.*;
-
-/**
- * The purpose of this interface is to allow UI components with a default
- * text value to give the default text its own colour, set independently of
- * the normal text colour.
- * @author Tom Denham
- */
-public interface ColoredDefaultText
-{
- /**
- * Sets the foreground color.
- *
- * @param c the color to set for the text field foreground
- */
- public void setForegroundColor(Color c);
-
- /**
- * Gets the foreground color.
- *
- * @return the color of the text
- */
- public Color getForegroundColor();
-
- /**
- * Sets the foreground color of the default text shown in this text field.
- *
- * @param c the color to set
- */
- public void setDefaultTextColor(Color c);
-
- /**
- * Gets the foreground color of the default text shown in this text field.
- *
- * @return the color of the default text
- */
- public Color getDefaultTextColor();
+package net.java.sip.communicator.plugin.desktoputil;
+
+import java.awt.*;
+
+/**
+ * The purpose of this interface is to allow UI components with a default
+ * text value to give the default text its own colour, set independently of
+ * the normal text colour.
+ * @author Tom Denham
+ */
+public interface ColoredDefaultText
+{
+ /**
+ * Sets the foreground color.
+ *
+ * @param c the color to set for the text field foreground
+ */
+ public void setForegroundColor(Color c);
+
+ /**
+ * Gets the foreground color.
+ *
+ * @return the color of the text
+ */
+ public Color getForegroundColor();
+
+ /**
+ * Sets the foreground color of the default text shown in this text field.
+ *
+ * @param c the color to set
+ */
+ public void setDefaultTextColor(Color c);
+
+ /**
+ * Gets the foreground color of the default text shown in this text field.
+ *
+ * @return the color of the default text
+ */
+ public Color getDefaultTextColor();
}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/SIPCommCheckBox.java b/src/net/java/sip/communicator/plugin/desktoputil/SIPCommCheckBox.java
index e263415..45c2e69 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/SIPCommCheckBox.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/SIPCommCheckBox.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,45 +15,45 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.desktoputil;
-
-import javax.swing.*;
-
-import org.jitsi.util.*;
-
-/**
- * @author Lubomir Marinov
- */
-public class SIPCommCheckBox
- extends JCheckBox
-{
- private static final long serialVersionUID = 0L;
-
- private static final boolean setContentAreaFilled = (OSUtils.IS_WINDOWS
- || OSUtils.IS_LINUX);
-
- public SIPCommCheckBox()
- {
- init();
- }
-
- public SIPCommCheckBox(String text)
- {
- super(text);
-
- init();
- }
-
- public SIPCommCheckBox(String text, boolean selected)
- {
- super(text, selected);
-
- init();
- }
-
- private void init()
- {
- if (setContentAreaFilled)
- setContentAreaFilled(false);
- }
-}
+package net.java.sip.communicator.plugin.desktoputil;
+
+import javax.swing.*;
+
+import org.jitsi.util.*;
+
+/**
+ * @author Lubomir Marinov
+ */
+public class SIPCommCheckBox
+ extends JCheckBox
+{
+ private static final long serialVersionUID = 0L;
+
+ private static final boolean setContentAreaFilled = (OSUtils.IS_WINDOWS
+ || OSUtils.IS_LINUX);
+
+ public SIPCommCheckBox()
+ {
+ init();
+ }
+
+ public SIPCommCheckBox(String text)
+ {
+ super(text);
+
+ init();
+ }
+
+ public SIPCommCheckBox(String text, boolean selected)
+ {
+ super(text, selected);
+
+ init();
+ }
+
+ private void init()
+ {
+ if (setContentAreaFilled)
+ setContentAreaFilled(false);
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/SIPCommRadioButton.java b/src/net/java/sip/communicator/plugin/desktoputil/SIPCommRadioButton.java
index 7089c99..1132c72 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/SIPCommRadioButton.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/SIPCommRadioButton.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,45 +15,45 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.desktoputil;
-
-import javax.swing.*;
-
-import org.jitsi.util.*;
-
-/**
- * @author Ingo Bauersachs
- */
-public class SIPCommRadioButton
- extends JRadioButton
-{
- private static final long serialVersionUID = 0L;
-
- private static final boolean setContentAreaFilled = (OSUtils.IS_WINDOWS
- || OSUtils.IS_LINUX);
-
- public SIPCommRadioButton()
- {
- init();
- }
-
- public SIPCommRadioButton(String text)
- {
- super(text);
-
- init();
- }
-
- public SIPCommRadioButton(String text, boolean selected)
- {
- super(text, selected);
-
- init();
- }
-
- private void init()
- {
- if (setContentAreaFilled)
- setContentAreaFilled(false);
- }
-}
+package net.java.sip.communicator.plugin.desktoputil;
+
+import javax.swing.*;
+
+import org.jitsi.util.*;
+
+/**
+ * @author Ingo Bauersachs
+ */
+public class SIPCommRadioButton
+ extends JRadioButton
+{
+ private static final long serialVersionUID = 0L;
+
+ private static final boolean setContentAreaFilled = (OSUtils.IS_WINDOWS
+ || OSUtils.IS_LINUX);
+
+ public SIPCommRadioButton()
+ {
+ init();
+ }
+
+ public SIPCommRadioButton(String text)
+ {
+ super(text);
+
+ init();
+ }
+
+ public SIPCommRadioButton(String text, boolean selected)
+ {
+ super(text, selected);
+
+ init();
+ }
+
+ private void init()
+ {
+ if (setContentAreaFilled)
+ setContentAreaFilled(false);
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/X509CertificatePanel.java b/src/net/java/sip/communicator/plugin/desktoputil/X509CertificatePanel.java
index a1284cd..5358030 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/X509CertificatePanel.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/X509CertificatePanel.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,490 +15,546 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.desktoputil;
-
-import java.awt.*;
-import java.security.*;
-import java.security.cert.*;
-import java.security.cert.Certificate;
-import java.security.interfaces.*;
-import java.util.*;
-
-import javax.naming.*;
-import javax.naming.ldap.*;
-import javax.security.auth.x500.*;
-import javax.swing.*;
-import javax.swing.border.*;
-import javax.swing.event.*;
-import javax.swing.text.*;
-import javax.swing.tree.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * Panel that shows the content of an X509Certificate.
- */
-public class X509CertificatePanel
- extends TransparentPanel
-{
- private static final long serialVersionUID = -8368302061995971947L;
-
- private final JEditorPane infoTextPane = new JEditorPane();
-
- private final ResourceManagementService R
- = DesktopUtilActivator.getResources();
-
- /**
- * Constructs a X509 certificate panel from a single certificate.
- * If a chain is available instead use the second constructor.
- * This constructor is kept for backwards compatibility and for convenience
- * when there is only one certificate of interest.
- *
- * @param certificate <tt>X509Certificate</tt> object
- */
- public X509CertificatePanel(Certificate certificate)
- {
- this(new Certificate[]
- {
- certificate
- });
- }
-
- /**
- * Constructs a X509 certificate panel.
- *
- * @param certificates <tt>X509Certificate</tt> objects
- */
- public X509CertificatePanel(Certificate[] certificates)
- {
- setLayout(new BorderLayout(5, 5));
-
- // Certificate chain list
- TransparentPanel topPanel = new TransparentPanel(new BorderLayout());
- topPanel.add(new JLabel("<html><body><b>"
- + R.getI18NString("service.gui.CERT_INFO_CHAIN")
- + "</b></body></html>"), BorderLayout.NORTH);
-
- DefaultMutableTreeNode top = new DefaultMutableTreeNode();
- DefaultMutableTreeNode previous = top;
- for (int i = certificates.length - 1; i >= 0; i--)
- {
- Certificate cert = certificates[i];
- DefaultMutableTreeNode next = new DefaultMutableTreeNode(cert);
- previous.add(next);
- previous = next;
- }
- JTree tree = new JTree(top);
- tree.setBorder(new BevelBorder(BevelBorder.LOWERED));
- tree.setRootVisible(false);
- tree.setExpandsSelectedPaths(true);
- tree.getSelectionModel().setSelectionMode(
- TreeSelectionModel.SINGLE_TREE_SELECTION);
- tree.setCellRenderer(new DefaultTreeCellRenderer()
- {
-
- @Override
- public Component getTreeCellRendererComponent(JTree tree,
- Object value, boolean sel, boolean expanded, boolean leaf,
- int row, boolean hasFocus)
- {
- JLabel component = (JLabel) super.getTreeCellRendererComponent(
- tree, value, sel, expanded, leaf, row, hasFocus);
- if (value instanceof DefaultMutableTreeNode)
- {
- Object o = ((DefaultMutableTreeNode) value).getUserObject();
- if (o instanceof X509Certificate)
- {
- component.setText(
- getSimplifiedName((X509Certificate) o));
- }
- else
- {
- // We don't know how to represent this certificate type,
- // let's use the first 20 characters
- String text = o.toString();
- if (text.length() > 20)
- {
- text = text.substring(0, 20);
- }
- component.setText(text);
- }
- }
- return component;
- }
-
- });
- tree.getSelectionModel().addTreeSelectionListener(
- new TreeSelectionListener()
- {
-
- @Override
- public void valueChanged(TreeSelectionEvent e)
- {
- valueChangedPerformed(e);
- }
- });
- tree.setSelectionPath(new TreePath(((
- (DefaultTreeModel)tree.getModel()).getPathToRoot(previous))));
- topPanel.add(tree, BorderLayout.CENTER);
-
- add(topPanel, BorderLayout.NORTH);
-
- // Certificate details pane
- Caret caret = infoTextPane.getCaret();
- if (caret instanceof DefaultCaret)
- {
- ((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
- }
-
- /*
- * Make JEditorPane respect our default font because we will be using it
- * to just display text.
- */
- infoTextPane.putClientProperty(
- JEditorPane.HONOR_DISPLAY_PROPERTIES,
- true);
-
- infoTextPane.setOpaque(false);
- infoTextPane.setEditable(false);
- infoTextPane.setContentType("text/html");
- infoTextPane.setText(toString(certificates[0]));
-
- final JScrollPane certScroll = new JScrollPane(infoTextPane);
- certScroll.setPreferredSize(new Dimension(300, 500));
- add(certScroll, BorderLayout.CENTER);
- }
-
- /**
- * Creates a String representation of the given object.
- * @param certificate to print
- * @return the String representation
- */
- private String toString(Object certificate)
- {
- final StringBuilder sb = new StringBuilder();
- sb.append("<html><body>\n");
-
- if (certificate instanceof X509Certificate)
- {
- renderX509(sb, (X509Certificate) certificate);
- }
- else
- {
- sb.append("<pre>\n");
- sb.append(certificate.toString());
- sb.append("</pre>\n");
- }
-
- sb.append("</body></html>");
- return sb.toString();
- }
-
- /**
- * Appends an HTML representation of the given X509Certificate.
- * @param sb StringBuilder to append to
- * @param certificate to print
- */
- private void renderX509(StringBuilder sb, X509Certificate certificate)
- {
- X500Principal issuer = certificate.getIssuerX500Principal();
- X500Principal subject = certificate.getSubjectX500Principal();
-
- sb.append("<table cellspacing='1' cellpadding='1'>\n");
-
- // subject
- addTitle(sb, R.getI18NString("service.gui.CERT_INFO_ISSUED_TO"));
- try
- {
- for(Rdn name : new LdapName(subject.getName()).getRdns())
- {
- String nameType = name.getType();
- String lblKey = "service.gui.CERT_INFO_" + nameType;
- String lbl = R.getI18NString(lblKey);
-
- if ((lbl == null) || ("!" + lblKey + "!").equals(lbl))
- lbl = nameType;
-
- final String value;
- Object nameValue = name.getValue();
-
- if (nameValue instanceof byte[])
- {
- byte[] nameValueAsByteArray = (byte[]) nameValue;
-
- value
- = getHex(nameValueAsByteArray) + " ("
- + new String(nameValueAsByteArray) + ")";
- }
- else
- value = nameValue.toString();
-
- addField(sb, lbl, value);
- }
- }
- catch (InvalidNameException ine)
- {
- addField(sb, R.getI18NString("service.gui.CERT_INFO_CN"),
- subject.getName());
- }
-
- // issuer
- addTitle(sb, R.getI18NString("service.gui.CERT_INFO_ISSUED_BY"));
- try
- {
- for(Rdn name : new LdapName(issuer.getName()).getRdns())
- {
- String nameType = name.getType();
- String lblKey = "service.gui.CERT_INFO_" + nameType;
- String lbl = R.getI18NString(lblKey);
-
- if ((lbl == null) || ("!" + lblKey + "!").equals(lbl))
- lbl = nameType;
-
- final String value;
- Object nameValue = name.getValue();
-
- if (nameValue instanceof byte[])
- {
- byte[] nameValueAsByteArray = (byte[]) nameValue;
-
- value
- = getHex(nameValueAsByteArray) + " ("
- + new String(nameValueAsByteArray) + ")";
- }
- else
- value = nameValue.toString();
-
- addField(sb, lbl, value);
- }
- }
- catch (InvalidNameException ine)
- {
- addField(sb, R.getI18NString("service.gui.CERT_INFO_CN"),
- issuer.getName());
- }
-
- // validity
- addTitle(sb, R.getI18NString("service.gui.CERT_INFO_VALIDITY"));
- addField(sb, R.getI18NString("service.gui.CERT_INFO_ISSUED_ON"),
- certificate.getNotBefore().toString());
- addField(sb, R.getI18NString("service.gui.CERT_INFO_EXPIRES_ON"),
- certificate.getNotAfter().toString());
-
- addTitle(sb, R.getI18NString("service.gui.CERT_INFO_FINGERPRINTS"));
- try
- {
- String sha1String = getThumbprint(certificate, "SHA1");
- String md5String = getThumbprint(certificate, "MD5");
-
- addField(sb, "SHA1:", sha1String);
- addField(sb, "MD5:", md5String);
- }
- catch (CertificateException e)
- {
- // do nothing as we cannot show this value
- }
-
- addTitle(sb, R.getI18NString("service.gui.CERT_INFO_CERT_DETAILS"));
-
- addField(sb, R.getI18NString("service.gui.CERT_INFO_SER_NUM"),
- certificate.getSerialNumber().toString());
-
- addField(sb, R.getI18NString("service.gui.CERT_INFO_VER"),
- String.valueOf(certificate.getVersion()));
-
- addField(sb, R.getI18NString("service.gui.CERT_INFO_SIGN_ALG"),
- String.valueOf(certificate.getSigAlgName()));
-
- addTitle(sb, R.getI18NString("service.gui.CERT_INFO_PUB_KEY_INFO"));
-
- addField(sb, R.getI18NString("service.gui.CERT_INFO_ALG"),
- certificate.getPublicKey().getAlgorithm());
-
- if(certificate.getPublicKey().getAlgorithm().equals("RSA"))
- {
- RSAPublicKey key = (RSAPublicKey)certificate.getPublicKey();
-
- addField(sb, R.getI18NString("service.gui.CERT_INFO_PUB_KEY"),
- R.getI18NString(
- "service.gui.CERT_INFO_KEY_BYTES_PRINT",
- new String[]{
- String.valueOf(key.getModulus().toByteArray().length-1),
- key.getModulus().toString(16)
- }));
-
- addField(sb, R.getI18NString("service.gui.CERT_INFO_EXP"),
- key.getPublicExponent().toString());
-
- addField(sb, R.getI18NString("service.gui.CERT_INFO_KEY_SIZE"),
- R.getI18NString(
- "service.gui.CERT_INFO_KEY_BITS_PRINT",
- new String[]{
- String.valueOf(key.getModulus().bitLength())}));
- }
- else if(certificate.getPublicKey().getAlgorithm().equals("DSA"))
- {
- DSAPublicKey key =
- (DSAPublicKey)certificate.getPublicKey();
-
- addField(sb, "Y:", key.getY().toString(16));
- }
-
- addField(sb, R.getI18NString("service.gui.CERT_INFO_SIGN"),
- R.getI18NString(
- "service.gui.CERT_INFO_KEY_BYTES_PRINT",
- new String[]{
- String.valueOf(certificate.getSignature().length),
- getHex(certificate.getSignature())
- }));
-
- sb.append("</table>\n");
- }
-
- /**
- * Add a title.
- *
- * @param sb StringBuilder to append to
- * @param title to print
- */
- private void addTitle(StringBuilder sb, String title)
- {
- sb.append("<tr><td colspan='2'")
- .append(" style='margin-top: 5pt; white-space: nowrap'><p><b>")
- .append(title).append("</b></p></td></tr>\n");
- }
-
- /**
- * Add a field.
- * @param sb StringBuilder to append to
- * @param field name of the certificate field
- * @param value to print
- */
- private void addField(StringBuilder sb, String field, String value)
- {
- sb.append("<tr>")
- .append("<td style='margin-left: 5pt; margin-right: 25pt;")
- .append(" white-space: nowrap'>")
- .append(field).append("</td>")
- .append("<td>").append(value).append("</td>")
- .append("</tr>\n");
- }
-
- /**
- * Converts the byte array to hex string.
- * @param raw the data.
- * @return the hex string.
- */
- private String getHex( byte [] raw )
- {
- if (raw == null)
- return null;
-
- StringBuilder hex = new StringBuilder(2 * raw.length);
- Formatter f = new Formatter(hex);
- try
- {
- for (byte b : raw)
- f.format("%02x", b);
- }
- finally
- {
- f.close();
- }
- return hex.toString();
- }
-
- /**
- * Calculates the hash of the certificate known as the "thumbprint"
- * and returns it as a string representation.
- *
- * @param cert The certificate to hash.
- * @param algorithm The hash algorithm to use.
- * @return The SHA-1 hash of the certificate.
- * @throws CertificateException
- */
- private static String getThumbprint(X509Certificate cert, String algorithm)
- throws CertificateException
- {
- MessageDigest digest;
- try
- {
- digest = MessageDigest.getInstance(algorithm);
- }
- catch (NoSuchAlgorithmException e)
- {
- throw new CertificateException(e);
- }
- byte[] encodedCert = cert.getEncoded();
- StringBuilder sb = new StringBuilder(encodedCert.length * 2);
- Formatter f = new Formatter(sb);
- try
- {
- for (byte b : digest.digest(encodedCert))
- f.format("%02x", b);
- }
- finally
- {
- f.close();
- }
- return sb.toString();
- }
-
- /**
- * Construct a "simplified name" based on the subject DN from the
- * certificate. The purpose is to have something shorter to display in the
- * list. The name used is one of the following DN parts, if
- * available, otherwise the complete DN:
- * 'CN', 'OU' or else 'O'.
- * @param cert to read subject DN from
- * @return the simplified name
- */
- private static String getSimplifiedName(X509Certificate cert)
- {
- final HashMap<String, String> parts = new HashMap<String, String>();
- try
- {
- for (Rdn name : new LdapName(
- cert.getSubjectX500Principal().getName()).getRdns())
- {
- if (name.getType() != null && name.getValue() != null)
- {
- parts.put(name.getType(), name.getValue().toString());
- }
- }
- }
- catch (InvalidNameException ignored) // NOPMD
- {
- }
-
- String result = parts.get("CN");
- if (result == null)
- {
- result = parts.get("OU");
- }
- if (result == null)
- {
- result = parts.get("O");
- }
- if (result == null)
- {
- result = cert.getSubjectX500Principal().getName();
- }
- return result;
- }
-
- /**
- * Called when the selection changed in the tree.
- * Loads the selected certificate.
- * @param e the event
- */
- private void valueChangedPerformed(TreeSelectionEvent e)
- {
- Object o = e.getNewLeadSelectionPath().getLastPathComponent();
- if (o instanceof DefaultMutableTreeNode)
- {
- DefaultMutableTreeNode node = (DefaultMutableTreeNode) o;
- infoTextPane.setText(toString(node.getUserObject()));
- }
- }
-}
+package net.java.sip.communicator.plugin.desktoputil;
+
+import java.awt.*;
+import java.security.*;
+import java.security.cert.*;
+import java.security.cert.Certificate;
+import java.security.interfaces.*;
+import java.util.*;
+
+import javax.naming.*;
+import javax.naming.ldap.*;
+import javax.security.auth.x500.*;
+import javax.swing.*;
+import javax.swing.border.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+import javax.swing.tree.*;
+
+import org.jitsi.service.resources.*;
+
+/**
+ * Panel that shows the content of an X509Certificate.
+ */
+public class X509CertificatePanel
+ extends TransparentPanel
+{
+ private static final long serialVersionUID = -8368302061995971947L;
+
+ private final JEditorPane infoTextPane = new JEditorPane();
+
+ private final ResourceManagementService R
+ = DesktopUtilActivator.getResources();
+
+ /**
+ * Constructs a X509 certificate panel from a single certificate.
+ * If a chain is available instead use the second constructor.
+ * This constructor is kept for backwards compatibility and for convenience
+ * when there is only one certificate of interest.
+ *
+ * @param certificate <tt>X509Certificate</tt> object
+ */
+ public X509CertificatePanel(Certificate certificate)
+ {
+ this(new Certificate[]
+ {
+ certificate
+ });
+ }
+
+ /**
+ * Constructs a X509 certificate panel.
+ *
+ * @param certificates <tt>X509Certificate</tt> objects
+ */
+ public X509CertificatePanel(Certificate[] certificates)
+ {
+ setLayout(new BorderLayout(5, 5));
+
+ // Certificate chain list
+ TransparentPanel topPanel = new TransparentPanel(new BorderLayout());
+ topPanel.add(new JLabel("<html><body><b>"
+ + R.getI18NString("service.gui.CERT_INFO_CHAIN")
+ + "</b></body></html>"), BorderLayout.NORTH);
+
+ DefaultMutableTreeNode top = new DefaultMutableTreeNode();
+ DefaultMutableTreeNode previous = top;
+ for (int i = certificates.length - 1; i >= 0; i--)
+ {
+ Certificate cert = certificates[i];
+ DefaultMutableTreeNode next = new DefaultMutableTreeNode(cert);
+ previous.add(next);
+ previous = next;
+ }
+ JTree tree = new JTree(top);
+ tree.setBorder(new BevelBorder(BevelBorder.LOWERED));
+ tree.setRootVisible(false);
+ tree.setExpandsSelectedPaths(true);
+ tree.getSelectionModel().setSelectionMode(
+ TreeSelectionModel.SINGLE_TREE_SELECTION);
+ tree.setCellRenderer(new DefaultTreeCellRenderer()
+ {
+
+ @Override
+ public Component getTreeCellRendererComponent(JTree tree,
+ Object value, boolean sel, boolean expanded, boolean leaf,
+ int row, boolean hasFocus)
+ {
+ JLabel component = (JLabel) super.getTreeCellRendererComponent(
+ tree, value, sel, expanded, leaf, row, hasFocus);
+ if (value instanceof DefaultMutableTreeNode)
+ {
+ Object o = ((DefaultMutableTreeNode) value).getUserObject();
+ if (o instanceof X509Certificate)
+ {
+ component.setText(
+ getSimplifiedName((X509Certificate) o));
+ }
+ else
+ {
+ // We don't know how to represent this certificate type,
+ // let's use the first 20 characters
+ String text = o.toString();
+ if (text.length() > 20)
+ {
+ text = text.substring(0, 20);
+ }
+ component.setText(text);
+ }
+ }
+ return component;
+ }
+
+ });
+ tree.getSelectionModel().addTreeSelectionListener(
+ new TreeSelectionListener()
+ {
+
+ @Override
+ public void valueChanged(TreeSelectionEvent e)
+ {
+ valueChangedPerformed(e);
+ }
+ });
+ tree.setSelectionPath(new TreePath(((
+ (DefaultTreeModel)tree.getModel()).getPathToRoot(previous))));
+ topPanel.add(tree, BorderLayout.CENTER);
+
+ add(topPanel, BorderLayout.NORTH);
+
+ // Certificate details pane
+ Caret caret = infoTextPane.getCaret();
+ if (caret instanceof DefaultCaret)
+ {
+ ((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
+ }
+
+ /*
+ * Make JEditorPane respect our default font because we will be using it
+ * to just display text.
+ */
+ infoTextPane.putClientProperty(
+ JEditorPane.HONOR_DISPLAY_PROPERTIES,
+ true);
+
+ infoTextPane.setOpaque(false);
+ infoTextPane.setEditable(false);
+ infoTextPane.setContentType("text/html");
+ infoTextPane.setText(toString(certificates[0]));
+
+ final JScrollPane certScroll = new JScrollPane(infoTextPane);
+ certScroll.setPreferredSize(new Dimension(300, 500));
+ add(certScroll, BorderLayout.CENTER);
+ }
+
+ /**
+ * Creates a String representation of the given object.
+ * @param certificate to print
+ * @return the String representation
+ */
+ private String toString(Object certificate)
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("<html><body>\n");
+
+ if (certificate instanceof X509Certificate)
+ {
+ renderX509(sb, (X509Certificate) certificate);
+ }
+ else
+ {
+ sb.append("<pre>\n");
+ sb.append(certificate.toString());
+ sb.append("</pre>\n");
+ }
+
+ sb.append("</body></html>");
+ return sb.toString();
+ }
+
+ /**
+ * Appends an HTML representation of the given X509Certificate.
+ * @param sb StringBuilder to append to
+ * @param certificate to print
+ */
+ private void renderX509(StringBuilder sb, X509Certificate certificate)
+ {
+ X500Principal issuer = certificate.getIssuerX500Principal();
+ X500Principal subject = certificate.getSubjectX500Principal();
+
+ sb.append("<table cellspacing='1' cellpadding='1'>\n");
+
+ // subject
+ addTitle(sb, R.getI18NString("service.gui.CERT_INFO_ISSUED_TO"));
+ try
+ {
+ for(Rdn name : new LdapName(subject.getName()).getRdns())
+ {
+ String nameType = name.getType();
+ String lblKey = "service.gui.CERT_INFO_" + nameType;
+ String lbl = R.getI18NString(lblKey);
+
+ if ((lbl == null) || ("!" + lblKey + "!").equals(lbl))
+ lbl = nameType;
+
+ final String value;
+ Object nameValue = name.getValue();
+
+ if (nameValue instanceof byte[])
+ {
+ byte[] nameValueAsByteArray = (byte[]) nameValue;
+
+ value
+ = getHex(nameValueAsByteArray) + " ("
+ + new String(nameValueAsByteArray) + ")";
+ }
+ else
+ value = nameValue.toString();
+
+ addField(sb, lbl, value);
+ }
+ }
+ catch (InvalidNameException ine)
+ {
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_CN"),
+ subject.getName());
+ }
+
+ // issuer
+ addTitle(sb, R.getI18NString("service.gui.CERT_INFO_ISSUED_BY"));
+ try
+ {
+ for(Rdn name : new LdapName(issuer.getName()).getRdns())
+ {
+ String nameType = name.getType();
+ String lblKey = "service.gui.CERT_INFO_" + nameType;
+ String lbl = R.getI18NString(lblKey);
+
+ if ((lbl == null) || ("!" + lblKey + "!").equals(lbl))
+ lbl = nameType;
+
+ final String value;
+ Object nameValue = name.getValue();
+
+ if (nameValue instanceof byte[])
+ {
+ byte[] nameValueAsByteArray = (byte[]) nameValue;
+
+ value
+ = getHex(nameValueAsByteArray) + " ("
+ + new String(nameValueAsByteArray) + ")";
+ }
+ else
+ value = nameValue.toString();
+
+ addField(sb, lbl, value);
+ }
+ }
+ catch (InvalidNameException ine)
+ {
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_CN"),
+ issuer.getName());
+ }
+
+ // validity
+ addTitle(sb, R.getI18NString("service.gui.CERT_INFO_VALIDITY"));
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_ISSUED_ON"),
+ certificate.getNotBefore().toString());
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_EXPIRES_ON"),
+ certificate.getNotAfter().toString());
+
+ addTitle(sb, R.getI18NString("service.gui.CERT_INFO_FINGERPRINTS"));
+ try
+ {
+ String sha256String = getThumbprint(certificate, "SHA-256");
+ String sha1String = getThumbprint(certificate, "SHA1");
+
+ addField(sb, "SHA256:", sha256String, 48);
+ addField(sb, "SHA1:", sha1String, 72);
+ }
+ catch (CertificateException e)
+ {
+ // do nothing as we cannot show this value
+ }
+
+ addTitle(sb, R.getI18NString("service.gui.CERT_INFO_CERT_DETAILS"));
+
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_SER_NUM"),
+ certificate.getSerialNumber().toString());
+
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_VER"),
+ String.valueOf(certificate.getVersion()));
+
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_SIGN_ALG"),
+ String.valueOf(certificate.getSigAlgName()));
+
+ addTitle(sb, R.getI18NString("service.gui.CERT_INFO_PUB_KEY_INFO"));
+
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_ALG"),
+ certificate.getPublicKey().getAlgorithm());
+
+ if(certificate.getPublicKey().getAlgorithm().equals("RSA"))
+ {
+ RSAPublicKey key = (RSAPublicKey)certificate.getPublicKey();
+
+ addField(sb,
+ R.getI18NString("service.gui.CERT_INFO_PUB_KEY"),
+ R.getI18NString("service.gui.CERT_INFO_KEY_BITS_PRINT",
+ new String[]{
+ String.valueOf(
+ (key.getModulus().toByteArray().length-1)*8)
+ }),
+ getHex(key.getModulus().toByteArray()),
+ 48);
+
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_EXP"),
+ key.getPublicExponent().toString());
+
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_KEY_SIZE"),
+ R.getI18NString(
+ "service.gui.CERT_INFO_KEY_BITS_PRINT",
+ new String[]{
+ String.valueOf(key.getModulus().bitLength())}));
+ }
+ else if(certificate.getPublicKey().getAlgorithm().equals("DSA"))
+ {
+ DSAPublicKey key =
+ (DSAPublicKey)certificate.getPublicKey();
+
+ addField(sb, "Y:", key.getY().toString(16));
+ }
+
+ addField(sb, R.getI18NString("service.gui.CERT_INFO_SIGN"),
+ R.getI18NString(
+ "service.gui.CERT_INFO_KEY_BITS_PRINT",
+ new String[]{
+ String.valueOf(certificate.getSignature().length*8),
+ }),
+ getHex(certificate.getSignature()),
+ 48);
+
+ sb.append("</table>\n");
+ }
+
+ /**
+ * Add a title.
+ *
+ * @param sb StringBuilder to append to
+ * @param title to print
+ */
+ private void addTitle(StringBuilder sb, String title)
+ {
+ sb.append("<tr><td colspan='2'")
+ .append(" style='margin-top: 5pt; white-space: nowrap'><p><b>")
+ .append(title).append("</b></p></td></tr>\n");
+ }
+
+ /**
+ * Add a field.
+ * @param sb StringBuilder to append to
+ * @param field name of the certificate field
+ * @param value to print
+ */
+ private void addField(StringBuilder sb, String field, String value)
+ {
+ addField(sb, field, value, null, 0);
+ }
+
+ /**
+ * Add a field.
+ * @param sb StringBuilder to append to
+ * @param field name of the certificate field
+ * @param value to print
+ * @param wrap force-wrap after number of characters
+ */
+ private void addField(StringBuilder sb, String field, String value,
+ int wrap)
+ {
+ addField(sb, field, value, null, wrap);
+ }
+
+ /**
+ * Add a field.
+ * @param sb StringBuilder to append to
+ * @param field name of the certificate field
+ * @param value to print (not wrapped)
+ * @param otherValue second line of value to print (wrapped)
+ * @param wrap force-wrap after number of characters
+ */
+ private void addField(StringBuilder sb, String field, String value,
+ String otherValue, int wrap)
+ {
+ sb.append("<tr><td style='margin-left: 5pt; margin-right: 25pt;")
+ .append("white-space: nowrap' valign='top'>")
+ .append(field).append("</td><td><span");
+
+ if (otherValue != null)
+ {
+ sb.append('>').append(value).append("</span><br/><span");
+ value = otherValue;
+ }
+
+ if (wrap > 0)
+ {
+ sb.append(" style='font-family:monospace'>");
+ for (int i = 0; i < value.length(); i++)
+ {
+ if (i % wrap == 0 && i > 0)
+ {
+ sb.append("<br/>");
+ }
+
+ sb.append(value.charAt(i));
+ }
+ }
+ else
+ {
+ sb.append(">");
+ sb.append(value);
+ }
+
+ sb.append("</span></td></tr>");
+ }
+
+ /**
+ * Converts the byte array to hex string.
+ * @param raw the data.
+ * @return the hex string.
+ */
+ private String getHex( byte [] raw )
+ {
+ if (raw == null)
+ return null;
+
+ StringBuilder hex = new StringBuilder(2 * raw.length);
+ Formatter f = new Formatter(hex);
+ try
+ {
+ for (byte b : raw)
+ f.format("%02X:", b);
+ }
+ finally
+ {
+ f.close();
+ }
+ return hex.substring(0, hex.length() - 1);
+ }
+
+ /**
+ * Calculates the hash of the certificate known as the "thumbprint"
+ * and returns it as a string representation.
+ *
+ * @param cert The certificate to hash.
+ * @param algorithm The hash algorithm to use.
+ * @return The SHA-1 hash of the certificate.
+ * @throws CertificateException
+ */
+ private static String getThumbprint(X509Certificate cert, String algorithm)
+ throws CertificateException
+ {
+ MessageDigest digest;
+ try
+ {
+ digest = MessageDigest.getInstance(algorithm);
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ throw new CertificateException(e);
+ }
+
+ byte[] encodedCert = cert.getEncoded();
+ StringBuilder sb = new StringBuilder(encodedCert.length * 2);
+ Formatter f = new Formatter(sb);
+ try
+ {
+ for (byte b : digest.digest(encodedCert))
+ f.format("%02X:", b);
+ }
+ finally
+ {
+ f.close();
+ }
+
+ return sb.substring(0, sb.length() - 1);
+ }
+
+ /**
+ * Construct a "simplified name" based on the subject DN from the
+ * certificate. The purpose is to have something shorter to display in the
+ * list. The name used is one of the following DN parts, if
+ * available, otherwise the complete DN:
+ * 'CN', 'OU' or else 'O'.
+ * @param cert to read subject DN from
+ * @return the simplified name
+ */
+ private static String getSimplifiedName(X509Certificate cert)
+ {
+ final HashMap<String, String> parts = new HashMap<String, String>();
+ try
+ {
+ for (Rdn name : new LdapName(
+ cert.getSubjectX500Principal().getName()).getRdns())
+ {
+ if (name.getType() != null && name.getValue() != null)
+ {
+ parts.put(name.getType(), name.getValue().toString());
+ }
+ }
+ }
+ catch (InvalidNameException ignored) // NOPMD
+ {
+ }
+
+ String result = parts.get("CN");
+ if (result == null)
+ {
+ result = parts.get("OU");
+ }
+ if (result == null)
+ {
+ result = parts.get("O");
+ }
+ if (result == null)
+ {
+ result = cert.getSubjectX500Principal().getName();
+ }
+ return result;
+ }
+
+ /**
+ * Called when the selection changed in the tree.
+ * Loads the selected certificate.
+ * @param e the event
+ */
+ private void valueChangedPerformed(TreeSelectionEvent e)
+ {
+ Object o = e.getNewLeadSelectionPath().getLastPathComponent();
+ if (o instanceof DefaultMutableTreeNode)
+ {
+ DefaultMutableTreeNode node = (DefaultMutableTreeNode) o;
+ infoTextPane.setText(toString(node.getUserObject()));
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java
index 443171b..ad05797 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomDestroyReasonDialog.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,175 +15,175 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.desktoputil.chat;
-
-import java.awt.*;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * Dialog with fields for reason and alternate address.
- *
- * @author Hristo Terezov
- */
-public class ChatRoomDestroyReasonDialog extends MessageDialog
-{
- /**
- * The <tt>Logger</tt> used by the <tt>ChatRoomDestroyReasonDialog</tt>
- * class and its instances for logging output.
- */
- private static Logger logger
- = Logger.getLogger(ChatRoomDestroyReasonDialog.class);
-
- /**
- * Serial id.
- */
- private static final long serialVersionUID = -916498752420264164L;
-
- /**
- * Text field for the alternate address.
- */
- private SIPCommTextField alternateAddress
- = new SIPCommTextField("chatroom@example.com");
-
- /**
- * Text field for reason text.
- */
- private JTextField reasonField = new JTextField();
-
- /**
- * Constructs new chat room destroy dialog.
- *
- * @param title the title of the dialog
- * @param message the message shown in this dialog
- */
- public ChatRoomDestroyReasonDialog(String title, String message)
- {
- super(null, title, message,
- DesktopUtilActivator.getResources().getI18NString("service.gui.OK"),
- false);
- this.setIcon((ImageIcon)null);
-
- alternateAddress.setFont(alternateAddress.getFont().deriveFont(12f));
-
- JLabel altAddressLabel
- = new JLabel(DesktopUtilActivator.getResources()
- .getI18NString("service.gui.ALTERNATE_ADDRESS") + ":");
-
- JLabel reasonLabel
- = new JLabel(DesktopUtilActivator.getResources()
- .getI18NString("service.gui.REASON") + ":");
-
- JPanel labelsPanel = new JPanel(new GridLayout(2, 1));
- labelsPanel.add(reasonLabel);
- labelsPanel.add(altAddressLabel);
-
- JPanel valuesPanel = new JPanel(new GridLayout(2, 1));
- valuesPanel.add(reasonField);
- valuesPanel.add(alternateAddress);
-
- JPanel fieldsPanel = new JPanel(new BorderLayout());
- fieldsPanel .add(labelsPanel, BorderLayout.WEST);
-
- fieldsPanel.add(valuesPanel, BorderLayout.CENTER);
- fieldsPanel.add(new JLabel(" "), BorderLayout.EAST);
- fieldsPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- fieldsPanel.setOpaque(false);
-
-
-
- replaceCheckBoxPanel(fieldsPanel);
- this.pack();
- }
-
- /**
- * Returns the text entered in the alternate address field.
- *
- * @return the text from the alternate address field.
- */
- public String getAlternateAddress()
- {
- return alternateAddress.getText();
- }
-
- /**
- * Returns the text entered in the reason field.
- *
- * @return the text from the reason field.
- */
- public String getReason()
- {
- return reasonField.getText();
- }
-
- /**
- * Opens a dialog with a fields for the reason and alternate address and
- * returns them.
- *
- * @return array with the reason and alternate address values.
- */
- public static String[] getDestroyOptions()
- {
- final ChatRoomDestroyReasonDialog[] res
- = new ChatRoomDestroyReasonDialog[1];
-
- try
- {
- SwingUtilities.invokeAndWait(new Runnable()
- {
- @Override
- public void run()
- {
- ResourceManagementService R
- = DesktopUtilActivator.getResources();
-
- res[0] = new ChatRoomDestroyReasonDialog(
- R.getI18NString("service.gui.DESTROY_CHATROOM"),
- R.getI18NString("service.gui.DESTROY_MESSAGE"));
- }
- });
- }
- catch(Throwable t)
- {
- logger.error("Error creating dialog", t);
- return null;
- }
-
- ChatRoomDestroyReasonDialog reasonDialog = res[0];
-
- int result = reasonDialog.showDialog();
-
- String destroyOptions[] = new String[2];
-
- if (result == MessageDialog.OK_RETURN_CODE)
- {
- destroyOptions[0] = proccessFieldValues(reasonDialog.getReason());
- destroyOptions[1]
- = proccessFieldValues(reasonDialog.getAlternateAddress());
- }
- else
- {
- destroyOptions = null;
- }
-
-
- return destroyOptions;
- }
-
- private static String proccessFieldValues(String value)
- {
- if(value != null)
- {
- value = value.trim();
- if(value.equals(""))
- value = null;
- }
- return value;
- }
-
-}
+package net.java.sip.communicator.plugin.desktoputil.chat;
+
+import java.awt.*;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.util.*;
+
+import org.jitsi.service.resources.*;
+
+/**
+ * Dialog with fields for reason and alternate address.
+ *
+ * @author Hristo Terezov
+ */
+public class ChatRoomDestroyReasonDialog extends MessageDialog
+{
+ /**
+ * The <tt>Logger</tt> used by the <tt>ChatRoomDestroyReasonDialog</tt>
+ * class and its instances for logging output.
+ */
+ private static Logger logger
+ = Logger.getLogger(ChatRoomDestroyReasonDialog.class);
+
+ /**
+ * Serial id.
+ */
+ private static final long serialVersionUID = -916498752420264164L;
+
+ /**
+ * Text field for the alternate address.
+ */
+ private SIPCommTextField alternateAddress
+ = new SIPCommTextField("chatroom@example.com");
+
+ /**
+ * Text field for reason text.
+ */
+ private JTextField reasonField = new JTextField();
+
+ /**
+ * Constructs new chat room destroy dialog.
+ *
+ * @param title the title of the dialog
+ * @param message the message shown in this dialog
+ */
+ public ChatRoomDestroyReasonDialog(String title, String message)
+ {
+ super(null, title, message,
+ DesktopUtilActivator.getResources().getI18NString("service.gui.OK"),
+ false);
+ this.setIcon((ImageIcon)null);
+
+ alternateAddress.setFont(alternateAddress.getFont().deriveFont(12f));
+
+ JLabel altAddressLabel
+ = new JLabel(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.ALTERNATE_ADDRESS") + ":");
+
+ JLabel reasonLabel
+ = new JLabel(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.REASON") + ":");
+
+ JPanel labelsPanel = new JPanel(new GridLayout(2, 1));
+ labelsPanel.add(reasonLabel);
+ labelsPanel.add(altAddressLabel);
+
+ JPanel valuesPanel = new JPanel(new GridLayout(2, 1));
+ valuesPanel.add(reasonField);
+ valuesPanel.add(alternateAddress);
+
+ JPanel fieldsPanel = new JPanel(new BorderLayout());
+ fieldsPanel .add(labelsPanel, BorderLayout.WEST);
+
+ fieldsPanel.add(valuesPanel, BorderLayout.CENTER);
+ fieldsPanel.add(new JLabel(" "), BorderLayout.EAST);
+ fieldsPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+ fieldsPanel.setOpaque(false);
+
+
+
+ replaceCheckBoxPanel(fieldsPanel);
+ this.pack();
+ }
+
+ /**
+ * Returns the text entered in the alternate address field.
+ *
+ * @return the text from the alternate address field.
+ */
+ public String getAlternateAddress()
+ {
+ return alternateAddress.getText();
+ }
+
+ /**
+ * Returns the text entered in the reason field.
+ *
+ * @return the text from the reason field.
+ */
+ public String getReason()
+ {
+ return reasonField.getText();
+ }
+
+ /**
+ * Opens a dialog with a fields for the reason and alternate address and
+ * returns them.
+ *
+ * @return array with the reason and alternate address values.
+ */
+ public static String[] getDestroyOptions()
+ {
+ final ChatRoomDestroyReasonDialog[] res
+ = new ChatRoomDestroyReasonDialog[1];
+
+ try
+ {
+ SwingUtilities.invokeAndWait(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ ResourceManagementService R
+ = DesktopUtilActivator.getResources();
+
+ res[0] = new ChatRoomDestroyReasonDialog(
+ R.getI18NString("service.gui.DESTROY_CHATROOM"),
+ R.getI18NString("service.gui.DESTROY_MESSAGE"));
+ }
+ });
+ }
+ catch(Throwable t)
+ {
+ logger.error("Error creating dialog", t);
+ return null;
+ }
+
+ ChatRoomDestroyReasonDialog reasonDialog = res[0];
+
+ int result = reasonDialog.showDialog();
+
+ String destroyOptions[] = new String[2];
+
+ if (result == MessageDialog.OK_RETURN_CODE)
+ {
+ destroyOptions[0] = proccessFieldValues(reasonDialog.getReason());
+ destroyOptions[1]
+ = proccessFieldValues(reasonDialog.getAlternateAddress());
+ }
+ else
+ {
+ destroyOptions = null;
+ }
+
+
+ return destroyOptions;
+ }
+
+ private static String proccessFieldValues(String value)
+ {
+ if(value != null)
+ {
+ value = value.trim();
+ if(value.equals(""))
+ value = null;
+ }
+ return value;
+ }
+
+}
diff --git a/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java
index 88a5327..db04c56 100644
--- a/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java
+++ b/src/net/java/sip/communicator/plugin/desktoputil/chat/ChatRoomJoinOptionsDialog.java
@@ -1,4 +1,4 @@
-/**
+/**
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,174 +15,174 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.desktoputil.chat;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-import javax.swing.border.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Dialog with fields for nickname and subject.
- *
- * @author Hristo Terezov
- */
-public class ChatRoomJoinOptionsDialog extends ChatOperationReasonDialog
-{
- /**
- * Serial id.
- */
- private static final long serialVersionUID = -916498752420264164L;
-
- /**
- * Text field for the subject.
- */
- private SIPCommTextField subject = new SIPCommTextField(DesktopUtilActivator
- .getResources().getI18NString("service.gui.SUBJECT"));
-
- /**
- * Label that hides and shows the subject fields panel on click.
- */
- private JLabel cmdExpandSubjectFields;
-
- /**
- * Panel that holds the subject fields.
- */
- private JPanel subjectFieldsPannel = new JPanel(new BorderLayout());
-
- /**
- * Adds the subject fields to dialog. Sets action listeners.
- *
- * @param title the title of the dialog
- * @param message the message shown in this dialog
- * @param disableOKIfReasonIsEmpty if true the OK button will be
- * disabled if the reason text is empty.
- * @param showReasonLabel specify if we want the "Reason:" label
- * @param dontDisplaySubjectFields if true the sibject fields will be
- * hidden.
- */
- public ChatRoomJoinOptionsDialog(String title, String message,
- boolean showReasonLabel,
- boolean disableOKIfReasonIsEmpty,
- boolean dontDisplaySubjectFields)
- {
- super(title,
- message,
- showReasonLabel,
- disableOKIfReasonIsEmpty);
-
- if(dontDisplaySubjectFields)
- return;
-
- JPanel subjectPanel = new JPanel(new BorderLayout());
- subjectPanel.setOpaque(false);
- subjectPanel.setBorder(
- BorderFactory.createEmptyBorder(10, 0, 0, 0));
-
- subjectFieldsPannel.setBorder(
- BorderFactory.createEmptyBorder(10, 30, 0, 0));
- subjectFieldsPannel.setOpaque(false);
- subjectFieldsPannel.add(subject, BorderLayout.CENTER);
- subjectFieldsPannel.setVisible(false);
- subject.setFont(getFont().deriveFont(12f));
-
- cmdExpandSubjectFields = new JLabel();
- cmdExpandSubjectFields.setBorder(new EmptyBorder(0, 5, 0, 0));
- cmdExpandSubjectFields.setIcon(DesktopUtilActivator.getResources()
- .getImage("service.gui.icons.RIGHT_ARROW_ICON"));
- cmdExpandSubjectFields.setText(DesktopUtilActivator
- .getResources().getI18NString("service.gui.SET_SUBJECT"));
- cmdExpandSubjectFields.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mouseClicked(MouseEvent e)
- {
- cmdExpandSubjectFields.setIcon(
- UtilActivator.getResources().getImage(
- subjectFieldsPannel.isVisible()
- ? "service.gui.icons.RIGHT_ARROW_ICON"
- : "service.gui.icons.DOWN_ARROW_ICON"));
-
- subjectFieldsPannel.setVisible(
- !subjectFieldsPannel.isVisible());
-
- pack();
- }
- });
- subjectPanel.add(cmdExpandSubjectFields,BorderLayout.NORTH);
- subjectPanel.add(subjectFieldsPannel,BorderLayout.CENTER);
- addToReasonFieldPannel(subjectPanel);
- this.pack();
- }
-
- /**
- * Returns the text entered in the subject field.
- *
- * @return the text from the subject field.
- */
- public String getSubject()
- {
- return subject.getText();
- }
-
- /**
- * Opens a dialog with a fields for the nickname and the subject of the room
- * and returns them.
- *
- * @param pps the protocol provider associated with the chat room.
- * @param chatRoomId the id of the chat room.
- * @param defaultNickname the nickname to show if any
- * @return array with the nickname and subject values.
- */
- public static String[] getJoinOptions(ProtocolProviderService pps,
- String chatRoomId, String defaultNickname)
- {
- return getJoinOptions(false, pps, chatRoomId, defaultNickname);
- }
-
- /**
- * Opens a dialog with a fields for the nickname and the subject of the room
- * and returns them.
- *
- * @param dontDisplaySubjectFields if true the subject fields will be hidden
- * @param pps the protocol provider associated with the chat room.
- * @param chatRoomId the id of the chat room.
- * @param defaultNickname the nickname to show if any
- * @return array with the nickname and subject values.
- */
- public static String[] getJoinOptions(boolean dontDisplaySubjectFields,
- ProtocolProviderService pps, String chatRoomId, String defaultNickname)
- {
- String nickName = null;
- ChatRoomJoinOptionsDialog reasonDialog =
- new ChatRoomJoinOptionsDialog(DesktopUtilActivator.getResources()
- .getI18NString("service.gui.CHANGE_NICKNAME"),
- DesktopUtilActivator.getResources().getI18NString(
- "service.gui.CHANGE_NICKNAME_LABEL"), false, true,
- dontDisplaySubjectFields);
- reasonDialog.setIcon(new ImageIcon(DesktopUtilActivator.getImage(
- "service.gui.icons.CHANGE_NICKNAME_16x16")));
-
- if(defaultNickname != null)
- reasonDialog.setReasonFieldText(defaultNickname);
-
- int result = reasonDialog.showDialog();
-
- if (result == MessageDialog.OK_RETURN_CODE)
- {
- nickName = reasonDialog.getReason().trim();
- ConfigurationUtils.updateChatRoomProperty(
- pps,
- chatRoomId, "userNickName", nickName);
-
- }
- String[] joinOptions = {nickName, reasonDialog.getSubject()};
- return joinOptions;
- }
-
-}
+package net.java.sip.communicator.plugin.desktoputil.chat;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+import javax.swing.border.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+/**
+ * Dialog with fields for nickname and subject.
+ *
+ * @author Hristo Terezov
+ */
+public class ChatRoomJoinOptionsDialog extends ChatOperationReasonDialog
+{
+ /**
+ * Serial id.
+ */
+ private static final long serialVersionUID = -916498752420264164L;
+
+ /**
+ * Text field for the subject.
+ */
+ private SIPCommTextField subject = new SIPCommTextField(DesktopUtilActivator
+ .getResources().getI18NString("service.gui.SUBJECT"));
+
+ /**
+ * Label that hides and shows the subject fields panel on click.
+ */
+ private JLabel cmdExpandSubjectFields;
+
+ /**
+ * Panel that holds the subject fields.
+ */
+ private JPanel subjectFieldsPannel = new JPanel(new BorderLayout());
+
+ /**
+ * Adds the subject fields to dialog. Sets action listeners.
+ *
+ * @param title the title of the dialog
+ * @param message the message shown in this dialog
+ * @param disableOKIfReasonIsEmpty if true the OK button will be
+ * disabled if the reason text is empty.
+ * @param showReasonLabel specify if we want the "Reason:" label
+ * @param dontDisplaySubjectFields if true the sibject fields will be
+ * hidden.
+ */
+ public ChatRoomJoinOptionsDialog(String title, String message,
+ boolean showReasonLabel,
+ boolean disableOKIfReasonIsEmpty,
+ boolean dontDisplaySubjectFields)
+ {
+ super(title,
+ message,
+ showReasonLabel,
+ disableOKIfReasonIsEmpty);
+
+ if(dontDisplaySubjectFields)
+ return;
+
+ JPanel subjectPanel = new JPanel(new BorderLayout());
+ subjectPanel.setOpaque(false);
+ subjectPanel.setBorder(
+ BorderFactory.createEmptyBorder(10, 0, 0, 0));
+
+ subjectFieldsPannel.setBorder(
+ BorderFactory.createEmptyBorder(10, 30, 0, 0));
+ subjectFieldsPannel.setOpaque(false);
+ subjectFieldsPannel.add(subject, BorderLayout.CENTER);
+ subjectFieldsPannel.setVisible(false);
+ subject.setFont(getFont().deriveFont(12f));
+
+ cmdExpandSubjectFields = new JLabel();
+ cmdExpandSubjectFields.setBorder(new EmptyBorder(0, 5, 0, 0));
+ cmdExpandSubjectFields.setIcon(DesktopUtilActivator.getResources()
+ .getImage("service.gui.icons.RIGHT_ARROW_ICON"));
+ cmdExpandSubjectFields.setText(DesktopUtilActivator
+ .getResources().getI18NString("service.gui.SET_SUBJECT"));
+ cmdExpandSubjectFields.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mouseClicked(MouseEvent e)
+ {
+ cmdExpandSubjectFields.setIcon(
+ UtilActivator.getResources().getImage(
+ subjectFieldsPannel.isVisible()
+ ? "service.gui.icons.RIGHT_ARROW_ICON"
+ : "service.gui.icons.DOWN_ARROW_ICON"));
+
+ subjectFieldsPannel.setVisible(
+ !subjectFieldsPannel.isVisible());
+
+ pack();
+ }
+ });
+ subjectPanel.add(cmdExpandSubjectFields,BorderLayout.NORTH);
+ subjectPanel.add(subjectFieldsPannel,BorderLayout.CENTER);
+ addToReasonFieldPannel(subjectPanel);
+ this.pack();
+ }
+
+ /**
+ * Returns the text entered in the subject field.
+ *
+ * @return the text from the subject field.
+ */
+ public String getSubject()
+ {
+ return subject.getText();
+ }
+
+ /**
+ * Opens a dialog with a fields for the nickname and the subject of the room
+ * and returns them.
+ *
+ * @param pps the protocol provider associated with the chat room.
+ * @param chatRoomId the id of the chat room.
+ * @param defaultNickname the nickname to show if any
+ * @return array with the nickname and subject values.
+ */
+ public static String[] getJoinOptions(ProtocolProviderService pps,
+ String chatRoomId, String defaultNickname)
+ {
+ return getJoinOptions(false, pps, chatRoomId, defaultNickname);
+ }
+
+ /**
+ * Opens a dialog with a fields for the nickname and the subject of the room
+ * and returns them.
+ *
+ * @param dontDisplaySubjectFields if true the subject fields will be hidden
+ * @param pps the protocol provider associated with the chat room.
+ * @param chatRoomId the id of the chat room.
+ * @param defaultNickname the nickname to show if any
+ * @return array with the nickname and subject values.
+ */
+ public static String[] getJoinOptions(boolean dontDisplaySubjectFields,
+ ProtocolProviderService pps, String chatRoomId, String defaultNickname)
+ {
+ String nickName = null;
+ ChatRoomJoinOptionsDialog reasonDialog =
+ new ChatRoomJoinOptionsDialog(DesktopUtilActivator.getResources()
+ .getI18NString("service.gui.CHANGE_NICKNAME"),
+ DesktopUtilActivator.getResources().getI18NString(
+ "service.gui.CHANGE_NICKNAME_LABEL"), false, true,
+ dontDisplaySubjectFields);
+ reasonDialog.setIcon(new ImageIcon(DesktopUtilActivator.getImage(
+ "service.gui.icons.CHANGE_NICKNAME_16x16")));
+
+ if(defaultNickname != null)
+ reasonDialog.setReasonFieldText(defaultNickname);
+
+ int result = reasonDialog.showDialog();
+
+ if (result == MessageDialog.OK_RETURN_CODE)
+ {
+ nickName = reasonDialog.getReason().trim();
+ ConfigurationUtils.updateChatRoomProperty(
+ pps,
+ chatRoomId, "userNickName", nickName);
+
+ }
+ String[] joinOptions = {nickName, reasonDialog.getSubject()};
+ return joinOptions;
+ }
+
+}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccRegWizzActivator.java
deleted file mode 100644
index 7911eeb..0000000
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccRegWizzActivator.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.dictaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * Registers the <tt>DictAccountRegistrationWizard</tt> in the UI Service.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class DictAccRegWizzActivator
- implements BundleActivator
-{
- /**
- * OSGi bundle context.
- */
- public static BundleContext bundleContext;
-
- private static Logger logger = Logger.getLogger(
- DictAccRegWizzActivator.class);
-
- private static BrowserLauncherService browserLauncherService;
-
- private static WizardContainer wizardContainer;
-
- private static DictAccountRegistrationWizard dictWizard;
-
- private static UIService uiService;
-
- /**
- * Starts this bundle.
- *
- * @param bc The bundle context.
- */
- public void start(BundleContext bc) throws Exception {
-
- bundleContext = bc;
-
- ServiceReference uiServiceRef = bundleContext
- .getServiceReference(UIService.class.getName());
-
- uiService = (UIService) bundleContext.getService(uiServiceRef);
-
- wizardContainer = uiService.getAccountRegWizardContainer();
-
- dictWizard = new DictAccountRegistrationWizard(wizardContainer);
-
- //wizardContainer.addAccountRegistrationWizard(dictWizard);
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
-
- containerFilter.put(
- ProtocolProviderFactory.PROTOCOL,
- ProtocolNames.DICT);
-
- bundleContext.registerService(
- AccountRegistrationWizard.class.getName(),
- dictWizard,
- containerFilter);
- }
-
-
- /**
- * Stops this bundle.
- *
- * @param bundleContext The bundle context (unused).
- *
- * @throws Exception Throws an execption from the
- * "wizardContainer.removeAccountRegistrationWizard" method.
- *
- */
- public void stop(BundleContext bundleContext) throws Exception
- {
- //wizardContainer.removeAccountRegistrationWizard(dictWizard);
- }
-
- /**
- * Returns the <tt>ProtocolProviderFactory</tt> for the Dict protocol.
- * @return the <tt>ProtocolProviderFactory</tt> for the Dict protocol
- */
- public static ProtocolProviderFactory getDictProtocolProviderFactory() {
-
- ServiceReference[] serRefs = null;
-
- String osgiFilter = "("
- + ProtocolProviderFactory.PROTOCOL
- + "="+ProtocolNames.DICT+")";
-
- try {
- serRefs = bundleContext.getServiceReferences(
- ProtocolProviderFactory.class.getName(), osgiFilter);
- }
- catch (InvalidSyntaxException ex){
- logger.error("DictAccRegWizzActivator : " + ex);
- }
-
- return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
- }
-
- /**
- * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context.
- * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context
- */
- public static BrowserLauncherService getBrowserLauncher() {
- if (browserLauncherService == null) {
- ServiceReference serviceReference = bundleContext
- .getServiceReference(BrowserLauncherService.class.getName());
-
- browserLauncherService = (BrowserLauncherService) bundleContext
- .getService(serviceReference);
- }
-
- return browserLauncherService;
- }
-
- /**
- * Returns the <tt>UIService</tt>.
- *
- * @return the <tt>UIService</tt>
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistration.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistration.java
deleted file mode 100644
index a7aca60..0000000
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistration.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.dictaccregwizz;
-
-import net.java.dict4j.*;
-
-/**
- * The <tt>DictAccountRegistration</tt> is used to store all user input data
- * through the <tt>DictAccountRegistrationWizard</tt>.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class DictAccountRegistration
-{
- private String userID;
-
- /**
- * The hostname of the DICT server.
- */
- private String host;
-
- /**
- * The port of the DICT server.
- */
- private int port;
-
- /**
- * The strategy selected for the matching of words in dictionaries.
- */
- private Strategy strategy;
-
- /**
- * Returns the User ID of the dict registration account.
- * @return the User ID of the dict registration account.
- */
- public String getUserID()
- {
- return userID;
- }
-
- /**
- * Returns the port of the dict registration account.
- * @return the port of the dict registration account.
- */
- public int getPort() {
- return this.port;
- }
-
- /**
- * Sets the port of the dict registration account.
- * @param port the port of the dict registration account.
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- /**
- * Returns the host of the dict registration account.
- * @return the host of the dict registration account.
- */
- public String getHost() {
- return this.host;
- }
-
- /**
- * Sets the host of the dict registration account.
- * @param host The host of the dict registration account.
- */
- public void setHost(String host) {
- this.host = host;
- }
-
- /**
- * Returns the strategy that will be used for this dict account.
- * @return the strategy that will be used for this dict account.
- */
- public Strategy getStrategy() {
- return this.strategy;
- }
-
- /**
- * Sets the strategy for this dict account.
- * @param strategy the strategy for this dict account.
- */
- public void setStrategy(Strategy strategy) {
- this.strategy = strategy;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistrationWizard.java
deleted file mode 100644
index 115d65c..0000000
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/DictAccountRegistrationWizard.java
+++ /dev/null
@@ -1,429 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.dictaccregwizz;
-
-import java.awt.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * The <tt>DictAccountRegistrationWizard</tt> is an implementation of the
- * <tt>AccountRegistrationWizard</tt> for the Dict protocol. It should allow
- * the user to create and configure a new Dict account.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class DictAccountRegistrationWizard
- extends DesktopAccountRegistrationWizard
-{
- private final Logger logger
- = Logger.getLogger(DictAccountRegistrationWizard.class);
-
- /**
- * The reference to the first page of the wizard.
- */
- private FirstWizardPage firstWizardPage;
-
- /**
- * The registration of the DICT account.
- */
- private DictAccountRegistration registration = new DictAccountRegistration();
-
- /**
- * The protocole provider.
- */
- private ProtocolProviderService protocolProvider;
-
- /**
- * Creates an instance of <tt>DictAccountRegistrationWizard</tt>.
- *
- * @param wizardContainer the wizard container, where this wizard is added
- */
- public DictAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- setWizardContainer(wizardContainer);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * @return Returns the icon to be used for this wizard.
- */
- @Override
- public byte[] getIcon()
- {
- return Resources.getImage(Resources.DICT_LOGO);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code>
- * method. Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- @Override
- public byte[] getPageImage()
- {
- return Resources.getImage(Resources.PAGE_IMAGE);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method.
- * @return Returns the protocol name for this wizard.
- */
- @Override
- public String getProtocolName()
- {
- return Resources.getString("plugin.dictaccregwizz.PROTOCOL_NAME");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code> method.
- * @return Returns the description of the protocol for this wizard.
- */
- @Override
- public String getProtocolDescription()
- {
- return Resources.getString("plugin.dictaccregwizz.PROTOCOL_DESCRIPTION");
- }
-
- /**
- * Returns the set of pages contained in this wizard.
- *
- * @return Returns the set of pages contained in this wizard.
- */
- @Override
- public Iterator<WizardPage> getPages()
- {
- java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
- this.firstWizardPage = new FirstWizardPage(this);
- pages.add(this.firstWizardPage);
- return pages.iterator();
- }
-
- /**
- * Returns the set of data that user has entered through this wizard.
- * @return Returns the set of data that user has entered through this wizard.
- */
- @Override
- public Iterator<Map.Entry<String, String>> getSummary()
- {
- Map<String, String> summaryTable = new LinkedHashMap<String, String>();
-
- summaryTable.put("Host", registration.getHost());
- summaryTable.put("Port", String.valueOf(registration.getPort()));
- summaryTable.put("Strategy", registration.getStrategy().getName());
-
- return summaryTable.entrySet().iterator();
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin()
- throws OperationFailedException
- {
- firstWizardPage.commitPage();
-
- return signin(registration.getUserID(), null);
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- *
- * @param userName the user name to sign in with
- * @param password the password to sign in with
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin(String userName, String password)
- throws OperationFailedException
- {
- ProtocolProviderFactory factory
- = DictAccRegWizzActivator.getDictProtocolProviderFactory();
-
- return this.installAccount(factory, registration.getHost(),
- registration.getPort(),
- registration.getStrategy().getCode());
- }
-
- /**
- * Creates an account for the given user and password.
- *
- * @param providerFactory the ProtocolProviderFactory which will create the
- * account.
- * @param host The hostname of the DICT server.
- * @param port The port used by the DICT server.
- * @param strategy The strategy choosen for matching words in the
- * dictionnaries.
- * @return the <tt>ProtocolProviderService</tt> for the new account.
- */
- public ProtocolProviderService installAccount(
- ProtocolProviderFactory providerFactory,
- String host,
- int port,
- String strategy)
- throws OperationFailedException
- {
- Hashtable<String, String> accountProperties
- = new Hashtable<String, String>();
-
- accountProperties.put( ProtocolProviderFactory.ACCOUNT_ICON_PATH,
- "resources/images/protocol/dict/dict-32x32.png");
-
- // Set this property to indicate that Dict account does not require
- // authentication.
- accountProperties.put(
- ProtocolProviderFactory.NO_PASSWORD_REQUIRED,
- new Boolean(true).toString());
-
- // Save host
- accountProperties.put(ProtocolProviderFactory.SERVER_ADDRESS, host);
- // Save port
- accountProperties.put( ProtocolProviderFactory.SERVER_PORT,
- String.valueOf(port));
- // Save strategy
- accountProperties.put(ProtocolProviderFactory.STRATEGY, strategy);
-
- if (isModification())
- {
- providerFactory.uninstallAccount(protocolProvider.getAccountID());
- this.protocolProvider = null;
- setModification(false);
- }
-
- try
- {
- String uid = this.generateUID();
- AccountID accountID =
- providerFactory.installAccount(uid, accountProperties);
-
- ServiceReference serRef =
- providerFactory.getProviderForAccount(accountID);
-
- protocolProvider =
- (ProtocolProviderService) DictAccRegWizzActivator.bundleContext
- .getService(serRef);
- }
- catch (IllegalStateException exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Account already exists.",
- OperationFailedException.IDENTIFICATION_CONFLICT);
- }
- catch (Exception exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Failed to add account",
- OperationFailedException.GENERAL_ERROR);
- }
-
-
- return protocolProvider;
- }
-
- /**
- * Fills the UIN and Password fields in this panel with the data coming
- * from the given protocolProvider.
- *
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load
- * the data from.
- */
- @Override
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- setModification(true);
-
- this.protocolProvider = protocolProvider;
-
- this.registration = new DictAccountRegistration();
-
- this.firstWizardPage.loadAccount(protocolProvider);
- }
-
- /**
- * Returns the registration object, which will store all the data through
- * the wizard.
- *
- * @return the registration object, which will store all the data through
- * the wizard
- */
- public DictAccountRegistration getRegistration()
- {
- return registration;
- }
-
- /**
- * Returns the size of this wizard.
- * @return the size of this wizard
- */
- @Override
- public Dimension getSize()
- {
- return new Dimension(300, 150);
- }
-
- /**
- * Returns the identifier of the page to show first in the wizard.
- * @return the identifier of the page to show first in the wizard.
- */
- @Override
- public Object getFirstPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- /**
- * Returns the identifier of the page to show last in the wizard.
- * @return the identifier of the page to show last in the wizard.
- */
- @Override
- public Object getLastPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- /**
- * Generate the UID for the acount
- * @return the new UID
- */
- private String generateUID()
- {
- String uid;
- int nbAccounts = this.getNumberOfAccounts();
- String host = this.registration.getHost();
- int nbAccountsForHost = this.getNbAccountForHost(host);
-
- if (nbAccounts == 0 || (this.isModification() && nbAccounts == 1) ||
- nbAccountsForHost == 0
- || (this.isModification() && nbAccountsForHost == 1))
- {
- // We create the first account or we edit the onlyone
- // Or we create the first account for this server or edit the onlyone
- uid = host;
- }
- else
- {
- uid = host + ":" + this.registration.getPort();
- }
-
- return uid;
- }
-
- /**
- * Returns the number of accounts stored for the protocol
- * @return the number of accounts stored for the protocol
- */
- private int getNumberOfAccounts()
- {
- ProtocolProviderFactory factory =
- DictAccRegWizzActivator.getDictProtocolProviderFactory();
-
- return factory.getRegisteredAccounts().size();
- }
-
- /**
- * Returns the number of account for a given host
- * @param hostName the host
- * @return the number of account for a given host
- */
- private int getNbAccountForHost(String host)
- {
- ProtocolProviderFactory factory =
- DictAccRegWizzActivator.getDictProtocolProviderFactory();
-
- ArrayList<AccountID> registeredAccounts
- = factory.getRegisteredAccounts();
- int total = 0;
-
- for (int i = 0; i < registeredAccounts.size(); i++)
- {
- AccountID accountID = registeredAccounts.get(i);
-
- // The host is always stored at the start
- if (accountID.getUserID().startsWith(host.toLowerCase()))
- {
- total++;
- }
- }
- return total;
- }
-
- /**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
- */
- @Override
- public String getUserNameExample()
- {
- return null;
- }
-
- /**
- * Indicates whether this wizard enables the simple "sign in" form shown
- * when the user opens the application for the first time. The simple
- * "sign in" form allows user to configure her account in one click, just
- * specifying her username and password and leaving any other configuration
- * as by default.
- * @return <code>true</code> if the simple "Sign in" form is enabled or
- * <code>false</code> otherwise.
- */
- @Override
- public boolean isSimpleFormEnabled()
- {
- return false;
- }
-
- /**
- * Returns a simple account registration form that would be the first form
- * shown to the user. Only if the user needs more settings she'll choose
- * to open the advanced wizard, consisted by all pages.
- *
- * @param isCreateAccount indicates if the simple form should be opened as
- * a create account form or as a login form
- * @return a simple account registration form
- */
- @Override
- public Object getSimpleForm(boolean isCreateAccount)
- {
- firstWizardPage = new FirstWizardPage(this);
-
- return firstWizardPage.getSimpleForm();
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/FirstWizardPage.java
deleted file mode 100644
index 59cfd27..0000000
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/FirstWizardPage.java
+++ /dev/null
@@ -1,637 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.dictaccregwizz;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.util.List;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import net.java.dict4j.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- * The <tt>FirstWizardPage</tt> is the page, where user could enter the host,
- * port and the strategy of the account.
- *
- * @author ROTH Damien
- * @author LITZELMANN Cedric
- */
-public class FirstWizardPage
- extends TransparentPanel
- implements WizardPage, DocumentListener, ActionListener
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
-
- private JPanel hostPortPanel = new TransparentPanel(new BorderLayout(10, 10));
-
- private JPanel labelsPanel = new TransparentPanel();
-
- private JPanel valuesPanel = new TransparentPanel();
-
- private JLabel hostLabel
- = new JLabel(Resources.getString("plugin.dictaccregwizz.HOST"));
-
- private JPanel emptyPanel = new TransparentPanel();
-
- private JLabel hostExampleLabel = new JLabel("Ex: dict.org");
-
- private JLabel portLabel
- = new JLabel(Resources.getString("service.gui.PORT"));
-
- private JTextField hostField = new JTextField();
-
- private JTextField portField = new JTextField("2628");
-
- private JPanel strategyPanel = new TransparentPanel(new BorderLayout(10, 10));
-
- private JPanel strategyTitleBloc = new TransparentPanel(new BorderLayout());
-
- private JLabel strategyTitle = new JLabel(Resources.getString(
- "plugin.dictaccregwizz.STRATEGY_LIST"));
-
- private JButton strategyLoader
- = new JButton(Resources.getString(
- "plugin.dictaccregwizz.SEARCH_STRATEGIES"));
-
- private StrategiesList strategiesList;
-
- private JTextArea strategyDescription
- = new JTextArea(Resources.getString(
- "plugin.dictaccregwizz.STRATEGY_DESCRIPTION"));
-
- private ProgressPanel searchProgressPanel;
-
- private JPanel mainPanel = new TransparentPanel(new BorderLayout());
-
- private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
-
- private DictAccountRegistrationWizard wizard;
-
- private String initstrategy = "";
-
- private ThreadManager searchThread = null;
-
- private boolean firstAccount = false;
-
- private boolean isPageCommitted = false;
-
- /**
- * Initial AccountID (null if new account)
- * Used to check if there are modifications to the account
- */
- private AccountID initAccountID = null;
-
- /**
- * Creates an instance of <tt>FirstWizardPage</tt>.
- *
- * @param wizard the parent wizard
- */
- public FirstWizardPage(DictAccountRegistrationWizard wizard)
- {
- super(new BorderLayout());
-
- this.wizard = wizard;
-
- this.setPreferredSize(new Dimension(300, 150));
-
- mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
-
- this.searchThread = new ThreadManager(this);
- this.searchProgressPanel = new ProgressPanel(this.searchThread);
-
- this.firstAccount = !this.hasAccount();
-
- if (this.firstAccount)
- {
- this.initFirstAccount();
- }
- else
- {
- this.init();
- }
-
- this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
- }
-
- /**
- * Initializes all panels, buttons, etc.
- */
- private void init()
- {
- // Host and port Field
- this.hostField = new JTextField();
- this.portField = new JTextField("2628");
-
- this.hostField.getDocument().addDocumentListener(this);
- this.portField.getDocument().addDocumentListener(this);
-
- this.hostExampleLabel.setForeground(Color.GRAY);
- this.hostExampleLabel.setFont(hostExampleLabel.getFont().deriveFont(8));
- this.emptyPanel.setMaximumSize(new Dimension(40, 35));
- this.hostExampleLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8,
- 0));
-
- labelsPanel.add(hostLabel);
- labelsPanel.add(emptyPanel);
- labelsPanel.add(portLabel);
-
- valuesPanel.add(hostField);
- valuesPanel.add(hostExampleLabel);
- valuesPanel.add(portField);
-
- hostPortPanel.add(labelsPanel, BorderLayout.WEST);
- hostPortPanel.add(valuesPanel, BorderLayout.CENTER);
-
- hostPortPanel.setBorder(BorderFactory.createTitledBorder(
- Resources.getString("plugin.dictaccregwizz.SERVER_INFO")));
-
- this.labelsPanel.setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
- this.valuesPanel.setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
-
- mainPanel.add(hostPortPanel);
-
- this.portField.addKeyListener(new KeyListener() {
- public void keyTyped(KeyEvent evt)
- {
- // If evt isn't a digit, we don't add it
- if (!Character.isDigit(evt.getKeyChar()))
- {
- evt.consume();
- }
- }
-
- // Not used
- public void keyPressed(KeyEvent evt) {;}
- public void keyReleased(KeyEvent evt) {;}
- });
-
- // Strategies list
- this.strategiesList = new StrategiesList();
-
- JScrollPane scrollPane = new JScrollPane();
- scrollPane.getViewport().add(this.strategiesList);
- this.strategyPanel.add(scrollPane);
-
- // Strategy title + button
- this.strategyTitleBloc.add(this.strategyTitle, BorderLayout.WEST);
- this.strategyTitleBloc.add(this.strategyLoader, BorderLayout.EAST);
-
- // Button action listener
- this.strategyLoader.setActionCommand("populateList");
- this.strategyLoader.addActionListener(this);
-
- // South Panel
- JPanel sSouthPanel = new TransparentPanel(new BorderLayout());
-
- // Description
- this.strategyDescription.setLineWrap(true);
- this.strategyDescription.setLineWrap(true);
- this.strategyDescription.setRows(4);
- this.strategyDescription.setWrapStyleWord(true);
- this.strategyDescription.setAutoscrolls(false);
- sSouthPanel.add(this.strategyDescription);
-
- // Message
- sSouthPanel.add(this.searchProgressPanel, BorderLayout.SOUTH);
-
- this.strategyPanel.add(sSouthPanel, BorderLayout.SOUTH);
-
- this.strategyPanel.add(this.strategyTitleBloc, BorderLayout.NORTH);
- this.strategyPanel.setBorder(BorderFactory.createTitledBorder(
- Resources.getString("plugin.dictaccregwizz.STRATEGY_SELECTION")));
- mainPanel.add(this.strategyPanel);
-
- this.add(mainPanel, BorderLayout.NORTH);
- }
-
- /**
- * Initialize the UI for the first account
- */
- private void initFirstAccount()
- {
- // Data init
- this.hostField = new JTextField("dict.org");
- this.portField = new JTextField("2628");
-
- // Init strategies list
- this.strategiesList = new StrategiesList();
-
- this.mainPanel = new TransparentPanel(new BorderLayout());
-
- JPanel infoTitlePanel
- = new TransparentPanel(new FlowLayout(FlowLayout.CENTER));
- JTextArea firstDescription
- = new JTextArea(Resources.getString(
- "plugin.dictaccregwizz.FIRST_ACCOUNT"));
- JLabel title
- = new JLabel(Resources.getString(
- "plugin.dictaccregwizz.ACCOUNT_INFO_TITLE"));
-
- // Title
- title.setFont(title.getFont().deriveFont(Font.BOLD, 14.0f));
- infoTitlePanel.add(title);
- this.mainPanel.add(infoTitlePanel, BorderLayout.NORTH);
- this.mainPanel.add(this.searchProgressPanel, BorderLayout.SOUTH);
-
- // Description
- firstDescription.setLineWrap(true);
- firstDescription.setEditable(false);
- firstDescription.setOpaque(false);
- firstDescription.setRows(6);
- firstDescription.setWrapStyleWord(true);
- firstDescription.setAutoscrolls(false);
- this.mainPanel.add(firstDescription);
- }
-
- /**
- * Implements the <code>WizardPage.getIdentifier</code> to return this
- * page identifier.
- *
- * @return Returns the identifier of the current (the first) page of the
- * wizard.
- */
- public Object getIdentifier()
- {
- return FIRST_PAGE_IDENTIFIER;
- }
-
- /**
- * Implements the <code>WizardPage.getNextPageIdentifier</code> to return
- * the next page identifier - the summary page.
- *
- * @return Returns the identifier of the next page of the wizard.
- */
- public Object getNextPageIdentifier()
- {
- return nextPageIdentifier;
- }
-
- /**
- * Implements the <code>WizardPage.getBackPageIdentifier</code> to return
- * the back identifier, which is null as this is the first wizard page.
- *
- * @return the identifier of the previous page of the wizard.
- */
- public Object getBackPageIdentifier()
- {
- return null;
- }
-
- /**
- * Implements the <code>WizardPage.getWizardForm</code> to return this
- * panel.
- * @return Returns this form of the wizard.
- */
- public Object getWizardForm()
- {
- return this;
- }
-
- /**
- * Before this page is displayed enables or disables the "Next" wizard
- * button according to whether the UIN field is empty.
- */
- public void pageShowing()
- {
- this.setNextButtonEnabled();
- }
-
- /**
- * Saves the user input when the "Next" wizard buttons is clicked.
- */
- public void commitPage()
- {
- String host = hostField.getText();
- int port = Integer.parseInt(portField.getText());
- boolean isModified = false;
-
- if (this.initAccountID != null)
- { // We check if there are modifications to the server
- String accHost =
- this.initAccountID.getAccountPropertyString(
- ProtocolProviderFactory.SERVER_ADDRESS);
- int accPort =
- Integer.parseInt(this.initAccountID
- .getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT));
-
- if (((accHost == null) ? (host != null) : !accHost.equals(host))
- || (accPort != port))
- {
- isModified = true;
- }
- }
-
- // We check if a strategy has been selected
- if (this.strategiesList.getModel().getSize() == 0)
- { // No Strategy, we get them
- this.populateStrategies();
-
- if (!this.searchThread.waitThread())
- {
- // TODO error dialog : thread interrupted ? no thread ?
- this.strategiesList.clear();
- }
- }
-
- if (this.strategiesList.getModel().getSize() == 0)
- {
- // No strategy, maybe not connected
- // Information message is already on the wizard
- nextPageIdentifier = FIRST_PAGE_IDENTIFIER;
- this.revalidate();
- }
- else
- {
- nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
-
- DictAccountRegistration registration = wizard.getRegistration();
-
- registration.setHost(host);
- registration.setPort(port);
- registration.setStrategy(
- (Strategy) this.strategiesList.getSelectedValue());
- }
-
- isPageCommitted = true;
- }
-
- /**
- * Enables or disables the "Next" wizard button according to whether the UIN
- * field is empty.
- */
- private void setNextButtonEnabled()
- {
- boolean hostOK = DictConnection.isUrl(hostField.getText());
- boolean portOK = (this.portField.getText().length() != 0)
- && Integer.parseInt(this.portField.getText()) > 10;
-
- if (this.firstAccount)
- {
- wizard.getWizardContainer().setNextFinishButtonEnabled(true);
- }
- else if (hostOK && portOK)
- {
- this.strategyLoader.setEnabled(true);
- wizard.getWizardContainer().setNextFinishButtonEnabled(true);
- }
- else
- {
- // Disable the finish button
- wizard.getWizardContainer().setNextFinishButtonEnabled(false);
-
- // Clear the list and disable the button
- this.strategiesList.clear();
- this.strategyLoader.setEnabled(false);
- }
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user types in the UIN
- * field. Enables or disables the "Next" wizard button according to whether
- * the UIN field is empty.
- *
- * @param e the <tt>DocumentEvent</tt> triggered when user types in the UIN
- * field.
- */
- public void insertUpdate(DocumentEvent e)
- {
- this.setNextButtonEnabled();
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
- * from the UIN field. Enables or disables the "Next" wizard button
- * according to whether the UIN field is empty.
- *
- * @param e The <tt>DocumentEvent</tt> triggered when user deletes letters
- * from the UIN field.
- */
- public void removeUpdate(DocumentEvent e)
- {
- this.setNextButtonEnabled();
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user changes an
- * attribute or set of attributes from the UIN field.
- * Currently this notification has no effect and is just here to implement
- * the DocumentListener interface.
- *
- * @param e The <tt>DocumentEvent</tt> triggered when an attribute or set of
- * attributes changed from the UIN field.
- */
- public void changedUpdate(DocumentEvent e)
- {
- }
-
- /**
- * Invoked when this WizardPage will be hidden eighter because the user has
- * clicked "Back" or "Next".
- * This function has no effect.
- */
- public void pageHiding()
- {
- }
-
- /**
- * Invoked when this WizardPage will be shown eighter because the user has
- * clicked "Back" on the next wizard page or "Next" on the previous one.
- * This function has no effect.
- */
- public void pageShown()
- {
- }
-
- /**
- * Invoked when user clicks on the "Back" wizard button.
- * This function has no effect.
- */
- public void pageBack()
- {
- }
-
- /**
- * Fills the Host, Port and Strategy fields in this panel with the data comming
- * from the given protocolProvider.
- *
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load
- * the data from.
- */
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- AccountID accountID = protocolProvider.getAccountID();
- String host =
- accountID
- .getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS);
- String port =
- accountID
- .getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT);
- String strategy =
- accountID
- .getAccountPropertyString(ProtocolProviderFactory.STRATEGY);
-
- this.initAccountID = accountID;
-
- // Host field
- this.hostField.setText(host);
-
- // Port Field
- this.portField.setText(port);
-
- // Load strategies
- this.initstrategy = strategy;
- this.populateStrategies();
- }
-
- /**
- * Handles the action of the button.
- *
- * @param e The event generated when the button is pressed.
- */
- public void actionPerformed(ActionEvent e)
- {
- // Button action -> populate the list
- if (e.getActionCommand().equals("populateList"))
- {
- this.populateStrategies();
- }
- }
-
- /**
- * Checks if an account is stored for this protocol
- * @return TRUE, if an account is stored - FALSE otherwise
- */
- private boolean hasAccount()
- {
- ProtocolProviderFactory factory =
- DictAccRegWizzActivator.getDictProtocolProviderFactory();
-
- return !factory.getRegisteredAccounts().isEmpty();
- }
-
- /**
- * Start the thread which will populate the Strategies List
- */
- public void populateStrategies()
- {
- // Clear ArrayList
- this.strategiesList.clear();
-
- boolean ok = this.searchThread.submitRequest(this.hostField.getText(),
- Integer.parseInt(this.portField.getText()));
-
- if (!ok)
- {
- // TODO Display error
- }
- }
-
- /**
- * Automatic selection of a strategy
- */
- public void autoSelectStrategy()
- {
- this.strategiesList.autoSelectStrategy(this.initstrategy);
- }
-
- /**
- *
- * @param strategies
- */
- public void setStrategies(List<Strategy> strategies)
- {
- this.strategiesList.setStrategies(strategies);
- }
-
- /**
- * Informs the user of the current status of the search
- * Should only be called by the thread
- * @param message Search status
- */
- public void progressMessage(String message)
- {
- this.searchProgressPanel.nextStep(message);
- }
-
- /**
- * Informs the wizard that the search of the strategies is complete.
- * Should only be called by the thread
- */
- public void strategiesSearchComplete()
- {
- setStrategyButtonEnable(true);
- this.searchProgressPanel.finish();
- }
-
- /**
- * Informs the wizard that the search of the strategies is a failure
- * Should only be called by the thread
- * @param reason Reason message
- * @param de Exception thrown
- */
- public void strategiesSearchFailure(String reason, DictException de)
- {
- strategiesSearchComplete();
- // TODO SHOW ERROR MESSAGE
- }
-
- /**
- * Enables or disable the Next Button and the Strategy Button
- * @param e TRUE enables - FALSE disables
- */
- public void setStrategyButtonEnable(boolean e)
- {
- // During all the process the buttons and the fieldsset are in the same state
-
- this.hostField.setEnabled(e);
- this.portField.setEnabled(e);
-
- this.strategyLoader.setEnabled(e);
- wizard.getWizardContainer().setNextFinishButtonEnabled(e);
- }
-
- public Object getSimpleForm()
- {
- return mainPanel;
- }
-
- /**
- * Indicates if this is the first dict account
- *
- * @return TRUE if this is the first dict account - FALSE otherwise
- */
- public boolean isFirstAccount()
- {
- return this.firstAccount;
- }
-
- public boolean isCommitted()
- {
- return isPageCommitted;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/ProgressPanel.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/ProgressPanel.java
deleted file mode 100644
index 7d46fa5..0000000
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/ProgressPanel.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.dictaccregwizz;
-
-import java.awt.*;
-import java.awt.event.*;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-/**
- * Panel showing the current status of the search of the strategies
- *
- * @author ROTH Damien
- */
-public class ProgressPanel
- extends TransparentPanel
- implements ActionListener
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private JPanel rightPanel;
-
- private JLabel messageLabel;
- private JLabel progressLabel;
- private JButton cancelButton;
-
- private int currentStep;
- private int totalSteps;
-
- private boolean isBuild;
-
- private ThreadManager searchThread;
-
- /**
- * Create an instance of <tt>ProgressPanel</tt>
- * @param searchThread The thread manager
- */
- public ProgressPanel(ThreadManager searchThread)
- {
- super(new BorderLayout());
-
- // Element creation
- this.messageLabel = new JLabel(" ");
- this.progressLabel = new JLabel(" ");
- this.cancelButton
- = new JButton(Resources.getString("service.gui.CANCEL"));
- this.cancelButton.addActionListener(this);
-
- // Right panel init
- this.rightPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT));
- this.rightPanel.add(this.progressLabel);
- this.rightPanel.add(this.cancelButton);
-
- this.searchThread = searchThread;
-
- init();
- this.totalSteps = ThreadManager.NB_STEPS;
- }
-
- /**
- * Init the values
- */
- private void init()
- {
- this.isBuild = false;
- this.currentStep = 1;
-
- this.add(this.messageLabel, BorderLayout.CENTER);
- }
-
- /**
- * Build the UI
- */
- private void build()
- {
- if (this.isBuild)
- {
- return;
- }
-
- this.add(this.messageLabel, BorderLayout.CENTER);
- this.add(this.rightPanel, BorderLayout.EAST);
-
- this.isBuild = true;
- }
-
- /**
- * Move to the next step without updating the message
- */
- public void nextStep()
- {
- nextStep(this.messageLabel.getText());
- }
-
- /**
- * Mode to the next step with a new message
- * @param message Message
- */
- public void nextStep(String message)
- {
- if (this.currentStep > this.totalSteps)
- {
- finish();
- }
-
- build();
- this.messageLabel.setText(message);
- this.progressLabel.setText(currentStep + "/" + totalSteps);
-
- this.currentStep++;
- }
-
- /**
- * Informs the end of the progress. Remove all the components and
- * reset the values
- */
- public void finish()
- {
- // Remove all elements
- this.removeAll();
-
- // Re-init the panel
- this.messageLabel.setText(" ");
- this.progressLabel.setText(" ");
- init();
-
- this.repaint();
- this.validate();
- }
-
- public void actionPerformed(ActionEvent arg0)
- {
- this.searchThread.cancel();
- this.finish();
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java
deleted file mode 100644
index 55856be..0000000
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/Resources.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.dictaccregwizz;
-
-import net.java.sip.communicator.service.resources.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The <tt>Resources</tt> class manages the access to the internationalization
- * properties files and the image resources used in this plugin.
- *
- * @author ROTH Damien
- * @author LITZELMAN Cedric
- */
-public class Resources
-{
- private static ResourceManagementService resourcesService;
-
- public static ImageID DICT_LOGO
- = new ImageID("service.protocol.dict.DICT_16x16");
-
- public static ImageID PAGE_IMAGE
- = new ImageID("service.protocol.dict.DICT_64x64");
-
- /**
- * 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)
- {
- return getResources().getI18NString(key);
- }
-
- /**
- * Loads an image from a given image identifier.
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static byte[] getImage(ImageID imageID)
- {
- return getResources().getImageInBytes(imageID.getId());
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(DictAccRegWizzActivator.bundleContext);
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/StrategiesList.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/StrategiesList.java
deleted file mode 100644
index ace9127..0000000
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/StrategiesList.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.dictaccregwizz;
-
-import java.awt.*;
-import java.util.*;
-import java.util.List;
-
-import javax.swing.*;
-
-import net.java.dict4j.*;
-
-/**
- * Class managing the list of strategies
- *
- * @author ROTH Damien
- */
-public class StrategiesList
- extends JList
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private ListModel model;
- private CellRenderer renderer;
-
- /**
- * Create an instance of the <tt>StrategiesList</tt>
- */
- public StrategiesList()
- {
- super();
-
- this.model = new ListModel();
- this.renderer = new CellRenderer();
-
- this.setCellRenderer(this.renderer);
- this.setModel(model);
- this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- this.setVisibleRowCount(6);
- }
-
- /**
- * Stores a new set of strategies
- * @param strategies List of strategies
- */
- public void setStrategies(List<Strategy> strategies)
- {
- this.model.setStrategies(strategies);
- }
-
- /**
- * Remove all the strategies of the list
- */
- public void clear()
- {
- this.model.clear();
- }
-
- /**
- * Automatic selection of strategies
- * @param initStrategy
- */
- public void autoSelectStrategy(String initStrategy)
- {
- int index = -1;
-
- if (initStrategy.length() > 0)
- { // saved strategy
- index = this.model.indexOf(initStrategy);
- }
- if (index < 0)
- {
- // First case : levenstein distance
- index = this.model.indexOf("lev");
- }
- if (index < 0)
- {
- // Second case : soundex
- index = this.model.indexOf("soundex");
- }
- if (index < 0)
- {
- // Last case : prefix
- index = this.model.indexOf("prefix");
- }
-
- // If the index is still < 0, we select the first index
- if (index < 0)
- {
- index = 0;
- }
- if (index < this.getVisibleRowCount())
- {
- // If the index is visible row, we don't need to scroll
- this.setSelectedIndex(index);
- }
- else
- {
- // Otherwise, we scroll to the selected value
- this.setSelectedValue(this.model.getElementAt(index), true);
- }
- }
-
- /**
- * Class managing the list datas
- *
- * @author ROTH Damien
- */
- static class ListModel
- extends AbstractListModel
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private List<Strategy> data;
-
- /**
- * Create an instance of <tt>ListModel</tt>
- */
- public ListModel()
- {
- data = new ArrayList<Strategy>();
- }
-
- /**
- * Stores the strategies into this model
- * @param strategies the strategies list
- */
- public void setStrategies(List<Strategy> strategies)
- {
- data = strategies;
- fireContentsChanged(this, 0, data.size());
- }
-
- /**
- * Remove all the strategies of the list
- */
- public void clear()
- {
- data.clear();
- }
-
- /**
- * Implements <tt>ListModel.getElementAt</tt>
- */
- public Strategy getElementAt(int row)
- {
- return data.get(row);
- }
-
- /**
- * Implements <tt>ListModel.getSize</tt>
- */
- public int getSize()
- {
- return data.size();
- }
-
- /**
- * Find the index of a strategy.
- *
- * @param strategyCode the code of the strategy
- * @return the index of the strategy
- */
- public int indexOf(String strategyCode)
- {
- for (int i = 0, size = data.size(); i < size; i++)
- {
- if (data.get(i).getCode().equals(strategyCode))
- return i;
- }
- return -1;
- }
- }
-
- /**
- * Class managing the cell rendering
- *
- * @author ROTH Damien
- */
- static class CellRenderer
- extends JLabel
- implements ListCellRenderer
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * implements <tt>ListCellRenderer.getListCellRendererComponent</tt>
- */
- public Component getListCellRendererComponent(
- JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus)
- {
- setText(((Strategy) value).getName());
-
- if (isSelected)
- {
- setBackground(list.getSelectionBackground());
- setForeground(list.getSelectionForeground());
- }
- else
- {
- setBackground(list.getBackground());
- setForeground(list.getForeground());
- }
- setEnabled(list.isEnabled());
- setFont(list.getFont());
- setOpaque(true);
-
- return this;
- }
- }
-}
-
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/ThreadManager.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/ThreadManager.java
deleted file mode 100644
index 4abcc75..0000000
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/ThreadManager.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.dictaccregwizz;
-
-import java.util.*;
-
-import net.java.dict4j.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Class manager the thread called for searching the strategies' list
- *
- * @author ROTH Damien
- */
-public class ThreadManager
-{
- protected static Logger logger = Logger.getLogger(ThreadManager.class);
- public static int NB_STEPS = 4;
-
- private StrategyThread thread = null;
- private FirstWizardPage wizard = null;
-
- /**
- * Create an instance of <tt>ThreadManager</tt>
- * @param wiz Wizard
- */
- public ThreadManager(FirstWizardPage wiz)
- {
- this.wizard = wiz;
- }
-
- /**
- * Submit a request to launch the thread
- * @param host Server host
- * @param port Server port
- * @return TRUE if the thread is started - FALSE otherwise
- */
- public boolean submitRequest(String host, int port)
- {
- if (this.thread != null)
- {
- return false;
- }
-
- this.thread = new StrategyThread(this.wizard, host, port);
- this.thread.start();
-
- return true;
- }
-
- /**
- * Stop the thread
- */
- public void cancel()
- {
- if (this.thread != null)
- {
- this.thread.interrupt();
- this.thread = null;
- }
- }
-
- /**
- * Wait for the searching thread to stop
- * @return true if success, false otherwise
- */
- public boolean waitThread()
- {
- if (this.thread == null)
- {
- return false;
- }
-
- try
- {
- this.thread.join();
- }
- catch (InterruptedException e)
- {
- if (logger.isInfoEnabled())
- logger.info(e);
- return false;
- }
- return true;
- }
-
- /**
- * Thread used to search the strategies
- *
- * @author ROTH Damien, LITZELMANN Cedric
- */
- static class StrategyThread
- extends Thread
- {
- private final FirstWizardPage wizard;
- private final String host;
- private final int port;
-
- /**
- * Informations messages
- */
- private String[] messages = new String[] {
- Resources.getString(
- "plugin.dictaccregwizz.THREAD_CONNECT"),
- Resources.getString(
- "plugin.dictaccregwizz.THREAD_CONNECT_FAILED"),
- Resources.getString(
- "plugin.dictaccregwizz.RETRIEVING_STRATEGIES"),
- Resources.getString(
- "plugin.dictaccregwizz.NO_STRATEGIES_FOUND"),
- Resources.getString(
- "plugin.dictaccregwizz.POPULATE_LIST"),
- Resources.getString(
- "plugin.dictaccregwizz.CLOSING_CONNECTION")
- };
-
- /**
- * Create an instance of the thread
- * @param wizard The wizard who started the thread
- * @param host Server host
- * @param port Server port
- */
- public StrategyThread(FirstWizardPage wizard, String host, int port)
- {
- this.wizard = wizard;
- this.host = host;
- this.port = port;
- }
-
- @Override
- public void run()
- {
- List<Strategy> strategies = null;
-
- DictConnection dictConnection = new DictConnection(host, port);
-
- // Open the connection to the server
- this.wizard.progressMessage(messages[0]);
- try
- {
- dictConnection.connect();
- }
- catch (DictException e)
- {
- this.wizard.strategiesSearchFailure(this.messages[1], e);
- return;
- }
-
- // Get the strategies
- this.wizard.progressMessage(messages[2]);
- try
- {
- strategies = dictConnection.getStrategies();
- }
- catch (DictException e)
- {
- this.wizard.strategiesSearchFailure(this.messages[3], e);
- return;
- }
-
- // Store the strategies
- this.wizard.progressMessage(messages[4]);
- this.wizard.setStrategies(strategies);
- this.wizard.autoSelectStrategy();
-
- // Close the connection
- this.wizard.progressMessage(messages[5]);
- try
- {
- dictConnection.close();
- }
- catch (DictException e)
- {
- // An error while closing the connection isn't very important
- // We just log it
- ThreadManager.logger.info("DICT search strategies thread : " +
- "Error while closing connection", e);
- }
-
- // End of the search
- this.wizard.strategiesSearchComplete();
- }
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf
deleted file mode 100644
index 02dc2c4..0000000
--- a/src/net/java/sip/communicator/plugin/dictaccregwizz/dictaccregwizz.manifest.mf
+++ /dev/null
@@ -1,34 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.plugin.dictaccregwizz.DictAccRegWizzActivator
-Bundle-Name: Dict account registration wizard
-Bundle-Description: Dict account registration wizard.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.plugin.dictaccregwizz
-Import-Package: org.osgi.framework,
- net.java.dict4j,
- net.java.sip.communicator.service.browserlauncher,
- org.jitsi.service.configuration,
- net.java.sip.communicator.service.contactlist,
- net.java.sip.communicator.service.contactlist.event,
- net.java.sip.communicator.service.gui,
- net.java.sip.communicator.service.gui.event,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,
- net.java.sip.communicator.service.protocol.icqconstants,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.plugin.desktoputil,
- javax.swing,
- javax.swing.event,
- javax.swing.table,
- javax.swing.text,
- javax.swing.text.html,
- javax.accessibility,
- javax.swing.plaf,
- javax.swing.plaf.metal,
- javax.swing.plaf.basic,
- javax.imageio,
- javax.swing.filechooser,
- javax.swing.tree,
- javax.swing.undo,
- javax.swing.border
diff --git a/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java b/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java
index 0500c07..27bf565 100644
--- a/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java
+++ b/src/net/java/sip/communicator/plugin/dnsconfig/DnssecPanel.java
@@ -267,7 +267,7 @@ public class DnssecPanel
if(chkEnabled.isSelected())
{
if(!f.createNewFile() && !f.exists())
- chkEnabled.setSelected(UnboundApi.isAvailable());
+ chkEnabled.setSelected(false);
}
else
{
diff --git a/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccRegWizzActivator.java
deleted file mode 100644
index 2400644..0000000
--- a/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccRegWizzActivator.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.facebookaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.resources.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.resources.*;
-import org.osgi.framework.*;
-
-/**
- * Registers the <tt>FacebookAccountRegistrationWizard</tt> in the UI Service.
- *
- * @author Dai Zhiwei
- */
-public class FacebookAccRegWizzActivator
- extends AbstractServiceDependentActivator
-{
- /**
- * The logger.
- */
- private static Logger logger
- = Logger.getLogger(FacebookAccRegWizzActivator.class.getName());
-
- /**
- * A currently valid bundle context.
- */
- public static BundleContext bundleContext;
-
- /**
- * The container.
- */
- private static WizardContainer wizardContainer;
-
- /**
- * Registration wizard.
- */
- private static FacebookAccountRegistrationWizard facebookWizard;
-
- /**
- * The UI service.
- */
- private static UIService uiService;
-
- /**
- * The browser launcher service.
- */
- private static BrowserLauncherService browserLauncherService;
-
- private static ResourceManagementService resourcesService;
-
- /**
- * Starts this bundle.
- */
- @Override
- public void start(Object dependentService)
- {
- if (logger.isInfoEnabled())
- logger.info("Loading facebook account wizard.");
-
- uiService = (UIService)dependentService;
-
- wizardContainer = uiService.getAccountRegWizardContainer();
-
- facebookWizard
- = new FacebookAccountRegistrationWizard(wizardContainer);
-
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
-
- containerFilter.put(
- ProtocolProviderFactory.PROTOCOL,
- ProtocolNames.FACEBOOK);
-
- bundleContext.registerService(
- AccountRegistrationWizard.class.getName(),
- facebookWizard,
- containerFilter);
-
- if (logger.isInfoEnabled())
- logger.info("Facebook account registration wizard [STARTED].");
- }
-
- /**
- * The dependent class. We are waiting for the ui service.
- * @return the ui service class.
- */
- @Override
- public Class<?> getDependentServiceClass()
- {
- return UIService.class;
- }
-
- /**
- * The bundle context to use.
- * @param context the context to set.
- */
- @Override
- public void setBundleContext(BundleContext context)
- {
- bundleContext = context;
- }
-
- /**
- * Called when this bundle is stopped so the Framework can perform the
- * bundle-specific activities necessary to stop the bundle.
- *
- * @param bundleContext The execution context of the bundle being stopped.
- */
- public void stop(BundleContext bundleContext)
- {
- }
-
- /**
- * Returns the <tt>ProtocolProviderFactory</tt> for the Facebook protocol.
- * @return the <tt>ProtocolProviderFactory</tt> for the Facebook protocol
- */
- public static ProtocolProviderFactory getFacebookProtocolProviderFactory()
- {
-
- ServiceReference[] serRefs = null;
-
- String osgiFilter = "("
- + ProtocolProviderFactory.PROTOCOL
- + "=" + ProtocolNames.JABBER + ")";
-
- try
- {
- serRefs = bundleContext.getServiceReferences(
- ProtocolProviderFactory.class.getName(), osgiFilter);
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error("FacebookAccRegWizzActivator : " + ex);
- }
-
- return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
- }
-
- /**
- * Returns the bundleContext that we received when we were started.
- *
- * @return a currently valid instance of a bundleContext.
- */
- public BundleContext getBundleContext()
- {
- return bundleContext;
- }
-
- /**
- * Returns the <tt>UIService</tt>.
- *
- * @return the <tt>UIService</tt>
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-
- /**
- * Gets the browser launcher service.
- * @return the browser launcher service.
- */
- public static BrowserLauncherService getBrowserLauncher()
- {
- if (browserLauncherService == null)
- {
- ServiceReference serviceReference =
- bundleContext.getServiceReference(BrowserLauncherService.class
- .getName());
-
- browserLauncherService =
- (BrowserLauncherService) bundleContext
- .getService(serviceReference);
- }
-
- return browserLauncherService;
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(FacebookAccRegWizzActivator.bundleContext);
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccountRegistrationWizard.java
deleted file mode 100644
index d70282d..0000000
--- a/src/net/java/sip/communicator/plugin/facebookaccregwizz/FacebookAccountRegistrationWizard.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.facebookaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.plugin.jabberaccregwizz.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.jabber.*;
-
-/**
- * The <tt>FacebookAccountRegistrationWizard</tt> is an implementation of the
- * <tt>AccountRegistrationWizard</tt> for the Facebook Chat protocol. It allows
- * the user to create and configure a new Facebook account.
- *
- * @author Dai Zhiwei
- * @author Yana Stamcheva
- */
-public class FacebookAccountRegistrationWizard
- extends JabberAccountRegistrationWizard
-{
- /**
- * The protocol name.
- */
- private static final String PROTOCOL = "Facebook";
-
- /**
- * A constant pointing to the Facebook protocol logo icon.
- */
- private static final String PROTOCOL_ICON
- = "service.protocol.facebook.FACEBOOK_16x16";
-
- /**
- * A constant pointing to the Facebook protocol wizard page image.
- */
- private static final String PAGE_IMAGE
- = "service.protocol.facebook.FACEBOOK_48x48";
-
- private static final String SERVER_ADDRESS = "chat.facebook.com";
-
- /**
- * Creates an instance of <tt>FacebookAccountRegistrationWizard</tt>.
- * @param wizardContainer the wizard container, where this wizard
- * is added
- */
- public FacebookAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- super(wizardContainer);
- }
-
- /**
- * Returns the set of pages contained in this wizard.
- * @return Iterator
- */
- @Override
- public Iterator<WizardPage> getPages()
- {
- JabberAccountRegistration reg = new JabberAccountRegistration();
-
- setPredefinedProperties(reg);
-
- return getPages(reg);
- }
-
- /**
- * Returns a simple account registration form that would be the first form
- * shown to the user. Only if the user needs more settings she'll choose
- * to open the advanced wizard, consisted by all pages.
- *
- * @param isCreateAccount indicates if the simple form should be opened as
- * a create account form or as a login form
- * @return a simple account registration form
- */
- @Override
- public Object getSimpleForm(boolean isCreateAccount)
- {
- JabberAccountRegistration reg = new JabberAccountRegistration();
-
- setPredefinedProperties(reg);
-
- return getSimpleForm(reg, isCreateAccount);
- }
-
- /**
- * Sets all facebook specific properties.
- *
- * @param reg the registration object
- */
- private void setPredefinedProperties(JabberAccountRegistration reg)
- {
- reg.setServerAddress(SERVER_ADDRESS);
- reg.setSendKeepAlive(true);
-
- reg.setServerOverridden(true);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * Returns the icon to be used for this wizard.
- * @return byte[]
- */
- @Override
- public byte[] getIcon()
- {
- return FacebookAccRegWizzActivator.getResources()
- .getImageInBytes(PROTOCOL_ICON);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
- * Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- @Override
- public byte[] getPageImage()
- {
- return FacebookAccRegWizzActivator.getResources()
- .getImageInBytes(PAGE_IMAGE);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method. Returns the protocol name for this wizard.
- * @return String
- */
- @Override
- public String getProtocolName()
- {
- return FacebookAccRegWizzActivator.getResources()
- .getI18NString("plugin.facebookaccregwizz.PROTOCOL_NAME");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code> method. Returns the description of the protocol for this wizard.
- * @return String
- */
- @Override
- public String getProtocolDescription()
- {
- return FacebookAccRegWizzActivator.getResources()
- .getI18NString("plugin.facebookaccregwizz.PROTOCOL_DESCRIPTION");
- }
-
- /**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
- */
- @Override
- public String getUserNameExample()
- {
- return "Ex: username";
- }
-
- /**
- * Returns the display label used for the sip id field.
- * @return the sip id display label string.
- */
- @Override
- protected String getUsernameLabel()
- {
- return FacebookAccRegWizzActivator.getResources()
- .getI18NString("plugin.facebookaccregwizz.USERNAME");
- }
-
- /**
- * Return the string for add existing account button.
- * @return the string for add existing account button.
- */
- @Override
- protected String getCreateAccountButtonLabel()
- {
- return null;
- }
-
- /**
- * Return the string for create new account button.
- * @return the string for create new account button.
- */
- @Override
- protected String getCreateAccountLabel()
- {
- return FacebookAccRegWizzActivator.getResources().getI18NString(
- "plugin.facebookaccregwizz.DESCRIPTION");
- }
-
- /**
- * Returns the protocol name as listed in "ProtocolNames" or just the name
- * of the service.
- * @return the protocol name
- */
- @Override
- public String getProtocol()
- {
- return PROTOCOL;
- }
-
- /**
- * Returns the protocol icon path.
- * @return the protocol icon path
- */
- @Override
- public String getProtocolIconPath()
- {
- return "resources/images/protocol/facebook";
- }
-
- /**
- * Returns the account icon path.
- * @return the account icon path
- */
- @Override
- public String getAccountIconPath()
- {
- return "resources/images/protocol/facebook/logo32x32.png";
- }
-
- /**
- * Opens a browser on the sign up page.
- */
- @Override
- public void webSignup() {}
-
- /**
- * Returns <code>true</code> if the web sign up is supported by the current
- * implementation, <code>false</code> - otherwise.
- * @return <code>true</code> if the web sign up is supported by the current
- * implementation, <code>false</code> - otherwise
- */
- @Override
- public boolean isWebSignupSupported()
- {
- return false;
- }
-
- /**
- * Creates an account for the given user and password.
- *
- * @param providerFactory the ProtocolProviderFactory which will create
- * the account
- * @param userName the user identifier
- * @param passwd the password
- * @return the <tt>ProtocolProviderService</tt> for the new account.
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- protected ProtocolProviderService installAccount(
- ProtocolProviderFactory providerFactory,
- String userName,
- String passwd)
- throws OperationFailedException
- {
- // add server part to username
- if(userName.indexOf("@") == -1)
- userName += "@" + SERVER_ADDRESS;
-
- return super.installAccount(providerFactory, userName, passwd);
- }
-
- /**
- * Returns an instance of <tt>CreateAccountService</tt> through which the
- * user could create an account. This method is meant to be implemented by
- * specific protocol provider wizards.
- * @return an instance of <tt>CreateAccountService</tt>
- */
- @Override
- protected JabberAccountCreationFormService getCreateAccountService()
- {
- return null;
- }
-
- /**
- * Whether the advanced configuration is enabled. Gives an option
- * to disable/hide advanced config button.
- * @return whether the advanced configuration is enabled.
- */
- public boolean isAdvancedConfigurationEnabled()
- {
- return false;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/facebookaccregwizz/facebookaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/facebookaccregwizz/facebookaccregwizz.manifest.mf
deleted file mode 100644
index 9c79947..0000000
--- a/src/net/java/sip/communicator/plugin/facebookaccregwizz/facebookaccregwizz.manifest.mf
+++ /dev/null
@@ -1,34 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.plugin.facebookaccregwizz.FacebookAccRegWizzActivator
-Bundle-Name: Facebook account registration wizard
-Bundle-Description: Facebook account registration wizard.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.plugin.facebookaccregwizz
-Import-Package: org.osgi.framework,
- net.java.sip.communicator.service.browserlauncher,
- org.jitsi.service.configuration,
- net.java.sip.communicator.service.contactlist,
- net.java.sip.communicator.service.contactlist.event,
- net.java.sip.communicator.service.gui,
- net.java.sip.communicator.service.gui.event,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,
- net.java.sip.communicator.service.protocol.jabber,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.plugin.desktoputil,
- net.java.sip.communicator.plugin.jabberaccregwizz,
- javax.accessibility,
- javax.imageio,
- javax.swing,
- javax.swing.border,
- javax.swing.filechooser,
- javax.swing.plaf,
- javax.swing.plaf.basic,
- javax.swing.plaf.metal,
- javax.swing.event,
- javax.swing.table,
- javax.swing.text,
- javax.swing.text.html,
- javax.swing.tree,
- javax.swing.undo
diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java
index 2f345d7..7222d97 100644
--- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java
+++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java
@@ -108,6 +108,14 @@ public class GeneralConfigPluginActivator
"net.java.sip.communicator.plugin.generalconfig.sipconfig.DISABLED";
/**
+ * Indicates if the XMPP configuration form should be disabled, i.e.
+ * not visible to the user.
+ */
+ private static final String XMPP_CONFIG_DISABLED_PROP
+ =
+ "net.java.sip.communicator.plugin.generalconfig.xmppconfig.DISABLED";
+
+ /**
* Starts this bundle.
*/
@Override
@@ -155,6 +163,22 @@ public class GeneralConfigPluginActivator
52, true),
properties);
}
+ if (!getConfigurationService()
+ .getBoolean(XMPP_CONFIG_DISABLED_PROP, false))
+ {
+ // Registers the XMPP config panel as advanced configuration form.
+ properties.put( ConfigurationForm.FORM_TYPE,
+ ConfigurationForm.ADVANCED_TYPE);
+ bundleContext.registerService(
+ ConfigurationForm.class.getName(),
+ new LazyConfigurationForm(
+ XMPPConfigForm.class.getName(),
+ getClass().getClassLoader(),
+ null,
+ "plugin.generalconfig.XMPP_CONFIG",
+ 52, true),
+ properties);
+ }
properties.put( ConfigurationForm.FORM_TYPE,
ConfigurationForm.ADVANCED_TYPE);
bundleContext.registerService(
diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java
index f5e482a..03fc308 100644
--- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java
+++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationPanel.java
@@ -98,6 +98,13 @@ public class GeneralConfigurationPanel
=
"net.java.sip.communicator.plugin.generalconfig.localeconfig.DISABLED";
+ /**
+ * Indicates if the systray config panel should be disabled, i.e. not
+ * visible to the user.
+ */
+ private static final String SYSTRAY_CONFIG_DISABLED_PROP =
+ "net.java.sip.communicator.plugin.generalconfig.systrayconfig.DISABLED";
+
/**
* Indicates if the Call configuration panel should be disabled, i.e.
* not visible to the user.
@@ -169,6 +176,13 @@ public class GeneralConfigurationPanel
}
if(!GeneralConfigPluginActivator.getConfigurationService()
+ .getBoolean(SYSTRAY_CONFIG_DISABLED_PROP, false))
+ {
+ mainPanel.add(createSystrayeConfigPanel());
+ mainPanel.add(Box.createVerticalStrut(10));
+ }
+
+ if(!GeneralConfigPluginActivator.getConfigurationService()
.getBoolean(CALL_CONFIG_DISABLED_PROP, false))
{
mainPanel.add(createCallConfigPanel());
@@ -237,6 +251,30 @@ public class GeneralConfigurationPanel
}
/**
+ * Initializes the minimize instead of hide checkbox.
+ */
+ public Component createMinimzeInsteadOfHideCheckBox()
+ {
+ JCheckBox chk = new SIPCommCheckBox();
+
+ chk.setText(
+ Resources.getString("plugin.generalconfig.MINIMIZE_NOT_HIDE"));
+ chk.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ boolean value = ((JCheckBox) e.getSource()).isSelected();
+ ConfigurationUtils.setIsMinimizeInsteadOfHide(value);
+ UtilActivator.getUIService().setMainWindowCanHide(
+ !UtilActivator.getSystrayService().checkInitialized());
+ }
+ });
+
+ chk.setSelected(ConfigurationUtils.isMinimizeInsteadOfHide());
+ return chk;
+ }
+
+ /**
* Creates the message configuration panel.
* @return the created panel
*/
@@ -832,6 +870,72 @@ public class GeneralConfigurationPanel
return localeConfigPanel;
}
+ private static class Item
+ {
+ public String key;
+ public String value;
+
+ public Item(String key, String value)
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public String toString()
+ {
+ return GeneralConfigPluginActivator.getResources()
+ .getI18NString(value);
+ }
+ }
+
+ /**
+ * Initializes the systray configuration panel.
+ * @return the created component
+ */
+ private Component createSystrayeConfigPanel()
+ {
+ JPanel panel = GeneralConfigPluginActivator.
+ createConfigSectionComponent(
+ Resources.getString("service.systray.MODE"));
+
+ final JComboBox<Item> systrayModes = new JComboBox<>();
+ SystrayService ss = GeneralConfigPluginActivator.getSystrayService();
+ for (Map.Entry<String, String> mode : ss.getSystrayModes().entrySet())
+ {
+ Item i = new Item(mode.getKey(), mode.getValue());
+ systrayModes.addItem(i);
+ if (mode.getKey().equals(ss.getActiveSystrayMode()))
+ {
+ systrayModes.setSelectedItem(i);
+ }
+ }
+
+ systrayModes.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ GeneralConfigPluginActivator.getConfigurationService()
+ .setProperty(SystrayService.PNMAE_TRAY_MODE,
+ ((Item) systrayModes.getSelectedItem()).key);
+ }
+ });
+
+ panel.add(systrayModes);
+ String label = "<html><body style='width:350px'>* " +
+ Resources.getString("service.systray.CLI_NOTE", new String[]{
+ Resources.getSettingsString("service.gui.APPLICATION_NAME")
+ }) + "</body></html>";
+ JLabel warnLabel = new JLabel(label);
+ warnLabel.setToolTipText(label);
+ warnLabel.setForeground(Color.GRAY);
+ warnLabel.setFont(warnLabel.getFont().deriveFont(8));
+ warnLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
+ panel.add(warnLabel);
+ return panel;
+ }
+
/**
* Creates the call configuration panel.
*
@@ -856,13 +960,11 @@ public class GeneralConfigurationPanel
*/
private Component createNormalizeNumberCheckBox()
{
- JPanel checkBoxPanel = new TransparentPanel(new BorderLayout());
-
- SIPCommCheckBox formatPhoneNumber = new SIPCommCheckBox("",
+ SIPCommCheckBox formatPhoneNumber = new SIPCommCheckBox(
+ GeneralConfigPluginActivator.getResources().getI18NString(
+ "plugin.generalconfig.REMOVE_SPECIAL_PHONE_SYMBOLS"),
ConfigurationUtils.isNormalizePhoneNumber());
- formatPhoneNumber.setAlignmentY(Component.TOP_ALIGNMENT);
-
formatPhoneNumber.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
@@ -872,22 +974,7 @@ public class GeneralConfigurationPanel
}
});
- StyledHTMLEditorPane checkBoxTextLabel = new StyledHTMLEditorPane();
-
- checkBoxTextLabel.setContentType("text/html");
- checkBoxTextLabel.appendToEnd(
- "<html>" + GeneralConfigPluginActivator.getResources().getI18NString(
- "plugin.generalconfig.REMOVE_SPECIAL_PHONE_SYMBOLS") + "</html>");
-
- checkBoxTextLabel.setBorder(
- BorderFactory.createEmptyBorder(3, 0, 0, 0));
- checkBoxTextLabel.setOpaque(false);
- checkBoxTextLabel.setEditable(false);
-
- checkBoxPanel.add(formatPhoneNumber, BorderLayout.WEST);
- checkBoxPanel.add(checkBoxTextLabel, BorderLayout.CENTER);
-
- return checkBoxPanel;
+ return formatPhoneNumber;
}
/**
@@ -897,17 +984,17 @@ public class GeneralConfigurationPanel
*/
private Component createAcceptPhoneNumberWithAlphaCharCheckBox()
{
- JPanel checkBoxPanel = new TransparentPanel(new BorderLayout());
+ JPanel checkBoxPanel = new TransparentPanel();
+ checkBoxPanel.setLayout(new BoxLayout(checkBoxPanel, BoxLayout.Y_AXIS));
// Checkbox to accept string with alphabetical characters as potential
// phone numbers.
- SIPCommCheckBox acceptPhoneNumberWithAlphaChars
- = new SIPCommCheckBox("",
+ SIPCommCheckBox alphaCharNumbers = new SIPCommCheckBox(
+ GeneralConfigPluginActivator.getResources().getI18NString(
+ "plugin.generalconfig.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS"),
ConfigurationUtils.acceptPhoneNumberWithAlphaChars());
- acceptPhoneNumberWithAlphaChars.setAlignmentY(Component.TOP_ALIGNMENT);
-
- acceptPhoneNumberWithAlphaChars.addActionListener(new ActionListener()
+ alphaCharNumbers.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
@@ -916,21 +1003,6 @@ public class GeneralConfigurationPanel
}
});
- StyledHTMLEditorPane acceptPhoneNumberWithAlphaCharsTextLabel
- = new StyledHTMLEditorPane();
-
- acceptPhoneNumberWithAlphaCharsTextLabel.setContentType("text/html");
- acceptPhoneNumberWithAlphaCharsTextLabel.appendToEnd(
- "<html>"
- + GeneralConfigPluginActivator.getResources().getI18NString(
- "plugin.generalconfig.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS")
- + "</html>");
-
- acceptPhoneNumberWithAlphaCharsTextLabel.setBorder(
- BorderFactory.createEmptyBorder(3, 0, 0, 0));
- acceptPhoneNumberWithAlphaCharsTextLabel.setOpaque(false);
- acceptPhoneNumberWithAlphaCharsTextLabel.setEditable(false);
-
// The example of changing letters to numbers in a phone number.
String label = "* " + Resources.getString(
"plugin.generalconfig.ACCEPT_PHONE_NUMBER_WITH_ALPHA_CHARS_EXAMPLE");
@@ -942,14 +1014,8 @@ public class GeneralConfigurationPanel
exampleLabel.setHorizontalAlignment(JLabel.LEFT);
// Adds the components to the current panel.
- checkBoxPanel.add(acceptPhoneNumberWithAlphaChars, BorderLayout.WEST);
- checkBoxPanel.add(
- acceptPhoneNumberWithAlphaCharsTextLabel,
- BorderLayout.CENTER);
- checkBoxPanel.add(
- exampleLabel,
- BorderLayout.SOUTH);
-
+ checkBoxPanel.add(alphaCharNumbers);
+ checkBoxPanel.add(exampleLabel);
return checkBoxPanel;
}
@@ -959,15 +1025,17 @@ public class GeneralConfigurationPanel
*/
public Component createStartupConfigPanel()
{
- if (!OSUtils.IS_WINDOWS)
- return null;
-
JPanel updateConfigPanel = GeneralConfigPluginActivator.
createConfigSectionComponent(
Resources.getString("plugin.generalconfig.STARTUP_CONFIG"));
- updateConfigPanel.add(createAutoStartCheckBox());
- updateConfigPanel.add(createUpdateCheckBox());
+ updateConfigPanel.add(createMinimzeInsteadOfHideCheckBox());
+ if (OSUtils.IS_WINDOWS)
+ {
+ updateConfigPanel.add(createAutoStartCheckBox());
+ updateConfigPanel.add(createUpdateCheckBox());
+ }
+
return updateConfigPanel;
}
diff --git a/src/net/java/sip/communicator/plugin/generalconfig/XMPPConfigForm.java b/src/net/java/sip/communicator/plugin/generalconfig/XMPPConfigForm.java
new file mode 100644
index 0000000..0113232
--- /dev/null
+++ b/src/net/java/sip/communicator/plugin/generalconfig/XMPPConfigForm.java
@@ -0,0 +1,101 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Copyright @ 2015 Atlassian Pty Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package net.java.sip.communicator.plugin.generalconfig;
+
+import java.awt.*;
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import org.jitsi.service.configuration.*;
+
+import net.java.sip.communicator.plugin.desktoputil.*;
+
+/**
+ * Implementation of the configuration form.
+ *
+ * @author Timur Masar
+ */
+public class XMPPConfigForm
+extends TransparentPanel
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * The name of the property used to control whether to use
+ * all resources to show capabilities
+ */
+ public static final String PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES =
+ "net.java.sip.communicator.XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES";
+
+ /**
+ * The default value for the capabilities setting
+ */
+ public static final boolean USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT =
+ true;
+
+ /**
+ * The <tt>ConfigurationService</tt> to be used to access configuration
+ */
+ private final ConfigurationService configurationService
+ = GeneralConfigPluginActivator.getConfigurationService();
+
+ /**
+ * Creates the form.
+ */
+ public XMPPConfigForm()
+ {
+ super(new BorderLayout());
+ Box box = Box.createVerticalBox();
+ add(box, BorderLayout.NORTH);
+
+ TransparentPanel contentPanel = new TransparentPanel();
+ contentPanel.setLayout(new BorderLayout(10, 10));
+
+ box.add(contentPanel);
+
+ TransparentPanel labelPanel
+ = new TransparentPanel(new GridLayout(0, 1, 2, 2));
+ TransparentPanel valuePanel
+ = new TransparentPanel(new GridLayout(0, 1, 2, 2));
+
+ contentPanel.add(labelPanel, BorderLayout.CENTER);
+ contentPanel.add(valuePanel, BorderLayout.WEST);
+
+ final JCheckBox useAllResourcesForCapabilitiesCheckbox =
+ new SIPCommCheckBox(Resources.getString(
+ "plugin.generalconfig.XMPP_USE_ALL_RESOURCES"));
+
+ useAllResourcesForCapabilitiesCheckbox.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent actionEvent) {
+ configurationService.setProperty(
+ PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES,
+ useAllResourcesForCapabilitiesCheckbox.isSelected());
+ }
+ });
+ useAllResourcesForCapabilitiesCheckbox.setSelected(
+ configurationService.getBoolean(
+ PROP_XMPP_USE_ALL_RESOURCES_FOR_CAPABILITIES,
+ USE_ALL_RESOURCES_FOR_CAPABILITIES_DEFAULT));
+ valuePanel.add(useAllResourcesForCapabilitiesCheckbox);
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java
index 38a51c6..37bc48f 100644
--- a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java
+++ b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/AutoAwayWatcher.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,462 +15,462 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.generalconfig.autoaway;
-
-import java.beans.*;
-import java.util.*;
-
-import net.java.sip.communicator.plugin.generalconfig.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.protocol.event.*;
-import net.java.sip.communicator.service.sysactivity.*;
-import net.java.sip.communicator.service.sysactivity.event.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * Listens for idle events from SystemActivityNotifications Service.
- *
- * @author Damian Minkov
- */
-public class AutoAwayWatcher
- implements ServiceListener,
- RegistrationStateChangeListener
-{
- /**
- * The logger.
- */
- private static final Logger logger
- = Logger.getLogger(AutoAwayWatcher.class);
-
- /**
- * The states of providers before going to away.
- */
- private final Map<ProtocolProviderService, PresenceStatus> lastStates
- = new HashMap<ProtocolProviderService, PresenceStatus>();
-
- /**
- * Listens for idle events.
- */
- private IdleListener idleListener = null;
-
- /**
- * Creates AutoAway handler.
- */
- public AutoAwayWatcher()
- {
- if (Preferences.isEnabled())
- {
- start();
- }
-
- Preferences.addEnableChangeListener(
- new PropertyChangeListener()
- {
- public void propertyChange(PropertyChangeEvent evt)
- {
- if(Boolean.parseBoolean((String) evt.getNewValue()))
- start();
- else
- stopInner();
- }
- }
- );
-
- // listens for changes in configured value.
- Preferences.addTimerChangeListener(
- new PropertyChangeListener()
- {
- public void propertyChange(PropertyChangeEvent evt)
- {
- stopInner();
- start();
- }
- }
- );
- }
-
- /**
- * Starts and add needed listeners.
- */
- private void start()
- {
- if(idleListener == null)
- {
-
- idleListener = new IdleListener();
-
- SystemActivityNotificationsService
- systemActivityNotificationsService
- = getSystemActivityNotificationsService();
-
- systemActivityNotificationsService.addIdleSystemChangeListener(
- Preferences.getTimer() * 60 * 1000,
- idleListener);
- systemActivityNotificationsService
- .addSystemActivityChangeListener(idleListener);
-
- startListeningForNewProviders();
- }
- }
-
- /**
- * Start listening for new providers and their registration states.
- */
- private void startListeningForNewProviders()
- {
- // listen for new providers
- GeneralConfigPluginActivator.bundleContext.addServiceListener(this);
-
- // lets check current providers
- ServiceReference[] protocolProviderRefs = null;
- try
- {
- protocolProviderRefs = GeneralConfigPluginActivator.bundleContext
- .getServiceReferences(ProtocolProviderService.class.getName(),
- null);
- }
- catch (InvalidSyntaxException ex)
- {
- // this shouldn't happen since we're providing no parameter string
- // but let's log just in case.
- logger.error(
- "Error while retrieving service refs", ex);
- return;
- }
-
- // in case we found any
- if (protocolProviderRefs != null)
- {
- for (int i = 0; i < protocolProviderRefs.length; i++)
- {
- ProtocolProviderService provider = (ProtocolProviderService)
- GeneralConfigPluginActivator.bundleContext
- .getService(protocolProviderRefs[i]);
-
- this.handleProviderAdded(provider);
- }
- }
- }
-
- /**
- * Stop listening for new providers and their registration states.
- */
- private void stopListeningForNewProviders()
- {
- // stop listen for new providers
- GeneralConfigPluginActivator.bundleContext.removeServiceListener(this);
-
- // lets check current providers and remove registration state listener
- ServiceReference[] protocolProviderRefs = null;
- try
- {
- protocolProviderRefs = GeneralConfigPluginActivator.bundleContext
- .getServiceReferences(ProtocolProviderService.class.getName(),
- null);
- }
- catch (InvalidSyntaxException ex)
- {
- // this shouldn't happen since we're providing no parameter string
- // but let's log just in case.
- logger.error(
- "Error while retrieving service refs", ex);
- return;
- }
-
- // in case we found any
- if (protocolProviderRefs != null)
- {
- for (int i = 0; i < protocolProviderRefs.length; i++)
- {
- ProtocolProviderService provider = (ProtocolProviderService)
- GeneralConfigPluginActivator.bundleContext
- .getService(protocolProviderRefs[i]);
-
- this.handleProviderRemoved(provider);
- }
- }
- }
-
- /**
- * Stops and removes the listeners.
- */
- public void stop()
- {
- GeneralConfigPluginActivator.bundleContext.removeServiceListener(this);
- stopInner();
- }
-
- /**
- * Stops and removes the listeners.
- */
- private void stopInner()
- {
- if(idleListener != null)
- {
- SystemActivityNotificationsService
- systemActivityNotificationsService
- = getSystemActivityNotificationsService();
-
- systemActivityNotificationsService.removeIdleSystemChangeListener(
- idleListener);
- systemActivityNotificationsService
- .removeSystemActivityChangeListener(idleListener);
-
- stopListeningForNewProviders();
-
- idleListener = null;
- }
- }
-
- /**
- * Change protocol to away saving status so it can be set again when
- * out of idle state.
- */
- private void changeProtocolsToAway()
- {
- for (ProtocolProviderService protocolProvider
- : GeneralConfigPluginActivator.getProtocolProviders())
- {
- OperationSetPresence presence
- = protocolProvider.getOperationSet(
- OperationSetPresence.class);
-
- if(presence == null)
- continue;
-
- PresenceStatus status = presence.getPresenceStatus();
-
- if (status.getStatus() < PresenceStatus.AVAILABLE_THRESHOLD)
- {
- // already (manually) set to away or lower
- continue;
- }
-
- PresenceStatus newStatus
- = StatusUpdateThread.findAwayStatus(presence);
-
- try
- {
- if (newStatus != null && !status.equals(newStatus))
- {
- addProviderToLastStates(protocolProvider, status);
-
- presence.publishPresenceStatus(
- newStatus,
- newStatus.getStatusName());
- }
- }
- catch (IllegalArgumentException e)
- {
- }
- catch (IllegalStateException e)
- {
- }
- catch (OperationFailedException e)
- {
- }
- }
- }
-
- /**
- * Back to status which was already saved before going to idle.
- */
- private void changeProtocolsToPreviousState()
- {
- for (ProtocolProviderService protocolProvider
- : GeneralConfigPluginActivator.getProtocolProviders())
- {
- PresenceStatus lastState = lastStates.get(protocolProvider);
-
- if (lastState != null)
- {
- OperationSetPresence presence
- = protocolProvider.getOperationSet(
- OperationSetPresence.class);
- try
- {
- presence.publishPresenceStatus(lastState, "");
- }
- catch (IllegalArgumentException e)
- {
- }
- catch (IllegalStateException e)
- {
- }
- catch (OperationFailedException e)
- {
- }
- removeProviderFromLastStates(protocolProvider);
- }
- }
- }
-
- /**
- * The SystemActivityNotifications Service.
- * @return the SystemActivityNotifications Service.
- */
- private SystemActivityNotificationsService
- getSystemActivityNotificationsService()
- {
- return
- ServiceUtils.getService(
- GeneralConfigPluginActivator.bundleContext,
- SystemActivityNotificationsService.class);
- }
-
- /**
- * When new protocol provider is registered we add our
- * registration change listener.
- * If unregistered remove reference to the provider and the
- * registration change listener.
- *
- * @param serviceEvent ServiceEvent
- */
- public void serviceChanged(ServiceEvent serviceEvent)
- {
- Object service
- = GeneralConfigPluginActivator.bundleContext.getService(
- serviceEvent.getServiceReference());
-
- // we don't care if the source service is not a protocol provider
- if (service instanceof ProtocolProviderService)
- {
- int serviceEventType = serviceEvent.getType();
-
- if (serviceEventType == ServiceEvent.REGISTERED)
- handleProviderAdded((ProtocolProviderService) service);
- else if (serviceEventType == ServiceEvent.UNREGISTERING)
- handleProviderRemoved((ProtocolProviderService) service);
- }
- }
-
- /**
- * Used to set registration state change listener.
- *
- * @param provider ProtocolProviderService
- */
- private synchronized void handleProviderAdded(
- ProtocolProviderService provider)
- {
- provider.addRegistrationStateChangeListener(this);
- }
-
- /**
- * Removes the registration change listener.
- *
- * @param provider the ProtocolProviderService that has been unregistered.
- */
- private void handleProviderRemoved(ProtocolProviderService provider)
- {
- provider.removeRegistrationStateChangeListener(this);
- }
-
- /**
- * Remove provider from list with last statuses.
- * If this is the last provider stop listening for idle events.
- * @param provider
- */
- private synchronized void removeProviderFromLastStates(
- ProtocolProviderService provider)
- {
- lastStates.remove(provider);
- }
-
- /**
- * Remember provider's last status, normally before setting it to away.
- * If needed start listening for idle events.
- * @param provider the provider.
- * @param status the status to save.
- */
- private synchronized void addProviderToLastStates(
- ProtocolProviderService provider,
- PresenceStatus status)
- {
- if(lastStates.size() == 0)
- start();
-
- lastStates.put(provider, status);
- }
-
- /**
- * Listens for provider states.
- * @param evt
- */
- public void registrationStateChanged(RegistrationStateChangeEvent evt)
- {
- if(evt.getSource() instanceof ProtocolProviderService)
- {
- if(evt.getNewState().equals(RegistrationState.UNREGISTERED)
- || evt.getNewState().equals(RegistrationState.CONNECTION_FAILED))
- {
- removeProviderFromLastStates(evt.getProvider());
- }
- else if(evt.getNewState().equals(
- RegistrationState.REGISTERED))
- {
- // we have at least one provider, so lets start listening
- if(lastStates.size() == 0)
- {
- start();
- }
- else
- {
- // or check are we away
- if(getSystemActivityNotificationsService()
- .getTimeSinceLastInput()
- > Preferences.getTimer()*60*1000)
- {
- // we are away, so update the newly registered provider
- // do it in new thread to give the provider
- // time dispatch his status
- new Thread(new Runnable()
- {
- public void run()
- {
- try{
- Thread.sleep(1000);
- }
- catch(Throwable t){}
-
- changeProtocolsToAway();
- }
- }).start();
- }
- }
- }
- }
- }
-
- /**
- * Listener waiting for idle state change.
- */
- private class IdleListener
- implements SystemActivityChangeListener
- {
- /**
- * Listens for activities and set corresponding statuses.
- *
- * @param event the <tt>NotificationActionTypeEvent</tt>, which is
- */
- public void activityChanged(SystemActivityEvent event)
- {
- switch(event.getEventID())
- {
- case SystemActivityEvent.EVENT_DISPLAY_SLEEP:
- case SystemActivityEvent.EVENT_SCREEN_LOCKED:
- case SystemActivityEvent.EVENT_SCREENSAVER_START:
- case SystemActivityEvent.EVENT_SYSTEM_IDLE:
- changeProtocolsToAway();
- break;
- case SystemActivityEvent.EVENT_DISPLAY_WAKE:
- case SystemActivityEvent.EVENT_SCREEN_UNLOCKED:
- case SystemActivityEvent.EVENT_SCREENSAVER_STOP:
- case SystemActivityEvent.EVENT_SYSTEM_IDLE_END:
- changeProtocolsToPreviousState();
- break;
- }
- }
- }
-}
+package net.java.sip.communicator.plugin.generalconfig.autoaway;
+
+import java.beans.*;
+import java.util.*;
+
+import net.java.sip.communicator.plugin.generalconfig.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.protocol.event.*;
+import net.java.sip.communicator.service.sysactivity.*;
+import net.java.sip.communicator.service.sysactivity.event.*;
+import net.java.sip.communicator.util.*;
+
+import org.osgi.framework.*;
+
+/**
+ * Listens for idle events from SystemActivityNotifications Service.
+ *
+ * @author Damian Minkov
+ */
+public class AutoAwayWatcher
+ implements ServiceListener,
+ RegistrationStateChangeListener
+{
+ /**
+ * The logger.
+ */
+ private static final Logger logger
+ = Logger.getLogger(AutoAwayWatcher.class);
+
+ /**
+ * The states of providers before going to away.
+ */
+ private final Map<ProtocolProviderService, PresenceStatus> lastStates
+ = new HashMap<ProtocolProviderService, PresenceStatus>();
+
+ /**
+ * Listens for idle events.
+ */
+ private IdleListener idleListener = null;
+
+ /**
+ * Creates AutoAway handler.
+ */
+ public AutoAwayWatcher()
+ {
+ if (Preferences.isEnabled())
+ {
+ start();
+ }
+
+ Preferences.addEnableChangeListener(
+ new PropertyChangeListener()
+ {
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ if(Boolean.parseBoolean((String) evt.getNewValue()))
+ start();
+ else
+ stopInner();
+ }
+ }
+ );
+
+ // listens for changes in configured value.
+ Preferences.addTimerChangeListener(
+ new PropertyChangeListener()
+ {
+ public void propertyChange(PropertyChangeEvent evt)
+ {
+ stopInner();
+ start();
+ }
+ }
+ );
+ }
+
+ /**
+ * Starts and add needed listeners.
+ */
+ private void start()
+ {
+ if(idleListener == null)
+ {
+
+ idleListener = new IdleListener();
+
+ SystemActivityNotificationsService
+ systemActivityNotificationsService
+ = getSystemActivityNotificationsService();
+
+ systemActivityNotificationsService.addIdleSystemChangeListener(
+ Preferences.getTimer() * 60 * 1000,
+ idleListener);
+ systemActivityNotificationsService
+ .addSystemActivityChangeListener(idleListener);
+
+ startListeningForNewProviders();
+ }
+ }
+
+ /**
+ * Start listening for new providers and their registration states.
+ */
+ private void startListeningForNewProviders()
+ {
+ // listen for new providers
+ GeneralConfigPluginActivator.bundleContext.addServiceListener(this);
+
+ // lets check current providers
+ ServiceReference[] protocolProviderRefs = null;
+ try
+ {
+ protocolProviderRefs = GeneralConfigPluginActivator.bundleContext
+ .getServiceReferences(ProtocolProviderService.class.getName(),
+ null);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ // this shouldn't happen since we're providing no parameter string
+ // but let's log just in case.
+ logger.error(
+ "Error while retrieving service refs", ex);
+ return;
+ }
+
+ // in case we found any
+ if (protocolProviderRefs != null)
+ {
+ for (int i = 0; i < protocolProviderRefs.length; i++)
+ {
+ ProtocolProviderService provider = (ProtocolProviderService)
+ GeneralConfigPluginActivator.bundleContext
+ .getService(protocolProviderRefs[i]);
+
+ this.handleProviderAdded(provider);
+ }
+ }
+ }
+
+ /**
+ * Stop listening for new providers and their registration states.
+ */
+ private void stopListeningForNewProviders()
+ {
+ // stop listen for new providers
+ GeneralConfigPluginActivator.bundleContext.removeServiceListener(this);
+
+ // lets check current providers and remove registration state listener
+ ServiceReference[] protocolProviderRefs = null;
+ try
+ {
+ protocolProviderRefs = GeneralConfigPluginActivator.bundleContext
+ .getServiceReferences(ProtocolProviderService.class.getName(),
+ null);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ // this shouldn't happen since we're providing no parameter string
+ // but let's log just in case.
+ logger.error(
+ "Error while retrieving service refs", ex);
+ return;
+ }
+
+ // in case we found any
+ if (protocolProviderRefs != null)
+ {
+ for (int i = 0; i < protocolProviderRefs.length; i++)
+ {
+ ProtocolProviderService provider = (ProtocolProviderService)
+ GeneralConfigPluginActivator.bundleContext
+ .getService(protocolProviderRefs[i]);
+
+ this.handleProviderRemoved(provider);
+ }
+ }
+ }
+
+ /**
+ * Stops and removes the listeners.
+ */
+ public void stop()
+ {
+ GeneralConfigPluginActivator.bundleContext.removeServiceListener(this);
+ stopInner();
+ }
+
+ /**
+ * Stops and removes the listeners.
+ */
+ private void stopInner()
+ {
+ if(idleListener != null)
+ {
+ SystemActivityNotificationsService
+ systemActivityNotificationsService
+ = getSystemActivityNotificationsService();
+
+ systemActivityNotificationsService.removeIdleSystemChangeListener(
+ idleListener);
+ systemActivityNotificationsService
+ .removeSystemActivityChangeListener(idleListener);
+
+ stopListeningForNewProviders();
+
+ idleListener = null;
+ }
+ }
+
+ /**
+ * Change protocol to away saving status so it can be set again when
+ * out of idle state.
+ */
+ private void changeProtocolsToAway()
+ {
+ for (ProtocolProviderService protocolProvider
+ : GeneralConfigPluginActivator.getProtocolProviders())
+ {
+ OperationSetPresence presence
+ = protocolProvider.getOperationSet(
+ OperationSetPresence.class);
+
+ if(presence == null)
+ continue;
+
+ PresenceStatus status = presence.getPresenceStatus();
+
+ if (status.getStatus() < PresenceStatus.AVAILABLE_THRESHOLD)
+ {
+ // already (manually) set to away or lower
+ continue;
+ }
+
+ PresenceStatus newStatus
+ = StatusUpdateThread.findAwayStatus(presence);
+
+ try
+ {
+ if (newStatus != null && !status.equals(newStatus))
+ {
+ addProviderToLastStates(protocolProvider, status);
+
+ presence.publishPresenceStatus(
+ newStatus,
+ newStatus.getStatusName());
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ catch (OperationFailedException e)
+ {
+ }
+ }
+ }
+
+ /**
+ * Back to status which was already saved before going to idle.
+ */
+ private void changeProtocolsToPreviousState()
+ {
+ for (ProtocolProviderService protocolProvider
+ : GeneralConfigPluginActivator.getProtocolProviders())
+ {
+ PresenceStatus lastState = lastStates.get(protocolProvider);
+
+ if (lastState != null)
+ {
+ OperationSetPresence presence
+ = protocolProvider.getOperationSet(
+ OperationSetPresence.class);
+ try
+ {
+ presence.publishPresenceStatus(lastState, "");
+ }
+ catch (IllegalArgumentException e)
+ {
+ }
+ catch (IllegalStateException e)
+ {
+ }
+ catch (OperationFailedException e)
+ {
+ }
+ removeProviderFromLastStates(protocolProvider);
+ }
+ }
+ }
+
+ /**
+ * The SystemActivityNotifications Service.
+ * @return the SystemActivityNotifications Service.
+ */
+ private SystemActivityNotificationsService
+ getSystemActivityNotificationsService()
+ {
+ return
+ ServiceUtils.getService(
+ GeneralConfigPluginActivator.bundleContext,
+ SystemActivityNotificationsService.class);
+ }
+
+ /**
+ * When new protocol provider is registered we add our
+ * registration change listener.
+ * If unregistered remove reference to the provider and the
+ * registration change listener.
+ *
+ * @param serviceEvent ServiceEvent
+ */
+ public void serviceChanged(ServiceEvent serviceEvent)
+ {
+ Object service
+ = GeneralConfigPluginActivator.bundleContext.getService(
+ serviceEvent.getServiceReference());
+
+ // we don't care if the source service is not a protocol provider
+ if (service instanceof ProtocolProviderService)
+ {
+ int serviceEventType = serviceEvent.getType();
+
+ if (serviceEventType == ServiceEvent.REGISTERED)
+ handleProviderAdded((ProtocolProviderService) service);
+ else if (serviceEventType == ServiceEvent.UNREGISTERING)
+ handleProviderRemoved((ProtocolProviderService) service);
+ }
+ }
+
+ /**
+ * Used to set registration state change listener.
+ *
+ * @param provider ProtocolProviderService
+ */
+ private synchronized void handleProviderAdded(
+ ProtocolProviderService provider)
+ {
+ provider.addRegistrationStateChangeListener(this);
+ }
+
+ /**
+ * Removes the registration change listener.
+ *
+ * @param provider the ProtocolProviderService that has been unregistered.
+ */
+ private void handleProviderRemoved(ProtocolProviderService provider)
+ {
+ provider.removeRegistrationStateChangeListener(this);
+ }
+
+ /**
+ * Remove provider from list with last statuses.
+ * If this is the last provider stop listening for idle events.
+ * @param provider
+ */
+ private synchronized void removeProviderFromLastStates(
+ ProtocolProviderService provider)
+ {
+ lastStates.remove(provider);
+ }
+
+ /**
+ * Remember provider's last status, normally before setting it to away.
+ * If needed start listening for idle events.
+ * @param provider the provider.
+ * @param status the status to save.
+ */
+ private synchronized void addProviderToLastStates(
+ ProtocolProviderService provider,
+ PresenceStatus status)
+ {
+ if(lastStates.size() == 0)
+ start();
+
+ lastStates.put(provider, status);
+ }
+
+ /**
+ * Listens for provider states.
+ * @param evt
+ */
+ public void registrationStateChanged(RegistrationStateChangeEvent evt)
+ {
+ if(evt.getSource() instanceof ProtocolProviderService)
+ {
+ if(evt.getNewState().equals(RegistrationState.UNREGISTERED)
+ || evt.getNewState().equals(RegistrationState.CONNECTION_FAILED))
+ {
+ removeProviderFromLastStates(evt.getProvider());
+ }
+ else if(evt.getNewState().equals(
+ RegistrationState.REGISTERED))
+ {
+ // we have at least one provider, so lets start listening
+ if(lastStates.size() == 0)
+ {
+ start();
+ }
+ else
+ {
+ // or check are we away
+ if(getSystemActivityNotificationsService()
+ .getTimeSinceLastInput()
+ > Preferences.getTimer()*60*1000)
+ {
+ // we are away, so update the newly registered provider
+ // do it in new thread to give the provider
+ // time dispatch his status
+ new Thread(new Runnable()
+ {
+ public void run()
+ {
+ try{
+ Thread.sleep(1000);
+ }
+ catch(Throwable t){}
+
+ changeProtocolsToAway();
+ }
+ }).start();
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Listener waiting for idle state change.
+ */
+ private class IdleListener
+ implements SystemActivityChangeListener
+ {
+ /**
+ * Listens for activities and set corresponding statuses.
+ *
+ * @param event the <tt>NotificationActionTypeEvent</tt>, which is
+ */
+ public void activityChanged(SystemActivityEvent event)
+ {
+ switch(event.getEventID())
+ {
+ case SystemActivityEvent.EVENT_DISPLAY_SLEEP:
+ case SystemActivityEvent.EVENT_SCREEN_LOCKED:
+ case SystemActivityEvent.EVENT_SCREENSAVER_START:
+ case SystemActivityEvent.EVENT_SYSTEM_IDLE:
+ changeProtocolsToAway();
+ break;
+ case SystemActivityEvent.EVENT_DISPLAY_WAKE:
+ case SystemActivityEvent.EVENT_SCREEN_UNLOCKED:
+ case SystemActivityEvent.EVENT_SCREENSAVER_STOP:
+ case SystemActivityEvent.EVENT_SYSTEM_IDLE_END:
+ changeProtocolsToPreviousState();
+ break;
+ }
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/Preferences.java b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/Preferences.java
index 148da25..bee52df 100644
--- a/src/net/java/sip/communicator/plugin/generalconfig/autoaway/Preferences.java
+++ b/src/net/java/sip/communicator/plugin/generalconfig/autoaway/Preferences.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,133 +15,133 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.generalconfig.autoaway;
-
-import net.java.sip.communicator.plugin.generalconfig.*;
-import org.jitsi.service.configuration.*;
-import org.jitsi.service.resources.*;
-
-import java.beans.*;
-
-/**
- * Preferences for the Status Update
- *
- * @author Thomas Hofer
- *
- */
-public final class Preferences
-{
- /**
- * Property indicating whether status change on away is enabled.
- */
- private static final String ENABLE
- = "net.java.sip.communicator.plugin.statusupdate.enable";
-
- /**
- * Property indicating the time in minutes to consider a pc in idle state.
- */
- private static final String TIMER
- = "net.java.sip.communicator.plugin.statusupdate.timer";
-
- /**
- * The default value to be displayed and to be considered
- * for {@link Preferences#TIMER}.
- */
- public static final int DEFAULT_TIMER = 15;
-
- /**
- * Whether change status on away is enabled.
- * @return whether change status on away is enabled.
- */
- static boolean isEnabled()
- {
- // if enabled start
- String enabledDefault
- = GeneralConfigPluginActivator.getResources().getSettingsString(
- Preferences.ENABLE);
-
- return
- GeneralConfigPluginActivator
- .getConfigurationService()
- .getBoolean(
- Preferences.ENABLE,
- Boolean.parseBoolean(enabledDefault));
- }
-
- /**
- * Returns the time in minutes to consider a pc in idle state.
- * @return the time in minutes to consider a pc in idle state.
- */
- static int getTimer()
- {
- ConfigurationService cfg
- = GeneralConfigPluginActivator.getConfigurationService();
- ResourceManagementService resources
- = GeneralConfigPluginActivator.getResources();
-
- String enabledDefault = resources.getSettingsString(Preferences.ENABLE);
-
- String timerDefaultStr = resources.getSettingsString(Preferences.TIMER);
- int timerDefault = DEFAULT_TIMER;
-
- if (timerDefaultStr != null)
- {
- try
- {
- timerDefault = Integer.parseInt(timerDefaultStr);
- }
- catch (NumberFormatException nfe)
- {
- }
- }
-
- return
- cfg.getBoolean(
- Preferences.ENABLE,
- Boolean.parseBoolean(enabledDefault))
- ? cfg.getInt(Preferences.TIMER, timerDefault)
- : 0;
- }
-
- /**
- * Save data in the configuration file
- * @param enabled is enabled
- * @param timer the time value to save
- */
- static void saveData(boolean enabled, String timer)
- {
- ConfigurationService cfg
- = GeneralConfigPluginActivator.getConfigurationService();
-
- cfg.setProperty(Preferences.ENABLE, Boolean.toString(enabled));
- cfg.setProperty(Preferences.TIMER, timer);
- }
-
- /**
- * Adds listener to detect property changes.
- * @param listener the listener to notify.
- */
- static void addEnableChangeListener(PropertyChangeListener listener)
- {
- // listens for changes in configuration enable/disable
- GeneralConfigPluginActivator
- .getConfigurationService()
- .addPropertyChangeListener(
- ENABLE,
- listener);
- }
-
- /**
- * Adds listener to detect timer property changes.
- * @param listener the listener to notify.
- */
- static void addTimerChangeListener(PropertyChangeListener listener)
- {
- // listens for changes in configuration enable/disable
- GeneralConfigPluginActivator
- .getConfigurationService()
- .addPropertyChangeListener(
- TIMER,
- listener);
- }
-}
+package net.java.sip.communicator.plugin.generalconfig.autoaway;
+
+import net.java.sip.communicator.plugin.generalconfig.*;
+import org.jitsi.service.configuration.*;
+import org.jitsi.service.resources.*;
+
+import java.beans.*;
+
+/**
+ * Preferences for the Status Update
+ *
+ * @author Thomas Hofer
+ *
+ */
+public final class Preferences
+{
+ /**
+ * Property indicating whether status change on away is enabled.
+ */
+ private static final String ENABLE
+ = "net.java.sip.communicator.plugin.statusupdate.enable";
+
+ /**
+ * Property indicating the time in minutes to consider a pc in idle state.
+ */
+ private static final String TIMER
+ = "net.java.sip.communicator.plugin.statusupdate.timer";
+
+ /**
+ * The default value to be displayed and to be considered
+ * for {@link Preferences#TIMER}.
+ */
+ public static final int DEFAULT_TIMER = 15;
+
+ /**
+ * Whether change status on away is enabled.
+ * @return whether change status on away is enabled.
+ */
+ static boolean isEnabled()
+ {
+ // if enabled start
+ String enabledDefault
+ = GeneralConfigPluginActivator.getResources().getSettingsString(
+ Preferences.ENABLE);
+
+ return
+ GeneralConfigPluginActivator
+ .getConfigurationService()
+ .getBoolean(
+ Preferences.ENABLE,
+ Boolean.parseBoolean(enabledDefault));
+ }
+
+ /**
+ * Returns the time in minutes to consider a pc in idle state.
+ * @return the time in minutes to consider a pc in idle state.
+ */
+ static int getTimer()
+ {
+ ConfigurationService cfg
+ = GeneralConfigPluginActivator.getConfigurationService();
+ ResourceManagementService resources
+ = GeneralConfigPluginActivator.getResources();
+
+ String enabledDefault = resources.getSettingsString(Preferences.ENABLE);
+
+ String timerDefaultStr = resources.getSettingsString(Preferences.TIMER);
+ int timerDefault = DEFAULT_TIMER;
+
+ if (timerDefaultStr != null)
+ {
+ try
+ {
+ timerDefault = Integer.parseInt(timerDefaultStr);
+ }
+ catch (NumberFormatException nfe)
+ {
+ }
+ }
+
+ return
+ cfg.getBoolean(
+ Preferences.ENABLE,
+ Boolean.parseBoolean(enabledDefault))
+ ? cfg.getInt(Preferences.TIMER, timerDefault)
+ : 0;
+ }
+
+ /**
+ * Save data in the configuration file
+ * @param enabled is enabled
+ * @param timer the time value to save
+ */
+ static void saveData(boolean enabled, String timer)
+ {
+ ConfigurationService cfg
+ = GeneralConfigPluginActivator.getConfigurationService();
+
+ cfg.setProperty(Preferences.ENABLE, Boolean.toString(enabled));
+ cfg.setProperty(Preferences.TIMER, timer);
+ }
+
+ /**
+ * Adds listener to detect property changes.
+ * @param listener the listener to notify.
+ */
+ static void addEnableChangeListener(PropertyChangeListener listener)
+ {
+ // listens for changes in configuration enable/disable
+ GeneralConfigPluginActivator
+ .getConfigurationService()
+ .addPropertyChangeListener(
+ ENABLE,
+ listener);
+ }
+
+ /**
+ * Adds listener to detect timer property changes.
+ * @param listener the listener to notify.
+ */
+ static void addTimerChangeListener(PropertyChangeListener listener)
+ {
+ // listens for changes in configuration enable/disable
+ GeneralConfigPluginActivator
+ .getConfigurationService()
+ .addPropertyChangeListener(
+ TIMER,
+ listener);
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyPluginActivator.java b/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyPluginActivator.java
index a80633e..7e9dbd5 100644
--- a/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyPluginActivator.java
+++ b/src/net/java/sip/communicator/plugin/globalproxyconfig/GlobalProxyPluginActivator.java
@@ -175,9 +175,8 @@ public class GlobalProxyPluginActivator implements BundleActivator
"http.proxyPort", globalProxyPortStr);
}
- // used by some protocols like yahoo
- System.setProperty(
- "proxySet", "true");
+ // used by some protocols
+ System.setProperty("proxySet", "true");
}
else if(globalProxyType.equals(
ProxyInfo.ProxyType.SOCKS4.name()) ||
@@ -196,9 +195,8 @@ public class GlobalProxyPluginActivator implements BundleActivator
"socksProxyPort", globalProxyPortStr);
}
- // used by some protocols like yahoo
- System.setProperty(
- "socksProxySet", "true");
+ // used by some protocols
+ System.setProperty("socksProxySet", "true");
}
Authenticator.setDefault(new AuthenticatorImpl(
diff --git a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccRegWizzActivator.java
index e457fdd..02b84e9 100644
--- a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccRegWizzActivator.java
+++ b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccRegWizzActivator.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,163 +15,163 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.googletalkaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.resources.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.resources.*;
-import org.osgi.framework.*;
-
-/**
- * Registers the <tt>GoogleTalkAccountRegistrationWizard</tt> in the UI Service.
- *
- * @author Lubomir Marinov
- */
-public class GoogleTalkAccRegWizzActivator
- extends AbstractServiceDependentActivator
-{
- /**
- * OSGi bundle context.
- */
- public static BundleContext bundleContext;
-
- private static ResourceManagementService resourcesService;
-
- /**
- * The <tt>Logger</tt> used by the <tt>GoogleTalkAccRegWizzActivator</tt>
- * and its instances for logging output.
- */
- private static final Logger logger
- = Logger.getLogger(GoogleTalkAccRegWizzActivator.class);
-
- private static BrowserLauncherService browserLauncherService;
-
- private static UIService uiService;
-
- /**
- * Starts this bundle.
- */
- @Override
- public void start(Object dependentService)
- {
- uiService = (UIService)dependentService;
-
- GoogleTalkAccountRegistrationWizard wizard =
- new GoogleTalkAccountRegistrationWizard(uiService
- .getAccountRegWizardContainer());
-
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
- containerFilter.put(
- ProtocolProviderFactory.PROTOCOL,
- GoogleTalkAccountRegistrationWizard.PROTOCOL);
-
- bundleContext.registerService(
- AccountRegistrationWizard.class.getName(),
- wizard,
- containerFilter);
- }
-
- /**
- * The dependent class. We are waiting for the ui service.
- * @return
- */
- @Override
- public Class<?> getDependentServiceClass()
- {
- return UIService.class;
- }
-
- /**
- * The bundle context to use.
- * @param context the context to set.
- */
- @Override
- public void setBundleContext(BundleContext context)
- {
- bundleContext = context;
- }
-
- public void stop(BundleContext bundleContext)
- throws Exception
- {
- }
-
- /**
- * Returns the <tt>ProtocolProviderFactory</tt> for the Google Talk
- * protocol.
- *
- * @return the <tt>ProtocolProviderFactory</tt> for the Google Talk
- * protocol
- */
- public static ProtocolProviderFactory getGoogleTalkProtocolProviderFactory()
- {
- ServiceReference[] serRefs = null;
-
- String osgiFilter = "("
- + ProtocolProviderFactory.PROTOCOL
- + "=" + ProtocolNames.JABBER + ")";
-
- try
- {
- serRefs = bundleContext.getServiceReferences(
- ProtocolProviderFactory.class.getName(), osgiFilter);
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error("GoogleTalkAccRegWizzActivator : " + ex);
- }
-
- return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
- }
-
- /**
- * Returns the <tt>UIService</tt>.
- *
- * @return the <tt>UIService</tt>
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-
- /**
- * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context.
- * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context
- */
- public static BrowserLauncherService getBrowserLauncher()
- {
- if (browserLauncherService == null)
- {
- browserLauncherService =
- (BrowserLauncherService) bundleContext
- .getService(bundleContext
- .getServiceReference(BrowserLauncherService.class
- .getName()));
- }
-
- return browserLauncherService;
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(GoogleTalkAccRegWizzActivator.bundleContext);
- return resourcesService;
- }
-}
+package net.java.sip.communicator.plugin.googletalkaccregwizz;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.browserlauncher.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.resources.*;
+import net.java.sip.communicator.util.*;
+
+import org.jitsi.service.resources.*;
+import org.osgi.framework.*;
+
+/**
+ * Registers the <tt>GoogleTalkAccountRegistrationWizard</tt> in the UI Service.
+ *
+ * @author Lubomir Marinov
+ */
+public class GoogleTalkAccRegWizzActivator
+ extends AbstractServiceDependentActivator
+{
+ /**
+ * OSGi bundle context.
+ */
+ public static BundleContext bundleContext;
+
+ private static ResourceManagementService resourcesService;
+
+ /**
+ * The <tt>Logger</tt> used by the <tt>GoogleTalkAccRegWizzActivator</tt>
+ * and its instances for logging output.
+ */
+ private static final Logger logger
+ = Logger.getLogger(GoogleTalkAccRegWizzActivator.class);
+
+ private static BrowserLauncherService browserLauncherService;
+
+ private static UIService uiService;
+
+ /**
+ * Starts this bundle.
+ */
+ @Override
+ public void start(Object dependentService)
+ {
+ uiService = (UIService)dependentService;
+
+ GoogleTalkAccountRegistrationWizard wizard =
+ new GoogleTalkAccountRegistrationWizard(uiService
+ .getAccountRegWizardContainer());
+
+ Hashtable<String, String> containerFilter
+ = new Hashtable<String, String>();
+ containerFilter.put(
+ ProtocolProviderFactory.PROTOCOL,
+ GoogleTalkAccountRegistrationWizard.PROTOCOL);
+
+ bundleContext.registerService(
+ AccountRegistrationWizard.class.getName(),
+ wizard,
+ containerFilter);
+ }
+
+ /**
+ * The dependent class. We are waiting for the ui service.
+ * @return
+ */
+ @Override
+ public Class<?> getDependentServiceClass()
+ {
+ return UIService.class;
+ }
+
+ /**
+ * The bundle context to use.
+ * @param context the context to set.
+ */
+ @Override
+ public void setBundleContext(BundleContext context)
+ {
+ bundleContext = context;
+ }
+
+ public void stop(BundleContext bundleContext)
+ throws Exception
+ {
+ }
+
+ /**
+ * Returns the <tt>ProtocolProviderFactory</tt> for the Google Talk
+ * protocol.
+ *
+ * @return the <tt>ProtocolProviderFactory</tt> for the Google Talk
+ * protocol
+ */
+ public static ProtocolProviderFactory getGoogleTalkProtocolProviderFactory()
+ {
+ ServiceReference[] serRefs = null;
+
+ String osgiFilter = "("
+ + ProtocolProviderFactory.PROTOCOL
+ + "=" + ProtocolNames.JABBER + ")";
+
+ try
+ {
+ serRefs = bundleContext.getServiceReferences(
+ ProtocolProviderFactory.class.getName(), osgiFilter);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ logger.error("GoogleTalkAccRegWizzActivator : " + ex);
+ }
+
+ return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
+ }
+
+ /**
+ * Returns the <tt>UIService</tt>.
+ *
+ * @return the <tt>UIService</tt>
+ */
+ public static UIService getUIService()
+ {
+ return uiService;
+ }
+
+ /**
+ * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
+ * context.
+ * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
+ * context
+ */
+ public static BrowserLauncherService getBrowserLauncher()
+ {
+ if (browserLauncherService == null)
+ {
+ browserLauncherService =
+ (BrowserLauncherService) bundleContext
+ .getService(bundleContext
+ .getServiceReference(BrowserLauncherService.class
+ .getName()));
+ }
+
+ return browserLauncherService;
+ }
+
+ /**
+ * Returns the <tt>ResourceManagementService</tt>.
+ *
+ * @return the <tt>ResourceManagementService</tt>.
+ */
+ public static ResourceManagementService getResources()
+ {
+ if (resourcesService == null)
+ resourcesService =
+ ResourceManagementServiceUtils
+ .getService(GoogleTalkAccRegWizzActivator.bundleContext);
+ return resourcesService;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java
index c296762..25b3b21 100644
--- a/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/googletalkaccregwizz/GoogleTalkAccountRegistrationWizard.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,254 +15,254 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.googletalkaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.plugin.jabberaccregwizz.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.jabber.*;
-
-/**
- * The <tt>GoogleTalkAccountRegistrationWizard</tt> is an implementation of the
- * <tt>AccountRegistrationWizard</tt> for the Google Talk protocol. It should
- * allow the user to create and configure a new Google Talk account.
- *
- * @author Lubomir Marinov
- * @author Yana Stamcheva
- */
-public class GoogleTalkAccountRegistrationWizard
- extends JabberAccountRegistrationWizard
-{
- /**
- * The Google Talk protocol name.
- */
- public static final String PROTOCOL = "Google Talk";
-
- /**
- * A constant pointing to the Google Talk protocol logo image.
- */
- public static final String PROTOCOL_ICON
- = "service.protocol.googletalk.GTALK_16x16";
-
- /**
- * A constant pointing to the Aim protocol wizard page image.
- */
- public static final String PAGE_IMAGE
- = "service.protocol.googletalk.GTALK_64x64";
-
- /**
- * Creates an instance of <tt>GoogleTalkAccountRegistrationWizard</tt>.
- * @param wizardContainer the wizard container, where this wizard
- * is added
- */
- public GoogleTalkAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- super(wizardContainer);
- }
-
- /**
- * Returns the set of pages contained in this wizard.
- * @return Iterator
- */
- @Override
- public Iterator<WizardPage> getPages()
- {
- JabberAccountRegistration reg = new JabberAccountRegistration();
-
- setPredefinedProperties(reg);
-
- return getPages(reg);
- }
-
- /**
- * Returns a simple account registration form that would be the first form
- * shown to the user. Only if the user needs more settings she'll choose
- * to open the advanced wizard, consisted by all pages.
- *
- * @param isCreateAccount indicates if the simple form should be opened as
- * a create account form or as a login form
- * @return a simple account registration form
- */
- @Override
- public Object getSimpleForm(boolean isCreateAccount)
- {
- JabberAccountRegistration reg = new JabberAccountRegistration();
-
- setPredefinedProperties(reg);
-
- return getSimpleForm(reg, isCreateAccount);
- }
-
- /**
- * Sets all google talk specific properties.
- *
- * @param reg the registration object
- */
- private void setPredefinedProperties(JabberAccountRegistration reg)
- {
- reg.setDefaultUserSufix("gmail.com");
- reg.setServerAddress("talk.google.com");
-
- reg.setServerOverridden(true);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * Returns the icon to be used for this wizard.
- * @return byte[]
- */
- @Override
- public byte[] getIcon()
- {
- return GoogleTalkAccRegWizzActivator.getResources()
- .getImageInBytes(PROTOCOL_ICON);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
- * Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- @Override
- public byte[] getPageImage()
- {
- return GoogleTalkAccRegWizzActivator.getResources()
- .getImageInBytes(PAGE_IMAGE);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method. Returns the protocol name for this wizard.
- * @return String
- */
- @Override
- public String getProtocolName()
- {
- return GoogleTalkAccRegWizzActivator.getResources()
- .getI18NString("plugin.googletalkaccregwizz.PROTOCOL_NAME");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code> method. Returns the description of the protocol for this wizard.
- * @return String
- */
- @Override
- public String getProtocolDescription()
- {
- return GoogleTalkAccRegWizzActivator.getResources()
- .getI18NString("plugin.googletalkaccregwizz.PROTOCOL_DESCRIPTION");
- }
-
- /**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
- */
- @Override
- public String getUserNameExample()
- {
- return "Ex: johnsmith@gmail.com or johnsmith";
- }
-
- /**
- * Returns the display label used for the sip id field.
- * @return the sip id display label string.
- */
- @Override
- protected String getUsernameLabel()
- {
- return GoogleTalkAccRegWizzActivator.getResources()
- .getI18NString("plugin.googletalkaccregwizz.USERNAME");
- }
-
- /**
- * Return the string for add existing account button.
- * @return the string for add existing account button.
- */
- @Override
- protected String getCreateAccountButtonLabel()
- {
- return GoogleTalkAccRegWizzActivator.getResources().getI18NString(
- "plugin.googletalkaccregwizz.NEW_ACCOUNT_TITLE");
- }
-
- /**
- * Return the string for create new account button.
- * @return the string for create new account button.
- */
- @Override
- protected String getCreateAccountLabel()
- {
- return GoogleTalkAccRegWizzActivator.getResources().getI18NString(
- "plugin.googletalkaccregwizz.REGISTER_NEW_ACCOUNT_TEXT");
- }
-
- /**
- * Returns the protocol name as listed in "ProtocolNames" or just the name
- * of the service.
- * @return the protocol name
- */
- @Override
- public String getProtocol()
- {
- return PROTOCOL;
- }
-
- /**
- * Returns the protocol icon path.
- * @return the protocol icon path
- */
- @Override
- public String getProtocolIconPath()
- {
- return "resources/images/protocol/googletalk";
- }
-
- /**
- * Returns the account icon path.
- * @return the account icon path
- */
- @Override
- public String getAccountIconPath()
- {
- return "resources/images/protocol/googletalk/logo32x32.png";
- }
-
- /**
- * Opens a browser on the sign up page.
- */
- @Override
- public void webSignup()
- {
- GoogleTalkAccRegWizzActivator.getBrowserLauncher()
- .openURL("https://www.google.com/accounts/NewAccount");
- }
-
- /**
- * Returns <code>true</code> if the web sign up is supported by the current
- * implementation, <code>false</code> - otherwise.
- * @return <code>true</code> if the web sign up is supported by the current
- * implementation, <code>false</code> - otherwise
- */
- @Override
- public boolean isWebSignupSupported()
- {
- return true;
- }
-
- /**
- * Returns an instance of <tt>CreateAccountService</tt> through which the
- * user could create an account. This method is meant to be implemented by
- * specific protocol provider wizards.
- * @return an instance of <tt>CreateAccountService</tt>
- */
- @Override
- protected JabberAccountCreationFormService getCreateAccountService()
- {
- return null;
- }
-}
+package net.java.sip.communicator.plugin.googletalkaccregwizz;
+
+import java.util.*;
+
+import net.java.sip.communicator.plugin.jabberaccregwizz.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.jabber.*;
+
+/**
+ * The <tt>GoogleTalkAccountRegistrationWizard</tt> is an implementation of the
+ * <tt>AccountRegistrationWizard</tt> for the Google Talk protocol. It should
+ * allow the user to create and configure a new Google Talk account.
+ *
+ * @author Lubomir Marinov
+ * @author Yana Stamcheva
+ */
+public class GoogleTalkAccountRegistrationWizard
+ extends JabberAccountRegistrationWizard
+{
+ /**
+ * The Google Talk protocol name.
+ */
+ public static final String PROTOCOL = "Google Talk";
+
+ /**
+ * A constant pointing to the Google Talk protocol logo image.
+ */
+ public static final String PROTOCOL_ICON
+ = "service.protocol.googletalk.GTALK_16x16";
+
+ /**
+ * A constant pointing to the Aim protocol wizard page image.
+ */
+ public static final String PAGE_IMAGE
+ = "service.protocol.googletalk.GTALK_64x64";
+
+ /**
+ * Creates an instance of <tt>GoogleTalkAccountRegistrationWizard</tt>.
+ * @param wizardContainer the wizard container, where this wizard
+ * is added
+ */
+ public GoogleTalkAccountRegistrationWizard(WizardContainer wizardContainer)
+ {
+ super(wizardContainer);
+ }
+
+ /**
+ * Returns the set of pages contained in this wizard.
+ * @return Iterator
+ */
+ @Override
+ public Iterator<WizardPage> getPages()
+ {
+ JabberAccountRegistration reg = new JabberAccountRegistration();
+
+ setPredefinedProperties(reg);
+
+ return getPages(reg);
+ }
+
+ /**
+ * Returns a simple account registration form that would be the first form
+ * shown to the user. Only if the user needs more settings she'll choose
+ * to open the advanced wizard, consisted by all pages.
+ *
+ * @param isCreateAccount indicates if the simple form should be opened as
+ * a create account form or as a login form
+ * @return a simple account registration form
+ */
+ @Override
+ public Object getSimpleForm(boolean isCreateAccount)
+ {
+ JabberAccountRegistration reg = new JabberAccountRegistration();
+
+ setPredefinedProperties(reg);
+
+ return getSimpleForm(reg, isCreateAccount);
+ }
+
+ /**
+ * Sets all google talk specific properties.
+ *
+ * @param reg the registration object
+ */
+ private void setPredefinedProperties(JabberAccountRegistration reg)
+ {
+ reg.setDefaultUserSufix("gmail.com");
+ reg.setServerAddress("talk.google.com");
+
+ reg.setServerOverridden(true);
+ }
+
+ /**
+ * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
+ * Returns the icon to be used for this wizard.
+ * @return byte[]
+ */
+ @Override
+ public byte[] getIcon()
+ {
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getImageInBytes(PROTOCOL_ICON);
+ }
+
+ /**
+ * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
+ * Returns the image used to decorate the wizard page
+ *
+ * @return byte[] the image used to decorate the wizard page
+ */
+ @Override
+ public byte[] getPageImage()
+ {
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getImageInBytes(PAGE_IMAGE);
+ }
+
+ /**
+ * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
+ * method. Returns the protocol name for this wizard.
+ * @return String
+ */
+ @Override
+ public String getProtocolName()
+ {
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getI18NString("plugin.googletalkaccregwizz.PROTOCOL_NAME");
+ }
+
+ /**
+ * Implements the <code>AccountRegistrationWizard.getProtocolDescription
+ * </code> method. Returns the description of the protocol for this wizard.
+ * @return String
+ */
+ @Override
+ public String getProtocolDescription()
+ {
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getI18NString("plugin.googletalkaccregwizz.PROTOCOL_DESCRIPTION");
+ }
+
+ /**
+ * Returns an example string, which should indicate to the user how the
+ * user name should look like.
+ * @return an example string, which should indicate to the user how the
+ * user name should look like.
+ */
+ @Override
+ public String getUserNameExample()
+ {
+ return "Ex: johnsmith@gmail.com or johnsmith";
+ }
+
+ /**
+ * Returns the display label used for the sip id field.
+ * @return the sip id display label string.
+ */
+ @Override
+ protected String getUsernameLabel()
+ {
+ return GoogleTalkAccRegWizzActivator.getResources()
+ .getI18NString("plugin.googletalkaccregwizz.USERNAME");
+ }
+
+ /**
+ * Return the string for add existing account button.
+ * @return the string for add existing account button.
+ */
+ @Override
+ protected String getCreateAccountButtonLabel()
+ {
+ return GoogleTalkAccRegWizzActivator.getResources().getI18NString(
+ "plugin.googletalkaccregwizz.NEW_ACCOUNT_TITLE");
+ }
+
+ /**
+ * Return the string for create new account button.
+ * @return the string for create new account button.
+ */
+ @Override
+ protected String getCreateAccountLabel()
+ {
+ return GoogleTalkAccRegWizzActivator.getResources().getI18NString(
+ "plugin.googletalkaccregwizz.REGISTER_NEW_ACCOUNT_TEXT");
+ }
+
+ /**
+ * Returns the protocol name as listed in "ProtocolNames" or just the name
+ * of the service.
+ * @return the protocol name
+ */
+ @Override
+ public String getProtocol()
+ {
+ return PROTOCOL;
+ }
+
+ /**
+ * Returns the protocol icon path.
+ * @return the protocol icon path
+ */
+ @Override
+ public String getProtocolIconPath()
+ {
+ return "resources/images/protocol/googletalk";
+ }
+
+ /**
+ * Returns the account icon path.
+ * @return the account icon path
+ */
+ @Override
+ public String getAccountIconPath()
+ {
+ return "resources/images/protocol/googletalk/logo32x32.png";
+ }
+
+ /**
+ * Opens a browser on the sign up page.
+ */
+ @Override
+ public void webSignup()
+ {
+ GoogleTalkAccRegWizzActivator.getBrowserLauncher()
+ .openURL("https://www.google.com/accounts/NewAccount");
+ }
+
+ /**
+ * Returns <code>true</code> if the web sign up is supported by the current
+ * implementation, <code>false</code> - otherwise.
+ * @return <code>true</code> if the web sign up is supported by the current
+ * implementation, <code>false</code> - otherwise
+ */
+ @Override
+ public boolean isWebSignupSupported()
+ {
+ return true;
+ }
+
+ /**
+ * Returns an instance of <tt>CreateAccountService</tt> through which the
+ * user could create an account. This method is meant to be implemented by
+ * specific protocol provider wizards.
+ * @return an instance of <tt>CreateAccountService</tt>
+ */
+ @Override
+ protected JabberAccountCreationFormService getCreateAccountService()
+ {
+ return null;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccRegWizzActivator.java
index c50178c..7340901 100644
--- a/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccRegWizzActivator.java
+++ b/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccRegWizzActivator.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,154 +15,154 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.iptelaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.resources.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.resources.*;
-import org.osgi.framework.*;
-
-/**
- * Registers the <tt>GoogleTalkAccountRegistrationWizard</tt> in the UI Service.
- *
- * @author Lubomir Marinov
- */
-public class IptelAccRegWizzActivator
- extends AbstractServiceDependentActivator
-{
- /**
- * OSGi bundle context.
- */
- public static BundleContext bundleContext;
-
- /**
- * The <tt>Logger</tt> used by the <tt>IptelAccRegWizzActivator</tt> class
- * and its instances for logging output.
- */
- private static final Logger logger
- = Logger.getLogger(IptelAccRegWizzActivator.class);
-
- private static BrowserLauncherService browserLauncherService;
-
- private static ResourceManagementService resourcesService;
-
- private static UIService uiService;
-
- /**
- * Starts this bundle.
- */
- @Override
- public void start(Object dependentService)
- {
- uiService = (UIService)dependentService;
-
- IptelAccountRegistrationWizard wizard
- = new IptelAccountRegistrationWizard(uiService
- .getAccountRegWizardContainer());
-
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
- containerFilter.put(
- ProtocolProviderFactory.PROTOCOL,
- IptelAccountRegistrationWizard.PROTOCOL);
-
- bundleContext.registerService(
- AccountRegistrationWizard.class.getName(),
- wizard,
- containerFilter);
- }
-
- /**
- * The dependent class. We are waiting for the ui service.
- * @return the ui service class.
- */
- @Override
- public Class<?> getDependentServiceClass()
- {
- return UIService.class;
- }
-
- /**
- * The bundle context to use.
- * @param context the context to set.
- */
- @Override
- public void setBundleContext(BundleContext context)
- {
- bundleContext = context;
- }
-
- public void stop(BundleContext bundleContext) throws Exception {}
-
- /**
- * Returns the <tt>ProtocolProviderFactory</tt> for the IP Tel protocol.
- *
- * @return the <tt>ProtocolProviderFactory</tt> for the IP Tel protocol
- */
- public static ProtocolProviderFactory getIptelProtocolProviderFactory()
- {
- ServiceReference[] serRefs = null;
-
- String osgiFilter = "("
- + ProtocolProviderFactory.PROTOCOL
- + "=" + ProtocolNames.SIP + ")";
-
- try
- {
- serRefs = bundleContext.getServiceReferences(
- ProtocolProviderFactory.class.getName(), osgiFilter);
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error("IptelAccRegWizzActivator : " + ex);
- }
-
- return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
- }
-
- /**
- * Returns the <tt>UIService</tt>.
- *
- * @return the <tt>UIService</tt>
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-
- /**
- * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context.
- * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context
- */
- public static BrowserLauncherService getBrowserLauncher()
- {
- if (browserLauncherService == null)
- {
- browserLauncherService
- = (BrowserLauncherService) bundleContext.getService(
- bundleContext.getServiceReference(
- BrowserLauncherService.class.getName()));
- }
- return browserLauncherService;
- }
-
- /**
- * Returns the service giving access to resources.
- * @return the service giving access to resources
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService = ResourceManagementServiceUtils
- .getService(IptelAccRegWizzActivator.bundleContext);
- return resourcesService;
- }
-}
+package net.java.sip.communicator.plugin.iptelaccregwizz;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.browserlauncher.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.service.resources.*;
+import net.java.sip.communicator.util.*;
+
+import org.jitsi.service.resources.*;
+import org.osgi.framework.*;
+
+/**
+ * Registers the <tt>GoogleTalkAccountRegistrationWizard</tt> in the UI Service.
+ *
+ * @author Lubomir Marinov
+ */
+public class IptelAccRegWizzActivator
+ extends AbstractServiceDependentActivator
+{
+ /**
+ * OSGi bundle context.
+ */
+ public static BundleContext bundleContext;
+
+ /**
+ * The <tt>Logger</tt> used by the <tt>IptelAccRegWizzActivator</tt> class
+ * and its instances for logging output.
+ */
+ private static final Logger logger
+ = Logger.getLogger(IptelAccRegWizzActivator.class);
+
+ private static BrowserLauncherService browserLauncherService;
+
+ private static ResourceManagementService resourcesService;
+
+ private static UIService uiService;
+
+ /**
+ * Starts this bundle.
+ */
+ @Override
+ public void start(Object dependentService)
+ {
+ uiService = (UIService)dependentService;
+
+ IptelAccountRegistrationWizard wizard
+ = new IptelAccountRegistrationWizard(uiService
+ .getAccountRegWizardContainer());
+
+ Hashtable<String, String> containerFilter
+ = new Hashtable<String, String>();
+ containerFilter.put(
+ ProtocolProviderFactory.PROTOCOL,
+ IptelAccountRegistrationWizard.PROTOCOL);
+
+ bundleContext.registerService(
+ AccountRegistrationWizard.class.getName(),
+ wizard,
+ containerFilter);
+ }
+
+ /**
+ * The dependent class. We are waiting for the ui service.
+ * @return the ui service class.
+ */
+ @Override
+ public Class<?> getDependentServiceClass()
+ {
+ return UIService.class;
+ }
+
+ /**
+ * The bundle context to use.
+ * @param context the context to set.
+ */
+ @Override
+ public void setBundleContext(BundleContext context)
+ {
+ bundleContext = context;
+ }
+
+ public void stop(BundleContext bundleContext) throws Exception {}
+
+ /**
+ * Returns the <tt>ProtocolProviderFactory</tt> for the IP Tel protocol.
+ *
+ * @return the <tt>ProtocolProviderFactory</tt> for the IP Tel protocol
+ */
+ public static ProtocolProviderFactory getIptelProtocolProviderFactory()
+ {
+ ServiceReference[] serRefs = null;
+
+ String osgiFilter = "("
+ + ProtocolProviderFactory.PROTOCOL
+ + "=" + ProtocolNames.SIP + ")";
+
+ try
+ {
+ serRefs = bundleContext.getServiceReferences(
+ ProtocolProviderFactory.class.getName(), osgiFilter);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ logger.error("IptelAccRegWizzActivator : " + ex);
+ }
+
+ return (ProtocolProviderFactory) bundleContext.getService(serRefs[0]);
+ }
+
+ /**
+ * Returns the <tt>UIService</tt>.
+ *
+ * @return the <tt>UIService</tt>
+ */
+ public static UIService getUIService()
+ {
+ return uiService;
+ }
+
+ /**
+ * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
+ * context.
+ * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
+ * context
+ */
+ public static BrowserLauncherService getBrowserLauncher()
+ {
+ if (browserLauncherService == null)
+ {
+ browserLauncherService
+ = (BrowserLauncherService) bundleContext.getService(
+ bundleContext.getServiceReference(
+ BrowserLauncherService.class.getName()));
+ }
+ return browserLauncherService;
+ }
+
+ /**
+ * Returns the service giving access to resources.
+ * @return the service giving access to resources
+ */
+ public static ResourceManagementService getResources()
+ {
+ if (resourcesService == null)
+ resourcesService = ResourceManagementServiceUtils
+ .getService(IptelAccRegWizzActivator.bundleContext);
+ return resourcesService;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccountRegistrationWizard.java
index 699496c..38b7a0a 100644
--- a/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/iptelaccregwizz/IptelAccountRegistrationWizard.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,205 +15,205 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.iptelaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.plugin.sipaccregwizz.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.sip.*;
-
-/**
- * The <tt>IptelAccountRegistrationWizard</tt> is an implementation of the
- * <tt>AccountRegistrationWizard</tt> for the SIP protocol. It should allow
- * the user to create and configure a new SIP account.
- *
- * @author Yana Stamcheva
- */
-public class IptelAccountRegistrationWizard
- extends SIPAccountRegistrationWizard
-{
- /**
- * A constant pointing to the IP Tel protocol logo image.
- */
- private static final String PROTOCOL_ICON
- = "service.protocol.iptel.IPTEL_16x16";
-
- /**
- * A constant pointing to the IP Tel protocol wizard page image.
- */
- private static final String PAGE_IMAGE
- = "service.protocol.iptel.IPTEL_64x64";
-
- /**
- * The protocol name.
- */
- public static final String PROTOCOL = "iptel.org";
-
- /**
- * Creates an instance of <tt>IptelAccountRegistrationWizard</tt>.
- * @param wizardContainer the wizard container
- */
- public IptelAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- super(wizardContainer);
- }
-
- /**
- * Returns the set of pages contained in this wizard.
- * @return Iterator
- */
- @Override
- public Iterator<WizardPage> getPages()
- {
- SIPAccountRegistration reg = new SIPAccountRegistration();
-
- setPredefinedProperties(reg);
-
- return getPages(reg);
- }
-
- /**
- * Returns a simple account registration form that would be the first form
- * shown to the user. Only if the user needs more settings she'll choose
- * to open the advanced wizard, consisted by all pages.
- *
- * @param isCreateAccount indicates if the simple form should be opened as
- * a create account form or as a login form
- * @return a simple account registration form
- */
- @Override
- public Object getSimpleForm(boolean isCreateAccount)
- {
- SIPAccountRegistration reg = new SIPAccountRegistration();
-
- setPredefinedProperties(reg);
-
- return getSimpleForm(reg, isCreateAccount);
- }
-
- /**
- * Sets all iptel specific properties.
- *
- * @param reg the registration object
- */
- private void setPredefinedProperties(SIPAccountRegistration reg)
- {
- reg.setDefaultDomain("iptel.org");
- reg.setPreferredTransport("TCP");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * Returns the icon to be used for this wizard.
- * @return byte[]
- */
- @Override
- public byte[] getIcon()
- {
- return IptelAccRegWizzActivator.getResources()
- .getImageInBytes(PROTOCOL_ICON);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
- * Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- @Override
- public byte[] getPageImage()
- {
- return IptelAccRegWizzActivator.getResources()
- .getImageInBytes(PAGE_IMAGE);
- }
-
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method. Returns the protocol name for this wizard.
- * @return String
- */
- @Override
- public String getProtocolName()
- {
- return Resources.getString(
- "plugin.iptelaccregwizz.PROTOCOL_NAME");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code> method. Returns the description of the protocol for this wizard.
- * @return String
- */
- @Override
- public String getProtocolDescription()
- {
- return Resources.getString(
- "plugin.iptelaccregwizz.PROTOCOL_DESCRIPTION");
- }
-
- /**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
- */
- @Override
- public String getUserNameExample()
- {
- return "Ex: myusername or myusername@iptel.org";
- }
-
- /**
- * Returns the protocol name as listed in "ProtocolNames" or just the name
- * of the service.
- * @return the protocol name
- */
- @Override
- public String getProtocol()
- {
- return PROTOCOL;
- }
-
- /**
- * Returns the protocol icon path.
- * @return the protocol icon path
- */
- @Override
- public String getProtocolIconPath()
- {
- return "resources/images/protocol/iptel";
- }
-
- /**
- * Returns the account icon path.
- * @return the account icon path
- */
- @Override
- public String getAccountIconPath()
- {
- return "resources/images/protocol/iptel/sip32x32.png";
- }
-
- /**
- * Opens the browser on the page sign up
- */
- @Override
- public void webSignup()
- {
- IptelAccRegWizzActivator.getBrowserLauncher()
- .openURL("https://serweb.iptel.org/user/reg/index.php");
- }
-
- /**
- * Returns the name of the web sign up link.
- * @return the name of the web sign up link
- */
- @Override
- public String getWebSignupLinkName()
- {
- return IptelAccRegWizzActivator.getResources().getI18NString(
- "plugin.iptelaccregwizz.NEW_ACCOUNT_TITLE");
- }
-}
+package net.java.sip.communicator.plugin.iptelaccregwizz;
+
+import java.util.*;
+
+import net.java.sip.communicator.plugin.sipaccregwizz.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.sip.*;
+
+/**
+ * The <tt>IptelAccountRegistrationWizard</tt> is an implementation of the
+ * <tt>AccountRegistrationWizard</tt> for the SIP protocol. It should allow
+ * the user to create and configure a new SIP account.
+ *
+ * @author Yana Stamcheva
+ */
+public class IptelAccountRegistrationWizard
+ extends SIPAccountRegistrationWizard
+{
+ /**
+ * A constant pointing to the IP Tel protocol logo image.
+ */
+ private static final String PROTOCOL_ICON
+ = "service.protocol.iptel.IPTEL_16x16";
+
+ /**
+ * A constant pointing to the IP Tel protocol wizard page image.
+ */
+ private static final String PAGE_IMAGE
+ = "service.protocol.iptel.IPTEL_64x64";
+
+ /**
+ * The protocol name.
+ */
+ public static final String PROTOCOL = "iptel.org";
+
+ /**
+ * Creates an instance of <tt>IptelAccountRegistrationWizard</tt>.
+ * @param wizardContainer the wizard container
+ */
+ public IptelAccountRegistrationWizard(WizardContainer wizardContainer)
+ {
+ super(wizardContainer);
+ }
+
+ /**
+ * Returns the set of pages contained in this wizard.
+ * @return Iterator
+ */
+ @Override
+ public Iterator<WizardPage> getPages()
+ {
+ SIPAccountRegistration reg = new SIPAccountRegistration();
+
+ setPredefinedProperties(reg);
+
+ return getPages(reg);
+ }
+
+ /**
+ * Returns a simple account registration form that would be the first form
+ * shown to the user. Only if the user needs more settings she'll choose
+ * to open the advanced wizard, consisted by all pages.
+ *
+ * @param isCreateAccount indicates if the simple form should be opened as
+ * a create account form or as a login form
+ * @return a simple account registration form
+ */
+ @Override
+ public Object getSimpleForm(boolean isCreateAccount)
+ {
+ SIPAccountRegistration reg = new SIPAccountRegistration();
+
+ setPredefinedProperties(reg);
+
+ return getSimpleForm(reg, isCreateAccount);
+ }
+
+ /**
+ * Sets all iptel specific properties.
+ *
+ * @param reg the registration object
+ */
+ private void setPredefinedProperties(SIPAccountRegistration reg)
+ {
+ reg.setDefaultDomain("iptel.org");
+ reg.setPreferredTransport("TCP");
+ }
+
+ /**
+ * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
+ * Returns the icon to be used for this wizard.
+ * @return byte[]
+ */
+ @Override
+ public byte[] getIcon()
+ {
+ return IptelAccRegWizzActivator.getResources()
+ .getImageInBytes(PROTOCOL_ICON);
+ }
+
+ /**
+ * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
+ * Returns the image used to decorate the wizard page
+ *
+ * @return byte[] the image used to decorate the wizard page
+ */
+ @Override
+ public byte[] getPageImage()
+ {
+ return IptelAccRegWizzActivator.getResources()
+ .getImageInBytes(PAGE_IMAGE);
+ }
+
+
+ /**
+ * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
+ * method. Returns the protocol name for this wizard.
+ * @return String
+ */
+ @Override
+ public String getProtocolName()
+ {
+ return Resources.getString(
+ "plugin.iptelaccregwizz.PROTOCOL_NAME");
+ }
+
+ /**
+ * Implements the <code>AccountRegistrationWizard.getProtocolDescription
+ * </code> method. Returns the description of the protocol for this wizard.
+ * @return String
+ */
+ @Override
+ public String getProtocolDescription()
+ {
+ return Resources.getString(
+ "plugin.iptelaccregwizz.PROTOCOL_DESCRIPTION");
+ }
+
+ /**
+ * Returns an example string, which should indicate to the user how the
+ * user name should look like.
+ * @return an example string, which should indicate to the user how the
+ * user name should look like.
+ */
+ @Override
+ public String getUserNameExample()
+ {
+ return "Ex: myusername or myusername@iptel.org";
+ }
+
+ /**
+ * Returns the protocol name as listed in "ProtocolNames" or just the name
+ * of the service.
+ * @return the protocol name
+ */
+ @Override
+ public String getProtocol()
+ {
+ return PROTOCOL;
+ }
+
+ /**
+ * Returns the protocol icon path.
+ * @return the protocol icon path
+ */
+ @Override
+ public String getProtocolIconPath()
+ {
+ return "resources/images/protocol/iptel";
+ }
+
+ /**
+ * Returns the account icon path.
+ * @return the account icon path
+ */
+ @Override
+ public String getAccountIconPath()
+ {
+ return "resources/images/protocol/iptel/sip32x32.png";
+ }
+
+ /**
+ * Opens the browser on the page sign up
+ */
+ @Override
+ public void webSignup()
+ {
+ IptelAccRegWizzActivator.getBrowserLauncher()
+ .openURL("https://serweb.iptel.org/user/reg/index.php");
+ }
+
+ /**
+ * Returns the name of the web sign up link.
+ * @return the name of the web sign up link
+ */
+ @Override
+ public String getWebSignupLinkName()
+ {
+ return IptelAccRegWizzActivator.getResources().getI18NString(
+ "plugin.iptelaccregwizz.NEW_ACCOUNT_TITLE");
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java
index f062058..962aeb1 100644
--- a/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java
+++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/IrcAccountRegistrationWizard.java
@@ -358,8 +358,7 @@ public class IrcAccountRegistrationWizard
ServiceReference<ProtocolProviderService> serRef = providerFactory
.getProviderForAccount(accountID);
- protocolProvider = (ProtocolProviderService)
- IrcAccRegWizzActivator.bundleContext
+ protocolProvider = IrcAccRegWizzActivator.bundleContext
.getService(serRef);
}
catch (IllegalStateException exc)
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java
index 0467033..c046348 100644
--- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/AccountPanel.java
@@ -140,7 +140,7 @@ public class AccountPanel
userIDPassPanel.setBorder(
BorderFactory.createTitledBorder(
Resources.getString(
- "plugin.sipaccregwizz.USERNAME_AND_PASSWORD")));
+ "plugin.jabberaccregwizz.USERNAME_AND_PASSWORD")));
JPanel southPanel = new TransparentPanel(new BorderLayout());
southPanel.add(rememberPassBox, BorderLayout.WEST);
@@ -564,8 +564,7 @@ public class AccountPanel
OperationSetChangePassword.class).supportsPasswordChange())
{
changePasswordMessagePane.setText(Resources.getString(
- "plugin.jabberaccregwizz."
- + "SERVER_NOT_SUPPORT_PASSWORD_CHANGE"));
+ "plugin.jabberaccregwizz.SERVER_NOT_SUPPORT_PASSWORD_CHANGE"));
}
else
{
@@ -683,8 +682,7 @@ public class AccountPanel
getAccountID().getAccountAddress(),
ex);
displayPopupError(Resources.getString(
- "plugin.jabberaccregwizz."
- + "PASSWORD_NOT_STORED"));
+ "plugin.jabberaccregwizz.PASSWORD_NOT_STORED"));
}
}
//now update the password field in AccountPanel,
@@ -705,8 +703,7 @@ public class AccountPanel
}
catch (OperationFailedException ex) {
displayPopupError(Resources.getString(
- "plugin.jabberaccregwizz."
- + "SERVER_NOT_SUPPORT_PASSWORD_CHANGE"));
+ "plugin.jabberaccregwizz.SERVER_NOT_SUPPORT_PASSWORD_CHANGE"));
}
}
}
diff --git a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountCreationForm.java b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountCreationForm.java
index 6288821..3e816cf 100644
--- a/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountCreationForm.java
+++ b/src/net/java/sip/communicator/plugin/jabberaccregwizz/JabberAccountCreationForm.java
@@ -93,7 +93,7 @@ public class JabberAccountCreationForm
private JButton chooseButton = new JButton();
// Smack objects
- private XMPPConnection xmppConnection = null;
+ private Connection xmppConnection = null;
private AccountManager accountManager = null;
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingChooser.java b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingChooser.java
index bd8ff0d..12ba3e2 100644
--- a/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingChooser.java
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/chooser/BindingChooser.java
@@ -24,6 +24,7 @@ import java.util.*;
import javax.swing.*;
import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.plugin.keybindingchooser.KeybindingChooserActivator;
import net.java.sip.communicator.service.keybindings.*;
/**
@@ -51,36 +52,12 @@ public class BindingChooser
// can be selected
private BindingEntry selectedEntry = null; // None selected when null
- private String selectedText = "Press shortcut...";
-
/**
* Keybinding set.
*/
private KeybindingSet set = null;
/**
- * Displays a dialog allowing the user to redefine the keystroke component
- * of key bindings. The top has light blue labels describing the fields and
- * the bottom provides an 'OK' and 'Cancel' option. This uses the default
- * color scheme and indent style. If no entries are selected then the enter
- * key is equivalent to pressing 'OK' and escape is the same as 'Cancel'.
- *
- * @param parent frame to which to apply modal property and center within
- * (centers within screen if null)
- * @param bindings initial mapping of keystrokes to their actions
- * @return redefined mapping of keystrokes to their actions, null if cancel
- * is pressed
- */
- public static LinkedHashMap<KeyStroke, String> showDialog(Component parent,
- Map<KeyStroke, String> bindings)
- {
- BindingChooser display = new BindingChooser();
- display.putAllBindings(bindings);
- return showDialog(parent, display, "Key Bindings", true, display
- .makeAdaptor());
- }
-
- /**
* Adds a collection of new key binding mappings to the end of the listing.
* If any shortcuts are already contained then the previous entries are
* replaced (not triggering the onUpdate method). Disabled shortcuts trigger
@@ -269,22 +246,6 @@ public class BindingChooser
}
/**
- * Sets the message of the selected shortcut field when awaiting user input.
- * By default this is "Press shortcut...".
- *
- * @param message prompt for user input
- */
- public void setSelectedText(String message)
- {
- if (this.selectedEntry != null)
- {
- this.selectedEntry.getField(BindingEntry.Field.SHORTCUT).setText(
- message);
- }
- this.selectedText = message;
- }
-
- /**
* Returns if a binding is currently awaiting input or not.
*
* @return true if a binding is awaiting input, false otherwise
@@ -344,7 +305,8 @@ public class BindingChooser
onUpdate(getBindingIndex(this.selectedEntry), this.selectedEntry,
false);
this.selectedEntry.getField(BindingEntry.Field.SHORTCUT).setText(
- " " + this.selectedText);
+ KeybindingChooserActivator.getResources().getI18NString(
+ "plugin.keybindings.WAITING"));
}
}
diff --git a/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutDialog.java b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutDialog.java
index aab01c5..1e9f83f 100644
--- a/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutDialog.java
+++ b/src/net/java/sip/communicator/plugin/keybindingchooser/globalchooser/GlobalShortcutDialog.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,489 +15,489 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.keybindingchooser.globalchooser;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.util.*;
-import java.util.List;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.plugin.keybindingchooser.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-import net.java.sip.communicator.plugin.desktoputil.plaf.*;
-import net.java.sip.communicator.service.globalshortcut.*;
-import net.java.sip.communicator.util.skin.*;
-
-import org.jitsi.util.*;
-// disambiguation
-
-/**
- * Dialog to choose the shortcut.
- *
- * @author Sebastien Vincent
- */
-public class GlobalShortcutDialog
- extends SIPCommDialog
- implements ActionListener,
- GlobalShortcutListener
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * Text displayed when no shortcut is configured.
- */
- private static final String PRESS_TO_SETUP_SHORTCUT =
- Resources.getString("plugin.keybindings.globalchooser.PRESS_BTN");
-
- /**
- * The global shortcut entry.
- */
- private final GlobalShortcutEntry entry;
-
- /**
- * OK button.
- */
- private final JButton btnOK = new JButton(
- Resources.getString("service.gui.OK"));
-
- /**
- * Cancel button.
- */
- private final JButton btnCancel = new JButton(
- Resources.getString("service.gui.CANCEL"));
-
- /**
- * Enable or not special key for shortcut.
- */
- private final JCheckBox specialBox = new SIPCommCheckBox(
- Resources.getString("plugin.keybindings.globalchooser.ENABLE_SPECIAL"));
-
- /**
- * First shortcut field.
- */
- private final ShortcutField fldShortcut = new ShortcutField(
- PRESS_TO_SETUP_SHORTCUT);
-
- /**
- * Secondary shortcut field.
- */
- private final ShortcutField fldShortcut2 = new ShortcutField(
- PRESS_TO_SETUP_SHORTCUT);
-
- /**
- * Return code.
- */
- private int retCode = 0;
-
- /**
- * Constructor.
- *
- * @param dialog root dialog
- * @param entry the global shortcut entry
- */
- public GlobalShortcutDialog(Dialog dialog, GlobalShortcutEntry entry)
- {
- super(dialog);
-
- setModal(true);
- setTitle("Global shortcut: " + entry.getAction());
- this.entry = entry;
- init();
- }
-
- /**
- * Initialize components.
- */
- private void init()
- {
- TransparentPanel mainPanel = new TransparentPanel(new BorderLayout());
- JPanel btnPanel = new TransparentPanel(
- new FlowLayout(FlowLayout.RIGHT));
- JPanel shortcutPanel = new TransparentPanel(
- new GridLayout(0, 2, 0, 10));
-
- btnOK.addActionListener(this);
- btnCancel.addActionListener(this);
-
- KeyAdapter keyAdapter = new KeyAdapter()
- {
- private KeyEvent buffer = null;
-
- @Override
- public void keyPressed(KeyEvent event)
- {
- if(event.getKeyCode() == KeyEvent.VK_ESCAPE)
- {
- SIPCommTextField field =
- (SIPCommTextField)event.getSource();
-
- AWTKeyStroke ks = null;
-
- if(field == fldShortcut)
- {
- ks = entry.getShortcut();
- }
- else if(field == fldShortcut2)
- {
- ks = entry.getShortcut2();
- }
-
- if(ks == null)
- field.setText(PRESS_TO_SETUP_SHORTCUT);
- else
- {
-
- if(ks.getModifiers() ==
- GlobalShortcutService.SPECIAL_KEY_MODIFIERS)
- {
- field.setText("Special");
- }
- else
- {
- field.setText(GlobalShortcutEntry.getShortcutText(
- entry.getShortcut()));
- }
- }
- btnOK.requestFocusInWindow();
- return;
- }
-
- if(event.getKeyCode() == 0)
- return;
-
- // Reports KEY_PRESSED events on release to support modifiers
- this.buffer = event;
- }
-
- @Override
- public void keyReleased(KeyEvent event)
- {
- if (buffer != null)
- {
- SIPCommTextField field =
- (SIPCommTextField)event.getSource();
- AWTKeyStroke input = KeyStroke.getKeyStrokeForEvent(buffer);
- buffer = null;
-
- GlobalShortcutEntry en = entry;
- List<AWTKeyStroke> kss = new ArrayList<AWTKeyStroke>();
-
- if(field == fldShortcut)
- {
- kss.add(input);
- kss.add(en.getShortcut2());
- }
- else if(field == fldShortcut2)
- {
- kss.add(en.getShortcut());
- kss.add(input);
- }
-
- en.setShortcuts(kss);
- en.setEditShortcut1(false);
- en.setEditShortcut2(false);
- field.setText(GlobalShortcutEntry.getShortcutText(
- input));
- btnOK.requestFocus();
- }
- }
- };
-
- AWTKeyStroke ks = entry.getShortcut();
- AWTKeyStroke ks2 = entry.getShortcut2();
-
- if(ks != null)
- {
- if(ks.getModifiers() != GlobalShortcutService.SPECIAL_KEY_MODIFIERS)
- {
- fldShortcut.setText(GlobalShortcutEntry.getShortcutText(ks));
- }
- else
- {
- fldShortcut.setText("Special");
- }
- }
-
- if(ks2 != null)
- {
-
- if(ks2.getModifiers() != GlobalShortcutService.SPECIAL_KEY_MODIFIERS)
- {
- fldShortcut2.setText(GlobalShortcutEntry.getShortcutText(ks2));
- }
- else
- {
- fldShortcut2.setText("Special");
- }
- }
-
- fldShortcut.addKeyListener(keyAdapter);
- fldShortcut2.addKeyListener(keyAdapter);
-
- specialBox.addItemListener(new ItemListener()
- {
- public void itemStateChanged(ItemEvent evt)
- {
- KeybindingChooserActivator.getGlobalShortcutService().
- setSpecialKeyDetection(
- (evt.getStateChange() == ItemEvent.SELECTED),
- GlobalShortcutDialog.this);
- }
- });
-
- shortcutPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10,
- 10));
- shortcutPanel.add(new JLabel("Primary shortcut"));
- shortcutPanel.add(fldShortcut);
- shortcutPanel.add(new JLabel("Secondary shortcut"));
- shortcutPanel.add(fldShortcut2);
-
- if(OSUtils.IS_WINDOWS)
- {
- shortcutPanel.add(new TransparentPanel());
- shortcutPanel.add(specialBox);
- }
-
- mainPanel.add(shortcutPanel, BorderLayout.CENTER);
-
- btnPanel.add(btnOK);
- btnPanel.add(btnCancel);
- mainPanel.add(btnPanel, BorderLayout.SOUTH);
-
- btnOK.requestFocus();
-
- getContentPane().add(mainPanel);
- pack();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void close(boolean isEscaped)
- {
- super.close(isEscaped);
- KeybindingChooserActivator.getGlobalShortcutService().
- setSpecialKeyDetection(false, this);
- }
-
- /**
- * Show the dialog and returns if the user has modified something (create
- * or modify entry).
- *
- * @return true if the user has modified something (create
- * or modify entry), false otherwise.
- */
- public int showDialog()
- {
- setVisible(true);
-
- // as the dialog is modal, wait for OK/Cancel button retCode
- setVisible(false);
- return retCode;
- }
-
- /**
- * {@inheritDoc}
- */
- public void actionPerformed(ActionEvent evt)
- {
- Object obj = evt.getSource();
-
- if(obj == btnOK)
- {
- retCode = 1;
- dispose();
- }
- else if(obj == btnCancel)
- {
- retCode = 0;
- dispose();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public void shortcutReceived(GlobalShortcutEvent evt)
- {
- AWTKeyStroke ksr = evt.getKeyStroke();
-
- if(ksr.getModifiers() != GlobalShortcutService.SPECIAL_KEY_MODIFIERS)
- {
- return;
- }
-
- if(!fldShortcut.isFocusOwner() && !fldShortcut2.isFocusOwner())
- return;
-
- List<AWTKeyStroke> kss = new ArrayList<AWTKeyStroke>();
-
- if(fldShortcut.isFocusOwner())
- {
- kss.add(ksr);
- kss.add(entry.getShortcut2());
- fldShortcut.setText("Special");
- }
- else if(fldShortcut2.isFocusOwner())
- {
- kss.add(entry.getShortcut());
- kss.add(ksr);
- fldShortcut2.setText("Special");
- }
- entry.setShortcuts(kss);
- KeybindingChooserActivator.getGlobalShortcutService().
- setSpecialKeyDetection(false, this);
- }
-
- /**
- * Clear the text field.
- *
- * @param ui <tt>TextFieldUI</tt> to clear
- */
- public void clearTextField(SIPCommTextFieldUI ui)
- {
- List<AWTKeyStroke> kss = new ArrayList<AWTKeyStroke>();
-
- if(ui == fldShortcut.getUI())
- {
- kss.add(null);
- kss.add(entry.getShortcut2());
- entry.setShortcuts(kss);
- btnOK.requestFocusInWindow();
- }
- else if(ui == fldShortcut2.getUI())
- {
- kss.add(entry.getShortcut());
- kss.add(null);
- entry.setShortcuts(kss);
- btnOK.requestFocusInWindow();
- }
- }
-
- /**
- * A custom call field.
- */
- private class ShortcutField
- extends SIPCommTextField
- implements Skinnable
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * The text field ui.
- */
- private ShortcutFieldUI textFieldUI;
-
- /**
- * Creates an instance of the <tt>CallField</tt>.
- *
- * @param text
- */
- public ShortcutField(String text)
- {
- super(text);
-
- textFieldUI = new ShortcutFieldUI();
- textFieldUI.setDeleteButtonEnabled(true);
-
- this.setPreferredSize(new Dimension(200, 23));
- this.setUI(textFieldUI);
- this.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
- this.setOpaque(false);
-
- this.setDragEnabled(true);
-
- loadSkin();
- }
-
- /**
- * Reloads text field UI defs.
- */
- public void loadSkin()
- {
- textFieldUI.loadSkin();
- }
- }
-
- /**
- * A custom text field UI.
- */
- public class ShortcutFieldUI
- extends SIPCommTextFieldUI
- implements Skinnable
- {
- /**
- * Creates a <tt>SIPCommTextFieldUI</tt>.
- */
- public ShortcutFieldUI()
- {
- loadSkin();
- }
-
- /**
- * Adds the custom mouse listeners defined in this class to the installed
- * listeners.
- */
- @Override
- protected void installListeners()
- {
- super.installListeners();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void updateDeleteIcon(MouseEvent evt)
- {
- super.updateDeleteIcon(evt);
-
- Rectangle deleteRect = getDeleteButtonRect();
- if(deleteRect.contains(evt.getX(), evt.getY()) &&
- evt.getID() == MouseEvent.MOUSE_CLICKED)
- {
- clearTextField(this);
- }
- }
-
- /**
- * Implements parent paintSafely method and enables antialiasing.
- * @param g the <tt>Graphics</tt> object that notified us
- */
- @Override
- protected void paintSafely(Graphics g)
- {
- customPaintBackground(g);
- super.paintSafely(g);
- }
-
- /**
- * Paints the background of the associated component.
- * @param g the <tt>Graphics</tt> object used for painting
- */
- @Override
- protected void customPaintBackground(Graphics g)
- {
- Graphics2D g2 = (Graphics2D) g.create();
-
- try
- {
- AntialiasingManager.activateAntialiasing(g2);
- super.customPaintBackground(g2);
- }
- finally
- {
- g2.dispose();
- }
- }
- }
-}
+package net.java.sip.communicator.plugin.keybindingchooser.globalchooser;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.*;
+import java.util.List;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.plugin.keybindingchooser.*;
+import net.java.sip.communicator.plugin.desktoputil.*;
+import net.java.sip.communicator.plugin.desktoputil.plaf.*;
+import net.java.sip.communicator.service.globalshortcut.*;
+import net.java.sip.communicator.util.skin.*;
+
+import org.jitsi.util.*;
+// disambiguation
+
+/**
+ * Dialog to choose the shortcut.
+ *
+ * @author Sebastien Vincent
+ */
+public class GlobalShortcutDialog
+ extends SIPCommDialog
+ implements ActionListener,
+ GlobalShortcutListener
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * Text displayed when no shortcut is configured.
+ */
+ private static final String PRESS_TO_SETUP_SHORTCUT =
+ Resources.getString("plugin.keybindings.globalchooser.PRESS_BTN");
+
+ /**
+ * The global shortcut entry.
+ */
+ private final GlobalShortcutEntry entry;
+
+ /**
+ * OK button.
+ */
+ private final JButton btnOK = new JButton(
+ Resources.getString("service.gui.OK"));
+
+ /**
+ * Cancel button.
+ */
+ private final JButton btnCancel = new JButton(
+ Resources.getString("service.gui.CANCEL"));
+
+ /**
+ * Enable or not special key for shortcut.
+ */
+ private final JCheckBox specialBox = new SIPCommCheckBox(
+ Resources.getString("plugin.keybindings.globalchooser.ENABLE_SPECIAL"));
+
+ /**
+ * First shortcut field.
+ */
+ private final ShortcutField fldShortcut = new ShortcutField(
+ PRESS_TO_SETUP_SHORTCUT);
+
+ /**
+ * Secondary shortcut field.
+ */
+ private final ShortcutField fldShortcut2 = new ShortcutField(
+ PRESS_TO_SETUP_SHORTCUT);
+
+ /**
+ * Return code.
+ */
+ private int retCode = 0;
+
+ /**
+ * Constructor.
+ *
+ * @param dialog root dialog
+ * @param entry the global shortcut entry
+ */
+ public GlobalShortcutDialog(Dialog dialog, GlobalShortcutEntry entry)
+ {
+ super(dialog);
+
+ setModal(true);
+ setTitle("Global shortcut: " + entry.getAction());
+ this.entry = entry;
+ init();
+ }
+
+ /**
+ * Initialize components.
+ */
+ private void init()
+ {
+ TransparentPanel mainPanel = new TransparentPanel(new BorderLayout());
+ JPanel btnPanel = new TransparentPanel(
+ new FlowLayout(FlowLayout.RIGHT));
+ JPanel shortcutPanel = new TransparentPanel(
+ new GridLayout(0, 2, 0, 10));
+
+ btnOK.addActionListener(this);
+ btnCancel.addActionListener(this);
+
+ KeyAdapter keyAdapter = new KeyAdapter()
+ {
+ private KeyEvent buffer = null;
+
+ @Override
+ public void keyPressed(KeyEvent event)
+ {
+ if(event.getKeyCode() == KeyEvent.VK_ESCAPE)
+ {
+ SIPCommTextField field =
+ (SIPCommTextField)event.getSource();
+
+ AWTKeyStroke ks = null;
+
+ if(field == fldShortcut)
+ {
+ ks = entry.getShortcut();
+ }
+ else if(field == fldShortcut2)
+ {
+ ks = entry.getShortcut2();
+ }
+
+ if(ks == null)
+ field.setText(PRESS_TO_SETUP_SHORTCUT);
+ else
+ {
+
+ if(ks.getModifiers() ==
+ GlobalShortcutService.SPECIAL_KEY_MODIFIERS)
+ {
+ field.setText("Special");
+ }
+ else
+ {
+ field.setText(GlobalShortcutEntry.getShortcutText(
+ entry.getShortcut()));
+ }
+ }
+ btnOK.requestFocusInWindow();
+ return;
+ }
+
+ if(event.getKeyCode() == 0)
+ return;
+
+ // Reports KEY_PRESSED events on release to support modifiers
+ this.buffer = event;
+ }
+
+ @Override
+ public void keyReleased(KeyEvent event)
+ {
+ if (buffer != null)
+ {
+ SIPCommTextField field =
+ (SIPCommTextField)event.getSource();
+ AWTKeyStroke input = KeyStroke.getKeyStrokeForEvent(buffer);
+ buffer = null;
+
+ GlobalShortcutEntry en = entry;
+ List<AWTKeyStroke> kss = new ArrayList<AWTKeyStroke>();
+
+ if(field == fldShortcut)
+ {
+ kss.add(input);
+ kss.add(en.getShortcut2());
+ }
+ else if(field == fldShortcut2)
+ {
+ kss.add(en.getShortcut());
+ kss.add(input);
+ }
+
+ en.setShortcuts(kss);
+ en.setEditShortcut1(false);
+ en.setEditShortcut2(false);
+ field.setText(GlobalShortcutEntry.getShortcutText(
+ input));
+ btnOK.requestFocus();
+ }
+ }
+ };
+
+ AWTKeyStroke ks = entry.getShortcut();
+ AWTKeyStroke ks2 = entry.getShortcut2();
+
+ if(ks != null)
+ {
+ if(ks.getModifiers() != GlobalShortcutService.SPECIAL_KEY_MODIFIERS)
+ {
+ fldShortcut.setText(GlobalShortcutEntry.getShortcutText(ks));
+ }
+ else
+ {
+ fldShortcut.setText("Special");
+ }
+ }
+
+ if(ks2 != null)
+ {
+
+ if(ks2.getModifiers() != GlobalShortcutService.SPECIAL_KEY_MODIFIERS)
+ {
+ fldShortcut2.setText(GlobalShortcutEntry.getShortcutText(ks2));
+ }
+ else
+ {
+ fldShortcut2.setText("Special");
+ }
+ }
+
+ fldShortcut.addKeyListener(keyAdapter);
+ fldShortcut2.addKeyListener(keyAdapter);
+
+ specialBox.addItemListener(new ItemListener()
+ {
+ public void itemStateChanged(ItemEvent evt)
+ {
+ KeybindingChooserActivator.getGlobalShortcutService().
+ setSpecialKeyDetection(
+ (evt.getStateChange() == ItemEvent.SELECTED),
+ GlobalShortcutDialog.this);
+ }
+ });
+
+ shortcutPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10,
+ 10));
+ shortcutPanel.add(new JLabel("Primary shortcut"));
+ shortcutPanel.add(fldShortcut);
+ shortcutPanel.add(new JLabel("Secondary shortcut"));
+ shortcutPanel.add(fldShortcut2);
+
+ if(OSUtils.IS_WINDOWS)
+ {
+ shortcutPanel.add(new TransparentPanel());
+ shortcutPanel.add(specialBox);
+ }
+
+ mainPanel.add(shortcutPanel, BorderLayout.CENTER);
+
+ btnPanel.add(btnOK);
+ btnPanel.add(btnCancel);
+ mainPanel.add(btnPanel, BorderLayout.SOUTH);
+
+ btnOK.requestFocus();
+
+ getContentPane().add(mainPanel);
+ pack();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void close(boolean isEscaped)
+ {
+ super.close(isEscaped);
+ KeybindingChooserActivator.getGlobalShortcutService().
+ setSpecialKeyDetection(false, this);
+ }
+
+ /**
+ * Show the dialog and returns if the user has modified something (create
+ * or modify entry).
+ *
+ * @return true if the user has modified something (create
+ * or modify entry), false otherwise.
+ */
+ public int showDialog()
+ {
+ setVisible(true);
+
+ // as the dialog is modal, wait for OK/Cancel button retCode
+ setVisible(false);
+ return retCode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void actionPerformed(ActionEvent evt)
+ {
+ Object obj = evt.getSource();
+
+ if(obj == btnOK)
+ {
+ retCode = 1;
+ dispose();
+ }
+ else if(obj == btnCancel)
+ {
+ retCode = 0;
+ dispose();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void shortcutReceived(GlobalShortcutEvent evt)
+ {
+ AWTKeyStroke ksr = evt.getKeyStroke();
+
+ if(ksr.getModifiers() != GlobalShortcutService.SPECIAL_KEY_MODIFIERS)
+ {
+ return;
+ }
+
+ if(!fldShortcut.isFocusOwner() && !fldShortcut2.isFocusOwner())
+ return;
+
+ List<AWTKeyStroke> kss = new ArrayList<AWTKeyStroke>();
+
+ if(fldShortcut.isFocusOwner())
+ {
+ kss.add(ksr);
+ kss.add(entry.getShortcut2());
+ fldShortcut.setText("Special");
+ }
+ else if(fldShortcut2.isFocusOwner())
+ {
+ kss.add(entry.getShortcut());
+ kss.add(ksr);
+ fldShortcut2.setText("Special");
+ }
+ entry.setShortcuts(kss);
+ KeybindingChooserActivator.getGlobalShortcutService().
+ setSpecialKeyDetection(false, this);
+ }
+
+ /**
+ * Clear the text field.
+ *
+ * @param ui <tt>TextFieldUI</tt> to clear
+ */
+ public void clearTextField(SIPCommTextFieldUI ui)
+ {
+ List<AWTKeyStroke> kss = new ArrayList<AWTKeyStroke>();
+
+ if(ui == fldShortcut.getUI())
+ {
+ kss.add(null);
+ kss.add(entry.getShortcut2());
+ entry.setShortcuts(kss);
+ btnOK.requestFocusInWindow();
+ }
+ else if(ui == fldShortcut2.getUI())
+ {
+ kss.add(entry.getShortcut());
+ kss.add(null);
+ entry.setShortcuts(kss);
+ btnOK.requestFocusInWindow();
+ }
+ }
+
+ /**
+ * A custom call field.
+ */
+ private class ShortcutField
+ extends SIPCommTextField
+ implements Skinnable
+ {
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ /**
+ * The text field ui.
+ */
+ private ShortcutFieldUI textFieldUI;
+
+ /**
+ * Creates an instance of the <tt>CallField</tt>.
+ *
+ * @param text
+ */
+ public ShortcutField(String text)
+ {
+ super(text);
+
+ textFieldUI = new ShortcutFieldUI();
+ textFieldUI.setDeleteButtonEnabled(true);
+
+ this.setPreferredSize(new Dimension(200, 23));
+ this.setUI(textFieldUI);
+ this.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
+ this.setOpaque(false);
+
+ this.setDragEnabled(true);
+
+ loadSkin();
+ }
+
+ /**
+ * Reloads text field UI defs.
+ */
+ public void loadSkin()
+ {
+ textFieldUI.loadSkin();
+ }
+ }
+
+ /**
+ * A custom text field UI.
+ */
+ public class ShortcutFieldUI
+ extends SIPCommTextFieldUI
+ implements Skinnable
+ {
+ /**
+ * Creates a <tt>SIPCommTextFieldUI</tt>.
+ */
+ public ShortcutFieldUI()
+ {
+ loadSkin();
+ }
+
+ /**
+ * Adds the custom mouse listeners defined in this class to the installed
+ * listeners.
+ */
+ @Override
+ protected void installListeners()
+ {
+ super.installListeners();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void updateDeleteIcon(MouseEvent evt)
+ {
+ super.updateDeleteIcon(evt);
+
+ Rectangle deleteRect = getDeleteButtonRect();
+ if(deleteRect.contains(evt.getX(), evt.getY()) &&
+ evt.getID() == MouseEvent.MOUSE_CLICKED)
+ {
+ clearTextField(this);
+ }
+ }
+
+ /**
+ * Implements parent paintSafely method and enables antialiasing.
+ * @param g the <tt>Graphics</tt> object that notified us
+ */
+ @Override
+ protected void paintSafely(Graphics g)
+ {
+ customPaintBackground(g);
+ super.paintSafely(g);
+ }
+
+ /**
+ * Paints the background of the associated component.
+ * @param g the <tt>Graphics</tt> object used for painting
+ */
+ @Override
+ protected void customPaintBackground(Graphics g)
+ {
+ Graphics2D g2 = (Graphics2D) g.create();
+
+ try
+ {
+ AntialiasingManager.activateAntialiasing(g2);
+ super.customPaintBackground(g2);
+ }
+ finally
+ {
+ g2.dispose();
+ }
+ }
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java
index 264f830..51b3a67 100644
--- a/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java
+++ b/src/net/java/sip/communicator/plugin/msofficecomm/Messenger.java
@@ -28,7 +28,6 @@ import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.ServerStoredDetails.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.jabberconstants.*;
-import net.java.sip.communicator.service.protocol.yahooconstants.*;
import net.java.sip.communicator.util.*;
import org.jitsi.service.configuration.*;
@@ -168,18 +167,16 @@ public class Messenger
static
{
- String lib = "jmsofficecomm";
-
try
{
- System.loadLibrary(lib);
+ System.loadLibrary("jmsofficecomm");
}
catch (Throwable t)
{
- logger.error(
- "Failed to load native library " + lib + ": "
- + t.getMessage());
- RegistryHandler.checkRegistryKeys();
+ logger.error("Couldn't load jmsofficecomm. If you are debugging,"
+ + " make sure that HKLM\\SOFTWARE[\\Wow6432Node]\\Microsoft\\"
+ + "Office\\Outlook\\Call Integration\\IMApplication is set to"
+ + " javaw.exe; " + t.getMessage());
throw new RuntimeException(t);
}
}
@@ -1125,11 +1122,6 @@ public class Messenger
{
mistatus = MISTATUS_ON_THE_PHONE;
}
- else if (ProtocolNames.YAHOO.equalsIgnoreCase(protocolName)
- && YahooStatusEnum.ON_THE_PHONE.equals(presenceStatus))
- {
- mistatus = MISTATUS_ON_THE_PHONE;
- }
else if ((i == 32 /* FIXME */)
&& ProtocolNames.JABBER.equalsIgnoreCase(protocolName)
&& JabberStatusEnum.IN_A_MEETING.equalsIgnoreCase(
diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java b/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java
index 2b108f8..632a933 100644
--- a/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java
+++ b/src/net/java/sip/communicator/plugin/msofficecomm/MsOfficeCommActivator.java
@@ -88,7 +88,6 @@ public class MsOfficeCommActivator
}
finally
{
- RegistryHandler.checkRegistryKeys();
if (stopMessenger)
Messenger.stop(bundleContext);
}
diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/OutOfProcessServer.java b/src/net/java/sip/communicator/plugin/msofficecomm/OutOfProcessServer.java
index 7415163..c412e66 100644
--- a/src/net/java/sip/communicator/plugin/msofficecomm/OutOfProcessServer.java
+++ b/src/net/java/sip/communicator/plugin/msofficecomm/OutOfProcessServer.java
@@ -25,11 +25,6 @@ package net.java.sip.communicator.plugin.msofficecomm;
*/
class OutOfProcessServer
{
- static
- {
- System.loadLibrary("jmsofficecomm");
- }
-
static native int start();
static native int stop();
diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/RegistryHandler.java b/src/net/java/sip/communicator/plugin/msofficecomm/RegistryHandler.java
deleted file mode 100644
index 1cb11f6..0000000
--- a/src/net/java/sip/communicator/plugin/msofficecomm/RegistryHandler.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.msofficecomm;
-
-import net.java.sip.communicator.util.Logger;
-
-import com.sun.jna.platform.win32.*;
-
-/**
- * Checks the registry keys used by
- * Outlook.
- *
- * @author Hristo Terezov
- */
-public class RegistryHandler
-{
- /**
- * The logger.
- */
- private static Logger logger = Logger.getLogger(RegistryHandler.class);
-
- /**
- * The key under which the IM application is placed.
- */
- private static String REGISTRY_IM_APPLICATION_KEY
- = "Software\\IM Providers";
-
- /**
- * The value under which the default IM application is placed.
- */
- private static String REGISTRY_DEFAULT_IM_APPLICATION_VALUE
- = "DefaultIMApp";
-
- /**
- * The key for the outlook call integration.
- */
- private static String REGISTRY_CALL_INTEGRATION
- = "Software\\Microsoft\\Office\\Outlook\\Call Integration";
-
- /**
- * The value for the outlook call integration.
- */
- private static String REGISTRY_CALL_INTEGRATION_VALUE
- = "IMApplication";
-
- /**
- * The key for the outlook rtc application.
- */
- private static String REGISTRY_OFFICE11_RTC_APPLICATION
- = "Software\\Microsoft\\Office\\11.0\\Common\\PersonaMenu";
-
- /**
- * The key for the outlook rtc application.
- */
- private static String REGISTRY_OFFICE12_RTC_APPLICATION
- = "Software\\Microsoft\\Office\\12.0\\Common\\PersonaMenu";
-
- /**
- * The value for the rtc application.
- */
- private static String REGISTRY_RTC_APPLICATION_VALUE = "RTCApplication";
-
- /**
- * The key for Communicator IM App.
- */
- private static String REGISTRY_COMMUNICATOR_UP
- = "Software\\IM Providers\\Communicator";
-
- /**
- * Up and running value.
- */
- private static String REGISTRY_UP_RUNNING_VALUE = "UpAndRunning";
-
- /**
- * Checks the existence of the registry keys for outlook call integration.
- */
- private static void checkCallIntegration()
- {
- if(!Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE,
- REGISTRY_CALL_INTEGRATION)
- || !Advapi32Util.registryValueExists(WinReg.HKEY_LOCAL_MACHINE,
- REGISTRY_CALL_INTEGRATION,
- REGISTRY_CALL_INTEGRATION_VALUE))
- {
- logger.error(REGISTRY_CALL_INTEGRATION +
- " doesn't exists in registry");
- return;
- }
- logger.info("Call integration: " +
- Advapi32Util.registryGetStringValue(
- WinReg.HKEY_LOCAL_MACHINE,
- REGISTRY_CALL_INTEGRATION,
- REGISTRY_CALL_INTEGRATION_VALUE));
- }
-
- /**
- * Checks the existence of the registry keys for outlook rtc application.
- */
- private static void checkRTCApplication()
- {
- if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_OFFICE11_RTC_APPLICATION)
- || !Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_OFFICE11_RTC_APPLICATION,
- REGISTRY_RTC_APPLICATION_VALUE))
- {
- logger.error(REGISTRY_OFFICE11_RTC_APPLICATION +
- " doesn't exists in registry");
- }
- else
- {
- logger.info("RTC application: " +
- Advapi32Util.registryGetIntValue(
- WinReg.HKEY_CURRENT_USER,
- REGISTRY_OFFICE11_RTC_APPLICATION,
- REGISTRY_RTC_APPLICATION_VALUE));
- }
-
- if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_OFFICE12_RTC_APPLICATION)
- || !Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_OFFICE12_RTC_APPLICATION,
- REGISTRY_RTC_APPLICATION_VALUE))
- {
- logger.error(REGISTRY_OFFICE12_RTC_APPLICATION +
- " doesn't exists in registry");
- }
- else
- {
- logger.info("RTC application: " +
- Advapi32Util.registryGetIntValue(
- WinReg.HKEY_CURRENT_USER,
- REGISTRY_OFFICE12_RTC_APPLICATION,
- REGISTRY_RTC_APPLICATION_VALUE));
- }
- }
-
- /**
- * Checks if the registry key for running Jitsi and Communicator.
- */
- private static void checkUpAndRunning()
- {
- if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_COMMUNICATOR_UP)
- || !Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_COMMUNICATOR_UP,
- REGISTRY_UP_RUNNING_VALUE))
- {
- logger.error(REGISTRY_COMMUNICATOR_UP +
- " doesn't exists in registry");
- }
- else
- {
- logger.info("Communicator up and running value: " +
- Advapi32Util.registryGetIntValue(
- WinReg.HKEY_CURRENT_USER,
- REGISTRY_COMMUNICATOR_UP,
- REGISTRY_UP_RUNNING_VALUE));
- }
-
- if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_IM_APPLICATION_KEY + "\\" + getApplicationName())
- || !Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_IM_APPLICATION_KEY + "\\" + getApplicationName(),
- REGISTRY_UP_RUNNING_VALUE))
- {
- logger.error(REGISTRY_IM_APPLICATION_KEY +
- " doesn't exists in registry");
- }
- else
- {
- logger.info("Up and running value: " +
- Advapi32Util.registryGetIntValue(
- WinReg.HKEY_CURRENT_USER,
- REGISTRY_IM_APPLICATION_KEY + "\\"
- + getApplicationName(),
- REGISTRY_UP_RUNNING_VALUE));
- }
- }
-
- /**
- * Logs registry information.
- */
- public static void checkRegistryKeys()
- {
- checkDefaultIMApp();
- checkRegisteredIMApp();
- checkCallIntegration();
- checkRTCApplication();
- checkUpAndRunning();
- }
-
-
- /**
- * Checks whether Jitsi is the default IM application.
- */
- private static void checkDefaultIMApp()
- {
- if(!Advapi32Util.registryKeyExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_IM_APPLICATION_KEY) ||
- !Advapi32Util.registryValueExists(WinReg.HKEY_CURRENT_USER,
- REGISTRY_IM_APPLICATION_KEY,
- REGISTRY_DEFAULT_IM_APPLICATION_VALUE))
- {
- logger.error(REGISTRY_IM_APPLICATION_KEY
- + " doesn't extsts");
- return;
- }
-
- logger.info("Default IM App: " + Advapi32Util.registryGetStringValue(
- WinReg.HKEY_CURRENT_USER,
- REGISTRY_IM_APPLICATION_KEY,
- REGISTRY_DEFAULT_IM_APPLICATION_VALUE));
- }
-
- /**
- * Checks whether Jitsi is registered as IM provider.
- */
- private static void checkRegisteredIMApp()
- {
- if(!Advapi32Util.registryKeyExists(
- WinReg.HKEY_LOCAL_MACHINE,
- REGISTRY_IM_APPLICATION_KEY + "\\" + getApplicationName()))
- {
- logger.error(REGISTRY_IM_APPLICATION_KEY + "\\" +
- getApplicationName() + " doesn;t exsts");
- return;
- }
-
- logger.info("Registered IM App friendly name: "
- + Advapi32Util.registryGetStringValue(
- WinReg.HKEY_LOCAL_MACHINE,
- REGISTRY_IM_APPLICATION_KEY + "\\" +
- getApplicationName(),
- "FriendlyName"));
- }
-
- /**
- * Returns the application name.
- * @return the application name
- */
- private static String getApplicationName()
- {
- return MsOfficeCommActivator.getResources().getSettingsString(
- "service.gui.APPLICATION_NAME");
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/msofficecomm/msofficecomm.manifest.mf b/src/net/java/sip/communicator/plugin/msofficecomm/msofficecomm.manifest.mf
index 54d8545..2a3a712 100644
--- a/src/net/java/sip/communicator/plugin/msofficecomm/msofficecomm.manifest.mf
+++ b/src/net/java/sip/communicator/plugin/msofficecomm/msofficecomm.manifest.mf
@@ -10,7 +10,6 @@ Import-Package: javax.swing,
net.java.sip.communicator.service.protocol,
net.java.sip.communicator.service.protocol.event,
net.java.sip.communicator.service.protocol.jabberconstants,
- net.java.sip.communicator.service.protocol.yahooconstants,
net.java.sip.communicator.util,
org.jitsi.service.configuration,
org.jitsi.util,
diff --git a/src/net/java/sip/communicator/plugin/otr/OtrConfigurator.java b/src/net/java/sip/communicator/plugin/otr/OtrConfigurator.java
index 42efc97..dd3940b 100644
--- a/src/net/java/sip/communicator/plugin/otr/OtrConfigurator.java
+++ b/src/net/java/sip/communicator/plugin/otr/OtrConfigurator.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,171 +15,171 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.otr;
-
-import java.util.*;
-
-import org.bouncycastle.util.encoders.Base64; // disambiguation
-import org.jitsi.service.configuration.*;
-
-/**
- * A class that gets/sets the OTR configuration values. Introduced to assure our
- * configuration is properly written when <tt>XMLConfigurationStore</tt> is
- * used. Can be seen as a proxy between the {@link ConfigurationService} and the
- * OTR Plugin.
- *
- * @author George Politis
- */
-public class OtrConfigurator
-{
- /**
- * Gets an XML tag friendly {@link String} from a {@link String}.
- *
- * @param s a {@link String}
- * @return an XML friendly {@link String}
- */
- private String getXmlFriendlyString(String s)
- {
- if (s == null || s.length() < 1)
- return s;
-
- // XML Tags are not allowed to start with digits,
- // insert a dummy "p" char.
- if (Character.isDigit(s.charAt(0)))
- s = "p" + s;
-
- char[] cId = new char[s.length()];
-
- for (int i = 0; i < cId.length; i++)
- {
- char c = s.charAt(i);
-
- cId[i] = Character.isLetterOrDigit(c) ? c : '_';
- }
-
- return new String(cId);
- }
-
- /**
- * Puts a given property ID under the OTR namespace and makes sure it is XML
- * tag friendly.
- *
- * @param id the property ID.
- * @return the namespaced ID.
- */
- private String getID(String id)
- {
- return
- "net.java.sip.communicator.plugin.otr." + getXmlFriendlyString(id);
- }
-
- /**
- * Returns the value of the property with the specified name or null if no
- * such property exists ({@link ConfigurationService#getProperty(String)}
- * proxy).
- *
- * @param id of the property that is being queried.
- * @return the <tt>byte[]</tt> value of the property with the specified
- * name.
- */
- public byte[] getPropertyBytes(String id)
- {
- String value = OtrActivator.configService.getString(getID(id));
-
- return (value == null) ? null : Base64.decode(value.getBytes());
- }
-
- /**
- * Gets the value of a specific property as a boolean (
- * {@link ConfigurationService#getBoolean(String, boolean)} proxy).
- *
- * @param id of the property that is being queried.
- * @param defaultValue the value to be returned if the specified property
- * name is not associated with a value.
- * @return the <tt>Boolean</tt> value of the property with the specified
- * name.
- */
- public boolean getPropertyBoolean(String id, boolean defaultValue)
- {
- return
- OtrActivator.configService.getBoolean(getID(id), defaultValue);
- }
-
- /**
- * Sets the property with the specified name to the specified value (
- * {@link ConfigurationService#setProperty(String, Object)} proxy). The
- * value is Base64 encoded.
- *
- * @param id the name of the property to change.
- * @param value the new value of the specified property.
- */
- public void setProperty(String id, byte[] value)
- {
- String valueToStore = new String(Base64.encode(value));
-
- OtrActivator.configService.setProperty(getID(id), valueToStore);
- }
-
- /**
- * Sets the property with the specified name to the specified value (
- * {@link ConfigurationService#setProperty(String, Object)} proxy).
- *
- * @param id the name of the property to change.
- * @param value the new value of the specified property.
- */
- public void setProperty(String id, Object value)
- {
- OtrActivator.configService.setProperty(getID(id), value);
- }
-
- /**
- * Removes the property with the specified name (
- * {@link ConfigurationService#removeProperty(String)} proxy).
- *
- * @param id the name of the property to change.
- */
- public void removeProperty(String id)
- {
- OtrActivator.configService.removeProperty(getID(id));
- }
-
- /**
- * Gets the value of a specific property as a signed decimal integer.
- *
- * @param id the name of the property to change.
- * @param defaultValue the value to be returned if the specified property
- * name is not associated with a value.
- * @return the <tt>int</tt> value of the property
- */
- public int getPropertyInt(String id, int defaultValue)
- {
- return OtrActivator.configService.getInt(getID(id), defaultValue);
- }
-
- /**
- * Appends <tt>value</tt> to the old value of the property with the
- * specified name. The two values will be comma separated.
- *
- * @param id the name of the property to append to
- * @param value the value to append
- */
- public void appendProperty(String id, Object value)
- {
- Object oldValue = OtrActivator.configService.getProperty(getID(id));
-
- String newValue =
- oldValue == null ? value.toString() : oldValue + "," + value;
-
- setProperty(id, newValue);
- }
-
- public List<String> getAppendedProperties(String id)
- {
- String listProperties =
- (String) OtrActivator.configService.getProperty(getID(id));
-
- if (listProperties == null) return new ArrayList<String>();
-
- return Arrays.asList(listProperties.split(","));
- }
-}
+package net.java.sip.communicator.plugin.otr;
+
+import java.util.*;
+
+import org.bouncycastle.util.encoders.Base64; // disambiguation
+import org.jitsi.service.configuration.*;
+
+/**
+ * A class that gets/sets the OTR configuration values. Introduced to assure our
+ * configuration is properly written when <tt>XMLConfigurationStore</tt> is
+ * used. Can be seen as a proxy between the {@link ConfigurationService} and the
+ * OTR Plugin.
+ *
+ * @author George Politis
+ */
+public class OtrConfigurator
+{
+ /**
+ * Gets an XML tag friendly {@link String} from a {@link String}.
+ *
+ * @param s a {@link String}
+ * @return an XML friendly {@link String}
+ */
+ private String getXmlFriendlyString(String s)
+ {
+ if (s == null || s.length() < 1)
+ return s;
+
+ // XML Tags are not allowed to start with digits,
+ // insert a dummy "p" char.
+ if (Character.isDigit(s.charAt(0)))
+ s = "p" + s;
+
+ char[] cId = new char[s.length()];
+
+ for (int i = 0; i < cId.length; i++)
+ {
+ char c = s.charAt(i);
+
+ cId[i] = Character.isLetterOrDigit(c) ? c : '_';
+ }
+
+ return new String(cId);
+ }
+
+ /**
+ * Puts a given property ID under the OTR namespace and makes sure it is XML
+ * tag friendly.
+ *
+ * @param id the property ID.
+ * @return the namespaced ID.
+ */
+ private String getID(String id)
+ {
+ return
+ "net.java.sip.communicator.plugin.otr." + getXmlFriendlyString(id);
+ }
+
+ /**
+ * Returns the value of the property with the specified name or null if no
+ * such property exists ({@link ConfigurationService#getProperty(String)}
+ * proxy).
+ *
+ * @param id of the property that is being queried.
+ * @return the <tt>byte[]</tt> value of the property with the specified
+ * name.
+ */
+ public byte[] getPropertyBytes(String id)
+ {
+ String value = OtrActivator.configService.getString(getID(id));
+
+ return (value == null) ? null : Base64.decode(value.getBytes());
+ }
+
+ /**
+ * Gets the value of a specific property as a boolean (
+ * {@link ConfigurationService#getBoolean(String, boolean)} proxy).
+ *
+ * @param id of the property that is being queried.
+ * @param defaultValue the value to be returned if the specified property
+ * name is not associated with a value.
+ * @return the <tt>Boolean</tt> value of the property with the specified
+ * name.
+ */
+ public boolean getPropertyBoolean(String id, boolean defaultValue)
+ {
+ return
+ OtrActivator.configService.getBoolean(getID(id), defaultValue);
+ }
+
+ /**
+ * Sets the property with the specified name to the specified value (
+ * {@link ConfigurationService#setProperty(String, Object)} proxy). The
+ * value is Base64 encoded.
+ *
+ * @param id the name of the property to change.
+ * @param value the new value of the specified property.
+ */
+ public void setProperty(String id, byte[] value)
+ {
+ String valueToStore = new String(Base64.encode(value));
+
+ OtrActivator.configService.setProperty(getID(id), valueToStore);
+ }
+
+ /**
+ * Sets the property with the specified name to the specified value (
+ * {@link ConfigurationService#setProperty(String, Object)} proxy).
+ *
+ * @param id the name of the property to change.
+ * @param value the new value of the specified property.
+ */
+ public void setProperty(String id, Object value)
+ {
+ OtrActivator.configService.setProperty(getID(id), value);
+ }
+
+ /**
+ * Removes the property with the specified name (
+ * {@link ConfigurationService#removeProperty(String)} proxy).
+ *
+ * @param id the name of the property to change.
+ */
+ public void removeProperty(String id)
+ {
+ OtrActivator.configService.removeProperty(getID(id));
+ }
+
+ /**
+ * Gets the value of a specific property as a signed decimal integer.
+ *
+ * @param id the name of the property to change.
+ * @param defaultValue the value to be returned if the specified property
+ * name is not associated with a value.
+ * @return the <tt>int</tt> value of the property
+ */
+ public int getPropertyInt(String id, int defaultValue)
+ {
+ return OtrActivator.configService.getInt(getID(id), defaultValue);
+ }
+
+ /**
+ * Appends <tt>value</tt> to the old value of the property with the
+ * specified name. The two values will be comma separated.
+ *
+ * @param id the name of the property to append to
+ * @param value the value to append
+ */
+ public void appendProperty(String id, Object value)
+ {
+ Object oldValue = OtrActivator.configService.getProperty(getID(id));
+
+ String newValue =
+ oldValue == null ? value.toString() : oldValue + "," + value;
+
+ setProperty(id, newValue);
+ }
+
+ public List<String> getAppendedProperties(String id)
+ {
+ String listProperties =
+ (String) OtrActivator.configService.getProperty(getID(id));
+
+ if (listProperties == null) return new ArrayList<String>();
+
+ return Arrays.asList(listProperties.split(","));
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java
index bce2fe7..8e4a235 100644
--- a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java
+++ b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,1330 +15,1328 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.otr;
-
-import java.net.*;
-import java.security.*;
-import java.util.*;
-import java.util.concurrent.*;
-
-import net.java.otr4j.*;
-import net.java.otr4j.crypto.*;
-import net.java.otr4j.session.*;
-import net.java.sip.communicator.plugin.otr.OtrContactManager.OtrContact;
-import net.java.sip.communicator.plugin.otr.authdialog.*;
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.contactlist.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- *
- * @author George Politis
- * @author Lyubomir Marinov
- * @author Pawel Domas
- * @author Marin Dzhigarov
- * @author Danny van Heumen
- */
-public class ScOtrEngineImpl
- implements ScOtrEngine,
- ChatLinkClickedListener,
- ServiceListener
-{
- private class ScOtrEngineHost
- implements OtrEngineHost
- {
- @Override
- public KeyPair getLocalKeyPair(SessionID sessionID)
- {
- AccountID accountID =
- OtrActivator.getAccountIDByUID(sessionID.getAccountID());
- KeyPair keyPair =
- OtrActivator.scOtrKeyManager.loadKeyPair(accountID);
- if (keyPair == null)
- OtrActivator.scOtrKeyManager.generateKeyPair(accountID);
-
- return OtrActivator.scOtrKeyManager.loadKeyPair(accountID);
- }
-
- @Override
- public OtrPolicy getSessionPolicy(SessionID sessionID)
- {
- return getContactPolicy(getOtrContact(sessionID).contact);
- }
-
- @Override
- public void injectMessage(SessionID sessionID, String messageText)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- Contact contact = otrContact.contact;
- ContactResource resource = null;
-
- if (contact.supportResources())
- {
- Collection<ContactResource> resources = contact.getResources();
- if (resources != null)
- {
- for (ContactResource r : resources)
- {
- if (r.equals(otrContact.resource))
- {
- resource = r;
- break;
- }
- }
- }
- }
-
- OperationSetBasicInstantMessaging imOpSet
- = contact
- .getProtocolProvider()
- .getOperationSet(
- OperationSetBasicInstantMessaging.class);
-
- // This is a dirty way of detecting whether the injected message
- // contains HTML markup. If this is the case then we should create
- // the message with the appropriate content type so that the remote
- // party can properly display the HTML.
- // When otr4j injects QueryMessages it calls
- // OtrEngineHost.getFallbackMessage() which is currently the only
- // host method that uses HTML so we can simply check if the injected
- // message contains the string that getFallbackMessage() returns.
- String otrHtmlFallbackMessage
- = "<a href=\"http://en.wikipedia.org/wiki/Off-the-Record_Messaging\">";
- String contentType
- = messageText.contains(otrHtmlFallbackMessage)
- ? OperationSetBasicInstantMessaging.HTML_MIME_TYPE
- : OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE;
- Message message
- = imOpSet.createMessage(
- messageText,
- contentType,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING,
- null);
-
- injectedMessageUIDs.add(message.getMessageUID());
- imOpSet.sendInstantMessage(contact, resource, message);
- }
-
- @Override
- public void showError(SessionID sessionID, String err)
- {
- ScOtrEngineImpl.this.showError(sessionID, err);
- }
-
- public void showWarning(SessionID sessionID, String warn)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- Contact contact = otrContact.contact;
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(), new Date(),
- Chat.SYSTEM_MESSAGE, warn,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
- }
-
- @Override
- public void unreadableMessageReceived(SessionID sessionID)
- throws OtrException
- {
- OtrContact otrContact = getOtrContact(sessionID);
- String resourceName = otrContact.resource != null ?
- "/" + otrContact.resource.getResourceName() : "";
-
- Contact contact = otrContact.contact;
- String error =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.unreadablemsgreceived",
- new String[]
- {contact.getDisplayName() + resourceName});
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(), new Date(),
- Chat.ERROR_MESSAGE, error,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
- }
-
- @Override
- public void unencryptedMessageReceived(SessionID sessionID, String msg)
- throws OtrException
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- Contact contact = otrContact.contact;
- String warn =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.unencryptedmsgreceived");
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(), new Date(),
- Chat.SYSTEM_MESSAGE, warn,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
- }
-
- @Override
- public void smpError(SessionID sessionID, int tlvType, boolean cheated)
- throws OtrException
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- Contact contact = otrContact.contact;
- logger.debug("SMP error occurred"
- + ". Contact: " + contact.getDisplayName()
- + ". TLV type: " + tlvType
- + ". Cheated: " + cheated);
-
- String error =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.smperror");
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(), new Date(),
- Chat.ERROR_MESSAGE, error,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
-
- SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
- if (progressDialog == null)
- {
- progressDialog = new SmpProgressDialog(contact);
- progressDialogMap.put(otrContact, progressDialog);
- }
-
- progressDialog.setProgressFail();
- progressDialog.setVisible(true);
- }
-
- @Override
- public void smpAborted(SessionID sessionID) throws OtrException
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- Contact contact = otrContact.contact;
- Session session = otrEngine.getSession(sessionID);
- if (session.isSmpInProgress())
- {
- String warn =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.smpaborted",
- new String[] {contact.getDisplayName()});
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(), new Date(),
- Chat.SYSTEM_MESSAGE, warn,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
-
- SmpProgressDialog progressDialog =
- progressDialogMap.get(otrContact);
- if (progressDialog == null)
- {
- progressDialog = new SmpProgressDialog(contact);
- progressDialogMap.put(otrContact, progressDialog);
- }
-
- progressDialog.setProgressFail();
- progressDialog.setVisible(true);
- }
- }
-
- @Override
- public void finishedSessionMessage(SessionID sessionID, String msgText)
- throws OtrException
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- String resourceName = otrContact.resource != null ?
- "/" + otrContact.resource.getResourceName() : "";
- Contact contact = otrContact.contact;
- String error =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.sessionfinishederror",
- new String[]
- {msgText, contact.getDisplayName() + resourceName});
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(), new Date(),
- Chat.ERROR_MESSAGE, error,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
- }
-
- @Override
- public void requireEncryptedMessage(SessionID sessionID, String msgText)
- throws OtrException
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- Contact contact = otrContact.contact;
- String error =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.requireencryption",
- new String[]
- {msgText});
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(), new Date(),
- Chat.ERROR_MESSAGE, error,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
- }
-
- @Override
- public byte[] getLocalFingerprintRaw(SessionID sessionID)
- {
- AccountID accountID =
- OtrActivator.getAccountIDByUID(sessionID.getAccountID());
- return
- OtrActivator.scOtrKeyManager.getLocalFingerprintRaw(accountID);
- }
-
- @Override
- public void askForSecret(
- SessionID sessionID, InstanceTag receiverTag, String question)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- Contact contact = otrContact.contact;
- SmpAuthenticateBuddyDialog dialog =
- new SmpAuthenticateBuddyDialog(
- otrContact, receiverTag, question);
- dialog.setVisible(true);
-
- SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
- if (progressDialog == null)
- {
- progressDialog = new SmpProgressDialog(contact);
- progressDialogMap.put(otrContact, progressDialog);
- }
-
- progressDialog.init();
- progressDialog.setVisible(true);
- }
-
- @Override
- public void verify(
- SessionID sessionID, String fingerprint, boolean approved)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- Contact contact = otrContact.contact;
- OtrActivator.scOtrKeyManager.verify(otrContact, fingerprint);
-
- SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
- if (progressDialog == null)
- {
- progressDialog = new SmpProgressDialog(contact);
- progressDialogMap.put(otrContact, progressDialog);
- }
-
- progressDialog.setProgressSuccess();
- progressDialog.setVisible(true);
- }
-
- @Override
- public void unverify(SessionID sessionID, String fingerprint)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- Contact contact = otrContact.contact;
- OtrActivator.scOtrKeyManager.unverify(otrContact, fingerprint);
-
- SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
- if (progressDialog == null)
- {
- progressDialog = new SmpProgressDialog(contact);
- progressDialogMap.put(otrContact, progressDialog);
- }
-
- progressDialog.setProgressFail();
- progressDialog.setVisible(true);
- }
-
- @Override
- public String getReplyForUnreadableMessage(SessionID sessionID)
- {
- AccountID accountID =
- OtrActivator.getAccountIDByUID(sessionID.getAccountID());
-
- return OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.unreadablemsgreply",
- new String[] {accountID.getDisplayName(),
- accountID.getDisplayName()});
- }
-
- @Override
- public String getFallbackMessage(SessionID sessionID)
- {
- AccountID accountID =
- OtrActivator.getAccountIDByUID(sessionID.getAccountID());
-
- return OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.fallbackmessage",
- new String[] {accountID.getDisplayName()});
- }
-
- @Override
- public void multipleInstancesDetected(SessionID sessionID)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- String resourceName = otrContact.resource != null ?
- "/" + otrContact.resource.getResourceName() : "";
- Contact contact = otrContact.contact;
- String message =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.multipleinstancesdetected",
- new String[]
- {contact.getDisplayName() + resourceName});
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(),
- new Date(), Chat.SYSTEM_MESSAGE,
- message,
- OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
- }
-
- @Override
- public void messageFromAnotherInstanceReceived(SessionID sessionID)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- String resourceName = otrContact.resource != null ?
- "/" + otrContact.resource.getResourceName() : "";
- Contact contact = otrContact.contact;
- String message =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.msgfromanotherinstance",
- new String[]
- {contact.getDisplayName() + resourceName});
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(),
- new Date(), Chat.SYSTEM_MESSAGE,
- message,
- OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
- }
-
- /**
- * Provide fragmenter instructions according to the Instant Messaging
- * transport channel of the contact's protocol.
- */
- @Override
- public FragmenterInstructions getFragmenterInstructions(
- final SessionID sessionID)
- {
- final OtrContact otrContact = getOtrContact(sessionID);
- final OperationSetBasicInstantMessagingTransport transport =
- otrContact.contact.getProtocolProvider().getOperationSet(
- OperationSetBasicInstantMessagingTransport.class);
- if (transport == null)
- {
- // There is no operation set for querying transport parameters.
- // Assuming transport capabilities are unlimited.
- if (logger.isDebugEnabled())
- {
- logger.debug("No implementation of "
- + "BasicInstantMessagingTransport available. Assuming "
- + "OTR defaults for OTR fragmentation instructions.");
- }
- return null;
- }
- int messageSize = transport.getMaxMessageSize(otrContact.contact);
- if (messageSize
- == OperationSetBasicInstantMessagingTransport.UNLIMITED)
- {
- messageSize = FragmenterInstructions.UNLIMITED;
- }
- int numberOfMessages =
- transport.getMaxNumberOfMessages(otrContact.contact);
- if (numberOfMessages
- == OperationSetBasicInstantMessagingTransport.UNLIMITED)
- {
- numberOfMessages = FragmenterInstructions.UNLIMITED;
- }
- if (logger.isDebugEnabled())
- {
- logger.debug("OTR fragmentation instructions for sending a "
- + "message to " + otrContact.contact.getDisplayName()
- + " (" + otrContact.contact.getAddress()
- + "). Maximum number of " + "messages: " + numberOfMessages
- + ", maximum message size: " + messageSize);
- }
- return new FragmenterInstructions(numberOfMessages, messageSize);
- }
- }
-
- /**
- * The max timeout period elapsed prior to establishing a TIMED_OUT session.
- */
- private static final int SESSION_TIMEOUT =
- OtrActivator.configService.getInt(
- "net.java.sip.communicator.plugin.otr.SESSION_STATUS_TIMEOUT",
- 30000);
-
- /**
- * Manages the scheduling of TimerTasks that are used to set Contact's
- * ScSessionStatus (to TIMED_OUT) after a period of time.
- */
- private ScSessionStatusScheduler scheduler = new ScSessionStatusScheduler();
-
- /**
- * This mapping is used for taking care of keeping SessionStatus and
- * ScSessionStatus in sync for every Session object.
- */
- private Map<SessionID, ScSessionStatus> scSessionStatusMap =
- new ConcurrentHashMap<SessionID, ScSessionStatus>();
-
- private static final Map<ScSessionID, OtrContact> contactsMap =
- new Hashtable<ScSessionID, OtrContact>();
-
- private static final Map<OtrContact, SmpProgressDialog> progressDialogMap =
- new ConcurrentHashMap<OtrContact, SmpProgressDialog>();
-
- public static OtrContact getOtrContact(SessionID sessionID)
- {
- return contactsMap.get(new ScSessionID(sessionID));
- }
-
- /**
- * Returns the <tt>ScSessionID</tt> for given <tt>UUID</tt>.
- * @param guid the <tt>UUID</tt> identifying <tt>ScSessionID</tt>.
- * @return the <tt>ScSessionID</tt> for given <tt>UUID</tt> or <tt>null</tt>
- * if no matching session found.
- */
- public static ScSessionID getScSessionForGuid(UUID guid)
- {
- for(ScSessionID scSessionID : contactsMap.keySet())
- {
- if(scSessionID.getGUID().equals(guid))
- {
- return scSessionID;
- }
- }
- return null;
- }
-
- public static SessionID getSessionID(OtrContact otrContact)
- {
- ProtocolProviderService pps = otrContact.contact.getProtocolProvider();
- String resourceName = otrContact.resource != null ?
- "/" + otrContact.resource.getResourceName() : "";
- SessionID sessionID
- = new SessionID(
- pps.getAccountID().getAccountUniqueID(),
- otrContact.contact.getAddress() + resourceName,
- pps.getProtocolName());
-
- synchronized (contactsMap)
- {
- if(contactsMap.containsKey(new ScSessionID(sessionID)))
- return sessionID;
-
- ScSessionID scSessionID = new ScSessionID(sessionID);
-
- contactsMap.put(scSessionID, otrContact);
- }
-
- return sessionID;
- }
-
- private final OtrConfigurator configurator = new OtrConfigurator();
-
- private final List<String> injectedMessageUIDs = new Vector<String>();
-
- private final List<ScOtrEngineListener> listeners =
- new Vector<ScOtrEngineListener>();
-
- /**
- * The logger
- */
- private final Logger logger = Logger.getLogger(ScOtrEngineImpl.class);
-
- private final OtrEngineHost otrEngineHost = new ScOtrEngineHost();
-
- private final OtrSessionManager otrEngine;
-
- public ScOtrEngineImpl()
- {
- otrEngine = new OtrSessionManagerImpl(otrEngineHost);
-
- // Clears the map after previous instance
- // This is required because of OSGi restarts in the same VM on Android
- contactsMap.clear();
- scSessionStatusMap.clear();
-
- this.otrEngine.addOtrEngineListener(new OtrEngineListener()
- {
- @Override
- public void sessionStatusChanged(SessionID sessionID)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- String resourceName = otrContact.resource != null ?
- "/" + otrContact.resource.getResourceName() : "";
- Contact contact = otrContact.contact;
- // Cancels any scheduled tasks that will change the
- // ScSessionStatus for this Contact
- scheduler.cancel(otrContact);
-
- ScSessionStatus scSessionStatus = getSessionStatus(otrContact);
- String message = "";
- final Session session = otrEngine.getSession(sessionID);
- switch (session.getSessionStatus())
- {
- case ENCRYPTED:
- scSessionStatus = ScSessionStatus.ENCRYPTED;
- scSessionStatusMap.put(sessionID, scSessionStatus);
- PublicKey remotePubKey = session.getRemotePublicKey();
-
- String remoteFingerprint = null;
- try
- {
- remoteFingerprint =
- new OtrCryptoEngineImpl().
- getFingerprint(remotePubKey);
- }
- catch (OtrCryptoException e)
- {
- logger.debug(
- "Could not get the fingerprint from the "
- + "public key of contact: " + contact);
- }
-
- List<String> allFingerprintsOfContact =
- OtrActivator.scOtrKeyManager.
- getAllRemoteFingerprints(contact);
- if (allFingerprintsOfContact != null)
- {
- if (!allFingerprintsOfContact.contains(
- remoteFingerprint))
- {
- OtrActivator.scOtrKeyManager.saveFingerprint(
- contact, remoteFingerprint);
- }
- }
-
- if (!OtrActivator.scOtrKeyManager.isVerified(
- contact, remoteFingerprint))
- {
- OtrActivator.scOtrKeyManager.unverify(
- otrContact, remoteFingerprint);
- UUID sessionGuid = null;
- for(ScSessionID scSessionID : contactsMap.keySet())
- {
- if(scSessionID.getSessionID().equals(sessionID))
- {
- sessionGuid = scSessionID.getGUID();
- break;
- }
- }
-
- OtrActivator.uiService.getChat(contact)
- .addChatLinkClickedListener(ScOtrEngineImpl.this);
-
- String unverifiedSessionWarning
- = OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator"
- + ".unverifiedsessionwarning",
- new String[]
- {
- contact.getDisplayName() + resourceName,
- this.getClass().getName(),
- "AUTHENTIFICATION",
- sessionGuid.toString()
- });
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(),
- new Date(), Chat.SYSTEM_MESSAGE,
- unverifiedSessionWarning,
- OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
-
- }
-
- // show info whether history is on or off
- String otrAndHistoryMessage;
- if(!OtrActivator.getMessageHistoryService()
- .isHistoryLoggingEnabled() ||
- !isHistoryLoggingEnabled(contact))
- {
- otrAndHistoryMessage =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.historyoff",
- new String[]{
- OtrActivator.resourceService
- .getSettingsString(
- "service.gui.APPLICATION_NAME"),
- this.getClass().getName(),
- "showHistoryPopupMenu"
- });
- }
- else
- {
- otrAndHistoryMessage =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.historyon",
- new String[]{
- OtrActivator.resourceService
- .getSettingsString(
- "service.gui.APPLICATION_NAME"),
- this.getClass().getName(),
- "showHistoryPopupMenu"
- });
- }
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(),
- new Date(), Chat.SYSTEM_MESSAGE,
- otrAndHistoryMessage,
- OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
-
- message =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.multipleinstancesdetected",
- new String[]
- {contact.getDisplayName()});
-
- if (contact.supportResources()
- && contact.getResources() != null
- && contact.getResources().size() > 1)
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(),
- new Date(), Chat.SYSTEM_MESSAGE,
- message,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
-
- message
- = OtrActivator.resourceService.getI18NString(
- OtrActivator.scOtrKeyManager.isVerified(
- contact, remoteFingerprint)
- ? "plugin.otr.activator.sessionstared"
- : "plugin.otr.activator"
- + ".unverifiedsessionstared",
- new String[]
- {contact.getDisplayName() + resourceName});
-
- break;
- case FINISHED:
- scSessionStatus = ScSessionStatus.FINISHED;
- scSessionStatusMap.put(sessionID, scSessionStatus);
- message =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.sessionfinished",
- new String[]
- {contact.getDisplayName() + resourceName});
- break;
- case PLAINTEXT:
- scSessionStatus = ScSessionStatus.PLAINTEXT;
- scSessionStatusMap.put(sessionID, scSessionStatus);
- message =
- OtrActivator.resourceService.getI18NString(
- "plugin.otr.activator.sessionlost", new String[]
- {contact.getDisplayName() + resourceName});
- break;
- }
-
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(), new Date(),
- Chat.SYSTEM_MESSAGE, message,
- OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
-
- for (ScOtrEngineListener l : getListeners())
- l.sessionStatusChanged(otrContact);
- }
-
- @Override
- public void multipleInstancesDetected(SessionID sessionID)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- for (ScOtrEngineListener l : getListeners())
- l.multipleInstancesDetected(otrContact);
- }
-
- @Override
- public void outgoingSessionChanged(SessionID sessionID)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- for (ScOtrEngineListener l : getListeners())
- l.outgoingSessionChanged(otrContact);
- }
- });
- }
-
- /**
- * Checks whether history is enabled for the metacontact containing
- * the <tt>contact</tt>.
- * @param contact the contact to check.
- * @return whether chat logging is enabled while chatting
- * with <tt>contact</tt>.
- */
- private boolean isHistoryLoggingEnabled(Contact contact)
- {
- MetaContact metaContact = OtrActivator
- .getContactListService().findMetaContactByContact(contact);
- if(metaContact != null)
- return OtrActivator.getMessageHistoryService()
- .isHistoryLoggingEnabled(metaContact.getMetaUID());
- else
- return true;
- }
-
- @Override
- public void addListener(ScOtrEngineListener l)
- {
- synchronized (listeners)
- {
- if (!listeners.contains(l))
- listeners.add(l);
- }
- }
-
- @Override
- public void chatLinkClicked(URI url)
- {
- String action = url.getPath();
- if(action.equals("/AUTHENTIFICATION"))
- {
- UUID guid = UUID.fromString(url.getQuery());
-
- if(guid == null)
- throw new RuntimeException(
- "No UUID found in OTR authenticate URL");
-
- // Looks for registered action handler
- OtrActionHandler actionHandler
- = ServiceUtils.getService(
- OtrActivator.bundleContext,
- OtrActionHandler.class);
-
- if(actionHandler != null)
- {
- actionHandler.onAuthenticateLinkClicked(guid);
- }
- else
- {
- logger.error("No OtrActionHandler registered");
- }
- }
- }
-
- @Override
- public void endSession(OtrContact otrContact)
- {
- SessionID sessionID = getSessionID(otrContact);
- try
- {
- setSessionStatus(otrContact, ScSessionStatus.PLAINTEXT);
-
- otrEngine.getSession(sessionID).endSession();
- }
- catch (OtrException e)
- {
- showError(sessionID, e.getMessage());
- }
- }
-
- @Override
- public OtrPolicy getContactPolicy(Contact contact)
- {
- ProtocolProviderService pps = contact.getProtocolProvider();
- SessionID sessionID
- = new SessionID(
- pps.getAccountID().getAccountUniqueID(),
- contact.getAddress(),
- pps.getProtocolName());
- int policy =
- this.configurator.getPropertyInt(sessionID + "contact_policy",
- -1);
- if (policy < 0)
- return getGlobalPolicy();
- else
- return new OtrPolicyImpl(policy);
- }
-
- @Override
- public OtrPolicy getGlobalPolicy()
- {
- /*
- * SEND_WHITESPACE_TAG bit will be lowered until we stabilize the OTR.
- */
- int defaultScOtrPolicy =
- OtrPolicy.OTRL_POLICY_DEFAULT & ~OtrPolicy.SEND_WHITESPACE_TAG;
- return new OtrPolicyImpl(this.configurator.getPropertyInt(
- "GLOBAL_POLICY", defaultScOtrPolicy));
- }
-
- /**
- * Gets a copy of the list of <tt>ScOtrEngineListener</tt>s registered with
- * this instance which may safely be iterated without the risk of a
- * <tt>ConcurrentModificationException</tt>.
- *
- * @return a copy of the list of <tt>ScOtrEngineListener<tt>s registered
- * with this instance which may safely be iterated without the risk of a
- * <tt>ConcurrentModificationException</tt>
- */
- private ScOtrEngineListener[] getListeners()
- {
- synchronized (listeners)
- {
- return listeners.toArray(new ScOtrEngineListener[listeners.size()]);
- }
- }
-
- /**
- * Manages the scheduling of TimerTasks that are used to set Contact's
- * ScSessionStatus after a period of time.
- *
- * @author Marin Dzhigarov
- */
- private class ScSessionStatusScheduler
- {
- private final Timer timer = new Timer();
-
- private final Map<OtrContact, TimerTask> tasks =
- new ConcurrentHashMap<OtrContact, TimerTask>();
-
- public void scheduleScSessionStatusChange(
- final OtrContact otrContact, final ScSessionStatus status)
- {
- cancel(otrContact);
-
- TimerTask task
- = new TimerTask()
- {
- @Override
- public void run()
- {
- setSessionStatus(otrContact, status);
- }
- };
- timer.schedule(task, SESSION_TIMEOUT);
- tasks.put(otrContact, task);
- }
-
- public void cancel(final OtrContact otrContact)
- {
- TimerTask task = tasks.get(otrContact);
- if (task != null)
- task.cancel();
- tasks.remove(otrContact);
- }
-
- public void serviceChanged(ServiceEvent ev)
- {
- Object service
- = OtrActivator.bundleContext.getService(
- ev.getServiceReference());
-
- if (!(service instanceof ProtocolProviderService))
- return;
-
- if (ev.getType() == ServiceEvent.UNREGISTERING)
- {
- ProtocolProviderService provider
- = (ProtocolProviderService) service;
-
- Iterator<OtrContact> i = tasks.keySet().iterator();
-
- while (i.hasNext())
- {
- OtrContact otrContact = i.next();
- if (provider.equals(
- otrContact.contact.getProtocolProvider()))
- {
- cancel(otrContact);
- i.remove();
- }
- }
- }
- }
- }
-
- private void setSessionStatus(OtrContact contact, ScSessionStatus status)
- {
- scSessionStatusMap.put(getSessionID(contact), status);
- scheduler.cancel(contact);
- for (ScOtrEngineListener l : getListeners())
- l.sessionStatusChanged(contact);
- }
-
- @Override
- public ScSessionStatus getSessionStatus(OtrContact contact)
- {
- SessionID sessionID = getSessionID(contact);
- SessionStatus sessionStatus = otrEngine.getSession(sessionID).getSessionStatus();
- ScSessionStatus scSessionStatus = null;
- if (!scSessionStatusMap.containsKey(sessionID))
- {
- switch (sessionStatus)
- {
- case PLAINTEXT:
- scSessionStatus = ScSessionStatus.PLAINTEXT;
- break;
- case ENCRYPTED:
- scSessionStatus = ScSessionStatus.ENCRYPTED;
- break;
- case FINISHED:
- scSessionStatus = ScSessionStatus.FINISHED;
- break;
- }
- scSessionStatusMap.put(sessionID, scSessionStatus);
- }
- return scSessionStatusMap.get(sessionID);
- }
-
- @Override
- public boolean isMessageUIDInjected(String mUID)
- {
- return injectedMessageUIDs.contains(mUID);
- }
-
- @Override
- public void launchHelp()
- {
- ServiceReference ref =
- OtrActivator.bundleContext
- .getServiceReference(BrowserLauncherService.class.getName());
-
- if (ref == null)
- return;
-
- BrowserLauncherService service =
- (BrowserLauncherService) OtrActivator.bundleContext.getService(ref);
-
- service.openURL(OtrActivator.resourceService
- .getI18NString("plugin.otr.authbuddydialog.HELP_URI"));
- }
-
- @Override
- public void refreshSession(OtrContact otrContact)
- {
- SessionID sessionID = getSessionID(otrContact);
- try
- {
- otrEngine.getSession(sessionID).refreshSession();
- }
- catch (OtrException e)
- {
- logger.error("Error refreshing session", e);
- showError(sessionID, e.getMessage());
- }
- }
-
- @Override
- public void removeListener(ScOtrEngineListener l)
- {
- synchronized (listeners)
- {
- listeners.remove(l);
- }
- }
-
- /**
- * Cleans the contactsMap when <tt>ProtocolProviderService</tt>
- * gets unregistered.
- */
- @Override
- public void serviceChanged(ServiceEvent ev)
- {
- Object service
- = OtrActivator.bundleContext.getService(ev.getServiceReference());
-
- if (!(service instanceof ProtocolProviderService))
- return;
-
- if (ev.getType() == ServiceEvent.UNREGISTERING)
- {
- if (logger.isDebugEnabled())
- {
- logger.debug(
- "Unregistering a ProtocolProviderService, cleaning"
- + " OTR's ScSessionID to Contact map.");
- logger.debug(
- "Unregistering a ProtocolProviderService, cleaning"
- + " OTR's Contact to SpmProgressDialog map.");
- }
-
- ProtocolProviderService provider
- = (ProtocolProviderService) service;
-
- synchronized(contactsMap)
- {
- Iterator<OtrContact> i = contactsMap.values().iterator();
-
- while (i.hasNext())
+package net.java.sip.communicator.plugin.otr;
+
+import java.net.*;
+import java.security.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+import net.java.otr4j.*;
+import net.java.otr4j.crypto.*;
+import net.java.otr4j.session.*;
+import net.java.sip.communicator.plugin.otr.OtrContactManager.OtrContact;
+import net.java.sip.communicator.plugin.otr.authdialog.*;
+import net.java.sip.communicator.service.browserlauncher.*;
+import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+import org.osgi.framework.*;
+
+/**
+ *
+ * @author George Politis
+ * @author Lyubomir Marinov
+ * @author Pawel Domas
+ * @author Marin Dzhigarov
+ * @author Danny van Heumen
+ */
+public class ScOtrEngineImpl
+ implements ScOtrEngine,
+ ChatLinkClickedListener,
+ ServiceListener
+{
+ private class ScOtrEngineHost
+ implements OtrEngineHost
+ {
+ @Override
+ public KeyPair getLocalKeyPair(SessionID sessionID)
+ {
+ AccountID accountID =
+ OtrActivator.getAccountIDByUID(sessionID.getAccountID());
+ KeyPair keyPair =
+ OtrActivator.scOtrKeyManager.loadKeyPair(accountID);
+ if (keyPair == null)
+ OtrActivator.scOtrKeyManager.generateKeyPair(accountID);
+
+ return OtrActivator.scOtrKeyManager.loadKeyPair(accountID);
+ }
+
+ @Override
+ public OtrPolicy getSessionPolicy(SessionID sessionID)
+ {
+ return getContactPolicy(getOtrContact(sessionID).contact);
+ }
+
+ @Override
+ public void injectMessage(SessionID sessionID, String messageText)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ Contact contact = otrContact.contact;
+ ContactResource resource = null;
+
+ if (contact.supportResources())
+ {
+ Collection<ContactResource> resources = contact.getResources();
+ if (resources != null)
+ {
+ for (ContactResource r : resources)
+ {
+ if (r.equals(otrContact.resource))
+ {
+ resource = r;
+ break;
+ }
+ }
+ }
+ }
+
+ OperationSetBasicInstantMessaging imOpSet
+ = contact
+ .getProtocolProvider()
+ .getOperationSet(
+ OperationSetBasicInstantMessaging.class);
+
+ // This is a dirty way of detecting whether the injected message
+ // contains HTML markup. If this is the case then we should create
+ // the message with the appropriate content type so that the remote
+ // party can properly display the HTML.
+ // When otr4j injects QueryMessages it calls
+ // OtrEngineHost.getFallbackMessage() which is currently the only
+ // host method that uses HTML so we can simply check if the injected
+ // message contains the string that getFallbackMessage() returns.
+ String otrHtmlFallbackMessage
+ = "<a href=\"http://en.wikipedia.org/wiki/Off-the-Record_Messaging\">";
+ String contentType
+ = messageText.contains(otrHtmlFallbackMessage)
+ ? OperationSetBasicInstantMessaging.HTML_MIME_TYPE
+ : OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE;
+ Message message
+ = imOpSet.createMessage(
+ messageText,
+ contentType,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_ENCODING,
+ null);
+
+ injectedMessageUIDs.add(message.getMessageUID());
+ imOpSet.sendInstantMessage(contact, resource, message);
+ }
+
+ @Override
+ public void showError(SessionID sessionID, String err)
+ {
+ ScOtrEngineImpl.this.showError(sessionID, err);
+ }
+
+ public void showWarning(SessionID sessionID, String warn)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ Contact contact = otrContact.contact;
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(), new Date(),
+ Chat.SYSTEM_MESSAGE, warn,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
+ }
+
+ @Override
+ public void unreadableMessageReceived(SessionID sessionID)
+ throws OtrException
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ String resourceName = otrContact.resource != null ?
+ "/" + otrContact.resource.getResourceName() : "";
+
+ Contact contact = otrContact.contact;
+ String error =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.unreadablemsgreceived",
+ new String[]
+ {contact.getDisplayName() + resourceName});
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(), new Date(),
+ Chat.ERROR_MESSAGE, error,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
+ }
+
+ @Override
+ public void unencryptedMessageReceived(SessionID sessionID, String msg)
+ throws OtrException
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ Contact contact = otrContact.contact;
+ String warn =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.unencryptedmsgreceived");
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(), new Date(),
+ Chat.SYSTEM_MESSAGE, warn,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
+ }
+
+ @Override
+ public void smpError(SessionID sessionID, int tlvType, boolean cheated)
+ throws OtrException
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ Contact contact = otrContact.contact;
+ logger.debug("SMP error occurred"
+ + ". Contact: " + contact.getDisplayName()
+ + ". TLV type: " + tlvType
+ + ". Cheated: " + cheated);
+
+ String error =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.smperror");
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(), new Date(),
+ Chat.ERROR_MESSAGE, error,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
+
+ SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
+ if (progressDialog == null)
+ {
+ progressDialog = new SmpProgressDialog(contact);
+ progressDialogMap.put(otrContact, progressDialog);
+ }
+
+ progressDialog.setProgressFail();
+ progressDialog.setVisible(true);
+ }
+
+ @Override
+ public void smpAborted(SessionID sessionID) throws OtrException
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ Contact contact = otrContact.contact;
+ Session session = otrEngine.getSession(sessionID);
+ if (session.isSmpInProgress())
+ {
+ String warn =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.smpaborted",
+ new String[] {contact.getDisplayName()});
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(), new Date(),
+ Chat.SYSTEM_MESSAGE, warn,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
+
+ SmpProgressDialog progressDialog =
+ progressDialogMap.get(otrContact);
+ if (progressDialog == null)
+ {
+ progressDialog = new SmpProgressDialog(contact);
+ progressDialogMap.put(otrContact, progressDialog);
+ }
+
+ progressDialog.setProgressFail();
+ progressDialog.setVisible(true);
+ }
+ }
+
+ @Override
+ public void finishedSessionMessage(SessionID sessionID, String msgText)
+ throws OtrException
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ String resourceName = otrContact.resource != null ?
+ "/" + otrContact.resource.getResourceName() : "";
+ Contact contact = otrContact.contact;
+ String error =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.sessionfinishederror",
+ new String[]
+ {msgText, contact.getDisplayName() + resourceName});
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(), new Date(),
+ Chat.ERROR_MESSAGE, error,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
+ }
+
+ @Override
+ public void requireEncryptedMessage(SessionID sessionID, String msgText)
+ throws OtrException
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ Contact contact = otrContact.contact;
+ String error =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.requireencryption",
+ new String[]
+ {msgText});
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(), new Date(),
+ Chat.ERROR_MESSAGE, error,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
+ }
+
+ @Override
+ public byte[] getLocalFingerprintRaw(SessionID sessionID)
+ {
+ AccountID accountID =
+ OtrActivator.getAccountIDByUID(sessionID.getAccountID());
+ return
+ OtrActivator.scOtrKeyManager.getLocalFingerprintRaw(accountID);
+ }
+
+ @Override
+ public void askForSecret(
+ SessionID sessionID, InstanceTag receiverTag, String question)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ Contact contact = otrContact.contact;
+ SmpAuthenticateBuddyDialog dialog =
+ new SmpAuthenticateBuddyDialog(
+ otrContact, receiverTag, question);
+ dialog.setVisible(true);
+
+ SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
+ if (progressDialog == null)
+ {
+ progressDialog = new SmpProgressDialog(contact);
+ progressDialogMap.put(otrContact, progressDialog);
+ }
+
+ progressDialog.init();
+ progressDialog.setVisible(true);
+ }
+
+ @Override
+ public void verify(
+ SessionID sessionID, String fingerprint, boolean approved)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ Contact contact = otrContact.contact;
+ OtrActivator.scOtrKeyManager.verify(otrContact, fingerprint);
+
+ SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
+ if (progressDialog == null)
+ {
+ progressDialog = new SmpProgressDialog(contact);
+ progressDialogMap.put(otrContact, progressDialog);
+ }
+
+ progressDialog.setProgressSuccess();
+ progressDialog.setVisible(true);
+ }
+
+ @Override
+ public void unverify(SessionID sessionID, String fingerprint)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ Contact contact = otrContact.contact;
+ OtrActivator.scOtrKeyManager.unverify(otrContact, fingerprint);
+
+ SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
+ if (progressDialog == null)
+ {
+ progressDialog = new SmpProgressDialog(contact);
+ progressDialogMap.put(otrContact, progressDialog);
+ }
+
+ progressDialog.setProgressFail();
+ progressDialog.setVisible(true);
+ }
+
+ @Override
+ public String getReplyForUnreadableMessage(SessionID sessionID)
+ {
+ AccountID accountID =
+ OtrActivator.getAccountIDByUID(sessionID.getAccountID());
+
+ return OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.unreadablemsgreply",
+ new String[] {accountID.getDisplayName(),
+ accountID.getDisplayName()});
+ }
+
+ @Override
+ public String getFallbackMessage(SessionID sessionID)
+ {
+ AccountID accountID =
+ OtrActivator.getAccountIDByUID(sessionID.getAccountID());
+
+ return OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.fallbackmessage",
+ new String[] {accountID.getDisplayName()});
+ }
+
+ @Override
+ public void multipleInstancesDetected(SessionID sessionID)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ String resourceName = otrContact.resource != null ?
+ "/" + otrContact.resource.getResourceName() : "";
+ Contact contact = otrContact.contact;
+ String message =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.multipleinstancesdetected",
+ new String[]
+ {contact.getDisplayName() + resourceName});
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(),
+ new Date(), Chat.SYSTEM_MESSAGE,
+ message,
+ OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
+ }
+
+ @Override
+ public void messageFromAnotherInstanceReceived(SessionID sessionID)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ String resourceName = otrContact.resource != null ?
+ "/" + otrContact.resource.getResourceName() : "";
+ Contact contact = otrContact.contact;
+ String message =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.msgfromanotherinstance",
+ new String[]
+ {contact.getDisplayName() + resourceName});
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(),
+ new Date(), Chat.SYSTEM_MESSAGE,
+ message,
+ OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
+ }
+
+ /**
+ * Provide fragmenter instructions according to the Instant Messaging
+ * transport channel of the contact's protocol.
+ */
+ @Override
+ public FragmenterInstructions getFragmenterInstructions(
+ final SessionID sessionID)
+ {
+ final OtrContact otrContact = getOtrContact(sessionID);
+ final OperationSetBasicInstantMessagingTransport transport =
+ otrContact.contact.getProtocolProvider().getOperationSet(
+ OperationSetBasicInstantMessagingTransport.class);
+ if (transport == null)
+ {
+ // There is no operation set for querying transport parameters.
+ // Assuming transport capabilities are unlimited.
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("No implementation of "
+ + "BasicInstantMessagingTransport available. Assuming "
+ + "OTR defaults for OTR fragmentation instructions.");
+ }
+ return null;
+ }
+ int messageSize = transport.getMaxMessageSize(otrContact.contact);
+ if (messageSize
+ == OperationSetBasicInstantMessagingTransport.UNLIMITED)
+ {
+ messageSize = FragmenterInstructions.UNLIMITED;
+ }
+ int numberOfMessages =
+ transport.getMaxNumberOfMessages(otrContact.contact);
+ if (numberOfMessages
+ == OperationSetBasicInstantMessagingTransport.UNLIMITED)
+ {
+ numberOfMessages = FragmenterInstructions.UNLIMITED;
+ }
+ if (logger.isDebugEnabled())
+ {
+ logger.debug("OTR fragmentation instructions for sending a "
+ + "message to " + otrContact.contact.getDisplayName()
+ + " (" + otrContact.contact.getAddress()
+ + "). Maximum number of " + "messages: " + numberOfMessages
+ + ", maximum message size: " + messageSize);
+ }
+ return new FragmenterInstructions(numberOfMessages, messageSize);
+ }
+ }
+
+ /**
+ * The max timeout period elapsed prior to establishing a TIMED_OUT session.
+ */
+ private static final int SESSION_TIMEOUT =
+ OtrActivator.configService.getInt(
+ "net.java.sip.communicator.plugin.otr.SESSION_STATUS_TIMEOUT",
+ 30000);
+
+ /**
+ * Manages the scheduling of TimerTasks that are used to set Contact's
+ * ScSessionStatus (to TIMED_OUT) after a period of time.
+ */
+ private ScSessionStatusScheduler scheduler = new ScSessionStatusScheduler();
+
+ /**
+ * This mapping is used for taking care of keeping SessionStatus and
+ * ScSessionStatus in sync for every Session object.
+ */
+ private Map<SessionID, ScSessionStatus> scSessionStatusMap =
+ new ConcurrentHashMap<SessionID, ScSessionStatus>();
+
+ private static final Map<ScSessionID, OtrContact> contactsMap =
+ new Hashtable<ScSessionID, OtrContact>();
+
+ private static final Map<OtrContact, SmpProgressDialog> progressDialogMap =
+ new ConcurrentHashMap<OtrContact, SmpProgressDialog>();
+
+ public static OtrContact getOtrContact(SessionID sessionID)
+ {
+ return contactsMap.get(new ScSessionID(sessionID));
+ }
+
+ /**
+ * Returns the <tt>ScSessionID</tt> for given <tt>UUID</tt>.
+ * @param guid the <tt>UUID</tt> identifying <tt>ScSessionID</tt>.
+ * @return the <tt>ScSessionID</tt> for given <tt>UUID</tt> or <tt>null</tt>
+ * if no matching session found.
+ */
+ public static ScSessionID getScSessionForGuid(UUID guid)
+ {
+ for(ScSessionID scSessionID : contactsMap.keySet())
+ {
+ if(scSessionID.getGUID().equals(guid))
+ {
+ return scSessionID;
+ }
+ }
+ return null;
+ }
+
+ public static SessionID getSessionID(OtrContact otrContact)
+ {
+ ProtocolProviderService pps = otrContact.contact.getProtocolProvider();
+ String resourceName = otrContact.resource != null ?
+ "/" + otrContact.resource.getResourceName() : "";
+ SessionID sessionID
+ = new SessionID(
+ pps.getAccountID().getAccountUniqueID(),
+ otrContact.contact.getAddress() + resourceName,
+ pps.getProtocolName());
+
+ synchronized (contactsMap)
+ {
+ if(contactsMap.containsKey(new ScSessionID(sessionID)))
+ return sessionID;
+
+ ScSessionID scSessionID = new ScSessionID(sessionID);
+
+ contactsMap.put(scSessionID, otrContact);
+ }
+
+ return sessionID;
+ }
+
+ private final OtrConfigurator configurator = new OtrConfigurator();
+
+ private final List<String> injectedMessageUIDs = new Vector<String>();
+
+ private final List<ScOtrEngineListener> listeners =
+ new Vector<ScOtrEngineListener>();
+
+ /**
+ * The logger
+ */
+ private final Logger logger = Logger.getLogger(ScOtrEngineImpl.class);
+
+ private final OtrEngineHost otrEngineHost = new ScOtrEngineHost();
+
+ private final OtrSessionManager otrEngine;
+
+ public ScOtrEngineImpl()
+ {
+ otrEngine = new OtrSessionManagerImpl(otrEngineHost);
+
+ // Clears the map after previous instance
+ // This is required because of OSGi restarts in the same VM on Android
+ contactsMap.clear();
+ scSessionStatusMap.clear();
+
+ this.otrEngine.addOtrEngineListener(new OtrEngineListener()
+ {
+ @Override
+ public void sessionStatusChanged(SessionID sessionID)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ String resourceName = otrContact.resource != null ?
+ "/" + otrContact.resource.getResourceName() : "";
+ Contact contact = otrContact.contact;
+ // Cancels any scheduled tasks that will change the
+ // ScSessionStatus for this Contact
+ scheduler.cancel(otrContact);
+
+ ScSessionStatus scSessionStatus = getSessionStatus(otrContact);
+ String message = "";
+ final Session session = otrEngine.getSession(sessionID);
+ switch (session.getSessionStatus())
+ {
+ case ENCRYPTED:
+ scSessionStatus = ScSessionStatus.ENCRYPTED;
+ scSessionStatusMap.put(sessionID, scSessionStatus);
+ PublicKey remotePubKey = session.getRemotePublicKey();
+
+ String remoteFingerprint = null;
+ try
+ {
+ remoteFingerprint =
+ new OtrCryptoEngineImpl().
+ getFingerprint(remotePubKey);
+ }
+ catch (OtrCryptoException e)
+ {
+ logger.debug(
+ "Could not get the fingerprint from the "
+ + "public key of contact: " + contact);
+ }
+
+ List<String> allFingerprintsOfContact =
+ OtrActivator.scOtrKeyManager.
+ getAllRemoteFingerprints(contact);
+ if (allFingerprintsOfContact != null)
+ {
+ if (!allFingerprintsOfContact.contains(
+ remoteFingerprint))
+ {
+ OtrActivator.scOtrKeyManager.saveFingerprint(
+ contact, remoteFingerprint);
+ }
+ }
+
+ if (!OtrActivator.scOtrKeyManager.isVerified(
+ contact, remoteFingerprint))
+ {
+ OtrActivator.scOtrKeyManager.unverify(
+ otrContact, remoteFingerprint);
+ UUID sessionGuid = null;
+ for(ScSessionID scSessionID : contactsMap.keySet())
+ {
+ if(scSessionID.getSessionID().equals(sessionID))
+ {
+ sessionGuid = scSessionID.getGUID();
+ break;
+ }
+ }
+
+ OtrActivator.uiService.getChat(contact)
+ .addChatLinkClickedListener(ScOtrEngineImpl.this);
+
+ String unverifiedSessionWarning
+ = OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.unverifiedsessionwarning",
+ new String[]
+ {
+ contact.getDisplayName() + resourceName,
+ this.getClass().getName(),
+ "AUTHENTIFICATION",
+ sessionGuid.toString()
+ });
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(),
+ new Date(), Chat.SYSTEM_MESSAGE,
+ unverifiedSessionWarning,
+ OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
+
+ }
+
+ // show info whether history is on or off
+ String otrAndHistoryMessage;
+ if(!OtrActivator.getMessageHistoryService()
+ .isHistoryLoggingEnabled() ||
+ !isHistoryLoggingEnabled(contact))
+ {
+ otrAndHistoryMessage =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.historyoff",
+ new String[]{
+ OtrActivator.resourceService
+ .getSettingsString(
+ "service.gui.APPLICATION_NAME"),
+ this.getClass().getName(),
+ "showHistoryPopupMenu"
+ });
+ }
+ else
+ {
+ otrAndHistoryMessage =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.historyon",
+ new String[]{
+ OtrActivator.resourceService
+ .getSettingsString(
+ "service.gui.APPLICATION_NAME"),
+ this.getClass().getName(),
+ "showHistoryPopupMenu"
+ });
+ }
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(),
+ new Date(), Chat.SYSTEM_MESSAGE,
+ otrAndHistoryMessage,
+ OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
+
+ message =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.multipleinstancesdetected",
+ new String[]
+ {contact.getDisplayName()});
+
+ if (contact.supportResources()
+ && contact.getResources() != null
+ && contact.getResources().size() > 1)
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(),
+ new Date(), Chat.SYSTEM_MESSAGE,
+ message,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
+
+ message
+ = OtrActivator.resourceService.getI18NString(
+ OtrActivator.scOtrKeyManager.isVerified(
+ contact, remoteFingerprint)
+ ? "plugin.otr.activator.sessionstared"
+ : "plugin.otr.activator.unverifiedsessionstared",
+ new String[]
+ {contact.getDisplayName() + resourceName});
+
+ break;
+ case FINISHED:
+ scSessionStatus = ScSessionStatus.FINISHED;
+ scSessionStatusMap.put(sessionID, scSessionStatus);
+ message =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.sessionfinished",
+ new String[]
+ {contact.getDisplayName() + resourceName});
+ break;
+ case PLAINTEXT:
+ scSessionStatus = ScSessionStatus.PLAINTEXT;
+ scSessionStatusMap.put(sessionID, scSessionStatus);
+ message =
+ OtrActivator.resourceService.getI18NString(
+ "plugin.otr.activator.sessionlost", new String[]
+ {contact.getDisplayName() + resourceName});
+ break;
+ }
+
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(), new Date(),
+ Chat.SYSTEM_MESSAGE, message,
+ OperationSetBasicInstantMessaging.HTML_MIME_TYPE);
+
+ for (ScOtrEngineListener l : getListeners())
+ l.sessionStatusChanged(otrContact);
+ }
+
+ @Override
+ public void multipleInstancesDetected(SessionID sessionID)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ for (ScOtrEngineListener l : getListeners())
+ l.multipleInstancesDetected(otrContact);
+ }
+
+ @Override
+ public void outgoingSessionChanged(SessionID sessionID)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ for (ScOtrEngineListener l : getListeners())
+ l.outgoingSessionChanged(otrContact);
+ }
+ });
+ }
+
+ /**
+ * Checks whether history is enabled for the metacontact containing
+ * the <tt>contact</tt>.
+ * @param contact the contact to check.
+ * @return whether chat logging is enabled while chatting
+ * with <tt>contact</tt>.
+ */
+ private boolean isHistoryLoggingEnabled(Contact contact)
+ {
+ MetaContact metaContact = OtrActivator
+ .getContactListService().findMetaContactByContact(contact);
+ if(metaContact != null)
+ return OtrActivator.getMessageHistoryService()
+ .isHistoryLoggingEnabled(metaContact.getMetaUID());
+ else
+ return true;
+ }
+
+ @Override
+ public void addListener(ScOtrEngineListener l)
+ {
+ synchronized (listeners)
+ {
+ if (!listeners.contains(l))
+ listeners.add(l);
+ }
+ }
+
+ @Override
+ public void chatLinkClicked(URI url)
+ {
+ String action = url.getPath();
+ if(action.equals("/AUTHENTIFICATION"))
+ {
+ UUID guid = UUID.fromString(url.getQuery());
+
+ if(guid == null)
+ throw new RuntimeException(
+ "No UUID found in OTR authenticate URL");
+
+ // Looks for registered action handler
+ OtrActionHandler actionHandler
+ = ServiceUtils.getService(
+ OtrActivator.bundleContext,
+ OtrActionHandler.class);
+
+ if(actionHandler != null)
+ {
+ actionHandler.onAuthenticateLinkClicked(guid);
+ }
+ else
+ {
+ logger.error("No OtrActionHandler registered");
+ }
+ }
+ }
+
+ @Override
+ public void endSession(OtrContact otrContact)
+ {
+ SessionID sessionID = getSessionID(otrContact);
+ try
+ {
+ setSessionStatus(otrContact, ScSessionStatus.PLAINTEXT);
+
+ otrEngine.getSession(sessionID).endSession();
+ }
+ catch (OtrException e)
+ {
+ showError(sessionID, e.getMessage());
+ }
+ }
+
+ @Override
+ public OtrPolicy getContactPolicy(Contact contact)
+ {
+ ProtocolProviderService pps = contact.getProtocolProvider();
+ SessionID sessionID
+ = new SessionID(
+ pps.getAccountID().getAccountUniqueID(),
+ contact.getAddress(),
+ pps.getProtocolName());
+ int policy =
+ this.configurator.getPropertyInt(sessionID + "contact_policy",
+ -1);
+ if (policy < 0)
+ return getGlobalPolicy();
+ else
+ return new OtrPolicyImpl(policy);
+ }
+
+ @Override
+ public OtrPolicy getGlobalPolicy()
+ {
+ /*
+ * SEND_WHITESPACE_TAG bit will be lowered until we stabilize the OTR.
+ */
+ int defaultScOtrPolicy =
+ OtrPolicy.OTRL_POLICY_DEFAULT & ~OtrPolicy.SEND_WHITESPACE_TAG;
+ return new OtrPolicyImpl(this.configurator.getPropertyInt(
+ "GLOBAL_POLICY", defaultScOtrPolicy));
+ }
+
+ /**
+ * Gets a copy of the list of <tt>ScOtrEngineListener</tt>s registered with
+ * this instance which may safely be iterated without the risk of a
+ * <tt>ConcurrentModificationException</tt>.
+ *
+ * @return a copy of the list of <tt>ScOtrEngineListener<tt>s registered
+ * with this instance which may safely be iterated without the risk of a
+ * <tt>ConcurrentModificationException</tt>
+ */
+ private ScOtrEngineListener[] getListeners()
+ {
+ synchronized (listeners)
+ {
+ return listeners.toArray(new ScOtrEngineListener[listeners.size()]);
+ }
+ }
+
+ /**
+ * Manages the scheduling of TimerTasks that are used to set Contact's
+ * ScSessionStatus after a period of time.
+ *
+ * @author Marin Dzhigarov
+ */
+ private class ScSessionStatusScheduler
+ {
+ private final Timer timer = new Timer();
+
+ private final Map<OtrContact, TimerTask> tasks =
+ new ConcurrentHashMap<OtrContact, TimerTask>();
+
+ public void scheduleScSessionStatusChange(
+ final OtrContact otrContact, final ScSessionStatus status)
+ {
+ cancel(otrContact);
+
+ TimerTask task
+ = new TimerTask()
+ {
+ @Override
+ public void run()
+ {
+ setSessionStatus(otrContact, status);
+ }
+ };
+ timer.schedule(task, SESSION_TIMEOUT);
+ tasks.put(otrContact, task);
+ }
+
+ public void cancel(final OtrContact otrContact)
+ {
+ TimerTask task = tasks.get(otrContact);
+ if (task != null)
+ task.cancel();
+ tasks.remove(otrContact);
+ }
+
+ public void serviceChanged(ServiceEvent ev)
+ {
+ Object service
+ = OtrActivator.bundleContext.getService(
+ ev.getServiceReference());
+
+ if (!(service instanceof ProtocolProviderService))
+ return;
+
+ if (ev.getType() == ServiceEvent.UNREGISTERING)
+ {
+ ProtocolProviderService provider
+ = (ProtocolProviderService) service;
+
+ Iterator<OtrContact> i = tasks.keySet().iterator();
+
+ while (i.hasNext())
+ {
+ OtrContact otrContact = i.next();
+ if (provider.equals(
+ otrContact.contact.getProtocolProvider()))
+ {
+ cancel(otrContact);
+ i.remove();
+ }
+ }
+ }
+ }
+ }
+
+ private void setSessionStatus(OtrContact contact, ScSessionStatus status)
+ {
+ scSessionStatusMap.put(getSessionID(contact), status);
+ scheduler.cancel(contact);
+ for (ScOtrEngineListener l : getListeners())
+ l.sessionStatusChanged(contact);
+ }
+
+ @Override
+ public ScSessionStatus getSessionStatus(OtrContact contact)
+ {
+ SessionID sessionID = getSessionID(contact);
+ SessionStatus sessionStatus = otrEngine.getSession(sessionID).getSessionStatus();
+ ScSessionStatus scSessionStatus = null;
+ if (!scSessionStatusMap.containsKey(sessionID))
+ {
+ switch (sessionStatus)
+ {
+ case PLAINTEXT:
+ scSessionStatus = ScSessionStatus.PLAINTEXT;
+ break;
+ case ENCRYPTED:
+ scSessionStatus = ScSessionStatus.ENCRYPTED;
+ break;
+ case FINISHED:
+ scSessionStatus = ScSessionStatus.FINISHED;
+ break;
+ }
+ scSessionStatusMap.put(sessionID, scSessionStatus);
+ }
+ return scSessionStatusMap.get(sessionID);
+ }
+
+ @Override
+ public boolean isMessageUIDInjected(String mUID)
+ {
+ return injectedMessageUIDs.contains(mUID);
+ }
+
+ @Override
+ public void launchHelp()
+ {
+ ServiceReference ref =
+ OtrActivator.bundleContext
+ .getServiceReference(BrowserLauncherService.class.getName());
+
+ if (ref == null)
+ return;
+
+ BrowserLauncherService service =
+ (BrowserLauncherService) OtrActivator.bundleContext.getService(ref);
+
+ service.openURL(OtrActivator.resourceService
+ .getI18NString("plugin.otr.authbuddydialog.HELP_URI"));
+ }
+
+ @Override
+ public void refreshSession(OtrContact otrContact)
+ {
+ SessionID sessionID = getSessionID(otrContact);
+ try
+ {
+ otrEngine.getSession(sessionID).refreshSession();
+ }
+ catch (OtrException e)
+ {
+ logger.error("Error refreshing session", e);
+ showError(sessionID, e.getMessage());
+ }
+ }
+
+ @Override
+ public void removeListener(ScOtrEngineListener l)
+ {
+ synchronized (listeners)
+ {
+ listeners.remove(l);
+ }
+ }
+
+ /**
+ * Cleans the contactsMap when <tt>ProtocolProviderService</tt>
+ * gets unregistered.
+ */
+ @Override
+ public void serviceChanged(ServiceEvent ev)
+ {
+ Object service
+ = OtrActivator.bundleContext.getService(ev.getServiceReference());
+
+ if (!(service instanceof ProtocolProviderService))
+ return;
+
+ if (ev.getType() == ServiceEvent.UNREGISTERING)
+ {
+ if (logger.isDebugEnabled())
+ {
+ logger.debug(
+ "Unregistering a ProtocolProviderService, cleaning"
+ + " OTR's ScSessionID to Contact map.");
+ logger.debug(
+ "Unregistering a ProtocolProviderService, cleaning"
+ + " OTR's Contact to SpmProgressDialog map.");
+ }
+
+ ProtocolProviderService provider
+ = (ProtocolProviderService) service;
+
+ synchronized(contactsMap)
+ {
+ Iterator<OtrContact> i = contactsMap.values().iterator();
+
+ while (i.hasNext())
{
- OtrContact otrContact = i.next();
- if (provider.equals(
- otrContact.contact.getProtocolProvider()))
- {
- scSessionStatusMap.remove(getSessionID(otrContact));
- i.remove();
- }
- }
- }
-
- Iterator<OtrContact> i = progressDialogMap.keySet().iterator();
-
- while (i.hasNext())
- {
- if (provider.equals(i.next().contact.getProtocolProvider()))
- i.remove();
- }
- scheduler.serviceChanged(ev);
- }
- }
-
- @Override
- public void setContactPolicy(Contact contact, OtrPolicy policy)
- {
- ProtocolProviderService pps = contact.getProtocolProvider();
- SessionID sessionID
- = new SessionID(
- pps.getAccountID().getAccountUniqueID(),
- contact.getAddress(),
- pps.getProtocolName());
-
- String propertyID = sessionID + "contact_policy";
- if (policy == null)
- this.configurator.removeProperty(propertyID);
- else
- this.configurator.setProperty(propertyID, policy.getPolicy());
-
- for (ScOtrEngineListener l : getListeners())
- l.contactPolicyChanged(contact);
- }
-
- @Override
- public void setGlobalPolicy(OtrPolicy policy)
- {
- if (policy == null)
- this.configurator.removeProperty("GLOBAL_POLICY");
- else
- this.configurator.setProperty("GLOBAL_POLICY", policy.getPolicy());
-
- for (ScOtrEngineListener l : getListeners())
- l.globalPolicyChanged();
- }
-
- public void showError(SessionID sessionID, String err)
- {
- OtrContact otrContact = getOtrContact(sessionID);
- if (otrContact == null)
- return;
-
- Contact contact = otrContact.contact;
- OtrActivator.uiService.getChat(contact).addMessage(
- contact.getDisplayName(), new Date(),
- Chat.ERROR_MESSAGE, err,
- OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
- }
-
- @Override
- public void startSession(OtrContact otrContact)
- {
- SessionID sessionID = getSessionID(otrContact);
-
- ScSessionStatus scSessionStatus = getSessionStatus(otrContact);
- scSessionStatus = ScSessionStatus.LOADING;
- scSessionStatusMap.put(sessionID, scSessionStatus);
- for (ScOtrEngineListener l : getListeners())
- {
- l.sessionStatusChanged(otrContact);
- }
-
- scheduler.scheduleScSessionStatusChange(
- otrContact, ScSessionStatus.TIMED_OUT);
-
- try
- {
- otrEngine.getSession(sessionID).startSession();
- }
- catch (OtrException e)
- {
- logger.error("Error starting session", e);
- showError(sessionID, e.getMessage());
- }
- }
-
- @Override
- public String transformReceiving(OtrContact otrContact, String msgText)
- {
- SessionID sessionID = getSessionID(otrContact);
- try
- {
- return otrEngine.getSession(sessionID).transformReceiving(msgText);
- }
- catch (OtrException e)
- {
- logger.error("Error receiving the message", e);
- showError(sessionID, e.getMessage());
- return null;
- }
- }
-
- @Override
- public String[] transformSending(OtrContact otrContact, String msgText)
- {
- SessionID sessionID = getSessionID(otrContact);
- try
- {
- return otrEngine.getSession(sessionID).transformSending(msgText);
- }
- catch (OtrException e)
- {
- logger.error("Error transforming the message", e);
- showError(sessionID, e.getMessage());
- return null;
- }
- }
-
- private Session getSession(OtrContact contact)
- {
- SessionID sessionID = getSessionID(contact);
- return otrEngine.getSession(sessionID);
- }
-
- @Override
- public void initSmp(OtrContact otrContact, String question, String secret)
- {
- Session session = getSession(otrContact);
- try
- {
- session.initSmp(question, secret);
-
- SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
- if (progressDialog == null)
- {
- progressDialog = new SmpProgressDialog(otrContact.contact);
- progressDialogMap.put(otrContact, progressDialog);
- }
-
- progressDialog.init();
- progressDialog.setVisible(true);
- }
- catch (OtrException e)
- {
- logger.error("Error initializing SMP session with contact "
- + otrContact.contact.getDisplayName(), e);
- showError(session.getSessionID(), e.getMessage());
- }
- }
-
- @Override
- public void respondSmp( OtrContact otrContact,
- InstanceTag receiverTag,
- String question,
- String secret)
- {
- Session session = getSession(otrContact);
- try
- {
- session.respondSmp(receiverTag, question, secret);
-
- SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
- if (progressDialog == null)
- {
- progressDialog = new SmpProgressDialog(otrContact.contact);
- progressDialogMap.put(otrContact, progressDialog);
- }
-
- progressDialog.incrementProgress();
- progressDialog.setVisible(true);
- }
- catch (OtrException e)
- {
- logger.error(
- "Error occured when sending SMP response to contact "
- + otrContact.contact.getDisplayName(), e);
- showError(session.getSessionID(), e.getMessage());
- }
- }
-
- @Override
- public void abortSmp(OtrContact otrContact)
- {
- Session session = getSession(otrContact);
- try
- {
- session.abortSmp();
-
- SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
- if (progressDialog == null)
- {
- progressDialog = new SmpProgressDialog(otrContact.contact);
- progressDialogMap.put(otrContact, progressDialog);
- }
-
- progressDialog.dispose();
- }
- catch (OtrException e)
- {
- logger.error("Error aborting SMP session with contact "
- + otrContact.contact.getDisplayName(), e);
- showError(session.getSessionID(), e.getMessage());
- }
- }
-
- @Override
- public PublicKey getRemotePublicKey(OtrContact otrContact)
- {
- if (otrContact == null)
- return null;
-
- Session session = getSession(otrContact);
-
- return session.getRemotePublicKey();
- }
-
- @Override
- public List<Session> getSessionInstances(OtrContact otrContact)
- {
- if (otrContact == null)
- return Collections.emptyList();
- return getSession(otrContact).getInstances();
- }
-
- @Override
- public boolean setOutgoingSession(OtrContact contact, InstanceTag tag)
- {
- if (contact == null)
- return false;
-
- Session session = getSession(contact);
-
- scSessionStatusMap.remove(session.getSessionID());
- return session.setOutgoingInstance(tag);
- }
-
- @Override
- public Session getOutgoingSession(OtrContact contact)
- {
- if (contact == null)
- return null;
-
- SessionID sessionID = getSessionID(contact);
-
- return otrEngine.getSession(sessionID).getOutgoingInstance();
- }
-}
+ OtrContact otrContact = i.next();
+ if (provider.equals(
+ otrContact.contact.getProtocolProvider()))
+ {
+ scSessionStatusMap.remove(getSessionID(otrContact));
+ i.remove();
+ }
+ }
+ }
+
+ Iterator<OtrContact> i = progressDialogMap.keySet().iterator();
+
+ while (i.hasNext())
+ {
+ if (provider.equals(i.next().contact.getProtocolProvider()))
+ i.remove();
+ }
+ scheduler.serviceChanged(ev);
+ }
+ }
+
+ @Override
+ public void setContactPolicy(Contact contact, OtrPolicy policy)
+ {
+ ProtocolProviderService pps = contact.getProtocolProvider();
+ SessionID sessionID
+ = new SessionID(
+ pps.getAccountID().getAccountUniqueID(),
+ contact.getAddress(),
+ pps.getProtocolName());
+
+ String propertyID = sessionID + "contact_policy";
+ if (policy == null)
+ this.configurator.removeProperty(propertyID);
+ else
+ this.configurator.setProperty(propertyID, policy.getPolicy());
+
+ for (ScOtrEngineListener l : getListeners())
+ l.contactPolicyChanged(contact);
+ }
+
+ @Override
+ public void setGlobalPolicy(OtrPolicy policy)
+ {
+ if (policy == null)
+ this.configurator.removeProperty("GLOBAL_POLICY");
+ else
+ this.configurator.setProperty("GLOBAL_POLICY", policy.getPolicy());
+
+ for (ScOtrEngineListener l : getListeners())
+ l.globalPolicyChanged();
+ }
+
+ public void showError(SessionID sessionID, String err)
+ {
+ OtrContact otrContact = getOtrContact(sessionID);
+ if (otrContact == null)
+ return;
+
+ Contact contact = otrContact.contact;
+ OtrActivator.uiService.getChat(contact).addMessage(
+ contact.getDisplayName(), new Date(),
+ Chat.ERROR_MESSAGE, err,
+ OperationSetBasicInstantMessaging.DEFAULT_MIME_TYPE);
+ }
+
+ @Override
+ public void startSession(OtrContact otrContact)
+ {
+ SessionID sessionID = getSessionID(otrContact);
+
+ ScSessionStatus scSessionStatus = getSessionStatus(otrContact);
+ scSessionStatus = ScSessionStatus.LOADING;
+ scSessionStatusMap.put(sessionID, scSessionStatus);
+ for (ScOtrEngineListener l : getListeners())
+ {
+ l.sessionStatusChanged(otrContact);
+ }
+
+ scheduler.scheduleScSessionStatusChange(
+ otrContact, ScSessionStatus.TIMED_OUT);
+
+ try
+ {
+ otrEngine.getSession(sessionID).startSession();
+ }
+ catch (OtrException e)
+ {
+ logger.error("Error starting session", e);
+ showError(sessionID, e.getMessage());
+ }
+ }
+
+ @Override
+ public String transformReceiving(OtrContact otrContact, String msgText)
+ {
+ SessionID sessionID = getSessionID(otrContact);
+ try
+ {
+ return otrEngine.getSession(sessionID).transformReceiving(msgText);
+ }
+ catch (OtrException e)
+ {
+ logger.error("Error receiving the message", e);
+ showError(sessionID, e.getMessage());
+ return null;
+ }
+ }
+
+ @Override
+ public String[] transformSending(OtrContact otrContact, String msgText)
+ {
+ SessionID sessionID = getSessionID(otrContact);
+ try
+ {
+ return otrEngine.getSession(sessionID).transformSending(msgText);
+ }
+ catch (OtrException e)
+ {
+ logger.error("Error transforming the message", e);
+ showError(sessionID, e.getMessage());
+ return null;
+ }
+ }
+
+ private Session getSession(OtrContact contact)
+ {
+ SessionID sessionID = getSessionID(contact);
+ return otrEngine.getSession(sessionID);
+ }
+
+ @Override
+ public void initSmp(OtrContact otrContact, String question, String secret)
+ {
+ Session session = getSession(otrContact);
+ try
+ {
+ session.initSmp(question, secret);
+
+ SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
+ if (progressDialog == null)
+ {
+ progressDialog = new SmpProgressDialog(otrContact.contact);
+ progressDialogMap.put(otrContact, progressDialog);
+ }
+
+ progressDialog.init();
+ progressDialog.setVisible(true);
+ }
+ catch (OtrException e)
+ {
+ logger.error("Error initializing SMP session with contact "
+ + otrContact.contact.getDisplayName(), e);
+ showError(session.getSessionID(), e.getMessage());
+ }
+ }
+
+ @Override
+ public void respondSmp( OtrContact otrContact,
+ InstanceTag receiverTag,
+ String question,
+ String secret)
+ {
+ Session session = getSession(otrContact);
+ try
+ {
+ session.respondSmp(receiverTag, question, secret);
+
+ SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
+ if (progressDialog == null)
+ {
+ progressDialog = new SmpProgressDialog(otrContact.contact);
+ progressDialogMap.put(otrContact, progressDialog);
+ }
+
+ progressDialog.incrementProgress();
+ progressDialog.setVisible(true);
+ }
+ catch (OtrException e)
+ {
+ logger.error(
+ "Error occured when sending SMP response to contact "
+ + otrContact.contact.getDisplayName(), e);
+ showError(session.getSessionID(), e.getMessage());
+ }
+ }
+
+ @Override
+ public void abortSmp(OtrContact otrContact)
+ {
+ Session session = getSession(otrContact);
+ try
+ {
+ session.abortSmp();
+
+ SmpProgressDialog progressDialog = progressDialogMap.get(otrContact);
+ if (progressDialog == null)
+ {
+ progressDialog = new SmpProgressDialog(otrContact.contact);
+ progressDialogMap.put(otrContact, progressDialog);
+ }
+
+ progressDialog.dispose();
+ }
+ catch (OtrException e)
+ {
+ logger.error("Error aborting SMP session with contact "
+ + otrContact.contact.getDisplayName(), e);
+ showError(session.getSessionID(), e.getMessage());
+ }
+ }
+
+ @Override
+ public PublicKey getRemotePublicKey(OtrContact otrContact)
+ {
+ if (otrContact == null)
+ return null;
+
+ Session session = getSession(otrContact);
+
+ return session.getRemotePublicKey();
+ }
+
+ @Override
+ public List<Session> getSessionInstances(OtrContact otrContact)
+ {
+ if (otrContact == null)
+ return Collections.emptyList();
+ return getSession(otrContact).getInstances();
+ }
+
+ @Override
+ public boolean setOutgoingSession(OtrContact contact, InstanceTag tag)
+ {
+ if (contact == null)
+ return false;
+
+ Session session = getSession(contact);
+
+ scSessionStatusMap.remove(session.getSessionID());
+ return session.setOutgoingInstance(tag);
+ }
+
+ @Override
+ public Session getOutgoingSession(OtrContact contact)
+ {
+ if (contact == null)
+ return null;
+
+ SessionID sessionID = getSessionID(contact);
+
+ return otrEngine.getSession(sessionID).getOutgoingInstance();
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManager.java b/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManager.java
index 183eed7..ae50390 100644
--- a/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManager.java
+++ b/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManager.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,44 +15,44 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.otr;
-
-import java.security.*;
-import java.util.*;
-
-import net.java.sip.communicator.plugin.otr.OtrContactManager.OtrContact;
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- *
- * @author George Politis
- *
- */
-public interface ScOtrKeyManager
-{
-
- public abstract void addListener(ScOtrKeyManagerListener l);
-
- public abstract void removeListener(ScOtrKeyManagerListener l);
-
- public abstract void verify(OtrContact contact, String fingerprint);
-
- public abstract void unverify(OtrContact contact, String fingerprint);
-
- public abstract boolean isVerified(Contact contact, String fingerprint);
-
- public abstract String getFingerprintFromPublicKey(PublicKey pubKey);
-
- public abstract List<String> getAllRemoteFingerprints(Contact contact);
-
- public abstract String getLocalFingerprint(AccountID account);
-
- public abstract byte[] getLocalFingerprintRaw(AccountID account);
-
- public abstract void saveFingerprint(Contact contact, String fingerprint);
-
- public abstract KeyPair loadKeyPair(AccountID accountID);
-
- public abstract void generateKeyPair(AccountID accountID);
-
+package net.java.sip.communicator.plugin.otr;
+
+import java.security.*;
+import java.util.*;
+
+import net.java.sip.communicator.plugin.otr.OtrContactManager.OtrContact;
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ *
+ * @author George Politis
+ *
+ */
+public interface ScOtrKeyManager
+{
+
+ public abstract void addListener(ScOtrKeyManagerListener l);
+
+ public abstract void removeListener(ScOtrKeyManagerListener l);
+
+ public abstract void verify(OtrContact contact, String fingerprint);
+
+ public abstract void unverify(OtrContact contact, String fingerprint);
+
+ public abstract boolean isVerified(Contact contact, String fingerprint);
+
+ public abstract String getFingerprintFromPublicKey(PublicKey pubKey);
+
+ public abstract List<String> getAllRemoteFingerprints(Contact contact);
+
+ public abstract String getLocalFingerprint(AccountID account);
+
+ public abstract byte[] getLocalFingerprintRaw(AccountID account);
+
+ public abstract void saveFingerprint(Contact contact, String fingerprint);
+
+ public abstract KeyPair loadKeyPair(AccountID accountID);
+
+ public abstract void generateKeyPair(AccountID accountID);
+
}
diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerImpl.java b/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerImpl.java
index 890211e..cb57ba4 100644
--- a/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerImpl.java
+++ b/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerImpl.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,311 +15,311 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.otr;
-
-import java.security.*;
-import java.security.spec.*;
-import java.util.*;
-
-import net.java.otr4j.crypto.*;
-import net.java.sip.communicator.plugin.otr.OtrContactManager.OtrContact;
-import net.java.sip.communicator.service.protocol.*;
-
-/**
- *
- * @author George Politis
- * @author Lyubomir Marinov
- */
-public class ScOtrKeyManagerImpl
- implements ScOtrKeyManager
-{
- private final OtrConfigurator configurator = new OtrConfigurator();
-
- private final List<ScOtrKeyManagerListener> listeners =
- new Vector<ScOtrKeyManagerListener>();
-
- public void addListener(ScOtrKeyManagerListener l)
- {
- synchronized (listeners)
- {
- if (!listeners.contains(l))
- listeners.add(l);
- }
- }
-
- /**
- * Gets a copy of the list of <tt>ScOtrKeyManagerListener</tt>s registered
- * with this instance which may safely be iterated without the risk of a
- * <tt>ConcurrentModificationException</tt>.
- *
- * @return a copy of the list of <tt>ScOtrKeyManagerListener<tt>s registered
- * with this instance which may safely be iterated without the risk of a
- * <tt>ConcurrentModificationException</tt>
- */
- private ScOtrKeyManagerListener[] getListeners()
- {
- synchronized (listeners)
- {
- return
- listeners.toArray(
- new ScOtrKeyManagerListener[listeners.size()]);
- }
- }
-
- public void removeListener(ScOtrKeyManagerListener l)
- {
- synchronized (listeners)
- {
- listeners.remove(l);
- }
- }
-
- public void verify(OtrContact otrContact, String fingerprint)
- {
- if ((fingerprint == null) || otrContact == null)
- return;
-
- this.configurator.setProperty(otrContact.contact.getAddress() + fingerprint
- + ".fingerprint.verified", true);
-
- for (ScOtrKeyManagerListener l : getListeners())
- l.contactVerificationStatusChanged(otrContact);
- }
-
- public void unverify(OtrContact otrContact, String fingerprint)
- {
- if ((fingerprint == null) || otrContact == null)
- return;
-
- this.configurator.setProperty(otrContact.contact.getAddress() + fingerprint
- + ".fingerprint.verified", false);
-
- for (ScOtrKeyManagerListener l : getListeners())
- l.contactVerificationStatusChanged(otrContact);
- }
-
- public boolean isVerified(Contact contact, String fingerprint)
- {
- if (fingerprint == null || contact == null)
- return false;
-
- return this.configurator.getPropertyBoolean(
- contact.getAddress() + fingerprint
- + ".fingerprint.verified", false);
- }
-
- public List<String> getAllRemoteFingerprints(Contact contact)
- {
- if (contact == null)
- return null;
-
- /*
- * The following lines are needed for backward compatibility with old
- * versions of the otr plugin. Instead of lists of fingerprints the otr
- * plugin used to store one public key for every contact in the form of
- * "userID.publicKey=..." and one boolean property in the form of
- * "userID.publicKey.verified=...". In order not to loose these old
- * properties we have to convert them to match the new format.
- */
- String userID = contact.getAddress();
-
- byte[] b64PubKey =
- this.configurator.getPropertyBytes(userID + ".publicKey");
- if (b64PubKey != null)
- {
- // We delete the old format property because we are going to convert
- // it in the new format
- this.configurator.removeProperty(userID + ".publicKey");
-
- X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(b64PubKey);
-
- KeyFactory keyFactory;
- try
- {
- keyFactory = KeyFactory.getInstance("DSA");
- PublicKey pubKey = keyFactory.generatePublic(publicKeySpec);
-
- boolean isVerified =
- this.configurator.getPropertyBoolean(userID
- + ".publicKey.verified", false);
-
- // We also make sure to delete this old format property if it
- // exists.
- this.configurator.removeProperty(userID + ".publicKey.verified");
-
- String fingerprint = getFingerprintFromPublicKey(pubKey);
-
- // Now we can store the old properties in the new format.
- if (isVerified)
- verify(OtrContactManager.getOtrContact(contact, null), fingerprint);
- else
- unverify(OtrContactManager.getOtrContact(contact, null), fingerprint);
-
- // Finally we append the new fingerprint to out stored list of
- // fingerprints.
- this.configurator.appendProperty(
- userID + ".fingerprints", fingerprint);
- }
- catch (NoSuchAlgorithmException e)
- {
- e.printStackTrace();
- }
- catch (InvalidKeySpecException e)
- {
- e.printStackTrace();
- }
- }
-
- // Now we can safely return our list of fingerprints for this contact
- // without worrying that we missed an old format property.
- return this.configurator.getAppendedProperties(
- contact.getAddress() + ".fingerprints");
- }
-
- public String getFingerprintFromPublicKey(PublicKey pubKey)
- {
- try
- {
- return new OtrCryptoEngineImpl().getFingerprint(pubKey);
- }
- catch (OtrCryptoException e)
- {
- e.printStackTrace();
- return null;
- }
- }
-
- public String getLocalFingerprint(AccountID account)
- {
- KeyPair keyPair = loadKeyPair(account);
-
- if (keyPair == null)
- return null;
-
- PublicKey pubKey = keyPair.getPublic();
-
- try
- {
- return new OtrCryptoEngineImpl().getFingerprint(pubKey);
- }
- catch (OtrCryptoException e)
- {
- e.printStackTrace();
- return null;
- }
- }
-
- public byte[] getLocalFingerprintRaw(AccountID account)
- {
- KeyPair keyPair = loadKeyPair(account);
-
- if (keyPair == null)
- return null;
-
- PublicKey pubKey = keyPair.getPublic();
-
- try
- {
- return new OtrCryptoEngineImpl().getFingerprintRaw(pubKey);
- }
- catch (OtrCryptoException e)
- {
- e.printStackTrace();
- return null;
- }
- }
-
- public void saveFingerprint(Contact contact, String fingerprint)
- {
- if (contact == null)
- return;
-
- this.configurator.appendProperty(contact.getAddress() + ".fingerprints",
- fingerprint);
-
- this.configurator.setProperty(contact.getAddress() + fingerprint
- + ".fingerprint.verified", false);
- }
-
- public KeyPair loadKeyPair(AccountID account)
- {
- if (account == null)
- return null;
-
- String accountID = account.getAccountUniqueID();
- // Load Private Key.
- byte[] b64PrivKey =
- this.configurator.getPropertyBytes(accountID + ".privateKey");
- if (b64PrivKey == null)
- return null;
-
- PKCS8EncodedKeySpec privateKeySpec =
- new PKCS8EncodedKeySpec(b64PrivKey);
-
- // Load Public Key.
- byte[] b64PubKey =
- this.configurator.getPropertyBytes(accountID + ".publicKey");
- if (b64PubKey == null)
- return null;
-
- X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(b64PubKey);
-
- PublicKey publicKey;
- PrivateKey privateKey;
-
- // Generate KeyPair.
- KeyFactory keyFactory;
- try
- {
- keyFactory = KeyFactory.getInstance("DSA");
- publicKey = keyFactory.generatePublic(publicKeySpec);
- privateKey = keyFactory.generatePrivate(privateKeySpec);
- }
- catch (NoSuchAlgorithmException e)
- {
- e.printStackTrace();
- return null;
- }
- catch (InvalidKeySpecException e)
- {
- e.printStackTrace();
- return null;
- }
-
- return new KeyPair(publicKey, privateKey);
- }
-
- public void generateKeyPair(AccountID account)
- {
- if (account == null)
- return;
-
- String accountID = account.getAccountUniqueID();
- KeyPair keyPair;
- try
- {
- keyPair = KeyPairGenerator.getInstance("DSA").genKeyPair();
- }
- catch (NoSuchAlgorithmException e)
- {
- e.printStackTrace();
- return;
- }
-
- // Store Public Key.
- PublicKey pubKey = keyPair.getPublic();
- X509EncodedKeySpec x509EncodedKeySpec =
- new X509EncodedKeySpec(pubKey.getEncoded());
-
- this.configurator.setProperty(accountID + ".publicKey",
- x509EncodedKeySpec.getEncoded());
-
- // Store Private Key.
- PrivateKey privKey = keyPair.getPrivate();
- PKCS8EncodedKeySpec pkcs8EncodedKeySpec =
- new PKCS8EncodedKeySpec(privKey.getEncoded());
-
- this.configurator.setProperty(accountID + ".privateKey",
- pkcs8EncodedKeySpec.getEncoded());
- }
-}
+package net.java.sip.communicator.plugin.otr;
+
+import java.security.*;
+import java.security.spec.*;
+import java.util.*;
+
+import net.java.otr4j.crypto.*;
+import net.java.sip.communicator.plugin.otr.OtrContactManager.OtrContact;
+import net.java.sip.communicator.service.protocol.*;
+
+/**
+ *
+ * @author George Politis
+ * @author Lyubomir Marinov
+ */
+public class ScOtrKeyManagerImpl
+ implements ScOtrKeyManager
+{
+ private final OtrConfigurator configurator = new OtrConfigurator();
+
+ private final List<ScOtrKeyManagerListener> listeners =
+ new Vector<ScOtrKeyManagerListener>();
+
+ public void addListener(ScOtrKeyManagerListener l)
+ {
+ synchronized (listeners)
+ {
+ if (!listeners.contains(l))
+ listeners.add(l);
+ }
+ }
+
+ /**
+ * Gets a copy of the list of <tt>ScOtrKeyManagerListener</tt>s registered
+ * with this instance which may safely be iterated without the risk of a
+ * <tt>ConcurrentModificationException</tt>.
+ *
+ * @return a copy of the list of <tt>ScOtrKeyManagerListener<tt>s registered
+ * with this instance which may safely be iterated without the risk of a
+ * <tt>ConcurrentModificationException</tt>
+ */
+ private ScOtrKeyManagerListener[] getListeners()
+ {
+ synchronized (listeners)
+ {
+ return
+ listeners.toArray(
+ new ScOtrKeyManagerListener[listeners.size()]);
+ }
+ }
+
+ public void removeListener(ScOtrKeyManagerListener l)
+ {
+ synchronized (listeners)
+ {
+ listeners.remove(l);
+ }
+ }
+
+ public void verify(OtrContact otrContact, String fingerprint)
+ {
+ if ((fingerprint == null) || otrContact == null)
+ return;
+
+ this.configurator.setProperty(otrContact.contact.getAddress() + fingerprint
+ + ".fingerprint.verified", true);
+
+ for (ScOtrKeyManagerListener l : getListeners())
+ l.contactVerificationStatusChanged(otrContact);
+ }
+
+ public void unverify(OtrContact otrContact, String fingerprint)
+ {
+ if ((fingerprint == null) || otrContact == null)
+ return;
+
+ this.configurator.setProperty(otrContact.contact.getAddress() + fingerprint
+ + ".fingerprint.verified", false);
+
+ for (ScOtrKeyManagerListener l : getListeners())
+ l.contactVerificationStatusChanged(otrContact);
+ }
+
+ public boolean isVerified(Contact contact, String fingerprint)
+ {
+ if (fingerprint == null || contact == null)
+ return false;
+
+ return this.configurator.getPropertyBoolean(
+ contact.getAddress() + fingerprint
+ + ".fingerprint.verified", false);
+ }
+
+ public List<String> getAllRemoteFingerprints(Contact contact)
+ {
+ if (contact == null)
+ return null;
+
+ /*
+ * The following lines are needed for backward compatibility with old
+ * versions of the otr plugin. Instead of lists of fingerprints the otr
+ * plugin used to store one public key for every contact in the form of
+ * "userID.publicKey=..." and one boolean property in the form of
+ * "userID.publicKey.verified=...". In order not to loose these old
+ * properties we have to convert them to match the new format.
+ */
+ String userID = contact.getAddress();
+
+ byte[] b64PubKey =
+ this.configurator.getPropertyBytes(userID + ".publicKey");
+ if (b64PubKey != null)
+ {
+ // We delete the old format property because we are going to convert
+ // it in the new format
+ this.configurator.removeProperty(userID + ".publicKey");
+
+ X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(b64PubKey);
+
+ KeyFactory keyFactory;
+ try
+ {
+ keyFactory = KeyFactory.getInstance("DSA");
+ PublicKey pubKey = keyFactory.generatePublic(publicKeySpec);
+
+ boolean isVerified =
+ this.configurator.getPropertyBoolean(userID
+ + ".publicKey.verified", false);
+
+ // We also make sure to delete this old format property if it
+ // exists.
+ this.configurator.removeProperty(userID + ".publicKey.verified");
+
+ String fingerprint = getFingerprintFromPublicKey(pubKey);
+
+ // Now we can store the old properties in the new format.
+ if (isVerified)
+ verify(OtrContactManager.getOtrContact(contact, null), fingerprint);
+ else
+ unverify(OtrContactManager.getOtrContact(contact, null), fingerprint);
+
+ // Finally we append the new fingerprint to out stored list of
+ // fingerprints.
+ this.configurator.appendProperty(
+ userID + ".fingerprints", fingerprint);
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ e.printStackTrace();
+ }
+ catch (InvalidKeySpecException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ // Now we can safely return our list of fingerprints for this contact
+ // without worrying that we missed an old format property.
+ return this.configurator.getAppendedProperties(
+ contact.getAddress() + ".fingerprints");
+ }
+
+ public String getFingerprintFromPublicKey(PublicKey pubKey)
+ {
+ try
+ {
+ return new OtrCryptoEngineImpl().getFingerprint(pubKey);
+ }
+ catch (OtrCryptoException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public String getLocalFingerprint(AccountID account)
+ {
+ KeyPair keyPair = loadKeyPair(account);
+
+ if (keyPair == null)
+ return null;
+
+ PublicKey pubKey = keyPair.getPublic();
+
+ try
+ {
+ return new OtrCryptoEngineImpl().getFingerprint(pubKey);
+ }
+ catch (OtrCryptoException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public byte[] getLocalFingerprintRaw(AccountID account)
+ {
+ KeyPair keyPair = loadKeyPair(account);
+
+ if (keyPair == null)
+ return null;
+
+ PublicKey pubKey = keyPair.getPublic();
+
+ try
+ {
+ return new OtrCryptoEngineImpl().getFingerprintRaw(pubKey);
+ }
+ catch (OtrCryptoException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public void saveFingerprint(Contact contact, String fingerprint)
+ {
+ if (contact == null)
+ return;
+
+ this.configurator.appendProperty(contact.getAddress() + ".fingerprints",
+ fingerprint);
+
+ this.configurator.setProperty(contact.getAddress() + fingerprint
+ + ".fingerprint.verified", false);
+ }
+
+ public KeyPair loadKeyPair(AccountID account)
+ {
+ if (account == null)
+ return null;
+
+ String accountID = account.getAccountUniqueID();
+ // Load Private Key.
+ byte[] b64PrivKey =
+ this.configurator.getPropertyBytes(accountID + ".privateKey");
+ if (b64PrivKey == null)
+ return null;
+
+ PKCS8EncodedKeySpec privateKeySpec =
+ new PKCS8EncodedKeySpec(b64PrivKey);
+
+ // Load Public Key.
+ byte[] b64PubKey =
+ this.configurator.getPropertyBytes(accountID + ".publicKey");
+ if (b64PubKey == null)
+ return null;
+
+ X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(b64PubKey);
+
+ PublicKey publicKey;
+ PrivateKey privateKey;
+
+ // Generate KeyPair.
+ KeyFactory keyFactory;
+ try
+ {
+ keyFactory = KeyFactory.getInstance("DSA");
+ publicKey = keyFactory.generatePublic(publicKeySpec);
+ privateKey = keyFactory.generatePrivate(privateKeySpec);
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ catch (InvalidKeySpecException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+
+ return new KeyPair(publicKey, privateKey);
+ }
+
+ public void generateKeyPair(AccountID account)
+ {
+ if (account == null)
+ return;
+
+ String accountID = account.getAccountUniqueID();
+ KeyPair keyPair;
+ try
+ {
+ keyPair = KeyPairGenerator.getInstance("DSA").genKeyPair();
+ }
+ catch (NoSuchAlgorithmException e)
+ {
+ e.printStackTrace();
+ return;
+ }
+
+ // Store Public Key.
+ PublicKey pubKey = keyPair.getPublic();
+ X509EncodedKeySpec x509EncodedKeySpec =
+ new X509EncodedKeySpec(pubKey.getEncoded());
+
+ this.configurator.setProperty(accountID + ".publicKey",
+ x509EncodedKeySpec.getEncoded());
+
+ // Store Private Key.
+ PrivateKey privKey = keyPair.getPrivate();
+ PKCS8EncodedKeySpec pkcs8EncodedKeySpec =
+ new PKCS8EncodedKeySpec(privKey.getEncoded());
+
+ this.configurator.setProperty(accountID + ".privateKey",
+ pkcs8EncodedKeySpec.getEncoded());
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerListener.java b/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerListener.java
index aeabf75..95403d3 100644
--- a/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerListener.java
+++ b/src/net/java/sip/communicator/plugin/otr/ScOtrKeyManagerListener.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,15 +15,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.otr;
-
-import net.java.sip.communicator.plugin.otr.OtrContactManager.OtrContact;
-
-/**
- *
- * @author George Politis
- */
-public interface ScOtrKeyManagerListener
-{
- public void contactVerificationStatusChanged(OtrContact contact);
-}
+package net.java.sip.communicator.plugin.otr;
+
+import net.java.sip.communicator.plugin.otr.OtrContactManager.OtrContact;
+
+/**
+ *
+ * @author George Politis
+ */
+public interface ScOtrKeyManagerListener
+{
+ public void contactVerificationStatusChanged(OtrContact contact);
+}
diff --git a/src/net/java/sip/communicator/plugin/otr/ScSessionID.java b/src/net/java/sip/communicator/plugin/otr/ScSessionID.java
index 4392045..1a55fcd 100644
--- a/src/net/java/sip/communicator/plugin/otr/ScSessionID.java
+++ b/src/net/java/sip/communicator/plugin/otr/ScSessionID.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,83 +15,83 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.otr;
-
-import java.util.*;
-
-import net.java.otr4j.session.*;
-
-/**
- * Class used to associate a random UUID to an OTR4J SessionID.
- *
- * @author Daniel Perren
- */
-public class ScSessionID
-{
- private final UUID guid = UUID.randomUUID();
-
- private final SessionID sessionID;
-
- /**
- * Creates a new instance of this class.
- *
- * @param sessionID the OTR4J SessionID that is being wrapped.
- */
- public ScSessionID(SessionID sessionID)
- {
- this.sessionID = sessionID;
- }
-
- /**
- * Overrides equals() for the ability to get the hashcode from sessionID.
- *
- * @param obj the object to compare
- * @return true if the objects are considered equal.
- */
- @Override
- public boolean equals(Object obj)
- {
- return (obj != null) && sessionID.toString().equals(obj.toString());
- }
-
- /**
- * Get the current GUID.
- *
- * @return The GUID generated for this SessionID.
- */
- public UUID getGUID()
- {
- return guid;
- }
-
- /**
- * Gets the wrapped session ID
- *
- * @return sessionID
- */
- public SessionID getSessionID()
- {
- return sessionID;
- }
-
- /**
- * Returns {@link SessionID#hashCode()} of the wrapped SessionID.
- *
- * @return HashCode of the wrapped SessionID.
- */
- @Override
- public int hashCode()
- {
- return sessionID.hashCode();
- }
-
- /**
- * Returns {@link SessionID#toString()} of the wrapped SessionID.
- * @return String representation of the wrapped SessionID.
- */
- @Override
- public String toString()
- {
- return sessionID.toString();
- }
-}
+package net.java.sip.communicator.plugin.otr;
+
+import java.util.*;
+
+import net.java.otr4j.session.*;
+
+/**
+ * Class used to associate a random UUID to an OTR4J SessionID.
+ *
+ * @author Daniel Perren
+ */
+public class ScSessionID
+{
+ private final UUID guid = UUID.randomUUID();
+
+ private final SessionID sessionID;
+
+ /**
+ * Creates a new instance of this class.
+ *
+ * @param sessionID the OTR4J SessionID that is being wrapped.
+ */
+ public ScSessionID(SessionID sessionID)
+ {
+ this.sessionID = sessionID;
+ }
+
+ /**
+ * Overrides equals() for the ability to get the hashcode from sessionID.
+ *
+ * @param obj the object to compare
+ * @return true if the objects are considered equal.
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ return (obj != null) && sessionID.toString().equals(obj.toString());
+ }
+
+ /**
+ * Get the current GUID.
+ *
+ * @return The GUID generated for this SessionID.
+ */
+ public UUID getGUID()
+ {
+ return guid;
+ }
+
+ /**
+ * Gets the wrapped session ID
+ *
+ * @return sessionID
+ */
+ public SessionID getSessionID()
+ {
+ return sessionID;
+ }
+
+ /**
+ * Returns {@link SessionID#hashCode()} of the wrapped SessionID.
+ *
+ * @return HashCode of the wrapped SessionID.
+ */
+ @Override
+ public int hashCode()
+ {
+ return sessionID.hashCode();
+ }
+
+ /**
+ * Returns {@link SessionID#toString()} of the wrapped SessionID.
+ * @return String representation of the wrapped SessionID.
+ */
+ @Override
+ public String toString()
+ {
+ return sessionID.toString();
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberContactSource.java b/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberContactSource.java
index 3f916a7..954f5d5 100644
--- a/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberContactSource.java
+++ b/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberContactSource.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,79 +15,79 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.phonenumbercontactsource;
-
-import net.java.sip.communicator.service.contactsource.*;
-
-/**
- * The <tt>PhoneNumberContactSource</tt> is a source of phone numbers coming
- * from the server stored contact info of all contacts for all protocol
- * providers.
- *
- * @author Yana Stamcheva
- */
-public class PhoneNumberContactSource
- implements ContactSourceService
-{
- /**
- * Returns DEFAULT_TYPE to indicate that this contact source is a default
- * source.
- *
- * @return the type of this contact source
- */
- public int getType()
- {
- return DEFAULT_TYPE;
- }
-
- /**
- * Returns a user-friendly string that identifies this contact source.
- *
- * @return the display name of this contact source
- */
- public String getDisplayName()
- {
- return PNContactSourceActivator.getResources().getI18NString(
- "plugin.phonenumbercontactsource.DISPLAY_NAME");
- }
-
- /**
- * Creates query for the given <tt>queryString</tt>.
- *
- * @param queryString the string to search for
- * @return the created query
- */
- public ContactQuery createContactQuery(String queryString)
- {
- return createContactQuery(queryString, -1);
- }
-
- /**
- * Creates query for the given <tt>queryString</tt>.
- *
- * @param queryString the string to search for
- * @param contactCount the maximum count of result contacts
- * @return the created query
- */
- public ContactQuery createContactQuery( String queryString,
- int contactCount)
- {
- if (queryString == null)
- queryString = "";
-
- PhoneNumberContactQuery contactQuery
- = new PhoneNumberContactQuery(this, queryString, contactCount);
-
- return contactQuery;
- }
-
- /**
- * Returns the index of the contact source in the result list.
- *
- * @return the index of the contact source in the result list
- */
- public int getIndex()
- {
- return -1;
- }
-}
+package net.java.sip.communicator.plugin.phonenumbercontactsource;
+
+import net.java.sip.communicator.service.contactsource.*;
+
+/**
+ * The <tt>PhoneNumberContactSource</tt> is a source of phone numbers coming
+ * from the server stored contact info of all contacts for all protocol
+ * providers.
+ *
+ * @author Yana Stamcheva
+ */
+public class PhoneNumberContactSource
+ implements ContactSourceService
+{
+ /**
+ * Returns DEFAULT_TYPE to indicate that this contact source is a default
+ * source.
+ *
+ * @return the type of this contact source
+ */
+ public int getType()
+ {
+ return DEFAULT_TYPE;
+ }
+
+ /**
+ * Returns a user-friendly string that identifies this contact source.
+ *
+ * @return the display name of this contact source
+ */
+ public String getDisplayName()
+ {
+ return PNContactSourceActivator.getResources().getI18NString(
+ "plugin.phonenumbercontactsource.DISPLAY_NAME");
+ }
+
+ /**
+ * Creates query for the given <tt>queryString</tt>.
+ *
+ * @param queryString the string to search for
+ * @return the created query
+ */
+ public ContactQuery createContactQuery(String queryString)
+ {
+ return createContactQuery(queryString, -1);
+ }
+
+ /**
+ * Creates query for the given <tt>queryString</tt>.
+ *
+ * @param queryString the string to search for
+ * @param contactCount the maximum count of result contacts
+ * @return the created query
+ */
+ public ContactQuery createContactQuery( String queryString,
+ int contactCount)
+ {
+ if (queryString == null)
+ queryString = "";
+
+ PhoneNumberContactQuery contactQuery
+ = new PhoneNumberContactQuery(this, queryString, contactCount);
+
+ return contactQuery;
+ }
+
+ /**
+ * Returns the index of the contact source in the result list.
+ *
+ * @return the index of the contact source in the result list
+ */
+ public int getIndex()
+ {
+ return -1;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberSourceContact.java b/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberSourceContact.java
index ef7352f..d7ec804 100644
--- a/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberSourceContact.java
+++ b/src/net/java/sip/communicator/plugin/phonenumbercontactsource/PhoneNumberSourceContact.java
@@ -107,6 +107,18 @@ public class PhoneNumberSourceContact
return true;
}
+ @Override
+ public int hashCode()
+ {
+ String dn = getDisplayName();
+ if (dn != null)
+ {
+ return getDisplayName().hashCode();
+ }
+
+ return 37;
+ }
+
/**
* Returns the protocol contact used.
* @return the protocol contact used.
diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java b/src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java
index 06d2db4..48a4305 100644
--- a/src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java
+++ b/src/net/java/sip/communicator/plugin/pluginmanager/BundleComparator.java
@@ -37,8 +37,8 @@ public class BundleComparator implements Comparator<Bundle>
*/
public int compare(Bundle arg0, Bundle arg1)
{
- String n1 = (String) arg0.getHeaders().get(Constants.BUNDLE_NAME);
- String n2 = (String) arg1.getHeaders().get(Constants.BUNDLE_NAME);
+ String n1 = arg0.getHeaders().get(Constants.BUNDLE_NAME);
+ String n2 = arg1.getHeaders().get(Constants.BUNDLE_NAME);
if (n1 == null)
{
diff --git a/src/net/java/sip/communicator/plugin/profiler4j/ProfilerActivator.java b/src/net/java/sip/communicator/plugin/profiler4j/ProfilerActivator.java
deleted file mode 100644
index f3844a2..0000000
--- a/src/net/java/sip/communicator/plugin/profiler4j/ProfilerActivator.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.profiler4j;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * Activates the profiler plug-in.
- *
- * @author Vladimir Skarupelov
- */
-public class ProfilerActivator implements BundleActivator {
-
- /**
- * OSGi bundle context.
- */
- public static BundleContext bundleContext;
-
- Logger logger = Logger.getLogger(ProfilerActivator.class);
-
- private ServiceRegistration menuRegistration = null;
-
- public void start(BundleContext bc) throws Exception {
- bundleContext = bc;
-
- Hashtable<String, String> toolsMenuFilter =
- new Hashtable<String, String>();
- toolsMenuFilter.put(Container.CONTAINER_ID,
- Container.CONTAINER_TOOLS_MENU.getID());
-
- menuRegistration = bc.registerService(
- PluginComponentFactory.class.getName(),
- new PluginComponentFactory(Container.CONTAINER_TOOLS_MENU)
- {
- @Override
- protected PluginComponent getPluginInstance()
- {
- return new SettingsWindowMenuEntry(
- Container.CONTAINER_TOOLS_MENU, this);
- }
- },
- toolsMenuFilter);
-
- if (logger.isInfoEnabled())
- logger.info("PROFILER4J [REGISTERED]");
-
- }
-
- public void stop(BundleContext bc) throws Exception {
- if (menuRegistration != null)
- {
- menuRegistration.unregister();
- if (logger.isInfoEnabled())
- logger.info("PROFILER4J [UNREGISTERED]");
- }
- }
-
-}
diff --git a/src/net/java/sip/communicator/plugin/profiler4j/Resources.java b/src/net/java/sip/communicator/plugin/profiler4j/Resources.java
deleted file mode 100644
index c69a8a5..0000000
--- a/src/net/java/sip/communicator/plugin/profiler4j/Resources.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.profiler4j;
-
-import net.java.sip.communicator.service.resources.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The Messages class manages the access to the internationalization properties
- * files.
- *
- * @author Vladimir Skarupelov;
- */
-public class Resources
-{
- private static ResourceManagementService resourcesService = null;
-
- /**
- * 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)
- {
- return getResources().getI18NString(key);
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(ProfilerActivator.bundleContext);
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/profiler4j/SettingsWindowMenuEntry.java b/src/net/java/sip/communicator/plugin/profiler4j/SettingsWindowMenuEntry.java
deleted file mode 100644
index f8ab3a6..0000000
--- a/src/net/java/sip/communicator/plugin/profiler4j/SettingsWindowMenuEntry.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.profiler4j;
-
-import java.awt.event.*;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.sf.profiler4j.console.*;
-
-/**
- * Menu entry for the profiler plug-in
- *
- * @author Vladimir Skarupelov
- */
-public class SettingsWindowMenuEntry
- extends AbstractPluginComponent
-{
- private static final String PROFILER_NAME = "plugin.profiler.PLUGIN_NAME";
- private JMenuItem settingsMenuEntry;
-
- public SettingsWindowMenuEntry(Container container,
- PluginComponentFactory parentFactory)
- {
- super(container, parentFactory);
-
- settingsMenuEntry = new JMenuItem(Resources.getString( PROFILER_NAME ));
- settingsMenuEntry.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- Prefs prefs = new Prefs();
-
- System.setProperty("swing.aatext",
- String.valueOf(prefs.isAntialiasing()));
-
- final Console app = new Console(prefs);
- app.connect();
- MainFrame f = new MainFrame(app);
- app.setMainFrame(f);
- f.pack();
- f.setVisible(true);
- }
- });
- }
-
- public Object getComponent()
- {
- return settingsMenuEntry;
- }
-
- public String getName()
- {
- return Resources.getString( PROFILER_NAME );
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/profiler4j/profiler4j.manifest.mf b/src/net/java/sip/communicator/plugin/profiler4j/profiler4j.manifest.mf
deleted file mode 100644
index 9e3ebf4..0000000
--- a/src/net/java/sip/communicator/plugin/profiler4j/profiler4j.manifest.mf
+++ /dev/null
@@ -1,24 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.plugin.profiler4j.ProfilerActivator
-Bundle-Name: Integrated profiler plugin
-Bundle-Description: A bundle that provides profile cpu and memory of the running app.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.plugin.profiler4j
-Import-Package: org.apache.commons.logging,
- org.osgi.framework,
- org.xml.sax,
- org.xml.sax.ext,
- org.xml.sax.helpers,
- net.java.sip.communicator.service.contactlist,
- net.java.sip.communicator.service.gui,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.util,
- javax.swing,
- javax.swing.border,
- javax.swing.event,
- javax.swing.filechooser,
- javax.swing.table,
- javax.swing.text,
- javax.swing.tree,
- javax.xml.parsers
diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java
index b8d6a2a..e1213ce 100644
--- a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java
+++ b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,736 +15,736 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.simpleaccreg;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-import java.util.*;
-import java.util.List;
-
-import javax.imageio.*;
-import javax.swing.*;
-import javax.swing.text.*;
-
-import net.java.sip.communicator.service.contactlist.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-import org.jitsi.service.configuration.*;
-import org.osgi.framework.*;
-
-/**
- * The <tt>NoAccountFoundPage</tt> is the page shown in the account
- * registration wizard shown in the beginning of the program, when no registered
- * accounts are found.
- *
- * @author Yana Stamcheva
- * @author Lubomir Marinov
- */
-public class InitialAccountRegistrationFrame
- extends SIPCommFrame
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private ConfigurationService configurationService;
-
- /**
- * The <tt>Logger</tt> used by this <tt>InitialAccountRegistrationFrame</tt>
- * for logging output.
- */
- private final Logger logger
- = Logger.getLogger(InitialAccountRegistrationFrame.class);
-
- private final TransparentPanel mainAccountsPanel
- = new TransparentPanel(new BorderLayout(10, 10));
-
- private final TransparentPanel accountsPanel
- = new TransparentPanel(new GridLayout(0, 2, 10, 10));
-
- private final TransparentPanel southPanel
- = new TransparentPanel(new BorderLayout());
-
- private final JButton signinButton
- = new JButton(Resources.getString("service.gui.SIGN_IN"));
-
- private final Collection<AccountRegistrationPanel> registrationForms =
- new Vector<AccountRegistrationPanel>();
-
- /**
- * Creates an instance of <tt>NoAccountFoundPage</tt>.
- */
- public InitialAccountRegistrationFrame()
- {
- super(false);
- setDefaultCloseOperation(DISPOSE_ON_CLOSE);
-
- TransparentPanel mainPanel
- = new TransparentPanel(new BorderLayout());
- mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
- southPanel.add(buttonPanel, BorderLayout.EAST);
- JButton cancelButton
- = new JButton(Resources.getString("service.gui.CANCEL"));
-
- this.setTitle(Resources.getString("service.gui.SIGN_IN"));
-
- this.setIconImage(
- Resources.getImage("service.gui.SIP_COMMUNICATOR_LOGO").getImage());
-
- // In order to have the same icon when using option panes
- JOptionPane.getRootFrame().setIconImage(
- Resources.getImage("service.gui.SIP_COMMUNICATOR_LOGO").getImage());
-
- mainAccountsPanel.setBorder(
- BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- this.getContentPane().add(mainPanel);
-
- mainPanel.add(createTitleComponent(), BorderLayout.NORTH);
- JScrollPane scroller = new JScrollPane(mainAccountsPanel);
- scroller.setOpaque(false);
- scroller.getViewport().setOpaque(false);
- mainPanel.add(scroller, BorderLayout.CENTER);
- mainPanel.add(southPanel, BorderLayout.SOUTH);
-
- mainAccountsPanel.add(accountsPanel, BorderLayout.CENTER);
-
- initProvisioningPanel();
-
- mainAccountsPanel.setOpaque(false);
- accountsPanel.setOpaque(false);
- buttonPanel.setOpaque(false);
-
- SigninActionListener actionListener = new SigninActionListener();
-
- signinButton.addActionListener(actionListener);
- cancelButton.addActionListener(actionListener);
-
- buttonPanel.add(signinButton);
- buttonPanel.add(cancelButton);
-
- this.getRootPane().setDefaultButton(signinButton);
-
- this.initAccountWizards();
-
- // Create the default group
- String groupName
- = Resources.getApplicationProperty("impl.gui.DEFAULT_GROUP_NAME");
-
- if(groupName != null && groupName.length() > 0)
- {
- MetaContactListService contactList =
- SimpleAccountRegistrationActivator.getContactList();
- Iterator<MetaContactGroup> iter
- = contactList.getRoot().getSubgroups();
- while (iter.hasNext())
- {
- MetaContactGroup gr = iter.next();
- if (groupName.equals(gr.getGroupName()))
- return;
- }
-
- contactList
- .createMetaContactGroup(contactList.getRoot(), groupName);
-
- getConfigurationService()
- .setProperty(
- "net.java.sip.communicator.impl.gui.addcontact.lastContactParent",
- groupName);
- }
-
- this.getRootPane().validate();
- this.pack();
-
- // if the screen height is sufficiently large, expand the window size
- // so that no scrolling is needed
- if (scroller.getViewport().getHeight()
- < Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 230)
- {
- this.setSize(scroller.getViewport().getWidth() + 100,
- scroller.getViewport().getHeight() + 150);
- }
- else
- {
- // otherwise add some width so that no horizontal scrolling is
- // needed
- this.setSize(this.getSize().width + 20,
- this.getSize().height - 10);
- }
- }
-
- /**
- * Initializes the provisioning panel.
- */
- private void initProvisioningPanel()
- {
- String isInitialProv = SimpleAccountRegistrationActivator.getResources()
- .getSettingsString(
- "plugin.provisioning.IS_INITIAL_PROVISIONING_LINK");
-
- if (isInitialProv != null && isInitialProv.length() > 0
- && !Boolean.parseBoolean(isInitialProv))
- return;
-
- String useProvisioningString = SimpleAccountRegistrationActivator
- .getResources().getI18NString("service.gui.USE_PROVISIONING");
-
- final JLabel provisioningLabel =
- new JLabel("<html><a href=''>"
- + useProvisioningString
- + "</a></html>");
-
- provisioningLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
- provisioningLabel.setToolTipText(useProvisioningString);
-
- provisioningLabel.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mousePressed(MouseEvent e)
- {
- ConfigurationContainer configContainer
- = SimpleAccountRegistrationActivator.getUIService()
- .getConfigurationContainer();
-
- ConfigurationForm advancedConfigForm
- = SimpleAccountRegistrationActivator.getAdvancedConfigForm();
-
- if (advancedConfigForm != null)
- {
- configContainer.setSelected(advancedConfigForm);
-
- if (advancedConfigForm instanceof ConfigurationContainer)
- {
- ConfigurationForm provisioningForm
- = SimpleAccountRegistrationActivator
- .getProvisioningConfigForm();
-
- if (provisioningForm != null)
- {
- ((ConfigurationContainer) advancedConfigForm)
- .setSelected(provisioningForm);
- }
- }
- }
-
- configContainer.setVisible(true);
- }
- });
-
- southPanel.add(provisioningLabel, BorderLayout.WEST);
- }
-
- private void initAccountWizards()
- {
- String simpleWizards
- = SimpleAccountRegistrationActivator.getConfigService()
- .getString("plugin.simpleaccreg.PROTOCOL_ORDER");
-
- StringTokenizer tokenizer = new StringTokenizer(simpleWizards, "|");
-
- ServiceReference[] serviceRefs = null;
- while (tokenizer.hasMoreTokens())
- {
- String protocolToken = tokenizer.nextToken();
-
- String osgiFilter = "("
- + ProtocolProviderFactory.PROTOCOL
- + "="+protocolToken+")";
-
- try
- {
- serviceRefs = SimpleAccountRegistrationActivator.bundleContext
- .getServiceReferences(
- AccountRegistrationWizard.class.getName(), osgiFilter);
-
- if (serviceRefs != null && serviceRefs.length > 0)
- {
- AccountRegistrationWizard wizard
- = (AccountRegistrationWizard)
-
- SimpleAccountRegistrationActivator
- .bundleContext.getService(serviceRefs[0]);
-
- this.addAccountRegistrationForm(wizard);
- }
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error("GuiActivator : ", ex);
- }
- }
- }
-
- /**
- * The account registration panel.
- */
- private class AccountRegistrationPanel
- extends JPanel
- {
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private JLabel usernameLabel
- = new JLabel(Resources.getString(
- "plugin.simpleaccregwizz.LOGIN_USERNAME"));
-
- private JLabel passwordLabel
- = new JLabel(Resources.getString("service.gui.PASSWORD"));
-
- private JTextField usernameField = new JTextField();
-
- private JLabel usernameExampleLabel = new JLabel();
-
- private JPasswordField passwordField = new JPasswordField();
-
- private JPanel labelsPanel = new JPanel(new GridLayout(0, 1, 5, 0));
-
- private JPanel fieldsPanel = new JPanel(new GridLayout(0, 1, 5, 0));
-
- private JPanel emptyPanel = new JPanel();
-
- private JPanel inputPanel = new JPanel(new BorderLayout(5, 5));
-
- private JPanel iconDescriptionPanel = new JPanel(new BorderLayout());
-
- private JTextArea descriptionArea = new JTextArea();
-
- private final AccountRegistrationWizard wizard;
-
- public AccountRegistrationPanel(
- AccountRegistrationWizard accountWizard,
- boolean isPreferredWizard)
- {
- super(new BorderLayout(5, 5));
-
- this.wizard = accountWizard;
-
- // Obtain the simple form in order to initialize all predefined
- // values.
- // TODO: Use the simple form instead of creating new fields and
- // panels here.
- wizard.getSimpleForm(false);
-
- JLabel protocolLabel = new JLabel();
- JPanel inputRegisterPanel = new JPanel(new BorderLayout());
-
- this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- this.setOpaque(false);
-
- this.inputPanel.setOpaque(false);
- this.labelsPanel.setOpaque(false);
- this.fieldsPanel.setOpaque(false);
- this.emptyPanel.setOpaque(false);
- inputRegisterPanel.setOpaque(false);
- this.iconDescriptionPanel.setOpaque(false);
-
- this.add(inputRegisterPanel, BorderLayout.CENTER);
-
- inputRegisterPanel.add(inputPanel, BorderLayout.NORTH);
-
- if (((wizard instanceof ExtendedAccountRegistrationWizard)
- && ((ExtendedAccountRegistrationWizard) wizard)
- .isSignupSupported()) || wizard.isWebSignupSupported())
- {
- String textKey =
- isPreferredWizard ? "plugin.simpleaccregwizz.SPECIAL_SIGNUP"
- : "plugin.simpleaccregwizz.SIGNUP";
- JLabel signupLabel =
- new JLabel("<html><a href=''>"
- + Resources.getString(textKey) + "</a></html>",
- JLabel.RIGHT);
-
- signupLabel.setFont(signupLabel.getFont().deriveFont(10f));
- signupLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
- signupLabel.setToolTipText(
- Resources.getString(
- "plugin.simpleaccregwizz.SPECIAL_SIGNUP"));
- signupLabel.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mousePressed(MouseEvent e)
- {
- try
- {
- if ((wizard
- instanceof ExtendedAccountRegistrationWizard)
- && ((ExtendedAccountRegistrationWizard) wizard)
- .isSignupSupported())
- {
- showCreateAccountWindow(wizard);
- dispose();
- }
- else if (wizard.isWebSignupSupported())
- {
- wizard.webSignup();
- }
- }
- catch (UnsupportedOperationException ex)
- {
- // This should not happen, because we check if the
- // operation is supported, before adding the sign
- // up.
- logger.error("The web sign up is not supported.",
- ex);
- }
- }
- });
-
- inputRegisterPanel.add(signupLabel, BorderLayout.SOUTH);
- }
-
- this.inputPanel.add(labelsPanel, BorderLayout.WEST);
-
- this.inputPanel.add(fieldsPanel, BorderLayout.CENTER);
-
- this.iconDescriptionPanel.add(
- protocolLabel, BorderLayout.NORTH);
-
- protocolLabel.setFont(
- protocolLabel.getFont().deriveFont(Font.BOLD, 14f));
- this.usernameExampleLabel.setForeground(Color.DARK_GRAY);
- this.usernameExampleLabel.setFont(
- usernameExampleLabel.getFont().deriveFont(8f));
- this.emptyPanel.setMaximumSize(new Dimension(40, 25));
-
- this.labelsPanel.add(usernameLabel);
- this.labelsPanel.add(emptyPanel);
- this.labelsPanel.add(passwordLabel);
-
- this.fieldsPanel.add(usernameField);
- this.fieldsPanel.add(usernameExampleLabel);
- this.fieldsPanel.add(passwordField);
-
- this.usernameExampleLabel.setText(wizard.getUserNameExample());
-
- protocolLabel.setText(wizard.getProtocolName());
-
- Image image = null;
- try
- {
- image = ImageIO.read(
- new ByteArrayInputStream(wizard.getPageImage()));
- }
- catch (IOException e)
- {
- logger.error("Unable to load image.", e);
- }
-
- if (image != null)
- {
- image = image.getScaledInstance(28, 28, Image.SCALE_SMOOTH);
-
- protocolLabel.setIcon(new ImageIcon(image));
- }
-
- if (isPreferredWizard)
- {
- descriptionArea.setBorder(BorderFactory
- .createEmptyBorder(10, 0, 0, 0));
-
- descriptionArea.setFont(
- descriptionArea.getFont().deriveFont(10f));
- descriptionArea.setPreferredSize(new Dimension(220, 50));
- descriptionArea.setLineWrap(true);
- descriptionArea.setWrapStyleWord(true);
- descriptionArea.setText(wizard.getProtocolDescription());
- descriptionArea.setEditable(false);
- descriptionArea.setOpaque(false);
-
- this.iconDescriptionPanel.add(
- descriptionArea, BorderLayout.CENTER);
-
- this.add(iconDescriptionPanel, BorderLayout.WEST);
- }
- else
- {
- this.add(iconDescriptionPanel, BorderLayout.NORTH);
- }
- }
-
- @Override
- public void paintComponent(Graphics g)
- {
- // do the superclass behavior first
- super.paintComponent(g);
-
- g = g.create();
- try
- {
- AntialiasingManager.activateAntialiasing(g);
-
- Graphics2D g2d = (Graphics2D) g;
-
- // paint the background with the chosen color
- g2d.setColor(Color.GRAY);
- g2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 15, 15);
- }
- finally
- {
- g.dispose();
- }
- }
-
- public boolean isFilled()
- {
- String username = usernameField.getText();
- return (username != null) && (username.length() > 0);
- }
-
- public void signin() throws OperationFailedException
- {
- ProtocolProviderService protocolProvider =
- wizard.signin(usernameField.getText(), new String(passwordField
- .getPassword()));
-
- saveAccountWizard(protocolProvider, wizard);
- }
- }
-
- /**
- * Adds a simple account registration form corresponding to the given
- * <tt>AccountRegistrationWizard</tt>.
- *
- * @param wizard the <tt>AccountRegistrationWizard</tt>, which gives us
- * information to fill our simple form.
- */
- private void addAccountRegistrationForm(AccountRegistrationWizard wizard)
- {
- // We don't need to add wizards that are not interested in a
- // simple sign in form.
- if (!wizard.isSimpleFormEnabled())
- return;
-
- String preferredWizardName
- = Resources.getLoginProperty("impl.gui.PREFERRED_ACCOUNT_WIZARD");
-
- AccountRegistrationPanel accountPanel;
-
- if (preferredWizardName != null
- && preferredWizardName.equals(wizard.getClass().getName()))
- {
- accountPanel = new AccountRegistrationPanel(wizard, true);
-
- mainAccountsPanel.add(
- accountPanel,
- BorderLayout.NORTH);
-
- mainAccountsPanel.validate();
- }
- else
- {
- accountPanel = new AccountRegistrationPanel(wizard, false);
-
- accountsPanel.add(accountPanel);
-
- accountsPanel.validate();
- }
-
- this.registrationForms.add(accountPanel);
- }
-
- /**
- * Handles the event triggered by the "service.gui.SIGN_IN" button.
- */
- private class SigninActionListener implements ActionListener
- {
- public void actionPerformed(ActionEvent evt)
- {
- JButton button = (JButton) evt.getSource();
-
- if (button.equals(signinButton))
- {
- Iterator<AccountRegistrationPanel> regIterator =
- registrationForms.iterator();
-
- if (regIterator.hasNext())
- setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
- while(regIterator.hasNext())
- {
- AccountRegistrationPanel regForm = regIterator.next();
-
- try
- {
- if (regForm.isFilled())
- regForm.signin();
- }
- catch (OperationFailedException e)
- {
- if (logger.isDebugEnabled())
- logger.debug("The sign in operation has failed.");
-
- PopupDialog popupDialog
- = SimpleAccountRegistrationActivator.getUIService()
- .getPopupDialog();
-
- if (e.getErrorCode()
- == OperationFailedException.ILLEGAL_ARGUMENT)
- {
- popupDialog.showMessagePopupDialog(
- Resources.getString(
- "service.gui.USERNAME_NULL"),
- Resources.getString(
- "service.gui.ERROR"),
- PopupDialog.ERROR_MESSAGE);
- }
- else if (e.getErrorCode()
- == OperationFailedException
- .IDENTIFICATION_CONFLICT)
- {
- popupDialog.showMessagePopupDialog(
- Resources.getString(
- "service.gui.USER_EXISTS_ERROR"),
- Resources.getString(
- "service.gui.ERROR"),
- PopupDialog.ERROR_MESSAGE);
- }
- else if (e.getErrorCode()
- == OperationFailedException
- .SERVER_NOT_SPECIFIED)
- {
- popupDialog.showMessagePopupDialog(
- Resources.getString(
- "service.gui.SPECIFY_SERVER"),
- Resources.getString(
- "service.gui.ERROR"),
- PopupDialog.ERROR_MESSAGE);
- }
- }
- }
- }
-
- InitialAccountRegistrationFrame initialAccountRegistrationFrame =
- InitialAccountRegistrationFrame.this;
- initialAccountRegistrationFrame.setVisible(false);
- initialAccountRegistrationFrame.dispose();
- }
- }
-
- /**
- * Saves the (protocol provider, wizard) pair in through the
- * <tt>ConfigurationService</tt>.
- *
- * @param protocolProvider the protocol provider to save
- * @param wizard the wizard to save
- */
- private void saveAccountWizard(ProtocolProviderService protocolProvider,
- AccountRegistrationWizard wizard)
- {
- String prefix = "net.java.sip.communicator.impl.gui.accounts";
-
- ConfigurationService configService = getConfigurationService();
-
- List<String> accounts = configService.getPropertyNamesByPrefix(prefix, true);
- boolean savedAccount = false;
-
- for (String accountRootPropName : accounts)
- {
- String accountUID = configService.getString(accountRootPropName);
-
- if (accountUID.equals(protocolProvider.getAccountID()
- .getAccountUniqueID()))
- {
-
- configService.setProperty(accountRootPropName + ".wizard",
- wizard.getClass().getName().replace('.', '_'));
-
- savedAccount = true;
- }
- }
-
- if (!savedAccount)
- {
- String accNodeName =
- "acc" + Long.toString(System.currentTimeMillis());
-
- String accountPackage =
- "net.java.sip.communicator.impl.gui.accounts." + accNodeName;
-
- configService.setProperty(accountPackage, protocolProvider
- .getAccountID().getAccountUniqueID());
-
- configService.setProperty(accountPackage + ".wizard", wizard);
- }
- }
-
- /**
- * Returns the <tt>ConfigurationService</tt>.
- *
- * @return the <tt>ConfigurationService</tt>
- */
- public ConfigurationService getConfigurationService()
- {
- if (configurationService == null)
- {
- BundleContext bundleContext =
- SimpleAccountRegistrationActivator.bundleContext;
- ServiceReference configReference =
- bundleContext.getServiceReference(ConfigurationService.class
- .getName());
-
- configurationService =
- (ConfigurationService) bundleContext
- .getService(configReference);
- }
- return configurationService;
- }
-
- /**
- * Creates the title component.
- * @return the newly created title component
- */
- private JComponent createTitleComponent()
- {
- JTextPane titlePane = new JTextPane();
- SimpleAttributeSet aSet = new SimpleAttributeSet();
- StyleConstants.setAlignment(aSet, StyleConstants.ALIGN_CENTER);
- StyleConstants.setBold(aSet, true);
- StyleConstants.setFontFamily(aSet, titlePane.getFont().getFamily());
-
- titlePane.setParagraphAttributes(aSet, true);
- titlePane.setEditable(false);
- titlePane.setText(Resources.getString(
- "plugin.simpleaccregwizz.INITIAL_ACCOUNT_REGISTRATION"));
- titlePane.setOpaque(false);
-
- return titlePane;
- }
-
- /**
- * Show the create account window for the given wizard.
- *
- * @param wizard the <tt>AccountRegistrationWizard</tt>, for which we're
- * opening the window
- */
- private void showCreateAccountWindow(AccountRegistrationWizard wizard)
- {
- CreateAccountWindow createAccountWindow
- = SimpleAccountRegistrationActivator
- .getUIService().getCreateAccountWindow();
-
- createAccountWindow.setSelectedWizard(wizard, true);
-
- if (wizard instanceof ExtendedAccountRegistrationWizard)
- {
- ((ExtendedAccountRegistrationWizard) wizard).setCreateAccountView();
- }
-
- createAccountWindow.setVisible(true);
- }
-
- @Override
- protected void close(boolean isEscaped)
- {
- }
-}
+package net.java.sip.communicator.plugin.simpleaccreg;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.io.*;
+import java.util.*;
+import java.util.List;
+
+import javax.imageio.*;
+import javax.swing.*;
+import javax.swing.text.*;
+
+import net.java.sip.communicator.service.contactlist.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+import net.java.sip.communicator.plugin.desktoputil.*;
+
+import org.jitsi.service.configuration.*;
+import org.osgi.framework.*;
+
+/**
+ * The <tt>NoAccountFoundPage</tt> is the page shown in the account
+ * registration wizard shown in the beginning of the program, when no registered
+ * accounts are found.
+ *
+ * @author Yana Stamcheva
+ * @author Lubomir Marinov
+ */
+public class InitialAccountRegistrationFrame
+ extends SIPCommFrame
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ private ConfigurationService configurationService;
+
+ /**
+ * The <tt>Logger</tt> used by this <tt>InitialAccountRegistrationFrame</tt>
+ * for logging output.
+ */
+ private final Logger logger
+ = Logger.getLogger(InitialAccountRegistrationFrame.class);
+
+ private final TransparentPanel mainAccountsPanel
+ = new TransparentPanel(new BorderLayout(10, 10));
+
+ private final TransparentPanel accountsPanel
+ = new TransparentPanel(new GridLayout(0, 2, 10, 10));
+
+ private final TransparentPanel southPanel
+ = new TransparentPanel(new BorderLayout());
+
+ private final JButton signinButton
+ = new JButton(Resources.getString("service.gui.SIGN_IN"));
+
+ private final Collection<AccountRegistrationPanel> registrationForms =
+ new Vector<AccountRegistrationPanel>();
+
+ /**
+ * Creates an instance of <tt>NoAccountFoundPage</tt>.
+ */
+ public InitialAccountRegistrationFrame()
+ {
+ super(false);
+ setDefaultCloseOperation(DISPOSE_ON_CLOSE);
+
+ TransparentPanel mainPanel
+ = new TransparentPanel(new BorderLayout());
+ mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+
+ JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+ southPanel.add(buttonPanel, BorderLayout.EAST);
+ JButton cancelButton
+ = new JButton(Resources.getString("service.gui.CANCEL"));
+
+ this.setTitle(Resources.getString("service.gui.SIGN_IN"));
+
+ this.setIconImage(
+ Resources.getImage("service.gui.SIP_COMMUNICATOR_LOGO").getImage());
+
+ // In order to have the same icon when using option panes
+ JOptionPane.getRootFrame().setIconImage(
+ Resources.getImage("service.gui.SIP_COMMUNICATOR_LOGO").getImage());
+
+ mainAccountsPanel.setBorder(
+ BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ this.getContentPane().add(mainPanel);
+
+ mainPanel.add(createTitleComponent(), BorderLayout.NORTH);
+ JScrollPane scroller = new JScrollPane(mainAccountsPanel);
+ scroller.setOpaque(false);
+ scroller.getViewport().setOpaque(false);
+ mainPanel.add(scroller, BorderLayout.CENTER);
+ mainPanel.add(southPanel, BorderLayout.SOUTH);
+
+ mainAccountsPanel.add(accountsPanel, BorderLayout.CENTER);
+
+ initProvisioningPanel();
+
+ mainAccountsPanel.setOpaque(false);
+ accountsPanel.setOpaque(false);
+ buttonPanel.setOpaque(false);
+
+ SigninActionListener actionListener = new SigninActionListener();
+
+ signinButton.addActionListener(actionListener);
+ cancelButton.addActionListener(actionListener);
+
+ buttonPanel.add(signinButton);
+ buttonPanel.add(cancelButton);
+
+ this.getRootPane().setDefaultButton(signinButton);
+
+ this.initAccountWizards();
+
+ // Create the default group
+ String groupName
+ = Resources.getApplicationProperty("impl.gui.DEFAULT_GROUP_NAME");
+
+ if(groupName != null && groupName.length() > 0)
+ {
+ MetaContactListService contactList =
+ SimpleAccountRegistrationActivator.getContactList();
+ Iterator<MetaContactGroup> iter
+ = contactList.getRoot().getSubgroups();
+ while (iter.hasNext())
+ {
+ MetaContactGroup gr = iter.next();
+ if (groupName.equals(gr.getGroupName()))
+ return;
+ }
+
+ contactList
+ .createMetaContactGroup(contactList.getRoot(), groupName);
+
+ getConfigurationService()
+ .setProperty(
+ "net.java.sip.communicator.impl.gui.addcontact.lastContactParent",
+ groupName);
+ }
+
+ this.getRootPane().validate();
+ this.pack();
+
+ // if the screen height is sufficiently large, expand the window size
+ // so that no scrolling is needed
+ if (scroller.getViewport().getHeight()
+ < Toolkit.getDefaultToolkit().getScreenSize().getHeight() - 230)
+ {
+ this.setSize(scroller.getViewport().getWidth() + 100,
+ scroller.getViewport().getHeight() + 150);
+ }
+ else
+ {
+ // otherwise add some width so that no horizontal scrolling is
+ // needed
+ this.setSize(this.getSize().width + 20,
+ this.getSize().height - 10);
+ }
+ }
+
+ /**
+ * Initializes the provisioning panel.
+ */
+ private void initProvisioningPanel()
+ {
+ String isInitialProv = SimpleAccountRegistrationActivator.getResources()
+ .getSettingsString(
+ "plugin.provisioning.IS_INITIAL_PROVISIONING_LINK");
+
+ if (isInitialProv != null && isInitialProv.length() > 0
+ && !Boolean.parseBoolean(isInitialProv))
+ return;
+
+ String useProvisioningString = SimpleAccountRegistrationActivator
+ .getResources().getI18NString("service.gui.USE_PROVISIONING");
+
+ final JLabel provisioningLabel =
+ new JLabel("<html><a href=''>"
+ + useProvisioningString
+ + "</a></html>");
+
+ provisioningLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ provisioningLabel.setToolTipText(useProvisioningString);
+
+ provisioningLabel.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ ConfigurationContainer configContainer
+ = SimpleAccountRegistrationActivator.getUIService()
+ .getConfigurationContainer();
+
+ ConfigurationForm advancedConfigForm
+ = SimpleAccountRegistrationActivator.getAdvancedConfigForm();
+
+ if (advancedConfigForm != null)
+ {
+ configContainer.setSelected(advancedConfigForm);
+
+ if (advancedConfigForm instanceof ConfigurationContainer)
+ {
+ ConfigurationForm provisioningForm
+ = SimpleAccountRegistrationActivator
+ .getProvisioningConfigForm();
+
+ if (provisioningForm != null)
+ {
+ ((ConfigurationContainer) advancedConfigForm)
+ .setSelected(provisioningForm);
+ }
+ }
+ }
+
+ configContainer.setVisible(true);
+ }
+ });
+
+ southPanel.add(provisioningLabel, BorderLayout.WEST);
+ }
+
+ private void initAccountWizards()
+ {
+ String simpleWizards
+ = SimpleAccountRegistrationActivator.getConfigService()
+ .getString("plugin.simpleaccreg.PROTOCOL_ORDER");
+
+ StringTokenizer tokenizer = new StringTokenizer(simpleWizards, "|");
+
+ ServiceReference[] serviceRefs = null;
+ while (tokenizer.hasMoreTokens())
+ {
+ String protocolToken = tokenizer.nextToken();
+
+ String osgiFilter = "("
+ + ProtocolProviderFactory.PROTOCOL
+ + "="+protocolToken+")";
+
+ try
+ {
+ serviceRefs = SimpleAccountRegistrationActivator.bundleContext
+ .getServiceReferences(
+ AccountRegistrationWizard.class.getName(), osgiFilter);
+
+ if (serviceRefs != null && serviceRefs.length > 0)
+ {
+ AccountRegistrationWizard wizard
+ = (AccountRegistrationWizard)
+
+ SimpleAccountRegistrationActivator
+ .bundleContext.getService(serviceRefs[0]);
+
+ this.addAccountRegistrationForm(wizard);
+ }
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ logger.error("GuiActivator : ", ex);
+ }
+ }
+ }
+
+ /**
+ * The account registration panel.
+ */
+ private class AccountRegistrationPanel
+ extends JPanel
+ {
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ private JLabel usernameLabel
+ = new JLabel(Resources.getString(
+ "plugin.simpleaccregwizz.LOGIN_USERNAME"));
+
+ private JLabel passwordLabel
+ = new JLabel(Resources.getString("service.gui.PASSWORD"));
+
+ private JTextField usernameField = new JTextField();
+
+ private JLabel usernameExampleLabel = new JLabel();
+
+ private JPasswordField passwordField = new JPasswordField();
+
+ private JPanel labelsPanel = new JPanel(new GridLayout(0, 1, 5, 0));
+
+ private JPanel fieldsPanel = new JPanel(new GridLayout(0, 1, 5, 0));
+
+ private JPanel emptyPanel = new JPanel();
+
+ private JPanel inputPanel = new JPanel(new BorderLayout(5, 5));
+
+ private JPanel iconDescriptionPanel = new JPanel(new BorderLayout());
+
+ private JTextArea descriptionArea = new JTextArea();
+
+ private final AccountRegistrationWizard wizard;
+
+ public AccountRegistrationPanel(
+ AccountRegistrationWizard accountWizard,
+ boolean isPreferredWizard)
+ {
+ super(new BorderLayout(5, 5));
+
+ this.wizard = accountWizard;
+
+ // Obtain the simple form in order to initialize all predefined
+ // values.
+ // TODO: Use the simple form instead of creating new fields and
+ // panels here.
+ wizard.getSimpleForm(false);
+
+ JLabel protocolLabel = new JLabel();
+ JPanel inputRegisterPanel = new JPanel(new BorderLayout());
+
+ this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ this.setOpaque(false);
+
+ this.inputPanel.setOpaque(false);
+ this.labelsPanel.setOpaque(false);
+ this.fieldsPanel.setOpaque(false);
+ this.emptyPanel.setOpaque(false);
+ inputRegisterPanel.setOpaque(false);
+ this.iconDescriptionPanel.setOpaque(false);
+
+ this.add(inputRegisterPanel, BorderLayout.CENTER);
+
+ inputRegisterPanel.add(inputPanel, BorderLayout.NORTH);
+
+ if (((wizard instanceof ExtendedAccountRegistrationWizard)
+ && ((ExtendedAccountRegistrationWizard) wizard)
+ .isSignupSupported()) || wizard.isWebSignupSupported())
+ {
+ String textKey =
+ isPreferredWizard ? "plugin.simpleaccregwizz.SPECIAL_SIGNUP"
+ : "plugin.simpleaccregwizz.SIGNUP";
+ JLabel signupLabel =
+ new JLabel("<html><a href=''>"
+ + Resources.getString(textKey) + "</a></html>",
+ JLabel.RIGHT);
+
+ signupLabel.setFont(signupLabel.getFont().deriveFont(10f));
+ signupLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
+ signupLabel.setToolTipText(
+ Resources.getString(
+ "plugin.simpleaccregwizz.SPECIAL_SIGNUP"));
+ signupLabel.addMouseListener(new MouseAdapter()
+ {
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ try
+ {
+ if ((wizard
+ instanceof ExtendedAccountRegistrationWizard)
+ && ((ExtendedAccountRegistrationWizard) wizard)
+ .isSignupSupported())
+ {
+ showCreateAccountWindow(wizard);
+ dispose();
+ }
+ else if (wizard.isWebSignupSupported())
+ {
+ wizard.webSignup();
+ }
+ }
+ catch (UnsupportedOperationException ex)
+ {
+ // This should not happen, because we check if the
+ // operation is supported, before adding the sign
+ // up.
+ logger.error("The web sign up is not supported.",
+ ex);
+ }
+ }
+ });
+
+ inputRegisterPanel.add(signupLabel, BorderLayout.SOUTH);
+ }
+
+ this.inputPanel.add(labelsPanel, BorderLayout.WEST);
+
+ this.inputPanel.add(fieldsPanel, BorderLayout.CENTER);
+
+ this.iconDescriptionPanel.add(
+ protocolLabel, BorderLayout.NORTH);
+
+ protocolLabel.setFont(
+ protocolLabel.getFont().deriveFont(Font.BOLD, 14f));
+ this.usernameExampleLabel.setForeground(Color.DARK_GRAY);
+ this.usernameExampleLabel.setFont(
+ usernameExampleLabel.getFont().deriveFont(8f));
+ this.emptyPanel.setMaximumSize(new Dimension(40, 25));
+
+ this.labelsPanel.add(usernameLabel);
+ this.labelsPanel.add(emptyPanel);
+ this.labelsPanel.add(passwordLabel);
+
+ this.fieldsPanel.add(usernameField);
+ this.fieldsPanel.add(usernameExampleLabel);
+ this.fieldsPanel.add(passwordField);
+
+ this.usernameExampleLabel.setText(wizard.getUserNameExample());
+
+ protocolLabel.setText(wizard.getProtocolName());
+
+ Image image = null;
+ try
+ {
+ image = ImageIO.read(
+ new ByteArrayInputStream(wizard.getPageImage()));
+ }
+ catch (IOException e)
+ {
+ logger.error("Unable to load image.", e);
+ }
+
+ if (image != null)
+ {
+ image = image.getScaledInstance(28, 28, Image.SCALE_SMOOTH);
+
+ protocolLabel.setIcon(new ImageIcon(image));
+ }
+
+ if (isPreferredWizard)
+ {
+ descriptionArea.setBorder(BorderFactory
+ .createEmptyBorder(10, 0, 0, 0));
+
+ descriptionArea.setFont(
+ descriptionArea.getFont().deriveFont(10f));
+ descriptionArea.setPreferredSize(new Dimension(220, 50));
+ descriptionArea.setLineWrap(true);
+ descriptionArea.setWrapStyleWord(true);
+ descriptionArea.setText(wizard.getProtocolDescription());
+ descriptionArea.setEditable(false);
+ descriptionArea.setOpaque(false);
+
+ this.iconDescriptionPanel.add(
+ descriptionArea, BorderLayout.CENTER);
+
+ this.add(iconDescriptionPanel, BorderLayout.WEST);
+ }
+ else
+ {
+ this.add(iconDescriptionPanel, BorderLayout.NORTH);
+ }
+ }
+
+ @Override
+ public void paintComponent(Graphics g)
+ {
+ // do the superclass behavior first
+ super.paintComponent(g);
+
+ g = g.create();
+ try
+ {
+ AntialiasingManager.activateAntialiasing(g);
+
+ Graphics2D g2d = (Graphics2D) g;
+
+ // paint the background with the chosen color
+ g2d.setColor(Color.GRAY);
+ g2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, 15, 15);
+ }
+ finally
+ {
+ g.dispose();
+ }
+ }
+
+ public boolean isFilled()
+ {
+ String username = usernameField.getText();
+ return (username != null) && (username.length() > 0);
+ }
+
+ public void signin() throws OperationFailedException
+ {
+ ProtocolProviderService protocolProvider =
+ wizard.signin(usernameField.getText(), new String(passwordField
+ .getPassword()));
+
+ saveAccountWizard(protocolProvider, wizard);
+ }
+ }
+
+ /**
+ * Adds a simple account registration form corresponding to the given
+ * <tt>AccountRegistrationWizard</tt>.
+ *
+ * @param wizard the <tt>AccountRegistrationWizard</tt>, which gives us
+ * information to fill our simple form.
+ */
+ private void addAccountRegistrationForm(AccountRegistrationWizard wizard)
+ {
+ // We don't need to add wizards that are not interested in a
+ // simple sign in form.
+ if (!wizard.isSimpleFormEnabled())
+ return;
+
+ String preferredWizardName
+ = Resources.getLoginProperty("impl.gui.PREFERRED_ACCOUNT_WIZARD");
+
+ AccountRegistrationPanel accountPanel;
+
+ if (preferredWizardName != null
+ && preferredWizardName.equals(wizard.getClass().getName()))
+ {
+ accountPanel = new AccountRegistrationPanel(wizard, true);
+
+ mainAccountsPanel.add(
+ accountPanel,
+ BorderLayout.NORTH);
+
+ mainAccountsPanel.validate();
+ }
+ else
+ {
+ accountPanel = new AccountRegistrationPanel(wizard, false);
+
+ accountsPanel.add(accountPanel);
+
+ accountsPanel.validate();
+ }
+
+ this.registrationForms.add(accountPanel);
+ }
+
+ /**
+ * Handles the event triggered by the "service.gui.SIGN_IN" button.
+ */
+ private class SigninActionListener implements ActionListener
+ {
+ public void actionPerformed(ActionEvent evt)
+ {
+ JButton button = (JButton) evt.getSource();
+
+ if (button.equals(signinButton))
+ {
+ Iterator<AccountRegistrationPanel> regIterator =
+ registrationForms.iterator();
+
+ if (regIterator.hasNext())
+ setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ while(regIterator.hasNext())
+ {
+ AccountRegistrationPanel regForm = regIterator.next();
+
+ try
+ {
+ if (regForm.isFilled())
+ regForm.signin();
+ }
+ catch (OperationFailedException e)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("The sign in operation has failed.");
+
+ PopupDialog popupDialog
+ = SimpleAccountRegistrationActivator.getUIService()
+ .getPopupDialog();
+
+ if (e.getErrorCode()
+ == OperationFailedException.ILLEGAL_ARGUMENT)
+ {
+ popupDialog.showMessagePopupDialog(
+ Resources.getString(
+ "service.gui.USERNAME_NULL"),
+ Resources.getString(
+ "service.gui.ERROR"),
+ PopupDialog.ERROR_MESSAGE);
+ }
+ else if (e.getErrorCode()
+ == OperationFailedException
+ .IDENTIFICATION_CONFLICT)
+ {
+ popupDialog.showMessagePopupDialog(
+ Resources.getString(
+ "service.gui.USER_EXISTS_ERROR"),
+ Resources.getString(
+ "service.gui.ERROR"),
+ PopupDialog.ERROR_MESSAGE);
+ }
+ else if (e.getErrorCode()
+ == OperationFailedException
+ .SERVER_NOT_SPECIFIED)
+ {
+ popupDialog.showMessagePopupDialog(
+ Resources.getString(
+ "service.gui.SPECIFY_SERVER"),
+ Resources.getString(
+ "service.gui.ERROR"),
+ PopupDialog.ERROR_MESSAGE);
+ }
+ }
+ }
+ }
+
+ InitialAccountRegistrationFrame initialAccountRegistrationFrame =
+ InitialAccountRegistrationFrame.this;
+ initialAccountRegistrationFrame.setVisible(false);
+ initialAccountRegistrationFrame.dispose();
+ }
+ }
+
+ /**
+ * Saves the (protocol provider, wizard) pair in through the
+ * <tt>ConfigurationService</tt>.
+ *
+ * @param protocolProvider the protocol provider to save
+ * @param wizard the wizard to save
+ */
+ private void saveAccountWizard(ProtocolProviderService protocolProvider,
+ AccountRegistrationWizard wizard)
+ {
+ String prefix = "net.java.sip.communicator.impl.gui.accounts";
+
+ ConfigurationService configService = getConfigurationService();
+
+ List<String> accounts = configService.getPropertyNamesByPrefix(prefix, true);
+ boolean savedAccount = false;
+
+ for (String accountRootPropName : accounts)
+ {
+ String accountUID = configService.getString(accountRootPropName);
+
+ if (accountUID.equals(protocolProvider.getAccountID()
+ .getAccountUniqueID()))
+ {
+
+ configService.setProperty(accountRootPropName + ".wizard",
+ wizard.getClass().getName().replace('.', '_'));
+
+ savedAccount = true;
+ }
+ }
+
+ if (!savedAccount)
+ {
+ String accNodeName =
+ "acc" + Long.toString(System.currentTimeMillis());
+
+ String accountPackage =
+ "net.java.sip.communicator.impl.gui.accounts." + accNodeName;
+
+ configService.setProperty(accountPackage, protocolProvider
+ .getAccountID().getAccountUniqueID());
+
+ configService.setProperty(accountPackage + ".wizard", wizard);
+ }
+ }
+
+ /**
+ * Returns the <tt>ConfigurationService</tt>.
+ *
+ * @return the <tt>ConfigurationService</tt>
+ */
+ public ConfigurationService getConfigurationService()
+ {
+ if (configurationService == null)
+ {
+ BundleContext bundleContext =
+ SimpleAccountRegistrationActivator.bundleContext;
+ ServiceReference configReference =
+ bundleContext.getServiceReference(ConfigurationService.class
+ .getName());
+
+ configurationService =
+ (ConfigurationService) bundleContext
+ .getService(configReference);
+ }
+ return configurationService;
+ }
+
+ /**
+ * Creates the title component.
+ * @return the newly created title component
+ */
+ private JComponent createTitleComponent()
+ {
+ JTextPane titlePane = new JTextPane();
+ SimpleAttributeSet aSet = new SimpleAttributeSet();
+ StyleConstants.setAlignment(aSet, StyleConstants.ALIGN_CENTER);
+ StyleConstants.setBold(aSet, true);
+ StyleConstants.setFontFamily(aSet, titlePane.getFont().getFamily());
+
+ titlePane.setParagraphAttributes(aSet, true);
+ titlePane.setEditable(false);
+ titlePane.setText(Resources.getString(
+ "plugin.simpleaccregwizz.INITIAL_ACCOUNT_REGISTRATION"));
+ titlePane.setOpaque(false);
+
+ return titlePane;
+ }
+
+ /**
+ * Show the create account window for the given wizard.
+ *
+ * @param wizard the <tt>AccountRegistrationWizard</tt>, for which we're
+ * opening the window
+ */
+ private void showCreateAccountWindow(AccountRegistrationWizard wizard)
+ {
+ CreateAccountWindow createAccountWindow
+ = SimpleAccountRegistrationActivator
+ .getUIService().getCreateAccountWindow();
+
+ createAccountWindow.setSelectedWizard(wizard, true);
+
+ if (wizard instanceof ExtendedAccountRegistrationWizard)
+ {
+ ((ExtendedAccountRegistrationWizard) wizard).setCreateAccountView();
+ }
+
+ createAccountWindow.setVisible(true);
+ }
+
+ @Override
+ protected void close(boolean isEscaped)
+ {
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java b/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java
index 7249e66..f62093f 100644
--- a/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java
+++ b/src/net/java/sip/communicator/plugin/simpleaccreg/Resources.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,92 +15,92 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.simpleaccreg;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.service.resources.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The <tt>Resources</tt> class manages the access to the internationalization
- * properties files and the image resources used in this plugin.
- *
- * @author Yana Stamcheva
- */
-public class Resources
-{
- private static ResourceManagementService resourcesService;
-
- /**
- * 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)
- {
- return getResources().getI18NString(key);
- }
-
- /**
- * Returns an int RGB color corresponding to the given key.
- *
- * @param key The key of the string.
- *
- * @return An internationalized string corresponding to the given key.
- */
- public static int getColor(String key)
- {
- return getResources().getColor(key);
- }
-
- /**
- * Returns the application property corresponding to the given key.
- *
- * @param key The key of the string.
- *
- * @return the application property corresponding to the given key
- */
- public static String getLoginProperty(String key)
- {
- return getResources().getSettingsString(key);
- }
-
- /**
- * Returns the application property corresponding to the given key.
- *
- * @param key The key of the string.
- *
- * @return the application property corresponding to the given key
- */
- public static String getApplicationProperty(String key)
- {
- return getResources().getSettingsString(key);
- }
-
- /**
- * Loads an image from a given image identifier.
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static ImageIcon getImage(String imageID)
- {
- return getResources().getImage(imageID);
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(SimpleAccountRegistrationActivator.bundleContext);
- return resourcesService;
- }
-}
+package net.java.sip.communicator.plugin.simpleaccreg;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.service.resources.*;
+
+import org.jitsi.service.resources.*;
+
+/**
+ * The <tt>Resources</tt> class manages the access to the internationalization
+ * properties files and the image resources used in this plugin.
+ *
+ * @author Yana Stamcheva
+ */
+public class Resources
+{
+ private static ResourceManagementService resourcesService;
+
+ /**
+ * 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)
+ {
+ return getResources().getI18NString(key);
+ }
+
+ /**
+ * Returns an int RGB color corresponding to the given key.
+ *
+ * @param key The key of the string.
+ *
+ * @return An internationalized string corresponding to the given key.
+ */
+ public static int getColor(String key)
+ {
+ return getResources().getColor(key);
+ }
+
+ /**
+ * Returns the application property corresponding to the given key.
+ *
+ * @param key The key of the string.
+ *
+ * @return the application property corresponding to the given key
+ */
+ public static String getLoginProperty(String key)
+ {
+ return getResources().getSettingsString(key);
+ }
+
+ /**
+ * Returns the application property corresponding to the given key.
+ *
+ * @param key The key of the string.
+ *
+ * @return the application property corresponding to the given key
+ */
+ public static String getApplicationProperty(String key)
+ {
+ return getResources().getSettingsString(key);
+ }
+
+ /**
+ * Loads an image from a given image identifier.
+ * @param imageID The identifier of the image.
+ * @return The image for the given identifier.
+ */
+ public static ImageIcon getImage(String imageID)
+ {
+ return getResources().getImage(imageID);
+ }
+
+ /**
+ * Returns the <tt>ResourceManagementService</tt>.
+ *
+ * @return the <tt>ResourceManagementService</tt>.
+ */
+ public static ResourceManagementService getResources()
+ {
+ if (resourcesService == null)
+ resourcesService =
+ ResourceManagementServiceUtils
+ .getService(SimpleAccountRegistrationActivator.bundleContext);
+ return resourcesService;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/CreateSip2SipAccountForm.java b/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/CreateSip2SipAccountForm.java
deleted file mode 100644
index aa38c69..0000000
--- a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/CreateSip2SipAccountForm.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.sip2sipaccregwizz;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-import java.net.*;
-
-import javax.swing.*;
-import javax.swing.text.*;
-
-import net.java.sip.communicator.plugin.ippiaccregwizz.*;
-import net.java.sip.communicator.plugin.sipaccregwizz.*;
-import net.java.sip.communicator.util.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-import org.json.simple.*;
-
-/**
- * @author Yana Stamcheva
- */
-public class CreateSip2SipAccountForm
- extends TransparentPanel
- implements SIPAccountCreationFormService
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- /**
- * The logger.
- */
- private static final Logger logger
- = Logger.getLogger(CreateSip2SipAccountForm.class);
-
- /**
- * The user name text field.
- */
- private final JTextField usernameField = new TrimTextField();
-
- /**
- * The display name text field.
- */
- private final JTextField displayNameField = new JTextField();
-
- /**
- * The password field.
- */
- private final JPasswordField passField = new JPasswordField();
-
- /**
- * The retype password field.
- */
- private final JPasswordField retypePassField = new JPasswordField();
-
- /**
- * The email field.
- */
- private final JTextField emailField = new JTextField();
-
- /**
- * The error text pane.
- */
- private final JTextPane errorPane = new JTextPane();
-
- /**
- * The register link.
- */
- private static String registerLink
- = "https://enrollment.sipthor.net/enrollment.phtml?";
-
- /**
- * Creates an instance of <tt>RegisterSip2SipAccountForm</tt>.
- */
- public CreateSip2SipAccountForm()
- {
- super(new BorderLayout());
-
- this.init();
- }
-
- /**
- * Initializes this panel.
- */
- private void init()
- {
- JPanel mainPanel = new TransparentPanel(new BorderLayout());
-
- mainPanel.setBorder(BorderFactory.createTitledBorder(
- Sip2SipAccRegWizzActivator.getResources()
- .getI18NString("plugin.sipaccregwizz.CREATE_ACCOUNT_TITLE")));
-
- JPanel labelsPanel = new TransparentPanel(new GridLayout(0, 1));
-
- JPanel valuesPanel = new TransparentPanel(new GridLayout(0, 1));
-
- JLabel usernameLabel
- = new JLabel(Sip2SipAccRegWizzActivator.getResources()
- .getI18NString("plugin.sip2sipaccregwizz.USERNAME"));
-
- JLabel displayNameLabel
- = new JLabel(Sip2SipAccRegWizzActivator.getResources()
- .getI18NString("plugin.sipaccregwizz.DISPLAY_NAME"));
-
- JLabel passLabel
- = new JLabel(Sip2SipAccRegWizzActivator.getResources()
- .getI18NString("service.gui.PASSWORD"));
-
- JLabel retypePasswordLabel
- = new JLabel(Sip2SipAccRegWizzActivator.getResources()
- .getI18NString("plugin.sip2sipaccregwizz.RETYPE_PASSWORD"));
-
- JLabel emailLabel
- = new JLabel(Sip2SipAccRegWizzActivator.getResources()
- .getI18NString("plugin.sip2sipaccregwizz.EMAIL"));
-
- labelsPanel.add(displayNameLabel);
- labelsPanel.add(usernameLabel);
- labelsPanel.add(passLabel);
- labelsPanel.add(retypePasswordLabel);
- labelsPanel.add(emailLabel);
-
- valuesPanel.add(displayNameField);
- valuesPanel.add(usernameField);
- valuesPanel.add(passField);
- valuesPanel.add(retypePassField);
- valuesPanel.add(emailField);
-
- JLabel emailDescriptionLabel
- = new JLabel(Sip2SipAccRegWizzActivator.getResources()
- .getI18NString("plugin.sip2sipaccregwizz.EMAIL_NOTE"),
- SwingConstants.CENTER);
- emailDescriptionLabel.setForeground(Color.GRAY);
- emailDescriptionLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8));
- emailDescriptionLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 8, 10));
-
- initErrorArea();
-
- mainPanel.add(labelsPanel, BorderLayout.WEST);
- mainPanel.add(valuesPanel, BorderLayout.CENTER);
- mainPanel.add(emailDescriptionLabel, BorderLayout.SOUTH);
-
- this.add(mainPanel, BorderLayout.CENTER);
-
- JLabel infoLabel
- = new JLabel(Sip2SipAccRegWizzActivator.getResources()
- .getI18NString("plugin.sip2sipaccregwizz.INFO_NOTE"),
- SwingConstants.RIGHT);
- infoLabel.setCursor(new Cursor(Cursor.HAND_CURSOR));
- infoLabel.setForeground(Color.GRAY);
- infoLabel.setFont(emailDescriptionLabel.getFont().deriveFont(8));
- infoLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0));
- infoLabel.addMouseListener(new MouseAdapter()
- {
- @Override
- public void mousePressed(MouseEvent e)
- {
- Sip2SipAccRegWizzActivator.getBrowserLauncher()
- .openURL("http://wiki.sip2sip.info");
- }
- });
-
- this.add(infoLabel, BorderLayout.SOUTH);
- }
-
- /**
- * Creates the error area component.
- */
- private void initErrorArea()
- {
- SimpleAttributeSet attribs = new SimpleAttributeSet();
- StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_RIGHT);
- StyleConstants.setFontFamily(attribs, errorPane.getFont().getFamily());
- StyleConstants.setForeground(attribs, Color.RED);
- errorPane.setParagraphAttributes(attribs, true);
- errorPane.setPreferredSize(new Dimension(100, 50));
- errorPane.setMinimumSize(new Dimension(100, 50));
- errorPane.setOpaque(false);
- }
-
- /**
- * Creates this account on the server.
- * @return the created account
- */
- public NewAccount createAccount()
- {
- // Check if the two passwords match.
- String pass1 = new String( passField.getPassword());
- String pass2 = new String( retypePassField.getPassword());
- if (!pass1.equals(pass2))
- {
- showErrorMessage(
- IppiAccRegWizzActivator.getResources().getI18NString(
- "plugin.sipaccregwizz.NOT_SAME_PASSWORD"));
-
- return null;
- }
-
- NewAccount newAccount = null;
- try
- {
- StringBuilder registerLinkBuilder = new StringBuilder(registerLink);
- registerLinkBuilder
- .append(URLEncoder.encode("email", "UTF-8"))
- .append("=").append(
- URLEncoder.encode(emailField.getText(), "UTF-8"))
- .append("&").append(URLEncoder.encode("password", "UTF-8"))
- .append("=").append(
- URLEncoder.encode(new String(passField.getPassword()), "UTF-8"))
- .append("&").append(URLEncoder.encode("display_name", "UTF-8"))
- .append("=").append(
- URLEncoder.encode(displayNameField.getText(), "UTF-8"))
- .append("&").append(URLEncoder.encode("username", "UTF-8"))
- .append("=").append(
- URLEncoder.encode(usernameField.getText(), "UTF-8"))
- .append("&").append(URLEncoder.encode("user_agent", "UTF-8"))
- .append("=").append(
- URLEncoder.encode("sip-communicator.org", "UTF-8"));
-
- URL url = new URL(registerLinkBuilder.toString());
- URLConnection conn = url.openConnection();
-
- // If this is not an http connection we have nothing to do here.
- if (!(conn instanceof HttpURLConnection))
- {
- return null;
- }
-
- HttpURLConnection httpConn = (HttpURLConnection) conn;
-
- int responseCode = httpConn.getResponseCode();
-
- if (responseCode == HttpURLConnection.HTTP_OK)
- {
- // Read all the text returned by the server
- BufferedReader in = new BufferedReader(
- new InputStreamReader(conn.getInputStream()));
- String str;
-
- StringBuffer stringBuffer = new StringBuffer();
- while ((str = in.readLine()) != null)
- {
- stringBuffer.append(str);
- }
-
- if (logger.isInfoEnabled())
- logger.info("JSON response to create account request: "
- + stringBuffer.toString());
-
- newAccount = parseHttpResponse(stringBuffer.toString());
- }
- }
- catch (MalformedURLException e1)
- {
- if (logger.isInfoEnabled())
- logger.info("Failed to create URL with string: "
- + registerLink, e1);
- }
- catch (IOException e1)
- {
- if (logger.isInfoEnabled())
- logger.info("Failed to open connection.", e1);
- }
- return newAccount;
- }
-
- /**
- * Returns the form, which would be used by the user to create a new
- * account.
- * @return the component of the form
- */
- public Component getForm()
- {
- return this;
- }
-
- /**
- * Clears all the data previously entered in the form.
- */
- public void clear()
- {
- usernameField.setText("");
- displayNameField.setText("");
- passField.setText("");
- retypePassField.setText("");
- emailField.setText("");
- errorPane.setText("");
-
- remove(errorPane);
- }
-
- /**
- * Parses the given http response.
- * @param response the http response to parse
- * @return the new account
- */
- private NewAccount parseHttpResponse(String response)
- {
- NewAccount newAccount = null;
- try
- {
- JSONObject jsonObject = (JSONObject)JSONValue
- .parseWithException(response);
- boolean isSuccess = (Boolean)jsonObject.get("success");
-
- if (isSuccess)
- {
- newAccount = new NewAccount(
- (String)jsonObject.get("sip_address"),
- passField.getPassword(),
- null,
- (String)jsonObject.get("outbound_proxy"));
-
- String xcapRoot = (String)jsonObject.get("xcap_root");
-
- // as sip2sip adds @sip2sip.info at the end of the
- // xcap_uri but doesn't report it in resullt after
- // creating account, we add it
- String domain = null;
- int delimIndex = newAccount.getUserName().indexOf("@");
- if (delimIndex != -1)
- {
- domain = newAccount.getUserName().substring(delimIndex);
- }
- if(domain != null)
- {
- if(xcapRoot.endsWith("/"))
- xcapRoot =
- xcapRoot.substring(0, xcapRoot.length() - 1)
- + domain;
- else
- xcapRoot += domain;
- }
-
- newAccount.setXcapRoot(xcapRoot);
- }
- else
- {
- showErrorMessage((String)jsonObject.get("error_message"));
- }
- }
- catch (Throwable e1)
- {
- if (logger.isInfoEnabled())
- logger.info("Failed Json parsing.", e1);
- }
-
- return newAccount;
- }
-
- /**
- * Shows the given error message.
- *
- * @param text the text of the error
- */
- private void showErrorMessage(String text)
- {
- errorPane.setText(text);
-
- if (errorPane.getParent() == null)
- add(errorPane, BorderLayout.NORTH);
-
- SwingUtilities.getWindowAncestor(CreateSip2SipAccountForm.this).pack();
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccRegWizzActivator.java
deleted file mode 100644
index 6263508..0000000
--- a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccRegWizzActivator.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.sip2sipaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.service.resources.*;
-
-import org.jitsi.service.resources.*;
-import org.osgi.framework.*;
-
-/**
- * Registers the <tt>GoogleTalkAccountRegistrationWizard</tt> in the UI Service.
- *
- * @author Lubomir Marinov
- * @author Yana Stamcheva
- */
-public class Sip2SipAccRegWizzActivator
- implements BundleActivator
-{
- /**
- * The bundle context.
- */
- public static BundleContext bundleContext;
-
- /**
- * The browser launcher service.
- */
- private static BrowserLauncherService browserLauncherService;
-
- /**
- * The resources service.
- */
- private static ResourceManagementService resourcesService;
-
- /**
- * The ui service.
- */
- private static UIService uiService;
-
- /**
- * Starts this bundle.
- * @param bc BundleContext
- * @throws Exception
- */
- public void start(BundleContext bc)
- throws Exception
- {
- bundleContext = bc;
-
- System.setProperty(
- "http.agent",
- System.getProperty("sip-communicator.application.name")
- + "/"
- + System.getProperty("sip-communicator.version"));
-
- uiService =
- (UIService) bundleContext.getService(bundleContext
- .getServiceReference(UIService.class.getName()));
-
- Sip2SipAccountRegistrationWizard wizard
- = new Sip2SipAccountRegistrationWizard(uiService
- .getAccountRegWizardContainer());
-
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
- containerFilter.put(
- ProtocolProviderFactory.PROTOCOL,
- Sip2SipAccountRegistrationWizard.PROTOCOL);
-
- bundleContext.registerService(
- AccountRegistrationWizard.class.getName(),
- wizard,
- containerFilter);
- }
-
- public void stop(BundleContext bundleContext) throws Exception {}
-
- /**
- * Returns the <tt>UIService</tt>.
- *
- * @return the <tt>UIService</tt>
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-
- /**
- * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context.
- * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context
- */
- public static BrowserLauncherService getBrowserLauncher()
- {
- if (browserLauncherService == null)
- {
- browserLauncherService
- = (BrowserLauncherService) bundleContext.getService(
- bundleContext.getServiceReference(
- BrowserLauncherService.class.getName()));
- }
- return browserLauncherService;
- }
-
- /**
- * Returns the service giving access to resources.
- * @return the service giving access to resources
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService = ResourceManagementServiceUtils
- .getService(Sip2SipAccRegWizzActivator.bundleContext);
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccountRegistrationWizard.java
deleted file mode 100644
index d6b09d8..0000000
--- a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/Sip2SipAccountRegistrationWizard.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.sip2sipaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.plugin.sipaccregwizz.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.sip.*;
-
-/**
- * The <tt>Sip2SipAccountRegistrationWizard</tt> is an implementation of the
- * <tt>AccountRegistrationWizard</tt> for the SIP protocol. It should allow
- * the user to create and configure a new IP Tel SIP account.
- *
- * @author Yana Stamcheva
- */
-public class Sip2SipAccountRegistrationWizard
- extends SIPAccountRegistrationWizard
-{
- /**
- * A constant pointing to the IP Tel protocol logo image.
- */
- private static final String PROTOCOL_ICON
- = "service.protocol.sip2sip.SIP2SIP_16x16";
-
- /**
- * A constant pointing to the IP Tel protocol wizard page image.
- */
- private static final String PAGE_IMAGE
- = "service.protocol.sip2sip.SIP2SIP_64x64";
-
- /**
- * The protocol name.
- */
- public static final String PROTOCOL = "sip2sip.info";
-
- /**
- * The create account form.
- */
- CreateSip2SipAccountForm createAccountForm = new CreateSip2SipAccountForm();
-
- /**
- * Creates an instance of <tt>IptelAccountRegistrationWizard</tt>.
- * @param wizardContainer the wizard container
- */
- public Sip2SipAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- super(wizardContainer);
- }
-
- /**
- * Returns the set of pages contained in this wizard.
- * @return Iterator
- */
- @Override
- public Iterator<WizardPage> getPages()
- {
- SIPAccountRegistration reg = new SIPAccountRegistration();
-
- setPredefinedProperties(reg);
-
- return getPages(reg);
- }
-
- /**
- * Returns a simple account registration form that would be the first form
- * shown to the user. Only if the user needs more settings she'll choose
- * to open the advanced wizard, consisted by all pages.
- *
- * @param isCreateAccount indicates if the simple form should be opened as
- * a create account form or as a login form
- * @return a simple account registration form
- */
- @Override
- public Object getSimpleForm(boolean isCreateAccount)
- {
- SIPAccountRegistration reg = new SIPAccountRegistration();
-
- setPredefinedProperties(reg);
-
- return getSimpleForm(reg, isCreateAccount);
- }
-
- /**
- * Sets all predefined properties specific for this account wizard.
- *
- * @param reg the registration object
- */
- private void setPredefinedProperties(SIPAccountRegistration reg)
- {
- // set properties common for sip2sip
- reg.setKeepAliveMethod("NONE");
- reg.setDefaultDomain("sip2sip.info");
- reg.setXCapEnable(true);
- reg.setClistOptionServerUri(
- "https://xcap.sipthor.net/xcap-root@sip2sip.info");
- reg.setClistOptionUseSipCredentials(true);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * Returns the icon to be used for this wizard.
- * @return byte[]
- */
- @Override
- public byte[] getIcon()
- {
- return Sip2SipAccRegWizzActivator.getResources()
- .getImageInBytes(PROTOCOL_ICON);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
- * Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- @Override
- public byte[] getPageImage()
- {
- return Sip2SipAccRegWizzActivator.getResources()
- .getImageInBytes(PAGE_IMAGE);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method. Returns the protocol name for this wizard.
- * @return String
- */
- @Override
- public String getProtocolName()
- {
- return Resources.getString(
- "plugin.sip2sipaccregwizz.PROTOCOL_NAME");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code> method. Returns the description of the protocol for this wizard.
- * @return String
- */
- @Override
- public String getProtocolDescription()
- {
- return Resources.getString(
- "plugin.sip2sipaccregwizz.PROTOCOL_DESCRIPTION");
- }
-
- /**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
- */
- @Override
- public String getUserNameExample()
- {
- return "Ex: myusername or myusername@sip2sip.info";
- }
-
- /**
- * Returns the protocol name as listed in "ProtocolNames" or just the name
- * of the service.
- * @return the protocol name
- */
- @Override
- public String getProtocol()
- {
- return PROTOCOL;
- }
-
- /**
- * Returns the protocol icon path.
- * @return the protocol icon path
- */
- @Override
- public String getProtocolIconPath()
- {
- return "resources/images/protocol/sip2sip";
- }
-
- /**
- * Returns the account icon path.
- * @return the account icon path
- */
- @Override
- public String getAccountIconPath()
- {
- return "resources/images/protocol/sip2sip/sip32x32.png";
- }
-
- /**
- * Opens the browser on the page sign up
- */
- @Override
- public void webSignup()
- {
- Sip2SipAccRegWizzActivator.getBrowserLauncher()
- .openURL("http://wiki.sip2sip.info");
- }
-
- /**
- * Returns the name of the web sign up link.
- * @return the name of the web sign up link
- */
- @Override
- public String getWebSignupLinkName()
- {
- return Resources.getString("plugin.sip2sipaccregwizz.NEW_ACCOUNT_TITLE");
- }
-
- /**
- * Returns an instance of <tt>CreateAccountService</tt> through which the
- * user could create an account. This method is meant to be implemented by
- * specific protocol provider wizards.
- * @return an instance of <tt>CreateAccountService</tt>
- */
- @Override
- protected SIPAccountCreationFormService getCreateAccountService()
- {
- return createAccountForm;
- }
-
- /**
- * Returns the display label used for the sip id field.
- * @return the sip id display label string.
- */
- @Override
- protected String getUsernameLabel()
- {
- return Resources.getString("plugin.sip2sipaccregwizz.USERNAME");
- }
-
- /**
- * Return the string for add existing account button.
- * @return the string for add existing account button.
- */
- @Override
- protected String getExistingAccountLabel()
- {
- return Resources.getString("plugin.sip2sipaccregwizz.EXISTING_ACCOUNT");
- }
-
- /**
- * Return the string for create new account button.
- * @return the string for create new account button.
- */
- @Override
- protected String getCreateAccountLabel()
- {
- return Resources.getString("plugin.sip2sipaccregwizz.CREATE_ACCOUNT");
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/sip2sipaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/sip2sipaccregwizz.manifest.mf
deleted file mode 100644
index 7ebbd1c..0000000
--- a/src/net/java/sip/communicator/plugin/sip2sipaccregwizz/sip2sipaccregwizz.manifest.mf
+++ /dev/null
@@ -1,43 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.plugin.sip2sipaccregwizz.Sip2SipAccRegWizzActivator
-Bundle-Name: Sip 2 Sip account registration wizard
-Bundle-Description: Sip 2 Sip account registration wizard.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.plugin.sip2sipaccregwizz
-Import-Package: org.osgi.framework,
- net.java.sip.communicator.service.browserlauncher,
- org.jitsi.service.configuration,
- net.java.sip.communicator.service.contactlist,
- net.java.sip.communicator.service.contactlist.event,
- org.jitsi.service.fileaccess,
- net.java.sip.communicator.service.gui,
- net.java.sip.communicator.service.gui.event,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,
- net.java.sip.communicator.service.protocol.icqconstants,
- net.java.sip.communicator.service.protocol.sip,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.plugin.desktoputil,
- net.java.sip.communicator.plugin.sipaccregwizz,
- javax.naming,
- javax.naming.directory,
- javax.xml.parsers,
- org.w3c.dom,
- org.xml.sax,
- org.json.simple,
- javax.swing,
- javax.swing.event,
- javax.swing.table,
- javax.swing.text,
- javax.swing.text.html,
- javax.accessibility,
- javax.swing.plaf,
- javax.swing.plaf.metal,
- javax.swing.plaf.basic,
- javax.imageio,
- javax.swing.filechooser,
- javax.swing.tree,
- javax.swing.undo,
- javax.swing.border,
- org.jivesoftware.smack
diff --git a/src/net/java/sip/communicator/plugin/skinmanager/BundleComparator.java b/src/net/java/sip/communicator/plugin/skinmanager/BundleComparator.java
index b77bbbe..251052a 100644
--- a/src/net/java/sip/communicator/plugin/skinmanager/BundleComparator.java
+++ b/src/net/java/sip/communicator/plugin/skinmanager/BundleComparator.java
@@ -38,8 +38,8 @@ public class BundleComparator
*/
public int compare(Bundle arg0, Bundle arg1)
{
- String n1 = (String) arg0.getHeaders().get(Constants.BUNDLE_NAME);
- String n2 = (String) arg1.getHeaders().get(Constants.BUNDLE_NAME);
+ String n1 = arg0.getHeaders().get(Constants.BUNDLE_NAME);
+ String n2 = arg1.getHeaders().get(Constants.BUNDLE_NAME);
if (n1 == null)
{
diff --git a/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckerConfigDialog.java b/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckerConfigDialog.java
index 35ef36b..6882d36 100644
--- a/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckerConfigDialog.java
+++ b/src/net/java/sip/communicator/plugin/spellcheck/SpellCheckerConfigDialog.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,423 +15,423 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.spellcheck;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.util.List;
-
-import javax.swing.*;
-import javax.swing.event.*;
-import javax.swing.text.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.util.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-import org.dts.spell.dictionary.*;
-import org.jitsi.service.resources.*;
-
-/**
- * The spell check dialog that would be opened from the right click menu in the
- * chat window.
- *
- * @author Purvesh Sahoo
- */
-public class SpellCheckerConfigDialog
- extends SIPCommDialog
- implements ActionListener
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- private static final Logger logger = Logger
- .getLogger(SpellCheckerConfigDialog.class);
-
- /**
- * UI Components
- */
- private JTextComponent currentWord;
-
- private JList suggestionList;
-
- private JScrollPane suggestionScroll;
-
- private JButton changeButton;
-
- private JButton nextButton;
-
- private JButton addButton;
-
- private JPanel checkPanel;
-
- private JPanel buttonsPanel;
-
- private JPanel topPanel;
-
- private JPanel suggestionPanel;
-
- private SpellDictionary dict;
-
- private Chat chat;
-
- private final ResourceManagementService resources = Resources
- .getResources();
-
- private String word;
-
- private int index;
-
- private Word clickedWord;
-
- public SpellCheckerConfigDialog(Chat chat, Word clickedWord,
- SpellDictionary dict)
- {
-
- super(false);
-
- this.dict = dict;
- this.chat = chat;
-
- initComponents(clickedWord);
-
- this.setTitle(resources.getI18NString("plugin.spellcheck.TITLE"));
- this.setMinimumSize(new Dimension(450, 320));
- this.setPreferredSize(new Dimension(450, 320));
- this.setResizable(false);
-
- JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
- mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- mainPanel.add(topPanel);
-
- this.getContentPane().add(mainPanel);
-
- this.pack();
- Toolkit toolkit = Toolkit.getDefaultToolkit();
- Dimension screenSize = toolkit.getScreenSize();
-
- int x = (screenSize.width - this.getWidth()) / 2;
- int y = (screenSize.height - this.getHeight()) / 2;
-
- this.setLocation(x, y);
-
- if (!currentWord.getText().equals(" ")
- && this.dict.isCorrect(currentWord.getText()))
- {
- nextButton.doClick();
- }
- }
-
- /**
- * Initialises the UI components.
- */
- private void initComponents(final Word clickWord)
- {
-
- clickedWord =
- (clickWord == null) ? Word.getWord(" ", 1, false) : clickWord;
-
- topPanel = new TransparentPanel(new BorderLayout());
- topPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
- topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
-
- checkPanel = new TransparentPanel(new BorderLayout(10, 10));
- checkPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
- checkPanel.setLayout(new BoxLayout(checkPanel, BoxLayout.X_AXIS));
-
- currentWord = new JTextField(clickedWord.getText());
-
- currentWord.setAlignmentX(LEFT_ALIGNMENT);
- currentWord.setMaximumSize(new Dimension(550, 30));
-
- currentWord.setText(clickedWord.getText());
- currentWord.selectAll();
-
- // JPanel wordPanel = new TransparentPanel(new BorderLayout());
- // wordPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
- // wordPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5));
- // wordPanel.add(currentWord);
-
- buttonsPanel =
- new TransparentPanel(new FlowLayout(FlowLayout.RIGHT, 0, 10));
- changeButton =
- new JButton(
- resources.getI18NString("plugin.spellcheck.dialog.REPLACE"));
- changeButton.setMnemonic(resources
- .getI18nMnemonic("plugin.spellcheck.dialog.REPLACE"));
-
- changeButton.addActionListener(new ActionListener()
- {
-
- public void actionPerformed(ActionEvent e)
- {
- if (suggestionList.getSelectedValue() != null)
- {
-
- StringBuffer newMessage =
- new StringBuffer(chat.getMessage());
- int endIndex;
-
- if (word != null)
- {
- endIndex = index + currentWord.getText().length();
- newMessage.replace(index, endIndex,
- (String) suggestionList.getSelectedValue());
- word = (String) suggestionList.getSelectedValue();
- }
- else
- {
- endIndex =
- clickedWord.getStart()
- + clickedWord.getText().length();
- newMessage.replace(clickedWord.getStart(), endIndex,
- (String) suggestionList.getSelectedValue());
- }
- currentWord.setText((String) suggestionList
- .getSelectedValue());
- chat.setMessage(newMessage.toString());
-
- }
- }
- });
- changeButton.setEnabled(false);
-
- nextButton =
- new JButton(
- resources.getI18NString("plugin.spellcheck.dialog.FIND"));
- nextButton.setMnemonic(resources
- .getI18nMnemonic("plugin.spellcheck.dialog.FIND"));
-
- nextButton.addActionListener(new ActionListener()
- {
-
- public Word getNextWord()
- {
-
- Word nextWord;
- int wordIndex;
-
- if (word == null)
- {
- if (currentWord.getText().equals(" "))
- {
- String words[] = chat.getMessage().split(" ");
- currentWord.setText(words[0]);
-
- }
-
- wordIndex =
- chat.getMessage().indexOf(currentWord.getText());
- if (dict.isCorrect(currentWord.getText()))
- currentWord.setText("");
- }
- else
- {
- wordIndex = chat.getMessage().indexOf(word, index);
- }
-
- Word presentWord =
- Word.getWord(chat.getMessage(), wordIndex, false);
-
- if (presentWord.getEnd() == chat.getMessage().length())
- {
- nextWord = Word.getWord(chat.getMessage(), 0, false);
-
- }
- else
- {
- nextWord =
- Word.getWord(chat.getMessage(),
- presentWord.getEnd() + 1, false);
- }
-
- index = nextWord.getStart();
- word = nextWord.getText();
-
- return nextWord;
- }
-
- public void actionPerformed(ActionEvent e)
- {
- Word nextWord = getNextWord();
- int breakIndex = nextWord.getStart();
- if(breakIndex == 0)
- breakIndex = nextWord.getEnd() + 1;
-
- if(nextWord.getText().length() == 0)
- {
- breakIndex++;
- nextWord = getNextWord();
- }
-
- while (dict.isCorrect(nextWord.getText())
- && nextWord.getEnd() + 1 != breakIndex)
- {
- nextWord = getNextWord();
-
- }
-
- if (!dict.isCorrect(nextWord.getText()))
- {
- word = nextWord.getText();
- currentWord.setText(nextWord.getText());
-
- String clickedWord = currentWord.getText();
- setSuggestionModel(clickedWord);
- }
-
- }
- });
-
- buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS));
- buttonsPanel.add(changeButton);
- buttonsPanel.add(nextButton);
-
- checkPanel.add(currentWord, BorderLayout.NORTH);
- checkPanel.add(Box.createHorizontalStrut(10));
- checkPanel.add(buttonsPanel, BorderLayout.EAST);
-
- topPanel.add(checkPanel, BorderLayout.NORTH);
- topPanel.add(Box.createVerticalStrut(10));
-
- DefaultListModel dataModel = new DefaultListModel();
- suggestionList = new JList(dataModel);
-
- suggestionScroll = new JScrollPane(suggestionList);
- suggestionScroll.setAlignmentX(LEFT_ALIGNMENT);
-
- if (!dict.isCorrect(clickedWord.getText()))
- setSuggestionModel(clickedWord.getText());
-
- suggestionList.addListSelectionListener(new ListSelectionListener()
- {
-
- public void valueChanged(ListSelectionEvent e)
- {
-
- if (!e.getValueIsAdjusting())
- {
- changeButton.setEnabled(true);
- }
- }
- });
-
- MouseListener clickListener = new MouseAdapter()
- {
- @Override
- public void mouseClicked(MouseEvent e)
- {
- if (e.getClickCount() == 2)
- {
-
- StringBuffer newMessage =
- new StringBuffer(chat.getMessage());
- int endIndex;
-
- if (word != null)
- {
- endIndex = index + currentWord.getText().length();
- newMessage.replace(index, endIndex,
- (String) suggestionList.getSelectedValue());
- word = (String) suggestionList.getSelectedValue();
- }
- else
- {
- endIndex =
- clickedWord.getStart()
- + clickedWord.getText().length();
- newMessage.replace(clickedWord.getStart(), endIndex,
- (String) suggestionList.getSelectedValue());
- }
- currentWord.setText((String) suggestionList
- .getSelectedValue());
- chat.setMessage(newMessage.toString());
-
- }
- }
- };
-
- suggestionList.addMouseListener(clickListener);
-
- addButton =
- new JButton(resources.getI18NString("plugin.spellcheck.dialog.ADD"));
- addButton.setMnemonic(resources
- .getI18nMnemonic("plugin.spellcheck.dialog.ADD"));
-
- addButton.addActionListener(new ActionListener()
- {
-
- public void actionPerformed(ActionEvent e)
- {
-
- try
- {
- dict.addWord(currentWord.getText());
- chat.promptRepaint();
- }
- catch (SpellDictionaryException exc)
- {
- String msg = "Unable to add word to personal dictionary";
- logger.error(msg, exc);
- }
- }
- });
-
- suggestionPanel = new TransparentPanel(new BorderLayout(10, 10));
- suggestionPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
- suggestionPanel.setLayout(new BoxLayout(suggestionPanel,
- BoxLayout.X_AXIS));
- suggestionPanel.add(suggestionScroll);
- suggestionPanel.add(Box.createHorizontalStrut(10));
- suggestionPanel.add(addButton);
-
- topPanel.add(suggestionPanel, BorderLayout.SOUTH);
-
- }
-
- /**
- * Sets the model for the suggestion list
- *
- * @param clickedWord
- */
- private void setSuggestionModel(String clickedWord)
- {
-
- DefaultListModel dataModel = new DefaultListModel();
- List<String> corrections = this.dict.getSuggestions(clickedWord);
- for (String correction : corrections)
- {
- dataModel.addElement(correction);
- }
-
- suggestionList.setModel(dataModel);
- }
-
- /**
- * Returns the selected correction value
- *
- * @return selected value from suggestion list
- */
- public Object getCorrection()
- {
-
- return suggestionList.getSelectedValue();
- }
-
- public void actionPerformed(ActionEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void close(boolean escaped)
- {
- // TODO Auto-generated method stub
-
- }
-
-}
+package net.java.sip.communicator.plugin.spellcheck;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.util.List;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.text.*;
+
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.util.*;
+import net.java.sip.communicator.plugin.desktoputil.*;
+
+import org.dts.spell.dictionary.*;
+import org.jitsi.service.resources.*;
+
+/**
+ * The spell check dialog that would be opened from the right click menu in the
+ * chat window.
+ *
+ * @author Purvesh Sahoo
+ */
+public class SpellCheckerConfigDialog
+ extends SIPCommDialog
+ implements ActionListener
+{
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 0L;
+
+ private static final Logger logger = Logger
+ .getLogger(SpellCheckerConfigDialog.class);
+
+ /**
+ * UI Components
+ */
+ private JTextComponent currentWord;
+
+ private JList suggestionList;
+
+ private JScrollPane suggestionScroll;
+
+ private JButton changeButton;
+
+ private JButton nextButton;
+
+ private JButton addButton;
+
+ private JPanel checkPanel;
+
+ private JPanel buttonsPanel;
+
+ private JPanel topPanel;
+
+ private JPanel suggestionPanel;
+
+ private SpellDictionary dict;
+
+ private Chat chat;
+
+ private final ResourceManagementService resources = Resources
+ .getResources();
+
+ private String word;
+
+ private int index;
+
+ private Word clickedWord;
+
+ public SpellCheckerConfigDialog(Chat chat, Word clickedWord,
+ SpellDictionary dict)
+ {
+
+ super(false);
+
+ this.dict = dict;
+ this.chat = chat;
+
+ initComponents(clickedWord);
+
+ this.setTitle(resources.getI18NString("plugin.spellcheck.TITLE"));
+ this.setMinimumSize(new Dimension(450, 320));
+ this.setPreferredSize(new Dimension(450, 320));
+ this.setResizable(false);
+
+ JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
+ mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
+
+ mainPanel.add(topPanel);
+
+ this.getContentPane().add(mainPanel);
+
+ this.pack();
+ Toolkit toolkit = Toolkit.getDefaultToolkit();
+ Dimension screenSize = toolkit.getScreenSize();
+
+ int x = (screenSize.width - this.getWidth()) / 2;
+ int y = (screenSize.height - this.getHeight()) / 2;
+
+ this.setLocation(x, y);
+
+ if (!currentWord.getText().equals(" ")
+ && this.dict.isCorrect(currentWord.getText()))
+ {
+ nextButton.doClick();
+ }
+ }
+
+ /**
+ * Initialises the UI components.
+ */
+ private void initComponents(final Word clickWord)
+ {
+
+ clickedWord =
+ (clickWord == null) ? Word.getWord(" ", 1, false) : clickWord;
+
+ topPanel = new TransparentPanel(new BorderLayout());
+ topPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
+ topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
+
+ checkPanel = new TransparentPanel(new BorderLayout(10, 10));
+ checkPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
+ checkPanel.setLayout(new BoxLayout(checkPanel, BoxLayout.X_AXIS));
+
+ currentWord = new JTextField(clickedWord.getText());
+
+ currentWord.setAlignmentX(LEFT_ALIGNMENT);
+ currentWord.setMaximumSize(new Dimension(550, 30));
+
+ currentWord.setText(clickedWord.getText());
+ currentWord.selectAll();
+
+ // JPanel wordPanel = new TransparentPanel(new BorderLayout());
+ // wordPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
+ // wordPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5));
+ // wordPanel.add(currentWord);
+
+ buttonsPanel =
+ new TransparentPanel(new FlowLayout(FlowLayout.RIGHT, 0, 10));
+ changeButton =
+ new JButton(
+ resources.getI18NString("plugin.spellcheck.dialog.REPLACE"));
+ changeButton.setMnemonic(resources
+ .getI18nMnemonic("plugin.spellcheck.dialog.REPLACE"));
+
+ changeButton.addActionListener(new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+ if (suggestionList.getSelectedValue() != null)
+ {
+
+ StringBuffer newMessage =
+ new StringBuffer(chat.getMessage());
+ int endIndex;
+
+ if (word != null)
+ {
+ endIndex = index + currentWord.getText().length();
+ newMessage.replace(index, endIndex,
+ (String) suggestionList.getSelectedValue());
+ word = (String) suggestionList.getSelectedValue();
+ }
+ else
+ {
+ endIndex =
+ clickedWord.getStart()
+ + clickedWord.getText().length();
+ newMessage.replace(clickedWord.getStart(), endIndex,
+ (String) suggestionList.getSelectedValue());
+ }
+ currentWord.setText((String) suggestionList
+ .getSelectedValue());
+ chat.setMessage(newMessage.toString());
+
+ }
+ }
+ });
+ changeButton.setEnabled(false);
+
+ nextButton =
+ new JButton(
+ resources.getI18NString("plugin.spellcheck.dialog.FIND"));
+ nextButton.setMnemonic(resources
+ .getI18nMnemonic("plugin.spellcheck.dialog.FIND"));
+
+ nextButton.addActionListener(new ActionListener()
+ {
+
+ public Word getNextWord()
+ {
+
+ Word nextWord;
+ int wordIndex;
+
+ if (word == null)
+ {
+ if (currentWord.getText().equals(" "))
+ {
+ String words[] = chat.getMessage().split(" ");
+ currentWord.setText(words[0]);
+
+ }
+
+ wordIndex =
+ chat.getMessage().indexOf(currentWord.getText());
+ if (dict.isCorrect(currentWord.getText()))
+ currentWord.setText("");
+ }
+ else
+ {
+ wordIndex = chat.getMessage().indexOf(word, index);
+ }
+
+ Word presentWord =
+ Word.getWord(chat.getMessage(), wordIndex, false);
+
+ if (presentWord.getEnd() == chat.getMessage().length())
+ {
+ nextWord = Word.getWord(chat.getMessage(), 0, false);
+
+ }
+ else
+ {
+ nextWord =
+ Word.getWord(chat.getMessage(),
+ presentWord.getEnd() + 1, false);
+ }
+
+ index = nextWord.getStart();
+ word = nextWord.getText();
+
+ return nextWord;
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ Word nextWord = getNextWord();
+ int breakIndex = nextWord.getStart();
+ if(breakIndex == 0)
+ breakIndex = nextWord.getEnd() + 1;
+
+ if(nextWord.getText().length() == 0)
+ {
+ breakIndex++;
+ nextWord = getNextWord();
+ }
+
+ while (dict.isCorrect(nextWord.getText())
+ && nextWord.getEnd() + 1 != breakIndex)
+ {
+ nextWord = getNextWord();
+
+ }
+
+ if (!dict.isCorrect(nextWord.getText()))
+ {
+ word = nextWord.getText();
+ currentWord.setText(nextWord.getText());
+
+ String clickedWord = currentWord.getText();
+ setSuggestionModel(clickedWord);
+ }
+
+ }
+ });
+
+ buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.Y_AXIS));
+ buttonsPanel.add(changeButton);
+ buttonsPanel.add(nextButton);
+
+ checkPanel.add(currentWord, BorderLayout.NORTH);
+ checkPanel.add(Box.createHorizontalStrut(10));
+ checkPanel.add(buttonsPanel, BorderLayout.EAST);
+
+ topPanel.add(checkPanel, BorderLayout.NORTH);
+ topPanel.add(Box.createVerticalStrut(10));
+
+ DefaultListModel dataModel = new DefaultListModel();
+ suggestionList = new JList(dataModel);
+
+ suggestionScroll = new JScrollPane(suggestionList);
+ suggestionScroll.setAlignmentX(LEFT_ALIGNMENT);
+
+ if (!dict.isCorrect(clickedWord.getText()))
+ setSuggestionModel(clickedWord.getText());
+
+ suggestionList.addListSelectionListener(new ListSelectionListener()
+ {
+
+ public void valueChanged(ListSelectionEvent e)
+ {
+
+ if (!e.getValueIsAdjusting())
+ {
+ changeButton.setEnabled(true);
+ }
+ }
+ });
+
+ MouseListener clickListener = new MouseAdapter()
+ {
+ @Override
+ public void mouseClicked(MouseEvent e)
+ {
+ if (e.getClickCount() == 2)
+ {
+
+ StringBuffer newMessage =
+ new StringBuffer(chat.getMessage());
+ int endIndex;
+
+ if (word != null)
+ {
+ endIndex = index + currentWord.getText().length();
+ newMessage.replace(index, endIndex,
+ (String) suggestionList.getSelectedValue());
+ word = (String) suggestionList.getSelectedValue();
+ }
+ else
+ {
+ endIndex =
+ clickedWord.getStart()
+ + clickedWord.getText().length();
+ newMessage.replace(clickedWord.getStart(), endIndex,
+ (String) suggestionList.getSelectedValue());
+ }
+ currentWord.setText((String) suggestionList
+ .getSelectedValue());
+ chat.setMessage(newMessage.toString());
+
+ }
+ }
+ };
+
+ suggestionList.addMouseListener(clickListener);
+
+ addButton =
+ new JButton(resources.getI18NString("plugin.spellcheck.dialog.ADD"));
+ addButton.setMnemonic(resources
+ .getI18nMnemonic("plugin.spellcheck.dialog.ADD"));
+
+ addButton.addActionListener(new ActionListener()
+ {
+
+ public void actionPerformed(ActionEvent e)
+ {
+
+ try
+ {
+ dict.addWord(currentWord.getText());
+ chat.promptRepaint();
+ }
+ catch (SpellDictionaryException exc)
+ {
+ String msg = "Unable to add word to personal dictionary";
+ logger.error(msg, exc);
+ }
+ }
+ });
+
+ suggestionPanel = new TransparentPanel(new BorderLayout(10, 10));
+ suggestionPanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
+ suggestionPanel.setLayout(new BoxLayout(suggestionPanel,
+ BoxLayout.X_AXIS));
+ suggestionPanel.add(suggestionScroll);
+ suggestionPanel.add(Box.createHorizontalStrut(10));
+ suggestionPanel.add(addButton);
+
+ topPanel.add(suggestionPanel, BorderLayout.SOUTH);
+
+ }
+
+ /**
+ * Sets the model for the suggestion list
+ *
+ * @param clickedWord
+ */
+ private void setSuggestionModel(String clickedWord)
+ {
+
+ DefaultListModel dataModel = new DefaultListModel();
+ List<String> corrections = this.dict.getSuggestions(clickedWord);
+ for (String correction : corrections)
+ {
+ dataModel.addElement(correction);
+ }
+
+ suggestionList.setModel(dataModel);
+ }
+
+ /**
+ * Returns the selected correction value
+ *
+ * @return selected value from suggestion list
+ */
+ public Object getCorrection()
+ {
+
+ return suggestionList.getSelectedValue();
+ }
+
+ public void actionPerformed(ActionEvent e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected void close(boolean escaped)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java
deleted file mode 100644
index f553815..0000000
--- a/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.sshaccregwizz;
-
-import java.awt.*;
-import java.awt.event.*;
-import java.io.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import net.java.sip.communicator.impl.protocol.ssh.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-/**
- * The <tt>FirstWizardPage</tt> is the page, where user could enter the user ID
- * and the password of the account.
- *
- * @author Shobhit Jindal
- */
-public class FirstWizardPage
- extends TransparentPanel
- implements WizardPage, DocumentListener
-{
- private static final long serialVersionUID = 8576006544813706541L;
-
- public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
-
- private JPanel accountPanel = new TransparentPanel(new BorderLayout(10, 10));
-
- private JPanel labelsPanel = new TransparentPanel();
-
- private JPanel valuesPanel = new TransparentPanel();
-
- private JLabel accountID
- = new JLabel(Resources.getString("plugin.sshaccregwizz.USERNAME"));
-
- private JLabel identityFile
- = new JLabel(Resources.getString("plugin.sshaccregwizz.IDENTITY_FILE"));
-
- private JLabel knownHostsFile
- = new JLabel(Resources.getString("plugin.sshaccregwizz.KNOWN_HOSTS"));
-
- private JPanel emptyPanel1 = new TransparentPanel();
-
- private JPanel emptyPanel2 = new TransparentPanel();
-
- private JPanel emptyPanel3 = new TransparentPanel();
-
- private JPanel emptyPanel4 = new TransparentPanel();
-
- private JPanel emptyPanel5 = new TransparentPanel();
-
- private JPanel emptyPanel6 = new TransparentPanel();
-
- private JPanel emptyPanel7 = new TransparentPanel();
-
- private JPanel emptyPanel8 = new TransparentPanel();
-
- private JPanel emptyPanel9 = new TransparentPanel();
-
- private JTextField userIDField = new TrimTextField();
-
- private JTextField identityFileField = new JTextField(
- Resources.getString("plugin.sshaccregwizz.OPTIONAL"));
-
- private JButton identityFileButton = new JButton(
- Resources.getString("service.gui.BROWSE"));
-
- private SipCommFileChooser identityFileChooser;
-
- private JPanel identityFilePanel = new TransparentPanel();
-
- private JTextField knownHostsFileField = new JTextField(
- Resources.getString("plugin.sshaccregwizz.KNOWN_HOSTS"));
-
- private JButton knownHostsFileButton = new JButton(
- Resources.getString("service.gui.BROWSE"));
-
- private SipCommFileChooser knownHostsFileChooser;
-
- private JPanel knownHostsFilePanel = new TransparentPanel();
-
- private JPanel mainPanel = new TransparentPanel();
-
- private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
-
- private SSHAccountRegistration registration = null;
-
- private WizardContainer wizardContainer;
-
- private boolean isCommitted = false;
-
- /**
- * Creates an instance of <tt>FirstWizardPage</tt>.
- * @param registration the <tt>SSHAccountRegistration</tt>, where
- * all data through the wizard are stored
- * @param wizardContainer the wizardContainer, where this page will
- * be added
- */
- public FirstWizardPage(SSHAccountRegistration registration,
- WizardContainer wizardContainer)
- {
-
- super(new BorderLayout());
-
- this.wizardContainer = wizardContainer;
-
- this.registration = registration;
-
- this.setPreferredSize(new Dimension(300, 150));
-
- mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
-
- identityFileField.setEditable(false);
-
- knownHostsFileField.setEditable(false);
-
- //identityFileChooser.setFileHidingEnabled(false);
-
- //knownHostsFileChooser.setFileHidingEnabled(false);
-
- this.init();
-
- this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- this.labelsPanel.setLayout(new BoxLayout(labelsPanel,
- BoxLayout.Y_AXIS));
-
- this.valuesPanel.setLayout(new BoxLayout(valuesPanel,
- BoxLayout.Y_AXIS));
-
- this.identityFilePanel.setLayout(new BoxLayout(identityFilePanel,
- BoxLayout.X_AXIS));
-
- this.knownHostsFilePanel.setLayout(new BoxLayout(knownHostsFilePanel,
- BoxLayout.X_AXIS));
- }
-
- /**
- * Initializes all panels, buttons, etc.
- */
- private void init()
- {
- this.mainPanel.setOpaque(false);
- this.labelsPanel.setOpaque(false);
- this.valuesPanel.setOpaque(false);
- this.accountPanel.setOpaque(false);
- this.identityFilePanel.setOpaque(false);
- this.knownHostsFilePanel.setOpaque(false);
- this.emptyPanel1.setOpaque(false);
- this.emptyPanel2.setOpaque(false);
- this.emptyPanel3.setOpaque(false);
- this.emptyPanel4.setOpaque(false);
- this.emptyPanel5.setOpaque(false);
- this.emptyPanel6.setOpaque(false);
- this.emptyPanel7.setOpaque(false);
- this.emptyPanel8.setOpaque(false);
- this.emptyPanel9.setOpaque(false);
-
- this.userIDField.getDocument().addDocumentListener(this);
-
- /*
- * Following empty panels cover the space needed between key labels
- * WRT Height 2 key lables = 1 text field
- */
- this.emptyPanel1.setMaximumSize(new Dimension(40, 35));
- this.emptyPanel2.setMaximumSize(new Dimension(40, 35));
- this.emptyPanel3.setMaximumSize(new Dimension(40, 35));
- this.emptyPanel4.setMaximumSize(new Dimension(40, 35));
- this.emptyPanel5.setMaximumSize(new Dimension(40, 35));
- this.emptyPanel6.setMaximumSize(new Dimension(40, 35));
- this.emptyPanel7.setMaximumSize(new Dimension(40, 35));
-
- identityFilePanel.add(identityFileField);
- identityFilePanel.add(identityFileButton);
-
- knownHostsFilePanel.add(knownHostsFileField);
- knownHostsFilePanel.add(knownHostsFileButton);
-
- labelsPanel.add(emptyPanel1);
- labelsPanel.add(accountID);
- labelsPanel.add(emptyPanel2);
- labelsPanel.add(emptyPanel3);
- labelsPanel.add(identityFile);
- labelsPanel.add(emptyPanel4);
- labelsPanel.add(emptyPanel5);
- labelsPanel.add(knownHostsFile);
- labelsPanel.add(emptyPanel6);
-
- valuesPanel.add(userIDField);
- valuesPanel.add(emptyPanel7);
- valuesPanel.add(identityFilePanel);
- valuesPanel.add(emptyPanel8);
- valuesPanel.add(knownHostsFilePanel);
- labelsPanel.add(emptyPanel9);
-
- accountPanel.add(labelsPanel, BorderLayout.WEST);
- accountPanel.add(valuesPanel, BorderLayout.CENTER);
-
- identityFileButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- identityFileChooser = GenericFileDialog.create(
- null, "Select Identify File",
- SipCommFileChooser.LOAD_FILE_OPERATION);
- File f = identityFileChooser.getFileFromDialog();
-
- if(f != null)
- identityFileField.setText(f.getAbsolutePath());
- }
- }
- );
-
- knownHostsFileButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- knownHostsFileChooser = GenericFileDialog.create(
- null, "Select SSH Known Hosts File",
- SipCommFileChooser.LOAD_FILE_OPERATION);
- File f = knownHostsFileChooser.getFileFromDialog();
-
- if(f != null)
- knownHostsFileField.setText(f.getAbsolutePath());
- }
- }
- );
-
- accountPanel.setBorder(BorderFactory
- .createTitledBorder(Resources.getString(
- "plugin.sshaccregwizz.ACCOUNT_DETAILS")));
-
- this.add(accountPanel, BorderLayout.NORTH);
- }
-
- /**
- * Fills the Account ID, Identity File and Known Hosts File fields in this
- * panel with the data coming from the given protocolProvider.
- *
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load the
- * data from.
- */
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- if (!(protocolProvider instanceof ProtocolProviderServiceSSHImpl))
- throw new ClassCastException("protocolProvider");
-
- AccountID accountID = protocolProvider.getAccountID();
-
- String identityFile =
- accountID
- .getAccountPropertyString(ProtocolProviderFactorySSH.IDENTITY_FILE);
-
- String knownHostsFile =
- accountID
- .getAccountPropertyString(ProtocolProviderFactorySSH.KNOWN_HOSTS_FILE);
-
- this.userIDField.setText(accountID.getUserID());
-
- this.identityFileField.setText(identityFile);
-
- this.knownHostsFileField.setText(knownHostsFile);
- }
-
- /**
- * Implements the <code>WizardPage.getIdentifier</code> to return
- * this page identifier.
- *
- * @return the Identifier of the first page in this wizard.
- */
- public Object getIdentifier()
- {
- return FIRST_PAGE_IDENTIFIER;
- }
-
- /**
- * Implements the <code>WizardPage.getNextPageIdentifier</code> to return
- * the next page identifier - the summary page.
- *
- * @return the identifier of the page following this one.
- */
- public Object getNextPageIdentifier()
- {
- return nextPageIdentifier;
- }
-
- /**
- * Implements the <code>WizardPage.getBackPageIdentifier</code> to return
- * the back identifier. In this case it's null because this is the first
- * wizard page.
- *
- * @return the identifier of the previous wizard page
- */
- public Object getBackPageIdentifier()
- {
- return null;
- }
-
- /**
- * Implements the <code>WizardPage.getWizardForm</code> to return
- * this panel.
- *
- * @return the component to be displayed in this wizard page.
- */
- public Object getWizardForm()
- {
- return this;
- }
-
- /**
- * Before this page is displayed enables or disables the "Next" wizard
- * button according to whether the UserID field is empty.
- */
- public void pageShowing()
- {
- this.setNextButtonAccordingToUserID();
- }
-
- /**
- * Saves the user input when the "Next" wizard buttons is clicked.
- */
- public void commitPage()
- {
- String userID = userIDField.getText();
-
- if(userID == null || userID.trim().length() == 0)
- throw new IllegalStateException("No user ID provided.");
-
- registration.setUserID(userID);
- registration.setIdentityFile(identityFileField.getText());
- registration.setKnownHostsFile(knownHostsFileField.getText());
-
- nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
-
- isCommitted = true;
- }
-
- /**
- * Enables or disables the "Next" wizard button according to whether the
- * User ID field is empty.
- */
- private void setNextButtonAccordingToUserID()
- {
- if (userIDField.getText() == null || userIDField.getText()
- .equals(""))
- {
- wizardContainer.setNextFinishButtonEnabled(false);
- }
- else
- {
- wizardContainer.setNextFinishButtonEnabled(true);
- }
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user types in the
- * User ID field. Enables or disables the "Next" wizard button according to
- * whether the User ID field is empty.
- *
- * @param event the event containing the update.
- */
- public void insertUpdate(DocumentEvent event)
- {
- this.setNextButtonAccordingToUserID();
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
- * from the UserID field. Enables or disables the "Next" wizard button
- * according to whether the UserID field is empty.
- *
- * @param event the event containing the update.
- */
- public void removeUpdate(DocumentEvent event)
- {
- this.setNextButtonAccordingToUserID();
- }
-
- public void changedUpdate(DocumentEvent event)
- {
- }
-
- public void pageHiding()
- {
- }
-
- public void pageShown()
- {
- }
-
- public void pageBack()
- {
- }
-
- public Object getSimpleForm()
- {
- return accountPanel;
- }
-
- public boolean isCommitted()
- {
- return isCommitted;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java
deleted file mode 100644
index 3c2f462..0000000
--- a/src/net/java/sip/communicator/plugin/sshaccregwizz/Resources.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.sshaccregwizz;
-
-import net.java.sip.communicator.service.resources.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The <tt>Resources</tt> class manages the access to the internationalization
- * properties files and the image resources used in this plugin.
- *
- * @author Shobhit Jindal
- */
-public class Resources
-{
- private static ResourceManagementService resourcesService;
-
- public static ImageID SSH_LOGO
- = new ImageID("service.protocol.ssh.SSH_16x16");
-
- public static ImageID PAGE_IMAGE
- = new ImageID("service.protocol.ssh.SSH_64x64");
-
- /**
- * 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)
- {
- return getResources().getI18NString(key);
- }
-
- /**
- * Loads an image from a given image identifier.
- *
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static byte[] getImage(ImageID imageID)
- {
- return getResources().getImageInBytes(imageID.getId());
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(SSHAccRegWizzActivator.bundleContext);
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccRegWizzActivator.java
deleted file mode 100644
index 459fb39..0000000
--- a/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccRegWizzActivator.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.sshaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * Registers the <tt>SSHAccountRegistrationWizard</tt> in the UI Service.
- *
- * @author Shobhit Jindal
- */
-public class SSHAccRegWizzActivator
- implements BundleActivator
-{
- private static final Logger logger =
- Logger.getLogger(SSHAccRegWizzActivator.class);
-
- /**
- * A currently valid bundle context.
- */
- public static BundleContext bundleContext;
-
- private static WizardContainer wizardContainer;
-
- private static SSHAccountRegistrationWizard sshWizard;
-
- private static UIService uiService;
-
- /**
- * Starts this bundle.
- * @param bc the currently valid <tt>BundleContext</tt>.
- */
- public void start(BundleContext bc)
- {
- if (logger.isInfoEnabled())
- logger.info("Loading ssh account wizard.");
-
- bundleContext = bc;
-
- ServiceReference uiServiceRef = bundleContext
- .getServiceReference(UIService.class.getName());
-
- uiService = (UIService) bundleContext
- .getService(uiServiceRef);
-
- wizardContainer = uiService.getAccountRegWizardContainer();
-
- sshWizard
- = new SSHAccountRegistrationWizard(wizardContainer);
-
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
-
- containerFilter.put(
- ProtocolProviderFactory.PROTOCOL,
- ProtocolNames.SSH);
-
- bundleContext.registerService(
- AccountRegistrationWizard.class.getName(),
- sshWizard,
- containerFilter);
-
- if (logger.isInfoEnabled())
- logger.info("SSH account registration wizard [STARTED].");
- }
-
- /**
- * Called when this bundle is stopped so the Framework can perform the
- * bundle-specific activities necessary to stop the bundle.
- *
- * @param bundleContext The execution context of the bundle being stopped.
- */
- public void stop(BundleContext bundleContext) throws Exception
- {
- }
-
- /**
- * Returns the <tt>ProtocolProviderFactory</tt> for the SSH protocol.
- * @return the <tt>ProtocolProviderFactory</tt> for the SSH protocol
- */
- public static ProtocolProviderFactory getSSHProtocolProviderFactory()
- {
- ServiceReference[] serRefs = null;
- String osgiFilter = "(" + ProtocolProviderFactory.PROTOCOL + "=SSH)";
-
- try
- {
- serRefs
- = bundleContext.getServiceReferences(
- ProtocolProviderFactory.class.getName(),
- osgiFilter);
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error(ex);
- }
-
- return
- (serRefs == null)
- ? null
- : (ProtocolProviderFactory)
- bundleContext.getService(serRefs[0]);
- }
-
- /**
- * Returns the bundleContext that we received when we were started.
- *
- * @return a currently valid instance of a bundleContext.
- */
- public BundleContext getBundleContext()
- {
- return bundleContext;
- }
-
- /**
- * Returns the <tt>UIService</tt>.
- *
- * @return the <tt>UIService</tt>
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccountRegistration.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccountRegistration.java
deleted file mode 100644
index 023ffee..0000000
--- a/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccountRegistration.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.java.sip.communicator.plugin.sshaccregwizz;
-
-/**
- * The <tt>SSHAccountRegistration</tt> is used to store all user input data
- * through the <tt>SSHAccountRegistrationWizard</tt>.
- *
- * @author Shobhit Jindal
- */
-public class SSHAccountRegistration
-{
- private String accountID;
-
- /**
- * Stored public keys[SSH] of remote server
- */
- private String knownHostsFile;
-
- /**
- * Identity file is a private[default] key of the user which is one
- * of the methods of authentication
- */
- private String identityFile;
-
- /**
- * Returns the Account ID of the ssh registration account.
- * @return accountID
- */
- public String getAccountID()
- {
- return accountID;
- }
-
- /**
- * Sets the Account ID of the ssh registration account.
- *
- * @param accountID the accountID of the ssh registration account.
- */
- public void setUserID(String accountID)
- {
- this.accountID = accountID;
- }
-
- /**
- * Returns the Known Hosts of the ssh registration account.
- *
- * @return knownHostsFile
- */
- public String getKnownHostsFile()
- {
- return knownHostsFile;
- }
-
- /**
- * Sets the Known Hosts of the ssh registration account.
- *
- * @param knownHostsFile
- */
- public void setKnownHostsFile(String knownHostsFile)
- {
- this.knownHostsFile = knownHostsFile;
- }
-
- /**
- * Returns the Identity File of the ssh registration account.
- *
- * @return identityFile
- */
- public String getIdentityFile()
- {
- return identityFile;
- }
-
- /**
- * Sets the Machine Port of the ssh registration account.
- *
- * @param machinePort
- */
- public void setIdentityFile(String machinePort)
- {
- this.identityFile = machinePort;
- }
-}
-
diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccountRegistrationWizard.java
deleted file mode 100644
index 77c398b..0000000
--- a/src/net/java/sip/communicator/plugin/sshaccregwizz/SSHAccountRegistrationWizard.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.java.sip.communicator.plugin.sshaccregwizz;
-
-import java.awt.*;
-import java.util.*;
-
-import net.java.sip.communicator.impl.protocol.ssh.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * The <tt>SSHAccountRegistrationWizard</tt> is an implementation of the
- * <tt>AccountRegistrationWizard</tt> for the SSH protocol. It allows
- * the user to create and configure a new SSH account.
- *
- * @author Shobhit Jindal
- */
-public class SSHAccountRegistrationWizard
- extends DesktopAccountRegistrationWizard
-{
- private final Logger logger
- = Logger.getLogger(SSHAccountRegistrationWizard.class);
-
- /**
- * The first page of the ssh account registration wizard.
- */
- private FirstWizardPage firstWizardPage;
-
- /**
- * The object that we use to store details on an account that we will be
- * creating.
- */
- private SSHAccountRegistration registration
- = new SSHAccountRegistration();
-
- private ProtocolProviderService protocolProvider;
-
- /**
- * Creates an instance of <tt>SSHAccountRegistrationWizard</tt>.
- * @param wizardContainer the wizard container, where this wizard
- * is added
- */
- public SSHAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- setWizardContainer(wizardContainer);
-
- wizardContainer.setFinishButtonText(
- Resources.getString("service.gui.SIGN_IN"));
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * Returns the icon to be used for this wizard.
- * @return byte[]
- */
- @Override
- public byte[] getIcon()
- {
- return Resources.getImage(Resources.SSH_LOGO);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code>
- * method.
- * Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- @Override
- public byte[] getPageImage()
- {
- return Resources.getImage(Resources.PAGE_IMAGE);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method. Returns the protocol name for this wizard.
- * @return String
- */
- @Override
- public String getProtocolName()
- {
- return Resources.getString("plugin.sshaccregwizz.PROTOCOL_NAME");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code> method. Returns the description of the protocol for this wizard.
- * @return String
- */
- @Override
- public String getProtocolDescription()
- {
- return Resources.getString("plugin.sshaccregwizz.PROTOCOL_DESCRIPTION");
- }
-
- /**
- * Returns the set of pages contained in this wizard.
- * @return Iterator
- */
- @Override
- public Iterator<WizardPage> getPages()
- {
- java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
- firstWizardPage
- = new FirstWizardPage(registration, getWizardContainer());
-
- pages.add(firstWizardPage);
-
- return pages.iterator();
- }
-
- /**
- * Returns the set of data that user has entered through this wizard.
- * @return Iterator
- */
- @Override
- public Iterator<Map.Entry<String, String>> getSummary() {
- Hashtable<String, String> summaryTable
- = new Hashtable<String, String>();
-
- /*
- * Hashtable arranges the entries alphabetically so the order
- * of appearance is
- * - Computer Name / IP
- * - Port
- * - User ID
- */
- summaryTable.put("Account ID", registration.getAccountID());
- summaryTable.put("Known Hosts", registration.getKnownHostsFile());
- summaryTable.put("Identity", registration.getIdentityFile());
-
- return summaryTable.entrySet().iterator();
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin()
- throws OperationFailedException
- {
- firstWizardPage.commitPage();
-
- return signin(registration.getAccountID(), null);
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- *
- * @param userName the user name to sign in with
- * @param password the password to sign in with
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin(String userName, String password)
- throws OperationFailedException
- {
- ProtocolProviderFactory factory
- = SSHAccRegWizzActivator.getSSHProtocolProviderFactory();
-
- return this.installAccount( factory,
- userName);
- }
-
- /**
- * Creates an account for the given Account ID, Identity File and Known
- * Hosts File
- *
- * @param providerFactory the ProtocolProviderFactory which will create
- * the account
- * @param user the user identifier
- * @return the <tt>ProtocolProviderService</tt> for the new account.
- */
- public ProtocolProviderService installAccount(
- ProtocolProviderFactory providerFactory,
- String user)
- throws OperationFailedException
- {
- Hashtable<String, String> accountProperties
- = new Hashtable<String, String>();
-
- accountProperties.put(ProtocolProviderFactory.ACCOUNT_ICON_PATH,
- "resources/images/protocol/ssh/ssh32x32.png");
-
- accountProperties.put(
- ProtocolProviderFactory.NO_PASSWORD_REQUIRED,
- new Boolean(true).toString());
-
- accountProperties.put(ProtocolProviderFactorySSHImpl.IDENTITY_FILE,
- registration.getIdentityFile());
-
- accountProperties.put(ProtocolProviderFactorySSHImpl.KNOWN_HOSTS_FILE,
- String.valueOf(registration.getKnownHostsFile()));
-
- try
- {
- AccountID accountID = providerFactory.installAccount(
- user, accountProperties);
-
- ServiceReference serRef = providerFactory
- .getProviderForAccount(accountID);
-
- protocolProvider = (ProtocolProviderService)
- SSHAccRegWizzActivator.bundleContext
- .getService(serRef);
- }
- catch (IllegalStateException exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Account already exists.",
- OperationFailedException.IDENTIFICATION_CONFLICT);
- }
- catch (Exception exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Failed to add account",
- OperationFailedException.GENERAL_ERROR);
- }
-
- return protocolProvider;
- }
-
- /**
- * Fills the UserID and Password fields in this panel with the data comming
- * from the given protocolProvider.
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load the
- * data from.
- */
- @Override
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- this.protocolProvider = protocolProvider;
-
- this.firstWizardPage.loadAccount(protocolProvider);
-
- setModification(true);
- }
-
- /**
- * Returns the size of this wizard.
- * @return the size of this wizard
- */
- @Override
- public Dimension getSize()
- {
- return new Dimension(600, 500);
- }
-
- /**
- * Returns the identifier of the first account registration wizard page.
- * This method is meant to be used by the wizard container to determine,
- * which is the first page to show to the user.
- *
- * @return the identifier of the first account registration wizard page
- */
- @Override
- public Object getFirstPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- @Override
- public Object getLastPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- /**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
- */
- @Override
- public String getUserNameExample()
- {
- return null;
- }
-
- /**
- * Indicates whether this wizard enables the simple "sign in" form shown
- * when the user opens the application for the first time. The simple
- * "sign in" form allows user to configure her account in one click, just
- * specifying her username and password and leaving any other configuration
- * as by default.
- * @return <code>true</code> if the simple "Sign in" form is enabled or
- * <code>false</code> otherwise.
- */
- @Override
- public boolean isSimpleFormEnabled()
- {
- return false;
- }
-
- /**
- * Returns a simple account registration form that would be the first form
- * shown to the user. Only if the user needs more settings she'll choose
- * to open the advanced wizard, consisted by all pages.
- *
- * @param isCreateAccount indicates if the simple form should be opened as
- * a create account form or as a login form
- * @return a simple account registration form
- */
- @Override
- public Object getSimpleForm(boolean isCreateAccount)
- {
- firstWizardPage = new FirstWizardPage(registration, getWizardContainer());
- return firstWizardPage.getSimpleForm();
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/sshaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/sshaccregwizz/sshaccregwizz.manifest.mf
deleted file mode 100644
index c48b853..0000000
--- a/src/net/java/sip/communicator/plugin/sshaccregwizz/sshaccregwizz.manifest.mf
+++ /dev/null
@@ -1,32 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.plugin.sshaccregwizz.SSHAccRegWizzActivator
-Bundle-Name: SSH account registration wizard
-Bundle-Description: SSH account registration wizard.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.plugin.sshaccregwizz
-Import-Package: org.osgi.framework,
- net.java.sip.communicator.service.browserlauncher,
- org.jitsi.service.configuration,
- net.java.sip.communicator.service.contactlist,
- net.java.sip.communicator.service.contactlist.event,
- net.java.sip.communicator.service.gui,
- net.java.sip.communicator.service.gui.event,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.plugin.desktoputil,
- javax.swing,
- javax.swing.event,
- javax.swing.table,
- javax.swing.text,
- javax.swing.text.html,
- javax.accessibility,
- javax.swing.plaf,
- javax.swing.plaf.metal,
- javax.swing.plaf.basic,
- javax.imageio,
- javax.swing.filechooser,
- javax.swing.tree,
- javax.swing.undo,
- javax.swing.border
diff --git a/src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdActivator.java b/src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdActivator.java
index 2a1bbe3..00c204e 100644
--- a/src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdActivator.java
+++ b/src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdActivator.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,170 +15,170 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.thunderbird;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.contactsource.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.jitsi.service.configuration.*;
-import org.jitsi.service.resources.*;
-import org.osgi.framework.*;
-
-/**
- * Bundle-Activator for the Thunderbird address book contact source plug-in.
- *
- * @author Ingo Bauersachs
- */
-public class ThunderbirdActivator
- implements BundleActivator
-{
- /** OSGi context. */
- private static BundleContext bundleContext;
-
- /** Active address book registrations. */
- private static Map<ThunderbirdContactSourceService, ServiceRegistration>
- registrations;
-
- /**
- * The registered PhoneNumberI18nService.
- */
- private static PhoneNumberI18nService phoneNumberI18nService;
-
- /**
- * Gets the configuration service.
- * @return the configuration service.
- */
- static ConfigurationService getConfigService()
- {
- return ServiceUtils.getService(bundleContext,
- ConfigurationService.class);
- }
-
- /**
- * Gets the resource service.
- * @return the resource service.
- */
- static ResourceManagementService getResources()
- {
- return ServiceUtils.getService(bundleContext,
- ResourceManagementService.class);
- }
-
- /**
- * Gets all registered Thunderbird address book services.
- * @return all registered Thunderbird address book services.
- */
- static List<ThunderbirdContactSourceService> getActiveServices()
- {
- return new LinkedList<ThunderbirdContactSourceService>(
- registrations.keySet());
- }
-
- /**
- * Loads and registers an address book service.
- * @param config the name of the base property of the service to load.
- */
- static void add(String config)
- {
- ThunderbirdContactSourceService service
- = new ThunderbirdContactSourceService(config);
- registrations.put(service,
- bundleContext.registerService(
- ContactSourceService.class.getName(), service, null));
- }
-
- /**
- * Stops an address book service and deletes the corresponding configuration
- * data.
- *
- * @param service the address book instance to remove.
- */
- static void remove(ThunderbirdContactSourceService service)
- {
- registrations.get(service).unregister();
- registrations.remove(service);
- ConfigurationService config = getConfigService();
- config.removeProperty(service.getBaseConfigProperty());
- for (String prop : config.getPropertyNamesByPrefix(
- service.getBaseConfigProperty(), false))
- {
- config.removeProperty(prop);
- }
- }
-
- /**
- * Searches the configuration for Thunderbird address books and registers a
- * {@link ContactSourceService} for each found config.
- */
- public void start(BundleContext bundleContext) throws Exception
- {
- ThunderbirdActivator.bundleContext = bundleContext;
-
- ConfigurationService config = getConfigService();
- List<String> configs =
- config.getPropertyNamesByPrefix(
- ThunderbirdContactSourceService.PNAME_BASE_THUNDERBIRD_CONFIG,
- false);
-
- registrations = new HashMap
- <ThunderbirdContactSourceService, ServiceRegistration>();
- for (String cfg : configs)
- {
- String value = config.getString(cfg);
- if (value != null && cfg.endsWith(value))
- {
- add(cfg);
- }
- }
-
- /* registers the configuration form */
- Dictionary<String, String> properties
- = new Hashtable<String, String>();
- properties.put(
- ConfigurationForm.FORM_TYPE,
- ConfigurationForm.CONTACT_SOURCE_TYPE);
-
- bundleContext.registerService(
- ConfigurationForm.class.getName(),
- new LazyConfigurationForm(
- ThunderbirdConfigForm.class.getName(),
- getClass().getClassLoader(),
- null,
- "plugin.thunderbird.CONFIG_FORM_TITLE"),
- properties);
- }
-
- /**
- * Unregisters all {@link ContactSourceService}s that were registered by
- * this activator.
- */
- public void stop(BundleContext bundleContext) throws Exception
- {
- for (ServiceRegistration sr : registrations.values())
- {
- sr.unregister();
- }
-
- registrations = null;
- }
-
- /**
- * Returns the PhoneNumberI18nService.
- * @return returns the PhoneNumberI18nService.
- */
- public static PhoneNumberI18nService getPhoneNumberI18nService()
- {
- if(phoneNumberI18nService == null)
- {
- phoneNumberI18nService = ServiceUtils.getService(
- bundleContext,
- PhoneNumberI18nService.class);
- }
-
- return phoneNumberI18nService;
- }
-}
+package net.java.sip.communicator.plugin.thunderbird;
+
+import java.util.*;
+
+import net.java.sip.communicator.service.contactsource.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+import org.jitsi.service.configuration.*;
+import org.jitsi.service.resources.*;
+import org.osgi.framework.*;
+
+/**
+ * Bundle-Activator for the Thunderbird address book contact source plug-in.
+ *
+ * @author Ingo Bauersachs
+ */
+public class ThunderbirdActivator
+ implements BundleActivator
+{
+ /** OSGi context. */
+ private static BundleContext bundleContext;
+
+ /** Active address book registrations. */
+ private static Map<ThunderbirdContactSourceService, ServiceRegistration>
+ registrations;
+
+ /**
+ * The registered PhoneNumberI18nService.
+ */
+ private static PhoneNumberI18nService phoneNumberI18nService;
+
+ /**
+ * Gets the configuration service.
+ * @return the configuration service.
+ */
+ static ConfigurationService getConfigService()
+ {
+ return ServiceUtils.getService(bundleContext,
+ ConfigurationService.class);
+ }
+
+ /**
+ * Gets the resource service.
+ * @return the resource service.
+ */
+ static ResourceManagementService getResources()
+ {
+ return ServiceUtils.getService(bundleContext,
+ ResourceManagementService.class);
+ }
+
+ /**
+ * Gets all registered Thunderbird address book services.
+ * @return all registered Thunderbird address book services.
+ */
+ static List<ThunderbirdContactSourceService> getActiveServices()
+ {
+ return new LinkedList<ThunderbirdContactSourceService>(
+ registrations.keySet());
+ }
+
+ /**
+ * Loads and registers an address book service.
+ * @param config the name of the base property of the service to load.
+ */
+ static void add(String config)
+ {
+ ThunderbirdContactSourceService service
+ = new ThunderbirdContactSourceService(config);
+ registrations.put(service,
+ bundleContext.registerService(
+ ContactSourceService.class.getName(), service, null));
+ }
+
+ /**
+ * Stops an address book service and deletes the corresponding configuration
+ * data.
+ *
+ * @param service the address book instance to remove.
+ */
+ static void remove(ThunderbirdContactSourceService service)
+ {
+ registrations.get(service).unregister();
+ registrations.remove(service);
+ ConfigurationService config = getConfigService();
+ config.removeProperty(service.getBaseConfigProperty());
+ for (String prop : config.getPropertyNamesByPrefix(
+ service.getBaseConfigProperty(), false))
+ {
+ config.removeProperty(prop);
+ }
+ }
+
+ /**
+ * Searches the configuration for Thunderbird address books and registers a
+ * {@link ContactSourceService} for each found config.
+ */
+ public void start(BundleContext bundleContext) throws Exception
+ {
+ ThunderbirdActivator.bundleContext = bundleContext;
+
+ ConfigurationService config = getConfigService();
+ List<String> configs =
+ config.getPropertyNamesByPrefix(
+ ThunderbirdContactSourceService.PNAME_BASE_THUNDERBIRD_CONFIG,
+ false);
+
+ registrations = new HashMap
+ <ThunderbirdContactSourceService, ServiceRegistration>();
+ for (String cfg : configs)
+ {
+ String value = config.getString(cfg);
+ if (value != null && cfg.endsWith(value))
+ {
+ add(cfg);
+ }
+ }
+
+ /* registers the configuration form */
+ Dictionary<String, String> properties
+ = new Hashtable<String, String>();
+ properties.put(
+ ConfigurationForm.FORM_TYPE,
+ ConfigurationForm.CONTACT_SOURCE_TYPE);
+
+ bundleContext.registerService(
+ ConfigurationForm.class.getName(),
+ new LazyConfigurationForm(
+ ThunderbirdConfigForm.class.getName(),
+ getClass().getClassLoader(),
+ null,
+ "plugin.thunderbird.CONFIG_FORM_TITLE"),
+ properties);
+ }
+
+ /**
+ * Unregisters all {@link ContactSourceService}s that were registered by
+ * this activator.
+ */
+ public void stop(BundleContext bundleContext) throws Exception
+ {
+ for (ServiceRegistration sr : registrations.values())
+ {
+ sr.unregister();
+ }
+
+ registrations = null;
+ }
+
+ /**
+ * Returns the PhoneNumberI18nService.
+ * @return returns the PhoneNumberI18nService.
+ */
+ public static PhoneNumberI18nService getPhoneNumberI18nService()
+ {
+ if(phoneNumberI18nService == null)
+ {
+ phoneNumberI18nService = ServiceUtils.getService(
+ bundleContext,
+ PhoneNumberI18nService.class);
+ }
+
+ return phoneNumberI18nService;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdContactQuery.java b/src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdContactQuery.java
index 429ff6c..00488f9 100644
--- a/src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdContactQuery.java
+++ b/src/net/java/sip/communicator/plugin/thunderbird/ThunderbirdContactQuery.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,267 +15,267 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.thunderbird;
-
-import java.io.*;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.regex.*;
-
-import org.jitsi.util.StringUtils;
-
-import mork.*;
-import net.java.sip.communicator.service.contactsource.*;
-import net.java.sip.communicator.service.contactsource.ContactDetail.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-/**
- * Queries a Thunderbird address book for contacts matching the given pattern.
- *
- * @author Ingo Bauersachs
- */
-public class ThunderbirdContactQuery
- extends AsyncContactQuery<ThunderbirdContactSourceService>
-{
- /** Class logger */
- private final static Logger logger = Logger
- .getLogger(ThunderbirdContactQuery.class);
-
- /**
- * Creates a new instance of this class.
- *
- * @param owner The contact source that created this query.
- * @param query The pattern to match against the contacts database.
- */
- public ThunderbirdContactQuery(ThunderbirdContactSourceService owner,
- Pattern query)
- {
- super(owner, query);
- }
-
- /**
- * Starts the query against the address book database.
- */
- @Override
- protected void run()
- {
- String filename = super.getContactSource().getFilename();
- File file = new File(filename);
- try
- {
- if (file.lastModified() > getContactSource().lastDatabaseFileChange)
- {
- // parse the Thunderbird Mork database
- InputStreamReader sr =
- new InputStreamReader(new FileInputStream(filename));
- MorkDocument md = new MorkDocument(sr);
- sr.close();
-
- // We now have rows in their tables and additional rows at
- // transaction level. Put the to a better format:
- // DB -> Tables -> Rows
- Map<String, Map<String, Row>> db =
- new HashMap<String, Map<String, Row>>();
- for (Table t : md.getTables())
- {
- String tableId = t.getTableId() + "/" + t.getScopeName();
- Map<String, Row> table = db.get(tableId);
- if (table == null)
- {
- table = new HashMap<String, Row>();
- db.put(tableId, table);
- }
-
- for (Row r : t.getRows())
- {
- String scope = r.getScopeName();
- if (scope == null)
- {
- scope = t.getScopeName();
- }
-
- table.put(r.getRowId() + "/" + scope, r);
- }
- }
-
- // The additional rows at the root-level update/replace the ones
- // in the tables. There's usually neither a table nor a scope
- // defined, so lets just use the default.
- String defaultScope = md.getDicts().get(0).dereference("^80");
- for (Row r : md.getRows())
- {
- String scope = r.getScopeName();
- if (scope == null)
- {
- scope = defaultScope;
- }
-
- String tableId = "1/" + scope;
- Map<String, Row> table = db.get(tableId);
- if (table == null)
- {
- table = new HashMap<String, Row>();
- db.put(tableId, table);
- }
-
- String rowId = r.getRowId() + "/" + scope;
- if (rowId.startsWith("-"))
- {
- rowId = rowId.substring(1);
- }
-
- table.put(rowId, r);
- }
-
- super.getContactSource().database = db;
- super.getContactSource().defaultScope = defaultScope;
- super.getContactSource().lastDatabaseFileChange =
- file.lastModified();
- }
-
- // okay, "transactions" are applied, now perform the search
- for (Entry<String, Map<String, Row>> table
- : super.getContactSource().database.entrySet())
- {
- for (Map.Entry<String, Row> e : table.getValue().entrySet())
- {
- if (e.getKey().endsWith(getContactSource().defaultScope))
- {
- readEntry(e.getValue());
- }
- }
- }
-
- super.stopped(true);
- }
- catch (FileNotFoundException e)
- {
- logger.warn("Could not open address book", e);
- }
- catch (Exception e)
- {
- logger.warn("Could not parse " + file, e);
- }
- }
-
- /**
- * Processes a database row by matching it against the query and adding it
- * to the result set if it matched.
- *
- * @param r The database row representing a contact.
- */
- private void readEntry(Row r)
- {
- // match the pattern against this contact
- boolean hadMatch = false;
- for (Alias value : r.getAliases().values())
- {
- if (value != null
- && (super.query.matcher(value.getValue()).find() || super
- .phoneNumberMatches(value.getValue())))
- {
- hadMatch = true;
- break;
- }
- }
-
- // nope, didn't match, ignore
- if (!hadMatch)
- {
- return;
- }
-
- List<ContactDetail> details = new LinkedList<ContactDetail>();
-
- // e-mail(s)
- for (String email : getPropertySet(r, "PrimaryEmail", "SecondEmail",
- "DefaultEmail"))
- {
- ContactDetail detail = new ContactDetail(email, Category.Email);
- detail.addSupportedOpSet(OperationSetPersistentPresence.class);
- details.add(detail);
- }
-
- // phone number(s)
- this.addPhoneDetail(details, r, "HomePhone", SubCategory.Home);
- this.addPhoneDetail(details, r, "WorkPhone", SubCategory.Work);
- this.addPhoneDetail(details, r, "CellularNumber", SubCategory.Mobile);
-
- // and the dispaly name
- String displayName = r.getValue("DisplayName");
- if (StringUtils.isNullOrEmpty(displayName, true))
- {
- displayName = r.getValue("LastName");
- if (displayName != null)
- {
- displayName = displayName.trim();
- }
-
- String firstName = r.getValue("FirstName");
- if (!StringUtils.isNullOrEmpty(firstName, true))
- {
- displayName = firstName + " " + displayName;
- }
- }
-
- // create the contact and add it to the results
- GenericSourceContact sc =
- new GenericSourceContact(super.getContactSource(), displayName,
- details);
- addQueryResult(sc);
- }
-
- /**
- * Adds a "Phone" {@link ContactDetail} to a query contact.
- *
- * @param details The {@link List} of {@link ContactDetail}s to which the
- * details is added.
- * @param r The source database row of the contact.
- * @param property The source database property name to add as a detail.
- * @param category The Phone-{@link SubCategory} for the phone number to
- * add.
- */
- private void addPhoneDetail(List<ContactDetail> details, Row r,
- String property, SubCategory category)
- {
- String phone = r.getValue(property);
- if (StringUtils.isNullOrEmpty(phone, true))
- {
- return;
- }
-
- phone
- = ThunderbirdActivator.getPhoneNumberI18nService().normalize(phone);
- ContactDetail detail =
- new ContactDetail(phone, ContactDetail.Category.Phone,
- new ContactDetail.SubCategory[]
- { category });
-
- detail.addSupportedOpSet(OperationSetBasicTelephony.class);
- detail.addSupportedOpSet(OperationSetPersistentPresence.class);
- details.add(detail);
- }
-
- /**
- * Gets a set of non-empty properties from the source database row.
- *
- * @param r The source database row to process.
- * @param properties The property-names to extract.
- * @return A set of non-empty properties from the source database row.
- */
- private Set<String> getPropertySet(Row r, String... properties)
- {
- Set<String> validValues = new HashSet<String>(properties.length);
- for (String prop : properties)
- {
- String value = r.getValue(prop);
- if (!StringUtils.isNullOrEmpty(value, true))
- {
- validValues.add(value);
- }
- }
-
- return validValues;
- }
-}
+package net.java.sip.communicator.plugin.thunderbird;
+
+import java.io.*;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.regex.*;
+
+import org.jitsi.util.StringUtils;
+
+import mork.*;
+import net.java.sip.communicator.service.contactsource.*;
+import net.java.sip.communicator.service.contactsource.ContactDetail.*;
+import net.java.sip.communicator.service.protocol.*;
+import net.java.sip.communicator.util.*;
+
+/**
+ * Queries a Thunderbird address book for contacts matching the given pattern.
+ *
+ * @author Ingo Bauersachs
+ */
+public class ThunderbirdContactQuery
+ extends AsyncContactQuery<ThunderbirdContactSourceService>
+{
+ /** Class logger */
+ private final static Logger logger = Logger
+ .getLogger(ThunderbirdContactQuery.class);
+
+ /**
+ * Creates a new instance of this class.
+ *
+ * @param owner The contact source that created this query.
+ * @param query The pattern to match against the contacts database.
+ */
+ public ThunderbirdContactQuery(ThunderbirdContactSourceService owner,
+ Pattern query)
+ {
+ super(owner, query);
+ }
+
+ /**
+ * Starts the query against the address book database.
+ */
+ @Override
+ protected void run()
+ {
+ String filename = super.getContactSource().getFilename();
+ File file = new File(filename);
+ try
+ {
+ if (file.lastModified() > getContactSource().lastDatabaseFileChange)
+ {
+ // parse the Thunderbird Mork database
+ InputStreamReader sr =
+ new InputStreamReader(new FileInputStream(filename));
+ MorkDocument md = new MorkDocument(sr);
+ sr.close();
+
+ // We now have rows in their tables and additional rows at
+ // transaction level. Put the to a better format:
+ // DB -> Tables -> Rows
+ Map<String, Map<String, Row>> db =
+ new HashMap<String, Map<String, Row>>();
+ for (Table t : md.getTables())
+ {
+ String tableId = t.getTableId() + "/" + t.getScopeName();
+ Map<String, Row> table = db.get(tableId);
+ if (table == null)
+ {
+ table = new HashMap<String, Row>();
+ db.put(tableId, table);
+ }
+
+ for (Row r : t.getRows())
+ {
+ String scope = r.getScopeName();
+ if (scope == null)
+ {
+ scope = t.getScopeName();
+ }
+
+ table.put(r.getRowId() + "/" + scope, r);
+ }
+ }
+
+ // The additional rows at the root-level update/replace the ones
+ // in the tables. There's usually neither a table nor a scope
+ // defined, so lets just use the default.
+ String defaultScope = md.getDicts().get(0).dereference("^80");
+ for (Row r : md.getRows())
+ {
+ String scope = r.getScopeName();
+ if (scope == null)
+ {
+ scope = defaultScope;
+ }
+
+ String tableId = "1/" + scope;
+ Map<String, Row> table = db.get(tableId);
+ if (table == null)
+ {
+ table = new HashMap<String, Row>();
+ db.put(tableId, table);
+ }
+
+ String rowId = r.getRowId() + "/" + scope;
+ if (rowId.startsWith("-"))
+ {
+ rowId = rowId.substring(1);
+ }
+
+ table.put(rowId, r);
+ }
+
+ super.getContactSource().database = db;
+ super.getContactSource().defaultScope = defaultScope;
+ super.getContactSource().lastDatabaseFileChange =
+ file.lastModified();
+ }
+
+ // okay, "transactions" are applied, now perform the search
+ for (Entry<String, Map<String, Row>> table
+ : super.getContactSource().database.entrySet())
+ {
+ for (Map.Entry<String, Row> e : table.getValue().entrySet())
+ {
+ if (e.getKey().endsWith(getContactSource().defaultScope))
+ {
+ readEntry(e.getValue());
+ }
+ }
+ }
+
+ super.stopped(true);
+ }
+ catch (FileNotFoundException e)
+ {
+ logger.warn("Could not open address book", e);
+ }
+ catch (Exception e)
+ {
+ logger.warn("Could not parse " + file, e);
+ }
+ }
+
+ /**
+ * Processes a database row by matching it against the query and adding it
+ * to the result set if it matched.
+ *
+ * @param r The database row representing a contact.
+ */
+ private void readEntry(Row r)
+ {
+ // match the pattern against this contact
+ boolean hadMatch = false;
+ for (Alias value : r.getAliases().values())
+ {
+ if (value != null
+ && (super.query.matcher(value.getValue()).find() || super
+ .phoneNumberMatches(value.getValue())))
+ {
+ hadMatch = true;
+ break;
+ }
+ }
+
+ // nope, didn't match, ignore
+ if (!hadMatch)
+ {
+ return;
+ }
+
+ List<ContactDetail> details = new LinkedList<ContactDetail>();
+
+ // e-mail(s)
+ for (String email : getPropertySet(r, "PrimaryEmail", "SecondEmail",
+ "DefaultEmail"))
+ {
+ ContactDetail detail = new ContactDetail(email, Category.Email);
+ detail.addSupportedOpSet(OperationSetPersistentPresence.class);
+ details.add(detail);
+ }
+
+ // phone number(s)
+ this.addPhoneDetail(details, r, "HomePhone", SubCategory.Home);
+ this.addPhoneDetail(details, r, "WorkPhone", SubCategory.Work);
+ this.addPhoneDetail(details, r, "CellularNumber", SubCategory.Mobile);
+
+ // and the dispaly name
+ String displayName = r.getValue("DisplayName");
+ if (StringUtils.isNullOrEmpty(displayName, true))
+ {
+ displayName = r.getValue("LastName");
+ if (displayName != null)
+ {
+ displayName = displayName.trim();
+ }
+
+ String firstName = r.getValue("FirstName");
+ if (!StringUtils.isNullOrEmpty(firstName, true))
+ {
+ displayName = firstName + " " + displayName;
+ }
+ }
+
+ // create the contact and add it to the results
+ GenericSourceContact sc =
+ new GenericSourceContact(super.getContactSource(), displayName,
+ details);
+ addQueryResult(sc);
+ }
+
+ /**
+ * Adds a "Phone" {@link ContactDetail} to a query contact.
+ *
+ * @param details The {@link List} of {@link ContactDetail}s to which the
+ * details is added.
+ * @param r The source database row of the contact.
+ * @param property The source database property name to add as a detail.
+ * @param category The Phone-{@link SubCategory} for the phone number to
+ * add.
+ */
+ private void addPhoneDetail(List<ContactDetail> details, Row r,
+ String property, SubCategory category)
+ {
+ String phone = r.getValue(property);
+ if (StringUtils.isNullOrEmpty(phone, true))
+ {
+ return;
+ }
+
+ phone
+ = ThunderbirdActivator.getPhoneNumberI18nService().normalize(phone);
+ ContactDetail detail =
+ new ContactDetail(phone, ContactDetail.Category.Phone,
+ new ContactDetail.SubCategory[]
+ { category });
+
+ detail.addSupportedOpSet(OperationSetBasicTelephony.class);
+ detail.addSupportedOpSet(OperationSetPersistentPresence.class);
+ details.add(detail);
+ }
+
+ /**
+ * Gets a set of non-empty properties from the source database row.
+ *
+ * @param r The source database row to process.
+ * @param properties The property-names to extract.
+ * @return A set of non-empty properties from the source database row.
+ */
+ private Set<String> getPropertySet(Row r, String... properties)
+ {
+ Set<String> validValues = new HashSet<String>(properties.length);
+ for (String prop : properties)
+ {
+ String value = r.getValue(prop);
+ if (!StringUtils.isNullOrEmpty(value, true))
+ {
+ validValues.add(value);
+ }
+ }
+
+ return validValues;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/update/CheckForUpdatesMenuItemComponent.java b/src/net/java/sip/communicator/plugin/update/CheckForUpdatesMenuItemComponent.java
index 20f85b8..9c61233 100644
--- a/src/net/java/sip/communicator/plugin/update/CheckForUpdatesMenuItemComponent.java
+++ b/src/net/java/sip/communicator/plugin/update/CheckForUpdatesMenuItemComponent.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,77 +15,77 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.update;
-
-import java.awt.event.*;
-
-import javax.swing.*;
-
-import net.java.sip.communicator.service.gui.*;
-
-/**
- * Implements <tt>PluginComponent</tt> for the "Check for Updates" menu
- * item.
- *
- * @author Damian Minkov
- * @author Lyubomir Marinov
- */
-public class CheckForUpdatesMenuItemComponent
- extends AbstractPluginComponent
-{
- /**
- * The "Check for Updates" menu item.
- */
- private JMenuItem checkForUpdatesMenuItem;
-
- /**
- * Initializes a new "Check for Updates" menu item.
- *
- * @param container the container of the update menu component
- */
- public CheckForUpdatesMenuItemComponent(Container container,
- PluginComponentFactory parentFactory)
- {
- super(container, parentFactory);
- }
-
- /**
- * Gets the UI <tt>Component</tt> of this <tt>PluginComponent</tt>.
- *
- * @return the UI <tt>Component</tt> of this <tt>PluginComponent</tt>
- * @see PluginComponent#getComponent()
- */
- public JMenuItem getComponent()
- {
- if(checkForUpdatesMenuItem == null)
- {
- checkForUpdatesMenuItem
- = new JMenuItem(
- Resources.getResources().getI18NString(
- "plugin.updatechecker.UPDATE_MENU_ENTRY"));
- checkForUpdatesMenuItem.addActionListener(
- new ActionListener()
- {
- public void actionPerformed(ActionEvent e)
- {
- UpdateActivator.getUpdateService().checkForUpdates(
- true);
- }
- });
- }
- return checkForUpdatesMenuItem;
- }
-
- /**
- * Gets the name of this <tt>PluginComponent</tt>.
- *
- * @return the name of this <tt>PluginComponent</tt>
- * @see PluginComponent#getName()
- */
- public String getName()
- {
- return
- Resources.getResources().getI18NString(
- "plugin.updatechecker.UPDATE_MENU_ENTRY");
- }
-}
+package net.java.sip.communicator.plugin.update;
+
+import java.awt.event.*;
+
+import javax.swing.*;
+
+import net.java.sip.communicator.service.gui.*;
+
+/**
+ * Implements <tt>PluginComponent</tt> for the "Check for Updates" menu
+ * item.
+ *
+ * @author Damian Minkov
+ * @author Lyubomir Marinov
+ */
+public class CheckForUpdatesMenuItemComponent
+ extends AbstractPluginComponent
+{
+ /**
+ * The "Check for Updates" menu item.
+ */
+ private JMenuItem checkForUpdatesMenuItem;
+
+ /**
+ * Initializes a new "Check for Updates" menu item.
+ *
+ * @param container the container of the update menu component
+ */
+ public CheckForUpdatesMenuItemComponent(Container container,
+ PluginComponentFactory parentFactory)
+ {
+ super(container, parentFactory);
+ }
+
+ /**
+ * Gets the UI <tt>Component</tt> of this <tt>PluginComponent</tt>.
+ *
+ * @return the UI <tt>Component</tt> of this <tt>PluginComponent</tt>
+ * @see PluginComponent#getComponent()
+ */
+ public JMenuItem getComponent()
+ {
+ if(checkForUpdatesMenuItem == null)
+ {
+ checkForUpdatesMenuItem
+ = new JMenuItem(
+ Resources.getResources().getI18NString(
+ "plugin.updatechecker.UPDATE_MENU_ENTRY"));
+ checkForUpdatesMenuItem.addActionListener(
+ new ActionListener()
+ {
+ public void actionPerformed(ActionEvent e)
+ {
+ UpdateActivator.getUpdateService().checkForUpdates(
+ true);
+ }
+ });
+ }
+ return checkForUpdatesMenuItem;
+ }
+
+ /**
+ * Gets the name of this <tt>PluginComponent</tt>.
+ *
+ * @return the name of this <tt>PluginComponent</tt>
+ * @see PluginComponent#getName()
+ */
+ public String getName()
+ {
+ return
+ Resources.getResources().getI18NString(
+ "plugin.updatechecker.UPDATE_MENU_ENTRY");
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/update/UpdateActivator.java b/src/net/java/sip/communicator/plugin/update/UpdateActivator.java
index 8155117..251ac7a 100644
--- a/src/net/java/sip/communicator/plugin/update/UpdateActivator.java
+++ b/src/net/java/sip/communicator/plugin/update/UpdateActivator.java
@@ -1,4 +1,4 @@
-/*
+/*
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
*
* Copyright @ 2015 Atlassian Pty Ltd
@@ -15,306 +15,306 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package net.java.sip.communicator.plugin.update;
-
-import java.util.*;
-import java.util.concurrent.*;
-
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.shutdown.*;
-import net.java.sip.communicator.service.update.*;
-import net.java.sip.communicator.util.*;
-import net.java.sip.communicator.util.Logger;
-
-import org.jitsi.service.configuration.*;
-import org.jitsi.util.*;
-import org.osgi.framework.*;
-
-/**
- * Implements <tt>BundleActivator</tt> for the update plug-in.
- *
- * @author Damian Minkov
- * @author Lyubomir Marinov
- */
-public class UpdateActivator
- extends AbstractServiceDependentActivator
-{
- /**
- * The <tt>Logger</tt> used by the <tt>UpdateActivator</tt> class and its
- * instances for logging output.
- */
- private static final Logger logger
- = Logger.getLogger(UpdateActivator.class);
-
- /**
- * The name of the configuration property which indicates whether the
- * checking for updates on application startup is enabled.
- */
- private static final String UPDATE_ENABLED
- = "net.java.sip.communicator.plugin.updatechecker.ENABLED";
-
- /**
- * The name of the configuration property which indicates whether the
- * "checking for updates" menu entry is disabled.
- */
- private static final String CHECK_FOR_UPDATES_MENU_DISABLED_PROP
- = "net.java.sip.communicator.plugin.update.checkforupdatesmenu.DISABLED";
-
- /**
- * The name of the configuration property which indicates whether the client
- * should automatically check for updates each day or not.
- */
- private static final String CHECK_FOR_UPDATES_DAILY_ENABLED_PROP =
- "net.java.sip.communicator.plugin.update.checkforupdatesmenu.daily.ENABLED";
-
- /**
- * The name of the configuration property which indicates the hour that
- * the client should check for updates (if daily update checking is enabled)
- */
- private static final String CHECK_FOR_UPDATES_DAILY_TIME_PROP =
- "net.java.sip.communicator.plugin.update.checkforupdatesmenu.daily.HOUR";
-
- /**
- * Reference to the <tt>BrowserLauncherService</tt>.
- */
- private static BrowserLauncherService browserLauncher;
-
- /**
- * The <tt>BundleContext</tt> in which the one and only
- * <tt>UpdateActivator</tt> instance of the update plug-in has been started.
- */
- static BundleContext bundleContext;
-
- /**
- * Reference to the <tt>ConfigurationService</tt>.
- */
- private static ConfigurationService configuration;
-
- /**
- * Reference to the <tt>UIService</tt>.
- */
- private static UIService uiService;
-
- /**
- * The update service.
- */
- private static UpdateService updateService;
-
- /**
- * A scheduler to check for updates once a day
- */
- private ScheduledExecutorService mUpdateExecutor = null;
-
- /**
- * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context.
- * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context
- */
- static BrowserLauncherService getBrowserLauncher()
- {
- if (browserLauncher == null)
- {
- browserLauncher
- = ServiceUtils.getService(
- bundleContext,
- BrowserLauncherService.class);
- }
- return browserLauncher;
- }
-
- /**
- * Returns the <tt>ConfigurationService</tt> obtained from the bundle
- * context.
- *
- * @return the <tt>ConfigurationService</tt> obtained from the bundle
- * context
- */
- static ConfigurationService getConfiguration()
- {
- if (configuration == null)
- {
- configuration
- = ServiceUtils.getService(
- bundleContext,
- ConfigurationService.class);
- }
- return configuration;
- }
-
- /**
- * Gets a reference to a <code>ShutdownService</code> implementation
- * currently registered in the bundle context of the active
- * <code>UpdateCheckActivator</code> instance.
- * <p>
- * The returned reference to <code>ShutdownService</code> is not being
- * cached.
- * </p>
- *
- * @return reference to a <code>ShutdownService</code> implementation
- * currently registered in the bundle context of the active
- * <code>UpdateCheckActivator</code> instance
- */
- static ShutdownService getShutdownService()
- {
- return ServiceUtils.getService(bundleContext, ShutdownService.class);
- }
-
- /**
- * Returns a reference to the UIService implementation currently registered
- * in the bundle context or null if no such implementation was found.
- *
- * @return a reference to a UIService implementation currently registered
- * in the bundle context or null if no such implementation was found.
- */
- static UIService getUIService()
- {
- if(uiService == null)
- uiService = ServiceUtils.getService(bundleContext, UIService.class);
- return uiService;
- }
-
- /**
- * The dependent service is available and the bundle will start.
- * @param dependentService the UIService this activator is waiting.
- */
- @Override
- public void start(Object dependentService)
- {
- if (logger.isDebugEnabled())
- logger.debug("Update checker [STARTED]");
-
- ConfigurationService cfg = getConfiguration();
-
- if (OSUtils.IS_WINDOWS)
- {
- updateService = new UpdateServiceImpl();
-
- bundleContext.registerService(
- UpdateService.class.getName(),
- updateService,
- null);
-
- // Register the "Check for Updates" menu item if
- // the "Check for Updates" property isn't disabled.
- if(!cfg.getBoolean(CHECK_FOR_UPDATES_MENU_DISABLED_PROP, false))
- {
- // Register the "Check for Updates" menu item.
-
- Hashtable<String, String> toolsMenuFilter
- = new Hashtable<String, String>();
- toolsMenuFilter.put(
- Container.CONTAINER_ID,
- Container.CONTAINER_HELP_MENU.getID());
-
- bundleContext.registerService(
- PluginComponentFactory.class.getName(),
- new PluginComponentFactory(Container.CONTAINER_HELP_MENU)
- {
- @Override
- protected PluginComponent getPluginInstance()
- {
- return new CheckForUpdatesMenuItemComponent(
- getContainer(), this);
- }
- },
- toolsMenuFilter);
- }
-
- // Check for software update upon startup if enabled.
- if(cfg.getBoolean(UPDATE_ENABLED, true))
- updateService.checkForUpdates(false);
- }
-
- if (cfg.getBoolean(CHECK_FOR_UPDATES_DAILY_ENABLED_PROP,
- false))
- {
- logger.info("Scheduled update checking enabled");
-
- // Schedule a "check for updates" task that will run once a day
- int hoursToWait = calcHoursToWait();
- Runnable updateRunnable = new Runnable()
- {
- public void run()
- {
- logger.debug("Performing scheduled update check");
- getUpdateService().checkForUpdates(false);
- }
- };
-
- mUpdateExecutor = Executors.newSingleThreadScheduledExecutor();
- mUpdateExecutor.scheduleAtFixedRate(updateRunnable,
- hoursToWait,
- 24*60*60,
- TimeUnit.SECONDS);
- }
-
- if (logger.isDebugEnabled())
- logger.debug("Update checker [REGISTERED]");
- }
-
- /**
- * This activator depends on UIService.
- * @return the class name of uiService.
- */
- @Override
- public Class<?> getDependentServiceClass()
- {
- return UIService.class;
- }
-
- /**
- * Setting context to the activator, as soon as we have one.
- *
- * @param context the context to set.
- */
- @Override
- public void setBundleContext(BundleContext context)
- {
- bundleContext = context;
- }
-
- /**
- * Calculate the number of hour to wait until the first scheduled update
- * check. This will only be called if daily checking for config updates
- * is enabled
- *
- * @return The number of hours to wait
- */
- private int calcHoursToWait()
- {
- // The hours to wait is the number of hours until midnight tonight (24
- // minus the current hour) plus the hour that the config says updates
- // should be
- return 24 - Calendar.getInstance().get(Calendar.HOUR_OF_DAY) +
- configuration.getInt(CHECK_FOR_UPDATES_DAILY_TIME_PROP, 0);
- }
-
- /**
- * Stop the bundle. Nothing to stop for now.
- * @param bundleContext <tt>BundleContext</tt> provided by OSGi framework
- * @throws Exception if something goes wrong during stop
- */
- public void stop(BundleContext bundleContext) throws Exception
- {
- if (logger.isDebugEnabled())
- logger.debug("Update checker [STOPPED]");
-
- if (mUpdateExecutor != null)
- {
- mUpdateExecutor.shutdown();
- mUpdateExecutor = null;
- }
- }
-
- /**
- * Returns the update service instance.
- *
- * @return the update service instance
- */
- static UpdateService getUpdateService()
- {
- return updateService;
- }
-}
+package net.java.sip.communicator.plugin.update;
+
+import java.util.*;
+import java.util.concurrent.*;
+
+import net.java.sip.communicator.service.browserlauncher.*;
+import net.java.sip.communicator.service.gui.*;
+import net.java.sip.communicator.service.shutdown.*;
+import net.java.sip.communicator.service.update.*;
+import net.java.sip.communicator.util.*;
+import net.java.sip.communicator.util.Logger;
+
+import org.jitsi.service.configuration.*;
+import org.jitsi.util.*;
+import org.osgi.framework.*;
+
+/**
+ * Implements <tt>BundleActivator</tt> for the update plug-in.
+ *
+ * @author Damian Minkov
+ * @author Lyubomir Marinov
+ */
+public class UpdateActivator
+ extends AbstractServiceDependentActivator
+{
+ /**
+ * The <tt>Logger</tt> used by the <tt>UpdateActivator</tt> class and its
+ * instances for logging output.
+ */
+ private static final Logger logger
+ = Logger.getLogger(UpdateActivator.class);
+
+ /**
+ * The name of the configuration property which indicates whether the
+ * checking for updates on application startup is enabled.
+ */
+ private static final String UPDATE_ENABLED
+ = "net.java.sip.communicator.plugin.updatechecker.ENABLED";
+
+ /**
+ * The name of the configuration property which indicates whether the
+ * "checking for updates" menu entry is disabled.
+ */
+ private static final String CHECK_FOR_UPDATES_MENU_DISABLED_PROP
+ = "net.java.sip.communicator.plugin.update.checkforupdatesmenu.DISABLED";
+
+ /**
+ * The name of the configuration property which indicates whether the client
+ * should automatically check for updates each day or not.
+ */
+ private static final String CHECK_FOR_UPDATES_DAILY_ENABLED_PROP =
+ "net.java.sip.communicator.plugin.update.checkforupdatesmenu.daily.ENABLED";
+
+ /**
+ * The name of the configuration property which indicates the hour that
+ * the client should check for updates (if daily update checking is enabled)
+ */
+ private static final String CHECK_FOR_UPDATES_DAILY_TIME_PROP =
+ "net.java.sip.communicator.plugin.update.checkforupdatesmenu.daily.HOUR";
+
+ /**
+ * Reference to the <tt>BrowserLauncherService</tt>.
+ */
+ private static BrowserLauncherService browserLauncher;
+
+ /**
+ * The <tt>BundleContext</tt> in which the one and only
+ * <tt>UpdateActivator</tt> instance of the update plug-in has been started.
+ */
+ static BundleContext bundleContext;
+
+ /**
+ * Reference to the <tt>ConfigurationService</tt>.
+ */
+ private static ConfigurationService configuration;
+
+ /**
+ * Reference to the <tt>UIService</tt>.
+ */
+ private static UIService uiService;
+
+ /**
+ * The update service.
+ */
+ private static UpdateService updateService;
+
+ /**
+ * A scheduler to check for updates once a day
+ */
+ private ScheduledExecutorService mUpdateExecutor = null;
+
+ /**
+ * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
+ * context.
+ * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
+ * context
+ */
+ static BrowserLauncherService getBrowserLauncher()
+ {
+ if (browserLauncher == null)
+ {
+ browserLauncher
+ = ServiceUtils.getService(
+ bundleContext,
+ BrowserLauncherService.class);
+ }
+ return browserLauncher;
+ }
+
+ /**
+ * Returns the <tt>ConfigurationService</tt> obtained from the bundle
+ * context.
+ *
+ * @return the <tt>ConfigurationService</tt> obtained from the bundle
+ * context
+ */
+ static ConfigurationService getConfiguration()
+ {
+ if (configuration == null)
+ {
+ configuration
+ = ServiceUtils.getService(
+ bundleContext,
+ ConfigurationService.class);
+ }
+ return configuration;
+ }
+
+ /**
+ * Gets a reference to a <code>ShutdownService</code> implementation
+ * currently registered in the bundle context of the active
+ * <code>UpdateCheckActivator</code> instance.
+ * <p>
+ * The returned reference to <code>ShutdownService</code> is not being
+ * cached.
+ * </p>
+ *
+ * @return reference to a <code>ShutdownService</code> implementation
+ * currently registered in the bundle context of the active
+ * <code>UpdateCheckActivator</code> instance
+ */
+ static ShutdownService getShutdownService()
+ {
+ return ServiceUtils.getService(bundleContext, ShutdownService.class);
+ }
+
+ /**
+ * Returns a reference to the UIService implementation currently registered
+ * in the bundle context or null if no such implementation was found.
+ *
+ * @return a reference to a UIService implementation currently registered
+ * in the bundle context or null if no such implementation was found.
+ */
+ static UIService getUIService()
+ {
+ if(uiService == null)
+ uiService = ServiceUtils.getService(bundleContext, UIService.class);
+ return uiService;
+ }
+
+ /**
+ * The dependent service is available and the bundle will start.
+ * @param dependentService the UIService this activator is waiting.
+ */
+ @Override
+ public void start(Object dependentService)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Update checker [STARTED]");
+
+ ConfigurationService cfg = getConfiguration();
+
+ if (OSUtils.IS_WINDOWS)
+ {
+ updateService = new UpdateServiceImpl();
+
+ bundleContext.registerService(
+ UpdateService.class.getName(),
+ updateService,
+ null);
+
+ // Register the "Check for Updates" menu item if
+ // the "Check for Updates" property isn't disabled.
+ if(!cfg.getBoolean(CHECK_FOR_UPDATES_MENU_DISABLED_PROP, false))
+ {
+ // Register the "Check for Updates" menu item.
+
+ Hashtable<String, String> toolsMenuFilter
+ = new Hashtable<String, String>();
+ toolsMenuFilter.put(
+ Container.CONTAINER_ID,
+ Container.CONTAINER_HELP_MENU.getID());
+
+ bundleContext.registerService(
+ PluginComponentFactory.class.getName(),
+ new PluginComponentFactory(Container.CONTAINER_HELP_MENU)
+ {
+ @Override
+ protected PluginComponent getPluginInstance()
+ {
+ return new CheckForUpdatesMenuItemComponent(
+ getContainer(), this);
+ }
+ },
+ toolsMenuFilter);
+ }
+
+ // Check for software update upon startup if enabled.
+ if(cfg.getBoolean(UPDATE_ENABLED, true))
+ updateService.checkForUpdates(false);
+ }
+
+ if (cfg.getBoolean(CHECK_FOR_UPDATES_DAILY_ENABLED_PROP,
+ false))
+ {
+ logger.info("Scheduled update checking enabled");
+
+ // Schedule a "check for updates" task that will run once a day
+ int hoursToWait = calcHoursToWait();
+ Runnable updateRunnable = new Runnable()
+ {
+ public void run()
+ {
+ logger.debug("Performing scheduled update check");
+ getUpdateService().checkForUpdates(false);
+ }
+ };
+
+ mUpdateExecutor = Executors.newSingleThreadScheduledExecutor();
+ mUpdateExecutor.scheduleAtFixedRate(updateRunnable,
+ hoursToWait,
+ 24*60*60,
+ TimeUnit.SECONDS);
+ }
+
+ if (logger.isDebugEnabled())
+ logger.debug("Update checker [REGISTERED]");
+ }
+
+ /**
+ * This activator depends on UIService.
+ * @return the class name of uiService.
+ */
+ @Override
+ public Class<?> getDependentServiceClass()
+ {
+ return UIService.class;
+ }
+
+ /**
+ * Setting context to the activator, as soon as we have one.
+ *
+ * @param context the context to set.
+ */
+ @Override
+ public void setBundleContext(BundleContext context)
+ {
+ bundleContext = context;
+ }
+
+ /**
+ * Calculate the number of hour to wait until the first scheduled update
+ * check. This will only be called if daily checking for config updates
+ * is enabled
+ *
+ * @return The number of hours to wait
+ */
+ private int calcHoursToWait()
+ {
+ // The hours to wait is the number of hours until midnight tonight (24
+ // minus the current hour) plus the hour that the config says updates
+ // should be
+ return 24 - Calendar.getInstance().get(Calendar.HOUR_OF_DAY) +
+ configuration.getInt(CHECK_FOR_UPDATES_DAILY_TIME_PROP, 0);
+ }
+
+ /**
+ * Stop the bundle. Nothing to stop for now.
+ * @param bundleContext <tt>BundleContext</tt> provided by OSGi framework
+ * @throws Exception if something goes wrong during stop
+ */
+ public void stop(BundleContext bundleContext) throws Exception
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Update checker [STOPPED]");
+
+ if (mUpdateExecutor != null)
+ {
+ mUpdateExecutor.shutdown();
+ mUpdateExecutor = null;
+ }
+ }
+
+ /**
+ * Returns the update service instance.
+ *
+ * @return the update service instance
+ */
+ static UpdateService getUpdateService()
+ {
+ return updateService;
+ }
+}
diff --git a/src/net/java/sip/communicator/plugin/update/UpdateServiceImpl.java b/src/net/java/sip/communicator/plugin/update/UpdateServiceImpl.java
index 53dde17..d0c908e 100644
--- a/src/net/java/sip/communicator/plugin/update/UpdateServiceImpl.java
+++ b/src/net/java/sip/communicator/plugin/update/UpdateServiceImpl.java
@@ -545,24 +545,22 @@ public class UpdateServiceImpl
if(notifyAboutNewestVersion)
{
SwingUtilities.invokeLater(
- new Runnable()
+ new Runnable()
+ {
+ public void run()
{
- public void run()
- {
- UIService ui = UpdateActivator.getUIService();
- ResourceManagementService r
- = Resources.getResources();
-
- ui.getPopupDialog().showMessagePopupDialog(
- r.getI18NString(
- "plugin.updatechecker."
- + "DIALOG_NOUPDATE"),
- r.getI18NString(
- "plugin.updatechecker."
- + "DIALOG_NOUPDATE_TITLE"),
- PopupDialog.INFORMATION_MESSAGE);
- }
- });
+ UIService ui = UpdateActivator.getUIService();
+ ResourceManagementService r
+ = Resources.getResources();
+
+ ui.getPopupDialog().showMessagePopupDialog(
+ r.getI18NString(
+ "plugin.updatechecker.DIALOG_NOUPDATE"),
+ r.getI18NString(
+ "plugin.updatechecker.DIALOG_NOUPDATE_TITLE"),
+ PopupDialog.INFORMATION_MESSAGE);
+ }
+ });
}
}
else
diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/FirstWizardPage.java
deleted file mode 100644
index 27e32c6..0000000
--- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/FirstWizardPage.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.yahooaccregwizz;
-
-import java.awt.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-/**
- * The <tt>FirstWizardPage</tt> is the page, where user could enter the uin
- * and the password of the account.
- *
- * @author Yana Stamcheva
- * @author Damian Minkov
- */
-public class FirstWizardPage
- extends TransparentPanel
- implements WizardPage,
- DocumentListener
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
-
- public static final String USER_NAME_EXAMPLE
- = "Ex: johnsmith@yahoo.com or johnsmith";
-
- private JPanel uinPassPanel = new TransparentPanel(new BorderLayout(10, 10));
-
- private JPanel labelsPanel = new TransparentPanel();
-
- private JPanel valuesPanel = new TransparentPanel();
-
- private JLabel uinLabel = new JLabel(
- Resources.getString("plugin.yahooaccregwizz.USERNAME"));
-
- private JLabel passLabel
- = new JLabel(Resources.getString("service.gui.PASSWORD"));
-
- private JPanel emptyPanel = new TransparentPanel();
-
- private JLabel uinExampleLabel = new JLabel(USER_NAME_EXAMPLE);
-
- private JTextField userIDField = new TrimTextField();
-
- private JPasswordField passField = new JPasswordField();
-
- private JCheckBox rememberPassBox =
- new SIPCommCheckBox(
- Resources.getString("service.gui.REMEMBER_PASSWORD"));
-
- private JPanel mainPanel = new TransparentPanel();
-
- private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
-
- private YahooAccountRegistrationWizard wizard;
-
- private boolean isCommitted = false;
-
- /**
- * Creates an instance of <tt>FirstWizardPage</tt>.
- *
- * @param wizard the parent wizard
- */
- public FirstWizardPage(YahooAccountRegistrationWizard wizard)
- {
-
- super(new BorderLayout());
-
- this.wizard = wizard;
-
- mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
-
- this.init();
-
- this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- this.labelsPanel
- .setLayout(new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
-
- this.valuesPanel
- .setLayout(new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
- }
-
- /**
- * Initializes all panels, buttons, etc.
- */
- private void init()
- {
- this.mainPanel.setOpaque(false);
- this.labelsPanel.setOpaque(false);
- this.valuesPanel.setOpaque(false);
- this.uinPassPanel.setOpaque(false);
- this.emptyPanel.setOpaque(false);
-
- this.userIDField.getDocument().addDocumentListener(this);
- this.rememberPassBox.setSelected(true);
-
- this.uinExampleLabel.setForeground(Color.GRAY);
- this.uinExampleLabel.setFont(uinExampleLabel.getFont().deriveFont(8));
- this.emptyPanel.setMaximumSize(new Dimension(40, 35));
- this.uinExampleLabel.setBorder(
- BorderFactory.createEmptyBorder(0, 0, 8, 0));
-
- labelsPanel.add(uinLabel);
- labelsPanel.add(emptyPanel);
- labelsPanel.add(passLabel);
-
- valuesPanel.add(userIDField);
- valuesPanel.add(uinExampleLabel);
- valuesPanel.add(passField);
-
- uinPassPanel.add(labelsPanel, BorderLayout.WEST);
- uinPassPanel.add(valuesPanel, BorderLayout.CENTER);
- uinPassPanel.add(rememberPassBox, BorderLayout.SOUTH);
-
- uinPassPanel.setBorder(BorderFactory.createTitledBorder(Resources
- .getString("plugin.yahooaccregwizz.USERID_AND_PASSWORD")));
-
- mainPanel.add(uinPassPanel);
- this.add(mainPanel, BorderLayout.NORTH);
- }
-
- /**
- * Implements the <code>WizardPage.getIdentifier</code> to return this
- * page identifier.
- */
- public Object getIdentifier()
- {
- return FIRST_PAGE_IDENTIFIER;
- }
-
- /**
- * Implements the <code>WizardPage.getNextPageIdentifier</code> to return
- * the next page identifier - the summary page.
- */
- public Object getNextPageIdentifier()
- {
- return nextPageIdentifier;
- }
-
- /**
- * Implements the <code>WizardPage.getBackPageIdentifier</code> to return
- * the back identifier. In this case it's null because this is the first
- * wizard page.
- * @return the identifier of the previous wizard page
- */
- public Object getBackPageIdentifier()
- {
- return null;
- }
-
- /**
- * Implements the <code>WizardPage.getWizardForm</code> to return this
- * panel.
- */
- public Object getWizardForm()
- {
- return this;
- }
-
- /**
- * Before this page is displayed enables or disables the "Next" wizard
- * button according to whether the UIN field is empty.
- */
- public void pageShowing()
- {
- this.setNextButtonAccordingToUIN();
- }
-
- /**
- * Saves the user input when the "Next" wizard buttons is clicked.
- */
- public void commitPage()
- {
- YahooAccountRegistration registration = wizard.getRegistration();
-
- String userID = userIDField.getText();
-
- if(userID == null || userID.trim().length() == 0)
- throw new IllegalStateException("No user ID provided.");
-
- registration.setUserID(userID);
- registration.setPassword(new String(passField.getPassword()));
- registration.setRememberPassword(rememberPassBox.isSelected());
-
- nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
-
- isCommitted = true;
- }
-
- /**
- * Enables or disables the "Next" wizard button according to whether the UIN
- * field is empty.
- */
- private void setNextButtonAccordingToUIN()
- {
- if (userIDField.getText() == null || userIDField.getText().equals(""))
- {
- wizard.getWizardContainer().setNextFinishButtonEnabled(false);
- }
- else
- {
- wizard.getWizardContainer().setNextFinishButtonEnabled(true);
- }
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user types in the UIN
- * field. Enables or disables the "Next" wizard button according to whether
- * the UIN field is empty.
- */
- public void insertUpdate(DocumentEvent e)
- {
- this.setNextButtonAccordingToUIN();
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
- * from the UIN field. Enables or disables the "Next" wizard button
- * according to whether the UIN field is empty.
- */
- public void removeUpdate(DocumentEvent e)
- {
- this.setNextButtonAccordingToUIN();
- }
-
- public void changedUpdate(DocumentEvent e)
- {
- }
-
- public void pageHiding()
- {
- }
-
- public void pageShown()
- {
- }
-
- public void pageBack()
- {
- }
-
- /**
- * Fills the UIN and Password fields in this panel with the data coming
- * from the given protocolProvider.
- *
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load
- * the data from.
- */
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- AccountID accountID = protocolProvider.getAccountID();
- String password = YahooAccRegWizzActivator
- .getYahooProtocolProviderFactory().loadPassword(accountID);
-
- this.userIDField.setEnabled(false);
- this.userIDField.setText(accountID.getUserID());
-
- if (password != null)
- {
- this.passField.setText(password);
- this.rememberPassBox.setSelected(true);
- }
- }
-
- public Object getSimpleForm()
- {
- return uinPassPanel;
- }
-
- public boolean isCommitted()
- {
- return isCommitted;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java
deleted file mode 100644
index c41a72f..0000000
--- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/Resources.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.yahooaccregwizz;
-
-import net.java.sip.communicator.service.resources.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The <tt>Resources</tt> class manages the access to the internationalization
- * properties files and the image resources used in this plugin.
- *
- * @author Yana Stamcheva
- */
-public class Resources
-{
- private static ResourceManagementService resourcesService;
-
- public static ImageID YAHOO_LOGO
- = new ImageID("service.protocol.yahoo.YAHOO_16x16");
-
- public static ImageID PAGE_IMAGE
- = new ImageID("service.protocol.yahoo.YAHOO_64x64");
-
- /**
- * 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)
- {
- return getResources().getI18NString(key);
- }
-
- /**
- * Loads an image from a given image identifier.
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static byte[] getImage(ImageID imageID)
- {
- return getResources().getImageInBytes(imageID.getId());
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(YahooAccRegWizzActivator.bundleContext);
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccRegWizzActivator.java
deleted file mode 100644
index cd526a9..0000000
--- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccRegWizzActivator.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.yahooaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.browserlauncher.*;
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * Registers the <tt>YahooAccountRegistrationWizard</tt> in the UI Service.
- *
- * @author Yana Stamcheva
- */
-public class YahooAccRegWizzActivator
- extends AbstractServiceDependentActivator
-{
- /**
- * OSGi bundle context.
- */
- public static BundleContext bundleContext;
-
- private static final Logger logger =
- Logger.getLogger(YahooAccRegWizzActivator.class);
-
- private static BrowserLauncherService browserLauncherService;
-
- private static WizardContainer wizardContainer;
-
- private static YahooAccountRegistrationWizard yahooWizard;
-
- private static UIService uiService;
-
- /**
- * Starts this bundle.
- */
- @Override
- public void start(Object dependentService)
- {
- uiService = (UIService)dependentService;
-
- wizardContainer = uiService.getAccountRegWizardContainer();
-
- yahooWizard = new YahooAccountRegistrationWizard(wizardContainer);
-
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
-
- containerFilter.put(
- ProtocolProviderFactory.PROTOCOL,
- ProtocolNames.YAHOO);
-
- bundleContext.registerService(
- AccountRegistrationWizard.class.getName(),
- yahooWizard,
- containerFilter);
- }
-
- /**
- * The dependent class. We are waiting for the ui service.
- * @return the ui service class.
- */
- @Override
- public Class<?> getDependentServiceClass()
- {
- return UIService.class;
- }
-
- /**
- * The bundle context to use.
- * @param context the context to set.
- */
- @Override
- public void setBundleContext(BundleContext context)
- {
- bundleContext = context;
- }
-
- public void stop(BundleContext bundleContext) throws Exception
- {
- }
-
- /**
- * Returns the <tt>ProtocolProviderFactory</tt> for the Yahoo protocol.
- * @return the <tt>ProtocolProviderFactory</tt> for the Yahoo protocol
- */
- public static ProtocolProviderFactory getYahooProtocolProviderFactory()
- {
- ServiceReference[] serRefs = null;
- String osgiFilter
- = "("
- + ProtocolProviderFactory.PROTOCOL
- + "="
- + ProtocolNames.YAHOO
- + ")";
-
- try {
- serRefs
- = bundleContext.getServiceReferences(
- ProtocolProviderFactory.class.getName(),
- osgiFilter);
- }
- catch (InvalidSyntaxException ex){
- logger.error("YahooAccRegWizzActivator : " + ex);
- }
-
- return
- (serRefs == null)
- ? null
- : (ProtocolProviderFactory)
- bundleContext.getService(serRefs[0]);
- }
-
- /**
- * Returns the <tt>UIService</tt>.
- *
- * @return the <tt>UIService</tt>
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-
- /**
- * Returns the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context.
- * @return the <tt>BrowserLauncherService</tt> obtained from the bundle
- * context
- */
- public static BrowserLauncherService getBrowserLauncher() {
- if (browserLauncherService == null) {
- ServiceReference serviceReference = bundleContext
- .getServiceReference(BrowserLauncherService.class.getName());
-
- browserLauncherService = (BrowserLauncherService) bundleContext
- .getService(serviceReference);
- }
-
- return browserLauncherService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistration.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistration.java
deleted file mode 100644
index 6cf7759..0000000
--- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistration.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.yahooaccregwizz;
-
-/**
- * The <tt>YahooAccountRegistration</tt> is used to store all user input data
- * through the <tt>YahooAccountRegistrationWizard</tt>.
- *
- * @author Yana Stamcheva
- */
-public class YahooAccountRegistration {
-
- private String uin;
-
- private String password;
-
- private boolean rememberPassword = true;
-
- /**
- * Returns the password of the yahoo registration account.
- * @return the password of the yahoo registration account.
- */
- public String getPassword() {
- return password;
- }
-
- /**
- * Sets the password of the yahoo registration account.
- * @param password the password of the yahoo registration account.
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
- /**
- * Returns TRUE if password has to remembered, FALSE otherwise.
- * @return TRUE if password has to remembered, FALSE otherwise
- */
- public boolean isRememberPassword() {
- return rememberPassword;
- }
-
- /**
- * Sets the rememberPassword value of this yahoo account registration.
- * @param rememberPassword TRUE if password has to remembered, FALSE
- * otherwise
- */
- public void setRememberPassword(boolean rememberPassword) {
- this.rememberPassword = rememberPassword;
- }
-
- /**
- * Returns the UIN of the yahoo registration account.
- * @return the UIN of the yahoo registration account.
- */
- public String getUin() {
- return uin;
- }
-
- /**
- * Sets the UIN of the yahoo registration account.
- * @param uin the UIN of the yahoo registration account.
- */
- public void setUserID(String uin) {
- this.uin = uin;
- }
-
-}
diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java
deleted file mode 100644
index 033f409..0000000
--- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/YahooAccountRegistrationWizard.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.yahooaccregwizz;
-
-import java.awt.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * The <tt>YahooAccountRegistrationWizard</tt> is an implementation of the
- * <tt>AccountRegistrationWizard</tt> for the Yahoo protocol. It should allow
- * the user to create and configure a new Yahoo account.
- *
- * @author Yana Stamcheva
- */
-public class YahooAccountRegistrationWizard
- extends DesktopAccountRegistrationWizard
-{
- private final Logger logger
- = Logger.getLogger(YahooAccountRegistrationWizard.class);
-
- private FirstWizardPage firstWizardPage;
-
- private YahooAccountRegistration registration =
- new YahooAccountRegistration();
-
- private ProtocolProviderService protocolProvider;
-
- /**
- * Creates an instance of <tt>YahooAccountRegistrationWizard</tt>.
- *
- * @param wizardContainer the wizard container, where this wizard is added
- */
- public YahooAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- setWizardContainer(wizardContainer);
-
- wizardContainer
- .setFinishButtonText(Resources.getString("service.gui.SIGN_IN"));
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * Returns the icon to be used for this wizard.
- *
- * @return byte[]
- */
- @Override
- public byte[] getIcon()
- {
- return Resources.getImage(Resources.YAHOO_LOGO);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code>
- * method. Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- @Override
- public byte[] getPageImage()
- {
- return Resources.getImage(Resources.PAGE_IMAGE);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method. Returns the protocol name for this wizard.
- *
- * @return String
- */
- @Override
- public String getProtocolName()
- {
- return Resources.getString("plugin.yahooaccregwizz.PROTOCOL_NAME");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code>
- * method. Returns the description of the protocol for this wizard.
- *
- * @return String
- */
- @Override
- public String getProtocolDescription()
- {
- return Resources
- .getString("plugin.yahooaccregwizz.PROTOCOL_DESCRIPTION");
- }
-
- /**
- * Returns the set of pages contained in this wizard.
- *
- * @return Iterator
- */
- @Override
- public Iterator<WizardPage> getPages()
- {
- java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
- firstWizardPage = new FirstWizardPage(this);
-
- pages.add(firstWizardPage);
-
- return pages.iterator();
- }
-
- /**
- * Returns the set of data that user has entered through this wizard.
- *
- * @return Iterator
- */
- @Override
- public Iterator<Map.Entry<String, String>> getSummary()
- {
- Hashtable<String, String> summaryTable
- = new Hashtable<String, String>();
-
- summaryTable.put(
- Resources.getString("plugin.yahooaccregwizz.USERNAME"),
- registration.getUin());
- summaryTable.put(
- Resources.getString("service.gui.REMEMBER_PASSWORD"),
- Boolean.toString(registration.isRememberPassword()));
-
- return summaryTable.entrySet().iterator();
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- *
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin()
- throws OperationFailedException
- {
- firstWizardPage.commitPage();
-
- return signin( registration.getUin(),
- registration.getPassword());
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- *
- * @param userName the user name to sign in with
- * @param password the password to sign in with
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin(String userName, String password)
- throws OperationFailedException
- {
- ProtocolProviderFactory factory =
- YahooAccRegWizzActivator.getYahooProtocolProviderFactory();
-
- return this.installAccount( factory,
- userName,
- password);
- }
-
- /**
- * Creates an account for the given user and password.
- *
- * @param providerFactory the ProtocolProviderFactory which will create the
- * account
- * @param user the user identifier
- * @param passwd the password
- * @return the <tt>ProtocolProviderService</tt> for the new account.
- */
- public ProtocolProviderService installAccount(
- ProtocolProviderFactory providerFactory, String user, String passwd)
- throws OperationFailedException
- {
- Hashtable<String, String> accountProperties
- = new Hashtable<String, String>();
-
- accountProperties.put(ProtocolProviderFactory.ACCOUNT_ICON_PATH,
- "resources/images/protocol/yahoo/yahoo32x32.png");
-
- if (registration.isRememberPassword())
- {
- accountProperties.put(ProtocolProviderFactory.PASSWORD, passwd);
- }
-
- if (isModification())
- {
- providerFactory.modifyAccount( protocolProvider,
- accountProperties);
-
- setModification(false);
-
- return protocolProvider;
- }
-
- try
- {
- AccountID accountID =
- providerFactory.installAccount(user, accountProperties);
-
- ServiceReference serRef =
- providerFactory.getProviderForAccount(accountID);
-
- protocolProvider =
- (ProtocolProviderService) YahooAccRegWizzActivator
- .bundleContext.getService(serRef);
- }
- catch (IllegalStateException exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Account already exists.",
- OperationFailedException.IDENTIFICATION_CONFLICT);
- }
- catch (Exception exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Failed to add account",
- OperationFailedException.GENERAL_ERROR);
- }
-
- return protocolProvider;
- }
-
- /**
- * Fills the UIN and Password fields in this panel with the data coming
- * from the given protocolProvider.
- *
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load
- * the data from.
- */
- @Override
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- setModification(true);
-
- this.protocolProvider = protocolProvider;
-
- this.registration = new YahooAccountRegistration();
-
- this.firstWizardPage.loadAccount(protocolProvider);
- }
-
- /**
- * Returns the registration object, which will store all the data through
- * the wizard.
- *
- * @return the registration object, which will store all the data through
- * the wizard
- */
- public YahooAccountRegistration getRegistration()
- {
- return registration;
- }
-
- /**
- * Returns the size of this wizard.
- * @return the size of this wizard
- */
- @Override
- public Dimension getSize()
- {
- return new Dimension(600, 500);
- }
-
- /**
- * Returns the identifier of the page to show first in the wizard.
- * @return the identifier of the page to show first in the wizard.
- */
- @Override
- public Object getFirstPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- /**
- * Returns the identifier of the page to show last in the wizard.
- * @return the identifier of the page to show last in the wizard.
- */
- @Override
- public Object getLastPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- /**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
- */
- @Override
- public String getUserNameExample()
- {
- return FirstWizardPage.USER_NAME_EXAMPLE;
- }
-
- /**
- * Defines the operation that will be executed when user clicks on the
- * "Sign up" link.
- * @throws UnsupportedOperationException if the web sign up operation is
- * not supported by the current implementation.
- */
- @Override
- public void webSignup()
- {
- YahooAccRegWizzActivator.getBrowserLauncher()
- .openURL("https://edit.yahoo.com/registration");
- }
-
- /**
- * Returns <code>true</code> if the web sign up is supported by the current
- * implementation, <code>false</code> - otherwise.
- * @return <code>true</code> if the web sign up is supported by the current
- * implementation, <code>false</code> - otherwise
- */
- @Override
- public boolean isWebSignupSupported()
- {
- return true;
- }
-
- /**
- * Returns a simple account registration form that would be the first form
- * shown to the user. Only if the user needs more settings she'll choose
- * to open the advanced wizard, consisted by all pages.
- *
- * @param isCreateAccount indicates if the simple form should be opened as
- * a create account form or as a login form
- * @return a simple account registration form
- */
- @Override
- public Object getSimpleForm(boolean isCreateAccount)
- {
- firstWizardPage = new FirstWizardPage(this);
-
- return firstWizardPage.getSimpleForm();
- }
-
- /**
- * Whether the advanced configuration is enabled. Gives an option
- * to disable/hide advanced config button.
- * @return whether the advanced configuration is enabled.
- */
- public boolean isAdvancedConfigurationEnabled()
- {
- return false;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/yahooaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/yahooaccregwizz/yahooaccregwizz.manifest.mf
deleted file mode 100644
index a975e2e..0000000
--- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/yahooaccregwizz.manifest.mf
+++ /dev/null
@@ -1,33 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.plugin.yahooaccregwizz.YahooAccRegWizzActivator
-Bundle-Name: Yahoo account registration wizard
-Bundle-Description: Yahoo account registration wizard.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.plugin.yahooaccregwizz
-Import-Package: org.osgi.framework,
- net.java.sip.communicator.service.browserlauncher,
- org.jitsi.service.configuration,
- net.java.sip.communicator.service.contactlist,
- net.java.sip.communicator.service.contactlist.event,
- net.java.sip.communicator.service.gui,
- net.java.sip.communicator.service.gui.event,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,
- net.java.sip.communicator.service.protocol.icqconstants,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.plugin.desktoputil,
- javax.swing,
- javax.swing.event,
- javax.swing.table,
- javax.swing.text,
- javax.swing.text.html,
- javax.accessibility,
- javax.swing.plaf,
- javax.swing.plaf.metal,
- javax.swing.plaf.basic,
- javax.imageio,
- javax.swing.filechooser,
- javax.swing.tree,
- javax.swing.undo,
- javax.swing.border
diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/FirstWizardPage.java
deleted file mode 100644
index 0f8815c..0000000
--- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/FirstWizardPage.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.zeroconfaccregwizz;
-
-import java.awt.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.plugin.desktoputil.*;
-
-/**
- * The <tt>FirstWizardPage</tt> is the page, where user could enter the user ID
- * and the password of the account.
- *
- * @author Christian Vincenot
- * @author Maxime Catelin
- */
-public class FirstWizardPage
- extends TransparentPanel
- implements WizardPage,
- DocumentListener
-{
- /**
- * Serial version UID.
- */
- private static final long serialVersionUID = 0L;
-
- public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier";
-
- private JPanel userPassPanel = new TransparentPanel(new BorderLayout(10, 10));
-
- private JPanel labelsPanel = new TransparentPanel();
-
- private JPanel valuesPanel = new TransparentPanel();
-
- private JLabel userID = new JLabel(
- Resources.getString("plugin.zeroaccregwizz.USERID"));
-
- /* TEMPORARY : HARD CODED !! Should be added to Resource */
- private JLabel firstLabel
- = new JLabel(Resources.getString("plugin.zeroaccregwizz.FIRST_NAME"));
- private JLabel lastLabel
- = new JLabel(Resources.getString("plugin.zeroaccregwizz.LAST_NAME"));
- private JLabel mailLabel
- = new JLabel(Resources.getString("plugin.zeroaccregwizz.EMAIL"));
-
- private JPanel emptyPanel = new TransparentPanel();
- private JPanel emptyPanel2 = new TransparentPanel();
- private JPanel emptyPanel3 = new TransparentPanel();
- private JPanel emptyPanel4 = new TransparentPanel();
-
- private JLabel userIDExampleLabel = new JLabel("Ex: Bill@microsoft");
- private JLabel firstExampleLabel = new JLabel("Ex: Bill");
- private JLabel lastExampleLabel = new JLabel("Ex: Gates");
- private JLabel mailExampleLabel = new JLabel("Ex: Bill@microsoft.com");
-
- private JTextField userIDField = new TrimTextField();
- private JTextField firstField = new JTextField();
- private JTextField lastField = new JTextField();
- private JTextField mailField = new JTextField();
-
- private JCheckBox rememberContacts =
- new SIPCommCheckBox(Resources.getString(
- "plugin.zeroaccregwizz.REMEMBER_CONTACTS"));
-
- private JPanel mainPanel = new TransparentPanel();
-
- private Object nextPageIdentifier = WizardPage.SUMMARY_PAGE_IDENTIFIER;
-
- private ZeroconfAccountRegistrationWizard wizard;
-
- private boolean isCommitted = false;
-
- /**
- * Creates an instance of <tt>FirstWizardPage</tt>.
- *
- * @param wizard the parent wizard
- */
- public FirstWizardPage(ZeroconfAccountRegistrationWizard wizard)
- {
-
- super(new BorderLayout());
-
- this.wizard = wizard;
-
- mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
-
- this.init();
-
- this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
-
- this.labelsPanel.setLayout(
- new BoxLayout(labelsPanel, BoxLayout.Y_AXIS));
-
- this.valuesPanel.setLayout(
- new BoxLayout(valuesPanel, BoxLayout.Y_AXIS));
- }
-
- /**
- * Initializes all panels, buttons, etc.
- */
- private void init()
- {
- this.userIDField.getDocument().addDocumentListener(this);
- this.firstField.getDocument().addDocumentListener(this);
- this.rememberContacts.setSelected(false);
-
- // not used so disable it for the moment
- this.rememberContacts.setEnabled(false);
-
- this.userIDExampleLabel.setForeground(Color.GRAY);
- this.userIDExampleLabel.setFont(
- userIDExampleLabel.getFont().deriveFont(8));
- this.emptyPanel.setMaximumSize(new Dimension(40, 35));
- this.userIDExampleLabel.setBorder(
- BorderFactory.createEmptyBorder(0, 0, 8,0));
-
- this.firstExampleLabel.setForeground(Color.GRAY);
- this.firstExampleLabel.setFont(
- firstExampleLabel.getFont().deriveFont(8));
- this.emptyPanel2.setMaximumSize(new Dimension(40, 35));
- this.firstExampleLabel.setBorder(
- BorderFactory.createEmptyBorder(0, 0, 8,0));
-
- this.lastExampleLabel.setForeground(Color.GRAY);
- this.lastExampleLabel.setFont(
- lastExampleLabel.getFont().deriveFont(8));
- this.emptyPanel3.setMaximumSize(new Dimension(40, 35));
- this.lastExampleLabel.setBorder(
- BorderFactory.createEmptyBorder(0, 0, 8,0));
-
- this.mailExampleLabel.setForeground(Color.GRAY);
- this.mailExampleLabel.setFont(
- mailExampleLabel.getFont().deriveFont(8));
- this.emptyPanel4.setMaximumSize(new Dimension(40, 35));
- this.mailExampleLabel.setBorder(
- BorderFactory.createEmptyBorder(0, 0, 8,0));
-
- labelsPanel.add(userID);
- labelsPanel.add(emptyPanel);
- labelsPanel.add(firstLabel);
- labelsPanel.add(emptyPanel2);
- labelsPanel.add(lastLabel);
- labelsPanel.add(emptyPanel3);
- labelsPanel.add(mailLabel);
-
- valuesPanel.add(userIDField);
- valuesPanel.add(userIDExampleLabel);
- valuesPanel.add(firstField);
- valuesPanel.add(firstExampleLabel);
- valuesPanel.add(lastField);
- valuesPanel.add(lastExampleLabel);
- valuesPanel.add(mailField);
- valuesPanel.add(mailExampleLabel);
-
- userPassPanel.add(labelsPanel, BorderLayout.WEST);
- userPassPanel.add(valuesPanel, BorderLayout.CENTER);
- userPassPanel.add(rememberContacts, BorderLayout.SOUTH);
-
- userPassPanel.setBorder(BorderFactory.createTitledBorder(
- Resources.getString("plugin.zeroaccregwizz.USERID_AND_PASSWORD")));
-
- this.add(userPassPanel, BorderLayout.NORTH);
- }
-
- /**
- * Implements the <code>WizardPage.getIdentifier</code> to return
- * this page identifier.
- *
- * @return the Identifier of the first page in this wizard.
- */
- public Object getIdentifier()
- {
- return FIRST_PAGE_IDENTIFIER;
- }
-
- /**
- * Implements the <code>WizardPage.getNextPageIdentifier</code> to return
- * the next page identifier - the summary page.
- *
- * @return the identifier of the page following this one.
- */
- public Object getNextPageIdentifier()
- {
- return nextPageIdentifier;
- }
-
- /**
- * Implements the <code>WizardPage.getBackPageIdentifier</code> to return
- * the back identifier. In this case it's null because this is the first
- * wizard page.
- *
- * @return the identifier of the previous wizard page
- */
- public Object getBackPageIdentifier()
- {
- return null;
- }
-
- /**
- * Implements the <code>WizardPage.getWizardForm</code> to return
- * this panel.
- *
- * @return the component to be displayed in this wizard page.
- */
- public Object getWizardForm()
- {
- return this;
- }
-
- /**
- * Before this page is displayed enables or disables the "Next" wizard
- * button according to whether the UserID field is empty.
- */
- public void pageShowing()
- {
- this.setNextButtonAccordingToUserID();
- }
-
- /**
- * Saves the user input when the "Next" wizard buttons is clicked.
- */
- public void commitPage()
- {
- ZeroconfAccountRegistration registration
- = wizard.getRegistration();
-
- String userID = userIDField.getText();
-
- if(userID == null || userID.trim().length() == 0)
- throw new IllegalStateException("No user ID provided.");
-
- registration.setUserID(userID);
- registration.setFirst(firstField.getText());
- registration.setLast(lastField.getText());
- registration.setMail(mailField.getText());
-
- registration.setRememberContacts(rememberContacts.isSelected());
-
- nextPageIdentifier = SUMMARY_PAGE_IDENTIFIER;
-
- isCommitted = true;
- }
-
- /**
- * Enables or disables the "Next" wizard button according to whether the
- * User ID field is empty.
- */
- private void setNextButtonAccordingToUserID()
- {
- if (userIDField.getText() == null || userIDField.getText().equals(""))
- {
- wizard.getWizardContainer().setNextFinishButtonEnabled(false);
- }
- else
- {
- wizard.getWizardContainer().setNextFinishButtonEnabled(true);
- }
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user types in the
- * User ID field. Enables or disables the "Next" wizard button according to
- * whether the User ID field is empty.
- *
- * @param event the event containing the update.
- */
- public void insertUpdate(DocumentEvent event)
- {
- this.setNextButtonAccordingToUserID();
- }
-
- /**
- * Handles the <tt>DocumentEvent</tt> triggered when user deletes letters
- * from the UserID field. Enables or disables the "Next" wizard button
- * according to whether the UserID field is empty.
- *
- * @param event the event containing the update.
- */
- public void removeUpdate(DocumentEvent event)
- {
- this.setNextButtonAccordingToUserID();
- }
-
- /**
- * Implemented from Wizard interface
- * @param event Event that happened
- */
- public void changedUpdate(DocumentEvent event)
- {
- }
-
- /**
- * Created to
- */
- public void pageHiding()
- {
- }
-
- /**
- * Implemented from Wizard interface
- */
- public void pageShown()
- {
- }
-
- /**
- * Implemented from Wizard interface
- */
- public void pageBack()
- {
- }
-
- /**
- * Fills the UserID field in this panel with the data comming
- * from the given protocolProvider.
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load the
- * data from.
- */
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- AccountID accountID = protocolProvider.getAccountID();
-
- this.userIDField.setEnabled(false);
- this.userIDField.setText(accountID.getUserID());
- this.firstField.setText(accountID.getAccountPropertyString("first"));
- this.lastField.setText(accountID.getAccountPropertyString("last"));
- this.mailField.setText(accountID.getAccountPropertyString("mail"));
-
- boolean remember = accountID
- .getAccountPropertyBoolean("rememberContacts", true);
- if (remember)
- this.rememberContacts.setSelected(true);
- }
-
- public Object getSimpleForm()
- {
- JPanel simplePanel = new TransparentPanel(new BorderLayout(10, 10));
-
- simplePanel.add(userID, BorderLayout.WEST);
- simplePanel.add(userIDField, BorderLayout.CENTER);
-
- return simplePanel;
- }
-
- public boolean isCommitted()
- {
- return isCommitted;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java
deleted file mode 100644
index 83b6131..0000000
--- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/Resources.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.zeroconfaccregwizz;
-
-import net.java.sip.communicator.service.resources.*;
-
-import org.jitsi.service.resources.*;
-
-/**
- * The Resources class manages the access to the internationalization
- * properties files and the images properties file.
- *
- * @author Christian Vincenot
- * @author Maxime Catelin
- */
-public class Resources
-{
- private static ResourceManagementService resourcesService;
-
- public static ImageID ZEROCONF_LOGO
- = new ImageID("service.protocol.zeroconf.ZEROCONF_16x16");
-
- public static ImageID PAGE_IMAGE
- = new ImageID("service.protocol.zeroconf.ZEROCONF_64x64");
-
- /**
- * 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)
- {
- return getResources().getI18NString(key);
- }
-
- /**
- * Loads an image from a given image identifier.
- * @param imageID The identifier of the image.
- * @return The image for the given identifier.
- */
- public static byte[] getImage(ImageID imageID)
- {
- return getResources().getImageInBytes(imageID.getId());
- }
-
- /**
- * Returns the <tt>ResourceManagementService</tt>.
- *
- * @return the <tt>ResourceManagementService</tt>.
- */
- public static ResourceManagementService getResources()
- {
- if (resourcesService == null)
- resourcesService =
- ResourceManagementServiceUtils
- .getService(ZeroconfAccRegWizzActivator.bundleContext);
- return resourcesService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccRegWizzActivator.java b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccRegWizzActivator.java
deleted file mode 100644
index 352796b..0000000
--- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccRegWizzActivator.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.zeroconfaccregwizz;
-
-import java.util.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * Registers the <tt>ZeroconfAccountRegistrationWizard</tt> in the UI Service.
- *
- * @author Christian Vincenot
- * @author Maxime Catelin
- */
-public class ZeroconfAccRegWizzActivator
- implements BundleActivator
-{
- private static final Logger logger =
- Logger.getLogger(ZeroconfAccRegWizzActivator.class);
-
- /**
- * A currently valid bundle context.
- */
- public static BundleContext bundleContext;
-
- private static UIService uiService;
-
- /**
- * Starts this bundle.
- * @param bc the currently valid <tt>BundleContext</tt>.
- */
- public void start(BundleContext bc)
- {
- if (logger.isInfoEnabled())
- logger.info("Loading zeroconf account wizard.");
-
- bundleContext = bc;
-
- ServiceReference uiServiceRef = bundleContext
- .getServiceReference(UIService.class.getName());
-
- uiService = (UIService) bundleContext.getService(uiServiceRef);
-
- WizardContainer wizardContainer
- = uiService.getAccountRegWizardContainer();
-
- ZeroconfAccountRegistrationWizard zeroconfWizard
- = new ZeroconfAccountRegistrationWizard(wizardContainer);
-
- Hashtable<String, String> containerFilter
- = new Hashtable<String, String>();
-
- containerFilter.put(
- ProtocolProviderFactory.PROTOCOL,
- ProtocolNames.ZEROCONF);
-
- bundleContext.registerService(
- AccountRegistrationWizard.class.getName(),
- zeroconfWizard,
- containerFilter);
-
- if (logger.isInfoEnabled())
- logger.info("Zeroconf account registration wizard [STARTED].");
- }
-
- /**
- * Called when this bundle is stopped so the Framework can perform the
- * bundle-specific activities necessary to stop the bundle.
- *
- * @param context The execution context of the bundle being stopped.
- */
- public void stop(BundleContext context)
- {
-
- }
-
- /**
- * Returns the <tt>ProtocolProviderFactory</tt> for the Zeroconf protocol.
- * @return the <tt>ProtocolProviderFactory</tt> for the Zeroconf protocol
- */
- public static ProtocolProviderFactory getZeroconfProtocolProviderFactory()
- {
- ServiceReference[] serRefs = null;
- String osgiFilter
- = "("
- + ProtocolProviderFactory.PROTOCOL
- + "="
- + ProtocolNames.ZEROCONF
- + ")";
-
- try
- {
- serRefs
- = bundleContext.getServiceReferences(
- ProtocolProviderFactory.class.getName(),
- osgiFilter);
- }
- catch (InvalidSyntaxException ex)
- {
- logger.error(ex);
- }
-
- return
- (serRefs == null)
- ? null
- : (ProtocolProviderFactory)
- bundleContext.getService(serRefs[0]);
- }
-
- /**
- * Returns the bundleContext that we received when we were started.
- * @return a currently valid instance of a bundleContext.
- */
- public BundleContext getBundleContext()
- {
- return bundleContext;
- }
-
- /**
- * Returns the <tt>UIService</tt>.
- *
- * @return the <tt>UIService</tt>
- */
- public static UIService getUIService()
- {
- return uiService;
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccountRegistration.java b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccountRegistration.java
deleted file mode 100644
index df4f6f5..0000000
--- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccountRegistration.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.zeroconfaccregwizz;
-
-/**
- * The <tt>ZeroconfAccountRegistration</tt> is used to store
- * all user input data
- * through the <tt>ZeroconfAccountRegistrationWizard</tt>.
- *
- * @author Christian Vincenot
- * @author Maxime Catelin
- */
-public class ZeroconfAccountRegistration
-{
- private String userID;
- private String first;
- private String last;
- private String mail;
- private boolean rememberContacts;
-
- /**
- * Returns the User ID of the zeroconf registration account.
- * @return the User ID of the zeroconf registration account.
- */
- public String getUserID()
- {
- return userID;
- }
-
- /**
- * Sets the user ID of the zeroconf registration account.
- * @param userID the userID of the zeroconf registration account.
- */
- public void setUserID(String userID)
- {
- this.userID = userID;
- }
-
- /**
- * Returns the password of the Zeroconf registration account.
- * @return the password of the Zeroconf registration account.
- */
- public String getFirst()
- {
- return first;
- }
-
- /**
- * Sets the password of the Zeroconf registration account.
- * @param first first name
- */
- public void setFirst(String first)
- {
- this.first = first;
- }
-
- /**
- * Returns <tt>true</tt> if password has to remembered, <tt>false</tt>
- * otherwise.
- * @return <tt>true</tt> if password has to remembered, <tt>false</tt>
- * otherwise.
- */
- public boolean isRememberContacts()
- {
- return rememberContacts;
- }
-
- /**
- * Sets the rememberPassword value of this Zeroconf account registration.
- * @param rememberContacts true if we want to remember the
- * contacts we meet, false otherwise
- */
- public void setRememberContacts(boolean rememberContacts)
- {
- this.rememberContacts = rememberContacts;
- }
-
- /**
- * Returns the last name
- * @return last name
- */
- public String getLast()
- {
- return last;
- }
-
- /**
- * Sets the last name
- * @param last last name
- */
- public void setLast(String last)
- {
- this.last = last;
- }
-
- /**
- * Returns the mail address
- * @return mail address
- */
- public String getMail()
- {
- return mail;
- }
-
- /**
- * Sets the mail address
- * @param mail mail address
- */
- public void setMail(String mail)
- {
- this.mail = mail;
- }
-
-
-}
diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccountRegistrationWizard.java b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccountRegistrationWizard.java
deleted file mode 100644
index 79f085f..0000000
--- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/ZeroconfAccountRegistrationWizard.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
- *
- * Copyright @ 2015 Atlassian Pty Ltd
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.java.sip.communicator.plugin.zeroconfaccregwizz;
-
-import java.awt.*;
-import java.util.*;
-
-import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.protocol.*;
-import net.java.sip.communicator.util.*;
-
-import org.osgi.framework.*;
-
-/**
- * The <tt>ZeroconfAccountRegistrationWizard</tt> is an implementation of the
- * <tt>AccountRegistrationWizard</tt> for the Zeroconf protocol. It allows
- * the user to create and configure a new Zeroconf account.
- *
- * @author Christian Vincenot
- * @author Maxime Catelin
- */
-public class ZeroconfAccountRegistrationWizard
- extends DesktopAccountRegistrationWizard
-{
- private Logger logger
- = Logger.getLogger(ZeroconfAccountRegistrationWizard.class);
-
- /**
- * The first page of the zeroconf account registration wizard.
- */
- private FirstWizardPage firstWizardPage;
-
- /**
- * The object that we use to store details on an account that we will be
- * creating.
- */
- private ZeroconfAccountRegistration registration
- = new ZeroconfAccountRegistration();
-
- private ProtocolProviderService protocolProvider;
-
- /**
- * Creates an instance of <tt>ZeroconfAccountRegistrationWizard</tt>.
- * @param wizardContainer the wizard container, where this wizard
- * is added
- */
- public ZeroconfAccountRegistrationWizard(WizardContainer wizardContainer)
- {
- setWizardContainer(wizardContainer);
-
- wizardContainer
- .setFinishButtonText(Resources.getString("service.gui.SIGN_IN"));
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getIcon</code> method.
- * Returns the icon to be used for this wizard.
- * @return byte[]
- */
- @Override
- public byte[] getIcon()
- {
- return Resources.getImage(Resources.ZEROCONF_LOGO);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getPageImage</code> method.
- * Returns the image used to decorate the wizard page
- *
- * @return byte[] the image used to decorate the wizard page
- */
- @Override
- public byte[] getPageImage()
- {
- return Resources.getImage(Resources.PAGE_IMAGE);
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolName</code>
- * method. Returns the protocol name for this wizard.
- * @return String
- */
- @Override
- public String getProtocolName()
- {
- return Resources.getString("plugin.zeroaccregwizz.PROTOCOL_NAME");
- }
-
- /**
- * Implements the <code>AccountRegistrationWizard.getProtocolDescription
- * </code> method. Returns the description of the protocol for this wizard.
- * @return String
- */
- @Override
- public String getProtocolDescription()
- {
- return Resources.getString("plugin.zeroaccregwizz.PROTOCOL_DESCRIPTION");
- }
-
- /**
- * Returns the set of pages contained in this wizard.
- * @return Iterator
- */
- @Override
- public Iterator<WizardPage> getPages()
- {
- java.util.List<WizardPage> pages = new ArrayList<WizardPage>();
-
- // create new registration, our container needs the pages
- // this means this is a new wizard and we must reset all data
- // it will be invoked and when the wizard cleans and unregister
- // our pages, but this fix don't hurt in this situation.
- this.registration = new ZeroconfAccountRegistration();
-
- firstWizardPage = new FirstWizardPage(this);
-
- pages.add(firstWizardPage);
-
- return pages.iterator();
- }
-
- /**
- * Returns the set of data that user has entered through this wizard.
- * @return Iterator
- */
- @Override
- public Iterator<Map.Entry<String, String>> getSummary()
- {
- Hashtable<String, String> summaryTable = new Hashtable<String, String>();
-
- summaryTable.put("User ID", registration.getUserID());
- summaryTable.put("First Name", registration.getFirst());
- summaryTable.put("Last Name", registration.getLast());
- summaryTable.put("Mail Address", registration.getMail());
- summaryTable.put("Remember Bonjour contacts?",
- Boolean.toString(registration.isRememberContacts()));
-
- return summaryTable.entrySet().iterator();
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- *
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin()
- throws OperationFailedException
- {
- firstWizardPage.commitPage();
-
- return signin(registration.getUserID(), null);
- }
-
- /**
- * Defines the operations that will be executed when the user clicks on
- * the wizard "Signin" button.
- *
- * @param userName the user name to sign in with
- * @param password the password to sign in with
- * @return the created <tt>ProtocolProviderService</tt> corresponding to the
- * new account
- * @throws OperationFailedException if the operation didn't succeed
- */
- @Override
- public ProtocolProviderService signin(String userName, String password)
- throws OperationFailedException
- {
- ProtocolProviderFactory factory
- = ZeroconfAccRegWizzActivator.getZeroconfProtocolProviderFactory();
-
- return this.installAccount(factory,
- userName);
- }
-
- /**
- * Creates an account for the given user and password.
- *
- * @return the <tt>ProtocolProviderService</tt> for the new account.
- * @param providerFactory the ProtocolProviderFactory which will create
- * the account
- * @param user the user identifier
- */
- public ProtocolProviderService installAccount(
- ProtocolProviderFactory providerFactory,
- String user)
- throws OperationFailedException
- {
- Hashtable<String, String> accountProperties
- = new Hashtable<String, String>();
-
- accountProperties.put(ProtocolProviderFactory.ACCOUNT_ICON_PATH,
- "resources/images/protocol/zeroconf/zeroconf32x32.png");
-
- accountProperties.put("first", registration.getFirst());
- accountProperties.put("last", registration.getLast());
- accountProperties.put("mail", registration.getMail());
-
- accountProperties.put(
- ProtocolProviderFactory.NO_PASSWORD_REQUIRED,
- new Boolean(true).toString());
-
- accountProperties.put("rememberContacts",
- new Boolean(registration.isRememberContacts()).toString());
-
- if (isModification())
- {
- providerFactory.uninstallAccount(protocolProvider.getAccountID());
- this.protocolProvider = null;
- setModification(false);
- }
-
- try
- {
- AccountID accountID = providerFactory.installAccount(
- user, accountProperties);
-
- ServiceReference serRef = providerFactory
- .getProviderForAccount(accountID);
-
- protocolProvider = (ProtocolProviderService)
- ZeroconfAccRegWizzActivator.bundleContext
- .getService(serRef);
- }
- catch (IllegalStateException exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Account already exists.",
- OperationFailedException.IDENTIFICATION_CONFLICT);
- }
- catch (Exception exc)
- {
- logger.warn(exc.getMessage());
-
- throw new OperationFailedException(
- "Failed to add account",
- OperationFailedException.GENERAL_ERROR);
- }
-
-
- return protocolProvider;
- }
-
- /**
- * Fills the UserID and Password fields in this panel with the data coming
- * from the given protocolProvider.
- * @param protocolProvider The <tt>ProtocolProviderService</tt> to load the
- * data from.
- */
- @Override
- public void loadAccount(ProtocolProviderService protocolProvider)
- {
- setModification(true);
-
- this.protocolProvider = protocolProvider;
-
- this.registration = new ZeroconfAccountRegistration();
-
- this.firstWizardPage.loadAccount(protocolProvider);
- }
-
- /**
- * Returns the registration object, which will store all the data through
- * the wizard.
- *
- * @return the registration object, which will store all the data through
- * the wizard
- */
- public ZeroconfAccountRegistration getRegistration()
- {
- return registration;
- }
-
- /**
- * Returns the size of this wizard.
- * @return the size of this wizard
- */
- @Override
- public Dimension getSize()
- {
- return new Dimension(600, 500);
- }
-
- /**
- * Returns the identifier of the page to show first in the wizard.
- * @return the identifier of the page to show first in the wizard.
- */
- @Override
- public Object getFirstPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- /**
- * Returns the identifier of the page to show last in the wizard.
- * @return the identifier of the page to show last in the wizard.
- */
- @Override
- public Object getLastPageIdentifier()
- {
- return firstWizardPage.getIdentifier();
- }
-
- /**
- * Returns the password label for the simplified account registration form.
- * @return the password label for the simplified account registration form.
- */
- public String getPasswordLabel()
- {
- return Resources.getString("service.gui.PASSWORD");
- }
-
- /**
- * Returns the user name label for the simplified account registration
- * form.
- *
- * @return the user name label for the simplified account registration
- * form.
- */
- public String getUserNameLabel()
- {
- return Resources.getString("userID");
- }
-
- /**
- * Returns an example string, which should indicate to the user how the
- * user name should look like.
- * @return an example string, which should indicate to the user how the
- * user name should look like.
- */
- @Override
- public String getUserNameExample()
- {
- return null;
- }
-
- /**
- * Indicates whether this wizard enables the simple "sign in" form shown
- * when the user opens the application for the first time. The simple
- * "sign in" form allows user to configure her account in one click, just
- * specifying her username and password and leaving any other configuration
- * as by default.
- * @return <code>true</code> if the simple "Sign in" form is enabled or
- * <code>false</code> otherwise.
- */
- @Override
- public boolean isSimpleFormEnabled()
- {
- return false;
- }
-
- /**
- * Returns a simple account registration form that would be the first form
- * shown to the user. Only if the user needs more settings she'll choose
- * to open the advanced wizard, consisted by all pages.
- *
- * @param isCreateAccount indicates if the simple form should be opened as
- * a create account form or as a login form
- * @return a simple account registration form
- */
- @Override
- public Object getSimpleForm(boolean isCreateAccount)
- {
- // when creating first wizard page, create and new
- // AccountRegistration to avoid reusing old instances and
- // data left from old registrations
- this.registration = new ZeroconfAccountRegistration();
-
- firstWizardPage = new FirstWizardPage(this);
- return firstWizardPage.getSimpleForm();
- }
-}
diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/zeroconfaccregwizz.manifest.mf b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/zeroconfaccregwizz.manifest.mf
deleted file mode 100644
index 57a863b..0000000
--- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/zeroconfaccregwizz.manifest.mf
+++ /dev/null
@@ -1,32 +0,0 @@
-Bundle-Activator: net.java.sip.communicator.plugin.zeroconfaccregwizz.ZeroconfAccRegWizzActivator
-Bundle-Name: Zeroconf account registration wizard
-Bundle-Description: Zeroconf account registration wizard.
-Bundle-Vendor: jitsi.org
-Bundle-Version: 0.0.1
-Bundle-SymbolicName: net.java.sip.communicator.plugin.zeroconfaccregwizz
-Import-Package: org.osgi.framework,
- net.java.sip.communicator.service.browserlauncher,
- org.jitsi.service.configuration,
- net.java.sip.communicator.service.contactlist,
- net.java.sip.communicator.service.contactlist.event,
- net.java.sip.communicator.service.gui,
- net.java.sip.communicator.service.gui.event,
- net.java.sip.communicator.service.protocol,
- net.java.sip.communicator.service.protocol.event,
- org.jitsi.service.resources, net.java.sip.communicator.service.resources,
- net.java.sip.communicator.util,
- net.java.sip.communicator.plugin.desktoputil,
- javax.swing,
- javax.swing.event,
- javax.swing.table,
- javax.swing.text,
- javax.swing.text.html,
- javax.accessibility,
- javax.swing.plaf,
- javax.swing.plaf.metal,
- javax.swing.plaf.basic,
- javax.imageio,
- javax.swing.filechooser,
- javax.swing.tree,
- javax.swing.undo,
- javax.swing.border