namespace OCC {
-InvalidFilenameDialog::InvalidFilenameDialog(AccountPtr account, Folder *folder, QString filePath, FileLocation fileLocation, QWidget *parent)
+InvalidFilenameDialog::InvalidFilenameDialog(AccountPtr account,
+ Folder *folder,
+ QString filePath,
+ FileLocation fileLocation,
+ InvalidMode invalidMode,
+ QWidget *parent)
: QDialog(parent)
, _ui(new Ui::InvalidFilenameDialog)
, _account(account)
_ui->descriptionLabel->setTextFormat(Qt::PlainText);
_ui->errorLabel->setTextFormat(Qt::PlainText);
- _ui->descriptionLabel->setText(tr("The file \"%1\" could not be synced because the name contains characters which are not allowed on this system.").arg(_originalFileName));
- _ui->explanationLabel->setText(tr("The following characters are not allowed on the system: * \" | & ? , ; : \\ / ~ < > leading/trailing spaces"));
+ switch (invalidMode) {
+ case InvalidMode::SystemInvalid:
+ _ui->descriptionLabel->setText(tr("The file \"%1\" could not be synced because the name contains characters which are not allowed on this system.").arg(_originalFileName));
+ _ui->explanationLabel->setText(tr("The following characters are not allowed on the system: * \" | & ? , ; : \\ / ~ < > leading/trailing spaces"));
+ break;
+ case InvalidMode::ServerInvalid:
+ _ui->descriptionLabel->setText(tr("The file \"%1\" could not be synced because the name contains characters which are not allowed on the server.").arg(_originalFileName));
+
+ const auto caps = _account->capabilities();
+ const auto forbiddenCharacters = caps.forbiddenFilenameCharacters();
+ const auto forbiddenBasenames = caps.forbiddenFilenameBasenames();
+ const auto forbiddenFilenames = caps.forbiddenFilenames();
+ const auto forbiddenExtensions = caps.forbiddenFilenameExtensions();
+
+ auto explanations = QStringList();
+
+ if (!forbiddenCharacters.isEmpty()) {
+ explanations.append(tr("The following characters are not allowed: %1").arg(forbiddenCharacters.join(" ")));
+ }
+ if (!forbiddenBasenames.isEmpty()) {
+ explanations.append(tr("The following basenames are not allowed: %1").arg(forbiddenBasenames.join(" ")));
+ }
+ if (!forbiddenFilenames.isEmpty()) {
+ explanations.append(tr("The following filenames are not allowed: %1").arg(forbiddenFilenames.join(" ")));
+ }
+ if (!forbiddenExtensions.isEmpty()) {
+ explanations.append(tr("The following file extensions are not allowed: %1").arg(forbiddenExtensions.join(" ")));
+ }
+ _ui->explanationLabel->setText(explanations.join("\n"));
+ break;
+ }
_ui->filenameLineEdit->setText(filePathFileInfo.fileName());
connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);