Helpviewer/HelpWindow.py

branch
6_0_x
changeset 4329
399e14805a5c
parent 4319
4b8309feef42
child 4330
2c278493b31e
equal deleted inserted replaced
4328:6420f6f8d9ac 4329:399e14805a5c
126 from .HelpIndexWidget import HelpIndexWidget 126 from .HelpIndexWidget import HelpIndexWidget
127 from .HelpSearchWidget import HelpSearchWidget 127 from .HelpSearchWidget import HelpSearchWidget
128 from .HelpBrowserWV import HelpBrowser 128 from .HelpBrowserWV import HelpBrowser
129 from .HelpTabWidget import HelpTabWidget 129 from .HelpTabWidget import HelpTabWidget
130 from .AdBlock.AdBlockIcon import AdBlockIcon 130 from .AdBlock.AdBlockIcon import AdBlockIcon
131 from .VirusTotalApi import VirusTotalAPI 131 ## from .VirusTotalApi import VirusTotalAPI
132 132
133 HelpWindow.setUseQtHelp(self.fromEric) 133 HelpWindow.setUseQtHelp(self.fromEric)
134 134
135 if not self.fromEric: 135 if not self.fromEric:
136 self.setStyle(Preferences.getUI("Style"), 136 self.setStyle(Preferences.getUI("Style"),
268 state = Preferences.getHelp("HelpViewerState") 268 state = Preferences.getHelp("HelpViewerState")
269 self.restoreState(state) 269 self.restoreState(state)
270 270
271 self.__initHelpDb() 271 self.__initHelpDb()
272 272
273 self.__virusTotal = VirusTotalAPI(self) 273 ## self.__virusTotal = VirusTotalAPI(self)
274 self.__virusTotal.submitUrlError.connect( 274 ## self.__virusTotal.submitUrlError.connect(
275 self.__virusTotalSubmitUrlError) 275 ## self.__virusTotalSubmitUrlError)
276 self.__virusTotal.urlScanReport.connect( 276 ## self.__virusTotal.urlScanReport.connect(
277 self.__virusTotalUrlScanReport) 277 ## self.__virusTotalUrlScanReport)
278 self.__virusTotal.fileScanReport.connect( 278 ## self.__virusTotal.fileScanReport.connect(
279 self.__virusTotalFileScanReport) 279 ## self.__virusTotalFileScanReport)
280 280 ##
281 self.__previewer = None 281 self.__previewer = None
282 self.__shutdownCalled = False 282 self.__shutdownCalled = False
283 283
284 if self.useQtHelp: 284 if self.useQtHelp:
285 QTimer.singleShot(0, self.__lookForNewDocumentation) 285 QTimer.singleShot(0, self.__lookForNewDocumentation)
1821 self.bookmarksToolBar.setIconSize(UI.Config.ToolBarIconSize) 1821 self.bookmarksToolBar.setIconSize(UI.Config.ToolBarIconSize)
1822 self.bookmarksToolBar.openUrl.connect(self.openUrl) 1822 self.bookmarksToolBar.openUrl.connect(self.openUrl)
1823 self.bookmarksToolBar.newUrl.connect(self.openUrlNewTab) 1823 self.bookmarksToolBar.newUrl.connect(self.openUrlNewTab)
1824 self.addToolBarBreak() 1824 self.addToolBarBreak()
1825 self.addToolBar(self.bookmarksToolBar) 1825 self.addToolBar(self.bookmarksToolBar)
1826 1826 ##
1827 self.addToolBarBreak() 1827 ## self.addToolBarBreak()
1828 vttb = self.addToolBar(self.tr("VirusTotal")) 1828 ## vttb = self.addToolBar(self.tr("VirusTotal"))
1829 vttb.setObjectName("VirusTotalToolBar") 1829 ## vttb.setObjectName("VirusTotalToolBar")
1830 vttb.setIconSize(UI.Config.ToolBarIconSize) 1830 ## vttb.setIconSize(UI.Config.ToolBarIconSize)
1831 vttb.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) 1831 ## vttb.setToolButtonStyle(Qt.ToolButtonTextBesideIcon)
1832 self.virustotalSearchEdit = QLineEdit() 1832 ## self.virustotalSearchEdit = QLineEdit()
1833 self.virustotalSearchEdit.setMaximumWidth(250) 1833 ## self.virustotalSearchEdit.setMaximumWidth(250)
1834 self.virustotalSearchEdit.setWhatsThis(self.tr( 1834 ## self.virustotalSearchEdit.setWhatsThis(self.tr(
1835 """<h2>File search</h2>""" 1835 ## """<h2>File search</h2>"""
1836 """<p>In order to search for the last VirusTotal report on a""" 1836 ## """<p>In order to search for the last VirusTotal report on a"""
1837 """ given file just enter its hash. Currently the allowed""" 1837 ## """ given file just enter its hash. Currently the allowed"""
1838 """ hashes are MD5, SHA1 and SHA256. You can also search for""" 1838 ## """ hashes are MD5, SHA1 and SHA256. You can also search for"""
1839 """ a particular file report by typing in its permalink id.</p>""" 1839 ## """ a particular file report by typing in its permalink id.</p>"""
1840 """<h2>URL search</h2>""" 1840 ## """<h2>URL search</h2>"""
1841 """<p>URL searches are simple, just type in the given URL, the""" 1841 ## """<p>URL searches are simple, just type in the given URL, the"""
1842 """ application will normalize it and compare it with the""" 1842 ## """ application will normalize it and compare it with the"""
1843 """ entries in VirusTotal's database. Alternatively you may""" 1843 ## """ entries in VirusTotal's database. Alternatively you may"""
1844 """ enter the MD5 hash of an URL preceded by "url:", e.g.""" 1844 ## """ enter the MD5 hash of an URL preceded by "url:", e.g."""
1845 """ url:7f911bbcf618f052ac6b9928600d2820.</p>""" 1845 ## """ url:7f911bbcf618f052ac6b9928600d2820.</p>"""
1846 """<h2>User search</h2>""" 1846 ## """<h2>User search</h2>"""
1847 """<p>Do you want to know whether a friend has a VT Community""" 1847 ## """<p>Do you want to know whether a friend has a VT Community"""
1848 """ account? Simply type in his nick preceded by the symbol""" 1848 ## """ account? Simply type in his nick preceded by the symbol"""
1849 """ "@", e.g. @EmilianoMartinez.</p>""" 1849 ## """ "@", e.g. @EmilianoMartinez.</p>"""
1850 """<h2>Search through comments</h2>""" 1850 ## """<h2>Search through comments</h2>"""
1851 """<p>The comments in VT Community may often help in""" 1851 ## """<p>The comments in VT Community may often help in"""
1852 """ disinfecting your PC or may proof themselves useful when""" 1852 ## """ disinfecting your PC or may proof themselves useful when"""
1853 """ analysing a particular malware sample, comment tags enable""" 1853 ## """ analysing a particular malware sample, comment tags enable"""
1854 """ users to search through the VT Community reviews. The""" 1854 ## """ users to search through the VT Community reviews. The"""
1855 """ standard file tags are: {0} The standard URL tags are: {1}""" 1855 ## """ standard file tags are: {0} The standard URL tags are: {1}"""
1856 """User generated tags are preceded by the symbol "#", e.g.""" 1856 ## """User generated tags are preceded by the symbol "#", e.g."""
1857 """ #disinfect.</p>""" 1857 ## """ #disinfect.</p>"""
1858 ).format( 1858 ## ).format(
1859 """<ul>""" 1859 ## """<ul>"""
1860 """<li>goodware</li>""" 1860 ## """<li>goodware</li>"""
1861 """<li>malware</li>""" 1861 ## """<li>malware</li>"""
1862 """<li>spamattachmentorlink</li>""" 1862 ## """<li>spamattachmentorlink</li>"""
1863 """<li>p2pdownload</li>""" 1863 ## """<li>p2pdownload</li>"""
1864 """<li>impropagating</li>""" 1864 ## """<li>impropagating</li>"""
1865 """<li>networkworm</li>""" 1865 ## """<li>networkworm</li>"""
1866 """<li>drivebydownload</li>""" 1866 ## """<li>drivebydownload</li>"""
1867 """</ul>""", 1867 ## """</ul>""",
1868 """<ul>""" 1868 ## """<ul>"""
1869 """<li>malicious</li>""" 1869 ## """<li>malicious</li>"""
1870 """<li>benign</li>""" 1870 ## """<li>benign</li>"""
1871 """<li>malewaredownload</li>""" 1871 ## """<li>malewaredownload</li>"""
1872 """<li>phishingsite</li>""" 1872 ## """<li>phishingsite</li>"""
1873 """<li>browserexploit</li>""" 1873 ## """<li>browserexploit</li>"""
1874 """<li>spamlink</li>""" 1874 ## """<li>spamlink</li>"""
1875 """</ul>""", 1875 ## """</ul>""",
1876 )) 1876 ## ))
1877 self.virustotalSearchEdit.textChanged.connect( 1877 ## self.virustotalSearchEdit.textChanged.connect(
1878 self.__virusTotalSearchChanged) 1878 ## self.__virusTotalSearchChanged)
1879 self.virustotalSearchEdit.returnPressed.connect( 1879 ## self.virustotalSearchEdit.returnPressed.connect(
1880 self.__virusTotalSearch) 1880 ## self.__virusTotalSearch)
1881 vttb.addWidget(self.virustotalSearchEdit) 1881 ## vttb.addWidget(self.virustotalSearchEdit)
1882 self.virustotalSearchAct = vttb.addAction( 1882 ## self.virustotalSearchAct = vttb.addAction(
1883 UI.PixmapCache.getIcon("virustotal.png"), 1883 ## UI.PixmapCache.getIcon("virustotal.png"),
1884 self.tr("Search VirusTotal"), 1884 ## self.tr("Search VirusTotal"),
1885 self.__virusTotalSearch) 1885 ## self.__virusTotalSearch)
1886 self.virustotalSearchAct.setEnabled(False) 1886 ## self.virustotalSearchAct.setEnabled(False)
1887 vttb.addSeparator() 1887 ## vttb.addSeparator()
1888 self.virustotalScanCurrentAct = vttb.addAction( 1888 ## self.virustotalScanCurrentAct = vttb.addAction(
1889 UI.PixmapCache.getIcon("virustotal.png"), 1889 ## UI.PixmapCache.getIcon("virustotal.png"),
1890 self.tr("Scan current site"), 1890 ## self.tr("Scan current site"),
1891 self.__virusTotalScanCurrentSite) 1891 ## self.__virusTotalScanCurrentSite)
1892 if not Preferences.getHelp("VirusTotalEnabled") or \ 1892 ## if not Preferences.getHelp("VirusTotalEnabled") or \
1893 Preferences.getHelp("VirusTotalServiceKey") == "": 1893 ## Preferences.getHelp("VirusTotalServiceKey") == "":
1894 self.virustotalSearchEdit.setEnabled(False) 1894 ## self.virustotalSearchEdit.setEnabled(False)
1895 self.virustotalScanCurrentAct.setEnabled(False) 1895 ## self.virustotalScanCurrentAct.setEnabled(False)
1896 1896
1897 def __nextTab(self): 1897 def __nextTab(self):
1898 """ 1898 """
1899 Private slot used to show the next tab. 1899 Private slot used to show the next tab.
1900 """ 1900 """
2504 self.historyManager().preferencesChanged() 2504 self.historyManager().preferencesChanged()
2505 2505
2506 self.tabWidget.preferencesChanged() 2506 self.tabWidget.preferencesChanged()
2507 2507
2508 self.searchEdit.preferencesChanged() 2508 self.searchEdit.preferencesChanged()
2509 2509 ##
2510 self.__virusTotal.preferencesChanged() 2510 ## self.__virusTotal.preferencesChanged()
2511 if not Preferences.getHelp("VirusTotalEnabled") or \ 2511 ## if not Preferences.getHelp("VirusTotalEnabled") or \
2512 Preferences.getHelp("VirusTotalServiceKey") == "": 2512 ## Preferences.getHelp("VirusTotalServiceKey") == "":
2513 self.virustotalSearchEdit.setEnabled(False) 2513 ## self.virustotalSearchEdit.setEnabled(False)
2514 self.virustotalScanCurrentAct.setEnabled(False) 2514 ## self.virustotalScanCurrentAct.setEnabled(False)
2515 else: 2515 ## else:
2516 self.virustotalSearchEdit.setEnabled(True) 2516 ## self.virustotalSearchEdit.setEnabled(True)
2517 self.virustotalScanCurrentAct.setEnabled(True) 2517 ## self.virustotalScanCurrentAct.setEnabled(True)
2518 self.__virusTotalSearchChanged(self.virustotalSearchEdit.text()) 2518 ## self.__virusTotalSearchChanged(self.virustotalSearchEdit.text())
2519 2519
2520 def masterPasswordChanged(self, oldPassword, newPassword): 2520 def masterPasswordChanged(self, oldPassword, newPassword):
2521 """ 2521 """
2522 Public slot to handle the change of the master password. 2522 Public slot to handle the change of the master password.
2523 2523
3578 self.__linkActivated(url) 3578 self.__linkActivated(url)
3579 return 3579 return
3580 3580
3581 super(HelpWindow, self).keyPressEvent(evt) 3581 super(HelpWindow, self).keyPressEvent(evt)
3582 3582
3583 ########################################################################### 3583 ## ###########################################################################
3584 ## Interface to VirusTotal below ## 3584 ## ## Interface to VirusTotal below ##
3585 ########################################################################### 3585 ## ###########################################################################
3586 3586 ##
3587 def __virusTotalSearchChanged(self, txt): 3587 ## def __virusTotalSearchChanged(self, txt):
3588 """ 3588 ## """
3589 Private slot to react upon changes of the VirusTotal search text. 3589 ## Private slot to react upon changes of the VirusTotal search text.
3590 3590 ##
3591 @param txt contents of the search (string) 3591 ## @param txt contents of the search (string)
3592 """ 3592 ## """
3593 self.virustotalSearchAct.setEnabled( 3593 ## self.virustotalSearchAct.setEnabled(
3594 txt != "" and 3594 ## txt != "" and
3595 Preferences.getHelp("VirusTotalEnabled") and 3595 ## Preferences.getHelp("VirusTotalEnabled") and
3596 Preferences.getHelp("VirusTotalServiceKey") != "") 3596 ## Preferences.getHelp("VirusTotalServiceKey") != "")
3597 3597 ##
3598 def __virusTotalSearch(self): 3598 ## def __virusTotalSearch(self):
3599 """ 3599 ## """
3600 Private slot to search VirusTotal for a given entry. 3600 ## Private slot to search VirusTotal for a given entry.
3601 """ 3601 ## """
3602 search = self.virustotalSearchEdit.text() 3602 ## search = self.virustotalSearchEdit.text()
3603 if search: 3603 ## if search:
3604 from .VirusTotalApi import VirusTotalAPI 3604 ## from .VirusTotalApi import VirusTotalAPI
3605 requestData = VirusTotalAPI.getSearchRequestData(search) 3605 ## requestData = VirusTotalAPI.getSearchRequestData(search)
3606 self.newTab(requestData=requestData) 3606 ## self.newTab(requestData=requestData)
3607 3607 ##
3608 def __virusTotalScanCurrentSite(self): 3608 ## def __virusTotalScanCurrentSite(self):
3609 """ 3609 ## """
3610 Private slot to ask VirusTotal for a scan of the URL of the current 3610 ## Private slot to ask VirusTotal for a scan of the URL of the current
3611 browser. 3611 ## browser.
3612 """ 3612 ## """
3613 cb = self.currentBrowser() 3613 ## cb = self.currentBrowser()
3614 if cb is not None: 3614 ## if cb is not None:
3615 url = cb.url() 3615 ## url = cb.url()
3616 if url.scheme() in ["http", "https", "ftp"]: 3616 ## if url.scheme() in ["http", "https", "ftp"]:
3617 self.requestVirusTotalScan(url) 3617 ## self.requestVirusTotalScan(url)
3618 3618 ##
3619 def requestVirusTotalScan(self, url): 3619 ## def requestVirusTotalScan(self, url):
3620 """ 3620 ## """
3621 Public method to submit a request to scan an URL by VirusTotal. 3621 ## Public method to submit a request to scan an URL by VirusTotal.
3622 3622 ##
3623 @param url URL to be scanned (QUrl) 3623 ## @param url URL to be scanned (QUrl)
3624 """ 3624 ## """
3625 self.__virusTotal.submitUrl(url) 3625 ## self.__virusTotal.submitUrl(url)
3626 3626 ##
3627 def __virusTotalSubmitUrlError(self, msg): 3627 ## def __virusTotalSubmitUrlError(self, msg):
3628 """ 3628 ## """
3629 Private slot to handle an URL scan submission error. 3629 ## Private slot to handle an URL scan submission error.
3630 3630 ##
3631 @param msg error message (str) 3631 ## @param msg error message (str)
3632 """ 3632 ## """
3633 E5MessageBox.critical( 3633 ## E5MessageBox.critical(
3634 self, 3634 ## self,
3635 self.tr("VirusTotal Scan"), 3635 ## self.tr("VirusTotal Scan"),
3636 self.tr("""<p>The VirusTotal scan could not be""" 3636 ## self.tr("""<p>The VirusTotal scan could not be"""
3637 """ scheduled.<p>\n<p>Reason: {0}</p>""").format(msg)) 3637 ## """ scheduled.<p>\n<p>Reason: {0}</p>""").format(msg))
3638 3638 ##
3639 def __virusTotalUrlScanReport(self, url): 3639 ## def __virusTotalUrlScanReport(self, url):
3640 """ 3640 ## """
3641 Private slot to initiate the display of the URL scan report page. 3641 ## Private slot to initiate the display of the URL scan report page.
3642 3642 ##
3643 @param url URL of the URL scan report page (string) 3643 ## @param url URL of the URL scan report page (string)
3644 """ 3644 ## """
3645 self.newTab(url) 3645 ## self.newTab(url)
3646 3646 ##
3647 def __virusTotalFileScanReport(self, url): 3647 ## def __virusTotalFileScanReport(self, url):
3648 """ 3648 ## """
3649 Private slot to initiate the display of the file scan report page. 3649 ## Private slot to initiate the display of the file scan report page.
3650 3650 ##
3651 @param url URL of the file scan report page (string) 3651 ## @param url URL of the file scan report page (string)
3652 """ 3652 ## """
3653 self.newTab(url) 3653 ## self.newTab(url)
3654 3654 ##
3655 def reloadUserStyleSheet(self): 3655 def reloadUserStyleSheet(self):
3656 """ 3656 """
3657 Public method to reload the user style sheet. 3657 Public method to reload the user style sheet.
3658 """ 3658 """
3659 settings = QWebSettings.globalSettings() 3659 settings = QWebSettings.globalSettings()

eric ide

mercurial