void InitVirtualDriveDialog::startDownload(const QString& repo_id) { default_repo_id_ = repo_id; LocalRepo repo; seafApplet->rpcClient()->getLocalRepo(repo_id, &repo); if (repo.isValid()) { // This repo is already here qDebug("The default library has already been downloaded"); default_repo_path_ = repo.worktree; finish(); return; } download_default_repo_req_ = new DownloadRepoRequest(account_, repo_id, false); connect(download_default_repo_req_, SIGNAL(success(const RepoDownloadInfo&)), this, SLOT(onDownloadRepoSuccess(const RepoDownloadInfo&))); connect(download_default_repo_req_, SIGNAL(failed(const ApiError&)), this, SLOT(onDownloadRepoFailure(const ApiError&))); download_default_repo_req_->send(); }
void SeafileTrayIcon::onMessageClicked() { if (repo_id_.isEmpty()) return; LocalRepo repo; if (seafApplet->rpcClient()->getLocalRepo(repo_id_, &repo) != 0 || !repo.isValid() || repo.worktree_invalid) return; showInGraphicalShell(repo.worktree); }
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 SeafileTrayIcon::onMessageClicked() { if (repo_id_.isEmpty()) return; LocalRepo repo; if (seafApplet->rpcClient()->getLocalRepo(repo_id_, &repo) != 0 || !repo.isValid() || repo.worktree_invalid) return; DiffReader *reader = new DiffReader(repo, previous_commit_id_, commit_id_); QThreadPool::globalInstance()->start(reader); }
void RepoService::openLocalFile(const QString& repo_id, const QString& path_in_repo, QWidget *dialog_parent) { LocalRepo r; seafApplet->rpcClient()->getLocalRepo(repo_id, &r); if (r.isValid()) { QString path = QDir(r.worktree).filePath(path_in_repo); openFile(path); } else { ServerRepo repo = getRepo(repo_id); if (!repo.isValid()) { return; } const QString path = "/" + path_in_repo; const Account account = seafApplet->accountManager()->currentAccount(); DataManager data_mgr(account); // endless loop for setPasswordDialog while(1) { FileDownloadTask *task = data_mgr.createDownloadTask(repo_id, path); FileBrowserProgressDialog dialog(task, dialog_parent); task->start(); if (dialog.exec()) { QString full_path = data_mgr.getLocalCachedFile(repo_id, path, task->fileId()); if (!full_path.isEmpty()) openFile(full_path); break; } // if the user canceled the task, don't bother it if (task->error() == FileNetworkTask::TaskCanceled) break; // if the repository is encrypted and password is incorrect if (repo.encrypted && task->httpErrorCode() == 400) { SetRepoPasswordDialog password_dialog(repo, dialog_parent); if (password_dialog.exec()) continue; // the user cancel the dialog here? skip break; } QString msg = QObject::tr("Unable to download item \"%1\"").arg(path_in_repo); seafApplet->warningBox(msg); break; }; } }
void SyncErrorsTableView::onItemDoubleClicked(const QModelIndex& index) { SyncErrorsTableModel *model = (SyncErrorsTableModel *)this->model(); SyncError error = model->errorAt(index.row()); // printf("error repo id is %s\n", error.repo_id.toUtf8().data()); if (!error.repo_id.isEmpty()) { LocalRepo repo; seafApplet->rpcClient()->getLocalRepo(error.repo_id, &repo); if (repo.isValid()) { QDesktopServices::openUrl(QUrl::fromLocalFile(repo.worktree)); } } }
void RepoTreeModel::updateRepoItemAfterSyncNow(RepoItem *item, void *data) { QString repo_id = *(QString *)data; LocalRepo r = item->localRepo(); if (r.isValid() && r.id == repo_id) { // We manually set the sync state of the repo to "SYNC_STATE_ING" to give // the user immediate feedback r.setSyncInfo("initializing"); r.sync_state = LocalRepo::SYNC_STATE_ING; r.sync_state_str = tr("sync initializing"); item->setLocalRepo(r); item->setSyncNowClicked(true); } }