def _load_settings(self): """Load global and core settings files. Deals with old format for storing settings""" #load a global config that said whether to store the last user that logged in (and his password) self.globalSettings = GlobalSettings.load() #always save, so the user can more easily edit the file for starting up from the console self.globalSettings.save() #does a settings file already exist? settingsFile = os.path.join(Globals.USER_DATA_DIR, CoreSettings.CoreSettings.defaultFile) if not Files.file_exists(settingsFile): #if not, make the folder if not Files.file_exists(Globals.USER_DATA_DIR): os.makedirs(Globals.USER_DATA_DIR) #and check that this isnt an old installation (we used to store settings on a #per username basis, which turned out to be a stupid idea). If that data exists, #copy it to the new location. if len(self.globalSettings.username) > 0: oldSettingsFilePath = os.path.join(Globals.USER_DATA_DIR, self.globalSettings.username, CoreSettings.CoreSettings.defaultFile) if os.path.exists(oldSettingsFilePath): oldFolder = os.path.join(Globals.USER_DATA_DIR, self.globalSettings.username) newFolder = Globals.USER_DATA_DIR Files.recursive_copy_folder(oldFolder, newFolder) #load the core settings: CoreSettings.start() self.coreSettings = CoreSettings.get() self.coreSettings.load(settingsFile) self.coreSettings.fileName = settingsFile
def _load_settings(self): """Load global and core settings files. Deals with old format for storing settings""" #load a global config that said whether to store the last user that logged in (and his password) self.globalSettings = GlobalSettings.load() #always save, so the user can more easily edit the file for starting up from the console self.globalSettings.save() #does a settings file already exist? settingsFile = os.path.join(Globals.USER_DATA_DIR, CoreSettings.CoreSettings.defaultFile) if not Files.file_exists(settingsFile): #if not, make the folder if not Files.file_exists(Globals.USER_DATA_DIR): os.makedirs(Globals.USER_DATA_DIR) #and check that this isnt an old installation (we used to store settings on a #per username basis, which turned out to be a stupid idea). If that data exists, #copy it to the new location. if len(self.globalSettings.username) > 0: oldSettingsFilePath = os.path.join( Globals.USER_DATA_DIR, self.globalSettings.username, CoreSettings.CoreSettings.defaultFile) if os.path.exists(oldSettingsFilePath): oldFolder = os.path.join(Globals.USER_DATA_DIR, self.globalSettings.username) newFolder = Globals.USER_DATA_DIR Files.recursive_copy_folder(oldFolder, newFolder) #load the core settings: CoreSettings.start() self.coreSettings = CoreSettings.get() self.coreSettings.load(settingsFile) self.coreSettings.fileName = settingsFile
def on_response(self, dialog, response_id): CoreSettings.get().askAboutRelay = self.askAboutRelay.get_active() CoreSettings.get().save() if (response_id == gtk.RESPONSE_YES): if not Tor.get().settings.beRelay: self.controller.toggle_relay() else: log_msg("User elected not to set up relay.", 4) self.dia.destroy()
def __init__(self, controller): buttons = (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO) dia = gtk.Dialog("Credits Low", None, 0, buttons) self.controller = controller vbox = gtk.VBox() title = gtk.Label() markup = "<span size='large' weight='bold'>You Are Running out of Credits</span>" title.set_markup(markup) title.set_justify(gtk.JUSTIFY_CENTER) vbox.pack_start(title, True, False, 0) #A text entry telling the user what to do: balance = Bank.get().get_expected_balance() balanceGB = Format.convert_to_gb(balance) label = gtk.Label() text = "You only have %s (%s) credits remaining. You must set up a relay to gain more credits. \ This will allow other users to send traffic via your computer.\n\nWould you like to set up a relay now?" % (balance, balanceGB) label.set_markup(text) label.set_line_wrap(True) vbox.pack_start(label, True, True, 5) #if we should always check: self.askAboutRelay = gtk.CheckButton("Always ask about help setting up relay") vbox.pack_start(self.askAboutRelay, True, True, 10) #initialize the checkbox: self.askAboutRelay.set_active(CoreSettings.get().askAboutRelay) vbox = GTKUtils.add_padding(vbox, 5) dia.vbox.pack_start(vbox, True, True, 0) dia.connect("response", self.on_response) self.dia = dia #start the dialog dia.show_all()
def prompt_about_bug_report(): coreSettings = CoreSettings.get() def response(dialog, response): if response == 0: coreSettings.sendBugReports = True send_error_report() else: coreSettings.sendBugReports = False coreSettings.save() if not coreSettings.askedAboutBugReports: GUIController.get().show_msgbox("BitBlinder had errors or crashed last time it was run. Is it ok to send the anonymized error report to the developers? If you dont, they will not be able to fix the errors! :(", title="Please Send Us Your Errors!", cb=response, buttons=("Yes, send anonymous crash data", 0, "No", 1), width=400) coreSettings.askedAboutBugReports = True coreSettings.save() elif coreSettings.sendBugReports: send_error_report()
def show_settings_cb(self, widget=None): #TODO: global and core settings creating and manipulating fake Application ojects, and settings are currently generally stupid. Change to a global settings obj apps = {} #create a fake Application wrapper for global settings: globalSettingsObj = GlobalSettings.get() apps[globalSettingsObj.settingsName] = globalSettingsObj.app coreSettingsObj = CoreSettings.get() apps[coreSettingsObj.settingsName] = coreSettingsObj.app realApplications = [self.torApp, self.btApp] # #currently no ff settings... really should use introspection, but everything is about to change # if System.IS_WINDOWS: # realApplications.append(self.ffApp) for app in realApplications: apps[app.get_settings_name()] = app self.show_settings(apps)
def on_update(self): """is responsible for updating the stat_dict""" global _showedLowMoneyWarning currentBalance = Bank.get().get_expected_balance() #if you have <HIGH_WATER credits: if currentBalance < LOW_MONEY_WARNING_LEVEL: #if you are NOT correctly set up as a relay, inform the user that they must be a relay for this system to keep working #are we not yet acting as a relay? if not Tor.get().settings.beRelay: #have we already warned them? if not _showedLowMoneyWarning: _showedLowMoneyWarning = True #Prompt the user about whether they want to run a relay and earn credits or not: if CoreSettings.get().askAboutRelay: GUIController.get().on_low_credits() self.statistics["Local Balance"].stat_value = str(Bank.get().get_wallet_balance()) self.statistics["Bank Balance"].stat_value = str(currentBalance) self.statistics["Credits Earned"].stat_value = str(Bank.get().get_earnings()) for text, label in self.statistics.iteritems(): label.set_text(text + ": " + label.stat_value)
def __init__(self, controller): buttons = (gtk.STOCK_YES, gtk.RESPONSE_YES, gtk.STOCK_NO, gtk.RESPONSE_NO) dia = gtk.Dialog("Credits Low", None, 0, buttons) self.controller = controller vbox = gtk.VBox() title = gtk.Label() markup = "<span size='large' weight='bold'>You Are Running out of Credits</span>" title.set_markup(markup) title.set_justify(gtk.JUSTIFY_CENTER) vbox.pack_start(title, True, False, 0) #A text entry telling the user what to do: balance = Bank.get().get_expected_balance() balanceGB = Format.convert_to_gb(balance) label = gtk.Label() text = "You only have %s (%s) credits remaining. You must set up a relay to gain more credits. \ This will allow other users to send traffic via your computer.\n\nWould you like to set up a relay now?" % ( balance, balanceGB) label.set_markup(text) label.set_line_wrap(True) vbox.pack_start(label, True, True, 5) #if we should always check: self.askAboutRelay = gtk.CheckButton( "Always ask about help setting up relay") vbox.pack_start(self.askAboutRelay, True, True, 10) #initialize the checkbox: self.askAboutRelay.set_active(CoreSettings.get().askAboutRelay) vbox = GTKUtils.add_padding(vbox, 5) dia.vbox.pack_start(vbox, True, True, 0) dia.connect("response", self.on_response) self.dia = dia #start the dialog dia.show_all()
def on_update(self): """is responsible for updating the stat_dict""" global _showedLowMoneyWarning currentBalance = Bank.get().get_expected_balance() #if you have <HIGH_WATER credits: if currentBalance < LOW_MONEY_WARNING_LEVEL: #if you are NOT correctly set up as a relay, inform the user that they must be a relay for this system to keep working #are we not yet acting as a relay? if not Tor.get().settings.beRelay: #have we already warned them? if not _showedLowMoneyWarning: _showedLowMoneyWarning = True #Prompt the user about whether they want to run a relay and earn credits or not: if CoreSettings.get().askAboutRelay: GUIController.get().on_low_credits() self.statistics["Local Balance"].stat_value = str( Bank.get().get_wallet_balance()) self.statistics["Bank Balance"].stat_value = str(currentBalance) self.statistics["Credits Earned"].stat_value = str( Bank.get().get_earnings()) for text, label in self.statistics.iteritems(): label.set_text(text + ": " + label.stat_value)