qint64 AssemblyModel::getModelHeight(U2OpStatus & os) { if(NO_VAL == cachedModelHeight) { U2AttributeDbi * attributeDbi = dbiHandle.dbi->getAttributeDbi(); if(attributeDbi != NULL) { U2IntegerAttribute attr = U2AttributeUtils::findIntegerAttribute(attributeDbi, assembly.id, U2BaseAttributeName::max_prow, os); LOG_OP(os); if(attr.hasValidId()) { if(attr.version == assembly.version) { cachedModelHeight = attr.value; } else if(checkPermissions(QFile::WriteUser,false)) { U2AttributeUtils::removeAttribute(attributeDbi, attr.id, os); LOG_OP(os); } } } if(cachedModelHeight == NO_VAL) { // if could not get value from attribute, recompute the value... cachedModelHeight = assemblyDbi->getMaxPackedRow(assembly.id, U2Region(0, getModelLength(os)), os); LOG_OP(os); if(! os.isCoR()) { // ...and store it in a new attribure U2IntegerAttribute attr; U2AttributeUtils::init(attr, assembly, U2BaseAttributeName::max_prow); attr.value = cachedModelHeight; attributeDbi->createIntegerAttribute(attr, os); } } if(cachedModelHeight == NO_VAL){ os.setError("Can't get model height, database is corrupted"); LOG_OP(os); } } return cachedModelHeight; }
MojErr MojDbPermissionTest::testObjectPermissions(MojDb& db) { MojErr err = putPermissions(db); MojTestErrCheck(err); err = checkPermissions(db); MojTestErrCheck(err); err = db.close(); MojTestErrCheck(err); err = db.open(MojDbTestDir); MojTestErrCheck(err); err = checkPermissions(db); MojTestErrCheck(err); return MojErrNone; }
void CopyApp::doUpdate() { static int partial = 0; if(partial == 0) { if(!checkPermissions(destination)) { startAsSudo(); QApplication::quit(); return; } } partial += 500; if(timeToWait != 0) { ui->progressBar->setValue(partial * 100 / timeToWait); if(partial < timeToWait) { QTimer::singleShot(500, this, SLOT(doUpdate())); return; } } emit currentOperation(tr("Looking for local file list info")); QStringList destinationFileList = processFileList(destination); emit currentOperation(tr("Looking for remote file list info")); QStringList remoteFileList = processFileList(origin); if(destinationFileList.isEmpty() || remoteFileList.isEmpty()) return; emit currentOperation(tr("Deleting old files...")); bool result = true; result &= deleteFiles(destinationFileList, destination); emit currentOperation(tr("Copying new files...")); result &= copyFiles(remoteFileList, origin, destination); QString resultStr; if(result) resultStr = tr("Update finished successfully. "); else resultStr = tr("Update finished with errors. "); if(!appToRun.isEmpty()) resultStr = resultStr + tr("Click ok to restart application"); QMessageBox::information(this, tr("Update finished"), resultStr); if(!appToRun.isEmpty()) { #ifdef Q_OS_OSX QProcess::startDetached("open", QStringList() << QDir(destination).filePath(appToRun)); #else QProcess::startDetached(QDir(destination).filePath(appToRun)); #endif } QApplication::quit(); }
QString MainWin::getConfigPath(const QString& configFile) { /* * Check home user directory */ QString fullHomePath = QString("%1/%2").arg(QDir::homePath()).arg(configFile); QFile testConfig(fullHomePath); QFileInfo checkPermissions(fullHomePath); if (!testConfig.exists() && testConfig.open(QIODevice::WriteOnly)) testConfig.close(); if (checkPermissions.isWritable()) { return fullHomePath; } QMessageBox::warning(this, "Current directory is not writable", "Program can't save connections file to current dir. Please change permissions or restart this program with administrative privileges" ); exit(1); }
bool AddAcl(EntityManager *entityManager) { createResources(entityManager); addPermissionsToResource(entityManager); return checkPermissions(entityManager); }