Added onShutdown and onShutdownVeto to the Shutdownrequest Interface. They are called before the shutdown, or after a shutdown has been denied by a veto. Until now, this has only been possible by implementing an extra veto handler.

Added Some Headless Dialog handling stuff. Headless jds forward dialogs to the console, until myjd has launched



git-svn-id: svn://svn.jdownloader.org/jdownloader/trunk@29136 ebf7c1c2-ba36-0410-9fe8-c592906822b4

Former-commit-id: 1ba871749f650af11783ce5cd70e95f8bbae8b32
This commit is contained in:
coalado 2015-02-18 09:13:17 +00:00
parent db63e615e9
commit 1104cebbc2
16 changed files with 612 additions and 73 deletions

View File

@ -16,15 +16,15 @@ sp_cleanup.add_missing_override_annotations_interface_methods=true
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=true
sp_cleanup.always_use_this_for_non_static_method_access=true
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=true
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=true
sp_cleanup.make_parameters_final=true
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_private_fields_final=false
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=false
sp_cleanup.never_use_blocks=false
@ -54,6 +54,6 @@ sp_cleanup.use_blocks=true
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true

369
src/jd/Win32WindowDemo.java Normal file
View File

@ -0,0 +1,369 @@
/* Copyright (c) 2012 Tobias Wolf, All Rights Reserved
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package jd;
import com.sun.jna.WString;
import com.sun.jna.platform.win32.DBT;
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_DEVICEINTERFACE;
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_HANDLE;
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_HDR;
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_OEM;
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_PORT;
import com.sun.jna.platform.win32.DBT.DEV_BROADCAST_VOLUME;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinDef.HMODULE;
import com.sun.jna.platform.win32.WinDef.HWND;
import com.sun.jna.platform.win32.WinDef.LPARAM;
import com.sun.jna.platform.win32.WinDef.LRESULT;
import com.sun.jna.platform.win32.WinDef.WPARAM;
import com.sun.jna.platform.win32.WinUser;
import com.sun.jna.platform.win32.WinUser.HDEVNOTIFY;
import com.sun.jna.platform.win32.WinUser.MSG;
import com.sun.jna.platform.win32.WinUser.WNDCLASSEX;
import com.sun.jna.platform.win32.WinUser.WindowProc;
import com.sun.jna.platform.win32.Wtsapi32;
// TODO: Auto-generated Javadoc
/**
* The Class Win32WindowTest.
*/
public class Win32WindowDemo implements WindowProc {
/**
* Instantiates a new win32 window test.
*/
public Win32WindowDemo() {
// define new window class
WString windowClass = new WString("MyWindowClass");
HMODULE hInst = Kernel32.INSTANCE.GetModuleHandle("");
WNDCLASSEX wClass = new WNDCLASSEX();
wClass.hInstance = hInst;
wClass.lpfnWndProc = Win32WindowDemo.this;
wClass.lpszClassName = windowClass;
// register window class
User32.INSTANCE.RegisterClassEx(wClass);
getLastError();
// create new window
HWND hWnd = User32.INSTANCE.CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "My hidden helper window, used only to catch the windows events", 0, 0, 0, 0, 0, null, // WM_DEVICECHANGE
// contradicts
// parent=WinUser.HWND_MESSAGE
null, hInst, null);
getLastError();
System.out.println("window sucessfully created! window hwnd: " + hWnd.getPointer().toString());
Wtsapi32.INSTANCE.WTSRegisterSessionNotification(hWnd, Wtsapi32.NOTIFY_FOR_THIS_SESSION);
/* this filters for all device classes */
// DEV_BROADCAST_HDR notificationFilter = new DEV_BROADCAST_HDR();
// notificationFilter.dbch_devicetype = DBT.DBT_DEVTYP_DEVICEINTERFACE;
/* this filters for all usb device classes */
DEV_BROADCAST_DEVICEINTERFACE notificationFilter = new DEV_BROADCAST_DEVICEINTERFACE();
notificationFilter.dbcc_size = notificationFilter.size();
notificationFilter.dbcc_devicetype = DBT.DBT_DEVTYP_DEVICEINTERFACE;
notificationFilter.dbcc_classguid = DBT.GUID_DEVINTERFACE_USB_DEVICE;
/*
* use User32.DEVICE_NOTIFY_ALL_INTERFACE_CLASSES instead of DEVICE_NOTIFY_WINDOW_HANDLE to ignore the dbcc_classguid value
*/
HDEVNOTIFY hDevNotify = User32.INSTANCE.RegisterDeviceNotification(hWnd, notificationFilter, User32.DEVICE_NOTIFY_WINDOW_HANDLE);
getLastError();
if (hDevNotify != null) {
System.out.println("RegisterDeviceNotification was sucessfully!");
}
MSG msg = new MSG();
while (User32.INSTANCE.GetMessage(msg, hWnd, 0, 0) != 0) {
User32.INSTANCE.TranslateMessage(msg);
User32.INSTANCE.DispatchMessage(msg);
}
User32.INSTANCE.UnregisterDeviceNotification(hDevNotify);
Wtsapi32.INSTANCE.WTSUnRegisterSessionNotification(hWnd);
User32.INSTANCE.UnregisterClass(windowClass, hInst);
User32.INSTANCE.DestroyWindow(hWnd);
System.out.println("program exit!");
}
/*
* (non-Javadoc)
*
* @see com.sun.jna.platform.win32.User32.WindowProc#callback(com.sun.jna.platform .win32.WinDef.HWND, int,
* com.sun.jna.platform.win32.WinDef.WPARAM, com.sun.jna.platform.win32.WinDef.LPARAM)
*/
public LRESULT callback(HWND hwnd, int uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WinUser.WM_CREATE: {
onCreate(wParam, lParam);
return new LRESULT(0);
}
case WinUser.WM_DESTROY: {
User32.INSTANCE.PostQuitMessage(0);
return new LRESULT(0);
}
case WinUser.WM_SESSION_CHANGE: {
this.onSessionChange(wParam, lParam);
return new LRESULT(0);
}
case WinUser.WM_DEVICECHANGE: {
LRESULT lResult = this.onDeviceChange(wParam, lParam);
return lResult != null ? lResult : User32.INSTANCE.DefWindowProc(hwnd, uMsg, wParam, lParam);
}
default:
return User32.INSTANCE.DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}
/**
* Gets the last error.
*
* @return the last error
*/
public int getLastError() {
int rc = Kernel32.INSTANCE.GetLastError();
if (rc != 0) {
System.out.println("error: " + rc);
}
return rc;
}
/**
* On session change.
*
* @param wParam
* the w param
* @param lParam
* the l param
*/
protected void onSessionChange(WPARAM wParam, LPARAM lParam) {
switch (wParam.intValue()) {
case Wtsapi32.WTS_CONSOLE_CONNECT: {
this.onConsoleConnect(lParam.intValue());
break;
}
case Wtsapi32.WTS_CONSOLE_DISCONNECT: {
this.onConsoleDisconnect(lParam.intValue());
break;
}
case Wtsapi32.WTS_SESSION_LOGON: {
this.onMachineLogon(lParam.intValue());
break;
}
case Wtsapi32.WTS_SESSION_LOGOFF: {
this.onMachineLogoff(lParam.intValue());
break;
}
case Wtsapi32.WTS_SESSION_LOCK: {
this.onMachineLocked(lParam.intValue());
break;
}
case Wtsapi32.WTS_SESSION_UNLOCK: {
this.onMachineUnlocked(lParam.intValue());
break;
}
}
}
/**
* On console connect.
*
* @param sessionId
* the session id
*/
protected void onConsoleConnect(int sessionId) {
System.out.println("onConsoleConnect: " + sessionId);
}
/**
* On console disconnect.
*
* @param sessionId
* the session id
*/
protected void onConsoleDisconnect(int sessionId) {
System.out.println("onConsoleDisconnect: " + sessionId);
}
/**
* On machine locked.
*
* @param sessionId
* the session id
*/
protected void onMachineLocked(int sessionId) {
System.out.println("onMachineLocked: " + sessionId);
}
/**
* On machine unlocked.
*
* @param sessionId
* the session id
*/
protected void onMachineUnlocked(int sessionId) {
System.out.println("onMachineUnlocked: " + sessionId);
}
/**
* On machine logon.
*
* @param sessionId
* the session id
*/
protected void onMachineLogon(int sessionId) {
System.out.println("onMachineLogon: " + sessionId);
}
/**
* On machine logoff.
*
* @param sessionId
* the session id
*/
protected void onMachineLogoff(int sessionId) {
System.out.println("onMachineLogoff: " + sessionId);
}
/**
* On device change.
*
* @param wParam
* the w param
* @param lParam
* the l param
* @return the result. Null if the message is not processed.
*/
protected LRESULT onDeviceChange(WPARAM wParam, LPARAM lParam) {
switch (wParam.intValue()) {
case DBT.DBT_DEVICEARRIVAL: {
return onDeviceChangeArrival(lParam);
}
case DBT.DBT_DEVICEREMOVECOMPLETE: {
return onDeviceChangeRemoveComplete(lParam);
}
case DBT.DBT_DEVNODES_CHANGED: {
// lParam is 0 for this wParam
return onDeviceChangeNodesChanged();
}
default:
System.out.println("Message WM_DEVICECHANGE message received, value unhandled.");
}
return null;
}
protected LRESULT onDeviceChangeArrivalOrRemoveComplete(LPARAM lParam, String action) {
DEV_BROADCAST_HDR bhdr = new DEV_BROADCAST_HDR(lParam.longValue());
switch (bhdr.dbch_devicetype) {
case DBT.DBT_DEVTYP_DEVICEINTERFACE: {
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363244.aspx
DEV_BROADCAST_DEVICEINTERFACE bdif = new DEV_BROADCAST_DEVICEINTERFACE(bhdr.getPointer());
System.out.println("BROADCAST_DEVICEINTERFACE: " + action);
System.out.println("dbcc_devicetype: " + bdif.dbcc_devicetype);
System.out.println("dbcc_name: " + bdif.getDbcc_name());
System.out.println("dbcc_classguid: " + bdif.dbcc_classguid.toGuidString());
break;
}
case DBT.DBT_DEVTYP_HANDLE: {
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363245.aspx
DEV_BROADCAST_HANDLE bhd = new DEV_BROADCAST_HANDLE(bhdr.getPointer());
System.out.println("BROADCAST_HANDLE: " + action);
break;
}
case DBT.DBT_DEVTYP_OEM: {
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363247.aspx
DEV_BROADCAST_OEM boem = new DEV_BROADCAST_OEM(bhdr.getPointer());
System.out.println("BROADCAST_OEM: " + action);
break;
}
case DBT.DBT_DEVTYP_PORT: {
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363248.aspx
DEV_BROADCAST_PORT bpt = new DEV_BROADCAST_PORT(bhdr.getPointer());
System.out.println("BROADCAST_PORT: " + action);
break;
}
case DBT.DBT_DEVTYP_VOLUME: {
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363249.aspx
DEV_BROADCAST_VOLUME bvl = new DEV_BROADCAST_VOLUME(bhdr.getPointer());
int logicalDriveAffected = bvl.dbcv_unitmask;
short flag = bvl.dbcv_flags;
boolean isMediaNotPhysical = 0 != (flag & DBT.DBTF_MEDIA/* value is 1 */);
boolean isNet = 0 != (flag & DBT.DBTF_NET/* value is 2 */);
System.out.println(action);
int driveLetterIndex = 0;
while (logicalDriveAffected != 0) {
if (0 != (logicalDriveAffected & 1)) {
System.out.println("Logical Drive Letter: " + ((char) ('A' + driveLetterIndex)));
}
logicalDriveAffected >>>= 1;
driveLetterIndex++;
}
System.out.println("isMediaNotPhysical:" + isMediaNotPhysical);
System.out.println("isNet:" + isNet);
break;
}
default:
return null;
}
// return TRUE means processed message for this wParam.
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363205.aspx
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363208.aspx
return new LRESULT(1);
}
protected LRESULT onDeviceChangeArrival(LPARAM lParam) {
return onDeviceChangeArrivalOrRemoveComplete(lParam, "Arrival");
}
protected LRESULT onDeviceChangeRemoveComplete(LPARAM lParam) {
return onDeviceChangeArrivalOrRemoveComplete(lParam, "Remove Complete");
}
protected LRESULT onDeviceChangeNodesChanged() {
System.out.println("Message DBT_DEVNODES_CHANGED");
// return TRUE means processed message for this wParam.
// see http://msdn.microsoft.com/en-us/library/windows/desktop/aa363211.aspx
return new LRESULT(1);
}
/**
* On create.
*
* @param wParam
* the w param
* @param lParam
* the l param
*/
protected void onCreate(WPARAM wParam, LPARAM lParam) {
System.out.println("onCreate: WM_CREATE");
}
/**
* The main method.
*
* @param args
* the arguments
*/
public static void main(String[] args) {
new Win32WindowDemo();
}
}

View File

@ -15,7 +15,13 @@ public class UpdateAPIImpl implements UpdateAPI {
@Override
public boolean isUpdateAvailable() {
return UpdateController.getInstance().hasPendingUpdates();
}
@Override
public void runUpdateCheck() {
UpdateController.getInstance().runUpdateChecker(true);
}
}

View File

@ -555,6 +555,7 @@ public class MyJDownloaderConnectThread extends Thread {
if (connected.getAndSet(set) == set) {
return;
}
System.out.println(" set " + set);
StatsManager.I().track(1000, "myjd/connection/" + set);
myJDownloaderController.fireConnectionStatusChanged(set, getEstablishedConnections());
}

View File

@ -7,5 +7,7 @@ import org.appwork.remoteapi.annotations.ApiNamespace;
public interface UpdateAPI extends RemoteAPIInterface {
public void restartAndUpdate();
public void runUpdateCheck();
public boolean isUpdateAvailable();
}

View File

@ -409,6 +409,7 @@ public class TranslatorExtension extends AbstractExtension<TranslatorConfig, Tra
load(tmp, locale, ExtTableTranslation.class);
load(tmp, locale, LogSenderTranslation.class);
load(tmp, locale, GuiTranslation.class);
LanguageFileSetup guiInterface = TranslationFactory.create(LanguageFileSetup.class);
fontname = guiInterface.config_fontname();

View File

@ -1111,46 +1111,62 @@ public class StatsManager implements GenericConfigEventListener<Object>, Downloa
* @param reducer
* @param path
*/
public void track(int reducer, String path2) {
public void track(final int reducer, String path2) {
if (reducer > 1) {
path2 += "_in" + reducer;
synchronized (reducerRandomMap) {
Integer randomValue = reducerRandomMap.get(path2 + "_" + reducer);
if (randomValue == null) {
Random random = new Random(System.currentTimeMillis());
randomValue = random.nextInt(reducer);
reducerRandomMap.put(path2 + "_" + reducer, randomValue.intValue());
try {
IO.secureWrite(reducerFile, JSonStorage.serializeToJson(reducerRandomMap).getBytes("UTF-8"));
} catch (Throwable e) {
logger.log(e);
}
Integer randomValue = reducerRandomMap.get(path2);
if (randomValue != null) {
}
if (randomValue.intValue() != 0) {
return;
if (randomValue.intValue() != 0) {
return;
}
}
}
path2 += "_in" + reducer;
}
final String path = path2;
final HashMap<String, String> cvar = new HashMap<String, String>();
try {
cvar.put("_id", System.getProperty(new String(new byte[] { (byte) 117, (byte) 105, (byte) 100 }, new String(new byte[] { 85, 84, 70, 45, 56 }, "UTF-8"))));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
cvar.put("source", "jd2");
cvar.put("os", CrossSystem.getOS().name());
log(new AbstractTrackEntry() {
@Override
public void send(Browser br) {
try {
if (reducer > 1) {
synchronized (reducerRandomMap) {
Integer randomValue = reducerRandomMap.get(path);
if (randomValue == null) {
Random random = new Random(System.currentTimeMillis());
randomValue = random.nextInt(reducer);
reducerRandomMap.put(path, randomValue.intValue());
try {
IO.secureWrite(reducerFile, JSonStorage.serializeToJson(reducerRandomMap).getBytes("UTF-8"));
} catch (Throwable e) {
logger.log(e);
}
}
if (randomValue.intValue() != 0) {
return;
}
}
}
final HashMap<String, String> cvar = new HashMap<String, String>();
try {
cvar.put("_id", System.getProperty(new String(new byte[] { (byte) 117, (byte) 105, (byte) 100 }, new String(new byte[] { 85, 84, 70, 45, 56 }, "UTF-8"))));
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
cvar.put("source", "jd2");
cvar.put("os", CrossSystem.getOS().name());
URLConnectionAdapter con = new Browser().openGetConnection("http://stats.appwork.org/jcgi/event/track?" + Encoding.urlEncode(path) + "&" + Encoding.urlEncode(JSonStorage.serializeToJson(cvar)));
con.disconnect();
} catch (Throwable e) {

View File

@ -954,4 +954,7 @@ public interface JdownloaderTranslation extends TranslateInterface {
@Default(lngs = { "en" }, values = { "Hidden (Usermode)" })
String DonateButtonState_CUSTOM_HIDDEN();
@Default(lngs = { "en", "de" }, values = { "Updates are ready for Installation. Do you want to run the update now?" })
String update_dialog_msg_x_updates_available();
}

View File

@ -18,7 +18,7 @@ public class BasicRestartRequest extends BasicShutdownRequest implements Restart
}
@Override
public String[] getArguments() {
public String[] getArguments() throws NoRestartException {
return arguments;
}

View File

@ -0,0 +1,88 @@
package org.jdownloader.updatev2;
import java.util.List;
import org.appwork.shutdown.ShutdownRequest;
import org.appwork.shutdown.ShutdownVetoException;
import org.appwork.shutdown.ShutdownVetoListener;
import org.appwork.storage.config.JsonConfig;
import org.appwork.uio.ConfirmDialogInterface;
import org.appwork.uio.UIOManager;
import org.appwork.utils.swing.dialog.ConfirmDialog;
import org.appwork.utils.swing.dialog.DialogNoAnswerException;
public class InstallUpdatesOnExitRestartRequest implements RestartRequest {
private ShutdownRequest shutdownRequest;
private boolean runUpdates = true;
public InstallUpdatesOnExitRestartRequest(ShutdownRequest filter) {
this.shutdownRequest = filter;
}
@Override
public boolean askForVeto(ShutdownVetoListener listener) {
boolean ret = shutdownRequest.askForVeto(listener);
return ret;
}
@Override
public void addVeto(ShutdownVetoException e) {
shutdownRequest.addVeto(e);
}
@Override
public boolean isSilent() {
return shutdownRequest.isSilent();
}
@Override
public List<ShutdownVetoException> getVetos() {
return shutdownRequest.getVetos();
}
@Override
public boolean hasVetos() {
return shutdownRequest.hasVetos();
}
@Override
public void onShutdown() {
// ask
this.runUpdates = true;
if (JsonConfig.create(UpdateSettings.class).isAskMyBeforeInstallingAnUpdateEnabled()) {
// DialogHook.showConfirmDialog(0, _UPDATE._.confirmdialog_new_update_available_frametitle(),
// _UPDATE._.confirmdialog_new_update_available_for_install_message_launcher(), null,
// _UPDATE._.confirmdialog_new_update_available_answer_now_install(),
// _UPDATE._.confirmdialog_new_update_available_answer_later_install());
ConfirmDialog dialog = new ConfirmDialog(UIOManager.LOGIC_COUNTDOWN, _UPDATE._.confirmdialog_new_update_available_frametitle(), _UPDATE._.confirmdialog_new_update_available_for_install_message_launcher(), null, _UPDATE._.confirmdialog_new_update_available_answer_now_install(), _UPDATE._.confirmdialog_new_update_available_answer_later_install());
try {
UIOManager.I().show(ConfirmDialogInterface.class, dialog).throwCloseExceptions();
} catch (DialogNoAnswerException e) {
runUpdates = false;
} catch (Throwable e) {
}
}
}
@Override
public String[] getArguments() throws NoRestartException {
if (!runUpdates) {
throw new NoRestartException();
} else {
return new String[] { "-updateOnExit" };
}
}
@Override
public void onShutdownVeto() {
}
}

View File

@ -0,0 +1,5 @@
package org.jdownloader.updatev2;
public class NoRestartException extends Exception {
}

View File

@ -15,6 +15,7 @@ import org.appwork.shutdown.ShutdownEvent;
import org.appwork.shutdown.ShutdownRequest;
import org.appwork.shutdown.ShutdownVetoException;
import org.appwork.shutdown.ShutdownVetoListener;
import org.appwork.storage.config.JsonConfig;
import org.appwork.uio.UIOManager;
import org.appwork.utils.Application;
import org.appwork.utils.logging2.LogSource;
@ -65,7 +66,9 @@ public class RestartController implements ShutdownVetoListener {
public void setRoot(File root) {
if (root == null) root = Application.getTemp().getParentFile();
if (root == null) {
root = Application.getTemp().getParentFile();
}
log("Set Root: " + root.getAbsolutePath());
this.root = root;
@ -88,7 +91,12 @@ public class RestartController implements ShutdownVetoListener {
@Override
public void onShutdown(final ShutdownRequest shutdownRequest) {
if (shutdownRequest instanceof RestartRequest) {
restarter.restart(getRoot(), getFilteredRestartParameters(((RestartRequest) shutdownRequest).getArguments()));
try {
String[] arguments = ((RestartRequest) shutdownRequest).getArguments();
restarter.restart(getRoot(), getFilteredRestartParameters(arguments));
} catch (NoRestartException e) {
// ok no restart required
}
}
}
@ -104,9 +112,13 @@ public class RestartController implements ShutdownVetoListener {
ArrayList<String> ret = new ArrayList<String>();
if (startupParameters != null) {
for (Entry<String, CommandSwitch> es : startupParameters.getMap().entrySet()) {
if (IGNORE_COMMAND_SWITCHES.contains(es.getKey() == null ? null : es.getKey().toLowerCase(Locale.ENGLISH))) continue;
if (IGNORE_COMMAND_SWITCHES.contains(es.getKey() == null ? null : es.getKey().toLowerCase(Locale.ENGLISH))) {
continue;
}
if (es.getKey() != null) ret.add("-" + es.getKey());
if (es.getKey() != null) {
ret.add("-" + es.getKey());
}
for (String p : es.getValue().getParameters()) {
ret.add(p);
}
@ -114,7 +126,9 @@ public class RestartController implements ShutdownVetoListener {
}
if (arguments != null) {
for (String s : arguments) {
if (s != null) ret.add(s);
if (s != null) {
ret.add(s);
}
}
}
@ -148,9 +162,24 @@ public class RestartController implements ShutdownVetoListener {
}
public void exitAsynch(final ShutdownRequest filter) {
if (filter == null) throw new NullPointerException();
if (filter == null) {
throw new NullPointerException();
}
if (!Application.isHeadless()) {
UpdateSettings cfg = JsonConfig.create(UpdateSettings.class);
if (filter.getClass() == SmartRlyExitRequest.class && cfg.isInstallUpdatesOnExitEnabled()) {
if (UpdateController.getInstance().hasPendingUpdates()) {
asyncRestart(new InstallUpdatesOnExitRestartRequest(filter));
return;
}
}
}
new Thread("ExitAsynch") {
public void run() {
ShutdownController.getInstance().requestShutdown(filter);
}
}.start();
@ -158,7 +187,9 @@ public class RestartController implements ShutdownVetoListener {
public synchronized ParameterParser getParameterParser(String[] args) {
if (startupParameters == null) {
if (args == null) throw new IllegalStateException();
if (args == null) {
throw new IllegalStateException();
}
startupParameters = new ParameterParser(args);
}
if (args != null) {
@ -169,8 +200,12 @@ public class RestartController implements ShutdownVetoListener {
@Override
public void onShutdownVetoRequest(ShutdownRequest shutdownVetoExceptions) throws ShutdownVetoException {
if (shutdownVetoExceptions.hasVetos()) { return; }
if (shutdownVetoExceptions.isSilent()) return;
if (shutdownVetoExceptions.hasVetos()) {
return;
}
if (shutdownVetoExceptions.isSilent()) {
return;
}
try {
if (shutdownVetoExceptions instanceof RestartRequest) {

View File

@ -4,5 +4,5 @@ import org.appwork.shutdown.ShutdownRequest;
public interface RestartRequest extends ShutdownRequest {
abstract public String[] getArguments();
abstract public String[] getArguments() throws NoRestartException;
}

View File

@ -24,6 +24,7 @@ import jd.gui.swing.jdgui.components.IconedProcessIndicator;
import org.appwork.storage.JSonStorage;
import org.appwork.storage.config.ConfigInterface;
import org.appwork.storage.config.JsonConfig;
import org.appwork.uio.ConfirmDialogInterface;
import org.appwork.uio.UIOManager;
import org.appwork.utils.Application;
import org.appwork.utils.IO;
@ -35,7 +36,6 @@ import org.appwork.utils.os.CrossSystem;
import org.appwork.utils.processes.ProcessBuilderFactory;
import org.appwork.utils.swing.EDTHelper;
import org.appwork.utils.swing.EDTRunner;
import org.appwork.utils.swing.dialog.Dialog;
import org.appwork.utils.swing.dialog.DialogCanceledException;
import org.appwork.utils.swing.dialog.DialogClosedException;
import org.appwork.utils.swing.dialog.DialogNoAnswerException;
@ -108,6 +108,7 @@ public class UpdateController implements UpdateCallbackInterface {
this.updaterid = updaterid;
hasPendingUpdates = handler.hasPendingUpdates();
handler.startIntervalChecker();
try {
jd.SecondLevelLaunch.UPDATE_HANDLER_SET.setReached();
} catch (Throwable e) {
@ -375,7 +376,7 @@ public class UpdateController implements UpdateCallbackInterface {
if (handler.hasPendingSelfupdate()) {
fireUpdatesAvailable(false, handler.createAWFInstallLog());
if (!isThreadConfirmed()) {
if (!handler.isGuiVisible() && settings.isDoNotAskJustInstallOnNextStartupEnabled()) {
if (!handler.isGuiVisible() && !settings.isAskMyBeforeInstallingAnUpdateEnabled()) {
return;
}
logger.info("ASK for installing selfupdate");
@ -417,7 +418,7 @@ public class UpdateController implements UpdateCallbackInterface {
if (awfoverview.getModifiedRestartRequiredFiles().size() == 0) {
logger.info("Only directs");
// can install direct
if (!settings.isDoNotAskToInstallPlugins()) {
if (!settings.isInstallUpdatesSilentlyIfPossibleEnabled()) {
logger.info("ask to install plugins");
confirm(UIOManager.LOGIC_COUNTDOWN, _UPDATE._.confirmdialog_new_update_available_frametitle(), _UPDATE._.confirmdialog_new_update_available_for_install_message_plugin(), _UPDATE._.confirmdialog_new_update_available_answer_now_install(), _UPDATE._.confirmdialog_new_update_available_answer_later_install());
@ -450,7 +451,7 @@ public class UpdateController implements UpdateCallbackInterface {
fireUpdatesAvailable(false, null);
} else {
if (!handler.isGuiVisible() && settings.isDoNotAskJustInstallOnNextStartupEnabled()) {
if (!handler.isGuiVisible() && settings.isAskMyBeforeInstallingAnUpdateEnabled()) {
return;
}
List<String> rInstalls = handler.getRequestedInstalls();
@ -505,7 +506,7 @@ public class UpdateController implements UpdateCallbackInterface {
};
Dialog.getInstance().showDialog(cd);
UIOManager.I().show(ConfirmDialogInterface.class, cd).throwCloseExceptions();
if (cd.isClosedBySkipUntilNextRestart()) {
if (lhandler != null) {
lhandler.stopIntervalChecker();

View File

@ -11,18 +11,18 @@ public interface UpdateSettings extends ConfigInterface {
@AboutConfig
@DefaultBooleanValue(true)
@DescriptionForConfigEntry("If enabled, JDownloader will update all plugins silently in the background without restarting")
boolean isDoNotAskToInstallPlugins();
boolean isInstallUpdatesSilentlyIfPossibleEnabled();
void setDoNotAskToInstallPlugins(boolean b);
void setInstallUpdatesSilentlyIfPossibleEnabled(boolean b);
@AboutConfig
@DefaultBooleanValue(true)
@DefaultBooleanValue(false)
@DescriptionForConfigEntry("If enabled, JD will install Updates silently during the next JDStart")
boolean isDoNotAskJustInstallOnNextStartupEnabled();
boolean isAskMyBeforeInstallingAnUpdateEnabled();
void setDoNotAskJustInstallOnNextStartupEnabled(boolean b);
void setAskMyBeforeInstallingAnUpdateEnabled(boolean b);
@AboutConfig
// @AboutConfig
@DefaultBooleanValue(true)
@DescriptionForConfigEntry("Jar diffs speed up the update process because it reduces the update package size a lot. Do NOT disable this without a very good reason")
boolean isJarDiffEnabled();
@ -52,27 +52,6 @@ public interface UpdateSettings extends ConfigInterface {
void setUpdateGuiAlwaysOnTop(boolean b);
@DefaultBooleanValue(true)
@AboutConfig
@DescriptionForConfigEntry("If enabled, The Updater will install updates without asking if the JDownloader core could not start.")
boolean isDoNotAskToInstallEmergencyUpdates();
void setDoNotAskToInstallEmergencyUpdates(boolean b);
@DefaultBooleanValue(true)
@AboutConfig
@DescriptionForConfigEntry("If enabled, The Updater will download updates without asking if the JDownloader core could not start.")
boolean isDoNotAskToDownloadEmergencyUpdates();
void setDoNotAskToDownloadEmergencyUpdates(boolean b);
@DefaultBooleanValue(true)
@AboutConfig
@DescriptionForConfigEntry("If enabled, Updates will be installed before JDownloader Core starts without asking.")
boolean isDoNotAskToInstallUpdatesOnStartup();
void setDoNotAskToInstallUpdatesOnStartup(boolean b);
@DefaultBooleanValue(false)
@AboutConfig
@DescriptionForConfigEntry("If enabled, JDownloader will ask before starting to download Updates.")
@ -113,4 +92,19 @@ public interface UpdateSettings extends ConfigInterface {
long getLastST();
void setLastST(long currentTimeMillis);
@DefaultBooleanValue(true)
@AboutConfig
@DescriptionForConfigEntry("Try to install updates when you exit JDownloader")
boolean isInstallUpdatesOnExitEnabled();
void setInstallUpdatesOnExitEnabled(boolean b);
@DefaultBooleanValue(false)
@AboutConfig
@DescriptionForConfigEntry("Show the tray panel when installing updates on exit")
boolean isInstallUpdatesOnExitPanelVisibleDev();
void setInstallUpdatesOnExitPanelVisibleDev(boolean b);
}

View File

@ -218,4 +218,22 @@ public interface UpdaterTranslation extends TranslateInterface {
@Default(lngs = { "en" }, values = { "Do you really want to restart JDownloader?" })
String RestartController_confirmTorestart_msg();
@Default(lngs = { "en" }, values = { "Installing Update..." })
String installonexitframe_start();
@Default(lngs = { "en" }, values = { "JDownloader Update" })
String installonexitframe_title();
@Default(lngs = { "en" }, values = { "JDownloader Update" })
String installonexitframe_tray_tt();
@Default(lngs = { "en" }, values = { "Cancel the update" })
String installonexitframe_cancel();
@Default(lngs = { "en" }, values = { "Hide the panel" })
String installonexitframe_hide();
@Default(lngs = { "en" }, values = { "Panel visible" })
String installonexitframe_panel_visible();
}