/* * Constructor * * @param listView The list view to display packages * @param spinner The spinner to configure the number of archive to keep * @param refreshBtn The refresh view button * @param cleanBtn The clean button */ PackageGroupModel::PackageGroupModel(QString optionsString, QListWidget *listView, QSpinBox *spinner, QPushButton *refreshBtn, QPushButton *cleanBtn) : QObject(NULL), m_optionsString(optionsString), m_listView(listView), m_spinner(spinner), m_refreshButton(refreshBtn), m_cleanButton(cleanBtn), m_cmd(new UnixCommand(this)), m_acc(new ProcessOutputAccumulator(m_cmd)), m_oldKeepValue(spinner->value()) { m_cleanButton->setText(tr("Clean")); //setup UI slots connect( m_spinner, SIGNAL( valueChanged(int) ), SLOT( updateKeepArchives() ) ); connect( m_spinner, SIGNAL( valueChanged(int) ), SLOT( refreshCacheView() ) ); connect( m_spinner, SIGNAL( editingFinished() ), SLOT( keepArchivesChanged() ) ); connect( m_refreshButton, SIGNAL( clicked() ), SLOT( refreshCacheView() ) ); connect( m_cleanButton, SIGNAL( clicked() ), SLOT( cleanCache() ) ); isExecutingCommand = false; //refresh cache informations at startup refreshCacheView(); }
MetricsCache * MetricsCache::instance(std::string & symbol) { if(symbol_ != symbol) { cleanCache(); symbol_ = symbol; } if(0 == instance_) { instance_ = new MetricsCache(); } return instance_; }
void setStopIssued(int val) { pthread_mutex_lock(&stopMutex); stopIssued = val; if(stopIssued==1) { shutdown(socket_desc,SHUT_RDWR); close(socket_desc); freeAPIs(); cleanCache(); puts("Server Stopped"); } pthread_mutex_unlock(&stopMutex); }
int main(int argc, char *argv[]) { if (getuid()!=0) { string args; for (int i=0; i<argc; i++) { args+=(string) argv[i] + " "; } return system("kdesu " + args); } setlocale(LC_ALL, ""); bindtextdomain( "installpkg-ng", "/usr/share/locale"); textdomain("installpkg-ng"); QApplication app(argc, argv); QTranslator translator; translator.load("/usr/share/mpkg/pkgmanager_ru"); app.installTranslator(&translator); MainWindow mw; QObject::connect(mw.ui.selectAllButton, SIGNAL(clicked()), &mw, SLOT(selectAll())); QObject::connect(mw.ui.deselectAllButton, SIGNAL(clicked()), &mw, SLOT(deselectAll())); QObject::connect(mw.ui.actionQuit, SIGNAL(triggered()), &mw, SLOT(quitApp())); QObject::connect(mw.ui.quitButton, SIGNAL(clicked()), &mw, SLOT(quitApp())); QObject::connect(mw.ui.applyButton, SIGNAL(clicked()), &mw, SLOT(commitChanges())); QObject::connect(mw.ui.actionAbout, SIGNAL(triggered()), &mw, SLOT(showAbout())); QObject::connect(mw.ui.actionReset_changes, SIGNAL(triggered()), &mw, SLOT(resetChanges())); QObject::connect(mw.ui.actionReset_all_queue, SIGNAL(triggered()), &mw, SLOT(resetQueue())); QObject::connect(mw.ui.actionPreferences, SIGNAL(triggered()), &mw, SLOT(showPreferences())); QObject::connect(mw.ui.actionAdd_remove_repositories, SIGNAL(triggered()), &mw, SLOT(showAddRemoveRepositories())); QObject::connect(mw.ui.actionClean_cache, SIGNAL(triggered()), &mw, SLOT(cleanCache())); QObject::connect(mw.ui.actionShow_installed, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter())); QObject::connect(mw.ui.actionShow_deprecated, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter())); QObject::connect(mw.ui.actionShow_available, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter())); QObject::connect(mw.ui.actionShow_queue, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter())); QObject::connect(mw.ui.actionShow_configexist, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter())); QObject::connect(mw.ui.actionShow_unavailable, SIGNAL(triggered()), &mw, SLOT(applyPackageFilter())); QObject::connect(mw.ui.actionCore_settings, SIGNAL(triggered()), &mw, SLOT(showCoreSettings())); QObject::connect(mw.ui.actionUpdate_data, SIGNAL(triggered()), &mw, SLOT(updateData())); QObject::connect(mw.ui.packageTable, SIGNAL(itemSelectionChanged()), &mw, SLOT(showPackageInfo())); QObject::connect(mw.ui.quickPackageSearchEdit, SIGNAL(textEdited(const QString &)), &mw, SLOT(applyPackageFilter())); int ret = app.exec(); return ret; }
bool Server::updateTime(bool noCleanCache) { clock_gettime(CLOCK_MONOTONIC, &curTime); clock_gettime(CLOCK_REALTIME, &curClockTime); tm time; gmtime_r(&curClockTime.tv_sec, &time); curRFCTime.len = rfctime(time, curRFCTime.d); if (noCleanCache) return true; timespec tmp1 = curTime; tmp1.tv_sec -= routeCacheCleanInterval; //printf("%i\n",tsCompare(_lastClean, tmp1)); if (tsCompare(_lastClean, tmp1) < 0) { _lastClean = curTime; return cleanCache(); } return true; }
bool LCache::findInCache(vector<WClause*> CNF, LogDouble& val) { if(CNF.size() > MAXCNFSIZE || CNF.size() == 0) return false; //for(unsigned int i=0;i<currentIndex;i++) vector<LCacheEntry*> tempCache = cacheIndex[CNF.size() - 1]; //for(unsigned int i=0;i<cacheEntries.size();i++) for(unsigned int i=0;i<tempCache.size();i++) { if(tempCache[i]) { if(unifier->CNFUnify(tempCache[i]->CNF,CNF)) { val = tempCache[i]->wCount; tempCache[i]->hits++; successfulHits++; #ifdef __DEBUG_PRINT__ cout<<"Cache Hit "<<i<<endl; for(unsigned int j=0;j<tempCache[i]->CNF.size();j++) { if(tempCache[i]->CNF[j]->satisfied) cout<<"Satisfied V "; tempCache[i]->CNF[j]->print(); } cout<<"******************"<<endl; for(unsigned int j=0;j<CNF.size();j++) { if(CNF[j]->satisfied) cout<<"Satisfied V "; CNF[j]->print(); } cout<<"sucesssful hit end"<<endl; #endif hits++; return true; } } } misses++; if(isFull() && (double)misses/(double)(misses+hits) > 0.5) { cleanCache(0); hits = 0; misses = 0; } return false; }
void TTRssFetcher::startFetching() { auto s = Settings::instance(); auto db = DatabaseManager::instance(); if (!db->makeBackup ()) { qWarning() << "Unable to make DB backup"; emit error(506); setBusy(false); return; } db->cleanDashboards(); DatabaseManager::Dashboard d; d.id = "ttrss"; d.name = "Default"; d.title = "Default"; d.description = "Tiny Tiny Rss default dashboard"; db->writeDashboard(d); s->setDashboardInUse(d.id); db->cleanTabs(); db->cleanStreams(); db->cleanModules(); if(busyType == Fetcher::Initiating) { db->cleanCache(); db->cleanEntries(); } commandList.clear(); commandList.append(&TTRssFetcher::fetchCategories); commandList.append(&TTRssFetcher::fetchFeeds); commandList.append(&TTRssFetcher::fetchStream); commandList.append(&TTRssFetcher::fetchStarredStream); commandList.append(&TTRssFetcher::fetchPublishedStream); commandList.append(&TTRssFetcher::pruneOld); proggressTotal = commandList.size() + s->getRetentionDays(); proggress = 0; lastDate = 0; offset = 0; callNextCmd(); }
void FontEngine::readSettings() { m_default_size[FM_Standard] = m_settings->getU16("font_size"); m_default_size[FM_Fallback] = m_settings->getU16("fallback_font_size"); m_default_size[FM_Mono] = m_settings->getU16("mono_font_size"); if (is_yes(_("needs_fallback_font"))) { m_currentMode = FM_Fallback; } else { m_currentMode = FM_Standard; } m_default_size[FM_Simple] = m_settings->getU16("font_size"); m_default_size[FM_SimpleMono] = m_settings->getU16("mono_font_size"); cleanCache(); updateFontCache(); updateSkin(); }
void FontEngine::readSettings() { #if USE_FREETYPE if (g_settings->getBool("freetype")) { m_default_size[FM_Standard] = m_settings->getU16("font_size"); m_default_size[FM_Fallback] = m_settings->getU16("fallback_font_size"); m_default_size[FM_Mono] = m_settings->getU16("mono_font_size"); if (is_yes(gettext("needs_fallback_font"))) { m_currentMode = FM_Fallback; } else { m_currentMode = FM_Standard; } } #endif m_default_size[FM_Simple] = m_settings->getU16("font_size"); m_default_size[FM_SimpleMono] = m_settings->getU16("mono_font_size"); cleanCache(); updateFontCache(); updateSkin(); }
GPUMemCopy::~GPUMemCopy() { cleanCache(); }
FontEngine::~FontEngine() { cleanCache(); }
SettingsDialog::SettingsDialog(const bool display, const QSize& size, const bool displayInfo , const bool quitConfirmation, const bool selectionShaderIsUsed , const bool vboIsUsed, const bool shaderIsUsed, const int defaultLod , const bool spacePartitionIsUsed, const bool useBoundingBox, const int partionDepth , const bool frustumCullingIsUsed, const bool pixelCullingIsUsed, int pixelCullingSize, QWidget *parent) : QDialog(parent) , m_InitLanguage() , m_NewLanguage() , m_ThumbnailSize(size) , m_InitVboUsage(vboIsUsed) , m_InitShaderUsage(shaderIsUsed) { setupUi(this); // Init Display thumbnail check box if (display) displayThumbnail->setCheckState(Qt::Checked); else displayThumbnail->setCheckState(Qt::Unchecked); // Initialize Thumbnail size combo box QString sizeArray[6]= {"32x32", "40x40", "50x50", "60x60", "70x70", "80x80"}; ThumbnailSize_Combo->addItem(sizeArray[0]); ThumbnailSize_Combo->addItem(sizeArray[1]); ThumbnailSize_Combo->addItem(sizeArray[2]); ThumbnailSize_Combo->addItem(sizeArray[3]); ThumbnailSize_Combo->addItem(sizeArray[4]); ThumbnailSize_Combo->addItem(sizeArray[5]); const QString stringSize(QString::number(m_ThumbnailSize.width()) + QString("x") + QString::number(m_ThumbnailSize.height())); int pos= 0; while (sizeArray[pos] != stringSize) pos++; ThumbnailSize_Combo->setCurrentIndex(pos); ThumbnailSize_Combo->setEnabled(display); #if defined(Q_OS_MAC) const QString settingsFileName(QDir::homePath() + "/Library/Application Support/" + QCoreApplication::applicationName() + QDir::separator() + "Settings.ini"); QDir().mkpath(QFileInfo(settingsFileName).path()); QSettings settings(settingsFileName, QSettings::IniFormat); #else QSettings settings; #endif m_InitLanguage= settings.value("currentLanguage").toString(); languageComboBox->addItem(tr("English")); languageComboBox->addItem(tr("French")); if (m_InitLanguage == "fr") { languageComboBox->setCurrentIndex(1); } else { languageComboBox->setCurrentIndex(0); } // Init Display thumbnail check box if (displayInfo) displayViewInfoPanel->setCheckState(Qt::Checked); else displayViewInfoPanel->setCheckState(Qt::Unchecked); // Init Quit confirmation check box if (quitConfirmation) quitConfirmationActive->setCheckState(Qt::Checked); else quitConfirmationActive->setCheckState(Qt::Unchecked); // Init Opengl information if (shaderIsUsed) { useShader->setCheckState(Qt::Checked); } else { useShader->setCheckState(Qt::Unchecked); } if (selectionShaderIsUsed) { useSelectionShader->setCheckState(Qt::Checked); } else { useSelectionShader->setCheckState(Qt::Unchecked); } if (vboIsUsed) { qDebug() << "settings use VBO"; useVbo->setCheckState(Qt::Checked); } else { useVbo->setCheckState(Qt::Unchecked); } setOpenGLInformation(); // Init performance setting defaultLodLineEdit->setText(QString::number(defaultLod)); levelOfDetailSlider->setValue(defaultLod); if (spacePartitionIsUsed) { useOctree->setCheckState(Qt::Checked); } else { useOctree->setCheckState(Qt::Unchecked); } // Bounding Box or bounding sphere radio bBoxRadio->setChecked(useBoundingBox); octreeDepthSpin->setValue(partionDepth); if (frustumCullingIsUsed) { useFrustumCulling->setCheckState(Qt::Checked); } else { useFrustumCulling->setCheckState(Qt::Unchecked); } if (pixelCullingIsUsed) { usePixelCulling->setCheckState(Qt::Checked); } else { usePixelCulling->setCheckState(Qt::Unchecked); } minimumPixelSize->setValue(pixelCullingSize); // Cache management if (GLC_State::cacheIsUsed()) { workWithCacheCheckBox->setCheckState(Qt::Checked); } else { workWithCacheCheckBox->setCheckState(Qt::Unchecked); } targetPath->setText(GLC_State::currentCacheManager().absolutePath()); if (GLC_State::currentCacheManager().compressionIsUsed()) { usedCompressedCacheCheckBox->setCheckState(Qt::Checked); } else { usedCompressedCacheCheckBox->setCheckState(Qt::Unchecked); } int compressionLevel= GLC_State::currentCacheManager().compressionLevel(); if (compressionLevel == -1) { usedDefaultCompressionCheckBox->setCheckState(Qt::Checked); } else { usedDefaultCompressionCheckBox->setCheckState(Qt::Unchecked); } CompressionLevelSpinBox->setValue(compressionLevel); // Signal and slot connection connect(languageComboBox, SIGNAL(currentIndexChanged(int)), this , SLOT(currentLanguageChange(int))); connect(displayThumbnail, SIGNAL(stateChanged(int)), this , SLOT(displayThumbnailStateChanged(int))); connect(ThumbnailSize_Combo, SIGNAL(currentIndexChanged(int)), this , SLOT(iconSizeChange(int))); connect(levelOfDetailSlider, SIGNAL(valueChanged(int)), this, SLOT(defaultLodChange(int))); // Cache management connect(browseCmd, SIGNAL(clicked()), this, SLOT(browse())); connect(updateCacheInfoCmd, SIGNAL(clicked()), this, SLOT(updateCacheInformations())); connect(cleanCacheCmd, SIGNAL(clicked()), this, SLOT(cleanCache())); // Performance connect(useOctree, SIGNAL(stateChanged(int)), this, SLOT(changeSpacePartitionning())); pageList->blockSignals(true); pageList->setCurrentRow(0); pageList->blockSignals(false); }
void* StartServer(void* vp) { int client_sock , c , *new_sock; struct sockaddr_in server , client; //Create socket socket_desc = socket(AF_INET , SOCK_STREAM , 0); if (socket_desc == -1) { printf("Could not create socket"); } puts("Socket created"); //Prepare the sockaddr_in structure server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(80); //Bind if( bind(socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0) { //print the error message perror("bind failed. Error"); return 0; } puts("bind done"); //Listen listen(socket_desc , 3); //Accept and incoming connection c = sizeof(struct sockaddr_in); client_sock=1; int abortState = getStopIssued(); loadAPIs(); initializeCache(); while( client_sock>0 && abortState!=1) { abortState = getStopIssued(); puts("Waiting for incoming connections..."); client_sock = accept(socket_desc, (struct sockaddr *)&client, (socklen_t*)&c); puts("Connection accepted"); pthread_t sniffer_thread; /* pthread_attr_t threadAttribute; int res = pthread_attr_init(&threadAttribute); if (res != 0) { perror("Attribute init failed"); exit(EXIT_FAILURE); } res = pthread_attr_setdetachstate(&threadAttribute, PTHREAD_CREATE_DETACHED); // The worker threads are detached. if (res != 0) { perror("Setting detached state failed"); exit(EXIT_FAILURE); }*/ new_sock = malloc(sizeof(new_sock)); *new_sock = client_sock; if(pthread_create( &sniffer_thread , NULL , connection_handler , (void*) new_sock) < 0) { perror("could not create thread"); } puts("Handler assigned"); } free(new_sock); if (client_sock < 0) { perror("accept failed"); } if(abortState ==1) { puts("Abort signal received."); } freeAPIs(); cleanCache(); puts("Server Stopped"); return 0; }
~InstanceMap(void) { cleanCache(); if (_mutex) delete _mutex; _mutex = NULL; }
VARAreaRef VARArea::create(size_t s, UsageHint h) { cleanCache(); VARAreaRef x = new VARArea(s, h); allVARAreas.push(x); return x; }
//----------------------------------------------------------------------- CollisionModelManager::~CollisionModelManager() { cleanCache(); }
int main(int argc, char *argv[]) { int sockfd, newsockfd, portno, pid; #ifdef __LINUX__ socklen_t clilen; #else int clilen; #endif struct sockaddr_in serv_addr, cli_addr; if (argc < 2) { fprintf(stderr,"ERROR, no port provided\n"); exit(1); } sockfd = socket(AF_INET, SOCK_STREAM, 0); //create socket if (sockfd < 0) error("ERROR opening socket"); memset((char *) &serv_addr, 0, sizeof(serv_addr)); //reset memory //fill in address info portno = atoi(argv[1]); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(portno); if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) error("ERROR on binding"); cleanCache(); while(1){ listen(sockfd,5); //5 simultaneous connection at most //accept connections newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); if (newsockfd < 0) error("ERROR on accept"); int n; char buffer[BUFLEN]; memset(buffer, 0, BUFLEN); //reset memory invalidateOptionList(); do{ //read client's message n = recv(newsockfd,buffer,BUFLEN-1,0); if (n < 0) error("ERROR reading from socket"); printf("Here is the message: \n%s\n",buffer); /*Null terminate the buffer so we can use string operations on it.*/ buffer[n] = '\0'; /*process request*/ n = processRequest(buffer, newsockfd); /*process failed*/ if (n == -1) printf("Request was not successful."); printf("\n---------------------next request--------------------\n"); nextSerial(); if (auth >= 0) printf("Next Serial Number should be %d.\n-------------------\n",savedSerial); }while(auth >= 0); close(newsockfd);//close connection } close(sockfd); return 0; }
void QOpenGL2GradientCache::freeResource(QOpenGLContext *) { cleanCache(); }