const Q3NetworkOperation *Q3UrlOperator::rename( const QString &oldname, const QString &newname ) { if ( !checkValid() ) return 0; Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpRename, oldname, newname, QString() ); return startOperation( res ); }
const Q3NetworkOperation *Q3UrlOperator::remove( const QString &filename ) { if ( !checkValid() ) return 0; Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpRemove, filename, QString(), QString() ); return startOperation( res ); }
const Q3NetworkOperation *Q3UrlOperator::listChildren() { if ( !checkValid() ) return 0; Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpListChildren, QString(), QString(), QString() ); return startOperation( res ); }
void selectAsyncWriteMsg(asyncOp *op, const HostAddress *address, uint64_t usTimeout) { op->useInternalBuffer = !(op->info.flags & afNoCopy); op->info.host = *address; startOperation(op, ioWriteMsg, usTimeout); }
const Q3NetworkOperation *Q3UrlOperator::mkdir( const QString &dirname ) { if ( !checkValid() ) return 0; Q3NetworkOperation *res = new Q3NetworkOperation( Q3NetworkProtocol::OpMkDir, dirname, QString(), QString() ); return startOperation( res ); }
void LogData::indexingFinished( bool success ) { LOG(logDEBUG) << "Entering LogData::indexingFinished."; // We use the newly created file data or restore the old ones. // (Qt implicit copy makes this fast!) { QMutexLocker locker( &dataMutex_ ); workerThread_.getIndexingData( &fileSize_, &maxLength_, &linePosition_ ); nbLines_ = linePosition_.size(); } LOG(logDEBUG) << "indexingFinished: " << success << ", found " << nbLines_ << " lines."; if ( success ) { // Use the new filename if needed if ( !currentOperation_->getFilename().isNull() ) { QString newFileName = currentOperation_->getFilename(); if ( file_ ) { QMutexLocker locker( &fileMutex_ ); file_->setFileName( newFileName ); } else { QMutexLocker locker( &fileMutex_ ); file_.reset( new QFile( newFileName ) ); } } // Update the modified date/time if the file exists lastModifiedDate_ = QDateTime(); QFileInfo fileInfo( *file_ ); if ( fileInfo.exists() ) lastModifiedDate_ = fileInfo.lastModified(); } if ( file_ ) { // And we watch the file for updates fileChangedOnDisk_ = Unchanged; fileWatcher_.addFile( file_->fileName() ); } emit loadingFinished( success ); // So now the operation is done, let's see if there is something // else to do, in which case, do it! assert( currentOperation_ ); currentOperation_ = nextOperation_; nextOperation_ = nullptr; if ( currentOperation_ ) { LOG(logDEBUG) << "indexingFinished is performing the next operation"; startOperation(); } }
// Add an operation to the queue and perform it immediately if // there is none ongoing. void LogData::enqueueOperation( std::shared_ptr<const LogDataOperation> new_operation ) { if ( currentOperation_ == nullptr ) { // We do it immediately currentOperation_ = new_operation; startOperation(); } else { // An operation is in progress... // ... we schedule the attach op for later nextOperation_ = new_operation; } }
ServiceViewer::ServiceViewer(Plasma::DataEngine *engine, const QString &source, QWidget *parent) : QDialog(parent), m_engine(engine), m_service(0), m_source(source), m_operationCount(0), m_operationButton(new QPushButton(i18n("Start Operation"), this)) { setAttribute(Qt::WA_DeleteOnClose); QWidget* mainWidget = new QWidget(this); QVBoxLayout *layout = new QVBoxLayout(); QDialogButtonBox *buttonBox = new QDialogButtonBox(this); buttonBox->addButton(m_operationButton, QDialogButtonBox::ActionRole); buttonBox->addButton(QDialogButtonBox::Close); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); layout->addWidget(mainWidget); layout->addWidget(buttonBox); setLayout(layout); setupUi(mainWidget); m_operationStatus->hide(); connect(m_operationButton, SIGNAL(clicked()), this, SLOT(startOperation())); m_operationButton->setEnabled(false); connect(m_operations, SIGNAL(currentIndexChanged(QString)), this, SLOT(operationSelected(QString))); QString engineName = i18nc("Plasma engine with unknown name", "Unknown"); QString serviceName = i18nc("Plasma service with unknown name", "Unknown"); if (m_engine) { engineName = KStringHandler::capwords(m_engine->pluginInfo().name()); qDebug() << "########### CALLING SERVICE FOR SOURCE: " << m_source; m_service = m_engine->serviceForSource(m_source); if (m_service != 0) { serviceName = m_service->name(); updateOperations(); connect(m_service, SIGNAL(operationsChanged()), this, SLOT(updateOperations())); connect(m_engine, SIGNAL(destroyed(QObject*)), this, SLOT(engineDestroyed())); } else {
void selectAsyncConnect(asyncOp *op, const HostAddress *address, uint64_t usTimeout) { struct sockaddr_in localAddress; localAddress.sin_family = address->family; localAddress.sin_addr.s_addr = address->ipv4; localAddress.sin_port = address->port; int err = connect(op->info.object->hSocket, (sockaddr*)&localAddress, sizeof(localAddress)); if (err == -1 && errno != EINPROGRESS) { fprintf(stderr, "connect error, errno: %s\n", strerror(errno)); return; } startOperation(op, ioConnect, usTimeout); }
void LogData::indexingFinished( LoadingStatus status ) { LOG(logDEBUG) << "indexingFinished: " << ( status == LoadingStatus::Successful ) << ", found " << indexing_data_.getNbLines() << " lines."; if ( keepFileClosed_ ) { QMutexLocker locker( &fileMutex_ ); attached_file_->close(); } if ( status == LoadingStatus::Successful ) { // Start watching we watch the file for updates fileChangedOnDisk_ = Unchanged; FileWatcher::getFileWatcher().addFile( indexingFileName_ ); // Update the modified date/time if the file exists lastModifiedDate_ = QDateTime(); QFileInfo fileInfo( indexingFileName_ ); if ( fileInfo.exists() ) lastModifiedDate_ = fileInfo.lastModified(); } // FIXME be cleverer here as a notification might have arrived whilst we // were indexing. fileChangedOnDisk_ = Unchanged; LOG(logDEBUG) << "Sending indexingFinished."; emit loadingFinished( status ); // So now the operation is done, let's see if there is something // else to do, in which case, do it! assert( currentOperation_ ); currentOperation_ = std::move( nextOperation_ ); nextOperation_.reset(); if ( currentOperation_ ) { LOG(logDEBUG) << "indexingFinished is performing the next operation"; startOperation(); } }
bool MainWindow::QuerySaveDatabase() { if (QuerySaveGame()) { if (m_currentDatabase && qobject_cast<MemoryDatabase*>(database())) { if (database()->isModified()) { int result = MessageDialog::yesNoCancel(tr("The current database is modified!") + '\n' + tr("Save it?")); if (MessageDialog::Yes == result) { startOperation(tr("Saving %1...").arg(database()->name())); Output output(Output::Sgn); connect(&output, SIGNAL(progress(int)), SLOT(slotOperationProgress(int))); output.output(database()->filename(), *database()); finishOperation(tr("%1 saved").arg(database()->name())); return true; } return result != MessageDialog::Cancel; } }
void CzpEditorView::OnEditAddFolder() { CFolderDialog folderDlg(NULL, _T("Select folder to add to package.")); if (folderDlg.DoModal() != IDOK) { return; } zp::String addToDir; ZpNode* node = getSelectedNode(); if (node != NULL && node->isDirectory) { addToDir = node->name; } CString path = folderDlg.GetPathName(); ZpExplorer& explorer = GetDocument()->GetZpExplorer(); zp::u64 totalFileSize = explorer.countDiskFileSize(path.GetString()); std::vector<std::pair<zp::String, zp::String>> params; params.push_back(std::make_pair(path.GetString(), addToDir)); startOperation(ProgressDialog::OP_ADD, totalFileSize, ¶ms); m_pDocument->UpdateAllViews(NULL); }
void CzpEditorView::OnEditExtract() { CFolderDialog dlg(NULL, _T("Select dest folder to extract.")); if (dlg.DoModal() != IDOK) { return; } zp::String destPath = dlg.GetPathName().GetString(); ZpExplorer& explorer = GetDocument()->GetZpExplorer(); zp::u64 totalFileSize = 0; std::vector<std::pair<zp::String, zp::String>> params; CListCtrl& listCtrl = GetListCtrl(); POSITION pos = listCtrl.GetFirstSelectedItemPosition(); if (pos == NULL) { //nothing selected, extract current folder totalFileSize += explorer.countNodeFileSize(explorer.currentNode()); params.push_back(std::make_pair(_T("."), destPath)); } else { while (pos != NULL) { int selectedIndex = listCtrl.GetNextSelectedItem(pos); ZpNode* node = (ZpNode*)listCtrl.GetItemData(selectedIndex); if (node == NULL) { continue; } totalFileSize += explorer.countNodeFileSize(node); params.push_back(std::make_pair(node->name, destPath)); } } startOperation(ProgressDialog::OP_EXTRACT, totalFileSize, ¶ms); }
void MMA7455::writeReg(uint8_t addr, byte val) { //say this is a write operation startOperation(_WRITE); //send the address of the register writeAddr(addr); //do nothin bit port &= ~clk; port |= clk; //send the value to the register for(byte a = 0x80; a; a >>= 1) { port &= ~clk; if (val & a) port |= sdio; else port &= ~sdio; port |= clk; } port &= ~(clk | sdio); port |= cs; }
int asyncExecuteIoCallback (AsyncIoData *iod, long int timeout) { if (iod) { Queue *functions = iod->functionQueue; unsigned int functionCount = functions? getQueueSize(functions): 0; prepareMonitors(); if (functionCount) { MonitorEntry monitorArray[functionCount]; MonitorGroup monitors = { .array = monitorArray, .count = 0 }; int executed = 0; Element *functionElement = processQueue(functions, addFunctionMonitor, &monitors); if (!functionElement) { if (!monitors.count) { approximateDelay(timeout); } else if (awaitMonitors(&monitors, timeout)) { functionElement = processQueue(functions, testFunctionMonitor, NULL); } } if (functionElement) { FunctionEntry *function = getElementItem(functionElement); Element *operationElement = getActiveOperationElement(function); OperationEntry *operation = getElementItem(operationElement); if (!operation->finished) finishOperation(operation); operation->active = 1; if (!function->methods->invokeCallback(operation)) operation->cancel = 1; operation->active = 0; executed = 1; if (operation->cancel) { deleteElement(operationElement); } else { operation->error = 0; } if ((operationElement = getActiveOperationElement(function))) { operation = getElementItem(operationElement); if (!operation->finished) startOperation(operation); requeueElement(functionElement); } else { deleteElement(functionElement); } } return executed; } } approximateDelay(timeout); return 0; } static void deallocateOperationEntry (void *item, void *data) { OperationEntry *operation = item; if (operation->extension) free(operation->extension); free(operation); }
void kqueueMonitor(asyncOp *op) { startOperation(op, ioMonitor, 0); }
void ThreadOperation::start() { emit startOperation(); }
status_t BnAppOpsService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { //printf("AppOpsService received: "); data.print(); switch(code) { case CHECK_OPERATION_TRANSACTION: { CHECK_INTERFACE(IAppOpsService, data, reply); int32_t code = data.readInt32(); int32_t uid = data.readInt32(); String16 packageName = data.readString16(); int32_t res = checkOperation(code, uid, packageName); reply->writeNoException(); reply->writeInt32(res); return NO_ERROR; } break; case NOTE_OPERATION_TRANSACTION: { CHECK_INTERFACE(IAppOpsService, data, reply); int32_t code = data.readInt32(); int32_t uid = data.readInt32(); String16 packageName = data.readString16(); int32_t res = noteOperation(code, uid, packageName); reply->writeNoException(); reply->writeInt32(res); return NO_ERROR; } break; case START_OPERATION_TRANSACTION: { CHECK_INTERFACE(IAppOpsService, data, reply); sp<IBinder> token = data.readStrongBinder(); int32_t code = data.readInt32(); int32_t uid = data.readInt32(); String16 packageName = data.readString16(); int32_t res = startOperation(token, code, uid, packageName); reply->writeNoException(); reply->writeInt32(res); return NO_ERROR; } break; case FINISH_OPERATION_TRANSACTION: { CHECK_INTERFACE(IAppOpsService, data, reply); sp<IBinder> token = data.readStrongBinder(); int32_t code = data.readInt32(); int32_t uid = data.readInt32(); String16 packageName = data.readString16(); finishOperation(token, code, uid, packageName); reply->writeNoException(); return NO_ERROR; } break; case START_WATCHING_MODE_TRANSACTION: { CHECK_INTERFACE(IAppOpsService, data, reply); int32_t op = data.readInt32(); String16 packageName = data.readString16(); sp<IAppOpsCallback> callback = interface_cast<IAppOpsCallback>(data.readStrongBinder()); startWatchingMode(op, packageName, callback); reply->writeNoException(); return NO_ERROR; } break; case STOP_WATCHING_MODE_TRANSACTION: { CHECK_INTERFACE(IAppOpsService, data, reply); sp<IAppOpsCallback> callback = interface_cast<IAppOpsCallback>(data.readStrongBinder()); stopWatchingMode(callback); reply->writeNoException(); return NO_ERROR; } break; case GET_TOKEN_TRANSACTION: { CHECK_INTERFACE(IAppOpsService, data, reply); sp<IBinder> clientToken = data.readStrongBinder(); sp<IBinder> token = getToken(clientToken); reply->writeNoException(); reply->writeStrongBinder(token); return NO_ERROR; } break; case PERMISSION_TO_OP_CODE_TRANSACTION: { CHECK_INTERFACE(IAppOpsService, data, reply); String16 permission = data.readString16(); const int32_t opCode = permissionToOpCode(permission); reply->writeNoException(); reply->writeInt32(opCode); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
void selectAsyncAccept(asyncOp *op, uint64_t usTimeout) { startOperation(op, ioAccept, usTimeout); }
void selectAsyncWrite(asyncOp *op, uint64_t usTimeout) { op->useInternalBuffer = !(op->info.flags & afNoCopy); startOperation(op, ioWrite, usTimeout); }
void kqueueAsyncRead(asyncOp *op, uint64_t usTimeout) { startOperation(op, ioRead, usTimeout); }
bool Bluetooth_HC05::probe(unsigned long timeout) { startOperation(timeout); writeCommand(0); return readOperationResult(); }
void selectMonitorStop(asyncOp *op) { startOperation(op, ioMonitorStop, 0); }
void selectAsyncReadMsg(asyncOp *op, uint64_t usTimeout) { startOperation(op, ioReadMsg, usTimeout); }