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

« back to all changes in this revision

Viewing changes to core/smb4kscanner_p.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
1
/***************************************************************************
2
 
    smb4kscanner_p  -  This is a private helper class for Smb4KScanner.
 
2
    smb4kscanner_p  -  Private helper classes for the scanner
3
3
                             -------------------
4
 
    begin                : Do Jul 19 2007
5
 
    copyright            : (C) 2007 by Alexander Reinholdt
6
 
    email                : dustpuppy@users.berlios.de
 
4
    begin                : So Mai 22 2011
 
5
    copyright            : (C) 2011 by Alexander Reinholdt
 
6
    email                : alexander.reinholdt@kdemail.net
7
7
 ***************************************************************************/
8
8
 
9
9
/***************************************************************************
19
19
 *                                                                         *
20
20
 *   You should have received a copy of the GNU General Public License     *
21
21
 *   along with this program; if not, write to the                         *
22
 
 *   Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,   *
23
 
 *   MA  02111-1307 USA                                                    *
 
22
 *   Free Software Foundation, 51 Franklin Street, Suite 500, Boston,      *
 
23
 *   MA 02110-1335, USA                                                    *
24
24
 ***************************************************************************/
25
25
 
26
26
#ifndef SMB4KSCANNER_P_H
31
31
#endif
32
32
 
33
33
// Qt includes
34
 
#include <QString>
 
34
#include <QWidget>
 
35
 
 
36
// KDE includes
 
37
#include <kjob.h>
35
38
 
36
39
// application specific includes
 
40
#include <smb4kscanner.h>
 
41
#include <smb4kprocess.h>
37
42
#include <smb4kworkgroup.h>
38
 
#include <smb4khost.h>
 
43
#include <smb4kauthinfo.h>
 
44
 
 
45
// forward declarations
 
46
class Smb4KHost;
 
47
class Smb4KShare;
 
48
 
 
49
class Smb4KLookupDomainsJob : public KJob
 
50
{
 
51
  Q_OBJECT
 
52
 
 
53
  public:
 
54
    /**
 
55
     * Constructor
 
56
     */
 
57
    Smb4KLookupDomainsJob( QObject *parent = 0 );
 
58
 
 
59
    /**
 
60
     * Destructor
 
61
     */
 
62
    ~Smb4KLookupDomainsJob();
 
63
 
 
64
    /**
 
65
     * Returns TRUE if the job has been started and FALSE otherwise
 
66
     *
 
67
     * @returns TRUE if the job has been started
 
68
     */
 
69
    bool isStarted() { return m_started; }
 
70
 
 
71
    /**
 
72
     * Starts the job
 
73
     */
 
74
    void start();
 
75
 
 
76
    /**
 
77
     * Sets up the lookup job.
 
78
     *
 
79
     * @param parent      The parent widget
 
80
     */
 
81
    void setupLookup( QWidget *parent = 0 );
 
82
 
 
83
    /**
 
84
     * Returns the parent widget
 
85
     *
 
86
     * @returns the parent widget
 
87
     */
 
88
    QWidget *parentWidget() { return m_parent_widget; }
 
89
 
 
90
    /**
 
91
     * Returns the list of discovered workgroups. You can use this function
 
92
     * after the finished() signal has been emitted to retrieve the complete
 
93
     * list of workgroups.
 
94
     *
 
95
     * @returns the list of workgroups
 
96
     */
 
97
    const QList<Smb4KWorkgroup> &workgroupsList() { return m_workgroups_list; }
 
98
 
 
99
  signals:
 
100
    /**
 
101
     * This signal is emitted when a lookup process is about
 
102
     * to start
 
103
     */
 
104
    void aboutToStart();
 
105
 
 
106
    /**
 
107
     * This signal is emitted when a lookup process finished
 
108
     */
 
109
    void finished();
 
110
    
 
111
    /**
 
112
     * Emits the list of discovered workgroups and domains
 
113
     */
 
114
    void workgroups( const QList<Smb4KWorkgroup> &list );
 
115
 
 
116
  protected:
 
117
    bool doKill();
 
118
 
 
119
  protected slots:
 
120
    void slotStartLookup();
 
121
    void slotReadStandardError();
 
122
    void slotProcessFinished( int exitCode,
 
123
                              QProcess::ExitStatus exitStatus );
 
124
 
 
125
  private:
 
126
    void processWorkgroups();
 
127
    bool m_started;
 
128
    QWidget *m_parent_widget;
 
129
    Smb4KProcess *m_proc;
 
130
    QList<Smb4KWorkgroup> m_workgroups_list;
 
131
};
 
132
 
 
133
 
 
134
class Smb4KQueryMasterJob : public KJob
 
135
{
 
136
  Q_OBJECT
 
137
 
 
138
  public:
 
139
    /**
 
140
     * Constructor
 
141
     */
 
142
    Smb4KQueryMasterJob( QObject *parent = 0 );
 
143
 
 
144
    /**
 
145
     * Destructor
 
146
     */
 
147
    ~Smb4KQueryMasterJob();
 
148
 
 
149
    /**
 
150
     * Returns TRUE if the job has been started and FALSE otherwise
 
151
     *
 
152
     * @returns TRUE if the job has been started
 
153
     */
 
154
    bool isStarted() { return m_started; }
 
155
 
 
156
    /**
 
157
     * Starts the job
 
158
     */
 
159
    void start();
 
160
 
 
161
    /**
 
162
     * Sets up the lookup job. With the @p master argument you can 
 
163
     * define a custom master browser that should be queried. If 
 
164
     * @p master is empty, the current master browser is queried.
 
165
     *
 
166
     * @param master        The master browser's name or IP address
 
167
     *
 
168
     * @param parent        The parent widget
 
169
     */
 
170
    void setupLookup( const QString &master,
 
171
                      QWidget *parent = 0 );
 
172
    
 
173
    /**
 
174
     * Returns the parent widget
 
175
     *
 
176
     * @returns the parent widget
 
177
     */
 
178
    QWidget *parentWidget() { return m_parent_widget; }
 
179
 
 
180
    /**
 
181
     * Returns the name of either the custom master browser, if one was
 
182
     * passed, or, in the case of an authentication error, the master
 
183
     * browser that needs authentication.
 
184
     *
 
185
     * @returns the custom master browser's name
 
186
     */
 
187
    const QString &masterBrowser() { return m_master_browser; }
 
188
 
 
189
    /**
 
190
     * Returns the list of discovered workgroups. You can use this function
 
191
     * after the finished() signal has been emitted to retrieve the complete
 
192
     * list of workgroups.
 
193
     *
 
194
     * @returns the list of workgroups
 
195
     */
 
196
    const QList<Smb4KWorkgroup> &workgroupsList() { return m_workgroups_list; }
 
197
 
 
198
  signals:
 
199
    /**
 
200
     * This signal is emitted when a lookup process is about
 
201
     * to start
 
202
     */
 
203
    void aboutToStart();
 
204
 
 
205
    /**
 
206
     * This signal is emitted when a lookup process finished
 
207
     */
 
208
    void finished();
 
209
 
 
210
    /**
 
211
     * Emits the list of discovered workgroups and domains
 
212
     */
 
213
    void workgroups( const QList<Smb4KWorkgroup> &list );
 
214
 
 
215
    /**
 
216
     * This signal is emitted when an authentication error
 
217
     * occurred.
 
218
     *
 
219
     * @param job           This job
 
220
     */
 
221
    void authError( Smb4KQueryMasterJob *job );
 
222
 
 
223
  protected:
 
224
    bool doKill();
 
225
 
 
226
  protected slots:
 
227
    void slotStartLookup();
 
228
    void slotReadStandardError();
 
229
    void slotProcessFinished( int exitCode,
 
230
                              QProcess::ExitStatus exitStatus );
 
231
    
 
232
  private:
 
233
    void processWorkgroups();
 
234
    bool m_started;
 
235
    QWidget *m_parent_widget;
 
236
    QString m_master_browser;
 
237
    Smb4KProcess *m_proc;
 
238
    QList<Smb4KWorkgroup> m_workgroups_list;
 
239
};
 
240
 
 
241
 
 
242
class Smb4KScanBAreasJob : public KJob
 
243
{
 
244
  Q_OBJECT
 
245
 
 
246
  public:
 
247
    /**
 
248
     * Constructor
 
249
     */
 
250
    Smb4KScanBAreasJob( QObject *parent = 0 );
 
251
 
 
252
    /**
 
253
     * Destructor
 
254
     */
 
255
    ~Smb4KScanBAreasJob();
 
256
 
 
257
    /**
 
258
     * Returns TRUE if the job has been started and FALSE otherwise
 
259
     *
 
260
     * @returns TRUE if the job has been started
 
261
     */
 
262
    bool isStarted() { return m_started; }
 
263
 
 
264
    /**
 
265
     * Starts the job
 
266
     */
 
267
    void start();
 
268
 
 
269
    /**
 
270
     * Sets up the scan job
 
271
     *
 
272
     * @param parent        The parent widget
 
273
     */
 
274
    void setupScan( QWidget *parent = 0 );
 
275
 
 
276
    /**
 
277
     * Returns the parent widget
 
278
     *
 
279
     * @returns the parent widget
 
280
     */
 
281
    QWidget *parentWidget() { return m_parent_widget; }
 
282
 
 
283
    /**
 
284
     * Returns the list of discovered workgroups. You can use this function 
 
285
     * after the finished() signal has been emitted to retrieve the complete
 
286
     * list of workgroups.
 
287
     *
 
288
     * @returns the list of workgroups
 
289
     */
 
290
    const QList<Smb4KWorkgroup> &workgroupsList() { return m_workgroups_list; }
 
291
 
 
292
    /**
 
293
     * Returns the list of discovered hosts. You can use this function
 
294
     * after the finished() signal has been emitted to retrieve the complete
 
295
     * list of hosts.
 
296
     *
 
297
     * @returns the list of hosts
 
298
     */
 
299
    const QList<Smb4KHost> &hostsList() { return m_hosts_list; }
 
300
 
 
301
  signals:
 
302
    /**
 
303
     * This signal is emitted when a scan process is about
 
304
     * to start
 
305
     */
 
306
    void aboutToStart();
 
307
 
 
308
    /**
 
309
     * This signal is emitted when a scan process finished
 
310
     */
 
311
    void finished();
 
312
 
 
313
    /**
 
314
     * Emits the list of discovered workgroups and domains.
 
315
     * 
 
316
     * @param list        The list of workgroups
 
317
     */
 
318
    void workgroups( const QList<Smb4KWorkgroup> &list );
 
319
 
 
320
    /**
 
321
     * Emits the list of discovered hosts.
 
322
     *
 
323
     * @param list        The list of hosts
 
324
     */
 
325
    void hosts( const QList<Smb4KHost> &list );
 
326
 
 
327
  protected:
 
328
    bool doKill();
 
329
 
 
330
  protected slots:
 
331
    void slotStartScan();
 
332
    void slotReadStandardError();
 
333
    void slotProcessFinished( int exitCode,
 
334
                              QProcess::ExitStatus exitStatus );
 
335
 
 
336
  private:
 
337
    void processScan();
 
338
    bool m_started;
 
339
    QWidget *m_parent_widget;
 
340
    Smb4KProcess *m_proc;
 
341
    QList<Smb4KWorkgroup> m_workgroups_list;
 
342
    QList<Smb4KHost> m_hosts_list;
 
343
};
 
344
 
 
345
 
 
346
class Smb4KLookupDomainMembersJob : public KJob
 
347
{
 
348
  Q_OBJECT
 
349
 
 
350
  public:
 
351
    /**
 
352
     * Constructor
 
353
     */
 
354
    Smb4KLookupDomainMembersJob( QObject *parent = 0 );
 
355
 
 
356
    /**
 
357
     * Destructor
 
358
     */
 
359
    ~Smb4KLookupDomainMembersJob();
 
360
 
 
361
    /**
 
362
     * Returns TRUE if the job has been started and FALSE otherwise
 
363
     *
 
364
     * @returns TRUE if the job has been started
 
365
     */
 
366
    bool isStarted() { return m_started; }
 
367
 
 
368
    /**
 
369
     * Starts the job
 
370
     */
 
371
    void start();
 
372
 
 
373
    /**
 
374
     * Sets up the lookup job.
 
375
     *
 
376
     * @param workgroup     The workgroup for that the hosts should be looked up
 
377
     *
 
378
     * @param parent        The parent widget
 
379
     */
 
380
    void setupLookup( Smb4KWorkgroup *workgroup,
 
381
                      QWidget *parent = 0 );
 
382
 
 
383
    /**
 
384
     * Returns the parent widget
 
385
     *
 
386
     * @returns the parent widget
 
387
     */
 
388
    QWidget *parentWidget() { return m_parent_widget; }
 
389
 
 
390
    /**
 
391
     * Returns the workgroup for that the hosts were looked up.
 
392
     * Please note that this is a copy of the initial workgroup object.
 
393
     * 
 
394
     * @returns the workgroup
 
395
     */
 
396
    Smb4KWorkgroup *workgroup() { return &m_workgroup; }
 
397
 
 
398
    /**
 
399
     * Returns the list of discovered hosts. You can use this function
 
400
     * after the finished() signal has been emitted to retrieve the 
 
401
     * list of hosts discovered in the defined workgroup.
 
402
     *
 
403
     * @returns the list of hosts
 
404
     */
 
405
    const QList<Smb4KHost> &hostsList() { return m_hosts_list; }
 
406
 
 
407
  signals:
 
408
    /**
 
409
     * This signal is emitted when the lookup process is about to start.
 
410
     *
 
411
     * @param workgroup     The workgroup for that the hosts should be looked up
 
412
     */
 
413
    void aboutToStart( Smb4KWorkgroup *workgroup );
 
414
 
 
415
    /**
 
416
     * This signal is emitted when the lookup process finished.
 
417
     *
 
418
     * @param workgroup     The workgroup for that the hosts should be looked up
 
419
     */
 
420
    void finished( Smb4KWorkgroup *workgroup );
 
421
 
 
422
    /**
 
423
     * Emits the list of @p hosts that belong to a certain @p workgroup.
 
424
     *
 
425
     * @param workgroup   The workgroup
 
426
     *
 
427
     * @param list        The list of hosts
 
428
     */
 
429
    void hosts( Smb4KWorkgroup *workgroup,
 
430
                const QList<Smb4KHost> &list );
 
431
    
 
432
    /**
 
433
     * This signal is emitted when an authentication error
 
434
     * occurred.
 
435
     *
 
436
     * @param job           This job
 
437
     */
 
438
    void authError( Smb4KLookupDomainMembersJob *job );
 
439
    
 
440
  protected:
 
441
    bool doKill();
 
442
 
 
443
  protected slots:
 
444
    void slotStartLookup();
 
445
    void slotReadStandardError();
 
446
    void slotProcessFinished( int exitCode,
 
447
                              QProcess::ExitStatus exitStatus );
 
448
  private:
 
449
    void processHosts();
 
450
    bool m_started;
 
451
    QWidget *m_parent_widget;
 
452
    Smb4KWorkgroup m_workgroup;
 
453
    Smb4KProcess *m_proc;
 
454
    QList<Smb4KHost> m_hosts_list;
 
455
    Smb4KHost m_master_browser;
 
456
};
 
457
 
 
458
 
 
459
class Smb4KLookupSharesJob : public KJob
 
460
{
 
461
  Q_OBJECT
 
462
  
 
463
  public:
 
464
    /**
 
465
     * Constructor
 
466
     */
 
467
    Smb4KLookupSharesJob( QObject* parent = 0 );
 
468
    
 
469
    /**
 
470
     * Destructor
 
471
     */
 
472
    ~Smb4KLookupSharesJob();
 
473
    
 
474
    /**
 
475
     * Returns TRUE if the job has been started and FALSE otherwise
 
476
     *
 
477
     * @returns TRUE if the job has been started
 
478
     */
 
479
    bool isStarted() { return m_started; }
 
480
 
 
481
    /**
 
482
     * Starts the job
 
483
     */
 
484
    void start();
 
485
 
 
486
    /**
 
487
     * Sets up the lookup job.
 
488
     *
 
489
     * @param workgroup     The host that is to be asked for its shared resources
 
490
     *
 
491
     * @param parent        The parent widget
 
492
     */
 
493
    void setupLookup( Smb4KHost *host,
 
494
                      QWidget *parent = 0 );
 
495
    
 
496
    /**
 
497
     * Returns the parent widget
 
498
     *
 
499
     * @returns the parent widget
 
500
     */
 
501
    QWidget *parentWidget() { return m_parent_widget; }
 
502
    
 
503
    /**
 
504
     * Returns the host that is/was queried for its shared resources.
 
505
     * Please note that this is a copy of the initial host object.
 
506
     * 
 
507
     * @returns the host
 
508
     */
 
509
    Smb4KHost *host() { return &m_host; }
 
510
    
 
511
  signals:
 
512
    /**
 
513
     * This signal is emitted when the lookup process is about to start.
 
514
     *
 
515
     * @param host          The host that is queried for its shares
 
516
     */
 
517
    void aboutToStart( Smb4KHost *host );
 
518
 
 
519
    /**
 
520
     * This signal is emitted when the lookup process finished.
 
521
     *
 
522
     * @param host          The host that is queried for its shares
 
523
     */
 
524
    void finished( Smb4KHost *host );
 
525
    
 
526
    /**
 
527
     * This signal emits the list of shares that was retrieved from
 
528
     * the queried host.
 
529
     * 
 
530
     * @param host          The host
 
531
     *
 
532
     * @param list          The list of shares
 
533
     */
 
534
    void shares( Smb4KHost *host,
 
535
                 const QList<Smb4KShare> &list );
 
536
    
 
537
    /**
 
538
     * This signal is emitted when an authentication error
 
539
     * occurred.
 
540
     *
 
541
     * @param job           This job
 
542
     */
 
543
    void authError( Smb4KLookupSharesJob *job );
 
544
    
 
545
  protected:
 
546
    bool doKill();
 
547
    
 
548
  protected slots:
 
549
    void slotStartLookup();
 
550
    void slotReadStandardError();
 
551
    void slotProcessFinished( int exitCode,
 
552
                              QProcess::ExitStatus exitStatus );
 
553
    
 
554
  private:
 
555
    void processShares();
 
556
    bool m_started;
 
557
    Smb4KHost m_host;
 
558
    QWidget *m_parent_widget;
 
559
    Smb4KProcess *m_proc;
 
560
    QList<Smb4KShare> m_shares_list;
 
561
};
 
562
 
 
563
 
 
564
class Smb4KLookupInfoJob : public KJob
 
565
{
 
566
  Q_OBJECT
 
567
  
 
568
  public:
 
569
    /**
 
570
     * Constructor
 
571
     */
 
572
    Smb4KLookupInfoJob( QObject *parent = 0 );
 
573
    
 
574
    /**
 
575
     * Destructor
 
576
     */
 
577
    ~Smb4KLookupInfoJob();
 
578
    
 
579
    /**
 
580
     * Returns TRUE if the job has been started and FALSE otherwise
 
581
     *
 
582
     * @returns TRUE if the job has been started
 
583
     */
 
584
    bool isStarted() { return m_started; }
 
585
 
 
586
    /**
 
587
     * Starts the job
 
588
     */
 
589
    void start();
 
590
 
 
591
    /**
 
592
     * Sets up the lookup job.
 
593
     *
 
594
     * @param workgroup     The host that is to be asked for its shared resources
 
595
     *
 
596
     * @param parent        The parent widget
 
597
     */
 
598
    void setupLookup( Smb4KHost *host,
 
599
                      QWidget *parent = 0 );
 
600
    
 
601
    /**
 
602
     * Returns the parent widget
 
603
     *
 
604
     * @returns the parent widget
 
605
     */
 
606
    QWidget *parentWidget() { return m_parent_widget; }
 
607
    
 
608
  signals:
 
609
    /**
 
610
     * This signal is emitted when the lookup process is about to start.
 
611
     *
 
612
     * @param host          The host that is queried for the additional
 
613
     *                      information
 
614
     */
 
615
    void aboutToStart( Smb4KHost *host );
 
616
 
 
617
    /**
 
618
     * This signal is emitted when the lookup process finished.
 
619
     *
 
620
     * @param host          The host that was queried for the additional
 
621
     *                      information
 
622
     */
 
623
    void finished( Smb4KHost *host );
 
624
    
 
625
    /**
 
626
     * This signal is emitted when and if additional information was
 
627
     * found.
 
628
     *
 
629
     * @param host          The host that was queried for and now carries
 
630
     *                      additional information
 
631
     */
 
632
    void info( Smb4KHost *host );
 
633
    
 
634
  protected:
 
635
    bool doKill();
 
636
    
 
637
  protected slots:
 
638
    void slotStartLookup();
 
639
    void slotProcessFinished( int exitCode,
 
640
                              QProcess::ExitStatus exitStatus );
 
641
    
 
642
  private:
 
643
    void processInfo();
 
644
    bool m_started;
 
645
    Smb4KHost m_host;
 
646
    QWidget *m_parent_widget;
 
647
    Smb4KProcess *m_proc;
 
648
};
39
649
 
40
650
 
41
651
class Smb4KScannerPrivate
43
653
  public:
44
654
    Smb4KScannerPrivate();
45
655
    ~Smb4KScannerPrivate();
46
 
    bool retry;
47
 
    void clearData();
48
 
    void setWorkgroup( const Smb4KWorkgroup &workgroup );
49
 
    void setHost( const Smb4KHost &host );
50
 
    Smb4KWorkgroup &workgroup() { return m_workgroup; }
51
 
    Smb4KHost &host() { return m_host; }
52
 
 
53
 
  private:
54
 
    Smb4KWorkgroup m_workgroup;
55
 
    Smb4KHost m_host;
56
 
};
57
 
 
58
 
 
59
 
class Smb4KScannerQueueContainer
60
 
{
61
 
  public:
62
 
    Smb4KScannerQueueContainer( int todo, const Smb4KWorkgroup &workgroup );
63
 
    Smb4KScannerQueueContainer( int todo, const Smb4KHost &item );
64
 
    Smb4KScannerQueueContainer( int todo, const QString &string );
65
 
    Smb4KScannerQueueContainer( int todo );
66
 
    ~Smb4KScannerQueueContainer();
67
 
    int todo() { return m_todo; }
68
 
    const Smb4KWorkgroup &workgroup() const { return m_workgroup; }
69
 
    const Smb4KHost &host() const { return m_host; }
70
 
    const QString &string() const { return m_string; }
71
 
 
72
 
  private:
73
 
    int m_todo;
74
 
    Smb4KWorkgroup m_workgroup;
75
 
    Smb4KHost m_host;
76
 
    QString m_string;
 
656
    Smb4KScanner instance;
77
657
};
78
658
 
79
659
#endif