Bug 586799 - Incubator embedding: MozView should auto-connect. r=mark.finkle
authorTatiana Meshkova <tanya.meshkova@gmail.com>
Wed, 18 Aug 2010 21:25:04 -0700
changeset 128 fd2905d0088cd27ed8cfd4c33fad8a65a914b6f0
parent 127 13ee3bfc6a101b4adb4b166bce524d8935231776
child 129 64e8cf2dd4e9566f0eba048550db463a7032656f
push id40
push userromaxa@gmail.com
push dateThu, 19 Aug 2010 04:25:25 +0000
reviewersmark.finkle
bugs586799
Bug 586799 - Incubator embedding: MozView should auto-connect. r=mark.finkle
qt/test/test.cpp
--- a/qt/test/test.cpp
+++ b/qt/test/test.cpp
@@ -35,19 +35,32 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <QApplication>
 #include <QDebug>
 #include <QPushButton>
 #include <QGraphicsProxyWidget>
+#include <nsCOMPtr.h>
+#include <nsIIOService.h>
+#include <nsNetUtil.h>
 
 #include "test.h"
 
+static nsresult ForceOnline()
+{
+    nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID);
+    if (!ioService)
+        return NS_ERROR_FAILURE;
+
+    ioService->SetOffline(PR_FALSE);
+    return NS_OK;
+}
+
 MyQGraphicsView::MyQGraphicsView(QGraphicsScene* scene, QWidget* parent)
  : QGraphicsView(scene, parent)
 {
     setAlignment(Qt::AlignLeft | Qt::AlignTop);
     setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 
     mLayout = new QGraphicsGridLayout;
@@ -97,16 +110,19 @@ MyQGraphicsView::~MyQGraphicsView()
 void MyQGraphicsView::resizeEvent(QResizeEvent* event)
 {
     mForm->resize(event->size());
     QGraphicsView::resizeEvent(event);
 }
 
 void MyQGraphicsView::loadUri(const QString& uri)
 {
+    // ForceOnline() must be called before any network call
+    // in order to get connectivity working
+    ForceOnline();
     mozView->loadUri(uri);
 }
 
 void MyQGraphicsView::consoleMessage(const QString& message)
 {
     qDebug() << "CONSOLE:" << message;
 }