Use registry for autostart on windows.

cusax-fix
Damian Minkov 15 years ago
parent a457a83458
commit df402569d0

@ -894,6 +894,7 @@
bundle-protocol,bundle-protocol-media,bundle-icq,
bundle-icq-slick,bundle-mock,bundle-smacklib,bundle-jmdnslib,
bundle-jabber,bundle-jabber-slick,bundle-swing-ui,bundle-ui-service,
bundle-jnalib,
bundle-msn,bundle-msn-slick,bundle-yahoo,bundle-yahoo-slick,
bundle-contactlist,meta-contactlist,meta-contactlist-slick,
bundle-plugin-icqaccregwizz,bundle-plugin-jabberaccregwizz,
@ -1337,6 +1338,14 @@ javax.swing.event, javax.swing.border"/>
</jar>
</target>
<target name="bundle-jnalib">
<!-- Creates a bundle containing the jmdns lib.-->
<jar compress="false" destfile="${bundles.dest}/jnalib.jar"
manifest="${lib.noinst}/jna.manifest.mf">
<zipfileset src="${lib.noinst}/jna.jar" prefix=""/>
</jar>
</target>
<!-- BUNDLE-ICQ -->
<target name="bundle-icq">
<!-- Creates a bundle containing the icq impl of the protocol provider.-->
@ -1510,7 +1519,6 @@ javax.swing.event, javax.swing.border"/>
manifest="${src}/net/java/sip/communicator/impl/gui/swing.ui.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/impl/gui"
prefix="net/java/sip/communicator/impl/gui"/>
<zipfileset src="lib/installer-exclude/jna.jar" prefix=""/>
<zipfileset src="lib/installer-exclude/transparency.jar" prefix=""/>
<zipfileset src="lib/installer-exclude/swing-worker-1.2.jar" prefix=""/>
<zipfileset src="lib/installer-exclude/mac_widgets-0.9.5.jar" prefix=""/>
@ -2126,7 +2134,14 @@ org.apache.http.util"/>
manifest="${src}/net/java/sip/communicator/plugin/generalconfig/generalconfig.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/plugin/generalconfig"
prefix="net/java/sip/communicator/plugin/generalconfig" />
<zipfileset src="${lib.noinst}/izpack-shortcut-link.jar" prefix=""/>
</jar>
<!-- on windows general config needs jna-platform to access windows registry -->
<jar compress="false" destfile="${bundles.dest.win}/generalconfig.jar"
manifest="${src}/net/java/sip/communicator/plugin/generalconfig/generalconfig.manifest.mf">
<zipfileset dir="${dest}/net/java/sip/communicator/plugin/generalconfig"
prefix="net/java/sip/communicator/plugin/generalconfig" />
<zipfileset src="${lib.win.noinst}/jna-platform-win32.jar" prefix=""/>
</jar>
</target>

@ -59,6 +59,7 @@
<classpathentry kind="lib" path="lib/os-specific/solaris/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/solaris/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/installer-exclude/jmf.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/installer-exclude/jna-platform-win32.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/installer-exclude/sound.jar"/>
<classpathentry kind="lib" path="lib/os-specific/windows/jdic_stub.jar"/>
<classpathentry kind="lib" path="lib/installer-exclude/lcrypto-jdk16-143.jar"/>

@ -123,7 +123,7 @@
<compilation-unit>
<package-root>src</package-root>
<classpath
mode="compile">lib/felix.jar:lib/jdic-all.jar:lib/bundle/junit.jar:lib/bundle/log4j.jar:lib/bundle/commons-logging.jar:lib/installer-exclude/concurrent.jar:lib/installer-exclude/dict4j.jar:lib/installer-exclude/dnsjava.jar:lib/installer-exclude/jain-sip-api.jar:lib/installer-exclude/jain-sip-ri.jar:lib/installer-exclude/jain-sdp.jar:lib/installer-exclude/jcalendar-1.3.2.jar:lib/installer-exclude/jdic_misc.jar:lib/installer-exclude/jdom.jar:lib/installer-exclude/jmf.jar:lib/installer-exclude/jml-1.0b5.jar:lib/installer-exclude/joscar-client.jar:lib/installer-exclude/joscar-common.jar:lib/installer-exclude/joscar-protocol.jar:lib/installer-exclude/jsocks-klea.jar:lib/installer-exclude/jspeex.jar:lib/installer-exclude/junit.jar:lib/installer-exclude/log4j-1.2.8.jar:lib/installer-exclude/nist-sdp-1.0.jar:lib/installer-exclude/rome-0.9.jar:lib/installer-exclude/smack.jar:lib/installer-exclude/smackx.jar:lib/installer-exclude/ymsg_network_v0_67.jar:lib/installer-exclude/fmj.jar:lib/installer-exclude/jna.jar:lib/installer-exclude/lti-civil-no_s_w_t.jar:lib/installer-exclude/swing-worker-1.2.jar:lib/os-specific/linux/installer-exclude/jmf.jar:lib/os-specific/linux/jdic_stub.jar:lib/os-specific/mac/OrangeExtensions.jar:lib/os-specific/mac/growl4j.jar:lib/os-specific/mac/jdic_stub.jar:lib/os-specific/mac/installer-exclude/jmf.jar:lib/os-specific/mac/installer-exclude/dock.jar:lib/os-specific/windows/jdic_stub.jar:lib/os-specific/windows/installer-exclude/jmf.jar:lib/os-specific/windows/installer-exclude/sound.jar:lib/installer-exclude/aclibico-2.1.jar:lib/installer-exclude/jdic_misc.jar:lib/installer-exclude/pircbot.jar:lib/os-specific/solaris/jdic_stub.jar:lib/os-specific/solaris/installer-exclude/jmf.jar:lib/installer-exclude/jsch-0.1.36.jar:lib/installer-exclude/apache-ant-1.7.0.jar:lib/installer-exclude/izpack-shortcut-link.jar:lib/installer-exclude/jfontchooser-1.0.5.jar:lib/installer-exclude/laf-widget.jar:lib/installer-exclude/transparency.jar:lib/installer-exclude/zrtp4j-light.jar:lib/installer-exclude/lcrypto-jdk16-143.jar:lib/installer-exclude/otr4j.jar:lib/installer-exclude/profiler4j-1.0-beta3-SC.jar:lib/installer-exclude/httpcore-4.0.1.jar:lib/installer-exclude/httpclient-4.0.1.jar:lib/installer-exclude/json-20090723.jar:lib/installer-exclude/ice4j.jar:lib/installer-exclude/dhcp4java-1.00.jar:lib/installer-exclude/jmdns.jar:lib/installer-exclude/jmyspell-core.jar:lib/installer-exclude/jnsapi.jar:lib/installer-exclude/mac_widgets-0.9.5.jar:lib/installer-exclude/forms-1.2.1.jar:lib/installer-exclude/weupnp-0.1.2-SNAPSHOT.jar:lib/installer-exclude/libphonenumber-2.4.jar</classpath>
mode="compile">lib/felix.jar:lib/jdic-all.jar:lib/bundle/junit.jar:lib/bundle/log4j.jar:lib/bundle/commons-logging.jar:lib/installer-exclude/concurrent.jar:lib/installer-exclude/dict4j.jar:lib/installer-exclude/dnsjava.jar:lib/installer-exclude/jain-sip-api.jar:lib/installer-exclude/jain-sip-ri.jar:lib/installer-exclude/jain-sdp.jar:lib/installer-exclude/jcalendar-1.3.2.jar:lib/installer-exclude/jdic_misc.jar:lib/installer-exclude/jdom.jar:lib/installer-exclude/jmf.jar:lib/installer-exclude/jml-1.0b5.jar:lib/installer-exclude/joscar-client.jar:lib/installer-exclude/joscar-common.jar:lib/installer-exclude/joscar-protocol.jar:lib/installer-exclude/jsocks-klea.jar:lib/installer-exclude/jspeex.jar:lib/installer-exclude/junit.jar:lib/installer-exclude/log4j-1.2.8.jar:lib/installer-exclude/nist-sdp-1.0.jar:lib/installer-exclude/rome-0.9.jar:lib/installer-exclude/smack.jar:lib/installer-exclude/smackx.jar:lib/installer-exclude/ymsg_network_v0_67.jar:lib/installer-exclude/fmj.jar:lib/installer-exclude/jna.jar:lib/installer-exclude/lti-civil-no_s_w_t.jar:lib/installer-exclude/swing-worker-1.2.jar:lib/os-specific/linux/installer-exclude/jmf.jar:lib/os-specific/linux/jdic_stub.jar:lib/os-specific/mac/OrangeExtensions.jar:lib/os-specific/mac/growl4j.jar:lib/os-specific/mac/jdic_stub.jar:lib/os-specific/mac/installer-exclude/jmf.jar:lib/os-specific/mac/installer-exclude/dock.jar:lib/os-specific/windows/jdic_stub.jar:lib/os-specific/windows/installer-exclude/jmf.jar:lib/os-specific/windows/installer-exclude/sound.jar:lib/os-specific/windows/installer-exclude/jna-platform-win32.jar:lib/installer-exclude/aclibico-2.1.jar:lib/installer-exclude/jdic_misc.jar:lib/installer-exclude/pircbot.jar:lib/os-specific/solaris/jdic_stub.jar:lib/os-specific/solaris/installer-exclude/jmf.jar:lib/installer-exclude/jsch-0.1.36.jar:lib/installer-exclude/apache-ant-1.7.0.jar:lib/installer-exclude/izpack-shortcut-link.jar:lib/installer-exclude/jfontchooser-1.0.5.jar:lib/installer-exclude/laf-widget.jar:lib/installer-exclude/transparency.jar:lib/installer-exclude/zrtp4j-light.jar:lib/installer-exclude/lcrypto-jdk16-143.jar:lib/installer-exclude/otr4j.jar:lib/installer-exclude/profiler4j-1.0-beta3-SC.jar:lib/installer-exclude/httpcore-4.0.1.jar:lib/installer-exclude/httpclient-4.0.1.jar:lib/installer-exclude/json-20090723.jar:lib/installer-exclude/ice4j.jar:lib/installer-exclude/dhcp4java-1.00.jar:lib/installer-exclude/jmdns.jar:lib/installer-exclude/jmyspell-core.jar:lib/installer-exclude/jnsapi.jar:lib/installer-exclude/mac_widgets-0.9.5.jar:lib/installer-exclude/forms-1.2.1.jar:lib/installer-exclude/weupnp-0.1.2-SNAPSHOT.jar:lib/installer-exclude/libphonenumber-2.4.jar</classpath>
<built-to>classes</built-to>
<source-level>1.5</source-level>
</compilation-unit>

@ -39,6 +39,7 @@ felix.auto.start.30= \
felix.auto.start.40= \
reference:file:sc-bundles/configuration.jar \
reference:file:sc-bundles/jmdnslib.jar \
reference:file:sc-bundles/jnalib.jar \
reference:file:sc-bundles/provdisc.jar \
reference:file:sc-bundles/resourcemanager.jar \
reference:file:sc-bundles/jfontchooserlib.jar \

Binary file not shown.

@ -0,0 +1,10 @@
Bundle-Name: JNA Lib Provider
Bundle-Description: JNA Lib Provider
Bundle-Vendor: sip-communicator.org
Bundle-Version: 0.0.1
System-Bundle: yes
Export-Package: com.sun.jna.win32,
com.sun.jna,
com.sun.jna.ptr,
com.sun.jna.examples

Binary file not shown.

@ -55,6 +55,18 @@
</RegistryKey>
</Component>
<Component
Id="Component_StartupRegistryEntries"
Directory="TARGETDIR"
Guid="64F3D56F-62D3-420D-B5A3-C448EB169708">
<Condition><![CDATA[HAS_STARTUP_REGISTRY]]></Condition>
<RegistryKey Action="createAndRemoveOnUninstall"
Key="Software\Microsoft\Windows\CurrentVersion\Run"
Root="HKCU">
<RegistryValue Name="@APP_NAME@" Type="string" Value="[INSTALLDIR]run.exe" />
</RegistryKey>
</Component>
</ComponentGroup>
</Fragment>
</Include>

@ -168,7 +168,7 @@
<Control Id="ShortcutGroup" Type="GroupBox" X="20" Y="60" Width="330" Height="65" Text="&amp;Create Shortcuts" />
<Control Id="StartMenuShortcutCheckBox" Type="CheckBox" X="25" Y="75" Width="320" Height="15" Property="CREATE_START_MENU_SHORTCUT" CheckBoxValue="1" Text="S&amp;tart Menu" />
<Control Id="DesktopShortcutCheckBox" Type="CheckBox" X="25" Y="90" Width="320" Height="15" Property="CREATE_DESKTOP_SHORTCUT" CheckBoxValue="1" Text="&amp;Desktop" />
<Control Id="StartupShortcutCheckBox" Type="CheckBox" X="25" Y="105" Width="320" Height="15" Property="CREATE_STARTUP_SHORTCUT" CheckBoxValue="1" Text="&amp;Auto-start when computer restarts or reboots" />
<Control Id="StartupShortcutCheckBox" Type="CheckBox" X="25" Y="105" Width="320" Height="15" Property="HAS_STARTUP_REGISTRY" CheckBoxValue="1" Text="&amp;Auto-start when computer restarts or reboots" />
<Control Id="RegistryGroup" Type="GroupBox" X="20" Y="130" Width="330" Height="50" Text="&amp;Associate Protocols" />
<Control Id="SipRegistryEntriesCheckBox" Type="CheckBox" X="25" Y="145" Width="320" Height="15" Property="CREATE_SIP_REGISTRY_ENTRIES" CheckBoxValue="1" Text="&amp;SIP" />
@ -226,12 +226,15 @@
<Custom Action="UnsetCREATE_START_MENU_SHORTCUT" After="SetINSTALLDIR">
<![CDATA[(IS_AUTOUPDATE = 1) AND NOT HAS_START_MENU_SHORTCUT AND NOT (HAS_START_MENU_SHORTCUT = "#1")]]>
</Custom>
<Custom Action="SetCREATE_STARTUP_SHORTCUT" After="SetINSTALLDIR">
<![CDATA[(IS_AUTOUPDATE = 1) AND HAS_STARTUP_SHORTCUT]]>
</Custom>
<Custom Action="UnsetCREATE_STARTUP_SHORTCUT" After="SetINSTALLDIR">
<![CDATA[(IS_AUTOUPDATE = 1) AND NOT HAS_STARTUP_SHORTCUT AND NOT (HAS_STARTUP_SHORTCUT = "#1")]]>
</Custom>
<Custom Action="SetCREATE_STARTUP_REGISTRY" After="SetINSTALLDIR">
<![CDATA[HAS_STARTUP_REGISTRY OR HAS_STARTUP_SHORTCUT]]>
</Custom>
<Custom Action="UnsetCREATE_STARTUP_REGISTRY" After="SetINSTALLDIR">
<![CDATA[NOT HAS_STARTUP_REGISTRY AND NOT (HAS_STARTUP_REGISTRY = "#1")]]>
</Custom>
<Custom Action="SetWIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" After="AppSearch">
<![CDATA[JRE_VERSION < "1.5" AND NOT Installed]]>
@ -264,8 +267,8 @@
Property="CREATE_START_MENU_SHORTCUT"
Value="1" />
<CustomAction
Id="SetCREATE_STARTUP_SHORTCUT"
Property="CREATE_STARTUP_SHORTCUT"
Id="SetCREATE_STARTUP_REGISTRY"
Property="CREATE_STARTUP_REGISTRY"
Value="1" />
<CustomAction
Id="SetINSTALLDIR"
@ -291,6 +294,10 @@
Id="UnsetCREATE_STARTUP_SHORTCUT"
Property="CREATE_STARTUP_SHORTCUT"
Value="0" />
<CustomAction
Id="UnsetCREATE_STARTUP_REGISTRY"
Property="CREATE_STARTUP_REGISTRY"
Value="0" />
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallFinalize" />
@ -311,12 +318,15 @@
<Custom Action="UnsetCREATE_START_MENU_SHORTCUT" After="SetINSTALLDIR">
<![CDATA[(IS_AUTOUPDATE = 1) AND NOT HAS_START_MENU_SHORTCUT AND NOT (HAS_START_MENU_SHORTCUT = "#1")]]>
</Custom>
<Custom Action="SetCREATE_STARTUP_SHORTCUT" After="SetINSTALLDIR">
<![CDATA[(IS_AUTOUPDATE = 1) AND HAS_STARTUP_SHORTCUT]]>
</Custom>
<Custom Action="UnsetCREATE_STARTUP_SHORTCUT" After="SetINSTALLDIR">
<![CDATA[(IS_AUTOUPDATE = 1) AND NOT HAS_STARTUP_SHORTCUT AND NOT (HAS_STARTUP_SHORTCUT = "#1")]]>
</Custom>
<Custom Action="SetCREATE_STARTUP_REGISTRY" After="SetINSTALLDIR">
<![CDATA[HAS_STARTUP_REGISTRY OR HAS_STARTUP_SHORTCUT]]>
</Custom>
<Custom Action="UnsetCREATE_STARTUP_REGISTRY" After="SetINSTALLDIR">
<![CDATA[NOT HAS_STARTUP_REGISTRY AND NOT (HAS_STARTUP_REGISTRY = "#1")]]>
</Custom>
<Custom Action="SetWIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" After="AppSearch">
<![CDATA[JRE_VERSION < "1.5" AND NOT Installed]]>
@ -347,6 +357,17 @@
Root="HKCU"
Type="raw" />
</Property>
<Property Id="HAS_STARTUP_REGISTRY">
<RegistrySearch
Id="RegistrySearch_HasStartupRegistry"
Key="Software\Microsoft\Windows\CurrentVersion\Run"
Name="@APP_NAME@"
Root="HKCU"
Type="raw" />
</Property>
<SetProperty Id="HAS_STARTUP_REGISTRY" After="AppSearch" Value="[HAS_STARTUP_SHORTCUT]">
HAS_STARTUP_SHORTCUT
</SetProperty>
<Property Id="JRE_VERSION">
<RegistrySearch
Id="RegistrySearch_JREVersion"
@ -360,6 +381,11 @@
<Property Id="ARPCONTACT" Value="@APP_EMAIL@" />
<Property Id="ARPHELPLINK" Value="@APP_WEB@" />
<Property Id="ARPPRODUCTICON" Value="Icon.ico" />
<!-- we move from startup shortcut to registry entry, we
always set CREATE_STARTUP_SHORTCUT = 0 so on update
the old shortcuts will be removed
-->
<Property Id="CREATE_STARTUP_SHORTCUT" Value="0" />
<Property Id="CREATE_FEED_REGISTRY_ENTRIES" Value="0" />
<Property Id="CREATE_SIP_REGISTRY_ENTRIES" Value="1" />
<Property Id="CREATE_XMPP_REGISTRY_ENTRIES" Value="1" />

@ -56,6 +56,7 @@ Import-Package: org.osgi.framework,
javax.swing.text.html,
javax.swing.tree,
javax.swing.undo,
com.sun.jna.examples,
org.jdesktop.jdic.desktop,
say.swing,
com.apple.eawt

@ -20,8 +20,6 @@
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.swing.*;
import com.izforge.izpack.util.os.*;
import org.osgi.framework.*;
/**
@ -94,7 +92,7 @@ private String getApplicationName()
}
/**
* Initializes the auto start checkbox.
* Initializes the auto start checkbox. Used only on windows.
* @return the created auto start check box
*/
private Component createAutoStartCheckBox()
@ -125,22 +123,7 @@ public void actionPerformed(ActionEvent e)
try
{
String appName = getApplicationName();
ShellLink shortcut =
new ShellLink(
ShellLink.STARTUP,
appName);
shortcut.setUserType(ShellLink.CURRENT_USER);
String f1 = shortcut.getcurrentUserLinkPath() +
File.separator + appName + ".lnk";
String f2 = f1.replaceAll(
System.getProperty("user.name"),
"All Users");
if(new File(f1).exists() || new File(f2).exists())
if(WindowsStartup.isStartupEnabled(getApplicationName()))
autoStartCheckBox.setSelected(true);
else
autoStartCheckBox.setSelected(false);
@ -820,59 +803,7 @@ private void setAutostart(boolean isAutoStart)
{
String workingDir = new File(".").getCanonicalPath();
String appName = getApplicationName();
ShellLink shortcut = new ShellLink(ShellLink.STARTUP, appName);
shortcut.setUserType(ShellLink.CURRENT_USER);
shortcut.setDescription(
"This starts " + appName + " Application");
shortcut.setIconLocation(
workingDir + File.separator + "sc-logo.ico", 0);
shortcut.setShowCommand(ShellLink.MINNOACTIVE);
shortcut.setTargetPath(workingDir + File.separator + "run.exe");
shortcut.setWorkingDirectory(workingDir);
String f1 = shortcut.getcurrentUserLinkPath() +
File.separator + appName + ".lnk";
String f2 = f1.replaceAll(
System.getProperty("user.name"),
"All Users");
if(isAutoStart)
{
if(!new File(f1).exists() &&
!new File(f2).exists())
shortcut.save();
}
else
{
boolean isFileDeleted = false;
try
{
isFileDeleted = new File(f1).delete();
}
catch (Exception ex)
{
if (logger.isTraceEnabled())
logger.trace("Unable to delete file. ", ex);
}
try
{
new File(f2).delete();
}
catch (Exception ex)
{
if(!isFileDeleted)
GeneralConfigPluginActivator.getUIService().
getPopupDialog().showMessagePopupDialog(
ex.getMessage(),
Resources.getString(
"plugin.generalconfig.ERROR_PERMISSION"),
PopupDialog.ERROR_MESSAGE);
// cannot delete no permissions
}
}
WindowsStartup.setAutostart(
getApplicationName(), workingDir, isAutoStart);
}
}

@ -0,0 +1,82 @@
/*
* 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.generalconfig;
import com.sun.jna.platform.win32.*;
import net.java.sip.communicator.util.*;
import java.io.*;
/**
* Take care of application auto startup. Reading and writing the registry.
*
* @author Damian Minkov
*/
public class WindowsStartup
{
/**
* The logger.
*/
private static final Logger logger
= Logger.getLogger(WindowsStartup.class);
/**
* The key under which startup keys are placed.
*/
private static String REGISTRY_STARTUP_KEY =
"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
/**
* Checks whether startup is enabled.
* @param appName the application name.
* @return is startup enabled.
*/
public static boolean isStartupEnabled(String appName)
{
return Advapi32Util.registryValueExists(
WinReg.HKEY_CURRENT_USER,
REGISTRY_STARTUP_KEY,
appName);
}
/**
* Creates or deletes registry key for application autostart.
*
* @param appName the application name
* @param workingDirectory the current working directory, normally the
* place where the application executable is placed.
* @param isAutoStart <tt>true</tt> to create registry key, <tt>false</tt>
* to delete it.
*/
public static void setAutostart(String appName,
String workingDirectory,
boolean isAutoStart)
{
if(isAutoStart)
{
Advapi32Util.registrySetStringValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_STARTUP_KEY,
appName,
workingDirectory + File.separator + "run.exe");
}
else
{
try
{
Advapi32Util.registryDeleteValue(
WinReg.HKEY_CURRENT_USER,
REGISTRY_STARTUP_KEY,
appName);
}
catch(Throwable t)
{
logger.warn("Cannot remove startup key or don't exist", t);
}
}
}
}

@ -15,6 +15,9 @@ Import-Package: org.osgi.framework,
net.java.sip.communicator.service.systray,
net.java.sip.communicator.util,
net.java.sip.communicator.util.swing,
com.sun.jna.win32,
com.sun.jna,
com.sun.jna.ptr,
javax.swing,
javax.swing.event,
javax.swing.table,

Loading…
Cancel
Save