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


C++ Proxy::setProxyType方法代码示例

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


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

示例1: getautoproxy

Proxy* WinHttpIO::getautoproxy()
{
    Proxy* proxy = new Proxy();
    proxy->setProxyType(Proxy::NONE);

    WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieProxyConfig = { 0 };

    if (WinHttpGetIEProxyConfigForCurrentUser(&ieProxyConfig) == TRUE)
    {
        if (ieProxyConfig.lpszProxy)
        {
            string proxyURL;
            proxy->setProxyType(Proxy::CUSTOM);
            int len = wcslen(ieProxyConfig.lpszProxy);
            proxyURL.assign((const char*)ieProxyConfig.lpszProxy, len * sizeof(wchar_t) + 1);

            // only save one proxy
            for (int i = 0; i < len; i++)
            {
                wchar_t* character = (wchar_t*)(proxyURL.data() + i * sizeof(wchar_t));

                if (*character == ' ' || *character == ';')
                {
                    proxyURL.resize(i*sizeof(wchar_t));
                    len = i;
                    break;
                }
            }

            // remove protocol prefix, if any
            for (int i = len - 1; i >= 0; i--)
            {
                wchar_t* character = (wchar_t*)(proxyURL.data() + i * sizeof(wchar_t));

                if (*character == '/')
                {
                    proxyURL = proxyURL.substr((i + 1) * sizeof(wchar_t));
                    break;
                }
            }

            proxy->setProxyURL(&proxyURL);
        }
        else if (ieProxyConfig.lpszAutoConfigUrl || ieProxyConfig.fAutoDetect == TRUE)
        {
            WINHTTP_AUTOPROXY_OPTIONS autoProxyOptions;

            if (ieProxyConfig.lpszAutoConfigUrl)
            {
                autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL;
                autoProxyOptions.lpszAutoConfigUrl = ieProxyConfig.lpszAutoConfigUrl;
                autoProxyOptions.dwAutoDetectFlags = 0;
            }
            else
            {
                autoProxyOptions.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT;
                autoProxyOptions.lpszAutoConfigUrl = NULL;
                autoProxyOptions.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP | WINHTTP_AUTO_DETECT_TYPE_DNS_A;
            }

            autoProxyOptions.fAutoLogonIfChallenged = TRUE;
            autoProxyOptions.lpvReserved = NULL;
            autoProxyOptions.dwReserved = 0;

            WINHTTP_PROXY_INFO proxyInfo;

            if (WinHttpGetProxyForUrl(hSession, L"https://g.api.mega.co.nz/", &autoProxyOptions, &proxyInfo))
            {
                if (proxyInfo.lpszProxy)
                {
                    string proxyURL;
                    proxy->setProxyType(Proxy::CUSTOM);
                    proxyURL.assign((const char*)proxyInfo.lpszProxy, wcslen(proxyInfo.lpszProxy) * sizeof(wchar_t));
                    proxy->setProxyURL(&proxyURL);
                }
            }
        }
    }

    if (ieProxyConfig.lpszProxy)
    {
        GlobalFree(ieProxyConfig.lpszProxy);
    }

    if (ieProxyConfig.lpszProxyBypass)
    {
        GlobalFree(ieProxyConfig.lpszProxyBypass);
    }

    if (ieProxyConfig.lpszAutoConfigUrl)
    {
        GlobalFree(ieProxyConfig.lpszAutoConfigUrl);
    }

    return proxy;
}
开发者ID:ChurchOfTheWord,项目名称:sdk,代码行数:96,代码来源:net.cpp

示例2: testUndo

void UndoTest::testUndo() {
    // we maintain 2 World objects, a "undo" World and a "reference" world
    //
    // we will do some changes on both worlds and then do some changes on
    // the "undo" world only. after calling undo, both worlds should be
    // synced again.
    //
    // whenever we start tests, both worlds should be synced.
    World undoWorld;
    World referenceWorld;

    // add simple proxies and never move them
    // this tests in particular that a undoStep() call does not change
    // things that shouldnt change
    undoWorld.addProxy(undoWorld.createProxy(new Box(10, 10, 10)));
    referenceWorld.addProxy(referenceWorld.createProxy(new Box(10, 10, 10)));

    // add simple proxies, move them before adding, never move them
    // afterwards
    // this tests in particular that a undoStep() call does not change
    // things that shouldnt change
    Proxy* staticUndoProxy = undoWorld.createProxy(new Box(10, 10, 10));
    Proxy* staticRefereceProxy = referenceWorld.createProxy(new Box(10, 10, 10));
    staticUndoProxy->translate(-10, 10, 5);
    staticRefereceProxy->translate(-10, 10, 5);
    undoWorld.addProxy(staticUndoProxy);
    referenceWorld.addProxy(staticRefereceProxy);

    // add simple proxies, but move them before adding
    Proxy* proxyUndoWorld = undoWorld.createProxy(new Box(10, 10, 10));
    Proxy* proxyReferenceWorld = referenceWorld.createProxy(new Box(10, 10, 10));
    proxyUndoWorld->translate(-10, 10, 5);
    proxyReferenceWorld->translate(-10, 10, 5);
    undoWorld.addProxy(proxyUndoWorld);
    referenceWorld.addProxy(proxyReferenceWorld);

    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));
    undoWorld.startNextStep();
    referenceWorld.startNextStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // undo simple translations
    proxyUndoWorld->translate(100, 100, 100);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // undo multiple translations
    proxyUndoWorld->translate(100, 100, 100);
    proxyUndoWorld->translate(100, 300, 200);
    proxyUndoWorld->translate(100, 400, 500);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // undo simple rotations
    proxyUndoWorld->rotate(45, 1, 0, 0);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // undo multiple simple rotations
    proxyUndoWorld->rotate(45, 1, 0, 0);
    proxyUndoWorld->rotate(15, 1, 0, 0);
    proxyUndoWorld->rotate(45, 0, 1, 0);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // undo translations and rotations
    proxyUndoWorld->translate(100, 100, 100);
    proxyUndoWorld->rotate(45, 1, 0, 0);
    proxyUndoWorld->translate(100, 1, 100);
    proxyUndoWorld->rotate(15, 1, 0, 0);
    proxyUndoWorld->translate(100, 20, 100);
    proxyUndoWorld->rotate(45, 0, 1, 0);
    proxyUndoWorld->translate(100, 100, 400);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // undo setTransformation()
    Matrix m;
    m.translate(100, 0, 0);
    proxyUndoWorld->setTransformation(m);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // undo multiple setTransformation()
    m = Matrix();
    m.translate(100, 0, 0);
    proxyUndoWorld->setTransformation(m);
    m.translate(0, 50, 0);
    proxyUndoWorld->setTransformation(m);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // undo setProxyType()
    proxyUndoWorld->setProxyType(PROXYTYPE_DEFORMABLE);
    undoWorld.undoStep();
    CPPUNIT_ASSERT_EQUAL(true, checkWorldsAreEqual(&undoWorld, &referenceWorld));

    // undo multiple setProxyType()
    proxyUndoWorld->setProxyType(PROXYTYPE_DEFORMABLE);
    proxyUndoWorld->setProxyType(PROXYTYPE_FIXED);
//.........这里部分代码省略.........
开发者ID:ColinGilbert,项目名称:d-collide,代码行数:101,代码来源:undotest.cpp


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