当前位置: 首页>>代码示例>>C++>>正文


C++ QNetworkConfigurationManager::allConfigurations方法代码示例

本文整理汇总了C++中QNetworkConfigurationManager::allConfigurations方法的典型用法代码示例。如果您正苦于以下问题:C++ QNetworkConfigurationManager::allConfigurations方法的具体用法?C++ QNetworkConfigurationManager::allConfigurations怎么用?C++ QNetworkConfigurationManager::allConfigurations使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QNetworkConfigurationManager的用法示例。


在下文中一共展示了QNetworkConfigurationManager::allConfigurations方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: comparison

void tst_QNetworkConfiguration::comparison()
{
    //test copy constructor and assignment operator
    //compare invalid connection points
    QNetworkConfiguration pt1;
    QVERIFY(!pt1.isValid());
    QVERIFY(pt1.type() == QNetworkConfiguration::Invalid);

    QNetworkConfiguration pt2(pt1);
    QVERIFY(pt1==pt2);
    QVERIFY(!(pt1!=pt2));
    QVERIFY(pt1.name() == pt2.name());
    QVERIFY(pt1.isValid() == pt2.isValid());
    QVERIFY(pt1.type() == pt2.type());
    QVERIFY(pt1.state() == pt2.state());
    QVERIFY(pt1.purpose() == pt2.purpose());


    QNetworkConfiguration pt3;
    pt3 = pt1;
    QVERIFY(pt1==pt3);
    QVERIFY(!(pt1!=pt3));
    QVERIFY(pt1.name() == pt3.name());
    QVERIFY(pt1.isValid() == pt3.isValid());
    QVERIFY(pt1.type() == pt3.type());
    QVERIFY(pt1.state() == pt3.state());
    QVERIFY(pt1.purpose() == pt3.purpose());

    //test case must run on machine that has valid connection points
    QNetworkConfigurationManager manager;
    QList<QNetworkConfiguration> preScanConfigs = manager.allConfigurations();

    QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
    manager.updateConfigurations(); //initiate scans
    QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete

    QList<QNetworkConfiguration> configs = manager.allConfigurations(QNetworkConfiguration::Discovered);
    QVERIFY(configs.count());
    QNetworkConfiguration defaultConfig = manager.defaultConfiguration();
    QVERIFY(defaultConfig.isValid());
    QVERIFY(defaultConfig.type() != QNetworkConfiguration::Invalid);
    QVERIFY(!defaultConfig.name().isEmpty());

    pt3 = defaultConfig;
    QVERIFY(defaultConfig==pt3);
    QVERIFY(!(defaultConfig!=pt3));
    QVERIFY(defaultConfig.name() == pt3.name());
    QVERIFY(defaultConfig.isValid() == pt3.isValid());
    QVERIFY(defaultConfig.type() == pt3.type());
    QVERIFY(defaultConfig.state() == pt3.state());
    QVERIFY(defaultConfig.purpose() == pt3.purpose());
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:52,代码来源:tst_qnetworkconfiguration.cpp

示例2: main

QT_USE_NAMESPACE


#define NO_DISCOVERED_CONFIGURATIONS_ERROR 1
#define SESSION_OPEN_ERROR 2


int main(int argc, char** argv)
{
    QCoreApplication app(argc, argv);

#ifndef QT_NO_BEARERMANAGEMENT
    // Update configurations so that everything is up to date for this process too.
    // Event loop is used to wait for awhile.
    QNetworkConfigurationManager manager;
    manager.updateConfigurations();
    QEventLoop iIgnoreEventLoop;
    QTimer::singleShot(3000, &iIgnoreEventLoop, SLOT(quit()));
    iIgnoreEventLoop.exec();

    QList<QNetworkConfiguration> discovered =
        manager.allConfigurations(QNetworkConfiguration::Discovered);

    foreach(QNetworkConfiguration config, discovered) {
        qDebug() << "Lackey: Name of the config enumerated: " << config.name();
        qDebug() << "Lackey: State of the config enumerated: " << config.state();
    }
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:27,代码来源:main.cpp

示例3: setupNetwork

static void setupNetwork(GlobalSettings *settings)
{
    QNetworkProxy proxy;
    if (settings->isEnabled(GlobalSettings::Proxy)) {
        QString proxyHost(settings->value(GlobalSettings::ProxyHost).toString());
        int proxyPort = settings->value(GlobalSettings::ProxyPort).toInt();
        proxy.setType(QNetworkProxy::HttpProxy);
        proxy.setHostName(proxyHost);
        proxy.setPort(proxyPort);
        QNetworkProxy::setApplicationProxy(proxy);
        qWarning() << "Using proxy host" << proxyHost << "on port" << proxyPort;
    }

    // Set Internet Access Point
    QNetworkConfigurationManager mgr;
    QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations();
    if (activeConfigs.count() <= 0)
        return;

    QNetworkConfiguration cfg = activeConfigs.at(0);
    foreach(QNetworkConfiguration config, activeConfigs) {
        if (config.type() == QNetworkConfiguration::UserChoice) {
            cfg = config;
            break;
        }
    }

    g_networkSession = new QNetworkSession(cfg);
    g_networkSession->open();
    g_networkSession->waitForOpened(-1);
}
开发者ID:qtmediahub,项目名称:sasquatch,代码行数:31,代码来源:main.cpp

示例4: allConfigurations

void tst_QNetworkConfigurationManager::allConfigurations()
{
    QNetworkConfigurationManager manager;
    QList<QNetworkConfiguration> preScanConfigs = manager.allConfigurations();

    foreach(QNetworkConfiguration c, preScanConfigs)
    {
        QVERIFY2(c.type()!=QNetworkConfiguration::UserChoice, "allConfiguration must not return UserChoice configs");
    }
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:9,代码来源:tst_qnetworkconfigurationmanager.cpp

示例5: children

void tst_QNetworkConfiguration::children()
{
    QNetworkConfigurationManager manager;
    QList<QNetworkConfiguration> configs = manager.allConfigurations();

    foreach(QNetworkConfiguration c, configs)
    {
        if ( c.type() == QNetworkConfiguration::ServiceNetwork ) {
            qDebug() << "found service network" << c.name() << c.children().count();
            QVERIFY(c.isValid());
            QList<QNetworkConfiguration> members = c.children();
            foreach(QNetworkConfiguration child, members) {
                QVERIFY(child.isValid());
                QVERIFY(configs.contains(child));
                qDebug() << "\t" << child.name();
            }
        }
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:17,代码来源:tst_qnetworkconfiguration.cpp

示例6: toggleProxy

void MainWindow::toggleProxy(){
#ifdef Q_WS_MAC
    /*
    CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL);
    if(!dict){
        qDebug()<<"no proxy";
    }
    */


    QNetworkConfigurationManager mgr;
    QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active);
    QList<QString> activeNames;
    foreach(QNetworkConfiguration cf,activeConfigs){
        //qDebug()<<"new work activated:"<<cf.type()<<cf.state()<<cf.name()<<cf.bearerTypeName()<<cf.identifier();

        activeNames.append(cf.name());
    }
开发者ID:feidianbo,项目名称:Rythem,代码行数:18,代码来源:mainwindow.cpp

示例7: syncDir

void OwncloudSyncd::syncDir(const QString& localPath){

    qDebug() << "\n"<< endl;

    /*
    QStringList files = watcher->files();

    qDebug() << files.size() << "Files To Check";

    bool filesToSync = false;

    for(int i = 0; i < files.size(); i++){
        qDebug() << "Sync File: " << files.at(i);
        QFileInfo fileInfo(files.at(i));
        if(!fileInfo.isHidden() || fileInfo.isDir()){
            filesToSync = true;
            break;
        }
    }

    if(!filesToSync){
        qDebug() << "Only Hidden Files - Quitting";
        return;
    }
    */

    //m_watcher->blockSignals(true);

    if (QFile(localPath + "/.csync_journal.db-shm").exists() ||
          QFile(localPath + "/.csync_journal.db-wal").exists()  ){

        qDebug() << "Delete Stale Database File";

        QFile::remove(localPath + "/.csync_journal.db-shm");
        QFile::remove(localPath + "/.csync_journal.db-wal");

    }

    //Create a connection manager, establish is a data connection is avaiable
    QNetworkConfigurationManager mgr;
    qDebug() << "Network Connection Type: " << mgr.defaultConfiguration().bearerTypeName();
    qDebug() << "Mobile Data Sync: " << m_mobileData;

    QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active);
    if (!activeConfigs.count()){
        qWarning() << "No Data Connection Available  - Quiting";
        return;
    } else {

        QNetworkConfiguration::BearerType connType = mgr.defaultConfiguration().bearerType();
        if(!m_mobileData){
            if(connType != QNetworkConfiguration::BearerEthernet && connType != QNetworkConfiguration::BearerWLAN){
                qDebug() << "No Sync on Mobile Data - Check User Settings - Quitting";
                return;
            }
        }

        //Either mobile data sync is allowed or Ethernet or Wifi is available
        //stop m_timer running while syncing
        m_timer->stop();
    }

    QString protocol;

    if(m_ssl){
        protocol = "https://";
    }else{
        protocol = "https://";
    }

    QString remotePath = protocol + m_serverURL + QStringLiteral("/remote.php/webdav") + m_folderMap.value(localPath);
    qDebug() << "Starting Owncloud Sync from " << localPath << " to " << remotePath;

    /* Needs more work
    QUrl url(remotePath);

    if (!url.isValid()) {
        qDebug() << QString("Remote Path Seems Invalid: %1").arg(url.toString());
    }else{
        qDebug() << "Remote Path Seems Valid";
    }
    */

    QString owncloudcmd;

    if( QFile("/opt/click.ubuntu.com/owncloud-sync/current/Owncloud-Sync/lib/arm-linux-gnueabihf/bin/owncloudcmd").exists()){
        owncloudcmd = "/opt/click.ubuntu.com/owncloud-sync/current/Owncloud-Sync/lib/arm-linux-gnueabihf/bin/owncloudcmd";
        qDebug() << "Using Arm owncloudcmd Binary - Mobile?";
    }else{
        owncloudcmd = "owncloudcmd";
        qDebug() << "Using Local owncloudcmd Binary - Desktop?";
    }


    QStringList arguments;
    arguments << "--user" << m_username << "--password" << m_password << "--silent" << "--non-interactive" << localPath << remotePath;



    QProcess *owncloudsync = new QProcess();
//.........这里部分代码省略.........
开发者ID:dubstar-04,项目名称:owncloud-sync,代码行数:101,代码来源:owncloudsyncd.cpp


注:本文中的QNetworkConfigurationManager::allConfigurations方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。