~ubuntu-branches/ubuntu/quantal/smb4k/quantal

« back to all changes in this revision

Viewing changes to core/smb4ksambaoptionsinfo.h

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-05-19 18:54:34 UTC
  • mfrom: (1.1.20)
  • Revision ID: package-import@ubuntu.com-20120519185434-duffny2n87214n1n
Tags: 1.0.1-1
* New upstream release.
* Update debian/compat: bump to 9.
* Update debian/control:
  - bump debhelper to 9.
  - bump kdelibs5-dev build dependency to 4:4.4.0.
  - bump Standards-Version to 3.9.3 (no changes needed).
  - Replace smbfs dependency by cifs-utils. (Closes: #638162)
* Update debian/copyright:
  - update upstream URL.
  - update upstream e-mail.
* Update debian/smb4k.lintian-overrides file.
* Update debian/watch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
    smb4ksambaoptionsinfo  -  This is a container class that carries
3
 
    various information of extra options for a specific host.
4
 
                             -------------------
5
 
    begin                : Mi Okt 18 2006
6
 
    copyright            : (C) 2006-2008 by Alexander Reinholdt
7
 
    email                : dustpuppy@users.berlios.de
8
 
 ***************************************************************************/
9
 
 
10
 
/***************************************************************************
11
 
 *   This program is free software; you can redistribute it and/or modify  *
12
 
 *   it under the terms of the GNU General Public License as published by  *
13
 
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 
 *   (at your option) any later version.                                   *
15
 
 *                                                                         *
16
 
 *   This program is distributed in the hope that it will be useful, but   *
17
 
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
18
 
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
19
 
 *   General Public License for more details.                              *
20
 
 *                                                                         *
21
 
 *   You should have received a copy of the GNU General Public License     *
22
 
 *   along with this program; if not, write to the                         *
23
 
 *   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,   *
24
 
 *   MA  02111-1307 USA                                                    *
25
 
 ***************************************************************************/
26
 
 
27
 
#ifndef SMB4KSAMBAOPTIONSINFO_H
28
 
#define SMB4KSAMBAOPTIONSINFO_H
29
 
 
30
 
#ifdef HAVE_CONFIG_H
31
 
#include <config.h>
32
 
#endif
33
 
 
34
 
// Qt includes
35
 
#include <QString>
36
 
#include <QMap>
37
 
 
38
 
// KDE includes
39
 
#include <kdemacros.h>
40
 
 
41
 
// forward declarations
42
 
class Smb4KHost;
43
 
class Smb4KShare;
44
 
 
45
 
 
46
 
/**
47
 
 * This class provides a container for all extra options that the user defined
48
 
 * for a certain share.
49
 
 *
50
 
 * @author  Alexander Reinholdt <dustpuppy@users.berlios.de>
51
 
 */
52
 
 
53
 
class KDE_EXPORT Smb4KSambaOptionsInfo
54
 
{
55
 
  public:
56
 
    /**
57
 
     * Type enumeration
58
 
     */
59
 
    enum Type { Share,
60
 
                Host };
61
 
 
62
 
    /**
63
 
     * Enumeration for the protocol
64
 
     */
65
 
    enum Protocol{ Automatic,
66
 
                   RPC,
67
 
                   RAP,
68
 
                   ADS,
69
 
                   UndefinedProtocol };
70
 
 
71
 
    /**
72
 
     * Enumeration for the write access
73
 
     */
74
 
    enum WriteAccess{ ReadWrite,
75
 
                      ReadOnly,
76
 
                      UndefinedWriteAccess };
77
 
 
78
 
    /**
79
 
     * Enumeration for the use of Kerberos
80
 
     */
81
 
    enum Kerberos{ UseKerberos,
82
 
                   NoKerberos,
83
 
                   UndefinedKerberos };
84
 
 
85
 
    /**
86
 
     * Enumeration for use with remounting
87
 
     */
88
 
    enum Remount{ DoRemount,
89
 
                  NoRemount,
90
 
                  UndefinedRemount };
91
 
 
92
 
    /**
93
 
     * Constructor. It takes a Smb4KHost object and extracts all needed (and
94
 
     * available) data. All missing information has to be set with the functions
95
 
     * provided by this class.
96
 
     *
97
 
     * @param host              The Smb4KHost object representing the host.
98
 
     */
99
 
    Smb4KSambaOptionsInfo( Smb4KHost *host );
100
 
 
101
 
    /**
102
 
     * Constructor. It takes a Smb4KShare object and extracts all needed (and
103
 
     * available) data. All missing information has to be set with the functions
104
 
     * provided by this class.
105
 
     *
106
 
     * @param share             The Smb4KShare object representing a share.
107
 
     */
108
 
    Smb4KSambaOptionsInfo( Smb4KShare *share );
109
 
 
110
 
    /**
111
 
     * The copy constructor. It takes another Smb4KSambaOptionsInfo object @p info
112
 
     * and copies its values.
113
 
     *
114
 
     * @param info              A Smb4KShareOptionsInfo object
115
 
     */
116
 
    Smb4KSambaOptionsInfo( const Smb4KSambaOptionsInfo &info );
117
 
 
118
 
    /**
119
 
     * The empty constructor. You have set all needed values with the functions
120
 
     * provided by this class.
121
 
     */
122
 
    Smb4KSambaOptionsInfo();
123
 
 
124
 
    /**
125
 
     * The destructor.
126
 
     */
127
 
    ~Smb4KSambaOptionsInfo();
128
 
 
129
 
    /**
130
 
     * Sets the "should be remounted" flag.
131
 
     *
132
 
     * @param remount           A value from the Remount enumeration that defines
133
 
     *                          whether a remount should take place or not.
134
 
     */
135
 
    void setRemount( Smb4KSambaOptionsInfo::Remount remount );
136
 
 
137
 
    /**
138
 
     * Returns TRUE if the share is to be remounted and FALSE otherwise.
139
 
     *
140
 
     * @returns a value from the Remount enumeration that determines whether the
141
 
     * share should be remounted or not.
142
 
     */
143
 
    Smb4KSambaOptionsInfo::Remount remount() const { return m_remount; }
144
 
 
145
 
    /**
146
 
     * This function sets the UNC of the item. If the item is a host, then you
147
 
     * should only set the host name here. If the item is a share, the UNC should
148
 
     * look like //[USER@]HOST/SHARE. Whether USER should be specified depends
149
 
     * on your operating system (e.g. FreeBSD).
150
 
     *
151
 
     * @param unc               The UNC of the network item
152
 
     */
153
 
    void setUNC( const QString &name );
154
 
 
155
 
    /**
156
 
     * This function returns the UNC of the network item.
157
 
     *
158
 
     * @returns                 The UNC of the network item.
159
 
     */
160
 
    const QString &unc() const { return m_unc; }
161
 
 
162
 
    /**
163
 
     * This function sets the port that should be used when querying this share.
164
 
     *
165
 
     * @param port              The port number
166
 
     */
167
 
    void setPort( int port );
168
 
 
169
 
    /**
170
 
     * This function returns the port that should be used when working with this
171
 
     * share. Please note, that it will be returned as an integer. If no port has been
172
 
     * defined, -1 will be returned.
173
 
     *
174
 
     * @returns                 the port number
175
 
     */
176
 
    int port() const { return m_port; }
177
 
 
178
 
    /**
179
 
     * Set the protocol that is to be used with the net command.
180
 
     *
181
 
     * @param protocol          One item from the Protocol enumeration defining
182
 
     *                          the protocol that should be used.
183
 
     */
184
 
    void setProtocol( Smb4KSambaOptionsInfo::Protocol protocol );
185
 
 
186
 
    /**
187
 
     * Returns the protocol that is to be used with the net command.
188
 
     *
189
 
     * @returns the protocol that is to be used with the net command.
190
 
     */
191
 
    Smb4KSambaOptionsInfo::Protocol protocol() const { return m_protocol; }
192
 
 
193
 
    /**
194
 
     * Set the 'Use Kerberos' flag.
195
 
     *
196
 
     * @param kerberos          One item from the Kerberos enueration defining
197
 
     *                          if Kerberos should be used or not.
198
 
     */
199
 
    void setUseKerberos( Smb4KSambaOptionsInfo::Kerberos kerberos );
200
 
 
201
 
    /**
202
 
     * This functions returns TRUE if the user wants to use Kerberos and
203
 
     * otherwise it returns FALSE.
204
 
     *
205
 
     * @returns                 TRUE if Kerberos should be used and FALSE
206
 
     *                          otherwise.
207
 
     */
208
 
    Smb4KSambaOptionsInfo::Kerberos useKerberos() const { return m_kerberos; }
209
 
 
210
 
    /**
211
 
     * With this function you can set the UID you want to use for this item.
212
 
     * However, it makes only sense with shares.
213
 
     *
214
 
     * @param uid               The UID
215
 
     */
216
 
    void setUID( uid_t uid );
217
 
 
218
 
    /**
219
 
     * This functions returns the UID defined for this item.
220
 
     *
221
 
     * Please note that the function will always return a UID (by default the
222
 
     * user's UID). If you want to check if a UID set, use uidIsSet() function.
223
 
     *
224
 
     * @returns                 the UID.
225
 
     */
226
 
    uid_t uid() const { return m_uid; }
227
 
 
228
 
    /**
229
 
     * This function returns TRUE if the UID was set.
230
 
     *
231
 
     * @returns TRUE if the UID was set.
232
 
     */
233
 
    bool uidIsSet() const { return m_uid_set; }
234
 
 
235
 
    /**
236
 
     * With this function you can set the GID you want to use for this item.
237
 
     * However, it makes only sense with shares.
238
 
     *
239
 
     * @param gid               The GID
240
 
     */
241
 
    void setGID( gid_t gid );
242
 
 
243
 
    /**
244
 
     * This functions returns the GID defined for this item.
245
 
     *
246
 
     * Please note that the function will always return a GID (by default the
247
 
     * user's GID). If you want to check if a GID set, use uidIsSet() function.
248
 
     *
249
 
     * @returns                 the GID.
250
 
     */
251
 
    gid_t gid() const { return m_gid; }
252
 
 
253
 
    /**
254
 
     * This function returns TRUE if the GID was set.
255
 
     *
256
 
     * @returns TRUE if the GID was set.
257
 
     */
258
 
    bool gidIsSet() const { return m_uid_set; }
259
 
 
260
 
    /**
261
 
     * This function returns the type of the network item for which the options
262
 
     * have been defined.
263
 
     *
264
 
     * @returns the type according to the Type enumeration.
265
 
     */
266
 
    int type();
267
 
 
268
 
#ifndef __FreeBSD__
269
 
    /**
270
 
     * Set if the share is to be mounted read-write or read-only.
271
 
     *
272
 
     * Note: This function is not available und FreeBSD.
273
 
     *
274
 
     * @param write_access      One of the values of the Type enumeration.
275
 
     */
276
 
    void setWriteAccess( Smb4KSambaOptionsInfo::WriteAccess write_access );
277
 
 
278
 
    /**
279
 
     * This functions returns TRUE if the user wants to mount a share read-write
280
 
     * otherwise it returns FALSE.
281
 
     *
282
 
     * Note: This function is not available und FreeBSD.
283
 
     *
284
 
     * @returns                 TRUE if read-write and FALSE otherwise.
285
 
     */
286
 
    Smb4KSambaOptionsInfo::WriteAccess writeAccess() const { return m_write_access; }
287
 
#endif
288
 
 
289
 
    /**
290
 
     * Set if this item has custom options. Please note that @p has_options
291
 
     * should even be set to FALSE if you have a share that is scheduled for
292
 
     * remount, but all other options have default values.
293
 
     *
294
 
     * @param has_options       Should be TRUE if this option has custom
295
 
     *                          options and otherwise FALSE.
296
 
     */
297
 
    void setHasCustomOptions( bool has_options );
298
 
 
299
 
    /**
300
 
     * This function returns TRUE if the item has custom options. Please note
301
 
     * that it will even return FALSE if the item represents a share that is scheduled
302
 
     * for remount, but all other options have default values. So, to check if this
303
 
     * item has no custom options and is also not scheduled for remount, you need
304
 
     * to do a check like this:
305
 
     *
306
 
     * @code
307
 
     *  ...
308
 
     *  if ( item->remount() && item->hasCustomOptions() )
309
 
     *  {
310
 
     *    // do something
311
 
     *  }
312
 
     *  ...
313
 
     * @endcode
314
 
     *
315
 
     * @returns                 TRUE if the item has custom options and FALSE otherwise.
316
 
     */
317
 
    bool hasCustomOptions() const { return m_has_custom_options; }
318
 
 
319
 
    /**
320
 
     * Set the workgroup for this item.
321
 
     *
322
 
     * @param workgroup         The workgroup for this item.
323
 
     */
324
 
    void setWorkgroup( const QString &workgroup );
325
 
 
326
 
    /**
327
 
     * This function returns the workgroup of this item.
328
 
     *
329
 
     * @returns                 the workgroup of this item.
330
 
     */
331
 
    const QString &workgroup() const { return m_workgroup; }
332
 
 
333
 
    /**
334
 
     * Set the IP address for this item. This function checks if the
335
 
     * IP address complies either with IPv4 or IPv6 and only sets it
336
 
     * if the check passes. In case the IP address is invalid, the
337
 
     * internal IP address object is cleared.
338
 
     *
339
 
     * @param ip                The IP address for this item.
340
 
     */
341
 
    void setIP( const QString &ip );
342
 
 
343
 
    /**
344
 
     * This function returns the valid IP address of this item.
345
 
     *
346
 
     * @returns                 the IP address.
347
 
     */
348
 
    const QString &ip() const { return m_ip; }
349
 
 
350
 
    /**
351
 
     * This function updates all values of an Smb4KSambaOptionsInfo object
352
 
     * except the UNC, workgroup and IP address.
353
 
     *
354
 
     * @param info              The object that is used for the update.
355
 
     */
356
 
    void update( Smb4KSambaOptionsInfo *info );
357
 
 
358
 
    /**
359
 
     * This function returns all custom options in a sorted map. The UNC,
360
 
     * workgroup and IP address must be retrieved separately if needed.
361
 
     *
362
 
     * Note that all entries that are not defined for a certain item have
363
 
     * empty values.
364
 
     *
365
 
     * @returns all custom entries.
366
 
     */
367
 
    QMap<QString,QString> entries();
368
 
 
369
 
    /**
370
 
     * Set the profile for which this custom options are to be used.
371
 
     *
372
 
     * @param name              The name of the profile.
373
 
     */
374
 
    void setProfile( const QString &name );
375
 
 
376
 
    /**
377
 
     * Return the name of the profile for which the options are to be
378
 
     * used.
379
 
     *
380
 
     * @returns the name of the profile for which the options should be
381
 
     * used.
382
 
     */
383
 
    const QString &profile() const { return m_profile; }
384
 
 
385
 
  private:
386
 
    /**
387
 
     * The share name.
388
 
     */
389
 
    QString m_unc;
390
 
 
391
 
    /**
392
 
     * Should be remounted?
393
 
     */
394
 
    Remount m_remount;
395
 
 
396
 
    /**
397
 
     * The port number
398
 
     */
399
 
    int m_port;
400
 
 
401
 
#ifndef __FreeBSD__
402
 
    /**
403
 
     * Mount read-write or read-only?
404
 
     */
405
 
    WriteAccess m_write_access;
406
 
#endif
407
 
 
408
 
    /**
409
 
     * The protocol
410
 
     */
411
 
    Protocol m_protocol;
412
 
 
413
 
    /**
414
 
     * Use Kerberos or not
415
 
     */
416
 
    Kerberos m_kerberos;
417
 
 
418
 
    /**
419
 
     * The UID
420
 
     */
421
 
    uid_t m_uid;
422
 
 
423
 
    /**
424
 
     * Is UID set?
425
 
     */
426
 
    bool m_uid_set;
427
 
 
428
 
    /**
429
 
     * The GID
430
 
     */
431
 
    gid_t m_gid;
432
 
 
433
 
    /**
434
 
     * Is GID set?
435
 
     */
436
 
    bool m_gid_set;
437
 
 
438
 
    /**
439
 
     * Carries this item custom options?
440
 
     */
441
 
    bool m_has_custom_options;
442
 
 
443
 
    /**
444
 
     * The workgroup
445
 
     */
446
 
    QString m_workgroup;
447
 
 
448
 
    /**
449
 
     * The IP address
450
 
     */
451
 
    QString m_ip;
452
 
 
453
 
    /**
454
 
     * The profile name
455
 
     */
456
 
    QString m_profile;
457
 
};
458
 
 
459
 
#endif