int HMessageBox::showOnSynchr() { setFree(s_free); // while (!m_bHandled) { // HThread::sleepWithMilliSeconds(10); // } // return m_retValue; }
int sfs_remove(char *file) { int i, j, k; // looks for 'file' for(i = 0;i < MAX_FILES;i++){ if(strncmp(root_dir[i].name, file, MAXFILENAME) == 0 && root_dir[i].inode_idx != LIMIT){ // updates root directory dir_entry_t *remove = &(root_dir[i]); int temp_inode = remove->inode_idx; strcpy(remove->name, "\0"); inode_t *inodeRemove = &(inode_table[temp_inode]); remove->inode_idx = LIMIT; if(inodeRemove->link_cnt > 12){ unsigned int *tempBuf = malloc(BLOCK_SIZE); read_blocks(19+ inodeRemove->ref_ptr, 1, tempBuf); //updates inode link_cnt for(j = 0; j < inodeRemove->link_cnt - 12; j++){ setFree(tempBuf[j]); } free(tempBuf); inodeRemove->link_cnt = inodeRemove->link_cnt - 12; setFree(inodeRemove->ref_ptr); inodeRemove->ref_ptr = LIMIT; } for(k = 0; k < 12; k++){ setFree(inodeRemove->data_ptrs[k]); inodeRemove->data_ptrs[k] = LIMIT; } // updates inode data inodeRemove->exists = 0; inodeRemove->link_cnt = 0; inodeRemove->size = 0; write_blocks(INODE_TABLE, INODE_TABLE_SIZE, inode_table); return 0; } } printf("File not found\n"); return -1; }
int FileBlocks::remove(void* object){ unsigned* blockNumber = (unsigned*)object; char* buffer = (char*)find(blockNumber); if ( buffer == NULL ) //Block not found return 0; setFree(*blockNumber); updateSpace(*blockNumber, 0); delete[] buffer; return 1; }
void HMessageBox::onCancelClick(CCObject*, CCControlEvent) { HGameManager::getInstance()->playSoundEffect(HMUSIC_BUTTON); if (!m_bHandled) { m_retValue = HMB_CANCEL; m_bHandled = true; dismissRootLayer(); retain(); autorelease(); msgList->removeObject(this); if (m_pDelegate) m_pDelegate->onCancel(this); if (m_pCancelCallBack) m_pCancelCallBack->execute(); setFree(s_free); } }
void FileBlocks::deserialize(){ unsigned* buffer = new unsigned[(blockSize / 4)]; fread(buffer, 4, ((blockSize/4)-1), f_space); unsigned i = 0; unsigned block = 0; while (buffer[i] <= blockSize){ updateSpace(block,buffer[i]); if(buffer[i] == 4095) setFree(block); block++; i++; } delete[] buffer; rewind(f_space); }
int HMessageBox::showOnAsyn() { setFree(s_free); return -1; }
int HMessageBox::showOnFree() { m_bUseFree = true; setFree(s_free); return -1; }
void RenderAf::v_refresh( time_t currentTime, AfContainer * pointer, MonitorContainer * monitoring) { if( isLocked() ) return; JobContainer * jobs = (JobContainer*)pointer; if( isOnline() && (getTimeUpdate() < (currentTime - af::Environment::getRenderZombieTime()))) { appendLog( std::string("ZOMBIETIME: ") + af::itos(af::Environment::getRenderZombieTime()) + " seconds."); AFCommon::QueueLog( std::string("Render: \"") + getName() + "\" - ZOMBIETIME"); /* if( isBusy()) { printf("Was busy:\n"); for( std::list<af::TaskExec*>::iterator it = tasks.begin(); it != tasks.end(); it++) (*it)->stdOut(); }*/ offline( jobs, af::TaskExec::UPRenderZombie, monitoring); return; } // Later auto nimby operations not needed if render is not online: if( isOffline()) { m_busy_time = currentTime; m_idle_time = currentTime; return; } // Update busy with no task time: if(( isFree() == false ) || isBusy()) // already nimby or has task(s) { m_busy_time = currentTime; } else { int cpu=0,mem=0,swp=0,hgb=0,hio=0,net=0; // CPU % busy: if(( m_host.m_nimby_busy_cpu <= 0 ) || (( 100 - m_hres.cpu_idle ) < m_host.m_nimby_busy_cpu )) cpu = 1; // Mem % used: if(( m_hres.mem_total_mb <= 0 ) || ( m_host.m_nimby_busy_mem <= 0 ) || (( 100 * ( m_hres.mem_total_mb - m_hres.mem_free_mb ) / m_hres.mem_total_mb ) < m_host.m_nimby_busy_mem )) mem = 1; // Swap % used: if(( m_hres.swap_total_mb <= 0 ) || (( m_host.m_nimby_busy_swp <= 0 ) || ( 100 * m_hres.swap_used_mb / m_hres.swap_total_mb ) < m_host.m_nimby_busy_swp )) swp = 1; // Hdd free GB: if(( m_hres.hdd_total_gb <= 0 ) || ( m_host.m_nimby_busy_hddgb <= 0 ) || ( m_hres.hdd_free_gb > m_host.m_nimby_busy_hddgb )) hgb = 1; // Hdd I/O %: if(( m_host.m_nimby_busy_hddio <= 0 ) || ( m_hres.hdd_busy < m_host.m_nimby_busy_hddio )) hio = 1; // Net Mb/s: if(( m_host.m_nimby_busy_netmbs <= 0 ) || ( m_hres.net_recv_kbsec + m_hres.net_send_kbsec < 1024 * m_host.m_nimby_busy_netmbs )) net = 1; // Render will be treated as 'not busy' if all params are 'not busy' if( cpu & mem & swp & hio & hgb & net ) { m_busy_time = currentTime; } else if(( m_host.m_nimby_busyfree_time > 0 ) && ( currentTime - m_busy_time > m_host.m_nimby_busyfree_time )) { // Automatic Nimby ON: std::string log("Automatic Nimby: "); log += "\n Busy since: " + af::time2str( m_busy_time);// + " CPU >= " + af::itos( m_host.m_nimby_busy_cpu) + "%"; log += "\n Nimby busy free time = " + af::time2strHMS( m_host.m_nimby_busyfree_time, true ); appendLog( log); setNIMBY(); monitoring->addEvent( af::Monitor::EVT_renders_change, m_id); store(); } //printf("BUSY: %li-%li=%li\n", currentTime, m_busy_time, currentTime-m_busy_time); } // Update idle time: if( isBusy()) { m_idle_time = currentTime; } else if(( m_host.m_nimby_idle_cpu <= 0 ) && ( m_host.m_nimby_idle_mem <= 0 ) && ( m_host.m_nimby_idle_swp <= 0 ) && ( m_host.m_nimby_idle_hddgb <= 0 ) && ( m_host.m_nimby_idle_hddio <= 0 ) && ( m_host.m_nimby_idle_netmbs <= 0 )) { // If all params are 'off' there is no 'idle': m_idle_time = currentTime; } else { int cpu=0,mem=0,swp=0,hgb=0,hio=0,net=0; // CPU % busy: if(( m_host.m_nimby_idle_cpu > 0 ) && (( 100 - m_hres.cpu_idle) > m_host.m_nimby_idle_cpu )) cpu = 1; // Mem % used: if(( m_hres.mem_total_mb > 0 ) && ( m_host.m_nimby_idle_mem > 0 ) && (( 100 * ( m_hres.mem_total_mb - m_hres.mem_free_mb ) / m_hres.mem_total_mb ) > m_host.m_nimby_idle_mem )) mem = 1; // Swap % used: if(( m_hres.swap_total_mb ) && ( m_host.m_nimby_idle_swp > 0 ) && (( 100 * m_hres.swap_used_mb / m_hres.swap_total_mb ) > m_host.m_nimby_idle_swp )) swp = 1; // Hdd free GB: if(( m_hres.hdd_total_gb > 0 ) && ( m_host.m_nimby_idle_hddgb > 0 ) && ( m_hres.hdd_free_gb < m_host.m_nimby_idle_hddgb )) hgb = 1; // Hdd I/O %: if(( m_host.m_nimby_idle_hddio > 0 ) && ( m_hres.hdd_busy > m_host.m_nimby_idle_hddio )) hio = 1; // Net Mb/s: if(( m_host.m_nimby_idle_netmbs > 0 ) && ( m_hres.net_recv_kbsec + m_hres.net_send_kbsec > 1024 * m_host.m_nimby_idle_netmbs )) net = 1; // it will be treated as 'not idle' any param is 'not idle' if( cpu | mem | swp | hio | hgb | net ) { m_idle_time = currentTime; } else { // Automatic WOL sleep: if(( m_host.m_wol_idlesleep_time > 0 ) && isOnline() && ( isWOLSleeping() == false) && ( isWOLFalling() == false) && ( currentTime - m_idle_time > m_host.m_wol_idlesleep_time )) { std::string log("Automatic WOL Sleep: "); log += "\n Idle since: " + af::time2str( m_idle_time); log += "\n WOL idle sleep time = " + af::time2strHMS( m_host.m_wol_idlesleep_time, true ); appendLog( log); wolSleep( monitoring); } // Automatic Nimby Free: if(( m_host.m_nimby_idlefree_time > 0 ) && isOnline() && ( isNimby() || isNIMBY()) && ( currentTime - m_idle_time > m_host.m_nimby_idlefree_time )) { std::string log("Automatic Nimby Free: "); log += "\n Idle since: " + af::time2str( m_idle_time); log += "\n Nimby idle free time = " + af::time2strHMS( m_host.m_nimby_idlefree_time, true ); appendLog( log); setFree(); monitoring->addEvent( af::Monitor::EVT_renders_change, m_id); store(); } } //printf("IDLE: %li-%li=%li\n", currentTime, m_idle_time, currentTime-m_idle_time); } }
UEditorWindow::UEditorWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::EditWindowClass), _confirmCloseMessageBox(0), _redoAction(0), _undoAction(0), _spaceNoteGeneration(false) { this->setFocusPolicy(Qt::StrongFocus); _startTime=0; _playViolon = false; _currentFile = NULL; _isPlaying=false; setAcceptDrops(true); USetting::Instance.init(); #ifdef QT_MODULE_NETWORK UCheckUpdate * check = new UCheckUpdate(QUrl(URL_VERSION)); connect(check,SIGNAL(connected()),this,SLOT(onConnected())); #endif setupAudio(); setupUi(); _currentFile = new UFile(this);// "songs/arkol - vingt ans/Arkol - vingt ans.txt"); fileConnect(); this->showSentenceWidget->setHScroll(0); connect(ui->vScroll,SIGNAL(valueChanged(int)),this,SLOT(onUpdateVScrollAndScale(int))); connect(ui->vSlider,SIGNAL(valueChanged(int)),this,SLOT(onUpdateVScrollAndScale(int))); connect(ui->vScroll,SIGNAL(sliderPressed()),this,SLOT(onUpdateVScrollAndScale())); connect(ui->vSlider,SIGNAL(sliderPressed()),this,SLOT(onUpdateVScrollAndScale())); //connect(ui->vScroll,SIGNAL(actionTriggered(int)),this,SLOT(changeVScroll(int))); connect(_hScroll,SIGNAL(valueChanged(int)),this,SLOT(changeHScroll(int))); //connect(ui->hSlider,SIGNAL(valueChanged(int)),this,SLOT(changeHSlider(int))); connect(_hScroll,SIGNAL(sliderPressed()),this,SLOT(changeHScroll())); //connect(ui->hSlider,SIGNAL(sliderPressed()),this,SLOT(changeHSlider())); connect(_hScroll,SIGNAL(pageStepChanged(int)),this,SLOT(changeHSlider(int))); connect(ui->actionOpen,SIGNAL(triggered()),this,SLOT(openFile())); connect(ui->actionEditHeaders,SIGNAL(triggered()),this,SLOT(editHeader())); connect(ui->actionApplyOffset,SIGNAL(triggered()),this,SLOT(openTiming())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); connect(playAction, SIGNAL(triggered()), this, SLOT(tooglePlay())); connect(pauseAction, SIGNAL(triggered()), this, SLOT(tooglePlay())); connect(recordAction, SIGNAL(triggered()), this, SLOT(toggleRecord())); connect(showSentenceWidget,SIGNAL(haveToStop()), this, SLOT(tooglePlay())); connect(this->ui->offsetSpinBox, SIGNAL(valueChanged(int)), showSentenceWidget, SLOT(setPreviousDisplayed(int))); this->ui->offsetSpinBox->setValue(2); connect(ui->actionSetNormalNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setNormal())); connect(ui->actionSetFreeNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setFree())); connect(ui->actionSetGoldNote,SIGNAL(triggered()),showSentenceWidget, SLOT(setGold())); connect(ui->actionMergeNotes,SIGNAL(triggered()),showSentenceWidget, SLOT(fusion())); connect(ui->actionSplitNote,SIGNAL(triggered()),showSentenceWidget, SLOT(split())); connect(ui->actionAddNote,SIGNAL(triggered()),showSentenceWidget, SLOT(nextClickAddNote())); connect(ui->actionAddSeparator,SIGNAL(triggered()),showSentenceWidget, SLOT(nextClickAddSeparator())); connect(ui->actionSave,SIGNAL(triggered()),this,SLOT(save())); connect(ui->actionSaveAs,SIGNAL(triggered()),this,SLOT(saveAs())); connect(ui->actionNew,SIGNAL(triggered()),this,SLOT(newSong())); connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(close())); connect(&UInputManager::Instance,SIGNAL(spacePressEvent(void)),this,SLOT(tooglePlay())); connect(_wydget_timeline, SIGNAL(gapModified(double)),this, SLOT(gapModified(double))); connect(ui->actionDeleteNote,SIGNAL(triggered()),showSentenceWidget,SLOT(deleteNotes())); connect(ui->actionPreferences,SIGNAL(triggered()),&USetting::Instance,SLOT(showDialog())); connect(ui->actionMorphe,SIGNAL(triggered()),showSentenceWidget,SLOT(calquer())); connect(ui->actionLockTimings,SIGNAL(toggled(bool)),showSentenceWidget,SLOT(lockTime(bool))); connect(ui->actionCenter,SIGNAL(triggered()),this,SLOT(centerView())); connect(ui->actionHelp,SIGNAL(triggered()),this,SLOT(displayHelpScreen())); connect(ui->actionSendFeedback,SIGNAL(triggered()),this,SLOT(displayFeedback())); onUpdateVScrollAndScale(); changeHScroll(0); // _currentFile = new UFile(this); this->showSentenceWidget->setLyrics(_currentFile->lyrics); _wydget_lyrics->setWidgetWords(showSentenceWidget); _undoAction = _currentFile->lyrics->history().createUndoAction(this->ui->menuEdit, tr("Annuler ")); _undoAction->setShortcut(QKeySequence::Undo); _undoAction->setIcon(QIcon(":/images/undo.png")); this->ui->menuEdit->addAction(_undoAction); this->ui->toolBar->insertAction(this->ui->actionSetNormalNote, _undoAction); _redoAction = _currentFile->lyrics->history().createRedoAction(this->ui->menuEdit, tr("Refaire ")); _redoAction->setShortcut(QKeySequence::Redo); _redoAction->setIcon(QIcon(":/images/redo.png")); this->ui->menuEdit->addAction(_redoAction); this->ui->toolBar->insertAction(this->ui->actionSetNormalNote, _redoAction); readLastFile(); connect(ui->actionRecentFiles,SIGNAL(triggered()),this,SLOT(openLastFile())); readSettings(); _spaceNote = new Recorder(this->showSentenceWidget); _autoSaveTimer = new QTimer(this); connect(_autoSaveTimer, SIGNAL(timeout()), this, SLOT(autoSave())); adaptNewFile(); }