void FileAllocator::allocateAsap( const string &name, unsigned long long &size ) { scoped_lock lk( _pendingMutex ); long oldSize = prevSize( name ); if ( oldSize != -1 ) { size = oldSize; if ( !inProgress( name ) ) return; } checkFailure(); _pendingSize[ name ] = size; if ( _pending.size() == 0 ) _pending.push_back( name ); else if ( _pending.front() != name ) { _pending.remove( name ); list< string >::iterator i = _pending.begin(); ++i; _pending.insert( i, name ); } _pendingUpdated.notify_all(); while( inProgress( name ) ) { checkFailure(); _pendingUpdated.wait( lk.boost() ); } }
void deletePlan(const IMC::PlanDB& req) { if (req.plan_id.empty()) { onFailure(DTR("undefined plan id")); return; } inProgress(); m_db->beginTransaction(); int count = 0; try { *m_delete_plan_stmt << req.plan_id; m_delete_plan_stmt->execute(&count); if (count) onChange(req); } catch (std::runtime_error& e) { onFailure(e.what()); m_db->rollback(); return; } m_db->commit(); if (!count) onFailure(DTR("undefined plan")); else onSuccess(); }
void setPlan(const IMC::PlanDB& req) { if (req.plan_id.empty()) { onFailure(DTR("undefined plan id")); return; } const IMC::PlanSpecification* spec = 0; if (!req.arg.get(spec)) { onFailure(DTR("no plan specification given")); return; } if (spec->plan_id != req.plan_id) { onFailure(DTR("plan id mismatch")); return; } inProgress(); storeInDB(spec); }
SQLiteIDBTransaction::~SQLiteIDBTransaction() { if (inProgress()) m_sqliteTransaction->rollback(); // Explicitly clear cursors, as that also unregisters them from the backing store. clearCursors(); }
void ConstructionTask::reserveLocation() { if(!mReservedLocation && !inProgress() && !hasEnded()) { LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Reserving Location"); mReservedLocation = BuildingPlacer::Instance().getBuildingReservation(mBuildingLocation, mType); assert(!mReservedLocation->update()); } }
void ConstructionTask::reserveResources() { if(!mReservedResources && !inProgress() && !hasEnded()) { LOGMESSAGE(String_Builder() << "ConstructionTask : " << mType.getName() << " : Reserving Resources"); ResourceTracker::Instance().reserveCurrentMinerals(mRequiredSatisfyTime, mType.mineralPrice()); ResourceTracker::Instance().reserveCurrentGas(mRequiredSatisfyTime, mType.gasPrice()); ResourceTracker::Instance().reserveCurrentSupply(mRequiredSatisfyTime, mType.supplyRequired()); mReservedResources = true; } }
void CarBlock::on_btnOil_clicked() { emit inProgress(); if(Database::isOpen()) { oilDialog = new OilDialog(idCar); if(oilDialog->exec()== OilDialog::Rejected) delete oilDialog; } else { QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!")); emit changeStatusBar("Nie można połączyć z bazą danych"); } emit progressFinished(); }
void CarBlock::on_btnViewRepairs_clicked() { emit inProgress(); if(Database::isOpen()) { serviceBlock = new ServiceBlock(idCar); if(serviceBlock->exec()== ServiceBlock::Rejected) delete serviceBlock; } else { QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!")); emit changeStatusBar("Nie można połączyć z bazą danych"); } emit progressFinished(); }
void CarBlock::on_btnAddImage_clicked() { emit inProgress(); QString choosenPhotoPath = QFileDialog::getOpenFileName(this, tr("Plik z obrazkiem"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), tr("Pliki PNG, JPG (*.jpg *.png)")); if(choosenPhotoPath.isEmpty()) ui->lblPhoto->setPixmap(QPixmap(carPhotoPath)); else { ui->lblPhoto->setPixmap(QPixmap(choosenPhotoPath)); carPhotoPath = choosenPhotoPath; if(!isAddBlock) updateImagePath(); } emit progressFinished(); }
void CarBlock::showNotesDialog(int _idNotes, int _idCar) { emit inProgress(); if(_idCar == idCar) { if(Database::isOpen()) { notesDialogPointer = std::shared_ptr<NotesDialog>(new NotesDialog(_idNotes, _idCar)); if(notesDialogPointer.use_count() == 1 && notesDialogPointer.get()->exec() == NotesDialog::Rejected){ if(!(BookingDialog::isOpen || ServiceBlock::isOpen)) emit progressFinished(); emit noteClosed(); } } else { QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!")); } } emit progressFinished(); }
DccChatWindow::DccChatWindow(DccDescriptor * dcc, const char * name) : DccWindow(KviWindow::DccChat, name, dcc) { m_pButtonBox = new KviTalHBox(this); m_pLabel = new KviThemedLabel(m_pButtonBox, this, "dcc_chat_label"); m_pLabel->setText(name); m_pButtonBox->setStretchFactor(m_pLabel, 1); m_pButtonContainer = new KviTalHBox(m_pButtonBox); createTextEncodingButton(m_pButtonContainer); #ifdef COMPILE_CRYPT_SUPPORT createCryptControllerButton(m_pButtonContainer); #endif m_pSplitter = new KviTalSplitter(Qt::Horizontal, this); m_pSplitter->setObjectName("dcc_chat_splitter"); m_pSplitter->setChildrenCollapsible(false); m_pIrcView = new KviIrcView(m_pSplitter, this); connect(m_pIrcView, SIGNAL(rightClicked()), this, SLOT(textViewRightClicked())); m_pInput = new KviInput(this); //setFocusHandler(m_pInput,this); m_pSlaveThread = nullptr; if(KVI_OPTION_BOOL(KviOption_boolAutoLogDccChat)) m_pIrcView->startLogging(); m_pMarshal = new DccMarshal(this); connect(m_pMarshal, SIGNAL(error(KviError::Code)), this, SLOT(handleMarshalError(KviError::Code))); connect(m_pMarshal, SIGNAL(connected()), this, SLOT(connected())); connect(m_pMarshal, SIGNAL(inProgress()), this, SLOT(connectionInProgress())); #ifdef COMPILE_SSL_SUPPORT connect(m_pMarshal, SIGNAL(startingSSLHandshake()), this, SLOT(startingSSLHandshake())); connect(m_pMarshal, SIGNAL(sslError(const char *)), this, SLOT(sslError(const char *))); #endif m_pSlaveThread = nullptr; startConnection(); }
void clearDatabase(const IMC::PlanDB& req) { inProgress(); m_db->beginTransaction(); try { m_delete_all_plans_stmt->execute(); onChange(req); } catch (std::runtime_error& e) { onFailure(e.what()); m_db->rollback(); return; } m_db->commit(); onSuccess(); }
void CarBlock::on_btnAddInspection_clicked() { emit inProgress(); if(Database::isOpen()) { QSqlQuery qry; qry.prepare("UPDATE car SET InspectionDate=:_inspectionDate WHERE idCar=:_id"); qry.bindValue(":_id", idCar); qry.bindValue(":_inspectionDate", ui->dateEditInspection->date()); if(!qry.exec()) QMessageBox::warning(this,tr("Uwaga!"),"Aktualizacja nie powidoła się.\nERROR: "+qry.lastError().text()+""); else QMessageBox::information(this,tr("Informacja"),tr("Zaktualizowano!")); } else { QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!")); emit changeStatusBar("Nie można połączyć z bazą danych"); } emit progressFinished(); }
DccVoiceWindow::DccVoiceWindow(DccDescriptor * dcc,const char * name) : DccWindow(KviWindow::DccVoice,name,dcc) { m_pDescriptor = dcc; m_pSlaveThread = 0; m_pSplitter = new KviTalSplitter(Qt::Horizontal,this); m_pSplitter->setObjectName("dcc_window_splitter"); m_pIrcView = new KviIrcView(m_pSplitter,this); m_pHBox = new KviTalHBox(this); KviTalVBox * vbox = new KviTalVBox(m_pHBox); m_pInputLabel = new QLabel(__tr2qs_ctx("Input buffer","dcc"),vbox); m_pInputLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel); m_pOutputLabel = new QLabel(__tr2qs_ctx("Output buffer","dcc"),vbox); m_pOutputLabel->setFrameStyle(QFrame::Sunken | QFrame::Panel); vbox->setSpacing(1); KviTalVBox * vbox2 = new KviTalVBox(m_pHBox); m_pRecordingLabel = new QLabel(vbox2); m_pRecordingLabel->setPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::Record))); m_pRecordingLabel->setEnabled(false); m_pRecordingLabel->setFrameStyle(QFrame::Raised | QFrame::Panel); m_pPlayingLabel = new QLabel(vbox2); m_pPlayingLabel->setPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::Play))); m_pPlayingLabel->setEnabled(false); m_pPlayingLabel->setFrameStyle(QFrame::Raised | QFrame::Panel); vbox2->setSpacing(1); //#warning "The volume slider should be enabled only when receiving data" //m_pVolumeSlider = new QSlider(-100, 0, 10, 0, Qt::Vertical, m_pHBox, "dcc_voice_volume_slider"); m_pVolumeSlider = new QSlider(Qt::Vertical,m_pHBox); m_pVolumeSlider->setObjectName("dcc_voice_volume_slider"); m_pVolumeSlider->setMinimum(-100); m_pVolumeSlider->setMaximum(0); m_pVolumeSlider->setPageStep(10); m_pVolumeSlider->setValue(0); m_pVolumeSlider->setValue(getMixerVolume()); /* Update the tooltip */ setMixerVolume(m_pVolumeSlider->value()); m_pVolumeSlider->setMaximumWidth(16); m_pVolumeSlider->setMaximumHeight(2*m_pPlayingLabel->height()); connect(m_pVolumeSlider, SIGNAL(valueChanged(int)), this, SLOT(setMixerVolume(int))); m_pTalkButton = new QToolButton(m_pHBox); m_pTalkButton->setEnabled(false); m_pTalkButton->setCheckable(true); QIcon iset; iset.addPixmap(*(g_pIconManager->getBigIcon(KVI_BIGICON_DISCONNECTED)),QIcon::Normal,QIcon::Off); iset.addPixmap(*(g_pIconManager->getBigIcon(KVI_BIGICON_CONNECTED)),QIcon::Normal,QIcon::On); m_pTalkButton->setIcon(iset); m_pTalkButton->setIconSize(QSize(32,32)); connect(m_pTalkButton,SIGNAL(toggled(bool)),this,SLOT(startOrStopTalking(bool))); m_pHBox->setStretchFactor(vbox,1); m_pHBox->setMargin(2); m_pHBox->setSpacing(1); //setFocusHandler(m_pIrcView,this); m_pMarshal = new DccMarshal(this); connect(m_pMarshal,SIGNAL(error(KviError::Code)),this,SLOT(handleMarshalError(KviError::Code))); connect(m_pMarshal,SIGNAL(connected()),this,SLOT(connected())); connect(m_pMarshal,SIGNAL(inProgress()),this,SLOT(connectionInProgress())); m_pUpdateTimer = new QTimer(); startConnection(); }
void CarBlock::on_btnRemove_clicked() { emit inProgress(); if(Database::isOpen()) { if(!isAddBlock) { if(!showMsgBeforeDelete()){ emit progressFinished(); return; } QSqlQuery qry; qry.prepare("DELETE FROM car WHERE idCar=:_id"); qry.bindValue(":_id", idCar); if(!qry.exec()) QMessageBox::warning(this,tr("Uwaga!"),"Usuwanie nie powiodło się.\nERROR: "+qry.lastError().text()+""); else { QMessageBox::information(this,tr("Informacja"),tr("Usunięto samochód!")); emit carDeleted(true); } } else { QSqlQuery qry; qry.prepare("INSERT INTO car(Brand,Model,LicensePlate,InspectionDate," "InsuranceDate,Mileage,Status,PhotoPath,IsVisible)" "VALUES(:_Brand,:_Model,:_LicensePlate,:_InspectionDate," ":_InsuranceDate,:_Mileage,:_Status,:_PhotoPath,:_IsVisible)"); if(ui->lblCarName->text().contains(" ")) { qry.bindValue(":_Brand", ui->lblCarName->text().split(" ").at(0)); qry.bindValue(":_Model", ui->lblCarName->text().split(" ").at(1)); } else { qry.bindValue(":_Brand", ui->lblCarName->text()); qry.bindValue(":_Model", ui->lblCarName->text()); } qry.bindValue(":_LicensePlate", ui->lblLicensePlate->text()); qry.bindValue(":_InspectionDate",ui->dateEditInspection->date()); qry.bindValue(":_InsuranceDate",ui->dateEditInsurance->date()); if(getCarVisible())qry.bindValue(":_Status",0); else qry.bindValue(":_Status",1); qry.bindValue(":_Mileage", ui->lblMileage->text()); if(!carPhotoPath.isEmpty())qry.bindValue(":_PhotoPath",carPhotoPath); else qry.bindValue(":_PhotoPath", QString(":/images/images/car.png")); qry.bindValue(":_IsVisible", getCarVisible()); if(!qry.exec()) QMessageBox::warning(this,tr("Uwaga!"),"Dodawanie nie powiodło się.\nERROR "+qry.lastError().text()+""); else { QMessageBox::information(this,tr("Informacja"),tr("Dodano samochód!")); emit carAdded(false); } } } else { QMessageBox::critical(this,tr("Błąd!"), tr("Utracono połączenie z bazą danych!")); emit changeStatusBar("Nie można połączyć z bazą danych"); } emit progressFinished(); }