예제 #1
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)
예제 #2
0
 def _make_exit_traffic_box(self):
   def make_exit_row(labelText):
     #make the widgets
     label = gtk.Label()
     label.set_markup("<span size='large'>%s</span>" % (labelText))
     entry = SettingsDisplay.make_entry("bool", True)
     #and pack them together
     box = gtk.HBox()
     box.pack_start(label, False, False, 0)
     box.pack_end(entry.entry, False, False, 0)
     return (entry, box)
   
   #make widgets
   exitTrafficLabel = gtk.Label()
   exitTrafficLabel.set_markup("<span size='large' weight='bold'>Exit Traffic Permissions:</span>")
   exitTrafficLabel.set_alignment(0.0, 0.5)
   self.webTrafficEntry, webBox = make_exit_row("   Allow Web Traffic")
   self.btTrafficEntry, btBox = make_exit_row("   Allow BitTorrent Traffic")
   self.dhtTrafficEntry, dhtBox = make_exit_row("   Allow DHT Traffic")
   risksLink = GTKUtils.make_html_link("What are the risks?", "")
   risksLink.label.set_alignment(0.0, 0.5)
   
   #pack them together:
   box = gtk.VBox(spacing=PADDING)
   box.pack_start(exitTrafficLabel, False, False, 0)
   box.pack_start(btBox, False, False, 0)
   box.pack_start(webBox, False, False, 0)
   box.pack_start(dhtBox, False, False, 0)
   box.pack_start(risksLink, False, False, 0)
   box = GTKUtils.add_padding(box, PADDING)
   frame = GTKUtils.add_frame(box, width=0)
   frame.show_all()
   return frame
예제 #3
0
    def _make_required_ports_box(self):
        """Make a box containing the settings and status for all required ports (currently just the Relay port)"""
        #make entry rows
        self.relayBox = RelayPortStatusBox("Relay Port (TCP)", "orPort", self)
        self.upnpBox = UPnPStatusBox("UPnP")

        #pack them together:
        box = gtk.VBox(spacing=PADDING)
        box.pack_start(self.relayBox, False, False, 0)
        box.pack_start(self.upnpBox, False, False, 0)
        box = GTKUtils.add_padding(box, PADDING)
        frame = GTKUtils.add_frame(box, name="Relay Port", width=0)
        frame.show_all()
        return frame
예제 #4
0
 def _make_required_ports_box(self):
   """Make a box containing the settings and status for all required ports (currently just the Relay port)"""
   #make entry rows
   self.relayBox = RelayPortStatusBox("Relay Port (TCP)", "orPort", self)
   self.upnpBox = UPnPStatusBox("UPnP")
   
   #pack them together:
   box = gtk.VBox(spacing=PADDING)
   box.pack_start(self.relayBox, False, False, 0)
   box.pack_start(self.upnpBox, False, False, 0)
   box = GTKUtils.add_padding(box, PADDING)
   frame = GTKUtils.add_frame(box, name="Relay Port", width=0)
   frame.show_all()
   return frame
예제 #5
0
    def _make_optional_info_box(self):
        """shows extra information that will scare away most users"""
        #make entry rows
        moreInfos = WrapLabel.WrapLabel(greaterInfoText)
        moreInfos.set_justify(gtk.JUSTIFY_FILL)

        #make a box for hiding
        self.optionalInfosBox = gtk.VBox()
        self.optionalInfosBox.pack_start(moreInfos, False, False, 0)
        self.optionalInfosBox = GTKUtils.add_padding(self.optionalInfosBox, 5)

        #make a frame with a built-in expander for showing and hiding these entry rows
        frame = GTKUtils.add_frame(self.optionalInfosBox, width=0)
        frameWidget = gtk.Expander("Learn More")
        frameWidget.connect("notify::expanded", self._toggle_optional_infos)
        frame.set_label_widget(frameWidget)
        return frame
예제 #6
0
  def _make_optional_info_box(self):
    """shows extra information that will scare away most users"""
    #make entry rows
    moreInfos = WrapLabel.WrapLabel(greaterInfoText)
    moreInfos.set_justify(gtk.JUSTIFY_FILL)
    
    #make a box for hiding
    self.optionalInfosBox = gtk.VBox()
    self.optionalInfosBox.pack_start(moreInfos, False, False, 0)
    self.optionalInfosBox = GTKUtils.add_padding(self.optionalInfosBox, 5)

    #make a frame with a built-in expander for showing and hiding these entry rows
    frame = GTKUtils.add_frame(self.optionalInfosBox, width=0)
    frameWidget = gtk.Expander("Learn More")
    frameWidget.connect("notify::expanded", self._toggle_optional_infos)
    frame.set_label_widget(frameWidget)
    return frame
예제 #7
0
    def __init__(self, app, allowNonanonymousMode=True):
        BaseDialog.BaseDialog.__init__(self,
                                       "%s Anonymity Selector" % (app.name),
                                       ("ok", "cancel"), None)
        self.app = app
        self.allowNonanonymousMode = allowNonanonymousMode

        titleLabel = gtk.Label()
        titleLabel.set_markup(
            "<span size='x-large' weight='bold'>%s Anonymity Selector</span>" %
            (self.app.name))
        titleLabel.set_justify(gtk.JUSTIFY_CENTER)

        vbox = gtk.VBox()
        vbox.pack_start(titleLabel, False, False, 5)
        infoTextLabel = WrapLabel.WrapLabel(infoText)
        infoTextLabel.set_justify(gtk.JUSTIFY_FILL)
        #keep the label from having no width
        infoTextLabel.set_size_request(300, -1)

        infoAndSlider = gtk.VBox()
        infoAndSlider.pack_start(infoTextLabel, False, False, 0)
        instructionBox = self._make_instruction_box()
        infoAndSlider.pack_start(instructionBox, False, False, 0)
        #get the appropriate path length from the app
        if not self.allowNonanonymousMode or self.app.useTor:
            pathLength = self.app.settings.pathLength
        else:
            pathLength = 0
        anonymityBox = self._make_slider_box(pathLength)
        infoAndSlider.pack_start(anonymityBox, False, False, 0)
        infoAndSlider = GTKUtils.add_padding(infoAndSlider, 5)
        infoAndSlider = GTKUtils.add_frame(infoAndSlider,
                                           name='Choose Your Anonymity Level')
        vbox.pack_start(infoAndSlider, False, False, 0)

        optionalInfos = self._make_optional_info_box()
        optionalInfos = GTKUtils.add_padding(optionalInfos, 0, 5, 5, 5)
        vbox.pack_start(optionalInfos, False, False, 0)

        self.dia.vbox.pack_start(vbox, False, False, 0)
        self.dia.vbox.show_all()
        self.optionalInfosBox.hide()
        self.dia.window.raise_()
예제 #8
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)
예제 #9
0
 def __init__(self, app, allowNonanonymousMode=True):
   BaseDialog.BaseDialog.__init__(self, "%s Anonymity Selector" % (app.name), ("ok", "cancel"), None)
   self.app = app
   self.allowNonanonymousMode = allowNonanonymousMode
   
   titleLabel = gtk.Label()
   titleLabel.set_markup("<span size='x-large' weight='bold'>%s Anonymity Selector</span>"  % (self.app.name))
   titleLabel.set_justify(gtk.JUSTIFY_CENTER)
   
   vbox = gtk.VBox()
   vbox.pack_start(titleLabel, False, False, 5)
   infoTextLabel = WrapLabel.WrapLabel(infoText)
   infoTextLabel.set_justify(gtk.JUSTIFY_FILL)
   #keep the label from having no width
   infoTextLabel.set_size_request(300, -1)
   
   infoAndSlider = gtk.VBox()
   infoAndSlider.pack_start(infoTextLabel, False, False, 0)
   instructionBox = self._make_instruction_box()
   infoAndSlider.pack_start(instructionBox, False, False, 0)
   #get the appropriate path length from the app
   if not self.allowNonanonymousMode or self.app.useTor:
     pathLength = self.app.settings.pathLength
   else:
     pathLength = 0
   anonymityBox = self._make_slider_box(pathLength)  
   infoAndSlider.pack_start(anonymityBox, False, False, 0)
   infoAndSlider = GTKUtils.add_padding(infoAndSlider, 5)
   infoAndSlider = GTKUtils.add_frame(infoAndSlider, name='Choose Your Anonymity Level')
   vbox.pack_start(infoAndSlider, False, False, 0)
   
   optionalInfos = self._make_optional_info_box()
   optionalInfos = GTKUtils.add_padding(optionalInfos, 0, 5, 5, 5)
   vbox.pack_start(optionalInfos, False, False, 0)
   
   self.dia.vbox.pack_start(vbox, False, False, 0)
   self.dia.vbox.show_all()
   self.optionalInfosBox.hide()
   self.dia.window.raise_()
예제 #10
0
    def _make_exit_traffic_box(self):
        def make_exit_row(labelText):
            #make the widgets
            label = gtk.Label()
            label.set_markup("<span size='large'>%s</span>" % (labelText))
            entry = SettingsDisplay.make_entry("bool", True)
            #and pack them together
            box = gtk.HBox()
            box.pack_start(label, False, False, 0)
            box.pack_end(entry.entry, False, False, 0)
            return (entry, box)

        #make widgets
        exitTrafficLabel = gtk.Label()
        exitTrafficLabel.set_markup(
            "<span size='large' weight='bold'>Exit Traffic Permissions:</span>"
        )
        exitTrafficLabel.set_alignment(0.0, 0.5)
        self.webTrafficEntry, webBox = make_exit_row("   Allow Web Traffic")
        self.btTrafficEntry, btBox = make_exit_row(
            "   Allow BitTorrent Traffic")
        self.dhtTrafficEntry, dhtBox = make_exit_row("   Allow DHT Traffic")
        risksLink = GTKUtils.make_html_link("What are the risks?", "")
        risksLink.label.set_alignment(0.0, 0.5)

        #pack them together:
        box = gtk.VBox(spacing=PADDING)
        box.pack_start(exitTrafficLabel, False, False, 0)
        box.pack_start(btBox, False, False, 0)
        box.pack_start(webBox, False, False, 0)
        box.pack_start(dhtBox, False, False, 0)
        box.pack_start(risksLink, False, False, 0)
        box = GTKUtils.add_padding(box, PADDING)
        frame = GTKUtils.add_frame(box, width=0)
        frame.show_all()
        return frame
예제 #11
0
    def __init__(self, bankApp):
        ListenerMixin.ListenerMixin.__init__(self)
        self.username = None
        self.password = None

        self._start_listening_for_event("login_success", bankApp,
                                        self.on_login_success)
        self._start_listening_for_event("login_failure", bankApp,
                                        self.on_login_failure)

        dia = gtk.Dialog("Login", None, 0, None)

        dia.connect("destroy", self.destroy_cb)
        #    dia.connect("expose_event", self.expose_cb)

        self.started = False
        self.succeeded = False

        self.loginButton = dia.add_button("Login", gtk.RESPONSE_OK)
        self.quitButton = dia.add_button("Quit", gtk.RESPONSE_CANCEL)

        #username field
        self.usernameLabel = gtk.Label("Username")
        self.nameEntry = gtk.Entry()
        self.nameEntry.set_max_length(50)
        self.nameEntry.connect("activate", self.enter_callback)

        #password field
        self.pwLabel = gtk.Label("Password")
        self.pwEntry = gtk.Entry()
        self.pwEntry.set_max_length(50)
        #so people cant see our password:
        self.pwEntry.set_visibility(False)
        self.pwEntry.connect("activate", self.enter_callback)

        resetPasswordLink = GTKUtils.make_html_link(
            "Forgot your password?",
            "%s/accounts/resetPassword/" % (ProgramState.Conf.BASE_HTTP))
        makeAccountLink = GTKUtils.make_html_link(
            "Need an account?",
            "%s/accounts/register/" % (ProgramState.Conf.BASE_HTTP))

        #put them in a nice little table
        table = gtk.Table(4, 2, True)
        table.attach(self.usernameLabel, 0, 1, 0, 1)
        table.attach(self.nameEntry, 1, 2, 0, 1)
        table.attach(makeAccountLink, 1, 2, 1, 2)
        table.attach(self.pwLabel, 0, 1, 2, 3)
        table.attach(self.pwEntry, 1, 2, 2, 3)
        table.attach(resetPasswordLink, 1, 2, 3, 4)

        self.savePassCheck = gtk.CheckButton("Remember Username/Password")

        #A text entry telling the user what to do:
        self.label = WrapLabel.WrapLabel()
        self.label.set_markup(
            "<span weight='bold'>Use your account name and password from the BitBlinder website!</span>"
        )
        align = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=1.0, yscale=0.0)
        align.add(self.label)
        align.set_padding(10, 10, 5, 5)

        dia.vbox.pack_start(GTKUtils.add_frame(align), True, True, 10)
        dia.vbox.pack_start(table, True, True, 0)
        dia.vbox.pack_start(self.savePassCheck, True, True, 10)

        #load a global config that said whether to store the last user that logged in (and his password)
        settings = GlobalSettings.load()

        self.nameEntry.set_text(settings.username)
        self.pwEntry.set_text(settings.password)
        self.savePassCheck.set_active(settings.save_password)

        #connect the handler:
        dia.connect("response", self.on_response)
        self.dia = dia
예제 #12
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
예제 #13
0
    def create(self):
        #    titleLabel = gtk.Label()
        #    titleLabel.set_markup("<span size='x-large' weight='bold'>Firefox Controls</span>")
        descriptionLabel = WrapLabel.WrapLabel("")
        descriptionLabel.set_markup(
            "<span size='x-large' weight='bold'>Important:  Flash is NOT supported yet!</span>\n\nAlso, DO NOT leave Firefox open if you are not using it!  Some website might keep sending traffic and cause you to lose credits over time\n\nThese will eventually be integrated into an extension inside of Firefox."
        )

        #make the controls:
        def make_button_row(labelText, callback, imageFile, descriptionText):
            button = GTKUtils.make_image_button(labelText,
                                                callback,
                                                imageFile,
                                                iconSize=32)
            button.set_size_request(200, -1)
            label = WrapLabel.WrapLabel(descriptionText)
            label.set_size_request(200, -1)
            box = gtk.HBox(spacing=3 * PADDING)
            box.pack_start(button, False, False, 0)
            box.pack_start(label, False, False, 0)
            return (box, button)

        anonRow, self.anonButton = make_button_row(
            "Anonymity Level", self._anonymity_cb, "identity.png",
            "Control how fast and anonymous your Firefox traffic will be.")
        circuitRow, circuitButton = make_button_row(
            "New Circuit", self._new_circuit_cb, "network.png",
            "Get a new circuit (and IP address) for Firefox traffic.  The new circuit might be faster or slower."
        )
        ffRow, self.ffButton = make_button_row(
            "Launch", self.toggle_firefox, "grey.png",
            "Start or stop our anonymous version of Firefox.")
        visibilityRow, self.visibilityButton = make_button_row(
            "Hide", self._hide_cb, "hide.png",
            "Hide these controls.  They can always be opened from the system tray icon or file menu."
        )
        controlBox = gtk.VBox(spacing=PADDING)
        controlBox.pack_start(ffRow, False, False, 0)
        controlBox.pack_start(anonRow, False, False, 0)
        controlBox.pack_start(circuitRow, False, False, 0)
        controlBox.pack_start(visibilityRow, False, False, 0)
        controlBox = GTKUtils.add_padding(controlBox, PADDING)
        controlBox = GTKUtils.add_frame(controlBox, name="Controls")

        def on_launched(button):
            self.start()
            self.ffButton.label.set_text("Starting...")
            self.ffButton.image.set_from_pixbuf(Images.YELLOW_CIRCLE)

        self._start_listening_for_event("launched", self.app, on_launched)

        def on_started(button):
            self.ffButton.label.set_text("Stop")
            self.ffButton.image.set_from_pixbuf(Images.GREEN_CIRCLE)

        self._start_listening_for_event("started", self.app, on_started)

        def on_stopped(button):
            self.ffButton.label.set_text("Closing...")
            self.ffButton.image.set_from_pixbuf(Images.YELLOW_CIRCLE)

        self._start_listening_for_event("stopped", self.app, on_stopped)

        def on_finished(button):
            self.ffButton.label.set_text("Start")
            self.ffButton.image.set_from_pixbuf(Images.GREY_CIRCLE)

        self._start_listening_for_event("finished", self.app, on_finished)

        #pack everything into our window:
        box = gtk.VBox(spacing=PADDING)
        #    box.pack_start(titleLabel, False, False, 0)
        box.pack_start(descriptionLabel, False, False, 0)
        box.pack_start(controlBox, False, False, 0)
        box.show()

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

        vbox = gtk.VBox()
        self.menuBar = FirefoxMenuBar(self.controller)
        vbox.pack_start(self.menuBar.create_menus(), False, False, 0)
        vbox.pack_start(frame, True, True, 0)
        vbox.show_all()
        self.add(vbox)
예제 #14
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
예제 #15
0
  def __init__(self, bankApp):
    ListenerMixin.ListenerMixin.__init__(self)
    self.username = None
    self.password = None
    
    self._start_listening_for_event("login_success", bankApp, self.on_login_success)
    self._start_listening_for_event("login_failure", bankApp, self.on_login_failure)

    dia = gtk.Dialog("Login", None, 0, None)

    dia.connect("destroy", self.destroy_cb)
#    dia.connect("expose_event", self.expose_cb)
    
    self.started = False
    self.succeeded = False
    
    self.loginButton = dia.add_button("Login", gtk.RESPONSE_OK)
    self.quitButton = dia.add_button("Quit", gtk.RESPONSE_CANCEL)
    
    #username field
    self.usernameLabel = gtk.Label("Username")
    self.nameEntry = gtk.Entry()
    self.nameEntry.set_max_length(50)
    self.nameEntry.connect("activate", self.enter_callback)
    
    #password field
    self.pwLabel = gtk.Label("Password")
    self.pwEntry = gtk.Entry()
    self.pwEntry.set_max_length(50)
    #so people cant see our password:
    self.pwEntry.set_visibility(False)
    self.pwEntry.connect("activate", self.enter_callback)
    
    resetPasswordLink = GTKUtils.make_html_link("Forgot your password?", "%s/accounts/resetPassword/" % (ProgramState.Conf.BASE_HTTP))
    makeAccountLink = GTKUtils.make_html_link("Need an account?", "%s/accounts/register/" % (ProgramState.Conf.BASE_HTTP))
    
    #put them in a nice little table
    table = gtk.Table(4, 2, True)
    table.attach(self.usernameLabel, 0, 1, 0, 1)
    table.attach(self.nameEntry, 1, 2, 0, 1)
    table.attach(makeAccountLink, 1, 2, 1, 2)
    table.attach(self.pwLabel, 0, 1, 2, 3)
    table.attach(self.pwEntry, 1, 2, 2, 3)
    table.attach(resetPasswordLink, 1, 2, 3, 4)
    
    self.savePassCheck = gtk.CheckButton("Remember Username/Password")
    
    #A text entry telling the user what to do:
    self.label = WrapLabel.WrapLabel()
    self.label.set_markup("<span weight='bold'>Use your account name and password from the BitBlinder website!</span>")
    align = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=1.0, yscale=0.0)
    align.add(self.label)
    align.set_padding(10, 10, 5, 5)

    dia.vbox.pack_start(GTKUtils.add_frame(align), True, True, 10)
    dia.vbox.pack_start(table, True, True, 0)
    dia.vbox.pack_start(self.savePassCheck, True, True, 10)
    
    #load a global config that said whether to store the last user that logged in (and his password)
    settings = GlobalSettings.load()
    
    self.nameEntry.set_text(settings.username)
    self.pwEntry.set_text(settings.password)
    self.savePassCheck.set_active(settings.save_password)

    #connect the handler:
    dia.connect("response", self.on_response)
    self.dia = dia
예제 #16
0
 def __init__(self, controller):
   self.window = gtk.Window()
   self.window.set_title("Out of credits!")
   self.controller = controller
   
   self.catch_event("settings_changed")
   self.window.connect("destroy", self._destroy_cb)
   
   #tell the user what happened
   headerLabel = gtk.Label()
   headerLabel.set_markup("<span size='x-large' weight='bold'>You have spent all your credits.\n</span>")
   headerImage = gtk.Image()
   headerImage.set_from_pixbuf(Images.make_icon("warning.png", 32))
   headerBox = gtk.HBox(spacing=PADDING)
   headerBox.pack_start(headerImage, False, False, 0)
   headerBox.pack_start(headerLabel, False, False, 0)
   descriptionLabel = WrapLabel.WrapLabel("You must get more credits before you can keep sending traffic through BitBlinder.  All users are given a small number of new credits each hour.\n\nYou can keep downloading with BitTorrent by disabling anonymity (upper right of the BitTorrent interface), but you will obviously not be anonymous!")
   descriptionBox = gtk.VBox(spacing=PADDING)
   descriptionBox.pack_start(headerBox, False, False, 0)
   descriptionBox.pack_start(descriptionLabel, False, False, 0)
   descriptionBox.show_all()
   
   #make some help text to explain what credits are
   creditLabel = WrapLabel.WrapLabel(CREDITS_HELP_TEXT)
   creditLabel = GTKUtils.add_padding(creditLabel, PADDING)
   creditLabel.show()
   creditExplanation = OptionalToggleFrame.OptionalToggleFrame(creditLabel, "What are credits?")
   creditExplanation = GTKUtils.add_padding(creditExplanation, PADDING)
   creditExplanation.show()
   
   #only appears if the user is still not configured as a relay
   relayButton = GTKUtils.make_image_button('<span size="large">Start Relay</span>', self._start_relay_cb, "power_off.png")
   relayLabel = WrapLabel.WrapLabel()
   relayLabel.set_markup('<span size="large" weight="bold">You should set up a relay!  </span><span size="large">You will earn credits MUCH more quickly by being a relay and sending traffic for other users.</span>')
   self.relayRow = gtk.HBox(spacing=PADDING)
   spacingBox = gtk.VBox()
   spacingBox.pack_start(relayButton, True, False, 0)
   self.relayRow.pack_start(spacingBox, False, False, 0)
   self.relayRow.pack_start(relayLabel, True, True, 0)
   self.relayRow = GTKUtils.add_frame(self.relayRow, width=PADDING, name="Relay Setup")
   self.relayRow.show_all()
   
   #if we should always check
   self.alwaysShow = gtk.CheckButton("Always tell you when your credits run out.")
   self.alwaysShow.set_active(True)
   self.alwaysShow.show()
   
   #make the bottom button row
   waitButton = GTKUtils.make_image_button('<span size="large">Wait for Credits</span>', self._wait_cb, "time.png")
   purchaseButton = GTKUtils.make_image_button('<span size="large">Purchase Credits</span>', self._purchase_cb, "money.png")
   buttonRow = gtk.HBox(spacing=PADDING)
   buttonRow.pack_end(waitButton, False, False, 0)
   buttonRow.pack_end(purchaseButton, False, False, 0)
   buttonRow = GTKUtils.add_padding(buttonRow, PADDING)
   buttonRow.show_all()
   
   #pack everything together
   topBox = gtk.VBox(spacing=PADDING)
   topBox.pack_start(descriptionBox, False, False, 0)
   topBox.pack_start(creditExplanation, False, False, 0)
   topBox.pack_start(self.relayRow, False, False, 0)
   topBox.pack_start(self.alwaysShow, False, False, 0)
   topBox.show()
   topBox = GTKUtils.add_padding(topBox, PADDING)
   topBox.show()
   vbox = gtk.VBox()
   vbox.pack_start(topBox, False, False, 0)
   sep = gtk.HSeparator()
   sep.show()
   vbox.pack_end(buttonRow, False, False, 0)
   vbox.pack_end(sep, False, False, 0)
   vbox.show()
   
   #and add it into our dialog
   self.window.add(vbox)
   self.window.show()
예제 #17
0
 def __init__(self, applications, root):
   """Responsible for user interface to settings.
   @param applications: BitBlinder applications to show settings for
   @type applications: list
   @param showGlobalSettings: Bool to show the global settings- ie, username and pw
   """
   #: settings name to application instance
   self.applications = applications
   #create the dialog:
   self.dia = gtk.Dialog("Settings", root, gtk.DIALOG_DESTROY_WITH_PARENT, None)
   #: the collection of displays, organized as [appName][categoryName]
   self.settingsDisplays = {}
   
   #: the Application that corresponds to the currently selected row on the left
   self.selectedApp = None
   #: the SettingsDisplay that corresponds to the currently selected row on the left
   self.selectedDisplay = None
   #: the settings category that corresponds to the currently selected row on the left
   self.selectedCategory = None
   
   self.mdl = gtk.TreeStore(gobject.TYPE_STRING)
   self.view = gtk.TreeView(self.mdl)
   #make column
   column = gtk.TreeViewColumn("Category")
   #basic string renderer for the data in the column
   column.cell = gtk.CellRendererText()
   #add the renderer to the column...  idk if you can add more than one
   column.pack_start(column.cell, True)
   #add the column to the treeview
   self.view.append_column(column)
   column.set_attributes(column.cell, text=0)
   self.view.connect("cursor-changed", self.row_changed)
   
   #Make the apply/ok/cancel buttons:
   i = 1
   #for name in ("Ok", "Apply", "Defaults", "Cancel"):
   for name in ("Ok", "Apply", "Cancel"):
     self.prevButton = self.dia.add_button(name, i)
     i += 1
   
   #glue:
   self.hbox = gtk.HBox()
   vbox = gtk.VBox()
   vbox.pack_start(self.hbox, True, True, 0)
   self.hbox.show()
   
   hbox = gtk.HBox()
   align = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=1.0, yscale=1.0)
   align.add(GTKUtils.add_frame(self.view))
   align.set_padding(0, 0, 10, 0)
   align.show_all()
   hbox.pack_start(align, False, False, 0)
   hbox.pack_end(vbox, True, True, 0)
   hbox.show()
   vbox.show()
   
   for name, app in self.applications.iteritems():
     #create the application row:
     self.settingsDisplays[app.get_settings_name()] = {}
     rowIter = self.mdl.append(None, [app.get_settings_name()])
     #make permanent reference for the row:
     app.settingsTreeRow = gtk.TreeRowReference(self.mdl, self.mdl.get_string_from_iter(rowIter))
     #make each subcategory:
     for category in app.settings.categories.keys():
       self.settingsDisplays[app.get_settings_name()][category] = SettingsDisplay.SettingsDisplay(app.settings, category)
       if category == "":
         continue
       if category == "DEV" and not ProgramState.DEBUG:
         continue
       self.mdl.append(rowIter, [category])
   
   self.dia.vbox.pack_start(hbox, True, True, 10)
   #connect the handler:
   self.dia.connect("response", self.on_response)
   #self.dia.connect("destroy", self.destroy_cb)
   self.dia.connect('delete-event', self.hide)
   #start the dialog
   self.dia.vbox.set_size_request(700, 500)
   self.dia.show()