prefs, especially encryption, redone by andar

This commit is contained in:
Marcos Pinto 2007-06-06 22:26:52 +00:00
parent dfa10203bb
commit 9f5b05b4d3
5 changed files with 667 additions and 952 deletions

File diff suppressed because it is too large Load Diff

View File

@ -106,3 +106,10 @@ def open_url_in_browser(dialog, link):
webbrowser.open(link)
except webbrowser.Error:
print _("Error: no webbrowser found")
# Encryption States
class EncState:
enabled, disabled, forced = range(3)
class EncLevel:
plaintext, both, rc4 = range(3)

View File

@ -750,7 +750,6 @@ class Manager:
def create_torrent(self, filename, source_directory, trackers, comments=None,
pieces=256, author="Deluge"):
return deluge_core.create_torrent(filename, source_directory, trackers, comments, pieces, author)
def pe_settings(self, out_enc_policy, in_enc_policy, allowed_enc_level, prefer_rc4):

View File

@ -38,43 +38,9 @@ class PreferencesDlg:
def show(self):
# Load settings into dialog
try:
if(self.preferences.get("encin_disabled") == "True"):
self.glade.get_widget("chk_encin_disabled").set_active(True)
self.glade.get_widget("chk_encin_enabled").set_active(False)
self.glade.get_widget("chk_encin_forced").set_active(False)
elif(self.preferences.get("encin_enabled") == "True"):
self.glade.get_widget("chk_encin_enabled").set_active(True)
self.glade.get_widget("chk_encin_disabled").set_active(False)
self.glade.get_widget("chk_encin_forced").set_active(False)
elif(self.preferences.get("encin_forced") == "True"):
self.glade.get_widget("chk_encin_forced").set_active(True)
self.glade.get_widget("chk_encin_enabled").set_active(False)
self.glade.get_widget("chk_encin_disabled").set_active(False)
if(self.preferences.get("encout_disabled") == "True"):
self.glade.get_widget("chk_encout_disabled").set_active(True)
self.glade.get_widget("chk_encout_enabled").set_active(False)
self.glade.get_widget("chk_encout_forced").set_active(False)
elif(self.preferences.get("encout_enabled") == "True"):
self.glade.get_widget("chk_encout_enabled").set_active(True)
self.glade.get_widget("chk_encout_disabled").set_active(False)
self.glade.get_widget("chk_encout_forced").set_active(False)
elif(self.preferences.get("encout_forced") == "True"):
self.glade.get_widget("chk_encout_forced").set_active(True)
self.glade.get_widget("chk_encout_enabled").set_active(False)
self.glade.get_widget("chk_encout_disabled").set_active(False)
if(self.preferences.get("level_plaintext") == "True"):
self.glade.get_widget("chk_level_plaintext").set_active(True)
self.glade.get_widget("chk_level_rc4").set_active(False)
self.glade.get_widget("chk_level_both").set_active(False)
elif(self.preferences.get("level_both") == "True"):
self.glade.get_widget("chk_level_both").set_active(True)
self.glade.get_widget("chk_level_plaintext").set_active(False)
self.glade.get_widget("chk_level_rc4").set_active(False)
elif(self.preferences.get("level_rc4") == "True"):
self.glade.get_widget("chk_level_rc4").set_active(True)
self.glade.get_widget("chk_level_both").set_active(False)
self.glade.get_widget("chk_level_plaintext").set_active(False)
self.glade.get_widget("combo_encin").set_active(self.preferences.get("encin_state", int, default=common.EncState.enabled))
self.glade.get_widget("combo_encout").set_active(self.preferences.get("encout_state", int, default=common.EncState.enabled))
self.glade.get_widget("combo_enclevel").set_active(self.preferences.get("enclevel_type", int, default=common.EncLevel.both))
self.glade.get_widget("chk_pref_rc4").set_active(self.preferences.get("pref_rc4", bool, default=True))
self.glade.get_widget("chk_use_tray").set_active(self.preferences.get("enable_system_tray", bool, default=True))
self.glade.get_widget("chk_min_on_close").set_active(self.preferences.get("close_to_tray", bool, default=False))
@ -84,6 +50,7 @@ class PreferencesDlg:
self.glade.get_widget("radio_save_all_to").set_active(True)
else:
self.glade.get_widget("radio_ask_save").set_active(True)
self.glade.get_widget("download_path_button").set_filename(self.preferences.get("default_download_path", str, default=os.path.expandvars('$HOME')))
self.glade.get_widget("chk_compact").set_active(self.preferences.get("use_compact_storage", bool, default=False))
self.glade.get_widget("active_port_label").set_text(str(self.parent.manager.get_state()['port']))
@ -106,15 +73,9 @@ class PreferencesDlg:
self.dialog.hide()
# Now, get the settings from the dialog
if r == 1:
self.preferences.set("encin_disabled", self.glade.get_widget("chk_encin_disabled").get_active())
self.preferences.set("encin_enabled", self.glade.get_widget("chk_encin_enabled").get_active())
self.preferences.set("encin_forced", self.glade.get_widget("chk_encin_forced").get_active())
self.preferences.set("encout_disabled", self.glade.get_widget("chk_encout_disabled").get_active())
self.preferences.set("encout_enabled", self.glade.get_widget("chk_encout_enabled").get_active())
self.preferences.set("encout_forced", self.glade.get_widget("chk_encout_forced").get_active())
self.preferences.set("level_plaintext", self.glade.get_widget("chk_level_plaintext").get_active())
self.preferences.set("level_rc4", self.glade.get_widget("chk_level_rc4").get_active())
self.preferences.set("level_both", self.glade.get_widget("chk_level_both").get_active())
self.preferences.set("encin_state", self.glade.get_widget("combo_encin").get_active())
self.preferences.set("encout_state", self.glade.get_widget("combo_encout").get_active())
self.preferences.set("encout_level", self.glade.get_widget("combo_enclevel").get_active())
self.preferences.set("pref_rc4", self.glade.get_widget("chk_pref_rc4").get_active())
self.preferences.set("system_tray", self.glade.get_widget("chk_use_tray").get_active())
self.preferences.set("close_to_tray", self.glade.get_widget("chk_min_on_close").get_active())

View File

@ -30,15 +30,9 @@ import xdg, xdg.BaseDirectory
import gettext, locale
DEFAULT_PREFS = {
"encin_disable" : False,
"encin_enable" : True,
"encin_force" : False,
"encout_disable" : False,
"encout_enable" : True,
"encout_force" : False,
"level_plaintext" : False,
"level_both" : True,
"level_rc4" : False,
"encin_state" : common.EncState.enabled,
"encout_state" : common.EncState.enabled,
"enclevel_type" : common.EncLevel.both,
"pref_rc4" : True,
"auto_end_seeding" : False,
"close_to_tray" : False,
@ -158,29 +152,7 @@ class DelugeGTK:
pass
self.apply_prefs()
self.load_window_geometry()
if(self.config.get("encout_disabled", str, default="False") == "True"):
out_policy = "0"
elif(self.config.get("encout_enabled", str, default="True")):
out_policy = "1"
elif(self.config.get("encout_forced", str, default="False") == "True"):
out_policy = "2"
if(self.config.get("encin_disabled", str, default="False") == "True"):
in_policy = "0"
elif(self.config.get("encin_enabled", str, default="True") == "True"):
in_policy = "1"
elif(self.config.get("encin_forced", str, default="False") == "True"):
in_policy = "2"
if(self.config.get("level_plaintext", str, default="False") == "True"):
level_policy = "0"
elif(self.config.get("level_both", str, default="True") == "True"):
level_policy = "1"
elif(self.config.get("level_rc4", str, default="False") == "True"):
level_policy = "2"
if(self.config.get("pref_rc4", str, default="True") == "True"):
prefrc4 = "1"
elif(self.config.get("pref_rc4", str, default="True") == "False"):
prefrc4 = "0"
self.manager.pe_settings(out_policy, in_policy, level_policy, prefrc4)
self.manager.pe_settings(self.config.get("encout_state", int, default=common.EncState.enabled), self.config.get("encin_state", int, default=common.EncState.enabled), self.config.get("enclevel_type", int, default=common.EncLevel.both), self.config.get("pref_rc4", bool, default=True))
def external_add_torrent(self, torrent_file):
print "Ding!"