diff options
author | Damian Minkov <damencho@jitsi.org> | 2009-05-16 09:17:27 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2009-05-16 09:17:27 +0000 |
commit | 0cb1c0688b8a097db834fce57b78b1e57c5624cf (patch) | |
tree | 7e568166074ce578f9fc2a3d59e98f039427048f /src/net/java/sip | |
parent | 164236df250af4d904f30f85588441c5ce476bcc (diff) | |
download | jitsi-0cb1c0688b8a097db834fce57b78b1e57c5624cf.zip jitsi-0cb1c0688b8a097db834fce57b78b1e57c5624cf.tar.gz jitsi-0cb1c0688b8a097db834fce57b78b1e57c5624cf.tar.bz2 |
- When download site is down updatecheck blocks loading bundles. Fixed. Check moved in separate thread and set timout to connection in order to avoid infinite block of thread.
- 3 threads in jml never ends after logout, fixed now.
Diffstat (limited to 'src/net/java/sip')
-rw-r--r-- | src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java | 236 | ||||
-rw-r--r-- | src/net/java/sip/communicator/service/protocol/OperationSetInstantMessageFiltering.java | 6 |
2 files changed, 129 insertions, 113 deletions
diff --git a/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java b/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java index ed72b7c..03149e4 100644 --- a/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java +++ b/src/net/java/sip/communicator/plugin/updatechecker/UpdateCheckActivator.java @@ -86,116 +86,9 @@ public class UpdateCheckActivator logger.logExit(); } - String osName = System.getProperty("os.name"); - - if (osName.startsWith("Windows")) - { - // register update button - Hashtable<String, String> toolsMenuFilter - = new Hashtable<String, String>(); - toolsMenuFilter.put( Container.CONTAINER_ID, - Container.CONTAINER_HELP_MENU.getID()); - - bundleContext.registerService( - PluginComponent.class.getName(), - new UpdateMenuButtonComponent( - Container.CONTAINER_HELP_MENU), - toolsMenuFilter); - } - - if(isNewestVersion()) - return; - - if (osName.startsWith("Windows")) - { - windowsUpdaterShow(); - return; - } - - final JDialog dialog = new SIPCommDialog() - { - protected void close(boolean isEscaped) - { - } - }; - dialog.setTitle( - getResources().getI18NString("plugin.updatechecker.DIALOG_TITLE")); - - JEditorPane contentMessage = new JEditorPane(); - contentMessage.setContentType("text/html"); - contentMessage.setOpaque(false); - contentMessage.setEditable(false); - - String dialogMsg = - getResources().getI18NString("plugin.updatechecker.DIALOG_MESSAGE", - new String[]{getResources() - .getSettingsString("service.gui.APPLICATION_NAME")}); - - if(lastVersion != null) - dialogMsg += - getResources().getI18NString( - "plugin.updatechecker.DIALOG_MESSAGE_2", - new String[]{ - getResources().getSettingsString( - "service.gui.APPLICATION_NAME"), - lastVersion}); - - contentMessage.setText(dialogMsg); - - JPanel contentPane = new TransparentPanel(new BorderLayout(5,5)); - contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - contentPane.add(contentMessage, BorderLayout.CENTER); - - JPanel buttonPanel - = new TransparentPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); - JButton closeButton = new JButton( - getResources().getI18NString("plugin.updatechecker.BUTTON_CLOSE")); - - closeButton.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) - { - dialog.setVisible(false); - } - }); - - if(downloadLink != null) - { - JButton downloadButton = new JButton(getResources().getI18NString( - "plugin.updatechecker.BUTTON_DOWNLOAD")); - - downloadButton.addActionListener(new ActionListener() { - - public void actionPerformed(ActionEvent e) - { - if(isLinux64()) - { - downloadLink = downloadLink.replace("i386", "amd64"); - } - - getBrowserLauncher().openURL(downloadLink); - dialog.dispose(); - } - }); - - buttonPanel.add(downloadButton); - } - - buttonPanel.add(closeButton); - - contentPane.add(buttonPanel, BorderLayout.SOUTH); - - dialog.setContentPane(contentPane); - - dialog.pack(); - - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - dialog.setLocation( - screenSize.width/2 - dialog.getWidth()/2, - screenSize.height/2 - dialog.getHeight()/2 - ); - - dialog.setVisible(true); + Thread updateThread = new Thread(new UpdateCheckThread()); + updateThread.setDaemon(true); + updateThread.start(); } /** @@ -313,9 +206,12 @@ public class UpdateCheckActivator } URL url = new URL(configString); + URLConnection conn = url.openConnection(); + conn.setConnectTimeout(10000); + conn.setReadTimeout(10000); Properties props = new Properties(); - props.load(url.openStream()); + props.load(conn.getInputStream()); lastVersion = props.getProperty("last_version"); downloadLink = props.getProperty("download_link"); @@ -768,4 +664,122 @@ public class UpdateCheckActivator return null; } } + + private class UpdateCheckThread + implements Runnable + { + public void run() + { + String osName = System.getProperty("os.name"); + + if (osName.startsWith("Windows")) + { + // register update button + Hashtable<String, String> toolsMenuFilter + = new Hashtable<String, String>(); + toolsMenuFilter.put( Container.CONTAINER_ID, + Container.CONTAINER_HELP_MENU.getID()); + + bundleContext.registerService( + PluginComponent.class.getName(), + new UpdateMenuButtonComponent( + Container.CONTAINER_HELP_MENU), + toolsMenuFilter); + } + + if(isNewestVersion()) + return; + + if (osName.startsWith("Windows")) + { + windowsUpdaterShow(); + return; + } + + final JDialog dialog = new SIPCommDialog() + { + protected void close(boolean isEscaped) + { + } + }; + dialog.setTitle( + getResources().getI18NString("plugin.updatechecker.DIALOG_TITLE")); + + JEditorPane contentMessage = new JEditorPane(); + contentMessage.setContentType("text/html"); + contentMessage.setOpaque(false); + contentMessage.setEditable(false); + + String dialogMsg = + getResources().getI18NString("plugin.updatechecker.DIALOG_MESSAGE", + new String[]{getResources() + .getSettingsString("service.gui.APPLICATION_NAME")}); + + if(lastVersion != null) + dialogMsg += + getResources().getI18NString( + "plugin.updatechecker.DIALOG_MESSAGE_2", + new String[]{ + getResources().getSettingsString( + "service.gui.APPLICATION_NAME"), + lastVersion}); + + contentMessage.setText(dialogMsg); + + JPanel contentPane = new TransparentPanel(new BorderLayout(5,5)); + contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + contentPane.add(contentMessage, BorderLayout.CENTER); + + JPanel buttonPanel + = new TransparentPanel(new FlowLayout(FlowLayout.CENTER, 10, 10)); + JButton closeButton = new JButton( + getResources().getI18NString("plugin.updatechecker.BUTTON_CLOSE")); + + closeButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + dialog.setVisible(false); + } + }); + + if(downloadLink != null) + { + JButton downloadButton = new JButton(getResources().getI18NString( + "plugin.updatechecker.BUTTON_DOWNLOAD")); + + downloadButton.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) + { + if(isLinux64()) + { + downloadLink = downloadLink.replace("i386", "amd64"); + } + + getBrowserLauncher().openURL(downloadLink); + dialog.dispose(); + } + }); + + buttonPanel.add(downloadButton); + } + + buttonPanel.add(closeButton); + + contentPane.add(buttonPanel, BorderLayout.SOUTH); + + dialog.setContentPane(contentPane); + + dialog.pack(); + + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + dialog.setLocation( + screenSize.width/2 - dialog.getWidth()/2, + screenSize.height/2 - dialog.getHeight()/2 + ); + + dialog.setVisible(true); + } + } } diff --git a/src/net/java/sip/communicator/service/protocol/OperationSetInstantMessageFiltering.java b/src/net/java/sip/communicator/service/protocol/OperationSetInstantMessageFiltering.java index de2b6d0..b76d15e 100644 --- a/src/net/java/sip/communicator/service/protocol/OperationSetInstantMessageFiltering.java +++ b/src/net/java/sip/communicator/service/protocol/OperationSetInstantMessageFiltering.java @@ -1,6 +1,8 @@ /* - * To change this template, choose Tools | Templates - * and open the template in the editor. + * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. + * + * Distributable under LGPL license. + * See terms of license at gnu.org. */ package net.java.sip.communicator.service.protocol; |