1
/***************************************************************************
2
smb4kcore - description
5
copyright : (C) 2004 by Alexander Reinholdt
6
email : dustpuppy@mail.berlios.de
7
***************************************************************************/
9
/***************************************************************************
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. *
16
***************************************************************************/
33
// application specific includes
34
#include "smb4kscanner.h"
35
#include "smb4kmounter.h"
36
#include "smb4kpasswdreader.h"
37
#include "smb4kfileio.h"
38
#include "smb4kipfinder.h"
39
#include "smb4kbookmarkhandler.h"
40
#include "smb4kprint.h"
41
#include "smb4kshellio.h"
45
* This is the top-level core class. It inherits all other core classes
46
* except the containers.
49
class Smb4KCore : public QObject
57
Smb4KCore( QObject *parent = 0, const char *name = 0 );
63
* Returns the state the scanner is in.
65
int scannerState() { return m_scanner_state; }
67
* Returns TRUE, if the scanner is running, otherwise FALSE.
69
bool scannerIsRunning() { return m_scanner_running; }
71
* Returns the state the mounter is in.
73
int mounterState() { return m_mounter_state; }
75
* Returns TRUE, if the mounter is running, otherwise FALSE.
77
bool mounterIsRunning() { return m_mounter_running; }
79
* Returns the state the IP finder is in.
81
int ipFinderState() { return m_ipfinder_state; }
83
* Returns TRUE, if the IP finder is running, otherwise FALSE.
85
bool ipFinderIsRunning() { return m_ipfinder_running; }
87
* Returns the state the print object is in.
89
int printState() { return m_print_state; }
91
* Returns TRUE, if the print object is running, otherwise FALSE.
93
bool printIsRunning() { return m_print_running; }
95
* Returns TRUE if one of the core classes is doing something.
99
* Returns the current state the core class is in.
101
int currentState() { return m_current_state; }
103
* Returns a pointer to the scanner object.
105
Smb4KScanner *scanner() { return m_scanner; }
107
* Returns a pointer to the mounter object.
109
Smb4KMounter *mounter() { return m_mounter; }
111
* Returns a pointer to the bookmark handler object.
113
Smb4KBookmarkHandler *bookmarkHandler() { return m_bookmarkHandler; }
115
* Returns a pointer to the file IO object.
117
Smb4KFileIO *fileIO() { return m_fileIO; }
119
* Returns a pointer to the IP finder object.
121
Smb4KIPFinder *ipFinder() { return m_finder; }
123
* Returns a pointer to the password reader object.
125
Smb4KPasswdReader *passwdReader() { return m_passwdReader; }
127
* Returns a pointer to the printer handler object.
129
Smb4KPrint *print() { return m_print; }
131
* Returns the pointer ti the shell IO object.
133
Smb4KShellIO *shellIO() { return m_shellIO; }
135
* Aborts any action of the core.
139
* Opens the mount point of a share. This function is used to run the file manager.
141
* @param share The share to be opened.
143
void open( Smb4KShare *share );
145
* This function returns the UMASK as integer. It is provided
150
* This function returns the Kernel version string. It is provided
153
const QString getKernelVersion();
155
* This function returns the system name. It is provided
158
const QString getSystemName();
160
* This function will return Samba's version string.
162
const QString getSambaVersion() { return m_samba_version; }
164
* This function returns the global options of the smb.conf file. You
165
* can reach the value of each option by providing the lowercase option
166
* name as key, if it was defined in the global section of the smb.conf.
168
const QMap<QString, QString> getGlobalSambaOptions() { return m_fileIO->readSMBOptions(); }
170
* This function returns the WINS server the system is using.
172
const QString getWINSServer();
174
* Sets the share for which the usage should be returned. You may also pass
175
* the NULL pointer. In this case, the usage() signal will return empty values.
176
* @param share The share object.
178
void setShareForUsageInfo( Smb4KShare *share );
182
* This signal is emitted, if one of the core objects
183
* starts or stops running.
185
void runStateChanged();
187
* This signal emits the usage info for a share.
189
* @param mountpoint The mountpoint/path that usage should be determined.
191
* @param total The total space that's available on the filesystem (in kB).
193
* @param used The space that's used (in kB).
195
* @param free The space that's free (in kB).
197
* @param percent The percentage the used space eats up (in kB).
199
* @param dirs The number of directories present in the mount point. The items
200
* '.' and '..' are ignored.
202
* @param files The number of files present in the mount point.
204
void usage( const QString &mountpoint, double total, double used, double free, double percent, int dirs, int files );
208
* This slot is called, if the scanner is running.
210
void slotScannerIsRunning( int state, bool on );
212
* This slot is called, if the mounter is running.
214
void slotMounterIsRunning( int state, bool on );
216
* This slot is called, if the mounter is running.
218
void slotIPFinderIsRunning( int state, bool on );
220
* This slot is called, if the printer handler is running.
222
void slotPrinterHandlerIsRunning( int state, bool on );
224
* This slot is called if an error in the core classes
227
void slotShowErrorMessage( int error_code, const QString &error_message = QString::null );
229
* This slot is called by the KApplication::shutDown() signal. Here all actions are
230
* taken to exit the core savely.
234
* This slot receives the sambaVersion() signal by Smb4KShellIO and writes
235
* Samba's version to the config file.
236
* @param version Samba's version string.
238
void slotReceiveSambaVersion( const QString &version );
240
* This slot will invoke Smb4KShellIO::getSambaVersion(). It is
241
* reimplemented for convenience. Connect to Smb4KCore::sambaVersion() to
244
void slotGetSambaVersion();
246
* This slot is connected to the timer. It is used to determine the usage
247
* of a share and emits this data via the usage() signal.
253
* The scanner object.
255
Smb4KScanner *m_scanner;
257
* The mounter object.
259
Smb4KMounter *m_mounter;
261
* The bookmark handler object.
263
Smb4KBookmarkHandler *m_bookmarkHandler;
267
Smb4KFileIO *m_fileIO;
269
* The IP finder object.
271
Smb4KIPFinder *m_finder;
273
* The password reader object.
275
Smb4KPasswdReader *m_passwdReader;
277
* The printer handler object.
281
* The shell IO object.
283
Smb4KShellIO *m_shellIO;
285
* The state the sanner is in.
289
* Is TRUE when the scanner is running, otherwise it is FALSE.
291
bool m_scanner_running;
293
* The state the mounter is in.
297
* Is TRUE when the mounter is running, otherwise it is FALSE.
299
bool m_mounter_running;
301
* The state the IP finder is in.
303
int m_ipfinder_state;
305
* Is TRUE when the IP finder is running, otherwise it is FALSE.
307
bool m_ipfinder_running;
309
* Holds the current state.
313
* The state the printer handler is in.
317
* Is TRUE when the printer handler is running, otherwise it is FALSE.
319
bool m_print_running;
321
* The advanced options for smbclient.
323
QString m_advancedSMBOptions;
325
* The KConfig object.
329
* Stores Samba's version string.
331
QString m_samba_version;
333
* This function is used to set the current state of the core.
334
* @param state One of the states defined in smb4kdefs.h
336
void setCurrentState( int state );
338
* Searches for the needed programs and emits an error
339
* if mandatory ones are missing.
341
void searchPrograms();
343
* The path for which the disk usage should be determined.
347
* The timer for retrieving the usage periodically.