Ejemplo n.º 1
0
 def push_history(self, history_ids):
     """
         Push history ids
         @param history_ids as [int]
     """
     if Gio.NetworkMonitor.get_default().get_network_available() and\
             self.__username and self.__password:
         task_helper = TaskHelper()
         task_helper.run(self.__push_history, history_ids)
Ejemplo n.º 2
0
 def __init__(self):
     """
         Create database tables or manage update if needed
     """
     self.thread_lock = Lock()
     self.__cancellable = Gio.Cancellable.new()
     self.__task_helper = TaskHelper()
     self.__phishing_mtime = int(time())
     self.__regex = None
Ejemplo n.º 3
0
 def __install_engine(self, uri, window):
     """
         Install engine from uri
         @param uri as str
         @param window as Window
     """
     task_helper = TaskHelper(self.__user_agent)
     task_helper.load_uri_content(uri, None, self.__on_engine_loaded,
                                  window)
Ejemplo n.º 4
0
 def remove_from_history(self, guid):
     """
         Remove history guid from remote history
         @param guid as str
     """
     if Gio.NetworkMonitor.get_default().get_network_available() and\
             self.__username and self.__password:
         task_helper = TaskHelper()
         task_helper.run(self.__remove_from_history, guid)
Ejemplo n.º 5
0
 def sync(self, loop=False, first_sync=False):
     """
         Start syncing, you need to check sync_status property
         @param loop as bool -> for GLib.timeout_add()
         @param first_sync as bool
     """
     if Gio.NetworkMonitor.get_default().get_network_available() and\
             self.__username and self.__password and not self.syncing:
         task_helper = TaskHelper()
         task_helper.run(self.__sync, first_sync)
     return loop
Ejemplo n.º 6
0
 def sync(self, loop=False, first_sync=False):
     """
         Start syncing, you need to check sync_status property
         @param loop as bool -> for GLib.timeout_add()
         @param first_sync as bool
     """
     if self.syncing or\
             not Gio.NetworkMonitor.get_default().get_network_available():
         return
     task_helper = TaskHelper()
     task_helper.run(self.__sync, (first_sync, ))
     return loop
Ejemplo n.º 7
0
 def __init__(self):
     """
         Init class
     """
     self.__helper = TaskHelper()
     self.__snapshot_id = None
     self.__save_favicon_timeout_id = None
     self.__cancellable = Gio.Cancellable()
     self.__initial_uri = None
     self.__favicon_width = {}
     self.__current_netloc = None
     self.connect("notify::uri", self.__on_uri_changed)
Ejemplo n.º 8
0
 def search_suggestions(self, value, cancellable, callback):
     """
         Search suggestions for value
         @param value as str
         @param cancellable as Gio.Cancellable
         @param callback as str
     """
     try:
         if not value.strip(" "):
             return
         uri = self.__suggest % GLib.uri_escape_string(value, None, True)
         task_helper = TaskHelper(self.__user_agent)
         task_helper.load_uri_content(uri, cancellable, callback,
                                      self.__encoding, value)
     except Exception as e:
         Logger.error("Search::search_suggestions(): %s", e)
Ejemplo n.º 9
0
 def search_suggestions(self, value, cancellable, callback):
     """
         Search suggestions for value
         @param value as str
         @param cancellable as Gio.Cancellable
         @param callback as str
     """
     try:
         if not value.strip(" "):
             return
         uri = self.__keyword % value
         task_helper = TaskHelper()
         task_helper.load_uri_content(uri, cancellable, callback,
                                      self.__encoding, value)
     except Exception as e:
         print("Search::search_suggestions():", e)
Ejemplo n.º 10
0
 def __init__(self):
     """
         Create database tables or manage update if needed
     """
     self.__cancellable = Gio.Cancellable.new()
     self.__task_helper = TaskHelper()
     # Lazy loading if not empty
     if not GLib.file_test(self.DB_PATH, GLib.FileTest.IS_REGULAR):
         try:
             if not GLib.file_test(EOLIE_DATA_PATH, GLib.FileTest.IS_DIR):
                 GLib.mkdir_with_parents(EOLIE_DATA_PATH, 0o0750)
             # Create db schema
             with SqlCursor(self) as sql:
                 sql.execute(self.__create_phishing)
                 sql.commit()
         except Exception as e:
             print("DatabasePhishing::__init__(): %s" % e)
Ejemplo n.º 11
0
 def push_password(self, user_form_name, user_form_value, pass_form_name,
                   pass_form_value, uri, form_uri, uuid):
     """
         Push password
         @param user_form_name as str
         @param user_form_value as str
         @param pass_form_name as str
         @param pass_form_value as str
         @param uri as str
         @param form_uri as str
         @param uuid as str
     """
     if Gio.NetworkMonitor.get_default().get_network_available():
         task_helper = TaskHelper()
         task_helper.run(self.__push_password,
                         (user_form_name, user_form_value, pass_form_name,
                          pass_form_value, uri, form_uri, uuid))
Ejemplo n.º 12
0
 def push_password(self, user_form_name, user_form_value, pass_form_name,
                   pass_form_value, uri, form_uri, uuid):
     """
         Push password
         @param user_form_name as str
         @param user_form_value as str
         @param pass_form_name as str
         @param pass_form_value as str
         @param uri as str
         @param form_uri as str
         @param uuid as str
     """
     if self.__username and self.__password:
         task_helper = TaskHelper()
         task_helper.run(self.__push_password, user_form_name,
                         user_form_value, pass_form_name, pass_form_value,
                         uri, form_uri, uuid)
Ejemplo n.º 13
0
 def _on_infobar_response(self, infobar, response_id):
     """
         Handle user response and remove wanted history ids
         @param infobar as Gtk.InfoBar
         @param response_id as int
     """
     if response_id == 1:
         active_id = self.__infobar_select.get_active_id()
         if active_id == TimeSpan.CUSTOM:
             (year, month, day) = self.__calendar.get_date()
             date = "%02d/%02d/%s" % (day, month + 1, year)
             atime = mktime(datetime.strptime(date, "%d/%m/%Y").timetuple())
         else:
             atime = int(time() - TimeSpanValues[active_id] / 1000000)
         task_helper = TaskHelper()
         task_helper.run(self.__clear_history, (atime, ))
     infobar.hide()
Ejemplo n.º 14
0
 def __init__(self):
     """
         Create database tables or manage update if needed
     """
     self.__cancellable = Gio.Cancellable.new()
     self.__task_helper = TaskHelper()
     f = Gio.File.new_for_path(self.DB_PATH)
     # Lazy loading if not empty
     if not f.query_exists():
         try:
             d = Gio.File.new_for_path(EOLIE_LOCAL_PATH)
             if not d.query_exists():
                 d.make_directory_with_parents()
             # Create db schema
             with SqlCursor(self) as sql:
                 sql.execute(self.__create_adblock)
                 sql.commit()
         except Exception as e:
             print("DatabaseAdblock::__init__(): %s" % e)
Ejemplo n.º 15
0
 def _on_sync_button_clicked(self, button):
     """
         Connect to Mozilla Sync to get tokens
         @param button as Gtk.Button
     """
     icon_name = self.__result_image.get_icon_name()[0]
     if icon_name == "network-transmit-receive-symbolic":
         El().sync_worker.stop(True)
         El().sync_worker.delete_secret()
         self.__setup_sync_button(False)
     else:
         El().sync_worker.delete_secret()
         self.__result_label.set_text(_("Connecting…"))
         button.set_sensitive(False)
         self.__result_image.set_from_icon_name("content-loading-symbolic",
                                                Gtk.IconSize.MENU)
         task_helper = TaskHelper()
         task_helper.run(self.__connect_mozilla_sync,
                         (self.__login_entry.get_text(),
                          self.__password_entry.get_text()))
Ejemplo n.º 16
0
    def __on_entry_changed_timeout(self, entry, value):
        """
            Update popover search if needed
            @param entry as Gtk.Entry
            @param value as str
        """
        task_helper = TaskHelper()
        self.__entry_changed_id = None

        self.__window.container.current.webview.add_text_entry(value)

        # Populate completion model
        task_helper.run(self.__populate_completion, value)

        self.__cancellable.cancel()
        self.__cancellable.reset()
        parsed = urlparse(value)

        network = Gio.NetworkMonitor.get_default().get_network_available()
        is_uri = parsed.scheme in ["about, http", "file", "https", "populars"]
        if is_uri:
            self.__popover.set_search_text(parsed.netloc + parsed.path)
        else:
            self.__popover.set_search_text(value)

        # Remove any pending suggestion search
        if self.__suggestion_id is not None:
            GLib.source_remove(self.__suggestion_id)
            self.__suggestion_id = None
        # Search for suggestions if needed
        if App().settings.get_value("enable-suggestions") and\
                value and not is_uri and network:
            self.__suggestion_id = GLib.timeout_add(
                50, self.__on_suggestion_timeout, value)
        task_helper.run(self.__search_in_current_views, value)
        self.__entry.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY,
                                             "system-search-symbolic")
        self.__entry.set_icon_tooltip_text(Gtk.EntryIconPosition.PRIMARY, "")
Ejemplo n.º 17
0
    def __init__(self, window):
        """
            Init dialog
            @param window as Window
        """
        self.__window = window
        self.__helper = PasswordsHelper()
        builder = Gtk.Builder()
        builder.add_from_resource("/org/gnome/Eolie/SettingsDialog.ui")

        self.__settings_dialog = builder.get_object("settings_dialog")
        self.__settings_dialog.set_transient_for(window)
        # self.__settings_dialog.connect("destroy", self.__on_destroy)

        if False:
            self.__settings_dialog.set_title(_("Preferences"))
        else:
            headerbar = builder.get_object("header_bar")
            headerbar.set_title(_("Preferences"))
            self.__settings_dialog.set_titlebar(headerbar)

        download_chooser = builder.get_object("download_chooser")
        dir_uri = App().settings.get_value("download-uri").get_string()
        if not dir_uri:
            directory = GLib.get_user_special_dir(
                GLib.UserDirectory.DIRECTORY_DOWNLOAD)
            if directory is not None:
                dir_uri = GLib.filename_to_uri(directory, None)
        if dir_uri:
            download_chooser.set_uri(dir_uri)
        else:
            download_chooser.set_uri("file://" + GLib.getenv("HOME"))

        open_downloads = builder.get_object("open_downloads_check")
        open_downloads.set_active(App().settings.get_value("open-downloads"))

        self.__start_page_uri = builder.get_object("start_page_uri")
        combo_start = builder.get_object("combo_start")
        start_page = App().settings.get_value("start-page").get_string()
        if start_page.startswith("http"):
            combo_start.set_active_id("address")
            self.__start_page_uri.set_text(start_page)
            self.__start_page_uri.show()
        else:
            combo_start.set_active_id(start_page)

        remember_session = builder.get_object("remember_sessions_check")
        remember_session.set_active(
            App().settings.get_value("remember-session"))

        suggestions = builder.get_object("suggestions_check")
        suggestions.set_active(App().settings.get_value("enable-suggestions"))

        enable_dev_tools = builder.get_object("dev_tools_check")
        enable_dev_tools.set_active(
            App().settings.get_value("developer-extras"))

        enable_plugins = builder.get_object("plugins_check")
        enable_plugins.set_active(App().settings.get_value("enable-plugins"))

        self.__fonts_grid = builder.get_object("fonts_grid")
        use_system_fonts = builder.get_object("system_fonts_check")
        use_system_fonts.set_active(
            App().settings.get_value("use-system-fonts"))
        self.__fonts_grid.set_sensitive(
            not App().settings.get_value("use-system-fonts"))

        sans_serif_button = builder.get_object("sans_serif_button")
        sans_serif_button.set_font_name(
            App().settings.get_value("font-sans-serif").get_string())
        serif_button = builder.get_object("serif_button")
        serif_button.set_font_name(
            App().settings.get_value("font-serif").get_string())
        monospace_button = builder.get_object("monospace_button")
        monospace_button.set_font_name(
            App().settings.get_value("font-monospace").get_string())

        min_font_size_spin = builder.get_object("min_font_size_spin")
        min_font_size_spin.set_value(
            App().settings.get_value("min-font-size").get_int32())

        monitor_model = get_current_monitor_model(window)
        zoom_levels = App().settings.get_value("default-zoom-level")
        wanted_zoom_level = 1.0
        try:
            for zoom_level in zoom_levels:
                zoom_splited = zoom_level.split('@')
                if zoom_splited[0] == monitor_model:
                    wanted_zoom_level = float(zoom_splited[1])
        except:
            pass
        default_zoom_level = builder.get_object("default_zoom_level")
        percent_zoom = int(wanted_zoom_level * 100)
        default_zoom_level.set_value(percent_zoom)
        default_zoom_level.set_text("{} %".format(percent_zoom))

        cookies_combo = builder.get_object("cookies_combo")
        storage = App().settings.get_enum("cookie-storage")
        cookies_combo.set_active_id(str(storage))

        history_combo = builder.get_object("history_combo")
        storage = App().settings.get_enum("history-storage")
        history_combo.set_active_id(str(storage))

        self.__populars_count = builder.get_object("populars_count")
        if start_page in ["popular_book", "popular_hist"]:
            self.__populars_count.show()
        max_popular_items = App().settings.get_value(
            "max-popular-items").get_int32()
        builder.get_object("popular_spin_button").set_value(max_popular_items)
        remember_passwords = builder.get_object("remember_passwords_check")
        remember_passwords.set_active(
            App().settings.get_value("remember-passwords"))

        dns_prediction_check = builder.get_object("dns_prediction_check")
        dns_prediction_check.set_active(
            App().settings.get_value("dns-prediction"))
        tracking_check = builder.get_object("tracking_check")
        tracking_check.set_active(App().settings.get_value("do-not-track"))
        self.__result_label = builder.get_object("result_label")
        self.__sync_button = builder.get_object("sync_button")
        self.__login_entry = builder.get_object("login_entry")
        self.__password_entry = builder.get_object("password_entry")
        self.__result_image = builder.get_object("result_image")
        builder.connect_signals(self)
        self.__helper.get_sync(self.__on_get_sync)

        task_helper = TaskHelper()
        task_helper.run(self.__get_sync_status)
Ejemplo n.º 18
0
 def __on_shortcut_action(self, action, param):
     """
         Global shortcuts handler
         @param action as Gio.SimpleAction
         @param param as GLib.Variant
     """
     string = param.get_string()
     if string == "uri":
         if self.is_fullscreen:
             self.__fullscreen_revealer.set_reveal_child(True)
         self.toolbar.title.focus_entry()
     elif string == "fullscreen":
         if self.is_fullscreen:
             self.unfullscreen()
         else:
             self.fullscreen()
     elif string == "quit":
         El().quit(True)
     elif string == "new_page":
         self.container.add_webview(El().start_page, LoadingType.FOREGROUND)
     elif string == "close_page":
         if self.is_fullscreen:
             self.container.current.webview.emit("leave-fullscreen")
             Gtk.ApplicationWindow.unfullscreen(self)
         self.__container.try_close_view(self.container.current)
     elif string == "reload":
         self.container.current.webview.reload()
     elif string == "home":
         self.container.current.webview.load_uri(El().start_page)
     elif string == "source":
         uri = self.container.current.webview.uri
         task_helper = TaskHelper()
         task_helper.load_uri_content(uri, None, self.__on_source_loaded)
     elif string == "find":
         find_widget = self.container.current.find_widget
         find_widget.set_search_mode(True)
         find_widget.search()
     elif string == "backward":
         self.toolbar.actions.backward()
     elif string == "forward":
         self.toolbar.actions.forward()
     elif string == "previous":
         self.__container.previous()
     elif string == "next":
         self.__container.next()
     elif string == "previous_site":
         self.__container.sites_manager.previous()
     elif string == "next_site":
         self.__container.sites_manager.next()
     elif string == "print":
         self.container.current.webview.print()
     elif string == "private":
         self.container.add_webview(El().start_page, LoadingType.FOREGROUND,
                                    True)
     elif string == "last_page":
         El().pages_menu.activate_last_action()
     elif string == "zoom_in":
         self.container.current.webview.zoom_in()
     elif string == "zoom_out":
         self.container.current.webview.zoom_out()
     elif string == "zoom_default":
         self.container.current.webview.zoom_default()
     elif string == "history":
         self.toolbar.title.focus_entry("history")
     elif string == "search":
         self.toolbar.title.focus_entry("search")
     elif string == "save":
         self.toolbar.end.save_page()
     elif string == "expose":
         active = self.toolbar.actions.view_button.get_active()
         self.toolbar.actions.view_button.set_active(not active)
     elif string == "show_left_panel":
         value = El().settings.get_value("show-sidebar")
         El().settings.set_value("show-sidebar",
                                 GLib.Variant("b", not value))