[GTKUI] Fix quitting bypassing password lock
This commit is contained in:
parent
c5ad5589df
commit
176064b520
|
@ -176,31 +176,41 @@ class MainWindow(component.Component):
|
||||||
:param shutdown: whether or not to shutdown the daemon as well
|
:param shutdown: whether or not to shutdown the daemon as well
|
||||||
:type shutdown: boolean
|
:type shutdown: boolean
|
||||||
"""
|
"""
|
||||||
|
def quit_gtkui():
|
||||||
|
def shutdown_daemon(result):
|
||||||
|
return client.daemon.shutdown()
|
||||||
|
|
||||||
def shutdown_daemon(result):
|
def disconnect_client(result):
|
||||||
return client.daemon.shutdown()
|
return client.disconnect()
|
||||||
|
|
||||||
def disconnect_client(result):
|
def stop_reactor(result):
|
||||||
return client.disconnect()
|
try:
|
||||||
|
reactor.stop()
|
||||||
|
except ReactorNotRunning:
|
||||||
|
log.debug("Attempted to stop the reactor but it is not running...")
|
||||||
|
|
||||||
def stop_reactor(result):
|
def log_failure(failure, action):
|
||||||
try:
|
log.error("Encountered error attempting to %s: %s" % \
|
||||||
reactor.stop()
|
(action, failure.getErrorMessage()))
|
||||||
except ReactorNotRunning:
|
|
||||||
log.debug("Attempted to stop the reactor but it is not running...")
|
|
||||||
|
|
||||||
def log_failure(failure, action):
|
d = defer.succeed(None)
|
||||||
log.error("Encountered error attempting to %s: %s" % \
|
if shutdown:
|
||||||
(action, failure.getErrorMessage()))
|
d.addCallback(shutdown_daemon)
|
||||||
|
d.addErrback(log_failure, "shutdown daemon")
|
||||||
|
if not client.is_classicmode() and client.connected():
|
||||||
|
d.addCallback(disconnect_client)
|
||||||
|
d.addErrback(log_failure, "disconnect client")
|
||||||
|
d.addBoth(stop_reactor)
|
||||||
|
|
||||||
d = defer.succeed(None)
|
if self.config["tray_password"] and not self.visible():
|
||||||
if shutdown:
|
dialog = PasswordDialog("Enter your pasword to Quit Deluge...")
|
||||||
d.addCallback(shutdown_daemon)
|
def on_dialog_response(response_id):
|
||||||
d.addErrback(log_failure, "shutdown daemon")
|
if response_id == gtk.RESPONSE_OK:
|
||||||
if not client.is_classicmode() and client.connected():
|
if self.config["tray_password"] == sha(dialog.get_password()).hexdigest():
|
||||||
d.addCallback(disconnect_client)
|
quit_gtkui()
|
||||||
d.addErrback(log_failure, "disconnect client")
|
dialog.run().addCallback(on_dialog_response)
|
||||||
d.addBoth(stop_reactor)
|
else:
|
||||||
|
quit_gtkui()
|
||||||
|
|
||||||
def load_window_state(self):
|
def load_window_state(self):
|
||||||
x = self.config["window_x_pos"]
|
x = self.config["window_x_pos"]
|
||||||
|
|
|
@ -377,16 +377,10 @@ class SystemTray(component.Component):
|
||||||
|
|
||||||
def on_menuitem_quit_activate(self, menuitem):
|
def on_menuitem_quit_activate(self, menuitem):
|
||||||
log.debug("on_menuitem_quit_activate")
|
log.debug("on_menuitem_quit_activate")
|
||||||
if self.config["lock_tray"] and not self.window.visible():
|
|
||||||
self.window.present()
|
|
||||||
|
|
||||||
self.window.quit()
|
self.window.quit()
|
||||||
|
|
||||||
def on_menuitem_quitdaemon_activate(self, menuitem):
|
def on_menuitem_quitdaemon_activate(self, menuitem):
|
||||||
log.debug("on_menuitem_quitdaemon_activate")
|
log.debug("on_menuitem_quitdaemon_activate")
|
||||||
if self.config["lock_tray"] and not self.window.visible():
|
|
||||||
self.window.present()
|
|
||||||
|
|
||||||
self.window.quit(shutdown=True)
|
self.window.quit(shutdown=True)
|
||||||
|
|
||||||
def on_tray_setbwdown(self, widget, data=None):
|
def on_tray_setbwdown(self, widget, data=None):
|
||||||
|
|
Loading…
Reference in New Issue