1. Matthew Smith
  2. qtm-1.2

Commits

Matthew Smith  committed 983dfe1

EditingWindow.cc,h - Now honours port & no-SSL settings

  • Participants
  • Parent commits 771045c
  • Branches default

Comments (0)

Files changed (2)

File EditingWindow.cc

View file
  • Ignore whitespace
     QHttpRequestHeader header( "POST", location );
     header.setValue( "Host", server );
     header.setValue( "User-Agent", userAgentString );
-    http->setHost( server, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
+    setHost( http, server, port, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
     http->request( header, requestArray );
 
     addToConsole( header.toString() );
   QHttpRequestHeader header( "POST", location );
   header.setValue( "Host", server );
   header.setValue( "User-Agent", userAgentString );
-  http->setHost( server, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
+  setHost( http, server, port, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
   http->request( header, requestArray );
 
   addToConsole( header.toString() );
 #endif
 }
 
+void EditingWindow::setHost( QHttp *h, QString &serv, QString &pt,
+                             bool cm )
+{
+  int p;
+  bool ok;
+
+  p = pt.toInt( &ok );
+#ifdef DONT_USE_SSL
+  if( !ok )
+    p = 80;
+  h->setHost( serv, p );
+#else
+  if( !ok )
+    p = 0;
+  h->setHost( serv, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp, p );
+#endif
+}
+  
 void EditingWindow::handleResponseHeader( const QHttpResponseHeader &header ) // slot
 {
   if( header.statusCode() == 404 ) {
   currentHttpBusiness = None;
   emit httpBusinessFinished();
 }
+
+#ifndef DONT_USE_SSL
+void EditingWindow::handleSSLErrors( const QList<QSslError> &errorList )
+{
+  int i = errorList.count();
+
+  if( i )
+    statusBar()->showMessage( tr( "%1 SSL errors" ).arg( i ), 2000 );
+}
+#endif
+
 void EditingWindow::changeCurrentBlog( int b ) // slot
 {
   currentBlog = b;
       QHttpRequestHeader header( "POST", location );
       header.setValue( "Host", server );
       header.setValue( "User-Agent", userAgentString );
-      http->setHost( server, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
+      setHost( http, server, port, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
       http->request( header, requestArray );
 
       addToConsole( header.toString() );
   QHttpRequestHeader header( "POST", location );
   header.setValue( "Host", server );
   header.setValue( "User-Agent", userAgentString );
-  http->setHost( server, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
+  setHost( http, server, port, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
   http->request( header, requestArray );
 
   addToConsole( header.toString() );
       QHttpRequestHeader header( "POST", location );
       header.setValue( "Host", server );
       header.setValue( "User-Agent", userAgentString );
-      http->setHost( server, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
+      setHost( http, server, port, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
       http->request( header, requestArray );
 
       if( progressBarAction->isVisible() )
     QHttpRequestHeader header( "POST", location );
     header.setValue( "Host", server );
     header.setValue( "User-Agent", userAgentString );
-    http->setHost( server, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
+    setHost( http, server, port, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
     http->request( header, requestArray );
 
     if( progressBarAction->isVisible() )
               QHttpRequestHeader header( "POST", location );
               header.setValue( "Host", server );
               header.setValue( "User-Agent", userAgentString );
-              http->setHost( server, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
+              setHost( http, server, port, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
               http->request( header, requestArray );
 
               addToConsole( header.toString() );
             QHttpRequestHeader header( "POST", location );
             header.setValue( "Host", server );
             header.setValue( "User-Agent", userAgentString );
-            http->setHost( server, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
+            setHost( http, server, port, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
             http->request( header, requestArray );
 
             addToConsole( header.toString() );
       QHttpRequestHeader header( "POST", location );
       header.setValue( "Host", server );
       header.setValue( "User-Agent", userAgentString );
-      http->setHost( server, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
+      setHost( http, server, port, useHTTPS ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp );
       http->request( header, requestArray );
       /*if( http->connectionMode() == QHttp::ConnectionModeHttps )
         qDebug() << "using HTTPS"; */

File EditingWindow.h

View file
  • Ignore whitespace
 #include <QColor>
 #include <QtXml>
 
+#ifndef DONT_USE_SSL
+#include <QSslError>
+#endif
+
 class QWidget;
 class QStackedWidget;
 // class QSplitter;
   void saveAccountsDom();
   void extractAccountAttributes();
   QString decodeXmlEntities( QString );
+  void setHost( QHttp *, QString &, QString &, bool );
 
   int currentAccount, currentBlog, loadedEntryBlog;
   QString loadedAccountId;
   void stopThisJob();
   void handleDone( bool );
   void handleResponseHeader( const QHttpResponseHeader & );
+#ifndef DONT_USE_SSL
+  void handleSSLErrors( const QList<QSslError> & );
+#endif
   void changeCurrentBlog( int );
   void changeAccount( int );
   void extractAccountDetails();