use of com.biglybt.pif.platform.PlatformManagerException in project BiglyBT by BiglySoftware.
the class PlatformManagerImpl method getRunAtLogin.
@Override
public boolean getRunAtLogin() throws PlatformManagerException {
if (Constants.isOSX_10_8_OrHigher) {
String item_name = SystemProperties.getApplicationName();
try {
StringBuffer sb = new StringBuffer();
sb.append("tell application \"");
sb.append("System Events");
sb.append("\" to get the name of every login item");
String[] items = performOSAScript(sb).split(",");
for (String item : items) {
if (item.trim().equalsIgnoreCase(item_name)) {
return (true);
}
}
return (false);
} catch (Throwable e) {
throw new PlatformManagerException("Failed to get login items", e);
}
}
File f = getLoginPList();
if (!f.exists()) {
return (false);
}
File bundle_file = getAbsoluteBundleFile();
if (!bundle_file.exists()) {
return (false);
}
try {
convertToXML(f);
LineNumberReader lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
int state = 0;
String target = bundle_file.getAbsolutePath();
try {
while (true) {
String line = lnr.readLine();
if (line == null) {
break;
}
if (state == 0) {
if (containsTag(line, "AutoLaunchedApplicationDictionary")) {
state = 1;
}
} else {
if (line.contains(target)) {
return (true);
}
}
}
return (false);
} finally {
lnr.close();
}
} catch (Throwable e) {
throw (new PlatformManagerException("Failed to read input file", e));
}
}
Aggregations