File indexing completed on 2024-04-21 15:42:54

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