예제 #1
0
    def open_filechooser(self, widget):
        filechooser_opening_dialog = Gtk.FileChooserDialog(
            "Choose Keepass Database", self, Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN,
             Gtk.ResponseType.OK))

        filter_text = Gtk.FileFilter()
        filter_text.set_name("Keepass 2 Database")
        filter_text.add_mime_type("application/x-keepass2")
        filechooser_opening_dialog.add_filter(filter_text)

        response = filechooser_opening_dialog.run()
        if response == Gtk.ResponseType.OK:
            logging_manager.log_debug(
                "File selected: " + filechooser_opening_dialog.get_filename())
            filechooser_opening_dialog.close()

            folder_path = filechooser_opening_dialog.get_current_folder() + "/"
            file_path = filechooser_opening_dialog.get_filename()

            tab_title = self.create_tab_title_from_filepath(
                file_path.replace(folder_path, ""))
            self.start_database_opening_routine(
                tab_title, filechooser_opening_dialog.get_filename())
        elif response == Gtk.ResponseType.CANCEL:
            logging_manager.log_debug("File selection canceled")
            filechooser_opening_dialog.close()
예제 #2
0
    def on_unlock_database_button_clicked(self, widget):
        password_unlock_input = self.builder.get_object(
            "password_unlock_input")

        if password_unlock_input.get_text() != "":
            try:
                self.keepass_loader = KeepassLoader(
                    self.database_filepath, password_unlock_input.get_text())
                self.open_database_page()

                logging_manager.log_debug(
                    "Opening of database was successfull")

            #OSError:master key invalid
            except (OSError):
                password_unlock_input.grab_focus()
                password_unlock_input.get_style_context().add_class("error")
                self.clear_input_fields()

                logging_manager.log_debug(
                    "Could not open database, wrong password")
예제 #3
0
    def on_keyfile_open_button_clicked(self, widget):
        logging_manager.log_debug("Opening keyfile chooser dialog")
        logging_manager.log_error("Feature currently not working")

        keyfile_chooser_dialog = Gtk.FileChooserDialog(
            "Choose a keyfile", self.window, Gtk.FileChooserAction.OPEN,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN,
             Gtk.ResponseType.OK))
        filter_text = Gtk.FileFilter()
        filter_text.set_name("Keyfile")
        filter_text.add_mime_type("application/octet-stream")
        keyfile_chooser_dialog.add_filter(filter_text)

        response = keyfile_chooser_dialog.run()
        if response == Gtk.ResponseType.OK:
            logging_manager.log_debug("File selected: " +
                                      keyfile_chooser_dialog.get_filename())
            keyfile_chooser_dialog.close()

            keyfile_path = keyfile_chooser_dialog.get_filename()
            self.stack.set_visible_child(self.stack.get_child_by_name("page2"))
            keyfile_name = self.builder.get_object("keyfile_name")
            keyfile_name.set_text(keyfile_path)

        elif response == Gtk.ResponseType.CANCEL:
            logging_manager.log_debug("File selection canceled")
            keyfile_chooser_dialog.close()
예제 #4
0
    def first_start_screen(self):
        if config_manager.has_group("history") and config_manager.get_string(
                "history", "last-opened-db") != "" and exists(
                    config_manager.get_string("history", "last-opened-db")):
            logging_manager.log_debug(
                "Found last opened database entry (" +
                config_manager.get_string("history", "last-opened-db") + ")")

            regex = re.search(
                "^(([A-Z]:)?[\.]?[\\{1,2}/]?.*[\\{1,2}/])*(.+)\.(.+)",
                config_manager.get_string("history", "last-opened-db"))
            tab_title = regex[0]
            self.start_database_opening_routine(
                tab_title,
                config_manager.get_string("history", "last-opened-db"))
        else:
            logging_manager.log_debug(
                "No / Not valid last opened database entry found.")
            builder = Gtk.Builder()
            builder.add_from_file("ui/main_headerbar.ui")

            self.first_start_grid = builder.get_object("first_start_grid")
            self.add(self.first_start_grid)
예제 #5
0
    def on_keyfile_unlock_button_clicked(self, widget):
        keyfile_name = self.builder.get_object("keyfile_name")
        keyfile_path = keyfile_name.get_text()
        keyfile_open_button = self.builder.get_object("keyfile_open_button")
        try:
            self.keepass_loader = KeepassLoader(self.database_filepath,
                                                keyfile_path)
            self.open_database_page()
            logging_manager.log_debug(
                "Database successfully with keyfile opened")

        except (OSError):
            self.stack.set_visible_child(self.stack.get_child_by_name("page1"))
            keyfile_open_button.get_style_context().add_class(
                Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION)
            keyfile_open_button.set_label("Try again")

            logging_manager.log_debug("Invalid keyfile chosen")
            logging_manager.log_debug("Keyfile path: " + keyfile_path)