35
#include <QTimerEvent>
36
#include <QStringList>
37
#include <kcompositejob.h>
40
38
#include <kdemacros.h>
43
// application specific includes
44
#include <smb4kworkgroup.h>
45
#include <smb4khost.h>
46
#include <smb4kshare.h>
49
* This class searches for network items (hosts and shares) and returns them.
50
* Depending on the settings, it uses nmblookup, smbclient or smbtree.
52
* This class belongs to the core of Smb4K.
54
* @author Alexander Reinholdt <dustpuppy@users.berlios.de>
58
typedef QPair<Smb4KHost, bool> HostEntry;
60
class KDE_EXPORT Smb4KSearch : public QObject
40
// forward declarations
41
class Smb4KSearchPrivate;
46
class KDE_EXPORT Smb4KSearch : public KCompositeJob
50
friend class Smb4KSearchPrivate;
68
* @param parent The parent of this class
70
Smb4KSearch( QObject *parent = 0 );
78
* Search for a given search item. This can either be a share or a host.
79
* The search will be done by default by using Samba's smbtree program.
80
* If you provided an IP address, nmblookup will be used automatically.
82
* @param string The search item
84
void search( const QString &string );
87
* Abort the search process.
92
* This function reports if the search is running or not.
94
* @returns TRUE if the search is running and FALSE otherwise.
96
bool isRunning() { return m_working; }
54
* This function returns a static pointer to this class.
56
* @returns a static pointer to the Smb4KSynchronizer class.
58
static Smb4KSearch *self();
61
* Searches for specific search string in the network neighborhood.
63
* @param string The search string
65
* @param parent The parent widget
67
void search( const QString &string,
68
QWidget *parent = 0 );
71
* This function tells you whether searches are running
74
* @returns TRUE if at least one search is running
79
* With this function you can test whether a search is already/still
82
* @returns TRUE if a search is already/still running
84
bool isRunning( const QString &string );
87
* This function aborts all searches at once.
92
* This function aborts the searching for a certain search string
93
* in the network neighborhood.
95
* @param string The search string
97
void abort( const QString &string );
100
* This function starts the composite job
100
* This signal emits an Smb4KHost item that matches the search
103
* @param host The Smb4KHost object
105
* @param known TRUE if the host is known to the application
106
* and FALSE otherwise
108
void result( Smb4KHost *host,
112
* This signal emits an Smb4KShare item that matches the search
115
* @param share The Smb4KShare object
117
* @param mounted TRUE if the share is already mounted and FALSE
120
void result( Smb4KShare *share,
124
* This signal emits the run state.
126
* @param state The so-called run state. There are several defined
127
* in the smb4kdefs.h header file.
129
void state( int state );
132
* This signal is emitted when the process finished.
138
* Reimplemented from QObject
140
void timerEvent( QTimerEvent *e );
106
* This signal is emitted when a search process is about to be started. It passes
107
* the search string to the receiver.
109
* @param string The search string
111
void aboutToStart( const QString &string );
114
* This signal is emitted when a search process has finished. It passes the
115
* search string to the receiver.
117
* @param string The search string
119
void finished( const QString &string );
122
* This signal is emitted when the search returned a result.
124
* @param item The network item
126
* @param mounted Is the item already known?
128
void result( Smb4KShare *share );
144
* This slot is called when output was received on stderr.
146
void slotReadyReadStandardError();
149
* This slot is called when output was received on stdout. It is
150
* used to process the search results.
152
void slotReadyReadStandardOutput();
155
* This slot is called, when the process exited.
157
* @param exitCode The exit code of the process
159
* @param exitStatus The exit status of the process (@see QProcess::ExitStatus)
161
void slotProcessFinished( int exitCode, QProcess::ExitStatus exitStatus );
164
* This slot is invoked when an error occurred with the process.
166
* @param errorCode The error code returned by the process
168
void slotProcessError( QProcess::ProcessError errorCode );
171
* Receive the IP address of a host (or for a share) from the IP
174
* @param host The Smb4KHost item that carries the IP address.
176
void slotReceiveIPAddress( Smb4KHost *host );
132
* Invoked by start() function
134
void slotStartJobs();
137
* Called when a job finished
139
void slotJobFinished( KJob *job );
142
* Called when an authentication error occurred
144
void slotAuthError( Smb4KSearchJob *job );
147
* Called when an search result was found
149
void slotProcessSearchResult( Smb4KShare *share );
152
* Called when the program is about to quit
154
void slotAboutToQuit();
185
* Carries a list of search items that need to be processed
202
QProcess::ProcessError m_process_error;
205
* The master browser as reported by smbtree
207
Smb4KHost m_master_browser;
210
* The workgroup string
212
QString m_workgroup_string;
215
* Was the process aborted?
220
* Do we need to retry?
225
* The state enumeration
227
enum State{ FullSearch,
237
* The list of hosts, that are discovered during one one.
239
QList<HostEntry> m_hosts_list;