aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator/plugin
diff options
context:
space:
mode:
authorDamian Minkov <damencho@jitsi.org>2008-07-02 15:56:53 +0000
committerDamian Minkov <damencho@jitsi.org>2008-07-02 15:56:53 +0000
commit7d31f0d49868e3f46f1b0be59bde1bd2af4f617d (patch)
tree23789268b7cc0b9f6776f6e9355b0c446684f217 /src/net/java/sip/communicator/plugin
parent1cedae22fb4931cfa9e270ae1e2871d70e92e436 (diff)
downloadjitsi-7d31f0d49868e3f46f1b0be59bde1bd2af4f617d.zip
jitsi-7d31f0d49868e3f46f1b0be59bde1bd2af4f617d.tar.gz
jitsi-7d31f0d49868e3f46f1b0be59bde1bd2af4f617d.tar.bz2
Init state of autostart option and handle and all users startup place.
Diffstat (limited to 'src/net/java/sip/communicator/plugin')
-rw-r--r--src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java17
-rw-r--r--src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationForm.java65
2 files changed, 76 insertions, 6 deletions
diff --git a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java
index 87b1dd0..1eeea2d 100644
--- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java
+++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigPluginActivator.java
@@ -19,10 +19,17 @@ public class GeneralConfigPluginActivator implements BundleActivator
private static ConfigurationService configService;
protected static BundleContext bundleContext;
+
+ private static UIService uiService;
public void start(BundleContext bc) throws Exception
{
bundleContext = bc;
+
+ ServiceReference uiServiceRef = bundleContext
+ .getServiceReference(UIService.class.getName());
+
+ uiService = (UIService) bundleContext.getService(uiServiceRef);
ConfigurationManager.loadGuiConfigurations();
@@ -57,4 +64,14 @@ public class GeneralConfigPluginActivator implements BundleActivator
return configService;
}
+
+ /**
+ * 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/generalconfig/GeneralConfigurationForm.java b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationForm.java
index d3faf47..e325fd9 100644
--- a/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationForm.java
+++ b/src/net/java/sip/communicator/plugin/generalconfig/GeneralConfigurationForm.java
@@ -84,6 +84,7 @@ public class GeneralConfigurationForm
mainPanel.add(Box.createVerticalStrut(10));
autoStartCheckBox.setText(
Resources.getString("autoStartOption"));
+ initAutoStartCheckBox();
autoStartCheckBox.addActionListener(this);
}
{
@@ -290,7 +291,6 @@ public class GeneralConfigurationForm
String appName =
Resources.getApplicationString("applicationName");
ShellLink shortcut = new ShellLink(ShellLink.STARTUP, appName);
- shortcut.setLinkType(ShellLink.STARTUP);
shortcut.setUserType(ShellLink.CURRENT_USER);
shortcut.setDescription(
"This starts " + appName + " Application");
@@ -299,18 +299,40 @@ public class GeneralConfigurationForm
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(autoStartCheckBox.isSelected())
+ {
+ if(!new File(f1).exists() &&
+ !new File(f2).exists())
shortcut.save();
+ }
else
{
- // before we can get the filename of the link
- // we have to save it
- shortcut.save();
+ boolean isFileDeleted = false;
+ try {
+ isFileDeleted = new File(f1).delete();
+ } catch (Exception e) {}
- new File(shortcut.getFileName()).delete();
+ try {
+ new File(f2).delete();
+ } catch (Exception e)
+ {
+ if(!isFileDeleted)
+ GeneralConfigPluginActivator.getUIService().
+ getPopupDialog().showMessagePopupDialog(
+ e.getMessage(),
+ Resources.getString("errorPermission"),
+ PopupDialog.ERROR_MESSAGE);
+ // cannot delete no permissions
+ }
}
-
} catch (Exception e)
{
logger.error("Cannot create/delete startup shortcut", e);
@@ -342,4 +364,35 @@ public class GeneralConfigurationForm
bringToFrontCheckBox.isSelected());
}
}
+
+
+ private void initAutoStartCheckBox()
+ {
+ try
+ {
+ String appName =
+ Resources.getApplicationString("applicationName");
+ 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())
+ autoStartCheckBox.setSelected(true);
+ else
+ autoStartCheckBox.setSelected(false);
+
+ } catch (Exception e)
+ {
+ logger.error(e);
+ }
+ }
}