1. Update Checker

2. Fix of Bulgarian translation
3. Move to latest jain-sip(committed by Emil)
cusax-fix
Damian Minkov 18 years ago
parent 2f4c61da7c
commit fff24887c6

@ -616,7 +616,8 @@
bundle-pluginmanager,bundle-notification,
bundle-ssh,bundle-plugin-sshaccregwizz,
bundle-contacteventhandler,bundle-plugin-contactinfo,
bundle-plugin-accountinfo,bundle-plugin-chatalerter"/>
bundle-plugin-accountinfo,bundle-plugin-chatalerter,
bundle-updatecheckplugin"/>
<!--BUNDLE-HISTORY-->
<target name="bundle-history">
@ -1608,4 +1609,18 @@ javax.swing.event, javax.swing.border"/>
prefix="resources/languages/plugin/accountinfo"/>
</jar>
</target>
<!--BUNDLE-UpdateCheckPlugin-->
<target name="bundle-updatecheckplugin">
<jar compress="false" destfile="${bundles.dest}/updatechecker.jar"
manifest="src/net/java/sip/communicator/plugin/updatechecker/updatecheck.manifest.mf">
<zipfileset dir="classes/net/java/sip/communicator/plugin/updatechecker"
prefix="net/java/sip/communicator/plugin/updatechecker" />
<zipfileset dir="${resources}/config" includes="updatecheck.properties"
prefix="resources/config" />
<zipfileset dir="${resources}/languages/plugin/updatechecker"
prefix="resources/languages/plugin/updatechecker"/>
</jar>
</target>
</project>

@ -93,6 +93,7 @@ felix.auto.start.60= \
felix.auto.start.66= \
reference:file:sc-bundles/swing-ui.jar \
reference:file:sc-bundles/updatechecker.jar \
reference:file:sc-bundles/systray.jar
felix.auto.start.67= \

@ -0,0 +1,2 @@
destinationPath=http://download.sip-communicator.org/nightly
pkgName=sip-communicator

@ -95,7 +95,7 @@ createChatRoom=&Създай стая за разговори...
createChatRoomNotSupported=Неуспешен опит за създаване на стая: {0}. Сървър {1} не поддържа тази операция.
createChatRoomError=Неуспешен опит за създаване на стая: {0}.
createChatRoomWizard=Create chat room wizard
createGroup=&Създай груп
createGroup=&Създай групa
createGroupName=Въведете името на групата, която бихте искали да създадете.
createFirstGroupWizard=Списъкът ви с контакти не съдържа групи. Моля добавете група от меню Файл/Добави група.
cut=О&трежи

@ -0,0 +1,2 @@
dialogTitle=New version available
dialogMessage=<html>There is new version of {0} <br>you can download it at : <br>

@ -0,0 +1,76 @@
/*
* 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.plugin.updatechecker;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.logging.*;
import javax.swing.*;
import net.java.sip.communicator.util.Logger;
/**
*
* @author Yana Stamcheva
*/
public class Resources
{
private static Logger logger = Logger.getLogger(Resources.class);
private static final String CONFIG_BUNDLE_NAME
= "resources.config.updatecheck";
private static final ResourceBundle configBundle = ResourceBundle
.getBundle(CONFIG_BUNDLE_NAME);
private static final String LANG_BUNDLE_NAME
= "resources.languages.plugin.updatechecker.resources";
private static final ResourceBundle langBundle = ResourceBundle
.getBundle(LANG_BUNDLE_NAME);
/**
* 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 getConfigString(String key)
{
try
{
return configBundle.getString(key);
}
catch (MissingResourceException e)
{
logger.error("Missing resources.", e);
return 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 getLangString(String key)
{
try
{
return langBundle.getString(key);
}
catch (MissingResourceException e)
{
logger.error("Missing resources.", e);
return null;
}
}
}

@ -0,0 +1,238 @@
/*
* 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.plugin.updatechecker;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import java.text.MessageFormat;
import java.util.*;
import javax.swing.*;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.*;
import javax.swing.text.html.*;
import net.java.sip.communicator.service.browserlauncher.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.version.VersionService;
import net.java.sip.communicator.util.*;
import org.osgi.framework.*;
/**
* Activates the UpdateCheck plugin
* @author Damian Minkov
**/
public class UpdateCheckActivator
implements BundleActivator
{
private static Logger logger = Logger.getLogger(UpdateCheckActivator.class);
private static BundleContext bundleContext = null;
private static BrowserLauncherService browserLauncherService;
/**
* Starts this bundle
*
* @param bundleContext BundleContext
* @throws Exception
*/
public void start(BundleContext bundleContext) throws Exception
{
try
{
logger.logEntry();
this.bundleContext = bundleContext;
}
finally
{
logger.logExit();
}
ServiceReference serviceReference = bundleContext
.getServiceReference(
net.java.sip.communicator.service.version.VersionService.class.getName());
VersionService verService = (VersionService) bundleContext
.getService(serviceReference);
net.java.sip.communicator.service.version.Version
ver = verService.getCurrentVersion();
if(isNewestVersion(ver.toString()))
return;
final JDialog dialog = new JDialog();
dialog.setTitle(Resources.getLangString("dialogTitle"));
JEditorPane contentMessage = new JEditorPane();
contentMessage.setContentType("text/html");
contentMessage.setOpaque(false);
contentMessage.setEditable(false);
contentMessage.setText(
MessageFormat.format(
Resources.getLangString("dialogMessage"),
ver.getApplicationName()) +
"<a href=\"" + Resources.getConfigString("destinationPath") + "\">" +
Resources.getConfigString("destinationPath") + "</a> </html>");
contentMessage.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e)
{
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
{
getBrowserLauncher().openURL(e.getDescription());
}
}
});
JPanel contentPane = new JPanel(new BorderLayout(5,5));
contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
contentPane.add(contentMessage, BorderLayout.CENTER);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
JButton okButton = new JButton("OK");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
dialog.setVisible(false);
}
});
buttonPanel.add(okButton);
contentPane.add(buttonPanel, BorderLayout.SOUTH);
dialog.setContentPane(contentPane);
dialog.pack();
dialog.setLocation(
Toolkit.getDefaultToolkit().getScreenSize().width/2
- dialog.getWidth()/2,
Toolkit.getDefaultToolkit().getScreenSize().height/2
- dialog.getHeight()/2
);
dialog.setVisible(true);
}
/**
* stop the bundle
*/
public void stop(BundleContext bundleContext) 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;
}
/**
* Check the first link as files on the web are sorted by date
* @param currentVersionStr
* @return
*/
private boolean isNewestVersion(String currentVersionStr)
{
String pkgName = Resources.getConfigString("pkgName") + "-";
EditorKit kit = new HTMLEditorKit();
Document doc = kit.createDefaultDocument();
// The Document class does not yet
// handle charset's properly.
doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
try
{
// as some of the distribution has own mechanisums of
// updating so just check from one of the platforms
// which is the last version
// Create a reader on the HTML content.
Reader rd = getReader(Resources.getConfigString("destinationPath") + "/windows");
// Parse the HTML.
kit.read(rd, doc, 0);
// Iterate through the elements
// of the HTML document.
ElementIterator it = new ElementIterator(doc);
Element elem;
while ((elem = it.next()) != null)
{
SimpleAttributeSet s = (SimpleAttributeSet)
elem.getAttributes().getAttribute(HTML.Tag.A);
if (s != null)
{
String link = s.getAttribute(HTML.Attribute.HREF).toString();
if(!link.startsWith(pkgName))
continue;
link = link.replaceAll(pkgName, "");
link = link.substring(0, link.lastIndexOf('.'));
return link.compareTo(currentVersionStr) <= 0;
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
return false;
}
// Returns a reader on the HTML data. If 'uri' begins
// with "http:", it's treated as a URL; otherwise,
// it's assumed to be a local filename.
static Reader getReader(String uri)
throws IOException
{
if (uri.startsWith("http:"))
{
// Retrieve from Internet.
URLConnection conn = new URL(uri).openConnection();
return new InputStreamReader(conn.getInputStream());
}
else
{
return new FileReader(uri);
}
}
}

@ -0,0 +1,15 @@
Bundle-Activator: net.java.sip.communicator.plugin.updatechecker.UpdateCheckActivator
Bundle-Name: UpdateCheckPlugin
Bundle-Description: A bundle that implements the UpdateCheck Plugin Package.
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
Import-Package: org.osgi.framework,
net.java.sip.communicator.util,
net.java.sip.communicator.service.gui,
net.java.sip.communicator.service.version,
net.java.sip.communicator.service.browserlauncher,
javax.swing,
javax.swing.event,
javax.swing.text,
javax.swing.text.html,
javax.imageio
Loading…
Cancel
Save