qtmobility/tests/auto/qnetworksession/lackey/main.cpp
changeset 11 06b8e2af4411
parent 4 90517678cc4f
equal deleted inserted replaced
8:71781823f776 11:06b8e2af4411
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the Qt Mobility Components.
     7 ** This file is part of the Qt Mobility Components.
     8 **
     8 **
    44 #include <QLocalSocket>
    44 #include <QLocalSocket>
    45 #include "../../../../src/bearer/qnetworkconfigmanager.h"
    45 #include "../../../../src/bearer/qnetworkconfigmanager.h"
    46 #include "../../../../src/bearer/qnetworkconfiguration.h"
    46 #include "../../../../src/bearer/qnetworkconfiguration.h"
    47 #include "../../../../src/bearer/qnetworksession.h"
    47 #include "../../../../src/bearer/qnetworksession.h"
    48 
    48 
       
    49 #include <QEventLoop>
       
    50 #include <QTimer>
    49 #include <QDebug>
    51 #include <QDebug>
    50 
    52 
    51 QTM_USE_NAMESPACE
    53 QTM_USE_NAMESPACE
    52 
    54 
    53 
    55 
    57 
    59 
    58 int main(int argc, char** argv)
    60 int main(int argc, char** argv)
    59 {
    61 {
    60     QCoreApplication app(argc, argv);
    62     QCoreApplication app(argc, argv);
    61 
    63 
       
    64     // Update configurations so that everything is up to date for this process too.
       
    65     // Event loop is used to wait for awhile.
    62     QNetworkConfigurationManager manager;
    66     QNetworkConfigurationManager manager;
       
    67     manager.updateConfigurations();
       
    68     QEventLoop iIgnoreEventLoop;
       
    69     QTimer::singleShot(3000, &iIgnoreEventLoop, SLOT(quit()));
       
    70     iIgnoreEventLoop.exec();
       
    71 
    63     QList<QNetworkConfiguration> discovered =
    72     QList<QNetworkConfiguration> discovered =
    64         manager.allConfigurations(QNetworkConfiguration::Discovered);
    73         manager.allConfigurations(QNetworkConfiguration::Discovered);
    65 
    74 
    66         foreach(QNetworkConfiguration config, discovered) {
    75         foreach(QNetworkConfiguration config, discovered) {
    67             qDebug() << "Lackey: Name of the config enumerated: " << config.name();
    76             qDebug() << "Lackey: Name of the config enumerated: " << config.name();
    73         return NO_DISCOVERED_CONFIGURATIONS_ERROR;
    82         return NO_DISCOVERED_CONFIGURATIONS_ERROR;
    74     }
    83     }
    75 
    84 
    76     // Cannot read/write to processes on WinCE or Symbian.
    85     // Cannot read/write to processes on WinCE or Symbian.
    77     // Easiest alternative is to use sockets for IPC.
    86     // Easiest alternative is to use sockets for IPC.
    78 
       
    79     QLocalSocket oopSocket;
    87     QLocalSocket oopSocket;
    80 
    88 
    81     oopSocket.connectToServer("tst_qnetworksession");
    89     oopSocket.connectToServer("tst_qnetworksession");
    82     oopSocket.waitForConnected(-1);
    90     oopSocket.waitForConnected(-1);
    83 
    91