Added the SSL info label to the URL bar.

Wed, 06 Oct 2010 19:54:56 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 06 Oct 2010 19:54:56 +0200
changeset 657
099d1ab9073e
parent 656
2f4496b1956f
child 658
2856f7ea6780

Added the SSL info label to the URL bar.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.HelpBrowserWV.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Helpviewer.UrlBar.UrlBar.html file | annotate | diff | comparison | revisions
Helpviewer/HelpBrowserWV.py file | annotate | diff | comparison | revisions
Helpviewer/UrlBar/UrlBar.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Wed Oct 06 08:46:55 2010 +0200
+++ b/APIs/Python3/eric5.api	Wed Oct 06 19:54:56 2010 +0200
@@ -1898,6 +1898,7 @@
 eric5.Helpviewer.HelpBrowserWV.HelpBrowser?1(mainWindow, parent = None, name = "")
 eric5.Helpviewer.HelpBrowserWV.HelpWebPage.acceptNavigationRequest?4(frame, request, type_)
 eric5.Helpviewer.HelpBrowserWV.HelpWebPage.extension?4(extension, option, output)
+eric5.Helpviewer.HelpBrowserWV.HelpWebPage.getSslInfo?4()
 eric5.Helpviewer.HelpBrowserWV.HelpWebPage.pageAttributeId?4()
 eric5.Helpviewer.HelpBrowserWV.HelpWebPage.populateNetworkRequest?4(request)
 eric5.Helpviewer.HelpBrowserWV.HelpWebPage.setUserAgent?4(agent)
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Wed Oct 06 08:46:55 2010 +0200
+++ b/Documentation/Help/source.qhp	Wed Oct 06 19:54:56 2010 +0200
@@ -2599,8 +2599,10 @@
       <keyword name="HelpBrowser.zoomOut" id="HelpBrowser.zoomOut" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpBrowser.zoomOut" />
       <keyword name="HelpBrowser.zoomReset" id="HelpBrowser.zoomReset" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpBrowser.zoomReset" />
       <keyword name="HelpWebPage (Constructor)" id="HelpWebPage (Constructor)" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.__init__" />
+      <keyword name="HelpWebPage.__managerFinished" id="HelpWebPage.__managerFinished" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.__managerFinished" />
       <keyword name="HelpWebPage.acceptNavigationRequest" id="HelpWebPage.acceptNavigationRequest" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.acceptNavigationRequest" />
       <keyword name="HelpWebPage.extension" id="HelpWebPage.extension" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.extension" />
+      <keyword name="HelpWebPage.getSslInfo" id="HelpWebPage.getSslInfo" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.getSslInfo" />
       <keyword name="HelpWebPage.pageAttributeId" id="HelpWebPage.pageAttributeId" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.pageAttributeId" />
       <keyword name="HelpWebPage.populateNetworkRequest" id="HelpWebPage.populateNetworkRequest" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.populateNetworkRequest" />
       <keyword name="HelpWebPage.setUserAgent" id="HelpWebPage.setUserAgent" ref="eric5.Helpviewer.HelpBrowserWV.html#HelpWebPage.setUserAgent" />
@@ -7347,6 +7349,8 @@
       <keyword name="UrlBar" id="UrlBar" ref="eric5.Helpviewer.UrlBar.UrlBar.html#UrlBar" />
       <keyword name="UrlBar (Constructor)" id="UrlBar (Constructor)" ref="eric5.Helpviewer.UrlBar.UrlBar.html#UrlBar.__init__" />
       <keyword name="UrlBar.__browserUrlChanged" id="UrlBar.__browserUrlChanged" ref="eric5.Helpviewer.UrlBar.UrlBar.html#UrlBar.__browserUrlChanged" />
+      <keyword name="UrlBar.__loadFinished" id="UrlBar.__loadFinished" ref="eric5.Helpviewer.UrlBar.UrlBar.html#UrlBar.__loadFinished" />
+      <keyword name="UrlBar.__loadStarted" id="UrlBar.__loadStarted" ref="eric5.Helpviewer.UrlBar.UrlBar.html#UrlBar.__loadStarted" />
       <keyword name="UrlBar.__privacyClicked" id="UrlBar.__privacyClicked" ref="eric5.Helpviewer.UrlBar.UrlBar.html#UrlBar.__privacyClicked" />
       <keyword name="UrlBar.__textChanged" id="UrlBar.__textChanged" ref="eric5.Helpviewer.UrlBar.UrlBar.html#UrlBar.__textChanged" />
       <keyword name="UrlBar.browser" id="UrlBar.browser" ref="eric5.Helpviewer.UrlBar.UrlBar.html#UrlBar.browser" />
--- a/Documentation/Source/eric5.Helpviewer.HelpBrowserWV.html	Wed Oct 06 08:46:55 2010 +0200
+++ b/Documentation/Source/eric5.Helpviewer.HelpBrowserWV.html	Wed Oct 06 19:54:56 2010 +0200
@@ -731,12 +731,18 @@
 <td><a href="#HelpWebPage.__init__">HelpWebPage</a></td>
 <td>Constructor</td>
 </tr><tr>
+<td><a href="#HelpWebPage.__managerFinished">__managerFinished</a></td>
+<td>Private slot to handle a finished reply.</td>
+</tr><tr>
 <td><a href="#HelpWebPage.acceptNavigationRequest">acceptNavigationRequest</a></td>
 <td>Protected method to determine, if a request may be accepted.</td>
 </tr><tr>
 <td><a href="#HelpWebPage.extension">extension</a></td>
 <td>Public method to implement a specific extension.</td>
 </tr><tr>
+<td><a href="#HelpWebPage.getSslInfo">getSslInfo</a></td>
+<td>Public method to get a reference to the SSL info object.</td>
+</tr><tr>
 <td><a href="#HelpWebPage.pageAttributeId">pageAttributeId</a></td>
 <td>Public method to get the attribute id of the page attribute.</td>
 </tr><tr>
@@ -766,6 +772,18 @@
 <dd>
 parent widget of this window (QWidget)
 </dd>
+</dl><a NAME="HelpWebPage.__managerFinished" ID="HelpWebPage.__managerFinished"></a>
+<h4>HelpWebPage.__managerFinished</h4>
+<b>__managerFinished</b>(<i>reply</i>)
+<p>
+        Private slot to handle a finished reply.
+</p><p>
+        This slot is used to get SSL related information for a reply.
+</p><dl>
+<dt><i>reply</i></dt>
+<dd>
+reference to the finished reply (QNetworkReply)
+</dd>
 </dl><a NAME="HelpWebPage.acceptNavigationRequest" ID="HelpWebPage.acceptNavigationRequest"></a>
 <h4>HelpWebPage.acceptNavigationRequest</h4>
 <b>acceptNavigationRequest</b>(<i>frame, request, type_</i>)
@@ -808,6 +826,16 @@
 <dd>
 flag indicating a successful call of the extension (boolean)
 </dd>
+</dl><a NAME="HelpWebPage.getSslInfo" ID="HelpWebPage.getSslInfo"></a>
+<h4>HelpWebPage.getSslInfo</h4>
+<b>getSslInfo</b>(<i></i>)
+<p>
+        Public method to get a reference to the SSL info object.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+reference to the SSL info (QSslCertificate)
+</dd>
 </dl><a NAME="HelpWebPage.pageAttributeId" ID="HelpWebPage.pageAttributeId"></a>
 <h4>HelpWebPage.pageAttributeId</h4>
 <b>pageAttributeId</b>(<i></i>)
--- a/Documentation/Source/eric5.Helpviewer.UrlBar.UrlBar.html	Wed Oct 06 08:46:55 2010 +0200
+++ b/Documentation/Source/eric5.Helpviewer.UrlBar.UrlBar.html	Wed Oct 06 19:54:56 2010 +0200
@@ -60,6 +60,12 @@
 <td><a href="#UrlBar.__browserUrlChanged">__browserUrlChanged</a></td>
 <td>Private slot to handle a URL change of the associated browser.</td>
 </tr><tr>
+<td><a href="#UrlBar.__loadFinished">__loadFinished</a></td>
+<td>Private slot to set some data after the page was loaded.</td>
+</tr><tr>
+<td><a href="#UrlBar.__loadStarted">__loadStarted</a></td>
+<td>Private slot to perform actions before the page is loaded.</td>
+</tr><tr>
 <td><a href="#UrlBar.__privacyClicked">__privacyClicked</a></td>
 <td>Private slot to handle the click of the private mode button.</td>
 </tr><tr>
@@ -120,7 +126,22 @@
 <dd>
 new URL of the browser (QUrl)
 </dd>
-</dl><a NAME="UrlBar.__privacyClicked" ID="UrlBar.__privacyClicked"></a>
+</dl><a NAME="UrlBar.__loadFinished" ID="UrlBar.__loadFinished"></a>
+<h4>UrlBar.__loadFinished</h4>
+<b>__loadFinished</b>(<i>ok</i>)
+<p>
+        Private slot to set some data after the page was loaded.
+</p><dl>
+<dt><i>ok</i></dt>
+<dd>
+flag indicating a successful load (boolean)
+</dd>
+</dl><a NAME="UrlBar.__loadStarted" ID="UrlBar.__loadStarted"></a>
+<h4>UrlBar.__loadStarted</h4>
+<b>__loadStarted</b>(<i></i>)
+<p>
+        Private slot to perform actions before the page is loaded.
+</p><a NAME="UrlBar.__privacyClicked" ID="UrlBar.__privacyClicked"></a>
 <h4>UrlBar.__privacyClicked</h4>
 <b>__privacyClicked</b>(<i></i>)
 <p>
--- a/Helpviewer/HelpBrowserWV.py	Wed Oct 06 08:46:55 2010 +0200
+++ b/Helpviewer/HelpBrowserWV.py	Wed Oct 06 19:54:56 2010 +0200
@@ -308,33 +308,24 @@
         
         if mainFrameRequest and \
            self.__sslInfo is not None and \
-           not self.__domainSchemeMatch(reply.url(), self.__sslInfo.url):
+           reply.url() == self.mainFrame().url():
             self.__sslInfo = None
         
         if reply.error() == QNetworkReply.NoError and \
            mainFrameRequest and \
            self.__sslInfo is None and \
-           reply.url().scheme().lower() == "https":
+           reply.url().scheme().lower() == "https" and \
+           reply.url() == self.mainFrame().url():
             self.__sslInfo = reply.sslConfiguration().peerCertificate()
             self.__sslInfo.url = QUrl(reply.url())
     
-    def __domainSchemeMatch(self, url1, url2):
-        """
-        Private method to check, if to URLs belong to the same domain.
-        
-        @param url1 first URL (QUrl)
-        @param url2 second URL (QUrl)
-        @return flag indicating a match (boolean)
+    def getSslInfo(self):
         """
-        if url1.scheme() != url2.scheme():
-            return False
+        Public method to get a reference to the SSL info object.
         
-        url1L = url1.host().lower().split(".")
-        url2L = url2.host().lower().split(".")
-        if min(len(url1L), len(url2L)) < 2:
-            return False
-        
-        return url1L[-2:] == url2L[-2:]
+        @return reference to the SSL info (QSslCertificate)
+        """
+        return self.__sslInfo
 
 ##########################################################################################
 
--- a/Helpviewer/UrlBar/UrlBar.py	Wed Oct 06 08:46:55 2010 +0200
+++ b/Helpviewer/UrlBar/UrlBar.py	Wed Oct 06 19:54:56 2010 +0200
@@ -8,7 +8,8 @@
 """
 
 from PyQt4.QtCore import Qt, QPointF, QUrl
-from PyQt4.QtGui import QColor, QPalette, QApplication, QLinearGradient
+from PyQt4.QtGui import QColor, QPalette, QApplication, QLinearGradient, QLabel
+from PyQt4.QtNetwork import QSslCertificate
 from PyQt4.QtWebKit import QWebSettings
 
 from E5Gui.E5LineEdit import E5LineEdit
@@ -41,6 +42,12 @@
         self.__favicon = FavIconLabel(self)
         self.addWidget(self.__favicon, E5LineEdit.LeftSide)
         
+        self.__sslLabel = QLabel(self)
+        self.__sslLabel.setStyleSheet(
+            "QLabel { color : white; background-color : green; }")
+        self.addWidget(self.__sslLabel, E5LineEdit.LeftSide)
+        self.__sslLabel.setVisible(False)
+        
         self.__privacyButton = E5LineEditButton(self)
         self.__privacyButton.setIcon(UI.PixmapCache.getIcon("privateBrowsing.png"))
         self.addWidget(self.__privacyButton, E5LineEdit.RightSide)
@@ -67,6 +74,8 @@
         
         self.__browser.urlChanged.connect(self.__browserUrlChanged)
         self.__browser.loadProgress.connect(self.update)
+        self.__browser.loadFinished.connect(self.__loadFinished)
+        self.__browser.loadStarted.connect(self.__loadStarted)
     
     def browser(self):
         """
@@ -83,6 +92,34 @@
         self.setText(str(url.toEncoded(), encoding = "utf-8"))
         self.setCursorPosition(0)
     
+    def __loadStarted(self):
+        """
+        Private slot to perform actions before the page is loaded.
+        """
+        self.__sslLabel.setVisible(False)
+    
+    def __loadFinished(self, ok):
+        """
+        Private slot to set some data after the page was loaded.
+        
+        @param ok flag indicating a successful load (boolean)
+        """
+        if ok and self.__browser.url().scheme() == "https":
+            sslInfo = self.__browser.page().getSslInfo()
+            if sslInfo is not None:
+                org = sslInfo.subjectInfo(QSslCertificate.Organization)
+                if org == "":
+                    cn = sslInfo.subjectInfo(QSslCertificate.CommonName)
+                    if cn != "":
+                        org = cn.split(".", 1)[1]
+                    if org == "":
+                        org = self.trUtf8("Unknown")
+                self.__sslLabel.setText(" {0} ".format(org))
+                self.__sslLabel.setVisible(True)
+                return
+        
+        self.__sslLabel.setVisible(False)
+    
     def setPrivateMode(self, on):
         """
         Public method to set the private mode.

eric ide

mercurial