Esempio n. 1
0
    def __initialSync(self):
        """
        Private slot to do the initial synchronization.
        """
        # Bookmarks
        if Preferences.getWebBrowser("SyncBookmarks"):
            self.__initialSyncFile(
                "bookmarks",
                WebBrowserWindow.bookmarksManager().getFileName())

        # History
        if Preferences.getWebBrowser("SyncHistory"):
            self.__initialSyncFile(
                "history",
                WebBrowserWindow.historyManager().getFileName())

        # Passwords
        if Preferences.getWebBrowser("SyncPasswords"):
            self.__initialSyncFile(
                "passwords",
                WebBrowserWindow.passwordManager().getFileName())

        # User Agent Settings
        if Preferences.getWebBrowser("SyncUserAgents"):
            self.__initialSyncFile(
                "useragents",
                WebBrowserWindow.userAgentsManager().getFileName())

        # Speed Dial Settings
        if Preferences.getWebBrowser("SyncSpeedDial"):
            self.__initialSyncFile("speeddial",
                                   WebBrowserWindow.speedDial().getFileName())

        self.__forceUpload = False
Esempio n. 2
0
 def __syncFinished(self, type_, status, download):
     """
     Private slot to handle a finished synchronization event.
     
     @param type_ type of the synchronization event (string one
         of "bookmarks", "history", "passwords", "useragents" or
         "speeddial")
     @param status flag indicating success (boolean)
     @param download flag indicating a download of a file (boolean)
     """
     if status and download:
         if type_ == "bookmarks":
             WebBrowserWindow.bookmarksManager().reload()
         elif type_ == "history":
             WebBrowserWindow.historyManager().reload()
         elif type_ == "passwords":
             WebBrowserWindow.passwordManager().reload()
         elif type_ == "useragents":
             WebBrowserWindow.userAgentsManager().reload()
         elif type_ == "speeddial":
             WebBrowserWindow.speedDial().reload()
     self.syncFinished.emit(type_, status, download)
 def syncHistory(self):
     """
     Public method to synchronize the history.
     """
     self.__syncFile("history",
                     WebBrowserWindow.historyManager().getFileName())
Esempio n. 4
0
    def loadSettings(self, forceUpload=False):
        """
        Public method to load the settings.
        
        @keyparam forceUpload flag indicating a forced upload of the files
            (boolean)
        """
        if self.__handler is not None:
            self.__handler.syncError.disconnect(self.__syncError)
            self.__handler.syncFinished.disconnect(self.__syncFinished)
            self.__handler.syncStatus.disconnect(self.__syncStatus)
            self.__handler.syncMessage.disconnect(self.syncMessage)
            self.__handler.shutdown()

        if self.syncEnabled():
            from . import SyncGlobals
            if (Preferences.getWebBrowser("SyncType") ==
                    SyncGlobals.SyncTypeFtp):
                from .FtpSyncHandler import FtpSyncHandler
                self.__handler = FtpSyncHandler(self)
            elif (Preferences.getWebBrowser("SyncType") ==
                  SyncGlobals.SyncTypeDirectory):
                from .DirectorySyncHandler import DirectorySyncHandler
                self.__handler = DirectorySyncHandler(self)
            self.__handler.syncError.connect(self.__syncError)
            self.__handler.syncFinished.connect(self.__syncFinished)
            self.__handler.syncStatus.connect(self.__syncStatus)
            self.__handler.syncMessage.connect(self.syncMessage)

            self.__handler.initialLoadAndCheck(forceUpload=forceUpload)

            # connect sync manager to bookmarks manager
            if Preferences.getWebBrowser("SyncBookmarks"):
                (WebBrowserWindow.bookmarksManager().bookmarksSaved.connect(
                    self.__syncBookmarks))
            else:
                try:
                    (WebBrowserWindow.bookmarksManager().bookmarksSaved.
                     disconnect(self.__syncBookmarks))
                except TypeError:
                    pass

            # connect sync manager to history manager
            if Preferences.getWebBrowser("SyncHistory"):
                (WebBrowserWindow.historyManager().historySaved.connect(
                    self.__syncHistory))
            else:
                try:
                    (WebBrowserWindow.historyManager().historySaved.disconnect(
                        self.__syncHistory))
                except TypeError:
                    pass

            # connect sync manager to passwords manager
            if Preferences.getWebBrowser("SyncPasswords"):
                (WebBrowserWindow.passwordManager().passwordsSaved.connect(
                    self.__syncPasswords))
            else:
                try:
                    (WebBrowserWindow.passwordManager().passwordsSaved.
                     disconnect(self.__syncPasswords))
                except TypeError:
                    pass

            # connect sync manager to user agent manager
            if Preferences.getWebBrowser("SyncUserAgents"):
                (WebBrowserWindow.userAgentsManager().userAgentSettingsSaved.
                 connect(self.__syncUserAgents))
            else:
                try:
                    (WebBrowserWindow.userAgentsManager().
                     userAgentSettingsSaved.disconnect(self.__syncUserAgents))
                except TypeError:
                    pass

            # connect sync manager to speed dial
            if Preferences.getWebBrowser("SyncSpeedDial"):
                (WebBrowserWindow.speedDial().speedDialSaved.connect(
                    self.__syncSpeedDial))
            else:
                try:
                    (WebBrowserWindow.speedDial().speedDialSaved.disconnect(
                        self.__syncSpeedDial))
                except TypeError:
                    pass
        else:
            self.__handler = None

            try:
                (WebBrowserWindow.bookmarksManager().bookmarksSaved.disconnect(
                    self.__syncBookmarks))
            except TypeError:
                pass
            try:
                (WebBrowserWindow.historyManager().historySaved.disconnect(
                    self.__syncHistory))
            except TypeError:
                pass
            try:
                (WebBrowserWindow.passwordManager().passwordsSaved.disconnect(
                    self.__syncPasswords))
            except TypeError:
                pass
            try:
                (WebBrowserWindow.userAgentsManager().userAgentSettingsSaved.
                 disconnect(self.__syncUserAgents))
            except TypeError:
                pass
            try:
                WebBrowserWindow.speedDial().speedDialSaved.disconnect(
                    self.__syncSpeedDial)
            except TypeError:
                pass
Esempio n. 5
0
    def __init__(self, browser, parent=None):
        """
        Constructor
        
        @param browser reference to the browser view
        @type WebBrowserView
        @param parent reference to the parent object
        @type QWidget
        """
        super(SiteInfoWidget, self).__init__(parent)

        self.__browser = browser
        url = browser.url()

        self.setMinimumWidth(400)

        layout = QGridLayout(self)
        rows = 0

        titleLabel = QLabel(self)
        titleLabel.setText(self.tr("<b>Site {0}</b>").format(url.host()))
        layout.addWidget(titleLabel, rows, 0, 1, -1, Qt.AlignCenter)
        rows += 1

        line = QFrame(self)
        line.setLineWidth(1)
        line.setFrameStyle(QFrame.HLine | QFrame.Sunken)
        layout.addWidget(line, rows, 0, 1, -1)
        rows += 1

        secureIcon = QLabel()
        layout.addWidget(secureIcon, rows, 0, Qt.AlignCenter)
        secureLabel = QLabel()
        secureLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
        layout.addWidget(secureLabel, rows, 1)
        if url.scheme() in ["https"]:
            secureLabel.setText(
                self.tr("Your connection to this site is <b>secure</b>."))
            secureIcon.setPixmap(UI.PixmapCache.getPixmap("securityHigh.png"))
        else:
            secureLabel.setText(
                self.tr("Your connection to this site is <b>not secure</b>."))
            secureIcon.setPixmap(UI.PixmapCache.getPixmap("securityLow.png"))
        rows += 1

        visits = WebBrowserWindow.historyManager().siteVisitsCount(
            url.scheme(), url.host())
        historyIcon = QLabel()
        layout.addWidget(historyIcon, rows, 0, Qt.AlignCenter)
        historyLabel = QLabel()
        historyLabel.setSizePolicy(QSizePolicy.Expanding,
                                   QSizePolicy.Preferred)
        layout.addWidget(historyLabel, rows, 1)
        if visits > 3:
            historyLabel.setText(
                self.tr("This is your <b>{0}.</b> visit of this site.").format(
                    visits))
            historyIcon.setPixmap(UI.PixmapCache.getPixmap("flagGreen.png"))
        elif visits == 0:
            historyLabel.setText(
                self.tr("You have <b>never</b> visited this site before.").
                format(visits))
            historyIcon.setPixmap(UI.PixmapCache.getPixmap("flagBlack.png"))
        else:
            historyIcon.setPixmap(UI.PixmapCache.getPixmap("flagYellow.png"))
            if visits == 1:
                visitStr = self.tr("first")
            elif visits == 2:
                visitStr = self.tr("second")
            else:
                visitStr = self.tr("third")
            historyLabel.setText(
                self.tr("This is your <b>{0}</b> visit of this site.").format(
                    visitStr))
        rows += 1

        line = QFrame(self)
        line.setLineWidth(1)
        line.setFrameStyle(QFrame.HLine | QFrame.Sunken)
        layout.addWidget(line, rows, 0, 1, -1)
        rows += 1

        page = self.__browser.page()
        scheme = page.registerProtocolHandlerRequestScheme()
        registeredUrl = (
            WebBrowserWindow.protocolHandlerManager().protocolHandler(scheme))
        if (bool(scheme)
                and registeredUrl != page.registerProtocolHandlerRequestUrl()):
            horizontalLayout = QHBoxLayout()
            protocolHandlerLabel = QLabel(
                self.tr("Register as <b>{0}</b> links handler.").format(
                    scheme), self)
            protocolHandlerLabel.setSizePolicy(QSizePolicy.Expanding,
                                               QSizePolicy.Preferred)

            horizontalLayout.addWidget(protocolHandlerLabel)
            protocolHandlerButton = QPushButton(self.tr("Register"), self)
            horizontalLayout.addWidget(protocolHandlerButton)
            protocolHandlerButton.clicked.connect(
                self.__registerProtocolHandler)
            layout.addLayout(horizontalLayout, rows, 0, 1, -1)
            rows += 1

            protocolHandlerLine = QFrame(self)
            protocolHandlerLine.setLineWidth(1)
            protocolHandlerLine.setFrameStyle(QFrame.HLine | QFrame.Sunken)
            layout.addWidget(protocolHandlerLine, rows, 0, 1, -1)
            rows += 1

        horizontalLayout = QHBoxLayout()
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        horizontalLayout.addItem(spacerItem)
        moreButton = QPushButton(self.tr("More..."), self)
        horizontalLayout.addWidget(moreButton)
        moreButton.clicked.connect(self.__showSiteInfo)
        layout.addLayout(horizontalLayout, rows, 0, 1, -1)