disk_cache_man::disk_cache_man(unsigned int tout) { setTimeout(tout); setCache("bitcascade-cache"); clearCache(); timeoutThread = new boost::thread(&disk_cache_man::timeoutLoop,this); }
unsigned SuperHashTable::doFindExact(const void *et) const { unsigned i = cache; if (i>=tablesize || table[i]!=et) { #ifdef HASHSIZE_POWER2 i = getHashFromElement(et) & (tablesize - 1); #else i = getHashFromElement(et) % tablesize; #endif unsigned is = i; for (;;) { const void * cur = table[i]; if (!cur || cur == et) break; i++; if (i==tablesize) i = 0; if (i==is) break; } setCache(i); } return i; }
void disk_cache_man::clearCache() { boost::mutex::scoped_lock lock(cache_mut); labelMap.clear(); fs::remove_all(cachepath); setCache("bitcascade-cache"); }
QCustomNetworkAccessManager::QCustomNetworkAccessManager(QNetworkAccessManager *manager, QObject *parent) : QNetworkAccessManager( parent ) { setCache(manager->cache()); setCookieJar(manager->cookieJar()); setProxyFactory(manager->proxyFactory()); }
void pf_Fragments::unlinkFrag(pf_Frag * pf) { // NOTE: it is the caller's responsibility to delete pf if appropriate. UT_return_if_fail (pf->getType() != pf_Frag::PFT_EndOfDoc); pf_Frag * pn = pf->getNext(); pf_Frag * pp = pf->getPrev(); setFragsDirty(); if (pn) { pn->setPrev(pp); } if (pp) pp->setNext(pn); pf->setNext(0); pf->setPrev(0); if (m_pLast == pf) m_pLast = pp; if(m_pFirst == pf) m_pFirst = pn; if (getCache() == pf) setCache(pp); }
NetworkAccessManager::NetworkAccessManager(QObject *parent, bool is_proxy) : QNetworkAccessManager(parent) , proxy_manager_(0) , proxy_exceptions_(0) , is_proxy_(is_proxy) , use_proxy_(false) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), SLOT(onAuthenticationRequired(QNetworkReply*,QAuthenticator*))); connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(onProxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); #ifndef QT_NO_OPENSSL connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), SLOT(onSSLErrors(QNetworkReply*, const QList<QSslError>&))); #endif loadSettings(); QNetworkDiskCache *disk_cache = new QNetworkDiskCache(this); if (disk_cache != 0) { QString location = getCacheLocation(); disk_cache->setCacheDirectory(location); setCache(disk_cache); if (proxy_manager_ != 0) { proxy_manager_->setCache(disk_cache); } } }
void KNetwork::loadSettings() { #if 1 QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); diskCache->setCacheDirectory(location); setCache(diskCache); #endif QNetworkProxy proxy; KDocument doc; if (doc.openDocument(QDesktopServices::storageLocation(QDesktopServices::DataLocation) + "/" + ENGINE_CONFIG_FILE)) { if (doc.getValue("kludget/network/enableProxy", "0").toInt() != 0) { QString host = doc.getValue("kludget/network/proxyHost", ""); QString port = ""; if (host.indexOf(":") != -1) { QStringList tmp = host.split(":"); host = tmp.at(0); port = tmp.at(1); } proxy = QNetworkProxy::HttpProxy; proxy.setHostName(host); proxy.setPort(port.toInt()); proxy.setUser(doc.getValue("kludget/network/proxyUser", "")); proxy.setPassword(Util::decrypt(doc.getValue("kludget/network/proxyPassword", ""))); } } setProxy(proxy); }
NetworkAccessManager::NetworkAccessManager() { m_cookieJar = new NetworkCookieJar(this); setCookieJar(m_cookieJar); m_diskCache = new NetworkDiskCache(this); setCache(m_diskCache); }
void *SuperHashTable::next(const void *et) const { unsigned i; if (!et) { if (!tablecount) return NULL; i = (unsigned) -1; } else { i = doFindExact(et); if (table[i] != et) { assertex(!"SuperHashTable::Next : start item not found"); return NULL; } } while (1) { i++; if (i>=tablesize) return NULL; if (table[i]) break; } setCache(i); return table[i]; }
disk_cache_man::disk_cache_man(unsigned int tout,const string& cacheloc) { setTimeout(tout); setCache(cacheloc); clearCache(); timeoutThread = new boost::thread(&disk_cache_man::timeoutLoop,this); }
MailNetworkManager::MailNetworkManager(QNetworkAccessManager* old, QObject *parent) : QNetworkAccessManager(parent), f_remoteEnabled(false) { setCache(old->cache()); setCookieJar(old->cookieJar()); setProxy(old->proxy()); setProxyFactory(old->proxyFactory()); }
int main(int argc, char *argv[]) { //#if defined(WIN32) && defined(_DEBUG) //TODO: restore this to eliminate console in windows release builds #if defined(WIN32) AllocConsole(); //TODO: add an icon to distribution then enable the commented out code below //QPixmap px(":/images/lightwallet.png"); //HICON hIcon = qt_pixmapToWinHICON(px); //SetConsoleIcon(hIcon); freopen("CONOUT$", "wb", stdout); freopen("CONOUT$", "wb", stderr); printf("testing stdout\n"); fprintf(stderr, "testing stderr\n"); #endif QGuiApplication app(argc, argv); app.setApplicationName(QStringLiteral("BitShares %1 Light Wallet").arg(BTS_BLOCKCHAIN_SYMBOL)); app.setOrganizationName(BTS_BLOCKCHAIN_NAME); app.setOrganizationDomain("bitshares.org"); app.setApplicationVersion("1.0 RC 1"); //Fire up the NTP system bts::blockchain::now(); #ifdef BTS_TEST_NETWORK QQmlDebuggingEnabler enabler; #endif qmlRegisterType<LightWallet>("org.BitShares.Types", 1, 0, "LightWallet"); qmlRegisterUncreatableType<Account>("org.BitShares.Types", 1, 0, "Account", QStringLiteral("Accounts can only be created in backend.")); qmlRegisterUncreatableType<Balance>("org.BitShares.Types", 1, 0, "Balance", QStringLiteral("Balances can only be created in backend.")); qmlRegisterUncreatableType<TransactionSummary>("org.BitShares.Types", 1, 0, "TransactionSummary", QStringLiteral("Transaction summaries can only be created in backend.")); qmlRegisterUncreatableType<LedgerEntry>("org.BitShares.Types", 1, 0, "LedgerEntry", QStringLiteral("Ledger entries can only be created in backend.")); QQmlApplicationEngine engine; auto nam = engine.networkAccessManager(); if( nam ) { QNetworkDiskCache* cache = new QNetworkDiskCache(&engine); cache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/cache"); nam->setCache(cache); } #if QT_VERSION >= 0x050400 engine.rootContext()->setContextProperty("PlatformName", QSysInfo::prettyProductName()); #endif engine.rootContext()->setContextProperty("ManifestUrl", QStringLiteral("https://bitshares.org/manifest.json")); engine.rootContext()->setContextProperty("AppName", QStringLiteral("lw_%1").arg(BTS_BLOCKCHAIN_SYMBOL).toLower()); engine.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); return app.exec(); }
QNetworkAccessManager* StandardNAMFactory::create (QObject *parent) { auto nam = new QNetworkAccessManager (parent); auto cache = new NetworkDiskCache (Subpath_, nam); cache->setMaximumCacheSize (CacheSizeGetter_ ()); nam->setCache (cache); return nam; }
// public: NetworkAccessManager::NetworkAccessManager(QObject *parent, bool diskCacheEnabled) : QNetworkAccessManager(parent), m_networkDiskCache(0) { if (diskCacheEnabled) { m_networkDiskCache = new QNetworkDiskCache(); m_networkDiskCache->setCacheDirectory(QDesktopServices::storageLocation(QDesktopServices::CacheLocation)); setCache(m_networkDiskCache); } connect(this, SIGNAL(finished(QNetworkReply*)), SLOT(handleFinished(QNetworkReply*))); }
void SuperHashTable::kill(void) { releaseAll(); doKill(); tablesize = InitialTableSize; tablecount = 0; setCache(0); table = (void * *) checked_malloc(InitialTableSize*sizeof(void *),-604); memset(table,0,InitialTableSize*sizeof(void *)); }
void NetworkManager::loadSettings() { Settings settings; if (settings.value("Web-Browser-Settings/AllowLocalCache", true).toBool() && !mApp->isPrivateSession()) { QNetworkDiskCache* cache = mApp->networkCache(); cache->setMaximumCacheSize(settings.value("MaximumCacheSize", 50).toInt() * 1024 * 1024); //MegaBytes setCache(cache); } settings.beginGroup("Web-Browser-Settings"); m_doNotTrack = settings.value("DoNotTrack", false).toBool(); m_sendReferer = settings.value("SendReferer", true).toBool(); settings.endGroup(); m_acceptLanguage = AcceptLanguage::generateHeader(settings.value("Language/acceptLanguage", AcceptLanguage::defaultLanguage()).toStringList()); // Falling back to Qt 4.7 default behavior, use SslV3 by default // Fixes issue with some older servers closing the connection // However, it also makes some servers requesting TLS ClientHello // not working, or showing invalid certificates. // See #921 // QSslConfiguration config = QSslConfiguration::defaultConfiguration(); // config.setProtocol(QSsl::SslV3); // QSslConfiguration::setDefaultConfiguration(config); #if defined(Q_OS_WIN) || defined(Q_OS_HAIKU) || defined(Q_OS_OS2) QString certDir = mApp->PROFILEDIR + "certificates"; QString bundlePath = certDir + "/ca-bundle.crt"; QString bundleVersionPath = certDir + "/bundle_version"; if (!QDir(certDir).exists()) { QDir dir(mApp->PROFILEDIR); dir.mkdir("certificates"); } if (!QFile::exists(bundlePath)) { QFile(":data/ca-bundle.crt").copy(bundlePath); QFile(bundlePath).setPermissions(QFile::ReadUser | QFile::WriteUser); QFile(":data/bundle_version").copy(bundleVersionPath); QFile(bundleVersionPath).setPermissions(QFile::ReadUser | QFile::WriteUser); } QSslSocket::setDefaultCaCertificates(QSslCertificate::fromPath(bundlePath)); #else QSslSocket::setDefaultCaCertificates(QSslSocket::systemCaCertificates()); #endif loadCertificates(); m_proxyFactory->loadSettings(); }
short ElemDDLSGOptions::importSGO(const ElemDDLSGOptions *sgo) { if (sgo->isStartValueSpecified()) { setStartValueSpec(TRUE); setStartValue(sgo->getStartValue()); } if (sgo->isIncrementSpecified()) { setIncrementSpec(TRUE); setIncrement(sgo->getIncrement()); } if (sgo->isMinValueSpecified()) { setMinValueSpec(TRUE); if (sgo->isNoMinValue()) setNoMinValue(TRUE); else setMinValue(sgo->getMinValue()); } if (sgo->isMaxValueSpecified()) { setMaxValueSpec(TRUE); if (sgo->isNoMaxValue()) setNoMaxValue(TRUE); else setMaxValue(sgo->getMaxValue()); } if (sgo->isCacheSpecified()) { setCacheSpec(TRUE); setCache(sgo->getCache()); } if (sgo->isCycleSpecified()) { setCycleSpec(TRUE); setCycle(sgo->isCycle()); } if (sgo->isResetSpecified()) { setResetSpec(); setReset(sgo->isReset()); } return 0; }
int QDeclarativeImageBase::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDeclarativeImplicitSizeItem::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 9) qt_static_metacall(this, _c, _id, _a); _id -= 9; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< Status*>(_v) = status(); break; case 1: *reinterpret_cast< QUrl*>(_v) = source(); break; case 2: *reinterpret_cast< qreal*>(_v) = progress(); break; case 3: *reinterpret_cast< bool*>(_v) = asynchronous(); break; case 4: *reinterpret_cast< bool*>(_v) = cache(); break; case 5: *reinterpret_cast< QSize*>(_v) = sourceSize(); break; case 6: *reinterpret_cast< bool*>(_v) = mirror(); break; } _id -= 7; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 1: setSource(*reinterpret_cast< QUrl*>(_v)); break; case 3: setAsynchronous(*reinterpret_cast< bool*>(_v)); break; case 4: setCache(*reinterpret_cast< bool*>(_v)); break; case 5: setSourceSize(*reinterpret_cast< QSize*>(_v)); break; case 6: setMirror(*reinterpret_cast< bool*>(_v)); break; } _id -= 7; } else if (_c == QMetaObject::ResetProperty) { switch (_id) { case 5: resetSourceSize(); break; } _id -= 7; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 7; } #endif // QT_NO_PROPERTIES return _id; }
CNetworkMgr::CNetworkMgr( QObject *pParent, QNetworkAccessManager *pPrev ) : QNetworkAccessManager( pParent ) { if ( pPrev ) { setCache( pPrev->cache() ); setCookieJar( pPrev->cookieJar() ); setProxy( pPrev->proxy() ); setProxyFactory( pPrev->proxyFactory() ); } // end if }
void SuperHashTable::_releaseAll(void) { if (tablecount) { unsigned i; for (i = 0; i < tablesize; i++) { void * et = table[i]; table[i] = NULL; if (et) onRemove(et); } tablecount = 0; setCache(0); } }
void NetworkManager::loadSettings() { Settings settings; settings.beginGroup("Web-Browser-Settings"); if (settings.value("AllowLocalCache", true).toBool()) { m_diskCache = mApp->networkCache(); m_diskCache->setCacheDirectory(mApp->getActiveProfilPath() + "/networkcache"); m_diskCache->setMaximumCacheSize(settings.value("MaximumCacheSize", 50).toInt() * 1024 * 1024); //MegaBytes setCache(m_diskCache); } m_doNotTrack = settings.value("DoNotTrack", false).toBool(); m_sendReferer = settings.value("SendReferer", true).toBool(); settings.endGroup(); m_acceptLanguage = AcceptLanguage::generateHeader(settings.value("Language/acceptLanguage", AcceptLanguage::defaultLanguage()).toStringList()); #ifdef Q_WS_WIN // From doc: // QSslSocket::VerifyNone ... The connection will still be encrypted, and your socket // will still send its local certificate to the peer if it's requested. QSslConfiguration config = QSslConfiguration::defaultConfiguration(); config.setPeerVerifyMode(QSslSocket::VerifyNone); QSslConfiguration::setDefaultConfiguration(config); #endif QString certDir = mApp->PROFILEDIR + "certificates"; QString bundlePath = certDir + "/ca-bundle.crt"; QString bundleVersionPath = certDir + "/bundle_version"; if (!QDir(certDir).exists()) { QDir dir(mApp->PROFILEDIR); dir.mkdir("certificates"); } if (!QFile::exists(bundlePath)) { QFile(":data/ca-bundle.crt").copy(bundlePath); QFile(bundlePath).setPermissions(QFile::ReadUser | QFile::WriteUser); QFile(":data/bundle_version").copy(bundleVersionPath); QFile(bundleVersionPath).setPermissions(QFile::ReadUser | QFile::WriteUser); } QSslSocket::setDefaultCaCertificates(QSslCertificate::fromPath(bundlePath)); m_proxyFactory->loadSettings(); }
short ElemDDLSGOptions::importSGA(const SequenceGeneratorAttributes *sga) { initializeDataMembers(); setFSDataType(sga->getSGFSDataType()); setStartValue(sga->getSGStartValue()); setIncrement(sga->getSGIncrement()); setMinValue(sga->getSGMinValue()); setMaxValue(sga->getSGMaxValue()); setCache(sga->getSGCache()); setCycle(sga->getSGCycleOption()); setReset(sga->getSGResetOption()); return 0; }
NetworkAccessManager::NetworkAccessManager(QObject *parent) : QNetworkAccessManager(parent) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*, QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); connect(this, SIGNAL(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*)), SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); #ifndef QT_NO_OPENSSL connect(this, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), SLOT(sslErrors(QNetworkReply*, const QList<QSslError>&))); #endif loadSettings(); QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); diskCache->setCacheDirectory(location); setCache(diskCache); }
NetworkAccessManager::NetworkAccessManager(QObject *parent) : QNetworkAccessManager(parent), requestFinishedCount(0), requestFinishedFromCacheCount(0), requestFinishedPipelinedCount(0), requestFinishedSecureCount(0), requestFinishedDownloadBufferCount(0) { connect(this, SIGNAL(finished(QNetworkReply*)), SLOT(requestFinished(QNetworkReply*))); #ifndef QT_NO_OPENSSL connect(this, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); #endif loadSettings(); QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); QString location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); diskCache->setCacheDirectory(location); setCache(diskCache); }
int __newindex(lua_State *L) { SLB_DEBUG_CALL; SLB_DEBUG_CLEAN_STACK(L,-2); SLB_DEBUG_STACK(6,L, "Call InternalHybridSubclass(%p)::__nexindex", this); //1 = table //2 = string //3 = function luaL_checkstring(L,2); if (lua_type(L,3) != LUA_TFUNCTION) { luaL_error(L, "Only functions can be added to hybrid classes" " (invalid %s of type %s)", lua_tostring(L,2), lua_typename(L, 3)); } SLB_DEBUG(4, "Added method to an hybrid-subclass:%s", lua_tostring(L,2)); lua_pushcclosure(L, HybridBase::call_lua_method, 1); // replaces setCache(L); return 0; }
/*! * This method clears out and repopulates the vector of pointers to fragments. * It also sets the doc Positions of all the fragments. */ void pf_Fragments::cleanFrags(void) const { if (m_vecFrags.getItemCount() > 0) m_vecFrags.clear(); pf_Frag * pfLast = NULL; PT_DocPosition sum = 0; for (pf_Frag * pf = getFirst(); (pf); pf=pf->getNext()) { pf->setPos(sum); sum += pf->getLength(); pfLast = pf; m_vecFrags.addItem((void *) pf); } UT_return_if_fail (pfLast /*&& (pfLast->getType() == pf_Frag::PFT_EndOfDoc)*/); xxx_UT_DEBUGMSG(("Found %d Frags dopos at end = %d \n",m_vecFrags.getItemCount(),getLast()->getPos())); m_bAreFragsClean = true; setCache(NULL); }
unsigned SuperHashTable::doFindElement(unsigned v, const void * findET) const { #ifdef HASHSIZE_POWER2 v = v & (tablesize - 1); #else v = v % tablesize; #endif unsigned vs = v; #ifdef TRACE_HASH unsigned searchlen = 0; #endif while (1) { #ifdef MY_TRACE_HASH my_search_tot++; #endif void *et = table[v]; if (!et) break; if (matchesElement(et, findET)) break; #ifdef TRACE_HASH searchlen ++; #endif v++; if (v==tablesize) v = 0; if (v==vs) break; } #ifdef MY_TRACE_HASH my_search_num++; if(my_search_num != 0) printf("Hash table average search length %d\n", (int) (my_search_tot/my_search_num)); #endif #ifdef TRACE_HASH note_searchlen(searchlen); #endif setCache(v); return v; }
NetworkManager::NetworkManager(QObject *parent) : QNetworkAccessManager(parent) { #if QT_VERSION<0x050000 cacheDir = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); #else cacheDir = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first(); #endif while (cacheDir.endsWith(QDir::separator())) { cacheDir.remove(cacheDir.length()-1, 1); }; cacheDir.append(QDir::separator()); cacheDir.append("LiturgicalOrthodoxCalendar"); diskCache = new QNetworkDiskCache(this); diskCache->setCacheDirectory(cacheDir); setCache(diskCache); connect(this, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); initTemporaryFiles(); }
unsigned SuperHashTable::doFindNew(unsigned v) const { #ifdef HASHSIZE_POWER2 v = v & (tablesize - 1); #else v = v % tablesize; #endif unsigned vs = v; #ifdef TRACE_HASH unsigned searchlen = 0; #endif while (1) { #ifdef MY_TRACE_HASH my_search_tot++; #endif void *et = table[v]; if (!et) break; #ifdef TRACE_HASH searchlen ++; #endif v++; if (v==tablesize) v = 0; if (v==vs) break; //table is full, should never occur } #ifdef MY_TRACE_HASH my_search_num++; if(my_search_num != 0) printf("Hash table average search length %d\n", (int) (my_search_tot/my_search_num)); #endif #ifdef TRACE_HASH note_searchlen(searchlen); #endif setCache(v); return v; }
NetworkAccessManager::NetworkAccessManager(QObject *parent) : QNetworkAccessManager(parent), requestFinishedCount(0), requestFinishedFromCacheCount(0), requestFinishedPipelinedCount(0), requestFinishedSecureCount(0) { connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)), SLOT(authenticationRequired(QNetworkReply*,QAuthenticator*))); connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)), SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*))); connect(this, SIGNAL(finished(QNetworkReply*)), SLOT(requestFinished(QNetworkReply*))); #ifndef QT_NO_OPENSSL connect(this, SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), SLOT(sslErrors(QNetworkReply*,QList<QSslError>))); #endif loadSettings(); QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); diskCache->setCacheDirectory(location); setCache(diskCache); }