void AccountSettingsDialog::onSubmitBtnClicked() { if (!validateInputs()) { return; } QString url = mServerAddr->text().trimmed(); if (url != account_.serverUrl.toString()) { Account new_account(account_); new_account.serverUrl = url; if (seafApplet->accountManager()->replaceAccount(account_, new_account) < 0) { showWarning(tr("Failed to save account information")); return; } QString error; QUrl new_server_url = new_account.serverUrl; new_server_url.setPath("/"); if (seafApplet->rpcClient()->updateReposServerHost(account_.serverUrl.host(), new_account.serverUrl.host(), new_server_url.toString(), &error) < 0) { showWarning(tr("Failed to save the changes: %1").arg(error)); return; } } seafApplet->messageBox(tr("Successfully updated current account information"), this); accept(); }
void LoginDialog::doLogin() { if (!validateInputs()) { return; } mStatusText->setText(tr("Logging in...")); mServerAddr->setEnabled(false); mUsername->setEnabled(false); mPassword->setEnabled(false); mSubmitBtn->setEnabled(false); if (request_) { delete request_; } request_ = new LoginRequest(url_, username_, password_); request_->setIgnoreSslErrors(false); connect(request_, SIGNAL(success(const QString&)), this, SLOT(loginSuccess(const QString&))); connect(request_, SIGNAL(failed(int)), this, SLOT(loginFailed(int))); connect(request_, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT(onSslErrors(QNetworkReply*, const QList<QSslError>&))); request_->send(); }
void LoginDialog::doLogin() { if (!validateInputs()) { return; } saveUsedServerAddresses(url_.toString()); mStatusText->setText(tr("Logging in...")); disableInputs(); if (request_) { request_->deleteLater(); } request_ = new LoginRequest(url_, username_, password_, computer_name_); if (!two_factor_auth_token_.isEmpty()) { request_->setHeader(kSeafileOTPHeader, two_factor_auth_token_); } connect(request_, SIGNAL(success(const QString&)), this, SLOT(loginSuccess(const QString&))); connect(request_, SIGNAL(failed(const ApiError&)), this, SLOT(loginFailed(const ApiError&))); request_->send(); }
void DownloadRepoDialog::onOkBtnClicked() { if (!validateInputs()) { return; } setAllInputsEnabled(false); DownloadRepoRequest *req = new DownloadRepoRequest(account_, repo_.id, repo_.readonly); connect(req, SIGNAL(success(const RepoDownloadInfo&)), this, SLOT(onDownloadRepoRequestSuccess(const RepoDownloadInfo&))); connect(req, SIGNAL(failed(const ApiError&)), this, SLOT(onDownloadRepoRequestFailed(const ApiError&))); req->send(); }
void CreateRepoDialog::createAction() { if (!validateInputs()) { return; } mStatusText->setText(tr("Creating...")); setAllInputsEnabled(false); if (request_) { delete request_; } request_ = new CreateRepoRequest(account_, name_, desc_, passwd_); connect(request_, SIGNAL(success(const RepoDownloadInfo&)), this, SLOT(createSuccess(const RepoDownloadInfo&))); connect(request_, SIGNAL(failed(const ApiError&)), this, SLOT(createFailed(const ApiError&))); request_->send(); }
int test_validateInputs() { int valid = 0; int result; result = validateInputs("action", "scan"); valid += assertTrue("test_validateInputs: action is not valid", result == STATUS_FAILURE); // action result = validateInputs("--action", "scan"); valid += assertTrue("test_validateInputs: Scan is a valid action", result == STATUS_SUCCESS); result = validateInputs("--action", "exists"); valid += assertTrue("test_validateInputs: Scan is a valid action", result == STATUS_SUCCESS); result = validateInputs("--action", "fetch"); valid += assertTrue("test_validateInputs: Scan is a valid action", result == STATUS_SUCCESS); result = validateInputs("--action", "store"); valid += assertTrue("test_validateInputs: Scan is a valid action", result == STATUS_SUCCESS); result = validateInputs("--action", "delete"); valid += assertTrue("test_validateInputs: Scan is a valid action", result == STATUS_SUCCESS); result = validateInputs("--action", "invalid"); valid += assertTrue("test_validateInputs: invalid is not a valid action", result == CONFIG_ERROR_ACTION); // engine result = validateInputs("--engine", "mc"); valid += assertTrue("test_validateInputs: mc is a valid engine", result == STATUS_SUCCESS); result = validateInputs("--engine", "shm"); valid += assertTrue("test_validateInputs: shm is a valid engine", result == STATUS_SUCCESS); result = validateInputs("--engine", "invalid"); valid += assertTrue("test_validateInputs: invalid is not a valid engine", result == CONFIG_ERROR_ENGINE); // search result = validateInputs("--search", "test"); valid += assertTrue("test_validateInputs: test is a valid search", result == STATUS_SUCCESS); result = validateInputs("--search", ""); valid += assertTrue("test_validateInputs: (empty) is not a valid engine", result == CONFIG_ERROR_SEARCH); // file result = validateInputs("--file", BLANK_FILENAME); valid += assertTrue("test_validateInputs: BLANK_FILENAME is a valid file", result == CONFIG_ERROR_FILE); createBlankFile(BLANK_FILENAME); result = validateInputs("--file", BLANK_FILENAME); valid += assertTrue("test_validateInputs: BLANK_FILENAME is a valid file", result == STATUS_SUCCESS); remove(BLANK_FILENAME); result = validateInputs("--file", "/tmp/"); valid += assertTrue("test_validateInputs: /tmp/ is a valid dir", result == STATUS_SUCCESS); result = validateInputs("--file", "/tmp/3q084gh0w3q840hg8"); valid += assertTrue("test_validateInputs: /tmp/ is a valid dir", result == CONFIG_ERROR_FILE); // limit result = validateInputs("--limit", 0); valid += assertTrue("test_validateInputs: 0 is not a valid limit", result == CONFIG_ERROR_LIMIT); result = validateInputs("--limit", 1); valid += assertTrue("test_validateInputs: 1 is a valid limit", result == STATUS_SUCCESS); result = validateInputs("--limit", 100); valid += assertTrue("test_validateInputs: 100 is a valid limit", result == STATUS_SUCCESS); result = validateInputs("--limit", -100); valid += assertTrue("test_validateInputs: -100 is a valid limit", result == CONFIG_ERROR_LIMIT); result = validateInputs("--limit", 1024); valid += assertTrue("test_validateInputs: 1024 is a valid limit", result == STATUS_SUCCESS); result = validateInputs("--limit", 1025); valid += assertTrue("test_validateInputs: 1025 is not a valid limit", result == CONFIG_ERROR_LIMIT); // read buffer result = validateInputs("--read_buffer", 0); valid += assertTrue("test_validateInputs: 0 is not a valid read_buffer", result == CONFIG_ERROR_READ_BUFFER); result = validateInputs("--read_buffer", 1); valid += assertTrue("test_validateInputs: 1 is a valid read_buffer", result == STATUS_SUCCESS); result = validateInputs("--read_buffer", 100); valid += assertTrue("test_validateInputs: 100 is a valid read_buffer", result == STATUS_SUCCESS); result = validateInputs("--read_buffer", -100); valid += assertTrue("test_validateInputs: -100 is a valid read_buffer", result == CONFIG_ERROR_READ_BUFFER); result = validateInputs("--read_buffer", 255); valid += assertTrue("test_validateInputs: 255 is a valid read_buffer", result == STATUS_SUCCESS); result = validateInputs("--read_buffer", 256); valid += assertTrue("test_validateInputs: 256 is not a valid read_buffer", result == CONFIG_ERROR_READ_BUFFER); // output result = validateInputs("--output", "screen"); valid += assertTrue("test_validateInputs: screen is a valid ouput", result == STATUS_SUCCESS); result = validateInputs("--output", "/abc/def/zyw"); valid += assertTrue("test_validateInputs: /abc/def/zyw is not a valid ouput (ENOENT)", result == ENOENT); createBlankFile(BLANK_FILENAME); result = validateInputs("--output", BLANK_FILENAME); valid += assertTrue("test_validateInputs: BLANK_FILENAME is not a valid ouput (CONFIG_ERROR_OUTPUT_FILE_EXISTS)", result == CONFIG_ERROR_OUTPUT_FILE_EXISTS); remove(BLANK_FILENAME); result = validateInputs("--output", "/etc/"); valid += assertTrue("test_validateInputs: /etc/ is not a valid ouput (EACCES)", result == EACCES); return valid; }
void FilterDialog::approveButton_clicked() { if(validateInputs()) hide(); }