diff options
Diffstat (limited to 'src/net/java/sip/communicator/plugin/dictaccregwizz')
9 files changed, 0 insertions, 2025 deletions
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 |