Пример #1
0
 def add_user_below3(self, widget):
     (model, node) = self.arw["treeview2"].get_selection().get_selected()
     x = ask_text(self.arw["window1"], "Name of the new user :"******"")
     if x is None:
         return
     else:
         x = self.controller.format_name(x)
         address = ask_text(self.arw['window1'], "Enter address of the user", "")
         if ip_address_test(address) or mac_address_test(address):
             self.controller.maclist[x] = [address]
         self.firewall_store.insert_after(node, [x] + [""] * 9 + [0, 1, 0, 0, 0, "", "#ffffff"])
Пример #2
0
 def proxy_group_add_item(self, widget):
     """Add a new domain to the list"""
     text = ask_text(self.proxy_group_window, _("Enter a domain name"))
     if not text:
         return
     iter = self.proxy_group_domain_store.append()
     self.proxy_group_domain_store.set_value(iter, 0, text)
Пример #3
0
    def check_mac_and_create_config(self):
        """Check if there is a configuration for the user's mac address and optionally create a new configuration
        for them"""

        if not self.mymac or self.mymac in self.maclist:
            return

        # Mac Address does not yet exist, ask the user to create a configuration
        self.arw["your_mac_address_label"].set_text(self.mymac)
        self.arw['user_mac_address_dialog'].show()
        response = self.arw['user_mac_address_dialog'].run()
        self.arw['user_mac_address_dialog'].hide()
        if response == Gtk.ResponseType.YES:
            # Create default configuration
            rule = ask_text(self.arw['window1'],
                            _("Enter name for configuration"))
            if not rule:
                rule = 'default'

            # Pre fill in details in the first-run assistant
            self.assistant.show_assistant_create_pre_enter(
                rule, self.mymac, rule)
            """
            self.arw['newly_created_summary'].show()
            self.arw['newly_created_summary'].run()
            self.arw['newly_created_summary'].hide()

            # Jump to the created rule
            self.arw['notebook3'].set_current_page(1)
            self.proxy_users.select_rule(rule)
            """

        elif response == Gtk.ResponseType.APPLY:
            # Show the assistant
            self.assistant.show_assistant_create_with_mac(self.mymac)
Пример #4
0
    def ask_user_dialog(self, level, text=""):
        if level == 1:
            new = _("Name of the new category")
        else:
            new = _("Name of the new user")

        return ask_text(self.arw["window1"], new, text)
Пример #5
0
 def ports_new_group(self, widget):
     """Create a new port group"""
     name = ask_text(self.arw['ports_window'], _('Enter group name'))
     if not name:
         return
     iter = self.arw['ports_list'].append([name, ''])
     valid, iter = self.arw['ports_tree'].get_model().convert_child_iter_to_iter(iter)
     self.arw['ports_tree'].get_selection().select_iter(iter)
Пример #6
0
 def profile_add_new(self, widget):
     """Add a new configuration"""
     profile_name = ask_text(self.window, "Enter name for profile")
     if profile_name:
         new_iter = self.profiles_store.append()
         self.profiles_store.set_value(new_iter, COLUMN_NAME, profile_name)
         self.profiles_store.set_value(new_iter, COLUMN_MODE, 'local')
         self.arw['profiles_tree'].get_selection().select_iter(new_iter)
Пример #7
0
 def new_proxy_group(self, widget):
     """Create a new filter group and open it for editing"""
     name = ask_text(self.arw['window1'], _("New group name"))
     if not name:
         return
     new_iter = self.current_store.append()
     self.current_store.set_value(new_iter, 0, name)
     self.current_store.set_value(new_iter, 1, '')
     self.edit_group(new_iter)
Пример #8
0
 def edit_user3(self, widget):
     (model, node) = self.arw["treeview2"].get_selection().get_selected()
     name = model.get_value(node, 0)
     x = ask_text(self.arw["window1"], "Name of the user :", name)
     if x is None:
         return
     else:
         x = self.controller.format_name(x)
         self.firewall_store.set(node, [0], [x])
Пример #9
0
    def rename_item(self, widget):
        """Rename an entry"""
        model, iter = self.widgets['groups_tree'].get_selection().get_selected(
        )
        name = model.get_value(iter, 0)
        value = ask_text(self.widgets['groups_window'], _("Rename Group"),
                         name)

        iter = model.convert_iter_to_child_iter(iter)
        model.get_model().set_value(iter, 0, value)
        self.groups_changed = True
Пример #10
0
 def edit_rule(self, widget):
     (model, node) = self.arw["treeview3"].get_selection().get_selected()
     name = model.get_value(node, 0)
     x = ask_text(self.arw["window1"], "Name of the rule :",
                  cleanhtml(name))
     if x is None:
         return
     else:
         # x = format_name(x)
         # Set format:
         if model.get_value(node, 1) == 'off':
             x = '<s>' + x + '</s>'
         self.current_store.set(node, [0], [x])
Пример #11
0
 def add_rule_below(self, widget):
     # add rule in the filter tab
     (model, node) = self.arw["treeview3"].get_selection().get_selected()
     x = ask_text(self.arw["window1"], _("Name of the new rule :"), "")
     if x is None:
         return
     else:
         # name = format_name(x)
         name = x
         iter1 = self.current_store.insert_after(node, [
             name, "on", "allow", "", "", "", "", "", "", "", "", 0, 0, 1,
             1, "#009900", "#ffffff", "", "", 0, 0
         ])
Пример #12
0
    def add_new_group(self, widget):
        """Create a new group entry"""
        if self.ask_verified_save_changes():
            # Do save?
            self.updated_verified(widget)

        name = ask_text(self.widgets['main_window'], "Enter the group name")
        if name:
            self.verified_dirty = True
            self.new_item = True
            self.widgets['verified_entry_name'].set_text(name)
            self.widgets['verified_entry_checkbox'].set_active(True)
            self.widgets['verified_buffer'].set_text("")
            self.widgets['verified_textview'].grab_focus()
Пример #13
0
    def add_item(self, widget):
        """Add a new group"""
        value = ask_text(self.widgets['groups_window'], _("Add Group"), "")
        if not value:
            return
        iter = self.widgets['groups_store'].append()
        self.widgets['groups_store'].set_value(iter, 0, value)
        self.widgets['groups_store'].set_value(iter, 1, '')

        # Select the new group
        sort_model = self.widgets['groups_tree'].get_model()
        model, sort_iter = sort_model.convert_child_iter_to_iter(iter)
        self.widgets['groups_tree'].set_cursor(sort_model.get_path(sort_iter))

        # Set focus to the text area
        self.widgets['groups_view'].grab_focus()
Пример #14
0
    def add_new_category(self, widget):
        """Create a new category entry"""
        name = ask_text(self.widgets['main_window'], "Please enter the category name")
        if not name:
            return

        parent_id = None

        model, iter = self.widgets['verified_treeview'].get_selection().get_selected()
        if iter:
            iter = model.convert_iter_to_child_iter(iter)
            model = model.get_model()

            if model.get_value(iter, COLUMN_TYPE) == TYPE_CATEGORY:
                parent_id = model.get_value(iter, COLUMN_ID)

        ok, err = self.database.create_category(name, parent_id)
        if not ok:
            message_dialog("Error", err)
        self.refresh_database()
Пример #15
0
    def rename_user(self, widget):
        (model, node) = self.arw["treeview1"].get_selection().get_selected()
        name = model.get_value(node, 0)
        x = ask_text(self.arw["window1"], "Name of the user :", name)
        if x is None:
            return
        else:
            # Rename all existing entries in the filter_store
            for item in self.controller.filter_store:
                users = (item[5] or '').split('\n')
                if name in users:
                    i = users.index(name)
                    users[i] = x
                self.controller.filter_store.set_value(item.iter, 5,
                                                       '\n'.join(users))
                # self.controller.load_filter_user(self.arw['treeview3'], event=None)
            # update the mac list
            self.controller.maclist[x] = self.controller.maclist[name]
            del self.controller.maclist[name]

            # Refresh the proxy users list
            self.controller.filter_rules.update_filter_user_list()

            self.users_store.set(node, [0], [x])
Пример #16
0
 def proxy_group_edit_item(self, widget):
     """When right clicked, Edit the selected item from the list"""
     model, iter = self.arw['proxy_group_domain_tree'].get_selection().get_selected()
     domain = model.get_value(iter, 0)
     domain = ask_text(self.proxy_group_window, _("Edit domain name"), domain)
     model.set_value(iter, 0, domain)