void DataManager::lockFile(const QString &repo_id, const QString &path, bool lock) { LockFileRequest *req = new LockFileRequest(account_, repo_id, path, lock); connect(req, SIGNAL(success()), SLOT(onLockFileSuccess())); connect(req, SIGNAL(failed(const ApiError&)), SIGNAL(lockFileFailed(const ApiError&))); req->send(); reqs_.push_back(req); }
void DataManager::onLockFileSuccess() { LockFileRequest *req = qobject_cast<LockFileRequest *>(sender()); if (!req) return; removeDirentsCache(req->repoId(), req->path(), false); seafApplet->rpcClient()->markFileLockState(req->repoId(), req->path(), req->lock()); emit lockFileSuccess(req->path(), req->lock()); }
void SeafileExtensionHandler::lockFile(const QString& repo_id, const QString& path_in_repo, bool lock) { // qDebug("path_in_repo: %s", path_in_repo.toUtf8().data()); const Account account = seafApplet->accountManager()->getAccountByRepo(repo_id); if (!account.isValid()) { return; } LockFileRequest *req = new LockFileRequest( account, repo_id, path_in_repo, lock); connect(req, SIGNAL(success()), this, SLOT(onLockFileSuccess())); connect(req, SIGNAL(failed(const ApiError&)), this, SLOT(onLockFileFailed(const ApiError&))); req->send(); }
void SeafileExtensionHandler::onLockFileSuccess() { LockFileRequest *req = qobject_cast<LockFileRequest *>(sender()); LocalRepo repo; seafApplet->rpcClient()->getLocalRepo(req->repoId(), &repo); if (repo.isValid()) { seafApplet->rpcClient()->markFileLockState(req->repoId(), req->path(), req->lock()); QString path = QDir::toNativeSeparators(QDir(repo.worktree).absoluteFilePath(req->path().mid(1))); SHChangeNotify(SHCNE_ATTRIBUTES, SHCNF_PATH, path.toUtf8().data(), NULL); } }
void SeafileExtensionHandler::onLockFileFailed(const ApiError& error) { LockFileRequest *req = qobject_cast<LockFileRequest *>(sender()); QString str = req->lock() ? tr("Failed to lock file") : tr("Failed to unlock file"); seafApplet->warningBox(QString("%1: %2").arg(str, error.toString())); }