File indexing completed on 2024-04-21 15:42:47
0001 /*************************************************************************** 0002 Private helper classes for Smb4KCustomOptionsManagerPrivate class 0003 ------------------- 0004 begin : Fr 29 Apr 2011 0005 copyright : (C) 2011-2019 by Alexander Reinholdt 0006 email : alexander.reinholdt@kdemail.net 0007 ***************************************************************************/ 0008 0009 /*************************************************************************** 0010 * This program is free software; you can redistribute it and/or modify * 0011 * it under the terms of the GNU General Public License as published by * 0012 * the Free Software Foundation; either version 2 of the License, or * 0013 * (at your option) any later version. * 0014 * * 0015 * This program is distributed in the hope that it will be useful, but * 0016 * WITHOUT ANY WARRANTY; without even the implied warranty of * 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 0018 * General Public License for more details. * 0019 * * 0020 * You should have received a copy of the GNU General Public License * 0021 * along with this program; if not, write to the * 0022 * Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,* 0023 * MA 02110-1335, USA * 0024 ***************************************************************************/ 0025 0026 #ifdef HAVE_CONFIG_H 0027 #include <config.h> 0028 #endif 0029 0030 // application specific includes 0031 #include "smb4kcustomoptionsmanager_p.h" 0032 #include "smb4ksettings.h" 0033 0034 #if defined(Q_OS_LINUX) 0035 #include "smb4kmountsettings_linux.h" 0036 #elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) 0037 #include "smb4kmountsettings_bsd.h" 0038 #endif 0039 0040 // Qt includes 0041 #include <QList> 0042 #include <QCheckBox> 0043 #include <QSpinBox> 0044 #include <QPushButton> 0045 #include <QVBoxLayout> 0046 #include <QHBoxLayout> 0047 #include <QLabel> 0048 #include <QGroupBox> 0049 #include <QTabWidget> 0050 #include <QPushButton> 0051 #include <QDialogButtonBox> 0052 #include <QWindow> 0053 0054 // KDE includes 0055 #define TRANSLATION_DOMAIN "smb4k-core" 0056 #include <KI18n/KLocalizedString> 0057 #include <KCoreAddons/KUser> 0058 #include <KConfigGui/KWindowConfig> 0059 #include <KIconThemes/KIconLoader> 0060 #include <KCompletion/KLineEdit> 0061 #include <KCompletion/KComboBox> 0062 0063 0064 Smb4KCustomOptionsDialog::Smb4KCustomOptionsDialog(const OptionsPtr &options, QWidget *parent) 0065 : QDialog(parent), m_options(options) 0066 { 0067 // 0068 // Set the title 0069 // 0070 setWindowTitle(i18n("Custom Options")); 0071 0072 // 0073 // Set up the layout 0074 // 0075 QVBoxLayout *layout = new QVBoxLayout(this); 0076 layout->setSpacing(5); 0077 setLayout(layout); 0078 0079 // Header 0080 QWidget *header = new QWidget(this); 0081 0082 QHBoxLayout *headerLayout = new QHBoxLayout(header); 0083 headerLayout->setSpacing(5); 0084 headerLayout->setMargin(0); 0085 0086 QLabel *pixmap = new QLabel(header); 0087 QPixmap preferencesPixmap = KDE::icon("preferences-system-network").pixmap(KIconLoader::SizeHuge); 0088 pixmap->setPixmap(preferencesPixmap); 0089 pixmap->setAlignment(Qt::AlignCenter); 0090 0091 QLabel *description = 0; 0092 0093 switch (m_options->type()) 0094 { 0095 case Host: 0096 { 0097 description = new QLabel(i18n("<p>Define custom options for host <b>%1</b> and all the shares it provides.</p>", m_options->displayString()), header); 0098 break; 0099 } 0100 case Share: 0101 { 0102 description = new QLabel(i18n("<p>Define custom options for share <b>%1</b>.</p>", m_options->displayString()), header); 0103 break; 0104 } 0105 default: 0106 { 0107 description = new QLabel(); 0108 break; 0109 } 0110 } 0111 0112 description->setWordWrap(true); 0113 description->setAlignment(Qt::AlignVCenter); 0114 0115 headerLayout->addWidget(pixmap, 0); 0116 headerLayout->addWidget(description, Qt::AlignVCenter); 0117 0118 layout->addWidget(header, 0); 0119 0120 // 0121 // Set up the operating system dependent stuff 0122 // 0123 setupView(); 0124 0125 // 0126 // Finish the layout 0127 // 0128 QDialogButtonBox *buttonBox = new QDialogButtonBox(Qt::Horizontal, this); 0129 0130 QPushButton *restoreButton = buttonBox->addButton(QDialogButtonBox::RestoreDefaults); 0131 0132 QPushButton *okButton = buttonBox->addButton(QDialogButtonBox::Ok); 0133 okButton->setShortcut(Qt::CTRL|Qt::Key_Return); 0134 okButton->setDefault(true); 0135 0136 QPushButton *cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel); 0137 cancelButton->setShortcut(Qt::Key_Escape); 0138 0139 layout->addWidget(buttonBox, 0); 0140 0141 // 0142 // Connections 0143 // 0144 connect(restoreButton, SIGNAL(clicked()), SLOT(slotSetDefaultValues())); 0145 connect(okButton, SIGNAL(clicked()), SLOT(slotOKClicked())); 0146 connect(cancelButton, SIGNAL(clicked()), SLOT(reject())); 0147 0148 // 0149 // Set the dialog size 0150 // 0151 create(); 0152 0153 KConfigGroup group(Smb4KSettings::self()->config(), "CustomOptionsDialog"); 0154 QSize dialogSize; 0155 0156 if (group.exists()) 0157 { 0158 KWindowConfig::restoreWindowSize(windowHandle(), group); 0159 dialogSize = windowHandle()->size(); 0160 } 0161 else 0162 { 0163 dialogSize = sizeHint(); 0164 } 0165 0166 resize(dialogSize); // workaround for QTBUG-40584 0167 0168 // 0169 // Enable/disable buttons 0170 // 0171 restoreButton->setEnabled(!checkDefaultValues()); 0172 } 0173 0174 0175 Smb4KCustomOptionsDialog::~Smb4KCustomOptionsDialog() 0176 { 0177 } 0178 0179 0180 #if defined(Q_OS_LINUX) 0181 // 0182 // Linux 0183 // 0184 void Smb4KCustomOptionsDialog::setupView() 0185 { 0186 // 0187 // Tab widget with settings 0188 // 0189 QTabWidget *tabWidget = new QTabWidget(this); 0190 0191 QVBoxLayout *dialogLayout = qobject_cast<QVBoxLayout *>(layout()); 0192 dialogLayout->addWidget(tabWidget, 0); 0193 0194 // 0195 // Custom options for mounting 0196 // 0197 QWidget *mountingTab = new QWidget(tabWidget); 0198 0199 QVBoxLayout *mountingTabLayout = new QVBoxLayout(mountingTab); 0200 mountingTabLayout->setSpacing(5); 0201 0202 // 0203 // Common options 0204 // 0205 QGroupBox *commonBox = new QGroupBox(i18n("Common Options"), mountingTab); 0206 QGridLayout *commonBoxLayout = new QGridLayout(commonBox); 0207 commonBoxLayout->setSpacing(5); 0208 0209 QCheckBox *remountAlways = new QCheckBox(i18n("Always remount this share"), commonBox); 0210 remountAlways->setObjectName("RemountAlways"); 0211 remountAlways->setEnabled(m_options->type() == Share); 0212 connect(remountAlways, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0213 0214 commonBoxLayout->addWidget(remountAlways, 0, 0, 1, 2, 0); 0215 0216 // Write access 0217 QCheckBox *useWriteAccess = new QCheckBox(Smb4KMountSettings::self()->useWriteAccessItem()->label(), commonBox); 0218 useWriteAccess->setObjectName("UseWriteAccess"); 0219 0220 KComboBox *writeAccess = new KComboBox(commonBox); 0221 writeAccess->setObjectName("WriteAccess"); 0222 0223 QString readWriteText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadWrite).label; 0224 QString readOnlyText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadOnly).label; 0225 0226 writeAccess->addItem(readWriteText); 0227 writeAccess->addItem(readOnlyText); 0228 0229 connect(useWriteAccess, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0230 connect(writeAccess, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues())); 0231 0232 commonBoxLayout->addWidget(useWriteAccess, 1, 0, 0); 0233 commonBoxLayout->addWidget(writeAccess, 1, 1, 0); 0234 0235 // Remote file system port 0236 QCheckBox *useFilesystemPort = new QCheckBox(Smb4KMountSettings::self()->useRemoteFileSystemPortItem()->label(), commonBox); 0237 useFilesystemPort->setObjectName("UseFilesystemPort"); 0238 0239 QSpinBox *filesystemPort = new QSpinBox(commonBox); 0240 filesystemPort->setObjectName("FileSystemPort"); 0241 filesystemPort->setMinimum(Smb4KMountSettings::self()->remoteFileSystemPortItem()->minValue().toInt()); 0242 filesystemPort->setMaximum(Smb4KMountSettings::self()->remoteFileSystemPortItem()->maxValue().toInt()); 0243 // filesystemPort->setSliderEnabled(true); 0244 0245 connect(useFilesystemPort, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0246 connect(filesystemPort, SIGNAL(valueChanged(int)), SLOT(slotCheckValues())); 0247 0248 commonBoxLayout->addWidget(useFilesystemPort, 2, 0, 0); 0249 commonBoxLayout->addWidget(filesystemPort, 2, 1, 0); 0250 0251 mountingTabLayout->addWidget(commonBox, 0); 0252 0253 // 0254 // CIFS Unix Extensions Support 0255 // 0256 QGroupBox *extensionsSupportBox = new QGroupBox(i18n("CIFS Unix Extensions Support"), mountingTab); 0257 QGridLayout *extensionsSupportBoxLayout = new QGridLayout(extensionsSupportBox); 0258 extensionsSupportBoxLayout->setSpacing(5); 0259 0260 QCheckBox *cifsExtensionsSupport = new QCheckBox(i18n("This server supports the CIFS Unix extensions"), extensionsSupportBox); 0261 cifsExtensionsSupport->setObjectName("CifsExtensionsSupport"); 0262 0263 connect(cifsExtensionsSupport, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0264 connect(cifsExtensionsSupport, SIGNAL(toggled(bool)), SLOT(slotCifsExtensionsSupport(bool))); 0265 0266 extensionsSupportBoxLayout->addWidget(cifsExtensionsSupport, 0, 0, 1, 4, 0); 0267 0268 // User Id 0269 QCheckBox *useUserId = new QCheckBox(Smb4KMountSettings::self()->useUserIdItem()->label(), extensionsSupportBox); 0270 useUserId->setObjectName("UseUserId"); 0271 0272 KComboBox *userId = new KComboBox(extensionsSupportBox); 0273 userId->setObjectName("UserId"); 0274 0275 QList<KUser> allUsers = KUser::allUsers(); 0276 0277 for (const KUser &u : allUsers) 0278 { 0279 userId->addItem(QString("%1 (%2)").arg(u.loginName()).arg(u.userId().nativeId()), QVariant::fromValue<K_GID>(u.groupId().nativeId())); 0280 } 0281 0282 connect(useUserId, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0283 connect(userId, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues())); 0284 0285 extensionsSupportBoxLayout->addWidget(useUserId, 1, 0, 0); 0286 extensionsSupportBoxLayout->addWidget(userId, 1, 1, 0); 0287 0288 // Group Id 0289 QCheckBox *useGroupId = new QCheckBox(Smb4KMountSettings::self()->useGroupIdItem()->label(), extensionsSupportBox); 0290 useGroupId->setObjectName("UseGroupId"); 0291 0292 KComboBox *groupId = new KComboBox(extensionsSupportBox); 0293 groupId->setObjectName("GroupId"); 0294 0295 QList<KUserGroup> allGroups = KUserGroup::allGroups(); 0296 0297 for (const KUserGroup &g : allGroups) 0298 { 0299 groupId->addItem(QString("%1 (%2)").arg(g.name()).arg(g.groupId().nativeId()), QVariant::fromValue<K_GID>(g.groupId().nativeId())); 0300 } 0301 0302 connect(useGroupId, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0303 connect(groupId, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues())); 0304 0305 extensionsSupportBoxLayout->addWidget(useGroupId, 2, 0, 0); 0306 extensionsSupportBoxLayout->addWidget(groupId, 2, 1, 0); 0307 0308 // File mode 0309 QCheckBox *useFileMode = new QCheckBox(Smb4KMountSettings::self()->useFileModeItem()->label(), extensionsSupportBox); 0310 useFileMode->setObjectName("UseFileMode"); 0311 0312 KLineEdit *fileMode = new KLineEdit(extensionsSupportBox); 0313 fileMode->setObjectName("FileMode"); 0314 fileMode->setClearButtonEnabled(true); 0315 fileMode->setAlignment(Qt::AlignRight); 0316 0317 connect(useFileMode, SIGNAL(toggled(bool)), this, SLOT(slotCheckValues())); 0318 connect(fileMode, SIGNAL(textEdited(QString)), this, SLOT(slotCheckValues())); 0319 0320 extensionsSupportBoxLayout->addWidget(useFileMode, 3, 0, 0); 0321 extensionsSupportBoxLayout->addWidget(fileMode, 3, 1, 0); 0322 0323 // Directory mode 0324 QCheckBox *useDirectoryMode = new QCheckBox(Smb4KMountSettings::self()->useDirectoryModeItem()->label(), extensionsSupportBox); 0325 useDirectoryMode->setObjectName("UseDirectoryMode"); 0326 0327 KLineEdit *directoryMode = new KLineEdit(extensionsSupportBox); 0328 directoryMode->setObjectName("DirectoryMode"); 0329 directoryMode->setClearButtonEnabled(true); 0330 directoryMode->setAlignment(Qt::AlignRight); 0331 0332 connect(useDirectoryMode, SIGNAL(toggled(bool)), this, SLOT(slotCheckValues())); 0333 connect(directoryMode, SIGNAL(textEdited(QString)), this, SLOT(slotCheckValues())); 0334 0335 extensionsSupportBoxLayout->addWidget(useDirectoryMode, 4, 0, 0); 0336 extensionsSupportBoxLayout->addWidget(directoryMode, 4, 1, 0); 0337 0338 mountingTabLayout->addWidget(extensionsSupportBox, 0); 0339 0340 // 0341 // Advanced options 0342 // 0343 QGroupBox *advancedOptionsBox = new QGroupBox(i18n("Advanced Options"), mountingTab); 0344 QGridLayout *advancedOptionsBoxLayout = new QGridLayout(advancedOptionsBox); 0345 advancedOptionsBoxLayout->setSpacing(5); 0346 0347 // Security mode 0348 QCheckBox *useSecurityMode = new QCheckBox(Smb4KMountSettings::self()->useSecurityModeItem()->label(), advancedOptionsBox); 0349 useSecurityMode->setObjectName("UseSecurityMode"); 0350 0351 KComboBox *securityMode = new KComboBox(advancedOptionsBox); 0352 securityMode->setObjectName("SecurityMode"); 0353 0354 QString noneText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::None).label; 0355 QString krb5Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5).label; 0356 QString krb5iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5i).label; 0357 QString ntlmText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlm).label; 0358 QString ntlmiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmi).label; 0359 QString ntlmv2Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2).label; 0360 QString ntlmv2iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2i).label; 0361 QString ntlmsspText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmssp).label; 0362 QString ntlmsspiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmsspi).label; 0363 0364 securityMode->addItem(noneText); 0365 securityMode->addItem(krb5Text); 0366 securityMode->addItem(krb5iText); 0367 securityMode->addItem(ntlmText); 0368 securityMode->addItem(ntlmiText); 0369 securityMode->addItem(ntlmv2Text); 0370 securityMode->addItem(ntlmv2iText); 0371 securityMode->addItem(ntlmsspText); 0372 0373 connect(useSecurityMode, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0374 connect(securityMode, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues())); 0375 0376 advancedOptionsBoxLayout->addWidget(useSecurityMode, 0, 0, 0); 0377 advancedOptionsBoxLayout->addWidget(securityMode, 0, 1, 0); 0378 0379 mountingTabLayout->addWidget(advancedOptionsBox, 0); 0380 mountingTabLayout->addStretch(100); 0381 0382 tabWidget->addTab(mountingTab, i18n("Mounting")); 0383 0384 // 0385 // Custom options for Samba 0386 // 0387 QWidget *sambaTab = new QWidget(tabWidget); 0388 QVBoxLayout *sambaTabLayout = new QVBoxLayout(sambaTab); 0389 sambaTabLayout->setSpacing(5); 0390 0391 // 0392 // Common Options 0393 // 0394 QGroupBox *commonSambaOptionsBox = new QGroupBox(i18n("Common Options"), sambaTab); 0395 QGridLayout *commonSambaOptionsBoxLayout = new QGridLayout(commonSambaOptionsBox); 0396 commonSambaOptionsBoxLayout->setSpacing(5); 0397 0398 // SMB port 0399 QCheckBox *useSmbPort = new QCheckBox(Smb4KSettings::self()->useRemoteSmbPortItem()->label(), commonSambaOptionsBox); 0400 useSmbPort->setObjectName("UseSmbPort"); 0401 0402 QSpinBox *smbPort = new QSpinBox(commonSambaOptionsBox); 0403 smbPort->setObjectName("SmbPort"); 0404 smbPort->setMinimum(Smb4KSettings::self()->remoteSmbPortItem()->minValue().toInt()); 0405 smbPort->setMaximum(Smb4KSettings::self()->remoteSmbPortItem()->maxValue().toInt()); 0406 // smbPort->setSliderEnabled(true); 0407 0408 connect(useSmbPort, SIGNAL(toggled(bool)), this, SLOT(slotCheckValues())); 0409 connect(smbPort, SIGNAL(valueChanged(int)), this, SLOT(slotCheckValues())); 0410 0411 commonSambaOptionsBoxLayout->addWidget(useSmbPort, 0, 0, 0); 0412 commonSambaOptionsBoxLayout->addWidget(smbPort, 0, 1, 0); 0413 0414 sambaTabLayout->addWidget(commonSambaOptionsBox, 0); 0415 0416 // 0417 // Authentication 0418 // 0419 QGroupBox *authenticationBox = new QGroupBox(i18n("Authentication"), sambaTab); 0420 QVBoxLayout *authenticationBoxLayout = new QVBoxLayout(authenticationBox); 0421 authenticationBoxLayout->setSpacing(5); 0422 0423 // Kerberos 0424 QCheckBox *useKerberos = new QCheckBox(Smb4KSettings::self()->useKerberosItem()->label(), authenticationBox); 0425 useKerberos->setObjectName("UseKerberos"); 0426 0427 connect(useKerberos, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0428 0429 authenticationBoxLayout->addWidget(useKerberos, 0); 0430 0431 sambaTabLayout->addWidget(authenticationBox, 0); 0432 sambaTabLayout->addStretch(100); 0433 0434 tabWidget->addTab(sambaTab, i18n("Samba")); 0435 0436 // 0437 // Custom options for Wake-On-LAN 0438 // 0439 // NOTE: If you change the texts here, also alter them in the respective 0440 // config page. 0441 // 0442 QWidget *wakeOnLanTab = new QWidget(tabWidget); 0443 QVBoxLayout *wakeOnLanTabLayout = new QVBoxLayout(wakeOnLanTab); 0444 wakeOnLanTabLayout->setSpacing(5); 0445 0446 // 0447 // MAC address 0448 // 0449 QGroupBox *macAddressBox = new QGroupBox(i18n("MAC Address"), wakeOnLanTab); 0450 QGridLayout *macAddressBoxLayout = new QGridLayout(macAddressBox); 0451 macAddressBoxLayout->setSpacing(5); 0452 0453 // MAC address 0454 QLabel *macAddressLabel = new QLabel(i18n("MAC Address:"), macAddressBox); 0455 KLineEdit *macAddress = new KLineEdit(macAddressBox); 0456 macAddress->setObjectName("MACAddress"); 0457 macAddress->setClearButtonEnabled(true); 0458 macAddress->setInputMask("HH:HH:HH:HH:HH:HH;_"); // MAC address, see QLineEdit doc 0459 macAddressLabel->setBuddy(macAddress); 0460 0461 connect(macAddress, SIGNAL(textEdited(QString)), SLOT(slotCheckValues())); 0462 connect(macAddress, SIGNAL(textEdited(QString)), SLOT(slotEnableWOLFeatures(QString))); 0463 0464 macAddressBoxLayout->addWidget(macAddressLabel, 0, 0, 0); 0465 macAddressBoxLayout->addWidget(macAddress, 0, 1, 0); 0466 0467 wakeOnLanTabLayout->addWidget(macAddressBox, 0); 0468 0469 // 0470 // Wake-On-LAN Actions 0471 // 0472 QGroupBox *wakeOnLANActionsBox = new QGroupBox(i18n("Actions"), wakeOnLanTab); 0473 QVBoxLayout *wakeOnLANActionsBoxLayout = new QVBoxLayout(wakeOnLANActionsBox); 0474 wakeOnLANActionsBoxLayout->setSpacing(5); 0475 0476 // Send magic package before network scan 0477 QCheckBox *sendPackageBeforeScan = new QCheckBox(i18n("Send magic package before scanning the network neighborhood"), wakeOnLANActionsBox); 0478 sendPackageBeforeScan->setObjectName("SendPackageBeforeScan"); 0479 0480 connect(sendPackageBeforeScan, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0481 0482 wakeOnLANActionsBoxLayout->addWidget(sendPackageBeforeScan, 0); 0483 0484 // Send magic package before mount 0485 QCheckBox *sendPackageBeforeMount = new QCheckBox(i18n("Send magic package before mounting a share"), wakeOnLanTab); 0486 sendPackageBeforeMount->setObjectName("SendPackageBeforeMount"); 0487 0488 connect(sendPackageBeforeMount, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0489 0490 wakeOnLANActionsBoxLayout->addWidget(sendPackageBeforeMount, 0); 0491 0492 wakeOnLanTabLayout->addWidget(wakeOnLANActionsBox, 0); 0493 wakeOnLanTabLayout->addStretch(100); 0494 0495 tabWidget->addTab(wakeOnLanTab, i18n("Wake-On-LAN")); 0496 0497 // 0498 // Load settings 0499 // 0500 if (m_options->hasOptions()) 0501 { 0502 if (m_options->type() == Share) 0503 { 0504 remountAlways->setChecked((m_options->remount() == Smb4KCustomOptions::RemountAlways)); 0505 } 0506 0507 // CIFS Unix extensions support 0508 cifsExtensionsSupport->setChecked(m_options->cifsUnixExtensionsSupport()); 0509 0510 // User information 0511 useUserId->setChecked(m_options->useUser()); 0512 userId->setCurrentText(QString("%1 (%2)").arg(m_options->user().loginName()).arg(m_options->user().userId().nativeId())); 0513 0514 // Group information 0515 useGroupId->setChecked(m_options->useGroup()); 0516 groupId->setCurrentText(QString("%1 (%2)").arg(m_options->group().name()).arg(m_options->group().groupId().nativeId())); 0517 0518 // File mode 0519 useFileMode->setChecked(m_options->useFileMode()); 0520 fileMode->setText(m_options->fileMode()); 0521 0522 // Directory mode 0523 useDirectoryMode->setChecked(m_options->useDirectoryMode()); 0524 directoryMode->setText(m_options->directoryMode()); 0525 0526 // Remote file system port 0527 useFilesystemPort->setChecked(m_options->useFileSystemPort()); 0528 filesystemPort->setValue(m_options->fileSystemPort()); 0529 0530 // Write access 0531 useWriteAccess->setChecked(m_options->useWriteAccess()); 0532 0533 switch (m_options->writeAccess()) 0534 { 0535 case Smb4KMountSettings::EnumWriteAccess::ReadWrite: 0536 { 0537 writeAccess->setCurrentText(readWriteText); 0538 break; 0539 } 0540 case Smb4KMountSettings::EnumWriteAccess::ReadOnly: 0541 { 0542 writeAccess->setCurrentText(readOnlyText); 0543 break; 0544 } 0545 default: 0546 { 0547 break; 0548 } 0549 } 0550 0551 // Security mode 0552 useSecurityMode->setChecked(m_options->useSecurityMode()); 0553 0554 switch (m_options->securityMode()) 0555 { 0556 case Smb4KMountSettings::EnumSecurityMode::None: 0557 { 0558 securityMode->setCurrentText(noneText); 0559 break; 0560 } 0561 case Smb4KMountSettings::EnumSecurityMode::Krb5: 0562 { 0563 securityMode->setCurrentText(krb5Text); 0564 break; 0565 } 0566 case Smb4KMountSettings::EnumSecurityMode::Krb5i: 0567 { 0568 securityMode->setCurrentText(krb5iText); 0569 break; 0570 } 0571 case Smb4KMountSettings::EnumSecurityMode::Ntlm: 0572 { 0573 securityMode->setCurrentText(ntlmText); 0574 break; 0575 } 0576 case Smb4KMountSettings::EnumSecurityMode::Ntlmi: 0577 { 0578 securityMode->setCurrentText(ntlmiText); 0579 break; 0580 } 0581 case Smb4KMountSettings::EnumSecurityMode::Ntlmv2: 0582 { 0583 securityMode->setCurrentText(ntlmv2Text); 0584 break; 0585 } 0586 case Smb4KMountSettings::EnumSecurityMode::Ntlmv2i: 0587 { 0588 securityMode->setCurrentText(ntlmv2iText); 0589 break; 0590 } 0591 case Smb4KMountSettings::EnumSecurityMode::Ntlmssp: 0592 { 0593 securityMode->setCurrentText(ntlmsspText); 0594 break; 0595 } 0596 case Smb4KMountSettings::EnumSecurityMode::Ntlmsspi: 0597 { 0598 securityMode->setCurrentText(ntlmsspiText); 0599 break; 0600 } 0601 default: 0602 { 0603 break; 0604 } 0605 } 0606 0607 // Remote SMB port 0608 useSmbPort->setChecked(m_options->useSmbPort()); 0609 smbPort->setValue(m_options->smbPort()); 0610 0611 // Kerberos 0612 useKerberos->setChecked(m_options->useKerberos()); 0613 0614 // MAC address 0615 macAddress->setText(m_options->macAddress()); 0616 0617 // Send magic package before scan 0618 sendPackageBeforeScan->setChecked(m_options->wolSendBeforeNetworkScan()); 0619 0620 // Send magic package before mount 0621 sendPackageBeforeMount->setChecked(m_options->wolSendBeforeMount()); 0622 } 0623 else 0624 { 0625 setDefaultValues(); 0626 } 0627 0628 // 0629 // Enable/disable features 0630 // 0631 wakeOnLanTab->setEnabled((m_options->type() == Host && Smb4KSettings::enableWakeOnLAN())); 0632 slotEnableWOLFeatures(macAddress->text()); 0633 slotCifsExtensionsSupport(cifsExtensionsSupport->isChecked()); 0634 } 0635 #elif defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD) 0636 // 0637 // FreeBSD and NetBSD 0638 // 0639 void Smb4KCustomOptionsDialog::setupView() 0640 { 0641 // 0642 // Tab widget with settings 0643 // 0644 QTabWidget *tabWidget = new QTabWidget(this); 0645 0646 QVBoxLayout *dialogLayout = qobject_cast<QVBoxLayout *>(layout()); 0647 dialogLayout->addWidget(tabWidget, 0); 0648 0649 // 0650 // Custom options for mounting 0651 // 0652 QWidget *mountingTab = new QWidget(tabWidget); 0653 0654 QVBoxLayout *mountingTabLayout = new QVBoxLayout(mountingTab); 0655 mountingTabLayout->setSpacing(5); 0656 0657 // 0658 // Common options 0659 // 0660 QGroupBox *commonBox = new QGroupBox(i18n("Common Options"), mountingTab); 0661 QGridLayout *commonBoxLayout = new QGridLayout(commonBox); 0662 commonBoxLayout->setSpacing(5); 0663 0664 QCheckBox *remountAlways = new QCheckBox(i18n("Always remount this share"), commonBox); 0665 remountAlways->setObjectName("RemountAlways"); 0666 remountAlways->setEnabled(m_options->type() == Share); 0667 connect(remountAlways, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0668 0669 commonBoxLayout->addWidget(remountAlways, 0, 0, 1, 2, 0); 0670 0671 // User Id 0672 QCheckBox *useUserId = new QCheckBox(Smb4KMountSettings::self()->useUserIdItem()->label(), commonBox); 0673 useUserId->setObjectName("UseUserId"); 0674 0675 KComboBox *userId = new KComboBox(commonBox); 0676 userId->setObjectName("UserId"); 0677 0678 QList<KUser> allUsers = KUser::allUsers(); 0679 0680 for (const KUser &u : allUsers) 0681 { 0682 userId->addItem(QString("%1 (%2)").arg(u.loginName()).arg(u.userId().nativeId()), QVariant::fromValue<K_GID>(u.groupId().nativeId())); 0683 } 0684 0685 connect(useUserId, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0686 connect(userId, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues())); 0687 0688 commonBoxLayout->addWidget(useUserId, 1, 0, 0); 0689 commonBoxLayout->addWidget(userId, 1, 1, 0); 0690 0691 // Group Id 0692 QCheckBox *useGroupId = new QCheckBox(Smb4KMountSettings::self()->useGroupIdItem()->label(), commonBox); 0693 useGroupId->setObjectName("UseGroupId"); 0694 0695 KComboBox *groupId = new KComboBox(commonBox); 0696 groupId->setObjectName("GroupId"); 0697 0698 QList<KUserGroup> allGroups = KUserGroup::allGroups(); 0699 0700 for (const KUserGroup &g : allGroups) 0701 { 0702 groupId->addItem(QString("%1 (%2)").arg(g.name()).arg(g.groupId().nativeId()), QVariant::fromValue<K_GID>(g.groupId().nativeId())); 0703 } 0704 0705 connect(useGroupId, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0706 connect(groupId, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues())); 0707 0708 commonBoxLayout->addWidget(useGroupId, 2, 0, 0); 0709 commonBoxLayout->addWidget(groupId, 2, 1, 0); 0710 0711 // File mode 0712 QCheckBox *useFileMode = new QCheckBox(Smb4KMountSettings::self()->useFileModeItem()->label(), commonBox); 0713 useFileMode->setObjectName("UseFileMode"); 0714 0715 KLineEdit *fileMode = new KLineEdit(commonBox); 0716 fileMode->setObjectName("FileMode"); 0717 fileMode->setClearButtonEnabled(true); 0718 fileMode->setAlignment(Qt::AlignRight); 0719 0720 connect(useFileMode, SIGNAL(toggled(bool)), this, SLOT(slotCheckValues())); 0721 connect(fileMode, SIGNAL(textEdited(QString)), this, SLOT(slotCheckValues())); 0722 0723 commonBoxLayout->addWidget(useFileMode, 3, 0, 0); 0724 commonBoxLayout->addWidget(fileMode, 3, 1, 0); 0725 0726 // Directory mode 0727 QCheckBox *useDirectoryMode = new QCheckBox(Smb4KMountSettings::self()->useDirectoryModeItem()->label(), commonBox); 0728 useDirectoryMode->setObjectName("UseDirectoryMode"); 0729 0730 KLineEdit *directoryMode = new KLineEdit(commonBox); 0731 directoryMode->setObjectName("DirectoryMode"); 0732 directoryMode->setClearButtonEnabled(true); 0733 directoryMode->setAlignment(Qt::AlignRight); 0734 0735 connect(useDirectoryMode, SIGNAL(toggled(bool)), this, SLOT(slotCheckValues())); 0736 connect(directoryMode, SIGNAL(textEdited(QString)), this, SLOT(slotCheckValues())); 0737 0738 commonBoxLayout->addWidget(useDirectoryMode, 4, 0, 0); 0739 commonBoxLayout->addWidget(directoryMode, 4, 1, 0); 0740 0741 mountingTabLayout->addWidget(commonBox, 0); 0742 mountingTabLayout->addStretch(100); 0743 0744 tabWidget->addTab(mountingTab, i18n("Mounting")); 0745 0746 // 0747 // Custom options for Samba 0748 // 0749 QWidget *sambaTab = new QWidget(tabWidget); 0750 QVBoxLayout *sambaTabLayout = new QVBoxLayout(sambaTab); 0751 sambaTabLayout->setSpacing(5); 0752 0753 // 0754 // Common Options 0755 // 0756 QGroupBox *commonSambaOptionsBox = new QGroupBox(i18n("Common Options"), sambaTab); 0757 QGridLayout *commonSambaOptionsBoxLayout = new QGridLayout(commonSambaOptionsBox); 0758 commonSambaOptionsBoxLayout->setSpacing(5); 0759 0760 // SMB port 0761 QCheckBox *useSmbPort = new QCheckBox(Smb4KSettings::self()->useRemoteSmbPortItem()->label(), commonSambaOptionsBox); 0762 useSmbPort->setObjectName("UseSmbPort"); 0763 0764 QSpinBox *smbPort = new QSpinBox(commonSambaOptionsBox); 0765 smbPort->setObjectName("SmbPort"); 0766 smbPort->setMinimum(Smb4KSettings::self()->remoteSmbPortItem()->minValue().toInt()); 0767 smbPort->setMaximum(Smb4KSettings::self()->remoteSmbPortItem()->maxValue().toInt()); 0768 // smbPort->setSliderEnabled(true); 0769 0770 connect(useSmbPort, SIGNAL(toggled(bool)), this, SLOT(slotCheckValues())); 0771 connect(smbPort, SIGNAL(valueChanged(int)), this, SLOT(slotCheckValues())); 0772 0773 commonSambaOptionsBoxLayout->addWidget(useSmbPort, 0, 0, 0); 0774 commonSambaOptionsBoxLayout->addWidget(smbPort, 0, 1, 0); 0775 0776 sambaTabLayout->addWidget(commonSambaOptionsBox, 0); 0777 0778 // 0779 // Authentication 0780 // 0781 QGroupBox *authenticationBox = new QGroupBox(i18n("Authentication"), sambaTab); 0782 QVBoxLayout *authenticationBoxLayout = new QVBoxLayout(authenticationBox); 0783 authenticationBoxLayout->setSpacing(5); 0784 0785 // Kerberos 0786 QCheckBox *useKerberos = new QCheckBox(Smb4KSettings::self()->useKerberosItem()->label(), authenticationBox); 0787 useKerberos->setObjectName("UseKerberos"); 0788 0789 connect(useKerberos, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0790 0791 authenticationBoxLayout->addWidget(useKerberos, 0); 0792 0793 sambaTabLayout->addWidget(authenticationBox, 0); 0794 sambaTabLayout->addStretch(100); 0795 0796 tabWidget->addTab(sambaTab, i18n("Samba")); 0797 0798 // 0799 // Custom options for Wake-On-LAN 0800 // 0801 // NOTE: If you change the texts here, also alter them in the respective 0802 // config page. 0803 // 0804 QWidget *wakeOnLanTab = new QWidget(tabWidget); 0805 QVBoxLayout *wakeOnLanTabLayout = new QVBoxLayout(wakeOnLanTab); 0806 wakeOnLanTabLayout->setSpacing(5); 0807 0808 // 0809 // MAC address 0810 // 0811 QGroupBox *macAddressBox = new QGroupBox(i18n("MAC Address"), wakeOnLanTab); 0812 QGridLayout *macAddressBoxLayout = new QGridLayout(macAddressBox); 0813 macAddressBoxLayout->setSpacing(5); 0814 0815 // MAC address 0816 QLabel *macAddressLabel = new QLabel(i18n("MAC Address:"), macAddressBox); 0817 KLineEdit *macAddress = new KLineEdit(macAddressBox); 0818 macAddress->setObjectName("MACAddress"); 0819 macAddress->setClearButtonEnabled(true); 0820 macAddress->setInputMask("HH:HH:HH:HH:HH:HH;_"); // MAC address, see QLineEdit doc 0821 macAddressLabel->setBuddy(macAddress); 0822 0823 connect(macAddress, SIGNAL(textEdited(QString)), SLOT(slotCheckValues())); 0824 connect(macAddress, SIGNAL(textEdited(QString)), SLOT(slotEnableWOLFeatures(QString))); 0825 0826 macAddressBoxLayout->addWidget(macAddressLabel, 0, 0, 0); 0827 macAddressBoxLayout->addWidget(macAddress, 0, 1, 0); 0828 0829 wakeOnLanTabLayout->addWidget(macAddressBox, 0); 0830 0831 // 0832 // Wake-On-LAN Actions 0833 // 0834 QGroupBox *wakeOnLANActionsBox = new QGroupBox(i18n("Actions"), wakeOnLanTab); 0835 QVBoxLayout *wakeOnLANActionsBoxLayout = new QVBoxLayout(wakeOnLANActionsBox); 0836 wakeOnLANActionsBoxLayout->setSpacing(5); 0837 0838 // Send magic package before network scan 0839 QCheckBox *sendPackageBeforeScan = new QCheckBox(i18n("Send magic package before scanning the network neighborhood"), wakeOnLANActionsBox); 0840 sendPackageBeforeScan->setObjectName("SendPackageBeforeScan"); 0841 0842 connect(sendPackageBeforeScan, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0843 0844 wakeOnLANActionsBoxLayout->addWidget(sendPackageBeforeScan, 0); 0845 0846 // Send magic package before mount 0847 QCheckBox *sendPackageBeforeMount = new QCheckBox(i18n("Send magic package before mounting a share"), wakeOnLanTab); 0848 sendPackageBeforeMount->setObjectName("SendPackageBeforeMount"); 0849 0850 connect(sendPackageBeforeMount, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0851 0852 wakeOnLANActionsBoxLayout->addWidget(sendPackageBeforeMount, 0); 0853 0854 wakeOnLanTabLayout->addWidget(wakeOnLANActionsBox, 0); 0855 wakeOnLanTabLayout->addStretch(100); 0856 0857 tabWidget->addTab(wakeOnLanTab, i18n("Wake-On-LAN")); 0858 0859 // 0860 // Load settings 0861 // 0862 if (m_options->hasOptions()) 0863 { 0864 if (m_options->type() == Share) 0865 { 0866 remountAlways->setChecked((m_options->remount() == Smb4KCustomOptions::RemountAlways)); 0867 } 0868 0869 // User information 0870 useUserId->setChecked(m_options->useUser()); 0871 userId->setCurrentText(QString("%1 (%2)").arg(m_options->user().loginName()).arg(m_options->user().userId().nativeId())); 0872 0873 // Group information 0874 useGroupId->setChecked(m_options->useGroup()); 0875 groupId->setCurrentText(QString("%1 (%2)").arg(m_options->group().name()).arg(m_options->group().groupId().nativeId())); 0876 0877 // File mode 0878 useFileMode->setChecked(m_options->useFileMode()); 0879 fileMode->setText(m_options->fileMode()); 0880 0881 // Directory mode 0882 useDirectoryMode->setChecked(m_options->useDirectoryMode()); 0883 directoryMode->setText(m_options->directoryMode()); 0884 0885 // Remote SMB port 0886 useSmbPort->setChecked(m_options->useSmbPort()); 0887 smbPort->setValue(m_options->smbPort()); 0888 0889 // Kerberos 0890 useKerberos->setChecked(m_options->useKerberos()); 0891 0892 // MAC address 0893 macAddress->setText(m_options->macAddress()); 0894 0895 // Send magic package before scan 0896 sendPackageBeforeScan->setChecked(m_options->wolSendBeforeNetworkScan()); 0897 0898 // Send magic package before mount 0899 sendPackageBeforeMount->setChecked(m_options->wolSendBeforeMount()); 0900 } 0901 else 0902 { 0903 setDefaultValues(); 0904 } 0905 0906 // 0907 // Enable/disable features 0908 // 0909 wakeOnLanTab->setEnabled((m_options->type() == Host && Smb4KSettings::enableWakeOnLAN())); 0910 slotEnableWOLFeatures(macAddress->text()); 0911 } 0912 #else 0913 // 0914 // Generic (without mount options) 0915 // 0916 void Smb4KCustomOptionsDialog::setupView() 0917 { 0918 // 0919 // Tab widget with settings 0920 // 0921 QTabWidget *tabWidget = new QTabWidget(this); 0922 0923 QVBoxLayout *dialogLayout = qobject_cast<QVBoxLayout *>(layout()); 0924 dialogLayout->addWidget(tabWidget, 0); 0925 0926 // 0927 // Custom options for Samba 0928 // 0929 QWidget *sambaTab = new QWidget(tabWidget); 0930 QVBoxLayout *sambaTabLayout = new QVBoxLayout(sambaTab); 0931 sambaTabLayout->setSpacing(5); 0932 0933 // 0934 // Common Options 0935 // 0936 QGroupBox *commonSambaOptionsBox = new QGroupBox(i18n("Common Options"), sambaTab); 0937 QGridLayout *commonSambaOptionsBoxLayout = new QGridLayout(commonSambaOptionsBox); 0938 commonSambaOptionsBoxLayout->setSpacing(5); 0939 0940 // SMB port 0941 QCheckBox *useSmbPort = new QCheckBox(Smb4KSettings::self()->useRemoteSmbPortItem()->label(), commonSambaOptionsBox); 0942 useSmbPort->setObjectName("UseSmbPort"); 0943 0944 QSpinBox *smbPort = new QSpinBox(commonSambaOptionsBox); 0945 smbPort->setObjectName("SmbPort"); 0946 smbPort->setMinimum(Smb4KSettings::self()->remoteSmbPortItem()->minValue().toInt()); 0947 smbPort->setMaximum(Smb4KSettings::self()->remoteSmbPortItem()->maxValue().toInt()); 0948 // smbPort->setSliderEnabled(true); 0949 0950 connect(useSmbPort, SIGNAL(toggled(bool)), this, SLOT(slotCheckValues())); 0951 connect(smbPort, SIGNAL(valueChanged(int)), this, SLOT(slotCheckValues())); 0952 0953 commonSambaOptionsBoxLayout->addWidget(useSmbPort, 0, 0, 0); 0954 commonSambaOptionsBoxLayout->addWidget(smbPort, 0, 1, 0); 0955 0956 sambaTabLayout->addWidget(commonSambaOptionsBox, 0); 0957 0958 // 0959 // Authentication 0960 // 0961 QGroupBox *authenticationBox = new QGroupBox(i18n("Authentication"), sambaTab); 0962 QVBoxLayout *authenticationBoxLayout = new QVBoxLayout(authenticationBox); 0963 authenticationBoxLayout->setSpacing(5); 0964 0965 // Kerberos 0966 QCheckBox *useKerberos = new QCheckBox(Smb4KSettings::self()->useKerberosItem()->label(), authenticationBox); 0967 useKerberos->setObjectName("UseKerberos"); 0968 0969 connect(useKerberos, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 0970 0971 authenticationBoxLayout->addWidget(useKerberos, 0); 0972 0973 sambaTabLayout->addWidget(authenticationBox, 0); 0974 sambaTabLayout->addStretch(100); 0975 0976 tabWidget->addTab(sambaTab, i18n("Samba")); 0977 0978 // 0979 // Custom options for Wake-On-LAN 0980 // 0981 // NOTE: If you change the texts here, also alter them in the respective 0982 // config page. 0983 // 0984 QWidget *wakeOnLanTab = new QWidget(tabWidget); 0985 QVBoxLayout *wakeOnLanTabLayout = new QVBoxLayout(wakeOnLanTab); 0986 wakeOnLanTabLayout->setSpacing(5); 0987 0988 // 0989 // MAC address 0990 // 0991 QGroupBox *macAddressBox = new QGroupBox(i18n("MAC Address"), wakeOnLanTab); 0992 QGridLayout *macAddressBoxLayout = new QGridLayout(macAddressBox); 0993 macAddressBoxLayout->setSpacing(5); 0994 0995 // MAC address 0996 QLabel *macAddressLabel = new QLabel(i18n("MAC Address:"), macAddressBox); 0997 KLineEdit *macAddress = new KLineEdit(macAddressBox); 0998 macAddress->setObjectName("MACAddress"); 0999 macAddress->setClearButtonEnabled(true); 1000 macAddress->setInputMask("HH:HH:HH:HH:HH:HH;_"); // MAC address, see QLineEdit doc 1001 macAddressLabel->setBuddy(macAddress); 1002 1003 connect(macAddress, SIGNAL(textEdited(QString)), SLOT(slotCheckValues())); 1004 connect(macAddress, SIGNAL(textEdited(QString)), SLOT(slotEnableWOLFeatures(QString))); 1005 1006 macAddressBoxLayout->addWidget(macAddressLabel, 0, 0, 0); 1007 macAddressBoxLayout->addWidget(macAddress, 0, 1, 0); 1008 1009 wakeOnLanTabLayout->addWidget(macAddressBox, 0); 1010 1011 // 1012 // Wake-On-LAN Actions 1013 // 1014 QGroupBox *wakeOnLANActionsBox = new QGroupBox(i18n("Actions"), wakeOnLanTab); 1015 QVBoxLayout *wakeOnLANActionsBoxLayout = new QVBoxLayout(wakeOnLANActionsBox); 1016 wakeOnLANActionsBoxLayout->setSpacing(5); 1017 1018 // Send magic package before network scan 1019 QCheckBox *sendPackageBeforeScan = new QCheckBox(i18n("Send magic package before scanning the network neighborhood"), wakeOnLANActionsBox); 1020 sendPackageBeforeScan->setObjectName("SendPackageBeforeScan"); 1021 1022 connect(sendPackageBeforeScan, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 1023 1024 wakeOnLANActionsBoxLayout->addWidget(sendPackageBeforeScan, 0); 1025 1026 // Send magic package before mount 1027 QCheckBox *sendPackageBeforeMount = new QCheckBox(i18n("Send magic package before mounting a share"), wakeOnLanTab); 1028 sendPackageBeforeMount->setObjectName("SendPackageBeforeMount"); 1029 1030 connect(sendPackageBeforeMount, SIGNAL(toggled(bool)), SLOT(slotCheckValues())); 1031 1032 wakeOnLANActionsBoxLayout->addWidget(sendPackageBeforeMount, 0); 1033 1034 wakeOnLanTabLayout->addWidget(wakeOnLANActionsBox, 0); 1035 wakeOnLanTabLayout->addStretch(100); 1036 1037 tabWidget->addTab(wakeOnLanTab, i18n("Wake-On-LAN")); 1038 1039 // 1040 // Load settings 1041 // 1042 if (m_options->hasOptions()) 1043 { 1044 // Remote SMB port 1045 useSmbPort->setChecked(m_options->useSmbPort()); 1046 smbPort->setValue(m_options->smbPort()); 1047 1048 // Kerberos 1049 useKerberos->setChecked(m_options->useKerberos()); 1050 1051 // MAC address 1052 macAddress->setText(m_options->macAddress()); 1053 1054 // Send magic package before scan 1055 sendPackageBeforeScan->setChecked(m_options->wolSendBeforeNetworkScan()); 1056 1057 // Send magic package before mount 1058 sendPackageBeforeMount->setChecked(m_options->wolSendBeforeMount()); 1059 } 1060 else 1061 { 1062 setDefaultValues(); 1063 } 1064 1065 // 1066 // Enable/disable features 1067 // 1068 wakeOnLanTab->setEnabled((m_options->type() == Host && Smb4KSettings::enableWakeOnLAN())); 1069 slotEnableWOLFeatures(macAddress->text()); 1070 1071 1072 } 1073 #endif 1074 1075 1076 bool Smb4KCustomOptionsDialog::checkDefaultValues() 1077 { 1078 // 1079 // Always remount the share 1080 // 1081 if (m_options->type() == Share) 1082 { 1083 QCheckBox *remountAlways = findChild<QCheckBox *>("RemountAlways"); 1084 1085 if (remountAlways) 1086 { 1087 if (remountAlways->isChecked()) 1088 { 1089 return false; 1090 } 1091 } 1092 } 1093 1094 // 1095 // User Id 1096 // 1097 QCheckBox *useUserId = findChild<QCheckBox *>("UseUserId"); 1098 1099 if (useUserId) 1100 { 1101 if (useUserId->isChecked() != Smb4KMountSettings::useUserId()) 1102 { 1103 return false; 1104 } 1105 } 1106 1107 KComboBox *userId = findChild<KComboBox *>("UserId"); 1108 1109 if (userId) 1110 { 1111 K_UID uid = (K_UID)userId->itemData(userId->currentIndex()).toInt(); 1112 1113 if (uid != (K_UID)Smb4KMountSettings::userId().toInt()) 1114 { 1115 return false; 1116 } 1117 } 1118 1119 // 1120 // Group Id 1121 // 1122 QCheckBox *useGroupId = findChild<QCheckBox *>("UseGroupId"); 1123 1124 if (useGroupId) 1125 { 1126 if (useGroupId->isChecked() != Smb4KMountSettings::useGroupId()) 1127 { 1128 return false; 1129 } 1130 } 1131 1132 KComboBox *groupId = findChild<KComboBox *>("GroupId"); 1133 1134 if (groupId) 1135 { 1136 K_GID gid = (K_GID)groupId->itemData(groupId->currentIndex()).toInt(); 1137 1138 if (gid != (K_GID)Smb4KMountSettings::groupId().toInt()) 1139 { 1140 return false; 1141 } 1142 } 1143 1144 // 1145 // File mode 1146 // 1147 QCheckBox *useFileMode = findChild<QCheckBox *>("UseFileMode"); 1148 1149 if (useFileMode) 1150 { 1151 if (useFileMode->isChecked() != Smb4KMountSettings::useFileMode()) 1152 { 1153 return false; 1154 } 1155 } 1156 1157 KLineEdit *fileMode = findChild<KLineEdit *>("FileMode"); 1158 1159 if (fileMode) 1160 { 1161 if (fileMode->text() != Smb4KMountSettings::fileMode()) 1162 { 1163 return false; 1164 } 1165 } 1166 1167 // 1168 // Directory mode 1169 // 1170 QCheckBox *useDirectoryMode = findChild<QCheckBox *>("UseDirectoryMode"); 1171 1172 if (useDirectoryMode) 1173 { 1174 if (useDirectoryMode->isChecked() != Smb4KMountSettings::useDirectoryMode()) 1175 { 1176 return false; 1177 } 1178 } 1179 1180 KLineEdit *directoryMode = findChild<KLineEdit *>("DirectoryMode"); 1181 1182 if (directoryMode) 1183 { 1184 if (directoryMode->text() != Smb4KMountSettings::directoryMode()) 1185 { 1186 return false; 1187 } 1188 } 1189 1190 #if defined(Q_OS_LINUX) 1191 // 1192 // CIFS Unix extensions support 1193 // 1194 QCheckBox *cifsExtensionsSupport = findChild<QCheckBox *>("CifsExtensionsSupport"); 1195 1196 if (cifsExtensionsSupport) 1197 { 1198 if (cifsExtensionsSupport->isChecked() != Smb4KMountSettings::cifsUnixExtensionsSupport()) 1199 { 1200 return false; 1201 } 1202 } 1203 1204 // 1205 // Filesystem port 1206 // 1207 QCheckBox *useFilesystemPort = findChild<QCheckBox *>("UseFilesystemPort"); 1208 1209 if (useFilesystemPort) 1210 { 1211 if (useFilesystemPort->isChecked() != Smb4KMountSettings::useRemoteFileSystemPort()) 1212 { 1213 return false; 1214 } 1215 } 1216 1217 QSpinBox *filesystemPort = findChild<QSpinBox *>("FileSystemPort"); 1218 1219 if (filesystemPort) 1220 { 1221 if (filesystemPort->value() != Smb4KMountSettings::remoteFileSystemPort()) 1222 { 1223 return false; 1224 } 1225 } 1226 1227 // 1228 // Write access 1229 // 1230 QCheckBox *useWriteAccess = findChild<QCheckBox *>("UseWriteAccess"); 1231 1232 if (useWriteAccess) 1233 { 1234 if (useWriteAccess->isChecked() != Smb4KMountSettings::useWriteAccess()) 1235 { 1236 return false; 1237 } 1238 } 1239 1240 KComboBox *writeAccess = findChild<KComboBox *>("WriteAccess"); 1241 1242 if (writeAccess) 1243 { 1244 if (writeAccess->currentText() != Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::self()->writeAccess()).label) 1245 { 1246 return false; 1247 } 1248 } 1249 1250 // 1251 // Security mode 1252 // 1253 QCheckBox *useSecurityMode = findChild<QCheckBox *>("UseSecurityMode"); 1254 1255 if (useSecurityMode) 1256 { 1257 if (useSecurityMode->isChecked() != Smb4KMountSettings::useSecurityMode()) 1258 { 1259 return false; 1260 } 1261 } 1262 1263 KComboBox *securityMode = findChild<KComboBox *>("SecurityMode"); 1264 1265 if (securityMode) 1266 { 1267 if (securityMode->currentText() != Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::self()->securityMode()).label) 1268 { 1269 return false; 1270 } 1271 } 1272 #endif 1273 1274 // 1275 // SMB port 1276 // 1277 QCheckBox *useSmbPort = findChild<QCheckBox *>("UseSmbPort"); 1278 1279 if (useSmbPort) 1280 { 1281 if (useSmbPort->isChecked() != Smb4KSettings::useRemoteSmbPort()) 1282 { 1283 return false; 1284 } 1285 } 1286 1287 QSpinBox *smbPort = findChild<QSpinBox *>("SmbPort"); 1288 1289 if (smbPort) 1290 { 1291 if (smbPort->value() != Smb4KSettings::remoteSmbPort()) 1292 { 1293 return false; 1294 } 1295 } 1296 1297 // 1298 // Kerberos 1299 // 1300 QCheckBox *useKerberos = findChild<QCheckBox *>("UseKerberos"); 1301 1302 if (useKerberos) 1303 { 1304 if (useKerberos->isChecked() != Smb4KSettings::useKerberos()) 1305 { 1306 return false; 1307 } 1308 } 1309 1310 // 1311 // MAC address & Wake-On-LAN features 1312 // 1313 if (m_options->type() == Host && Smb4KSettings::enableWakeOnLAN()) 1314 { 1315 KLineEdit *macAddress = findChild<KLineEdit *>("MACAddress"); 1316 1317 if (macAddress) 1318 { 1319 QRegExp exp("..\\:..\\:..\\:..\\:..\\:.."); 1320 1321 if (exp.exactMatch(macAddress->text())) 1322 { 1323 return false; 1324 } 1325 } 1326 1327 QCheckBox *sendPackageBeforeScan = findChild<QCheckBox *>("SendPackageBeforeScan"); 1328 1329 if (sendPackageBeforeScan) 1330 { 1331 if (sendPackageBeforeScan->isChecked()) 1332 { 1333 return false; 1334 } 1335 } 1336 1337 QCheckBox *sendPackageBeforeMount = findChild<QCheckBox *>("SendPackageBeforeMount"); 1338 1339 if (sendPackageBeforeMount) 1340 { 1341 if (sendPackageBeforeMount->isChecked()) 1342 { 1343 return false; 1344 } 1345 } 1346 } 1347 1348 return true; 1349 } 1350 1351 1352 void Smb4KCustomOptionsDialog::setDefaultValues() 1353 { 1354 // 1355 // Always remount the share 1356 // 1357 if (m_options->type() == Share) 1358 { 1359 QCheckBox *remountAlways = findChild<QCheckBox *>("RemountAlways"); 1360 1361 if (remountAlways) 1362 { 1363 remountAlways->setChecked(false); 1364 } 1365 } 1366 1367 // 1368 // User Id 1369 // 1370 QCheckBox *useUserId = findChild<QCheckBox *>("UseUserId"); 1371 1372 if (useUserId) 1373 { 1374 useUserId->setChecked(Smb4KMountSettings::useUserId()); 1375 } 1376 1377 KComboBox *userId = findChild<KComboBox *>("UserId"); 1378 1379 if (userId) 1380 { 1381 KUser user((K_UID)Smb4KMountSettings::userId().toInt()); 1382 userId->setCurrentText(QString("%1 (%2)").arg(user.loginName()).arg(user.userId().nativeId())); 1383 } 1384 1385 // 1386 // Group Id 1387 // 1388 QCheckBox *useGroupId = findChild<QCheckBox *>("UseGroupId"); 1389 1390 if (useGroupId) 1391 { 1392 useGroupId->setChecked(Smb4KMountSettings::useGroupId()); 1393 } 1394 1395 KComboBox *groupId = findChild<KComboBox *>("GroupId"); 1396 1397 if (groupId) 1398 { 1399 KUserGroup group((K_GID)Smb4KMountSettings::groupId().toInt()); 1400 groupId->setCurrentText(QString("%1 (%2)").arg(group.name()).arg(group.groupId().nativeId()));; 1401 } 1402 1403 // 1404 // File mask 1405 // 1406 QCheckBox *useFileMode = findChild<QCheckBox *>("UseFileMode"); 1407 1408 if (useFileMode) 1409 { 1410 useFileMode->setChecked(Smb4KMountSettings::useFileMode()); 1411 } 1412 1413 KLineEdit *fileMode = findChild<KLineEdit *>("FileMode"); 1414 1415 if (fileMode) 1416 { 1417 fileMode->setText(Smb4KMountSettings::fileMode()); 1418 } 1419 1420 // 1421 // Directory mode 1422 // 1423 QCheckBox *useDirectoryMode = findChild<QCheckBox *>("UseDirectoryMode"); 1424 1425 if (useDirectoryMode) 1426 { 1427 useDirectoryMode->setChecked(Smb4KMountSettings::useDirectoryMode()); 1428 } 1429 1430 KLineEdit *directoryMode = findChild<KLineEdit *>("DirectoryMode"); 1431 1432 if (directoryMode) 1433 { 1434 directoryMode->setText(Smb4KMountSettings::directoryMode()); 1435 } 1436 1437 #if defined(Q_OS_LINUX) 1438 // 1439 // CIFS Unix extensions support 1440 // 1441 QCheckBox *cifsExtensionsSupport = findChild<QCheckBox *>("CifsExtensionsSupport"); 1442 1443 if (cifsExtensionsSupport) 1444 { 1445 cifsExtensionsSupport->setChecked(Smb4KMountSettings::cifsUnixExtensionsSupport()); 1446 } 1447 1448 // 1449 // Filesystem port 1450 // 1451 QCheckBox *useFilesystemPort = findChild<QCheckBox *>("UseFilesystemPort"); 1452 1453 if (useFilesystemPort) 1454 { 1455 useFilesystemPort->setChecked(Smb4KMountSettings::useRemoteFileSystemPort()); 1456 } 1457 1458 QSpinBox *filesystemPort = findChild<QSpinBox *>("FileSystemPort"); 1459 1460 if (filesystemPort) 1461 { 1462 filesystemPort->setValue(Smb4KMountSettings::remoteFileSystemPort()); 1463 } 1464 1465 // 1466 // Write access 1467 // 1468 QCheckBox *useWriteAccess = findChild<QCheckBox *>("UseWriteAccess"); 1469 1470 if (useWriteAccess) 1471 { 1472 useWriteAccess->setChecked(Smb4KMountSettings::useWriteAccess()); 1473 } 1474 1475 KComboBox *writeAccess = findChild<KComboBox *>("WriteAccess"); 1476 1477 if (writeAccess) 1478 { 1479 QString readWriteText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadWrite).label; 1480 QString readOnlyText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadOnly).label; 1481 1482 switch (Smb4KMountSettings::writeAccess()) 1483 { 1484 case Smb4KMountSettings::EnumWriteAccess::ReadWrite: 1485 { 1486 writeAccess->setCurrentText(readWriteText); 1487 break; 1488 } 1489 case Smb4KMountSettings::EnumWriteAccess::ReadOnly: 1490 { 1491 writeAccess->setCurrentText(readOnlyText); 1492 break; 1493 } 1494 default: 1495 { 1496 break; 1497 } 1498 } 1499 } 1500 1501 // 1502 // Security mode 1503 // 1504 QCheckBox *useSecurityMode = findChild<QCheckBox *>("UseSecurityMode"); 1505 1506 if (useSecurityMode) 1507 { 1508 useSecurityMode->setChecked(Smb4KMountSettings::useSecurityMode()); 1509 } 1510 1511 KComboBox *securityMode = findChild<KComboBox *>("SecurityMode"); 1512 1513 if (securityMode) 1514 { 1515 QString noneText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::None).label; 1516 QString krb5Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5).label; 1517 QString krb5iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5i).label; 1518 QString ntlmText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlm).label; 1519 QString ntlmiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmi).label; 1520 QString ntlmv2Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2).label; 1521 QString ntlmv2iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2i).label; 1522 QString ntlmsspText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmssp).label; 1523 QString ntlmsspiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmsspi).label; 1524 1525 switch (Smb4KMountSettings::securityMode()) 1526 { 1527 case Smb4KMountSettings::EnumSecurityMode::None: 1528 { 1529 securityMode->setCurrentText(noneText); 1530 break; 1531 } 1532 case Smb4KMountSettings::EnumSecurityMode::Krb5: 1533 { 1534 securityMode->setCurrentText(krb5Text); 1535 break; 1536 } 1537 case Smb4KMountSettings::EnumSecurityMode::Krb5i: 1538 { 1539 securityMode->setCurrentText(krb5iText); 1540 break; 1541 } 1542 case Smb4KMountSettings::EnumSecurityMode::Ntlm: 1543 { 1544 securityMode->setCurrentText(ntlmText); 1545 break; 1546 } 1547 case Smb4KMountSettings::EnumSecurityMode::Ntlmi: 1548 { 1549 securityMode->setCurrentText(ntlmiText); 1550 break; 1551 } 1552 case Smb4KMountSettings::EnumSecurityMode::Ntlmv2: 1553 { 1554 securityMode->setCurrentText(ntlmv2Text); 1555 break; 1556 } 1557 case Smb4KMountSettings::EnumSecurityMode::Ntlmv2i: 1558 { 1559 securityMode->setCurrentText(ntlmv2iText); 1560 break; 1561 } 1562 case Smb4KMountSettings::EnumSecurityMode::Ntlmssp: 1563 { 1564 securityMode->setCurrentText(ntlmsspText); 1565 break; 1566 } 1567 case Smb4KMountSettings::EnumSecurityMode::Ntlmsspi: 1568 { 1569 securityMode->setCurrentText(ntlmsspiText); 1570 break; 1571 } 1572 default: 1573 { 1574 break; 1575 } 1576 } 1577 } 1578 #endif 1579 1580 // 1581 // SMB port 1582 // 1583 QCheckBox *useSmbPort = findChild<QCheckBox *>("UseSmbPort"); 1584 1585 if (useSmbPort) 1586 { 1587 useSmbPort->setChecked(Smb4KSettings::useRemoteSmbPort()); 1588 } 1589 1590 QSpinBox *smbPort = findChild<QSpinBox *>("SmbPort"); 1591 1592 if (smbPort) 1593 { 1594 smbPort->setValue(Smb4KSettings::remoteSmbPort()); 1595 } 1596 1597 // 1598 // Kerberos 1599 // 1600 QCheckBox *useKerberos = findChild<QCheckBox *>("UseKerberos"); 1601 1602 if (useKerberos) 1603 { 1604 useKerberos->setChecked(Smb4KSettings::useKerberos()); 1605 } 1606 1607 // 1608 // MAC address & Wake-On-LAN features 1609 // 1610 if (m_options->type() == Host) 1611 { 1612 KLineEdit *macAddress = findChild<KLineEdit *>("MACAddress"); 1613 1614 if (macAddress) 1615 { 1616 macAddress->clear(); 1617 macAddress->setInputMask("HH:HH:HH:HH:HH:HH;_"); 1618 } 1619 1620 QCheckBox *sendPackageBeforeScan = findChild<QCheckBox *>("SendPackageBeforeScan"); 1621 1622 if (sendPackageBeforeScan) 1623 { 1624 sendPackageBeforeScan->setChecked(false); 1625 } 1626 1627 QCheckBox *sendPackageBeforeMount = findChild<QCheckBox *>("SendPackageBeforeMount"); 1628 1629 if (sendPackageBeforeMount) 1630 { 1631 sendPackageBeforeMount->setChecked(false); 1632 } 1633 } 1634 } 1635 1636 1637 void Smb4KCustomOptionsDialog::saveValues() 1638 { 1639 // 1640 // Always remount the share 1641 // 1642 if (m_options->type() == Share) 1643 { 1644 QCheckBox *remountAlways = findChild<QCheckBox *>("RemountAlways"); 1645 1646 if (remountAlways) 1647 { 1648 if (remountAlways->isChecked()) 1649 { 1650 m_options->setRemount(Smb4KCustomOptions::RemountAlways); 1651 } 1652 else 1653 { 1654 m_options->setRemount(Smb4KCustomOptions::UndefinedRemount); 1655 } 1656 } 1657 } 1658 1659 // 1660 // User Id 1661 // 1662 QCheckBox *useUserId = findChild<QCheckBox *>("UseUserId"); 1663 1664 if (useUserId) 1665 { 1666 m_options->setUseUser(useUserId->isChecked()); 1667 } 1668 1669 KComboBox *userId = findChild<KComboBox *>("UserId"); 1670 1671 if (userId) 1672 { 1673 m_options->setUser(KUser(userId->itemData(userId->currentIndex()).toInt())); 1674 } 1675 1676 // 1677 // Group Id 1678 // 1679 QCheckBox *useGroupId = findChild<QCheckBox *>("UseGroupId"); 1680 1681 if (useGroupId) 1682 { 1683 m_options->setUseGroup(useGroupId->isChecked()); 1684 } 1685 1686 KComboBox *groupId = findChild<KComboBox *>("GroupId"); 1687 1688 if (groupId) 1689 { 1690 m_options->setGroup(KUserGroup(groupId->itemData(groupId->currentIndex()).toInt())); 1691 } 1692 1693 // 1694 // File mode 1695 // 1696 QCheckBox *useFileMode = findChild<QCheckBox *>("UseFileMode"); 1697 1698 if (useFileMode) 1699 { 1700 m_options->setUseFileMode(useFileMode->isChecked()); 1701 } 1702 1703 KLineEdit *fileMode = findChild<KLineEdit *>("FileMode"); 1704 1705 if (fileMode) 1706 { 1707 m_options->setFileMode(fileMode->text()); 1708 } 1709 1710 // 1711 // Directory mode 1712 // 1713 QCheckBox *useDirectoryMode = findChild<QCheckBox *>("UseDirectoryMode"); 1714 1715 if (useDirectoryMode) 1716 { 1717 m_options->setUseDirectoryMode(useDirectoryMode->isChecked()); 1718 } 1719 1720 KLineEdit *directoryMode = findChild<KLineEdit *>("DirectoryMode"); 1721 1722 if (directoryMode) 1723 { 1724 m_options->setDirectoryMode(directoryMode->text()); 1725 } 1726 1727 #if defined(Q_OS_LINUX) 1728 // 1729 // CIFS Unix extensions support 1730 // 1731 QCheckBox *cifsExtensionsSupport = findChild<QCheckBox *>("CifsExtensionsSupport"); 1732 1733 if (cifsExtensionsSupport) 1734 { 1735 m_options->setCifsUnixExtensionsSupport(cifsExtensionsSupport->isChecked()); 1736 } 1737 1738 // 1739 // Filesystem port 1740 // 1741 QCheckBox *useFilesystemPort = findChild<QCheckBox *>("UseFilesystemPort"); 1742 1743 if (useFilesystemPort) 1744 { 1745 m_options->setUseFileSystemPort(useFilesystemPort->isChecked()); 1746 } 1747 1748 QSpinBox *filesystemPort = findChild<QSpinBox *>("FileSystemPort"); 1749 1750 if (filesystemPort) 1751 { 1752 m_options->setFileSystemPort(filesystemPort->value()); 1753 } 1754 1755 // 1756 // Write access 1757 // 1758 QCheckBox *useWriteAccess = findChild<QCheckBox *>("UseWriteAccess"); 1759 1760 if (useWriteAccess) 1761 { 1762 m_options->setUseWriteAccess(useWriteAccess->isChecked()); 1763 } 1764 1765 KComboBox *writeAccess = findChild<KComboBox *>("WriteAccess"); 1766 1767 if (writeAccess) 1768 { 1769 QString readWriteText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadWrite).label; 1770 QString readOnlyText = Smb4KMountSettings::self()->writeAccessItem()->choices().value(Smb4KMountSettings::EnumWriteAccess::ReadOnly).label; 1771 1772 if (writeAccess->currentText() == readWriteText) 1773 { 1774 m_options->setWriteAccess(Smb4KMountSettings::EnumWriteAccess::ReadWrite); 1775 } 1776 else if (writeAccess->currentText() == readOnlyText) 1777 { 1778 m_options->setWriteAccess(Smb4KMountSettings::EnumWriteAccess::ReadOnly); 1779 } 1780 } 1781 1782 // 1783 // Security mode 1784 // 1785 QCheckBox *useSecurityMode = findChild<QCheckBox *>("UseSecurityMode"); 1786 1787 if (useSecurityMode) 1788 { 1789 m_options->setUseSecurityMode(useSecurityMode->isChecked()); 1790 } 1791 1792 KComboBox *securityMode = findChild<KComboBox *>("SecurityMode"); 1793 1794 if (securityMode) 1795 { 1796 QString noneText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::None).label; 1797 QString krb5Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5).label; 1798 QString krb5iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Krb5i).label; 1799 QString ntlmText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlm).label; 1800 QString ntlmiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmi).label; 1801 QString ntlmv2Text = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2).label; 1802 QString ntlmv2iText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmv2i).label; 1803 QString ntlmsspText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmssp).label; 1804 QString ntlmsspiText = Smb4KMountSettings::self()->securityModeItem()->choices().value(Smb4KMountSettings::EnumSecurityMode::Ntlmsspi).label; 1805 1806 if (securityMode->currentText() == noneText) 1807 { 1808 m_options->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::None); 1809 } 1810 else if (securityMode->currentText() == krb5Text) 1811 { 1812 m_options->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Krb5); 1813 } 1814 else if (securityMode->currentText() == krb5iText) 1815 { 1816 m_options->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Krb5i); 1817 } 1818 else if (securityMode->currentText() == ntlmText) 1819 { 1820 m_options->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlm); 1821 } 1822 else if (securityMode->currentText() == ntlmiText) 1823 { 1824 m_options->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmi); 1825 } 1826 else if (securityMode->currentText() == ntlmv2Text) 1827 { 1828 m_options->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmv2); 1829 } 1830 else if (securityMode->currentText() == ntlmv2iText) 1831 { 1832 m_options->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmv2i); 1833 } 1834 else if (securityMode->currentText() == ntlmsspText) 1835 { 1836 m_options->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmssp); 1837 } 1838 else if (securityMode->currentText() == ntlmsspiText) 1839 { 1840 m_options->setSecurityMode(Smb4KMountSettings::EnumSecurityMode::Ntlmsspi); 1841 } 1842 } 1843 #endif 1844 1845 // 1846 // SMB port 1847 // 1848 QCheckBox *useSmbPort = findChild<QCheckBox *>("UseSmbPort"); 1849 1850 if (useSmbPort) 1851 { 1852 m_options->setUseSmbPort(useSmbPort->isChecked()); 1853 } 1854 1855 QSpinBox *smbPort = findChild<QSpinBox *>("SmbPort"); 1856 1857 if (smbPort) 1858 { 1859 m_options->setSmbPort(smbPort->value()); 1860 } 1861 1862 // Kerberos 1863 QCheckBox *useKerberos = findChild<QCheckBox *>("UseKerberos"); 1864 1865 if (useKerberos) 1866 { 1867 m_options->setUseKerberos(useKerberos->isChecked()); 1868 } 1869 1870 // MAC address & Wake-On-LAN features 1871 if (m_options->type() == Host) 1872 { 1873 KLineEdit *macAddress = findChild<KLineEdit *>("MACAddress"); 1874 1875 if (macAddress) 1876 { 1877 m_options->setMACAddress(macAddress->text()); 1878 } 1879 1880 QCheckBox *sendPackageBeforeScan = findChild<QCheckBox *>("SendPackageBeforeScan"); 1881 1882 if (sendPackageBeforeScan) 1883 { 1884 m_options->setWOLSendBeforeNetworkScan(sendPackageBeforeScan->isChecked()); 1885 } 1886 1887 QCheckBox *sendPackageBeforeMount = findChild<QCheckBox *>("SendPackageBeforeMount"); 1888 1889 if (sendPackageBeforeMount) 1890 { 1891 m_options->setWOLSendBeforeMount(sendPackageBeforeMount->isChecked()); 1892 } 1893 } 1894 1895 KConfigGroup group(Smb4KSettings::self()->config(), "CustomOptionsDialog"); 1896 KWindowConfig::saveWindowSize(windowHandle(), group); 1897 } 1898 1899 1900 void Smb4KCustomOptionsDialog::slotSetDefaultValues() 1901 { 1902 setDefaultValues(); 1903 } 1904 1905 1906 void Smb4KCustomOptionsDialog::slotCheckValues() 1907 { 1908 QDialogButtonBox *buttonBox = findChild<QDialogButtonBox *>(); 1909 1910 if (buttonBox) 1911 { 1912 for (QAbstractButton *b : buttonBox->buttons()) 1913 { 1914 if (buttonBox->buttonRole(b) == QDialogButtonBox::ResetRole) 1915 { 1916 b->setEnabled(!checkDefaultValues()); 1917 break; 1918 } 1919 } 1920 } 1921 } 1922 1923 1924 void Smb4KCustomOptionsDialog::slotOKClicked() 1925 { 1926 saveValues(); 1927 accept(); 1928 } 1929 1930 1931 void Smb4KCustomOptionsDialog::slotEnableWOLFeatures(const QString &mac) 1932 { 1933 QRegExp exp("..\\:..\\:..\\:..\\:..\\:.."); 1934 1935 QCheckBox *sendPackageBeforeScan = findChild<QCheckBox *>("SendPackageBeforeScan"); 1936 1937 if (sendPackageBeforeScan) 1938 { 1939 sendPackageBeforeScan->setEnabled(m_options->type() == Host && exp.exactMatch(mac)); 1940 } 1941 1942 QCheckBox *sendPackageBeforeMount = findChild<QCheckBox *>("SendPackageBeforeMount"); 1943 1944 if (sendPackageBeforeMount) 1945 { 1946 sendPackageBeforeMount->setEnabled(m_options->type() == Host && exp.exactMatch(mac)); 1947 } 1948 } 1949 1950 1951 void Smb4KCustomOptionsDialog::slotCifsExtensionsSupport(bool support) 1952 { 1953 #if defined(Q_OS_LINUX) 1954 // 1955 // User id 1956 // 1957 QCheckBox *useUserId = findChild<QCheckBox *>("UseUserId"); 1958 1959 if (useUserId) 1960 { 1961 useUserId->setEnabled(!support); 1962 } 1963 1964 KComboBox *userId = findChild<KComboBox *>("UserId"); 1965 1966 if (userId) 1967 { 1968 userId->setEnabled(!support); 1969 } 1970 1971 // 1972 // Group id 1973 // 1974 QCheckBox *useGroupId = findChild<QCheckBox *>("UseGroupId"); 1975 1976 if (useGroupId) 1977 { 1978 useGroupId->setEnabled(!support); 1979 } 1980 1981 KComboBox *groupId = findChild<KComboBox *>("GroupId"); 1982 1983 if (groupId) 1984 { 1985 groupId->setEnabled(!support); 1986 } 1987 1988 // 1989 // File mode 1990 // 1991 QCheckBox *useFileMode = findChild<QCheckBox *>("UseFileMode"); 1992 1993 if (useFileMode) 1994 { 1995 useFileMode->setEnabled(!support); 1996 } 1997 1998 KLineEdit *fileMode = findChild<KLineEdit *>("FileMode"); 1999 2000 if (fileMode) 2001 { 2002 fileMode->setEnabled(!support); 2003 } 2004 2005 // 2006 // Directory mode 2007 // 2008 QCheckBox *useDirectoryMode = findChild<QCheckBox *>("UseDirectoryMode"); 2009 2010 if (useDirectoryMode) 2011 { 2012 useDirectoryMode->setEnabled(!support); 2013 } 2014 2015 KLineEdit *directoryMode = findChild<KLineEdit *>("DirectoryMode"); 2016 2017 if (directoryMode) 2018 { 2019 directoryMode->setEnabled(!support); 2020 } 2021 #else 2022 Q_UNUSED(support); 2023 #endif 2024 } 2025 2026