|
|
|
@ -48,7 +48,7 @@
|
|
|
|
|
#include "smb4knetworkitems.h"
|
|
|
|
|
#include "smb4ksettings.h"
|
|
|
|
|
|
|
|
|
|
using namespace Smb4KGlobal;
|
|
|
|
|
using namespace Smb4TDEGlobal;
|
|
|
|
|
|
|
|
|
|
static bool created_workgroups_list = false;
|
|
|
|
|
static bool created_hosts_list = false;
|
|
|
|
@ -81,21 +81,21 @@ TQObject *parent, const char *name )
|
|
|
|
|
// The list was passed to the constructor from outside.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_proc = new KProcess( this, "ScannerMainProcess" );
|
|
|
|
|
m_proc = new TDEProcess( this, "ScannerMainProcess" );
|
|
|
|
|
m_proc->setUseShell( true );
|
|
|
|
|
|
|
|
|
|
m_working = false;
|
|
|
|
|
|
|
|
|
|
m_queue.setAutoDelete( true );
|
|
|
|
|
|
|
|
|
|
connect( m_proc, TQT_SIGNAL( receivedStdout( KProcess *, char *, int ) ),
|
|
|
|
|
this, TQT_SLOT( slotReceivedStdout( KProcess *, char *, int ) ) );
|
|
|
|
|
connect( m_proc, TQT_SIGNAL( receivedStdout( TDEProcess *, char *, int ) ),
|
|
|
|
|
this, TQT_SLOT( slotReceivedStdout( TDEProcess *, char *, int ) ) );
|
|
|
|
|
|
|
|
|
|
connect( m_proc, TQT_SIGNAL( processExited( KProcess* ) ),
|
|
|
|
|
this, TQT_SLOT( slotProcessExited( KProcess * ) ) );
|
|
|
|
|
connect( m_proc, TQT_SIGNAL( processExited( TDEProcess* ) ),
|
|
|
|
|
this, TQT_SLOT( slotProcessExited( TDEProcess * ) ) );
|
|
|
|
|
|
|
|
|
|
connect( m_proc, TQT_SIGNAL( receivedStderr( KProcess *, char *, int ) ),
|
|
|
|
|
this, TQT_SLOT( slotReceivedStderr( KProcess *, char *, int ) ) );
|
|
|
|
|
connect( m_proc, TQT_SIGNAL( receivedStderr( TDEProcess *, char *, int ) ),
|
|
|
|
|
this, TQT_SLOT( slotReceivedStderr( TDEProcess *, char *, int ) ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -299,11 +299,11 @@ void Smb4KScanner::scanNetwork()
|
|
|
|
|
command.append( "net " );
|
|
|
|
|
command.append( optionsHandler()->netOptions( Smb4KSambaOptionsHandler::LookupHost,
|
|
|
|
|
Smb4KSettings::customMasterBrowser() ) );
|
|
|
|
|
command.append( " -U % -S "+KProcess::quote( Smb4KSettings::customMasterBrowser() ) );
|
|
|
|
|
command.append( " -U % -S "+TDEProcess::quote( Smb4KSettings::customMasterBrowser() ) );
|
|
|
|
|
command.append( " | xargs net " );
|
|
|
|
|
command.append( optionsHandler()->netOptions( Smb4KSambaOptionsHandler::Domain,
|
|
|
|
|
TQString() ) );
|
|
|
|
|
command.append( " -U % -S "+KProcess::quote( Smb4KSettings::customMasterBrowser() )+" -I " );
|
|
|
|
|
command.append( " -U % -S "+TDEProcess::quote( Smb4KSettings::customMasterBrowser() )+" -I " );
|
|
|
|
|
|
|
|
|
|
*m_proc << command;
|
|
|
|
|
|
|
|
|
@ -378,15 +378,15 @@ void Smb4KScanner::scanForWorkgroupMembers( const TQString &workgroup, const TQS
|
|
|
|
|
{
|
|
|
|
|
command.append( "net "+optionsHandler()->netOptions( Smb4KSambaOptionsHandler::ServerDomain, TQString() ) );
|
|
|
|
|
command.append( " -I "+ip );
|
|
|
|
|
command.append( " -w "+KProcess::quote( workgroup ) );
|
|
|
|
|
command.append( " -S "+KProcess::quote( master ) );
|
|
|
|
|
command.append( " -w "+TDEProcess::quote( workgroup ) );
|
|
|
|
|
command.append( " -S "+TDEProcess::quote( master ) );
|
|
|
|
|
|
|
|
|
|
Smb4KAuthInfo authInfo( workgroup, master, TQString() );
|
|
|
|
|
(void) passwordHandler()->readAuth( &authInfo );
|
|
|
|
|
|
|
|
|
|
if ( !authInfo.user().isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
command.append( TQString( " -U %1" ).arg( KProcess::quote( authInfo.user() ) ) );
|
|
|
|
|
command.append( TQString( " -U %1" ).arg( TDEProcess::quote( authInfo.user() ) ) );
|
|
|
|
|
|
|
|
|
|
if ( !authInfo.password().isEmpty() )
|
|
|
|
|
{
|
|
|
|
@ -400,8 +400,8 @@ void Smb4KScanner::scanForWorkgroupMembers( const TQString &workgroup, const TQS
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
command.append( "net "+optionsHandler()->netOptions( Smb4KSambaOptionsHandler::LookupHost, KProcess::quote( master ) ) );
|
|
|
|
|
command.append( " -S "+KProcess::quote( master )+" -w "+KProcess::quote( workgroup )+" -U % " );
|
|
|
|
|
command.append( "net "+optionsHandler()->netOptions( Smb4KSambaOptionsHandler::LookupHost, TDEProcess::quote( master ) ) );
|
|
|
|
|
command.append( " -S "+TDEProcess::quote( master )+" -w "+TDEProcess::quote( workgroup )+" -U % " );
|
|
|
|
|
// FIXME: Maybe we need to know the shell if the user does not use a
|
|
|
|
|
// sh-compatible one...?
|
|
|
|
|
command.append( "| xargs -IIPADDR " );
|
|
|
|
@ -409,15 +409,15 @@ void Smb4KScanner::scanForWorkgroupMembers( const TQString &workgroup, const TQS
|
|
|
|
|
command.append( " -c 'echo \"*** "+master+": IPADDR ***\" && " );
|
|
|
|
|
command.append( "net "+optionsHandler()->netOptions( Smb4KSambaOptionsHandler::ServerDomain, TQString() ) );
|
|
|
|
|
command.append( " -I IPADDR" );
|
|
|
|
|
command.append( " -w "+KProcess::quote( workgroup ) );
|
|
|
|
|
command.append( " -S "+KProcess::quote( master ) );
|
|
|
|
|
command.append( " -w "+TDEProcess::quote( workgroup ) );
|
|
|
|
|
command.append( " -S "+TDEProcess::quote( master ) );
|
|
|
|
|
|
|
|
|
|
Smb4KAuthInfo authInfo( workgroup, master, TQString() );
|
|
|
|
|
(void) passwordHandler()->readAuth( &authInfo );
|
|
|
|
|
|
|
|
|
|
if ( !authInfo.user().isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
command.append( TQString( " -U %1'" ).arg( KProcess::quote( authInfo.user() ) ) );
|
|
|
|
|
command.append( TQString( " -U %1'" ).arg( TDEProcess::quote( authInfo.user() ) ) );
|
|
|
|
|
|
|
|
|
|
if ( !authInfo.password().isEmpty() )
|
|
|
|
|
{
|
|
|
|
@ -450,16 +450,16 @@ void Smb4KScanner::scanForShares( const TQString &workgroup, const TQString &hos
|
|
|
|
|
|
|
|
|
|
TQString command;
|
|
|
|
|
|
|
|
|
|
command = TQString( "net %1 -w %2 -S %3" ).arg( optionsHandler()->netOptions( Smb4KSambaOptionsHandler::Share, host, protocol ) ).arg( KProcess::quote( workgroup ), KProcess::quote( host ) );
|
|
|
|
|
command = TQString( "net %1 -w %2 -S %3" ).arg( optionsHandler()->netOptions( Smb4KSambaOptionsHandler::Share, host, protocol ) ).arg( TDEProcess::quote( workgroup ), TDEProcess::quote( host ) );
|
|
|
|
|
|
|
|
|
|
if ( !ip.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
command.append( TQString( " -I %1" ).arg( KProcess::quote( ip ) ) );
|
|
|
|
|
command.append( TQString( " -I %1" ).arg( TDEProcess::quote( ip ) ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !auth->user().isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
command.append( TQString( " -U %1" ).arg( KProcess::quote( auth->user() ) ) );
|
|
|
|
|
command.append( TQString( " -U %1" ).arg( TDEProcess::quote( auth->user() ) ) );
|
|
|
|
|
|
|
|
|
|
if ( !auth->password().isEmpty() )
|
|
|
|
|
{
|
|
|
|
@ -491,11 +491,11 @@ void Smb4KScanner::scanForInfo( const TQString &workgroup, const TQString &host,
|
|
|
|
|
|
|
|
|
|
TQString smbclient_options = optionsHandler()->smbclientOptions();
|
|
|
|
|
|
|
|
|
|
TQString command = TQString( "smbclient -d1 -U guest% -W %1 -L %2" ).arg( KProcess::quote( workgroup ) ).arg( KProcess::quote( host ) );
|
|
|
|
|
TQString command = TQString( "smbclient -d1 -U guest% -W %1 -L %2" ).arg( TDEProcess::quote( workgroup ) ).arg( TDEProcess::quote( host ) );
|
|
|
|
|
|
|
|
|
|
if ( !ip.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
command.append( TQString( " -I %1" ).arg( KProcess::quote( ip ) ) );
|
|
|
|
|
command.append( TQString( " -I %1" ).arg( TDEProcess::quote( ip ) ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !smbclient_options.stripWhiteSpace().isEmpty() )
|
|
|
|
@ -609,7 +609,7 @@ void Smb4KScanner::startProcess( int state )
|
|
|
|
|
TQApplication::setOverrideCursor( waitCursor );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_proc->start( KProcess::NotifyOnExit, KProcess::AllOutput );
|
|
|
|
|
m_proc->start( TDEProcess::NotifyOnExit, TDEProcess::AllOutput );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1590,19 +1590,19 @@ void Smb4KScanner::timerEvent( TQTimerEvent * )
|
|
|
|
|
Internal slots.
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Smb4KScanner::slotReceivedStdout( KProcess *, char *buf, int len )
|
|
|
|
|
void Smb4KScanner::slotReceivedStdout( TDEProcess *, char *buf, int len )
|
|
|
|
|
{
|
|
|
|
|
m_buffer.append( TQString::fromLocal8Bit( buf, len ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Smb4KScanner::slotProcessExited( KProcess * )
|
|
|
|
|
void Smb4KScanner::slotProcessExited( TDEProcess * )
|
|
|
|
|
{
|
|
|
|
|
endProcess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Smb4KScanner::slotReceivedStderr( KProcess *, char *buf, int len )
|
|
|
|
|
void Smb4KScanner::slotReceivedStderr( TDEProcess *, char *buf, int len )
|
|
|
|
|
{
|
|
|
|
|
m_buffer.append( TQString::fromLocal8Bit( buf, len ) );
|
|
|
|
|
}
|
|
|
|
@ -1637,8 +1637,8 @@ void Smb4KScanner::lookupIPAddresses()
|
|
|
|
|
|
|
|
|
|
command.append( "nmblookup" );
|
|
|
|
|
command.append( optionsHandler()->nmblookupOptions() );
|
|
|
|
|
command.append( optionsHandler()->winsServer().isEmpty() ? "" : " -R -U "+KProcess::quote( optionsHandler()->winsServer() ) );
|
|
|
|
|
command.append( " -- "+KProcess::quote( (*it)->name() )+" | grep '<00>'" );
|
|
|
|
|
command.append( optionsHandler()->winsServer().isEmpty() ? "" : " -R -U "+TDEProcess::quote( optionsHandler()->winsServer() ) );
|
|
|
|
|
command.append( " -- "+TDEProcess::quote( (*it)->name() )+" | grep '<00>'" );
|
|
|
|
|
command.append( " ; " );
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
@ -1653,16 +1653,16 @@ void Smb4KScanner::lookupIPAddresses()
|
|
|
|
|
|
|
|
|
|
if ( start )
|
|
|
|
|
{
|
|
|
|
|
KProcess *proc = new KProcess( this );
|
|
|
|
|
TDEProcess *proc = new TDEProcess( this );
|
|
|
|
|
proc->setUseShell( true );
|
|
|
|
|
|
|
|
|
|
connect( proc, TQT_SIGNAL( receivedStdout( KProcess *, char *, int ) ),
|
|
|
|
|
this, TQT_SLOT( slotReceivedIPAddresses( KProcess *, char *, int ) ) );
|
|
|
|
|
connect( proc, TQT_SIGNAL( processExited( KProcess * ) ),
|
|
|
|
|
this, TQT_SLOT( slotIPAddressProcessExited( KProcess * ) ) );
|
|
|
|
|
connect( proc, TQT_SIGNAL( receivedStdout( TDEProcess *, char *, int ) ),
|
|
|
|
|
this, TQT_SLOT( slotReceivedIPAddresses( TDEProcess *, char *, int ) ) );
|
|
|
|
|
connect( proc, TQT_SIGNAL( processExited( TDEProcess * ) ),
|
|
|
|
|
this, TQT_SLOT( slotIPAddressProcessExited( TDEProcess * ) ) );
|
|
|
|
|
|
|
|
|
|
*proc << command;
|
|
|
|
|
proc->start( KProcess::NotifyOnExit, KProcess::Stdout );
|
|
|
|
|
proc->start( TDEProcess::NotifyOnExit, TDEProcess::Stdout );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1671,7 +1671,7 @@ void Smb4KScanner::lookupIPAddresses()
|
|
|
|
|
Processes IP addresses if data occurrs on stdout.
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Smb4KScanner::slotReceivedIPAddresses( KProcess *, char *buf, int len )
|
|
|
|
|
void Smb4KScanner::slotReceivedIPAddresses( TDEProcess *, char *buf, int len )
|
|
|
|
|
{
|
|
|
|
|
// WARNING: Do not implement error handling here!!!
|
|
|
|
|
|
|
|
|
@ -1711,7 +1711,7 @@ void Smb4KScanner::slotReceivedIPAddresses( KProcess *, char *buf, int len )
|
|
|
|
|
End IP address scan.
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Smb4KScanner::slotIPAddressProcessExited( KProcess *p )
|
|
|
|
|
void Smb4KScanner::slotIPAddressProcessExited( TDEProcess *p )
|
|
|
|
|
{
|
|
|
|
|
delete p;
|
|
|
|
|
}
|
|
|
|
|