예제 #1
0
 def create_file_menu(self):
   self.fileMenu = gtk.Menu()
   self.fileMenuRoot = gtk.MenuItem("File")
   
   def make_toggle_app_entry(app, is_running_func, toggle_func, name, stopEvent, startEvent):
     menuItem = GTKUtils.append_menu_item(self.fileMenu, " ", toggle_func)
     def on_toggled(app):
       if is_running_func():
         menuItem.child.set_text("Stop %s" % (name))
       else:
         menuItem.child.set_text("Start %s" % (name))
     on_toggled(app)
     self._start_listening_for_event(startEvent, app, on_toggled)
     self._start_listening_for_event(stopEvent, app, on_toggled)
     return menuItem
     
   self.serverMenuItem = make_toggle_app_entry(Tor.get(), Tor.get().is_server, 
     self.controller.toggle_relay, "Relay", "server_stopped", "server_started")
   self.bittorrentMenuItem = make_toggle_app_entry(BitTorrentClient.get(), BitTorrentClient.get().is_running, 
     self.controller.toggle_bittorrent, "BitTorrent", "stopped", "started")
   firefox = FirefoxPortable.get()
   if firefox:
     self.firefoxMenuItem = make_toggle_app_entry(firefox, firefox.is_running, 
       self.controller.toggle_firefox, "Browser", "stopped", "started")
   
   self.fileMenu.append(gtk.SeparatorMenuItem())
   GTKUtils.append_menu_item(self.fileMenu, "Update", self.controller.update_check)
   GTKUtils.append_menu_item(self.fileMenu, "Quit", self.controller.quit_cb)
   self.fileMenuRoot.set_submenu(self.fileMenu)
   self.fileMenuRoot.show()
   return self.fileMenu
예제 #2
0
 def _create_applications(self):
   """Creates all application classes that the MainLoop coordinates.  This does NOT start them-
   that's done later.
   WARNING: the gui assumes the apps exist!
   """
   #create the Bank application:
   Bank.start()
   self.bankApp = Bank.get()
   #create the Tor application:
   Tor.start()
   self.torApp = Tor.get()
   
   #create the pseudo applications for InnomiNet
   BitBlinder.start(self.torApp, self.bankApp)
   self.bbApp = BitBlinder.get()
   #create the applications:
   BitTorrentClient.start(self.torApp)
   self.btApp = BitTorrentClient.get()
   self.bbApp.add_application(self.btApp)
   if System.IS_WINDOWS:
     FirefoxPortable.start(self.torApp)
     self.ffApp = FirefoxPortable.get()
     self.bbApp.add_application(self.ffApp)
   
   self.gui.on_applications_created(self.bankApp, self.torApp, self.bbApp, self.btApp, self.ffApp)
예제 #3
0
    def _create_applications(self):
        """Creates all application classes that the MainLoop coordinates.  This does NOT start them-
    that's done later.
    WARNING: the gui assumes the apps exist!
    """
        #create the Bank application:
        Bank.start()
        self.bankApp = Bank.get()
        #create the Tor application:
        Tor.start()
        self.torApp = Tor.get()

        #create the pseudo applications for InnomiNet
        BitBlinder.start(self.torApp, self.bankApp)
        self.bbApp = BitBlinder.get()
        #create the applications:
        BitTorrentClient.start(self.torApp)
        self.btApp = BitTorrentClient.get()
        self.bbApp.add_application(self.btApp)
        if System.IS_WINDOWS:
            FirefoxPortable.start(self.torApp)
            self.ffApp = FirefoxPortable.get()
            self.bbApp.add_application(self.ffApp)

        self.gui.on_applications_created(self.bankApp, self.torApp, self.bbApp,
                                         self.btApp, self.ffApp)
예제 #4
0
  def __init__(self):
    GeneratorMixin.GeneratorMixin.__init__(self)
    self.torApp = Tor.get()
    self._add_events("done")

    #make the components for this GUI
    headerBox = self._make_header_box()
    exitTrafficBox = self._make_exit_traffic_box()
    buttonBox = self._make_button_box()
    
    #pack them into our window:
    box = gtk.VBox(spacing=PADDING)
    box.pack_start(headerBox, False, False, 0)
    box.pack_start(exitTrafficBox, False, False, 0)
    box.pack_start(gtk.HSeparator(), False, False, 0)
    box.pack_start(buttonBox, False, False, 0)
    box.show()
    
    paddedBox = GTKUtils.add_padding(box, PADDING)
    paddedBox.show()
    
    self.container = paddedBox
    self.label = gtk.Label("Exit Traffic Types")
    
    self.container.set_focus_child(self.doneButton)
예제 #5
0
    def __init__(self):
        GeneratorMixin.GeneratorMixin.__init__(self)
        self.torApp = Tor.get()
        self._add_events("done")

        #make the components for this GUI
        headerBox = self._make_header_box()
        exitTrafficBox = self._make_exit_traffic_box()
        buttonBox = self._make_button_box()

        #pack them into our window:
        box = gtk.VBox(spacing=PADDING)
        box.pack_start(headerBox, False, False, 0)
        box.pack_start(exitTrafficBox, False, False, 0)
        box.pack_start(gtk.HSeparator(), False, False, 0)
        box.pack_start(buttonBox, False, False, 0)
        box.show()

        paddedBox = GTKUtils.add_padding(box, PADDING)
        paddedBox.show()

        self.container = paddedBox
        self.label = gtk.Label("Exit Traffic Types")

        self.container.set_focus_child(self.doneButton)
예제 #6
0
 def on_settings_changed(self):
     if Tor.get().settings.beRelay:
         self.relayToggleButton.label.set_text(_("Stop"))
         self.relayToggleButton.image.set_from_pixbuf(Images.STOP_RELAY_PIXBUF)
     else:
         self.relayToggleButton.label.set_text(_("Start"))
         self.relayToggleButton.image.set_from_pixbuf(Images.START_RELAY_PIXBUF)
예제 #7
0
 def __init__(self, controller):
   GeneratorMixin.GeneratorMixin.__init__(self)
   self.controller = controller
   self.testUpdateEvent = None
   self.torApp = Tor.get()
   self.lastTestResult = None
   ClientUtil.add_updater(self)
   self._add_events("failure", "success", "size_changed")
   
   #make the components for this GUI
   instructionBox = self._make_instruction_box()
   requiredPortsBox = self._make_required_ports_box()
   optionalPortsBox = self._make_optional_ports_box()
   buttonBox = self._make_button_box()
   
   #pack them into our window:
   box = gtk.VBox(spacing=PADDING)
   box.pack_start(instructionBox, False, False, 0)
   box.pack_start(requiredPortsBox, False, False, 0)
   box.pack_start(optionalPortsBox, False, False, 0)
   box.pack_end(buttonBox, False, False, 0)
   box.show()
   
   paddedBox = GTKUtils.add_padding(box, PADDING)
   paddedBox.show()
   frame = GTKUtils.add_frame(paddedBox)
   frame.show()
   
   self.container = frame
   self.label = gtk.Label("Relay Setup")
   
   #make pretty:
   _unify_widget_widths([self.relayBox.label, self.dhtBox.label, self.dirBox.label, self.upnpBox.label])
   _unify_widget_widths([self.relayBox.entry.entry, self.dhtBox.entry.entry, self.dirBox.entry.entry, self.upnpBox.entry.entry])
   self.container.set_focus_child(self.doneButton)
예제 #8
0
 def on_settings_changed(self):
   if Tor.get().settings.beRelay:
     self.relayToggleButton.label.set_text(_("Stop"))
     self.relayToggleButton.image.set_from_pixbuf(Images.STOP_RELAY_PIXBUF)
   else:
     self.relayToggleButton.label.set_text(_("Start"))
     self.relayToggleButton.image.set_from_pixbuf(Images.START_RELAY_PIXBUF)
예제 #9
0
 def update(self):
     torApp = Tor.get()
     #    #is upnp even supported on this platform?
     #    if not System.IS_WINDOWS:
     #      self.statusImage.set_from_pixbuf(Images.GREY_CIRCLE)
     #      self.statusLabel.set_markup(STATUS_MARKUP % ("Not supported in linux"))
     #    #update UPnP label based on the result of the port tests
     #    else:
     upnpSucceeded = False
     upnpFailed = False
     for portObj in (torApp.orPort, torApp.dirPort, torApp.dhtPort):
         if portObj:
             if portObj.upnpState == "YES":
                 upnpSucceeded = True
             elif portObj.upnpState == "NO":
                 upnpFailed = True
     if upnpSucceeded:
         self.statusImage.set_from_pixbuf(Images.GREEN_CIRCLE)
         self.statusLabel.set_markup(STATUS_MARKUP % ("Succeeded"))
     elif upnpFailed:
         self.statusImage.set_from_pixbuf(Images.RED_CIRCLE)
         self.statusLabel.set_markup(
             STATUS_MARKUP %
             ("Failed.  Please enable UPnP in your router."))
     else:
         self.statusImage.set_from_pixbuf(Images.YELLOW_CIRCLE)
         self.statusLabel.set_markup(UNKNOWN_MARKUP)
예제 #10
0
  def update(self):
    torApp = Tor.get()
#    #is upnp even supported on this platform?
#    if not System.IS_WINDOWS:
#      self.statusImage.set_from_pixbuf(Images.GREY_CIRCLE)
#      self.statusLabel.set_markup(STATUS_MARKUP % ("Not supported in linux"))
#    #update UPnP label based on the result of the port tests
#    else:
    upnpSucceeded = False
    upnpFailed = False
    for portObj in (torApp.orPort, torApp.dirPort, torApp.dhtPort):
      if portObj:
        if portObj.upnpState == "YES":
          upnpSucceeded = True
        elif portObj.upnpState == "NO":
          upnpFailed = True
    if upnpSucceeded:
      self.statusImage.set_from_pixbuf(Images.GREEN_CIRCLE)
      self.statusLabel.set_markup(STATUS_MARKUP % ("Succeeded"))
    elif upnpFailed:
      self.statusImage.set_from_pixbuf(Images.RED_CIRCLE)
      self.statusLabel.set_markup(STATUS_MARKUP % ("Failed.  Please enable UPnP in your router."))
    else:
      self.statusImage.set_from_pixbuf(Images.YELLOW_CIRCLE)
      self.statusLabel.set_markup(UNKNOWN_MARKUP)
예제 #11
0
 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()
예제 #12
0
 def _entry_changed(self, widget, *args):
     self.update()
     portObj = getattr(Tor.get(), self.portObjName, None)
     if not portObj:
         return
     if self.entry.get_value() != portObj.get_port():
         self.serverSetupWindow.set_title_unknown()
     else:
         self.serverSetupWindow.set_title_from_test_result()
예제 #13
0
 def _entry_changed(self, widget, *args):
   self.update()
   portObj = getattr(Tor.get(), self.portObjName, None)
   if not portObj:
     return
   if self.entry.get_value() != portObj.get_port():
     self.serverSetupWindow.set_title_unknown()
   else:
     self.serverSetupWindow.set_title_from_test_result()
예제 #14
0
 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()
예제 #15
0
    def create_box(self):
        #create each of the pages:
        self._mainBox = gtk.HBox()
        self.vbox.pack_start(self._mainBox, True, True, 0)
        BORDER_WIDTH = 10

        def add_var(name, box, ignoreHBar=None):
            return self.add_variable(name,
                                     Tor.get().settings, Tor.get(), "", box,
                                     ignoreHBar)

        #general settings page:
        vbox = gtk.VBox()
        add_var("orPort", vbox)
        add_var("dirPort", vbox)
        add_var("dhtPort", vbox)
        vbox.set_border_width(BORDER_WIDTH)
        #windows settings, if necessary
        if System.IS_WINDOWS:
            startOnBootEntry = self.add_variable("startBitBlinderOnBoot",
                                                 BitBlinder.get().settings,
                                                 BitBlinder.get(), "", vbox)
            #NOTE:  change the default to starting on bootup if we're a server now
            if not Tor.get().settings.wasRelay:
                startOnBootEntry.set_value(True)
            self.add_variable("halfOpenConnections",
                              BitBlinder.get().settings, BitBlinder.get(), "",
                              vbox)
        self._boxes.append(vbox)
        #exit traffic page:
        vbox = gtk.VBox()
        vbox.set_border_width(BORDER_WIDTH)
        exitTypeEntry = add_var("exitType", vbox, True)
        exitTypeEntry.set_value("Both")
        vbox.pack_start(
            GTKUtils.make_html_link(
                "Learn more about exit traffic",
                "%s/overview/" % (ProgramState.Conf.BASE_HTTP)), False, False,
            2)
        self._boxes.append(vbox)
        #bandwidth page:
        vbox = gtk.VBox()
        vbox.set_border_width(BORDER_WIDTH)
        label = WrapLabel.WrapLabel("")
        label.set_markup(
            """<span size='large' weight='bold'>You should run BitBlinder in the background to accumulate credits.
</span>
""")
        vbox.pack_start(label, False, False, 0)
        #    vbox.pack_start(gtk.HSeparator(), False, False, 0)
        add_var("monthlyCap", vbox)
        add_var("bwRate", vbox)
        add_var("bwSchedule", vbox)
        self._boxes.append(vbox)
        self._mainBox.set_size_request(600, -1)
        self.set_current_page()
예제 #16
0
 def update(self):
   portObj = getattr(Tor.get(), self.portObjName)
   if not portObj or self.entry.get_value() == 0:
     self.statusImage.set_from_pixbuf(Images.GREY_CIRCLE)
     self.statusLabel.set_markup(STATUS_MARKUP % ("Disabled"))
     return
   if self.entry.get_value() != portObj.get_port():
     self.statusImage.set_from_pixbuf(Images.YELLOW_CIRCLE)
     self.statusLabel.set_markup(UNKNOWN_MARKUP)
   elif portObj.reachableState == "YES":
     self.statusImage.set_from_pixbuf(Images.GREEN_CIRCLE)
     self.statusLabel.set_markup(STATUS_MARKUP % ("Reachable"))
   elif portObj.reachableState == "NO":
     self.statusImage.set_from_pixbuf(Images.RED_CIRCLE)
     self.statusLabel.set_markup(STATUS_MARKUP % ("Not reachable"))
   else:
     self.statusImage.set_from_pixbuf(Images.YELLOW_CIRCLE)
     self.statusLabel.set_markup(UNKNOWN_MARKUP)
예제 #17
0
 def update(self):
     portObj = getattr(Tor.get(), self.portObjName)
     if not portObj or self.entry.get_value() == 0:
         self.statusImage.set_from_pixbuf(Images.GREY_CIRCLE)
         self.statusLabel.set_markup(STATUS_MARKUP % ("Disabled"))
         return
     if self.entry.get_value() != portObj.get_port():
         self.statusImage.set_from_pixbuf(Images.YELLOW_CIRCLE)
         self.statusLabel.set_markup(UNKNOWN_MARKUP)
     elif portObj.reachableState == "YES":
         self.statusImage.set_from_pixbuf(Images.GREEN_CIRCLE)
         self.statusLabel.set_markup(STATUS_MARKUP % ("Reachable"))
     elif portObj.reachableState == "NO":
         self.statusImage.set_from_pixbuf(Images.RED_CIRCLE)
         self.statusLabel.set_markup(STATUS_MARKUP % ("Not reachable"))
     else:
         self.statusImage.set_from_pixbuf(Images.YELLOW_CIRCLE)
         self.statusLabel.set_markup(UNKNOWN_MARKUP)
예제 #18
0
  def create_box(self):
    #create each of the pages:
    self._mainBox = gtk.HBox()
    self.vbox.pack_start(self._mainBox, True, True, 0)
    BORDER_WIDTH = 10
    def add_var(name, box, ignoreHBar=None):
      return self.add_variable(name, Tor.get().settings, Tor.get(), "", box, ignoreHBar)
    #general settings page:
    vbox = gtk.VBox()
    add_var("orPort", vbox)
    add_var("dirPort", vbox)
    add_var("dhtPort", vbox)
    vbox.set_border_width(BORDER_WIDTH)
    #windows settings, if necessary
    if System.IS_WINDOWS:
      startOnBootEntry = self.add_variable("startBitBlinderOnBoot", BitBlinder.get().settings, BitBlinder.get(), "", vbox)
      #NOTE:  change the default to starting on bootup if we're a server now
      if not Tor.get().settings.wasRelay:
        startOnBootEntry.set_value(True)
      self.add_variable("halfOpenConnections", BitBlinder.get().settings, BitBlinder.get(), "", vbox)
    self._boxes.append(vbox)
    #exit traffic page:
    vbox = gtk.VBox()
    vbox.set_border_width(BORDER_WIDTH)
    exitTypeEntry = add_var("exitType", vbox, True)
    exitTypeEntry.set_value("Both")
    vbox.pack_start(GTKUtils.make_html_link("Learn more about exit traffic", "%s/overview/" % (ProgramState.Conf.BASE_HTTP)), False, False, 2)
    self._boxes.append(vbox)
    #bandwidth page:
    vbox = gtk.VBox()
    vbox.set_border_width(BORDER_WIDTH)
    label = WrapLabel.WrapLabel("")
    label.set_markup("""<span size='large' weight='bold'>You should run BitBlinder in the background to accumulate credits.
</span>
""")
    vbox.pack_start(label, False, False, 0)
#    vbox.pack_start(gtk.HSeparator(), False, False, 0)
    add_var("monthlyCap", vbox)
    add_var("bwRate", vbox)
    add_var("bwSchedule", vbox)
    self._boxes.append(vbox)
    self._mainBox.set_size_request(600, -1)
    self.set_current_page()
예제 #19
0
    def __init__(self, controller):
        GeneratorMixin.GeneratorMixin.__init__(self)
        self.controller = controller
        self.testUpdateEvent = None
        self.torApp = Tor.get()
        self.lastTestResult = None
        ClientUtil.add_updater(self)
        self._add_events("failure", "success", "size_changed")

        #make the components for this GUI
        instructionBox = self._make_instruction_box()
        requiredPortsBox = self._make_required_ports_box()
        optionalPortsBox = self._make_optional_ports_box()
        buttonBox = self._make_button_box()

        #pack them into our window:
        box = gtk.VBox(spacing=PADDING)
        box.pack_start(instructionBox, False, False, 0)
        box.pack_start(requiredPortsBox, False, False, 0)
        box.pack_start(optionalPortsBox, False, False, 0)
        box.pack_end(buttonBox, False, False, 0)
        box.show()

        paddedBox = GTKUtils.add_padding(box, PADDING)
        paddedBox.show()
        frame = GTKUtils.add_frame(paddedBox)
        frame.show()

        self.container = frame
        self.label = gtk.Label("Relay Setup")

        #make pretty:
        _unify_widget_widths([
            self.relayBox.label, self.dhtBox.label, self.dirBox.label,
            self.upnpBox.label
        ])
        _unify_widget_widths([
            self.relayBox.entry.entry, self.dhtBox.entry.entry,
            self.dirBox.entry.entry, self.upnpBox.entry.entry
        ])
        self.container.set_focus_child(self.doneButton)
예제 #20
0
 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)
예제 #21
0
 def _stop_done(self, result):
   Basic.validate_result(result, "BitTorrentWindow::_stop_done")
   if not BitBlinder.get().is_running():
     GlobalEvents.throw_event("quit_signal")
   else:
     #are there any other apps using bitblinder?
     for app in BitBlinder.get().applications.values():
       #if there is another app, dont bother shutting down everything
       if app.is_running() and app != Bank.get():
         return
     #ok, check if there is a relay then
     if Tor.get().settings.beRelay:
       #then we should prompt about shutdown
       def callback(dialog, response):
         if response == gtk.RESPONSE_YES:
           self._do_quit()
       msgText = "BitBlinder is acting as a server and help others be anonymous, and earning you more credits!\n\nDo you also want to stop the server?"
       GUIController.get().show_preference_prompt(msgText, "Stop Relay?", callback, "promptAboutRelayQuit")
     else:
       #otherwise shutdown completely:
       self._do_quit()
예제 #22
0
    def _stop_done(self, result):
        Basic.validate_result(result, "BitTorrentWindow::_stop_done")
        if not BitBlinder.get().is_running():
            GlobalEvents.throw_event("quit_signal")
        else:
            #are there any other apps using bitblinder?
            for app in BitBlinder.get().applications.values():
                #if there is another app, dont bother shutting down everything
                if app.is_running() and app != Bank.get():
                    return
            #ok, check if there is a relay then
            if Tor.get().settings.beRelay:
                #then we should prompt about shutdown
                def callback(dialog, response):
                    if response == gtk.RESPONSE_YES:
                        self._do_quit()

                msgText = "BitBlinder is acting as a server and help others be anonymous, and earning you more credits!\n\nDo you also want to stop the server?"
                GUIController.get().show_preference_prompt(
                    msgText, "Stop Relay?", callback, "promptAboutRelayQuit")
            else:
                #otherwise shutdown completely:
                self._do_quit()
예제 #23
0
    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)
예제 #24
0
 def _update_relay_box_visibility(self):
   if Tor.get().is_server():
     self.relayRow.hide()
   else:
     self.relayRow.show()
   GTKUtils.refit(self.relayRow)
예제 #25
0
 def initialize(self):
     self.entry.set_value(getattr(Tor.get().settings, self.portObjName))
예제 #26
0
 def apply_value(self):
     self.currentPort = self.entry.get_value()
     setattr(Tor.get().settings, self.portObjName, self.currentPort)
예제 #27
0
 def __init__(self, controller):
   TopWindow.Window.__init__(self, "Server Setup",  None)
   self.controller = controller
   self.currentDisplay = None
   self.settingDialog = None
   self.torApp = Tor.get()
예제 #28
0
 def _start_relay_cb(self, widget=None):
   if not Tor.get().is_server():
     self.controller.toggle_relay()
예제 #29
0
  def create(self):
    #Stores references to the program rows
    self.rows = {}
    self.selectedApp = None
    
    ClientUtil.add_updater(self)
    
    #create a liststore with one string column to use as the model
                #COLUMNS:
                #0:  Program name
    typeList = [gobject.TYPE_STRING,
                #1:  Number of hops
                gobject.TYPE_INT,
                #2:  Download Rate
                gobject.TYPE_STRING,
                #3:  Upload Rate
                gobject.TYPE_STRING,
                #4:  Coins spent
                gobject.TYPE_INT
                ]
    self.attrIdx = {}
    self.attrIdx["name"]         = 0
    self.attrIdx["numHops"]      = 1
    self.attrIdx["rateDown"]     = 2
    self.attrIdx["rateUp"]       = 3
    self.attrIdx["numCredits"]     = 4
    self.liststore = gtk.ListStore(*typeList)
    COLUMN_NAMES = ['Name','Anonymity Level', "Down Rate", "Up Rate", "Credits Used"]
    viewName = "Anonymous Programs"

    modelfilter, treeview = GTKUtils.make_listview(self.liststore, COLUMN_NAMES)
    for i in range (0, len(COLUMN_NAMES)):
      GTKUtils.make_text_cell(treeview.columns[i], i)
    
    #make treeview searchable
    treeview.set_search_column(0)
    #attach the filtermodel and treeview
    treeview.set_model(gtk.TreeModelSort(modelfilter))
#    treeview.connect("row-activated", self.row_activate_cb)
    treeview.connect("cursor-changed", self.row_change_cb)
    treeview.connect("button-press-event", self.button_press_cb)
    treeview.set_size_request(-1, 80)
    treeview.get_selection().set_mode(gtk.SELECTION_SINGLE)
      
    def make_button(text, cb, picFile):
      return GTKUtils.make_image_button(text, cb, picFile)
    
    bottomRow = gtk.HBox()
    self.removeButton = make_button('Stop', self.stop_cb, ClientUtil.get_image_file("stop.png"))
    bottomRow.pack_start(self.removeButton, False, False, 1)
    self.anonEntry = SettingsDisplay.make_entry("anonymity level", 1)
    self.anonEntry.connect_user_changed(self.toggle_anon_cb)
    bottomRow.pack_end(self.anonEntry.get_gtk_element(), False, False, 5)
    label = gtk.Label("")
    label.set_markup('<span size="large" weight="bold">Number of Hops: </span>')
    bottomRow.pack_end(label, False, False, 5)
    
    self.treeview, self.modelfilter = treeview, modelfilter
#    self.modelfilter.set_visible_func(self.visible_cb)

    self.bankDisplay = BankDisplay.BankDisplay()
    self.circuitList = CircuitList.CircuitList()
    self.console = Console.Console(Tor.get())

    self.bwGraph = BWGraph.BWGraph(BWHistory.localBandwidth, root=self)
    self.bwGraph.container.set_size_request(-1, 200)
    self.bwGraphLabel = gtk.Label("All Traffic")
    
    self.notebook = ClosableTabNotebook.ClosableTabNotebook()
    self.notebook.show_display(self.bwGraph)
    
    notebookAlign = gtk.Alignment(0, 0, 1, 1)
    notebookAlign.set_padding(5, 5, 0, 5)
    notebookAlign.add(self.notebook)
    
    self.topBox = gtk.VBox()
    self.topBox.pack_start(GTKUtils.make_scroll_box(treeview, hPolicy=gtk.POLICY_AUTOMATIC, vPolicy=gtk.POLICY_AUTOMATIC), True, True, 10)
    self.topBox.pack_start(bottomRow, False, True, 10)
    
    alignBottom = gtk.Alignment(1, 1, 1, 1)
    alignBottom.set_padding(10, 3, 1, 1)
    alignBottom.add(notebookAlign)
    vpane = gtk.VPaned()
     
    frame = gtk.Frame()
    frame.set_shadow_type(gtk.SHADOW_OUT)
    frame.add(self.topBox)
    
    alignTop = gtk.Alignment(1, 1, 1, 1)
    alignTop.set_padding(10, 10, 7, 7)
    alignTop.add(frame)
    
    topContainer = gtk.VBox()
    topContainer.pack_start(alignTop, True, True, 0)
    
    vpane.pack1(topContainer, resize=True, shrink=False)
    vpane.pack2(alignBottom, resize=True, shrink=False)
    vpane.set_position(400)
    
    self.label = gtk.Label("")
    self.label.set_markup("<span size='x-large' weight='bold'>Applications</span>")
    self.container = vpane
    
    self.catch_event("settings_changed")
    
    self.menuBar = SocksServerMenuBar(self.root, self)
    
    vbox = gtk.VBox() 
    vbox.pack_start(self.menuBar.create_menus(), False, False, 0)
    vbox.pack_start(self.container, True, True, 0)
    self.add(vbox)
    vbox.show_all()
예제 #30
0
 def add_var(name, box, ignoreHBar=None):
     return self.add_variable(name,
                              Tor.get().settings, Tor.get(), "", box,
                              ignoreHBar)
예제 #31
0
    def __init__(self, controller):
        GeneratorMixin.GeneratorMixin.__init__(self)
        ListenerMixin.ListenerMixin.__init__(self)

        self.controller = controller
        self.torApp = Tor.get()

        self._add_events("show_settings", "toggle_server", "show_setup", "done")
        ClientUtil.add_updater(self)

        self.bwGraph = BWGraph.BWGraph(BWHistory.remoteBandwidth, root=controller.serverWindow)
        self.bwGraph.container.set_size_request(400, 200)
        self.bwGraph.label = gtk.Label("Relay Traffic")
        self.statusRows = []

        self.statistics = {}
        self.torStatus = None
        self.rows = []
        iconSize = 24
        tooltips = gtk.Tooltips()

        def make_row_box(name, labelText, childWidget):
            """packs a gui row with a label, childWidget, and an image.
      it then adds the row and a separator to a vbox which it returns 
      as well as the label it created as for use in homogenizing all the label widths"""

            image = gtk.Image()
            image.set_from_pixbuf(Images.GREY_CIRCLE)
            imageAlign = gtk.Alignment(0, 0, 0, 0)
            # push the widget over
            imageAlign.set_padding(0, 0, 0, 10)
            imageAlign.add(image)

            textLabel = gtk.Label()
            textLabel.set_markup("<span size='large' weight='bold'>%s</span>" % (labelText))
            # stick the align on the left
            textLabel.set_alignment(0, 0.5)

            row = StatusHBox(name, textLabel, childWidget, image)
            self.statusRows.append(row)

            row.pack_start(imageAlign, False, False, 0)
            row.pack_start(textLabel, False, False, 0)
            row.pack_start(childWidget, False, False, 0)

            # pad the whole row
            rowAlign = gtk.Alignment(0, 0, 1, 1)
            rowAlign.set_padding(0, 0, 5, 5)
            rowAlign.add(row)

            sep = gtk.HSeparator()
            vBox = gtk.VBox()
            vBox.pack_start(rowAlign, False, False, 10)
            vBox.pack_start(sep, False, False, 0)

            return (vBox, row)

        creditsValueLabel = gtk.Label("0")
        creditsBox, self.creditsRow = make_row_box("credits", "Credits: ", creditsValueLabel)

        statusValueLabel = gtk.Label("Unknown")
        statusBox, self.statusRow = make_row_box("status", "Status: ", statusValueLabel)

        def on_toggle(widget):
            self._trigger_event("toggle_server")

        self.relayToggleButton = GTKUtils.make_image_button(_("Start"), on_toggle, "exit.png")
        self.relayToggleButton.set_size_request(75, -1)
        relayBox, self.relayRow = make_row_box("relay", "Relay:", self.relayToggleButton)

        textLabel = gtk.Label("Unknown")
        relayPortBox, self.tcpRelayPortRow = make_row_box("orPort", "TCP Relay Port:", textLabel)

        textLabel = gtk.Label("Unknown")
        udpRelayPortBox, self.udpRelayPortRow = make_row_box("dhtPort", "UDP Relay Port:", textLabel)

        textLabel = gtk.Label()
        textLabel.set_markup('<span size="large">     55555 is unreachable        </span>')
        dirPortBox, self.dirPortRow = make_row_box("dirPort", "Directory Port:", textLabel)

        labels = [
            box.rowLabel
            for box in self.creditsRow,
            self.statusRow,
            self.relayRow,
            self.tcpRelayPortRow,
            self.udpRelayPortRow,
            self.dirPortRow,
        ]
        maxLabelWidth = 5 + max([label.size_request()[0] for label in labels])
        for label in labels:
            label.set_size_request(maxLabelWidth, -1)

        hideButton = gtk.Button("Hide")
        hideButton.connect("clicked", self._hide_cb)
        settingsButton = gtk.Button("Settings")

        def on_settings(widget):
            self._trigger_event("show_settings")

        settingsButton.connect("clicked", on_settings)
        buttonBox = gtk.HBox()
        buttonBox.pack_start(hideButton, False, False, 0)
        buttonBox.pack_end(settingsButton, False, False, 0)

        self.serverBox = gtk.VBox()
        for box in [relayBox, statusBox, relayPortBox, udpRelayPortBox, dirPortBox, creditsBox]:
            self.serverBox.pack_start(box, True, False, 0)
        self.serverBox.pack_start(buttonBox, True, False, 0)
        align = gtk.Alignment(0, 0, 0, 0)
        align.set_padding(0, 0, 5, 5)
        align.add(self.serverBox)

        serverFrame = GTKUtils.add_frame(align)
        makeAuroraFramesRounded = gtk.HBox()
        makeAuroraFramesRounded.set_size_request(0, 0)
        serverFrame.set_label_widget(makeAuroraFramesRounded)

        self.notebook = ClosableTabNotebook.ClosableTabNotebook()
        self.notebook.show_display(self.bwGraph)

        notebookAlign = gtk.Alignment(0, 0, 1, 1)
        notebookAlign.set_padding(5, 5, 0, 5)
        notebookAlign.add(self.notebook)

        hbox = gtk.HBox()
        hbox.pack_start(serverFrame, False, False, 0)
        hbox.pack_start(notebookAlign, True, True, 0)
        hbox.show_all()

        self.catch_event("settings_changed")

        #    self.container = hbox
        self.label = gtk.Label("Server Status %s" % (Globals.VERSION))

        vbox = gtk.VBox()
        self.menuBar = BaseMenuBar.BaseMenuBar(self.controller)
        vbox.pack_start(self.menuBar.create_menus(), False, False, 0)
        vbox.pack_start(hbox, True, True, 0)
        vbox.show_all()
        self.container = vbox
예제 #32
0
 def add_var(name, box, ignoreHBar=None):
   return self.add_variable(name, Tor.get().settings, Tor.get(), "", box, ignoreHBar)
예제 #33
0
 def apply_value(self):
   self.currentPort = self.entry.get_value()
   setattr(Tor.get().settings, self.portObjName, self.currentPort)
예제 #34
0
  def __init__(self, controller):
    GeneratorMixin.GeneratorMixin.__init__(self)
    ListenerMixin.ListenerMixin.__init__(self)
    
    self.controller = controller
    self.torApp = Tor.get()
    
    self._add_events("show_settings", "toggle_server", "show_setup", "done")
    ClientUtil.add_updater(self)

    self.bwGraph = BWGraph.BWGraph(BWHistory.remoteBandwidth, root=controller.serverWindow)
    self.bwGraph.container.set_size_request(400, 200)
    self.bwGraph.label = gtk.Label("Relay Traffic")
    self.statusRows = []
    
    self.statistics = {}
    self.torStatus = None
    self.rows = []  
    iconSize = 24
    tooltips = gtk.Tooltips()
    
    def make_row_box(name, labelText, childWidget):
      """packs a gui row with a label, childWidget, and an image.
      it then adds the row and a separator to a vbox which it returns 
      as well as the label it created as for use in homogenizing all the label widths"""
      
      image = gtk.Image()
      image.set_from_pixbuf(Images.GREY_CIRCLE)
      imageAlign = gtk.Alignment(0, 0, 0, 0)
      #push the widget over 
      imageAlign.set_padding(0, 0, 0, 10)
      imageAlign.add(image)
     
      textLabel = gtk.Label()
      textLabel.set_markup("<span size='large' weight='bold'>%s</span>" % (labelText))
      #stick the align on the left
      textLabel.set_alignment(0, 0.5)
      
      row = StatusHBox(name, textLabel, childWidget, image)
      self.statusRows.append(row)
      
      row.pack_start(imageAlign, False, False, 0)
      row.pack_start(textLabel, False, False, 0)
      row.pack_start(childWidget, False, False, 0)
      
      #pad the whole row
      rowAlign = gtk.Alignment(0, 0, 1, 1)
      rowAlign.set_padding(0, 0, 5, 5)
      rowAlign.add(row)
      
      sep = gtk.HSeparator()
      vBox = gtk.VBox()
      vBox.pack_start(rowAlign, False, False, 10)
      vBox.pack_start(sep, False, False, 0)
      
      return (vBox, row)
    
    creditsValueLabel = gtk.Label("0")
    creditsBox, self.creditsRow = make_row_box('credits', 'Credits: ', creditsValueLabel)
    
    statusValueLabel = gtk.Label("Unknown")
    statusBox, self.statusRow = make_row_box('status', 'Status: ', statusValueLabel)
    
    def on_toggle(widget):
      self._trigger_event("toggle_server")
    self.relayToggleButton = GTKUtils.make_image_button(_("Start"), on_toggle, "exit.png")
    self.relayToggleButton.set_size_request(75, -1)
    relayBox, self.relayRow = make_row_box('relay', "Relay:", self.relayToggleButton)
    
    textLabel = gtk.Label("Unknown")
    relayPortBox, self.tcpRelayPortRow = make_row_box('orPort', "TCP Relay Port:", textLabel)
    
    textLabel = gtk.Label("Unknown")
    udpRelayPortBox, self.udpRelayPortRow = make_row_box('dhtPort', "UDP Relay Port:", textLabel)
    
    textLabel = gtk.Label()
    textLabel.set_markup('<span size="large">     55555 is unreachable        </span>')
    dirPortBox, self.dirPortRow = make_row_box('dirPort', "Directory Port:", textLabel)
    
    labels = [box.rowLabel for box in \
              self.creditsRow, self.statusRow, self.relayRow, self.tcpRelayPortRow, self.udpRelayPortRow, self.dirPortRow]
    maxLabelWidth = 5 + max([label.size_request()[0] for label in labels])
    for label in labels:
      label.set_size_request(maxLabelWidth, -1)
      
    hideButton = gtk.Button("Hide")
    hideButton.connect("clicked", self._hide_cb)
    settingsButton = gtk.Button("Settings")
    def on_settings(widget):
      self._trigger_event("show_settings")
    settingsButton.connect("clicked", on_settings)
    buttonBox = gtk.HBox()
    buttonBox.pack_start(hideButton, False, False, 0)
    buttonBox.pack_end(settingsButton, False, False, 0)
    
    self.serverBox = gtk.VBox()
    for box in [relayBox, statusBox, relayPortBox, udpRelayPortBox, dirPortBox, creditsBox]:
      self.serverBox.pack_start(box, True, False, 0)
    self.serverBox.pack_start(buttonBox, True, False, 0)
    align = gtk.Alignment(0, 0, 0, 0)
    align.set_padding(0, 0, 5, 5)
    align.add(self.serverBox)
    
    serverFrame = GTKUtils.add_frame(align)
    makeAuroraFramesRounded = gtk.HBox()
    makeAuroraFramesRounded.set_size_request(0,0)
    serverFrame.set_label_widget(makeAuroraFramesRounded)
    
    self.notebook = ClosableTabNotebook.ClosableTabNotebook()
    self.notebook.show_display(self.bwGraph)
    
    notebookAlign = gtk.Alignment(0, 0, 1, 1)
    notebookAlign.set_padding(5, 5, 0, 5)
    notebookAlign.add(self.notebook)

    hbox = gtk.HBox()
    hbox.pack_start(serverFrame, False, False, 0)
    hbox.pack_start(notebookAlign, True, True, 0)
    hbox.show_all()
    
    self.catch_event("settings_changed")
    
#    self.container = hbox
    self.label = gtk.Label("Server Status %s" % (Globals.VERSION))
    
    vbox = gtk.VBox() 
    self.menuBar = BaseMenuBar.BaseMenuBar(self.controller)    
    vbox.pack_start(self.menuBar.create_menus(), False, False, 0)
    vbox.pack_start(hbox, True, True, 0)
    vbox.show_all()
    self.container = vbox
예제 #35
0
 def initialize(self):
   self.entry.set_value(getattr(Tor.get().settings, self.portObjName))