~ubuntu-branches/ubuntu/vivid/smb4k/vivid

« back to all changes in this revision

Viewing changes to core/smb4kcustomoptionsmanager_p.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-06-15 16:27:38 UTC
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20140615162738-t1426an8s5beix1b
Tags: upstream-1.1.2
ImportĀ upstreamĀ versionĀ 1.1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
    smb4kcustomoptionsmanager_p - Private helper classes for 
 
2
    smb4kcustomoptionsmanager_p - Private helper classes for
3
3
    Smb4KCustomOptionsManager class
4
4
                             -------------------
5
5
    begin                : Fr 29 Apr 2011
6
 
    copyright            : (C) 2011 by Alexander Reinholdt
 
6
    copyright            : (C) 2011-2012 by Alexander Reinholdt
7
7
    email                : alexander.reinholdt@kdemail.net
8
8
 ***************************************************************************/
9
9
 
20
20
 *                                                                         *
21
21
 *   You should have received a copy of the GNU General Public License     *
22
22
 *   along with this program; if not, write to the                         *
23
 
 *   Free Software Foundation, 51 Franklin Street, Suite 500, Boston,      *
 
23
 *   Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,*
24
24
 *   MA 02110-1335, USA                                                    *
25
25
 ***************************************************************************/
26
26
 
 
27
#ifdef HAVE_CONFIG_H
 
28
#include <config.h>
 
29
#endif
 
30
 
 
31
// application specific includes
 
32
#include "smb4kcustomoptionsmanager_p.h"
 
33
#include "smb4ksettings.h"
 
34
 
27
35
// Qt includes
28
 
#include <QVBoxLayout>
29
 
#include <QHBoxLayout>
30
 
#include <QLabel>
31
 
#include <QCoreApplication>
 
36
#include <QtCore/QCoreApplication>
 
37
#include <QtGui/QVBoxLayout>
 
38
#include <QtGui/QHBoxLayout>
 
39
#include <QtGui/QLabel>
 
40
#include <QtGui/QGroupBox>
32
41
 
33
42
// KDE includes
34
43
#include <klocale.h>
35
44
#include <kstandardguiitem.h>
36
45
#include <kuser.h>
37
 
 
38
 
// application specific includes
39
 
#include <smb4kcustomoptionsmanager_p.h>
40
 
#include <smb4ksettings.h>
 
46
#include <ktabwidget.h>
41
47
 
42
48
 
43
49
Smb4KCustomOptionsDialog::Smb4KCustomOptionsDialog( Smb4KCustomOptions *options, QWidget *parent )
47
53
  setButtons( User1|Ok|Cancel );
48
54
  setDefaultButton( Ok );
49
55
  setButtonGuiItem( User1, KStandardGuiItem::defaults() );
50
 
  
 
56
 
51
57
  setupView();
52
 
  
53
 
  connect( this, SIGNAL( user1Clicked() ), SLOT( slotSetDefaultValues() ) );
54
 
  connect( this, SIGNAL( okClicked() ), SLOT( slotOKClicked() ) );
55
 
  
 
58
 
 
59
  connect( this, SIGNAL(user1Clicked()), SLOT(slotSetDefaultValues()) );
 
60
  connect( this, SIGNAL(okClicked()), SLOT(slotOKClicked()) );
 
61
 
56
62
  KConfigGroup group( Smb4KSettings::self()->config(), "CustomOptionsDialog" );
57
63
  restoreDialogSize( group );
58
64
}
84
90
  pixmap->setAlignment( Qt::AlignBottom );
85
91
 
86
92
  QLabel *label = NULL;
87
 
  
 
93
 
88
94
  switch ( m_options->type() )
89
95
  {
90
96
    case Smb4KCustomOptions::Host:
91
97
    {
92
 
      label = new QLabel( i18n( "<p>Define custom options for host <b>%1</b> and all the shares it provides.</p>", 
93
 
                          m_options->host()->hostName() ), description );
 
98
      label = new QLabel( i18n( "<p>Define custom options for host <b>%1</b> and all the shares it provides.</p>",
 
99
                          m_options->hostName() ), description );
94
100
      break;
95
101
    }
96
102
    case Smb4KCustomOptions::Share:
97
103
    {
98
 
      label = new QLabel( i18n( "<p>Define custom options for share <b>%1</b> at host <b>%2</b>.</p>", 
99
 
                          m_options->share()->shareName(), m_options->share()->hostName() ), 
 
104
      label = new QLabel( i18n( "<p>Define custom options for share <b>%1</b> at host <b>%2</b>.</p>",
 
105
                          m_options->shareName(), m_options->hostName() ),
100
106
                          description );
101
107
      break;
102
108
    }
106
112
      break;
107
113
    }
108
114
  }
109
 
  
 
115
 
110
116
  label->setWordWrap( true );
111
117
  label->setAlignment( Qt::AlignBottom );
112
118
 
113
119
  desc_layout->addWidget( pixmap, 0 );
114
120
  desc_layout->addWidget( label, Qt::AlignBottom );
115
 
  
116
 
  QWidget *editors = new QWidget( main_widget );
117
 
  
118
 
  QGridLayout *editors_layout = new QGridLayout( editors );
119
 
  editors_layout->setSpacing( 5 );
120
 
  editors_layout->setMargin( 0 );
121
 
 
122
 
  QLabel *unc_label = new QLabel( i18n( "UNC Address:" ), editors );
123
 
  KLineEdit *unc    = NULL;
124
 
  
125
 
  switch ( m_options->type() )
126
 
  {
127
 
    case Smb4KCustomOptions::Host:
128
 
    {
129
 
      unc = new KLineEdit( m_options->host()->unc(), editors );
130
 
      break;
131
 
    }
132
 
    case Smb4KCustomOptions::Share:
133
 
    {
134
 
      unc = new KLineEdit( m_options->share()->unc(), editors );
135
 
      break;
136
 
    }
137
 
    default:
138
 
    {
139
 
      break;
140
 
    }
141
 
  }
 
121
 
 
122
  QGroupBox *general = new QGroupBox( i18n( "General" ), main_widget );
 
123
 
 
124
  QGridLayout *general_layout = new QGridLayout( general );
 
125
  general_layout->setSpacing( 5 );
 
126
 
 
127
  QLabel *unc_label = new QLabel( i18n( "UNC Address:" ), general );
 
128
  KLineEdit *unc    = new KLineEdit( m_options->unc(), general );
142
129
  unc->setReadOnly( true );
143
 
      
144
 
  QLabel *smb_label = new QLabel( i18n( "SMB Port:" ), editors );
 
130
  
 
131
  QLabel *ip_label = new QLabel( i18n( "IP Address:" ), general );
 
132
  KLineEdit *ip    = new KLineEdit( m_options->ip(), general );
 
133
  ip->setReadOnly( true );
 
134
  
 
135
  general_layout->addWidget( unc_label, 0, 0, 0 );
 
136
  general_layout->addWidget( unc, 0, 1, 0 );
 
137
  general_layout->addWidget( ip_label, 1, 0, 0 );
 
138
  general_layout->addWidget( ip, 1, 1, 0 );
 
139
 
 
140
 
 
141
  //
 
142
  // Tab widget with settings
 
143
  //
 
144
 
 
145
  KTabWidget *tab_widget = new KTabWidget( main_widget );
 
146
 
 
147
  //
 
148
  // Custom options for Samba
 
149
  //
 
150
 
 
151
  QWidget *samba_editors = new QWidget( tab_widget );
 
152
  
 
153
  QGridLayout *samba_editors_layout = new QGridLayout( samba_editors );
 
154
  samba_editors_layout->setSpacing( 5 );
 
155
 
 
156
  QLabel *smb_label = new QLabel( i18n( "SMB Port:" ), samba_editors );
145
157
  m_smb_port        = new KIntNumInput( (m_options->smbPort() != Smb4KSettings::remoteSMBPort() ?
146
 
                      m_options->smbPort() : Smb4KSettings::remoteSMBPort()), editors );
 
158
                      m_options->smbPort() : Smb4KSettings::remoteSMBPort()), samba_editors );
147
159
  m_smb_port->setRange( Smb4KSettings::self()->remoteSMBPortItem()->minValue().toInt(),
148
160
                        Smb4KSettings::self()->remoteSMBPortItem()->maxValue().toInt() );
149
161
  m_smb_port->setSliderEnabled( true );
 
162
  smb_label->setBuddy( m_smb_port );
150
163
 
151
164
#ifndef Q_OS_FREEBSD
152
 
  QLabel *fs_label = new QLabel( i18n( "Filesystem Port:" ), editors );
153
 
  m_fs_port        = new KIntNumInput( (m_options->fileSystemPort() != Smb4KSettings::remoteFileSystemPort() ? 
154
 
                     m_options->fileSystemPort() : Smb4KSettings::remoteFileSystemPort()), editors );
 
165
  QLabel *fs_label = new QLabel( i18n( "Filesystem Port:" ), samba_editors );
 
166
  m_fs_port        = new KIntNumInput( (m_options->fileSystemPort() != Smb4KSettings::remoteFileSystemPort() ?
 
167
                     m_options->fileSystemPort() : Smb4KSettings::remoteFileSystemPort()), samba_editors );
155
168
  m_fs_port->setRange( Smb4KSettings::self()->remoteFileSystemPortItem()->minValue().toInt(),
156
169
                       Smb4KSettings::self()->remoteFileSystemPortItem()->maxValue().toInt() );
157
170
  m_fs_port->setSliderEnabled( true );
158
 
     
159
 
  QLabel *rw_label = new QLabel( i18n( "Write Access:" ), editors );
160
 
  m_write_access   = new KComboBox( editors );
 
171
  fs_label->setBuddy( m_fs_port );
 
172
 
 
173
  QLabel *rw_label = new QLabel( i18n( "Write Access:" ), samba_editors );
 
174
  m_write_access   = new KComboBox( samba_editors );
161
175
  m_write_access->insertItem( 0, Smb4KSettings::self()->writeAccessItem()->choices()
162
 
                                 .value( Smb4KSettings::EnumWriteAccess::ReadWrite ).label, 
 
176
                                 .value( Smb4KSettings::EnumWriteAccess::ReadWrite ).label,
163
177
                              QVariant::fromValue<int>( Smb4KCustomOptions::ReadWrite ) );
164
178
  m_write_access->insertItem( 1, Smb4KSettings::self()->writeAccessItem()->choices()
165
 
                                 .value( Smb4KSettings::EnumWriteAccess::ReadOnly ).label, 
 
179
                                 .value( Smb4KSettings::EnumWriteAccess::ReadOnly ).label,
166
180
                              QVariant::fromValue<int>( Smb4KCustomOptions::ReadOnly ) );
167
 
 
 
181
  rw_label->setBuddy( m_write_access );
 
182
 
168
183
  if ( m_options->writeAccess() == Smb4KCustomOptions::UndefinedWriteAccess )
169
184
  {
170
185
    switch ( Smb4KSettings::writeAccess() )
205
220
      }
206
221
    }
207
222
  }
 
223
 
 
224
  QLabel *security_label = new QLabel( i18n( "Security Mode:" ), samba_editors );
 
225
  
 
226
  m_security_mode        = new KComboBox( samba_editors );
 
227
  m_security_mode->insertItem( 0, Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::EnumSecurityMode::None ).label,
 
228
                               QVariant::fromValue<int>( Smb4KCustomOptions::NoSecurityMode ) );
 
229
  m_security_mode->insertItem( 1, Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::EnumSecurityMode::Krb5 ).label,
 
230
                               QVariant::fromValue<int>( Smb4KCustomOptions::Krb5 ) );
 
231
  m_security_mode->insertItem( 2, Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::EnumSecurityMode::Krb5i ).label,
 
232
                               QVariant::fromValue<int>( Smb4KCustomOptions::Krb5i ) );
 
233
  m_security_mode->insertItem( 3, Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::EnumSecurityMode::Ntlm ).label,
 
234
                               QVariant::fromValue<int>( Smb4KCustomOptions::Ntlm ) );
 
235
  m_security_mode->insertItem( 4, Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::EnumSecurityMode::Ntlmi ).label,
 
236
                               QVariant::fromValue<int>( Smb4KCustomOptions::Ntlmi ) );
 
237
  m_security_mode->insertItem( 5, Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::EnumSecurityMode::Ntlmv2 ).label,
 
238
                               QVariant::fromValue<int>( Smb4KCustomOptions::Ntlmv2 ) );
 
239
  m_security_mode->insertItem( 6, Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::EnumSecurityMode::Ntlmv2i ).label,
 
240
                               QVariant::fromValue<int>( Smb4KCustomOptions::Ntlmv2i ) );
 
241
  m_security_mode->insertItem( 7, Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::EnumSecurityMode::Ntlmssp ).label,
 
242
                               QVariant::fromValue<int>( Smb4KCustomOptions::Ntlmssp ) );
 
243
  m_security_mode->insertItem( 8, Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::EnumSecurityMode::Ntlmsspi ).label,
 
244
                               QVariant::fromValue<int>( Smb4KCustomOptions::Ntlmsspi ) );
 
245
  security_label->setBuddy( m_security_mode );
 
246
 
 
247
  if ( m_options->securityMode() == Smb4KCustomOptions::UndefinedSecurityMode )
 
248
  {
 
249
    switch ( Smb4KSettings::securityMode() )
 
250
    {
 
251
      case Smb4KSettings::EnumSecurityMode::None:
 
252
      {
 
253
        m_security_mode->setCurrentIndex( 0 );
 
254
        break;
 
255
      }
 
256
      case Smb4KSettings::EnumSecurityMode::Krb5:
 
257
      {
 
258
        m_security_mode->setCurrentIndex( 1 );
 
259
        break;
 
260
      }
 
261
      case Smb4KSettings::EnumSecurityMode::Krb5i:
 
262
      {
 
263
        m_security_mode->setCurrentIndex( 2 );
 
264
        break;
 
265
      }
 
266
      case Smb4KSettings::EnumSecurityMode::Ntlm:
 
267
      {
 
268
        m_security_mode->setCurrentIndex( 3 );
 
269
        break;
 
270
      }
 
271
      case Smb4KSettings::EnumSecurityMode::Ntlmi:
 
272
      {
 
273
        m_security_mode->setCurrentIndex( 4 );
 
274
        break;
 
275
      }
 
276
      case Smb4KSettings::EnumSecurityMode::Ntlmv2:
 
277
      {
 
278
        m_security_mode->setCurrentIndex( 5 );
 
279
        break;
 
280
      }
 
281
      case Smb4KSettings::EnumSecurityMode::Ntlmv2i:
 
282
      {
 
283
        m_security_mode->setCurrentIndex( 6 );
 
284
        break;
 
285
      }
 
286
      case Smb4KSettings::EnumSecurityMode::Ntlmssp:
 
287
      {
 
288
        m_security_mode->setCurrentIndex( 7 );
 
289
        break;
 
290
      }
 
291
      case Smb4KSettings::EnumSecurityMode::Ntlmsspi:
 
292
      {
 
293
        m_security_mode->setCurrentIndex( 8 );
 
294
        break;
 
295
      }
 
296
      default:
 
297
      {
 
298
        break;
 
299
      }
 
300
    }
 
301
  }
 
302
  else
 
303
  {
 
304
    switch ( m_options->securityMode() )
 
305
    {
 
306
      case Smb4KCustomOptions::NoSecurityMode:
 
307
      {
 
308
        m_security_mode->setCurrentIndex( 0 );
 
309
        break;
 
310
      }
 
311
      case Smb4KCustomOptions::Krb5:
 
312
      {
 
313
        m_security_mode->setCurrentIndex( 1 );
 
314
        break;
 
315
      }
 
316
      case Smb4KCustomOptions::Krb5i:
 
317
      {
 
318
        m_security_mode->setCurrentIndex( 2 );
 
319
        break;
 
320
      }
 
321
      case Smb4KCustomOptions::Ntlm:
 
322
      {
 
323
        m_security_mode->setCurrentIndex( 3 );
 
324
        break;
 
325
      }
 
326
      case Smb4KCustomOptions::Ntlmi:
 
327
      {
 
328
        m_security_mode->setCurrentIndex( 4 );
 
329
        break;
 
330
      }
 
331
      case Smb4KCustomOptions::Ntlmv2:
 
332
      {
 
333
        m_security_mode->setCurrentIndex( 5 );
 
334
        break;
 
335
      }
 
336
      case Smb4KCustomOptions::Ntlmv2i:
 
337
      {
 
338
        m_security_mode->setCurrentIndex( 6 );
 
339
        break;
 
340
      }
 
341
      case Smb4KCustomOptions::Ntlmssp:
 
342
      {
 
343
        m_security_mode->setCurrentIndex( 7 );
 
344
        break;
 
345
      }
 
346
      case Smb4KCustomOptions::Ntlmsspi:
 
347
      {
 
348
        m_security_mode->setCurrentIndex( 8 );
 
349
        break;
 
350
      }
 
351
      default:
 
352
      {
 
353
        break;
 
354
      }
 
355
    }
 
356
  }
208
357
#endif
209
358
 
210
 
  QLabel *protocol_label = new QLabel( i18n( "Protocol Hint:" ), editors );
211
 
  m_protocol_hint        = new KComboBox( editors );
 
359
  QLabel *protocol_label = new QLabel( i18n( "Protocol Hint:" ), samba_editors );
 
360
  m_protocol_hint        = new KComboBox( samba_editors );
212
361
  m_protocol_hint->insertItem( 0, Smb4KSettings::self()->protocolHintItem()->choices()
213
362
                                  .value( Smb4KSettings::EnumProtocolHint::Automatic ).label,
214
363
                               QVariant::fromValue<int>( Smb4KCustomOptions::Automatic ) );
221
370
  m_protocol_hint->insertItem( 3, Smb4KSettings::self()->protocolHintItem()->choices()
222
371
                                  .value( Smb4KSettings::EnumProtocolHint::ADS ).label,
223
372
                               QVariant::fromValue<int>( Smb4KCustomOptions::ADS ) );
 
373
  protocol_label->setBuddy( m_protocol_hint );
224
374
 
225
375
  if ( m_options->protocolHint() == Smb4KCustomOptions::UndefinedProtocolHint )
226
376
  {
282
432
      }
283
433
    }
284
434
  }
285
 
  
286
 
  QLabel *uid_label = new QLabel( i18n( "User ID:" ), editors );
287
 
  m_user_id         = new KComboBox( editors );
288
 
  
289
 
  for ( int i = 0; i < KUser::allUsers().size(); ++i )
 
435
 
 
436
  QLabel *uid_label = new QLabel( i18n( "User ID:" ), samba_editors );
 
437
  m_user_id         = new KComboBox( samba_editors );
 
438
  uid_label->setBuddy( m_user_id );
 
439
 
 
440
  // To avoid weird crashes under FreeBSD, first copy KUser::allUsers().
 
441
  QList<KUser> all_users = KUser::allUsers();
 
442
 
 
443
  for ( int i = 0; i < all_users.size(); ++i )
290
444
  {
291
 
    KUser user = KUser::allUsers().at( i );
292
 
    m_user_id->insertItem( i, QString( "%1 (%2)" ).arg( user.loginName() ).arg( user.uid() ), 
 
445
    KUser user = all_users.at( i );
 
446
    m_user_id->insertItem( i, QString( "%1 (%2)" ).arg( user.loginName() ).arg( user.uid() ),
293
447
                           QVariant::fromValue<K_UID>( user.uid() ) );
294
 
    
 
448
 
295
449
    if ( m_options->uid() == user.uid() )
296
450
    {
297
451
      m_user_id->setCurrentIndex( i );
301
455
      // Do nothing
302
456
    }
303
457
  }
304
 
  
305
 
  QLabel *gid_label = new QLabel( i18n( "Group ID:" ), editors );
306
 
  m_group_id        = new KComboBox( editors );
307
 
  
308
 
  for ( int i = 0; i < KUserGroup::allGroups().size(); ++i )
 
458
 
 
459
  QLabel *gid_label = new QLabel( i18n( "Group ID:" ), samba_editors );
 
460
  m_group_id        = new KComboBox( samba_editors );
 
461
  gid_label->setBuddy( m_group_id );
 
462
 
 
463
  // To avoid weird crashes under FreeBSD, first copy KUserGroup::allGroups().
 
464
  QList<KUserGroup> all_groups = KUserGroup::allGroups();
 
465
 
 
466
  for ( int i = 0; i < all_groups.size(); ++i )
309
467
  {
310
 
    KUserGroup group = KUserGroup::allGroups().at( i );
311
 
    m_group_id->insertItem( i, QString( "%1 (%2)" ).arg( group.name() ).arg( group.gid() ), 
 
468
    KUserGroup group = all_groups.at( i );
 
469
    m_group_id->insertItem( i, QString( "%1 (%2)" ).arg( group.name() ).arg( group.gid() ),
312
470
                           QVariant::fromValue<K_UID>( group.gid() ) );
313
 
    
 
471
 
314
472
    if ( m_options->gid() == group.gid() )
315
473
    {
316
474
      m_group_id->setCurrentIndex( i );
320
478
      // Do nothing
321
479
    }
322
480
  }
323
 
  
324
 
  m_kerberos = new QCheckBox( Smb4KSettings::self()->useKerberosItem()->label(), editors );
325
 
    
 
481
 
 
482
  m_kerberos = new QCheckBox( Smb4KSettings::self()->useKerberosItem()->label(), samba_editors );
 
483
 
326
484
  if ( m_options->useKerberos() == Smb4KCustomOptions::UndefinedKerberos )
327
485
  {
328
486
    m_kerberos->setChecked( Smb4KSettings::useKerberos() );
347
505
      }
348
506
    }
349
507
  }
350
 
  
351
 
  editors_layout->addWidget( unc_label, 0, 0, 0 );
352
 
  editors_layout->addWidget( unc, 0, 1, 0 );
353
 
  editors_layout->addWidget( smb_label, 1, 0, 0 );
354
 
  editors_layout->addWidget( m_smb_port, 1, 1, 0 );
 
508
 
 
509
  samba_editors_layout->addWidget( smb_label, 0, 0, 0 );
 
510
  samba_editors_layout->addWidget( m_smb_port, 0, 1, 0 );
355
511
#ifndef Q_OS_FREEBSD
356
 
  editors_layout->addWidget( fs_label, 2, 0, 0 );
357
 
  editors_layout->addWidget( m_fs_port, 2, 1, 0 );
358
 
  editors_layout->addWidget( rw_label, 3, 0, 0 );
359
 
  editors_layout->addWidget( m_write_access, 3, 1, 0 );
360
 
  editors_layout->addWidget( protocol_label, 4, 0, 0 );
361
 
  editors_layout->addWidget( m_protocol_hint, 4, 1, 0 );
362
 
  editors_layout->addWidget( uid_label, 5, 0, 0 );
363
 
  editors_layout->addWidget( m_user_id, 5, 1, 0 );
364
 
  editors_layout->addWidget( gid_label, 6, 0, 0 );
365
 
  editors_layout->addWidget( m_group_id, 6, 1, 0 );
366
 
  editors_layout->addWidget( m_kerberos, 7, 0, 1, 2, 0 );
 
512
  samba_editors_layout->addWidget( fs_label, 1, 0, 0 );
 
513
  samba_editors_layout->addWidget( m_fs_port, 1, 1, 0 );
 
514
  samba_editors_layout->addWidget( rw_label, 2, 0, 0 );
 
515
  samba_editors_layout->addWidget( m_write_access, 2, 1, 0 );
 
516
  samba_editors_layout->addWidget( security_label, 3, 0, 0 );
 
517
  samba_editors_layout->addWidget( m_security_mode, 3, 1, 0 );
 
518
  samba_editors_layout->addWidget( protocol_label, 4, 0, 0 );
 
519
  samba_editors_layout->addWidget( m_protocol_hint, 4, 1, 0 );
 
520
  samba_editors_layout->addWidget( uid_label, 5, 0, 0 );
 
521
  samba_editors_layout->addWidget( m_user_id, 5, 1, 0 );
 
522
  samba_editors_layout->addWidget( gid_label, 6, 0, 0 );
 
523
  samba_editors_layout->addWidget( m_group_id, 6, 1, 0 );
 
524
  samba_editors_layout->addWidget( m_kerberos, 7, 0, 1, 2, 0 );
367
525
#else
368
 
  editors_layout->addWidget( protocol_label, 2, 0, 0 );
369
 
  editors_layout->addWidget( m_protocol_hint, 2, 1, 0 );
370
 
  editors_layout->addWidget( uid_label, 3, 0, 0 );
371
 
  editors_layout->addWidget( m_user_id, 3, 1, 0 );
372
 
  editors_layout->addWidget( gid_label, 4, 0, 0 );
373
 
  editors_layout->addWidget( m_group_id, 4, 1, 0 );
374
 
  editors_layout->addWidget( m_kerberos, 5, 0, 1, 2, 0 );
 
526
  samba_editors_layout->addWidget( protocol_label, 1, 0, 0 );
 
527
  samba_editors_layout->addWidget( m_protocol_hint, 1, 1, 0 );
 
528
  samba_editors_layout->addWidget( uid_label, 2, 0, 0 );
 
529
  samba_editors_layout->addWidget( m_user_id, 2, 1, 0 );
 
530
  samba_editors_layout->addWidget( gid_label, 3, 0, 0 );
 
531
  samba_editors_layout->addWidget( m_group_id, 3, 1, 0 );
 
532
  samba_editors_layout->addWidget( m_kerberos, 4, 0, 1, 2, 0 );
375
533
#endif
376
 
  
 
534
 
 
535
  tab_widget->addTab( samba_editors, i18n( "Samba" ) );
 
536
 
 
537
 
 
538
  //
 
539
  // Custom options for Wake-On-LAN
 
540
  //
 
541
 
 
542
  QWidget *wol_editors = new QWidget( tab_widget );
 
543
  
 
544
  QGridLayout *wol_editors_layout = new QGridLayout( wol_editors );
 
545
  wol_editors_layout->setSpacing( 5 );
 
546
  
 
547
  QLabel *mac_label = new QLabel( i18n( "MAC Address:" ), wol_editors );
 
548
  m_mac_address     = new KLineEdit( m_options->macAddress(), wol_editors );
 
549
  mac_label->setBuddy( m_mac_address );
 
550
  
 
551
  // If you change the texts here, please also alter them in the config
 
552
  // dialog.
 
553
  m_send_before_scan = new QCheckBox( i18n( "Send magic package before scanning the network neighborhood" ), wol_editors );
 
554
  m_send_before_scan->setChecked( m_options->wolSendBeforeNetworkScan() );
 
555
  m_send_before_scan->setEnabled( (m_options->type() == Smb4KCustomOptions::Host) );
 
556
  
 
557
  m_send_before_mount = new QCheckBox( i18n( "Send magic package before mounting a share" ), wol_editors );
 
558
  m_send_before_mount->setChecked( m_options->wolSendBeforeMount() );
 
559
  m_send_before_mount->setEnabled( (m_options->type() == Smb4KCustomOptions::Host) );
 
560
  
 
561
  wol_editors_layout->addWidget( mac_label, 0, 0, 0 );
 
562
  wol_editors_layout->addWidget( m_mac_address, 0, 1, 0 );
 
563
  wol_editors_layout->addWidget( m_send_before_scan, 1, 0, 1, 2, 0 );
 
564
  wol_editors_layout->addWidget( m_send_before_mount, 2, 0, 1, 2, 0 );
 
565
  wol_editors_layout->setRowStretch( 3, 100 );
 
566
 
 
567
  tab_widget->addTab( wol_editors, i18n( "Wake-On-LAN" ) );
 
568
 
377
569
  layout->addWidget( description );
378
 
  layout->addWidget( editors );
379
 
  
380
 
  connect( m_smb_port, SIGNAL( valueChanged( int ) ), SLOT( slotCheckValues() ) );
 
570
  layout->addWidget( general );
 
571
  layout->addWidget( tab_widget );
 
572
 
 
573
  connect( m_smb_port, SIGNAL(valueChanged(int)), SLOT(slotCheckValues()) );
381
574
#ifndef Q_OS_FREEBSD
382
 
  connect( m_fs_port, SIGNAL( valueChanged(int) ), SLOT( slotCheckValues() ) );
383
 
  connect( m_write_access, SIGNAL( currentIndexChanged( int ) ), SLOT( slotCheckValues() ) );
 
575
  connect( m_fs_port, SIGNAL(valueChanged(int)), SLOT(slotCheckValues()) );
 
576
  connect( m_write_access, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues()) );
 
577
  connect( m_security_mode, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues()) );
384
578
#endif
385
 
  connect( m_protocol_hint, SIGNAL( currentIndexChanged( int ) ), SLOT( slotCheckValues() ) );
386
 
  connect( m_user_id, SIGNAL( currentIndexChanged( int ) ), SLOT( slotCheckValues() ) );
387
 
  connect( m_group_id, SIGNAL( currentIndexChanged( int ) ), SLOT( slotCheckValues() ) );
388
 
  connect( m_kerberos, SIGNAL( toggled( bool ) ), SLOT( slotCheckValues() ) );
 
579
  connect( m_protocol_hint, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues()) );
 
580
  connect( m_user_id, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues()) );
 
581
  connect( m_group_id, SIGNAL(currentIndexChanged(int)), SLOT(slotCheckValues()) );
 
582
  connect( m_kerberos, SIGNAL(toggled(bool)), SLOT(slotCheckValues()) );
 
583
  connect( m_mac_address, SIGNAL(textChanged(QString)), SLOT(slotCheckValues()) );
 
584
  connect( m_mac_address, SIGNAL(textChanged(QString)), SLOT(slotEnableWOLFeatures(QString)) );
 
585
  connect( m_send_before_scan, SIGNAL(toggled(bool)), SLOT(slotCheckValues()) );
 
586
  connect( m_send_before_mount, SIGNAL(toggled(bool)), SLOT(slotCheckValues()) );
 
587
  
 
588
  wol_editors->setEnabled( (m_options->type() == Smb4KCustomOptions::Host && Smb4KSettings::enableWakeOnLAN()) );
389
589
  
390
590
  enableButton( User1, !defaultValues() );
391
591
}
401
601
  {
402
602
    // Do nothing
403
603
  }
404
 
  
 
604
 
405
605
#ifndef Q_OS_FREEBSD
406
 
 
407
606
  if ( m_fs_port->value() != Smb4KSettings::remoteFileSystemPort() )
408
607
  {
409
608
    return false;
412
611
  {
413
612
    // Do nothing
414
613
  }
415
 
  
416
 
  if ( QString::compare( m_write_access->currentText(), 
 
614
 
 
615
  if ( QString::compare( m_write_access->currentText(),
417
616
       Smb4KSettings::self()->writeAccessItem()->choices().value( Smb4KSettings::self()->writeAccess() ).label,
418
617
       Qt::CaseInsensitive ) != 0 )
419
618
  {
423
622
  {
424
623
    // Do nothing
425
624
  }
 
625
 
 
626
  if ( QString::compare( m_security_mode->currentText(),
 
627
       Smb4KSettings::self()->securityModeItem()->choices().value( Smb4KSettings::self()->securityMode() ).label,
 
628
       Qt::CaseInsensitive ) != 0 )
 
629
  {
 
630
    return false;
 
631
  }
 
632
  else
 
633
  {
 
634
    // Do nothing
 
635
  }
426
636
#endif
427
637
 
428
638
  if ( QString::compare( m_protocol_hint->currentText(),
435
645
  {
436
646
    // Do nothing
437
647
  }
438
 
  
 
648
 
439
649
  K_UID uid = (K_UID)m_user_id->itemData( m_user_id->currentIndex() ).toInt();
440
 
  
 
650
 
441
651
  if ( uid != (K_UID)Smb4KSettings::userID().toInt() )
442
652
  {
443
653
    return false;
446
656
  {
447
657
    // Do nothing
448
658
  }
449
 
  
 
659
 
450
660
  K_GID gid = (K_GID)m_group_id->itemData( m_group_id->currentIndex() ).toInt();
451
 
  
 
661
 
452
662
  if ( gid != (K_GID)Smb4KSettings::groupID().toInt() )
453
663
  {
454
664
    return false;
457
667
  {
458
668
    // Do nothing
459
669
  }
460
 
  
 
670
 
461
671
  if ( m_kerberos->isChecked() != Smb4KSettings::useKerberos() )
462
672
  {
463
673
    return false;
467
677
    // Do nothing
468
678
  }
469
679
  
 
680
  if ( m_options->type() == Smb4KCustomOptions::Host )
 
681
  {
 
682
    if ( !m_mac_address->text().isEmpty() )
 
683
    {
 
684
      return false;
 
685
    }
 
686
    else
 
687
    {
 
688
      // Do nothing
 
689
    }
 
690
    
 
691
    if ( m_send_before_scan->isChecked() )
 
692
    {
 
693
      return false;
 
694
    }
 
695
    else
 
696
    {
 
697
      // Do nothing
 
698
    }
 
699
    
 
700
    if ( m_send_before_mount->isChecked() )
 
701
    {
 
702
      return false;
 
703
    }
 
704
    else
 
705
    {
 
706
      // Do nothing
 
707
    }
 
708
  }
 
709
  else
 
710
  {
 
711
    // Do nothing
 
712
  }
 
713
 
470
714
  return true;
471
715
}
472
716
 
494
738
      break;
495
739
    }
496
740
  }
 
741
 
 
742
  switch ( Smb4KSettings::securityMode() )
 
743
  {
 
744
    case Smb4KSettings::EnumSecurityMode::None:
 
745
    {
 
746
      m_security_mode->setCurrentIndex( 0 );
 
747
      break;
 
748
    }
 
749
    case Smb4KSettings::EnumSecurityMode::Krb5:
 
750
    {
 
751
      m_security_mode->setCurrentIndex( 1 );
 
752
      break;
 
753
    }
 
754
    case Smb4KSettings::EnumSecurityMode::Krb5i:
 
755
    {
 
756
      m_security_mode->setCurrentIndex( 2 );
 
757
      break;
 
758
    }
 
759
    case Smb4KSettings::EnumSecurityMode::Ntlm:
 
760
    {
 
761
      m_security_mode->setCurrentIndex( 3 );
 
762
      break;
 
763
    }
 
764
    case Smb4KSettings::EnumSecurityMode::Ntlmi:
 
765
    {
 
766
      m_security_mode->setCurrentIndex( 4 );
 
767
      break;
 
768
    }
 
769
    case Smb4KSettings::EnumSecurityMode::Ntlmv2:
 
770
    {
 
771
      m_security_mode->setCurrentIndex( 5 );
 
772
      break;
 
773
    }
 
774
    case Smb4KSettings::EnumSecurityMode::Ntlmv2i:
 
775
    {
 
776
      m_security_mode->setCurrentIndex( 6 );
 
777
      break;
 
778
    }
 
779
    case Smb4KSettings::EnumSecurityMode::Ntlmssp:
 
780
    {
 
781
      m_security_mode->setCurrentIndex( 7 );
 
782
      break;
 
783
    }
 
784
    case Smb4KSettings::EnumSecurityMode::Ntlmsspi:
 
785
    {
 
786
      m_security_mode->setCurrentIndex( 8 );
 
787
      break;
 
788
    }
 
789
    default:
 
790
    {
 
791
      break;
 
792
    }
 
793
  }
497
794
#endif
498
795
 
499
796
  switch ( Smb4KSettings::protocolHint() )
523
820
      break;
524
821
    }
525
822
  }
526
 
  
 
823
 
527
824
  for ( int i = 0; i < m_user_id->count(); ++i )
528
825
  {
529
826
    if ( m_user_id->itemData( i ).toInt() == Smb4KSettings::userID().toInt() )
536
833
      continue;
537
834
    }
538
835
  }
539
 
  
 
836
 
540
837
  for ( int i = 0; i < m_group_id->count(); ++i )
541
838
  {
542
839
    if ( m_group_id->itemData( i ).toInt() == Smb4KSettings::groupID().toInt() )
549
846
      continue;
550
847
    }
551
848
  }
552
 
  
 
849
 
553
850
  m_kerberos->setChecked( Smb4KSettings::self()->useKerberos() );
 
851
 
 
852
  if ( m_options->type() == Smb4KCustomOptions::Host )
 
853
  {
 
854
    m_mac_address->clear();
 
855
    m_send_before_scan->setChecked( false );
 
856
    m_send_before_mount->setChecked( false );
 
857
  }
 
858
  else
 
859
  {
 
860
    // Do nothing, because with shares these widgets are
 
861
    // disabled.
 
862
  }
554
863
}
555
864
 
556
865
 
566
875
#ifndef Q_OS_FREEBSD
567
876
  m_options->setFileSystemPort( m_fs_port->value() );
568
877
  m_options->setWriteAccess( (Smb4KCustomOptions::WriteAccess)m_write_access->itemData( m_write_access->currentIndex() ).toInt() );
 
878
  m_options->setSecurityMode( (Smb4KCustomOptions::SecurityMode)m_security_mode->itemData( m_security_mode->currentIndex() ).toInt() );
569
879
#endif
570
880
  m_options->setProtocolHint( (Smb4KCustomOptions::ProtocolHint)m_protocol_hint->itemData( m_protocol_hint->currentIndex() ).toInt() );
571
881
  m_options->setUID( m_user_id->itemData( m_user_id->currentIndex() ).toInt() );
580
890
    m_options->setUseKerberos( Smb4KCustomOptions::NoKerberos );
581
891
  }
582
892
  
 
893
  m_options->setMACAddress( m_mac_address->text() );
 
894
  m_options->setWOLSendBeforeNetworkScan( m_send_before_scan->isChecked() );
 
895
  m_options->setWOLSendBeforeMount( m_send_before_mount->isChecked() );
 
896
 
583
897
  KConfigGroup group( Smb4KSettings::self()->config(), "CustomOptionsDialog" );
584
898
  saveDialogSize( group, KConfigGroup::Normal );
585
899
}
586
900
 
587
901
 
588
 
 
589
 
Smb4KCustomOptionsManagerPrivate::Smb4KCustomOptionsManagerPrivate()
590
 
{
591
 
}
592
 
 
593
 
 
594
 
Smb4KCustomOptionsManagerPrivate::~Smb4KCustomOptionsManagerPrivate()
595
 
{
596
 
}
 
902
void Smb4KCustomOptionsDialog::slotEnableWOLFeatures( const QString &mac )
 
903
{
 
904
  QRegExp exp( "..\\:..\\:..\\:..\\:..\\:.." );
 
905
    
 
906
  m_send_before_scan->setEnabled( exp.exactMatch( mac ) );
 
907
  m_send_before_mount->setEnabled( exp.exactMatch( mac ) );
 
908
}
 
909
 
597
910
 
598
911
#include "smb4kcustomoptionsmanager_p.moc"
599
912