Skip to content

Commit

Permalink
Added debug messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
dchapyshev committed Nov 8, 2023
1 parent 9b8545e commit 46d04a6
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 4 deletions.
7 changes: 5 additions & 2 deletions source/host/ui/change_password_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ChangePasswordDialog::ChangePasswordDialog(Mode mode, QWidget* parent)
: QDialog(parent),
mode_(mode)
{
LOG(LS_INFO) << "ChangePasswordDialog Ctor (" << static_cast<int>(mode) << ")";
LOG(LS_INFO) << "Ctor (" << static_cast<int>(mode) << ")";
ui.setupUi(this);

QPushButton* cancel_button = ui.button_box->button(QDialogButtonBox::StandardButton::Cancel);
Expand Down Expand Up @@ -62,7 +62,7 @@ ChangePasswordDialog::ChangePasswordDialog(Mode mode, QWidget* parent)
//--------------------------------------------------------------------------------------------------
ChangePasswordDialog::~ChangePasswordDialog()
{
LOG(LS_INFO) << "ChangePasswordDialog Dtor";
LOG(LS_INFO) << "Dtor";
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -83,6 +83,8 @@ void ChangePasswordDialog::onButtonBoxClicked(QAbstractButton* button)
QDialogButtonBox::StandardButton standard_button = ui.button_box->standardButton(button);
if (standard_button == QDialogButtonBox::Ok)
{
LOG(LS_INFO) << "[ACTION] Accepted by user";

if (mode_ == Mode::CREATE_NEW_PASSWORD)
{
QString new_password = ui.edit_new_pass->text();
Expand Down Expand Up @@ -165,6 +167,7 @@ void ChangePasswordDialog::onButtonBoxClicked(QAbstractButton* button)
}
else
{
LOG(LS_INFO) << "[ACTION] Rejected by user";
reject();
}

Expand Down
3 changes: 3 additions & 0 deletions source/host/ui/check_password_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ void CheckPasswordDialog::onButtonBoxClicked(QAbstractButton* button)
QDialogButtonBox::StandardButton standard_button = ui.button_box->standardButton(button);
if (standard_button == QDialogButtonBox::Ok)
{
LOG(LS_INFO) << "[ACTION] Accepted by user";

QString password = ui.edit_pass->text();

if (!SystemSettings::isValidPassword(password.toStdString()))
Expand All @@ -79,6 +81,7 @@ void CheckPasswordDialog::onButtonBoxClicked(QAbstractButton* button)
}
else
{
LOG(LS_INFO) << "[ACTION] Rejected by user";
reject();
}

Expand Down
39 changes: 39 additions & 0 deletions source/host/ui/config_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ void ConfigDialog::onCurrentUserChanged(
//--------------------------------------------------------------------------------------------------
void ConfigDialog::onAddUser()
{
LOG(LS_INFO) << "[ACTION] Add user";

QStringList exist_names;

for (int i = 0; i < ui.tree_users->topLevelItemCount(); ++i)
Expand All @@ -369,9 +371,14 @@ void ConfigDialog::onAddUser()
//--------------------------------------------------------------------------------------------------
void ConfigDialog::onModifyUser()
{
LOG(LS_INFO) << "[ACTION] Modify user";

UserTreeItem* current_item = static_cast<UserTreeItem*>(ui.tree_users->currentItem());
if (!current_item)
{
LOG(LS_INFO) << "No selected item";
return;
}

QString current_name = current_item->text(0);
QStringList exist_names;
Expand All @@ -394,9 +401,14 @@ void ConfigDialog::onModifyUser()
//--------------------------------------------------------------------------------------------------
void ConfigDialog::onDeleteUser()
{
LOG(LS_INFO) << "[ACTION] Delete user";

UserTreeItem* user_item = static_cast<UserTreeItem*>(ui.tree_users->currentItem());
if (!user_item)
{
LOG(LS_INFO) << "No selected item";
return;
}

QMessageBox message_box(QMessageBox::Question,
tr("Confirmation"),
Expand All @@ -409,9 +421,14 @@ void ConfigDialog::onDeleteUser()

if (message_box.exec() == QMessageBox::Yes)
{
LOG(LS_INFO) << "[ACTION] Accepted by user";
delete user_item;
setConfigChanged(true);
}
else
{
LOG(LS_INFO) << "[ACTION] Rejected by user";
}

if (ui.tree_users->topLevelItemCount() <= 0)
{
Expand Down Expand Up @@ -540,10 +557,15 @@ void ConfigDialog::onChangePassClicked()
//--------------------------------------------------------------------------------------------------
void ConfigDialog::onImport()
{
LOG(LS_INFO) << "[ACTION] Import settings";

QString file_path =
QFileDialog::getOpenFileName(this, tr("Import"), QString(), tr("JSON-files (*.json)"));
if (file_path.isEmpty())
{
LOG(LS_INFO) << "No selected file path";
return;
}

if (SettingsUtil::importFromFile(file_path.toStdU16String(), false, this))
{
Expand Down Expand Up @@ -575,10 +597,15 @@ void ConfigDialog::onImport()
//--------------------------------------------------------------------------------------------------
void ConfigDialog::onExport()
{
LOG(LS_INFO) << "[ACTION] Export settings";

QString file_path =
QFileDialog::getSaveFileName(this, tr("Export"), QString(), tr("JSON-files (*.json)"));
if (file_path.isEmpty())
{
LOG(LS_INFO) << "No selected file path";
return;
}

SettingsUtil::exportToFile(file_path.toStdU16String(), false, this);
}
Expand All @@ -591,6 +618,8 @@ void ConfigDialog::onButtonBoxClicked(QAbstractButton* button)
if (isConfigChanged() && (standard_button == QDialogButtonBox::Ok ||
standard_button == QDialogButtonBox::Apply))
{
LOG(LS_INFO) << "[ACTION] Accepted by user";

SystemSettings settings;

if (!settings.isWritable())
Expand Down Expand Up @@ -711,6 +740,7 @@ void ConfigDialog::onButtonBoxClicked(QAbstractButton* button)
}
else if (standard_button == QDialogButtonBox::Cancel)
{
LOG(LS_INFO) << "[ACTION] Rejected by user";
reject();
}

Expand Down Expand Up @@ -920,14 +950,18 @@ bool ConfigDialog::installService()
std::filesystem::path service_file_path;

if (!base::BasePaths::currentExecDir(&service_file_path))
{
LOG(LS_ERROR) << "BasePaths::currentExecDir failed";
return false;
}

service_file_path.append(kHostServiceFileName);

base::win::ServiceController controller = base::win::ServiceController::install(
kHostServiceName, kHostServiceDisplayName, service_file_path);
if (!controller.isValid())
{
LOG(LS_INFO) << "Unable to install service";
QMessageBox::warning(this,
tr("Warning"),
tr("The service could not be installed."),
Expand All @@ -952,6 +986,7 @@ bool ConfigDialog::removeService()
#if defined(OS_WIN)
if (!base::win::ServiceController::remove(kHostServiceName))
{
LOG(LS_ERROR) << "Unable to remove service";
QMessageBox::warning(this,
tr("Warning"),
tr("The service could not be removed."),
Expand All @@ -972,6 +1007,7 @@ bool ConfigDialog::startService()
base::win::ServiceController controller = base::win::ServiceController::open(kHostServiceName);
if (!controller.isValid())
{
LOG(LS_ERROR) << "Unable to open service";
QMessageBox::warning(this,
tr("Warning"),
tr("Could not access the service."),
Expand All @@ -982,6 +1018,7 @@ bool ConfigDialog::startService()
{
if (!controller.start())
{
LOG(LS_ERROR) << "Unable to start serivce";
QMessageBox::warning(this,
tr("Warning"),
tr("The service could not be started."),
Expand All @@ -1003,6 +1040,7 @@ bool ConfigDialog::stopService()
base::win::ServiceController controller = base::win::ServiceController::open(kHostServiceName);
if (!controller.isValid())
{
LOG(LS_ERROR) << "Unable to open service";
QMessageBox::warning(this,
tr("Warning"),
tr("Could not access the service."),
Expand All @@ -1013,6 +1051,7 @@ bool ConfigDialog::stopService()
{
if (!controller.stop())
{
LOG(LS_ERROR) << "Unable to stop service";
QMessageBox::warning(this,
tr("Warning"),
tr("The service could not be stopped."),
Expand Down
4 changes: 2 additions & 2 deletions source/host/ui/connect_confirm_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ void ConnectConfirmDialog::onButtonBoxClicked(QAbstractButton* button)
QDialogButtonBox::StandardButton standard_button = ui.button_box->standardButton(button);
if (standard_button == QDialogButtonBox::Yes)
{
LOG(LS_INFO) << "'Yes' button clicked";
LOG(LS_INFO) << "[ACTION] 'Yes' button clicked";
accept();
}
else
{
LOG(LS_INFO) << "'No' button clicked";
LOG(LS_INFO) << "[ACTION] 'No' button clicked";
reject();
}

Expand Down
16 changes: 16 additions & 0 deletions source/host/ui/notifier_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,15 @@ void NotifierWindow::onClientListChanged(const UserSessionAgent::ClientList& cli
//--------------------------------------------------------------------------------------------------
void NotifierWindow::onVoiceChat()
{
LOG(LS_INFO) << "[ACTION] Voice chat";
is_voice_chat_ = !is_voice_chat_;
emit sig_voiceChat(is_voice_chat_);
}

//--------------------------------------------------------------------------------------------------
void NotifierWindow::onTextChat()
{
LOG(LS_INFO) << "[ACTION] Text chat";
emit sig_textChat();
}

Expand All @@ -257,6 +259,8 @@ void NotifierWindow::onLockMouse()
{
is_mouse_locked_ = !is_mouse_locked_;

LOG(LS_INFO) << "[ACTION] Lock mouse: " << is_mouse_locked_;

QString icon;
QString tooltip;

Expand All @@ -282,6 +286,8 @@ void NotifierWindow::onLockKeyboard()
{
is_keyboard_locked_ = !is_keyboard_locked_;

LOG(LS_INFO) << "[ACTION] Lock keyboard: " << is_keyboard_locked_;

QString icon;
QString tooltip;

Expand All @@ -307,6 +313,8 @@ void NotifierWindow::onPause()
{
is_paused_ = !is_paused_;

LOG(LS_INFO) << "[ACTION] Pause: " << is_paused_;

QString icon;
QString tooltip;

Expand All @@ -330,6 +338,8 @@ void NotifierWindow::onPause()
//--------------------------------------------------------------------------------------------------
void NotifierWindow::onStop()
{
LOG(LS_INFO) << "[ACTION] Stop";

for (int i = 0; i < ui.tree->topLevelItemCount(); ++i)
{
SessionTreeItem* item = static_cast<SessionTreeItem*>(ui.tree->topLevelItem(i));
Expand Down Expand Up @@ -427,9 +437,15 @@ void NotifierWindow::moveEvent(QMoveEvent* event)
void NotifierWindow::onShowHidePressed()
{
if (ui.content->isVisible())
{
LOG(LS_INFO) << "[ACTION] Hide";
hideNotifier();
}
else
{
LOG(LS_INFO) << "[ACTION] Show";
showNotifier();
}
}

//--------------------------------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions source/host/ui/user_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ void UserDialog::onButtonBoxClicked(QAbstractButton* button)
{
if (ui.button_box->standardButton(button) == QDialogButtonBox::Ok)
{
LOG(LS_INFO) << "[ACTION] Accepted by user";

if (account_changed_)
{
std::u16string username = ui.edit_username->text().toStdU16String();
std::u16string password = ui.edit_password->text().toStdU16String();

if (!base::User::isValidUserName(username))
{
LOG(LS_ERROR) << "Invalid user name: " << username;
QMessageBox::warning(this,
tr("Warning"),
tr("The user name can not be empty and can contain only alphabet"
Expand All @@ -154,6 +157,7 @@ void UserDialog::onButtonBoxClicked(QAbstractButton* button)

if (exist_names_.contains(username, Qt::CaseInsensitive))
{
LOG(LS_ERROR) << "User name already exists: " << username;
QMessageBox::warning(this,
tr("Warning"),
tr("The username you entered already exists."),
Expand All @@ -169,6 +173,7 @@ void UserDialog::onButtonBoxClicked(QAbstractButton* button)
if (password != ui.edit_password_repeat->text().toStdU16String())
#endif
{
LOG(LS_ERROR) << "Passwords do not match";
QMessageBox::warning(this,
tr("Warning"),
tr("The passwords you entered do not match."),
Expand All @@ -180,6 +185,7 @@ void UserDialog::onButtonBoxClicked(QAbstractButton* button)

if (!base::User::isValidPassword(password))
{
LOG(LS_ERROR) << "Invalid password";
QMessageBox::warning(this,
tr("Warning"),
tr("Password can not be empty and should not exceed %n characters.",
Expand Down Expand Up @@ -222,6 +228,7 @@ void UserDialog::onButtonBoxClicked(QAbstractButton* button)
user_ = base::User::create(username, password);
if (!user_.isValid())
{
LOG(LS_ERROR) << "Unable to create user";
QMessageBox::warning(this,
tr("Warning"),
tr("Unknown internal error when creating or modifying a user."),
Expand Down Expand Up @@ -249,6 +256,7 @@ void UserDialog::onButtonBoxClicked(QAbstractButton* button)
}
else
{
LOG(LS_INFO) << "[ACTION] Rejected by user";
reject();
}

Expand All @@ -258,6 +266,7 @@ void UserDialog::onButtonBoxClicked(QAbstractButton* button)
//--------------------------------------------------------------------------------------------------
void UserDialog::setAccountChanged(bool changed)
{
LOG(LS_INFO) << "[ACTION] Account changed";
account_changed_ = changed;

ui.edit_password->setEnabled(changed);
Expand Down

0 comments on commit 46d04a6

Please sign in to comment.