Esempio n. 1
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_timeout = 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)
        self.__show_related_view(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)

        parsed = urlparse(self.__uri)
        if value and not is_uri and network:
            El().search.search_suggestions(value,
                                           self.__cancellable,
                                           self.__search_suggestion)

        self.__entry.set_icon_from_icon_name(Gtk.EntryIconPosition.PRIMARY,
                                             "system-search-symbolic")
        self.__entry.set_icon_tooltip_text(Gtk.EntryIconPosition.PRIMARY,
                                           "")
Esempio n. 2
0
    def quit(self, vacuum=False):
        """
            Quit application
            @param vacuum as bool
        """
        self.__save_state()
        for window in self.windows:
            window.hide()
        # Stop pending tasks
        self.download_manager.cancel()
        self.adblock.stop()
        # Clear history
        active_id = str(self.settings.get_enum("history-storage"))
        if active_id != TimeSpan.FOREVER:
            atime = time()
            if active_id != TimeSpan.NEVER:
                atime -= TimeSpanValues[active_id] / 1000000
            self.history.clear_to(int(atime))

        if self.sync_worker is not None:
            if self.sync_worker.syncing:
                self.sync_worker.stop()
            self.sync_worker.save_pendings()
        if vacuum:
            task_helper = TaskHelper()
            task_helper.run(self.__vacuum,
                            callback=(lambda x: Gio.Application.quit(self), ))
        else:
            Gio.Application.quit(self)
Esempio n. 3
0
 def quit(self, vacuum=False):
     """
         Quit application
         @param vacuum as bool
     """
     # Save webpage state
     self.__save_state()
     # Stop pending tasks
     self.download_manager.cancel()
     self.adblock.stop()
     # Clear history
     active_id = str(self.settings.get_enum("history-storage"))
     if active_id != TimeSpan.FOREVER:
         atime = time()
         if active_id != TimeSpan.NEVER:
             atime -= TimeSpanValues[active_id]/1000000
         self.history.clear_to(int(atime))
     # If sync is running, to avoid db lock, we do not vacuum
     if self.sync_worker is not None and self.sync_worker.syncing:
         self.sync_worker.stop()
         Gio.Application.quit(self)
     elif vacuum:
         task_helper = TaskHelper()
         task_helper.run(self.__vacuum,
                         (),
                         lambda x: Gio.Application.quit(self))
     else:
         Gio.Application.quit(self)
Esempio n. 4
0
 def __init__(self, uri, page_id, window):
     """
         Init popover
         @param uri as str
         @param page_id as int
         @param window as Window
     """
     Gtk.Popover.__init__(self)
     self.set_modal(False)
     window.register(self)
     self.__cache_uris = []
     self.__uri = uri
     self.__page_id = page_id
     self.__cancellable = Gio.Cancellable()
     self.__filter = ""
     builder = Gtk.Builder()
     builder.add_from_resource("/org/gnome/Eolie/PopoverImages.ui")
     builder.connect_signals(self)
     widget = builder.get_object("widget")
     self.__spinner = builder.get_object("spinner")
     self.__flowbox = builder.get_object("flowbox")
     self.__flowbox.set_filter_func(self.__filter_func)
     self.__entry = builder.get_object("entry")
     self.__button = builder.get_object("button")
     self.add(widget)
     if Gio.NetworkMonitor.get_default().get_network_available():
         El().helper.call("GetImages", page_id, None, self.__on_get_images)
     (width, height) = El().active_window.get_size()
     self.set_size_request(width / 2, height / 1.5)
     self.connect("closed", self.__on_closed)
     self.__task_helper = TaskHelper()
Esempio n. 5
0
 def remove_from_passwords(self, uuid):
     """
         Remove password from passwords collection
         @param uuid as str
     """
     if self.__username and self.__password:
         task_helper = TaskHelper()
         task_helper.run(self.__remove_from_passwords, uuid)
Esempio n. 6
0
 def remove_from_bookmarks(self, guid):
     """
         Remove bookmark guid from remote bookmarks
         @param guid as str
     """
     if self.__username and self.__password:
         task_helper = TaskHelper()
         task_helper.run(self.__remove_from_bookmarks, guid)
Esempio n. 7
0
 def remove_from_history(self, guid):
     """
         Remove history guid from remote history
         @param guid as str
     """
     if self.__username and self.__password:
         task_helper = TaskHelper()
         task_helper.run(self.__remove_from_history, guid)
Esempio n. 8
0
 def push_bookmark(self, bookmark_id):
     """
         Push bookmark id
         @param bookmark_id as int
     """
     if self.__username and self.__password:
         task_helper = TaskHelper()
         task_helper.run(self.__push_bookmark, bookmark_id)
Esempio n. 9
0
 def remove_from_bookmarks(self, guid):
     """
         Remove bookmark guid from remote bookmarks
         @param guid as str
     """
     if Gio.NetworkMonitor.get_default().get_network_available():
         task_helper = TaskHelper()
         task_helper.run(self.__remove_from_bookmarks, (guid, ))
Esempio n. 10
0
 def sync(self):
     """
         Start syncing
     """
     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)
Esempio n. 11
0
 def push_history(self, history_id):
     """
         Push history id
         @param history_id as int
     """
     if self.__username and self.__password:
         task_helper = TaskHelper()
         task_helper.run(self.__push_history, history_id)
Esempio n. 12
0
 def _on_button_clicked(self, button):
     """
         Save visible images
         @param button as Gtk.Button
     """
     task_helper = TaskHelper()
     task_helper.run(self.__move_images)
     self.__spinner.start()
Esempio n. 13
0
 def push_history(self, history_ids):
     """
         Push history ids
         @param history_ids as [int]
     """
     if Gio.NetworkMonitor.get_default().get_network_available():
         task_helper = TaskHelper()
         task_helper.run(self.__push_history, (history_ids, ))
Esempio n. 14
0
 def remove_from_passwords(self, uuid):
     """
         Remove password from passwords collection
         @param uuid as str
     """
     if Gio.NetworkMonitor.get_default().get_network_available():
         task_helper = TaskHelper()
         task_helper.run(self.__remove_from_passwords, (uuid, ))
Esempio n. 15
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():
         task_helper = TaskHelper()
         task_helper.run(self.__remove_from_history, (guid, ))
Esempio n. 16
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
Esempio n. 17
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)
Esempio n. 18
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)
Esempio n. 19
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
Esempio n. 20
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
Esempio n. 21
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)
Esempio n. 22
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)
Esempio n. 23
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)
Esempio n. 24
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()
Esempio n. 25
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)
Esempio n. 26
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))
Esempio n. 27
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)
Esempio n. 28
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)
Esempio n. 29
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()))
Esempio n. 30
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, "")