Message info
 
To:kde-commits@kde.org From:Alexander Reinholdt Subject:playground/network/smb4k/core Date:Sun, 18 Mar 2012 17:59:52 +0100 (CET)
 

SVN commit 1286200 by areinholdt:

- Add lookup() function.
- Only modify cursor if Smb4KGlobal::modifyCursor() is true.


M +57 -9 smb4kscanner.cpp
M +13 -0 smb4kscanner.h


--- trunk/playground/network/smb4k/core/smb4kscanner.cpp #1286199:1286200
@@ -486,7 +486,7 @@
connect( job, SIGNAL( finished() ), SLOT( slotDomainsLookupFinished() ) );
connect( job, SIGNAL( workgroups( const QList<Smb4KWorkgroup> & ) ), SLOT( slotWorkgroups( const QList<Smb4KWorkgroup> & ) ) );

- if ( !hasSubjobs() )
+ if ( !hasSubjobs() && modifyCursor() )
{
QApplication::setOverrideCursor( Qt::BusyCursor );
}
@@ -511,7 +511,7 @@
connect( job, SIGNAL( workgroups( const QList<Smb4KWorkgroup> & ) ), SLOT( slotWorkgroups( const QList<Smb4KWorkgroup> & ) ) );
connect( job, SIGNAL( authError( Smb4KQueryMasterJob * ) ), SLOT( slotAuthError( Smb4KQueryMasterJob * ) ) );

- if ( !hasSubjobs() )
+ if ( !hasSubjobs() && modifyCursor() )
{
QApplication::setOverrideCursor( Qt::BusyCursor );
}
@@ -549,7 +549,7 @@
connect( job, SIGNAL( workgroups( const QList<Smb4KWorkgroup> & ) ), SLOT( slotWorkgroups( const QList<Smb4KWorkgroup> & ) ) );
connect( job, SIGNAL( authError( Smb4KQueryMasterJob * ) ), SLOT( slotAuthError( Smb4KQueryMasterJob * ) ) );

- if ( !hasSubjobs() )
+ if ( !hasSubjobs() && modifyCursor() )
{
QApplication::setOverrideCursor( Qt::BusyCursor );
}
@@ -576,7 +576,7 @@
connect( job, SIGNAL( workgroups( const QList<Smb4KWorkgroup> & ) ), SLOT( slotWorkgroups( const QList<Smb4KWorkgroup> & ) ) );
connect( job, SIGNAL( hosts( const QList<Smb4KHost> & ) ), SLOT( slotHosts( const QList<Smb4KHost> & ) ) );

- if ( !hasSubjobs() )
+ if ( !hasSubjobs() && modifyCursor() )
{
QApplication::setOverrideCursor( Qt::BusyCursor );
}
@@ -616,7 +616,7 @@
connect( job, SIGNAL( hosts( Smb4KWorkgroup *, const QList<Smb4KHost> & ) ), SLOT( slotHosts( Smb4KWorkgroup *, const QList<Smb4KHost> & ) ) );
connect( job, SIGNAL( authError( Smb4KLookupDomainMembersJob * ) ), SLOT( slotAuthError( Smb4KLookupDomainMembersJob * ) ) );

- if ( !hasSubjobs() )
+ if ( !hasSubjobs() && modifyCursor() )
{
QApplication::setOverrideCursor( Qt::BusyCursor );
}
@@ -645,7 +645,7 @@
connect( job, SIGNAL( shares( Smb4KHost *, const QList<Smb4KShare> & ) ), SLOT( slotShares( Smb4KHost *, const QList<Smb4KShare> &) ) );
connect( job, SIGNAL( authError( Smb4KLookupSharesJob * ) ), SLOT( slotAuthError( Smb4KLookupSharesJob * ) ) );

- if ( !hasSubjobs() )
+ if ( !hasSubjobs() && modifyCursor() )
{
QApplication::setOverrideCursor( Qt::BusyCursor );
}
@@ -687,7 +687,7 @@
connect( job, SIGNAL( finished( Smb4KHost * ) ), SLOT( slotSharesLookupFinished( Smb4KHost * ) ) );
connect( job, SIGNAL( info( Smb4KHost * ) ), SLOT( slotInfo( Smb4KHost * ) ) );

- if ( !hasSubjobs() )
+ if ( !hasSubjobs() && modifyCursor() )
{
QApplication::setOverrideCursor( Qt::BusyCursor );
}
@@ -720,7 +720,55 @@
}


+void Smb4KScanner::lookup( const QUrl& url, int type )
+{
+ switch ( type )
+ {
+ case Smb4KNetworkObject::Unknown:
+ {
+ lookupDomains();
+ break;
+ }
+ case Smb4KNetworkObject::Workgroup:
+ {
+ // Check if the workgroup is known.
+ Smb4KWorkgroup *workgroup = findWorkgroup( url.host().toUpper() );

+ if ( workgroup )
+ {
+ lookupDomainMembers( workgroup );
+ }
+ else
+ {
+ // Do nothing
+ }
+ break;
+ }
+ case Smb4KNetworkObject::Host:
+ {
+ // Check if the host is known.
+ Smb4KHost *host = findHost( url.host().toUpper() );
+
+ if ( host )
+ {
+ lookupShares( host );
+ }
+ else
+ {
+ // Do nothing
+ }
+ break;
+ }
+ default:
+ {
+ // Shares are ignored
+ break;
+ }
+ }
+}
+
+
+
void Smb4KScanner::timerEvent( QTimerEvent */*e*/ )
{
if ( Smb4KSettings::periodicScanning() )
@@ -865,7 +913,7 @@
{
removeSubjob( job );

- if ( !hasSubjobs() )
+ if ( !hasSubjobs() && modifyCursor() )
{
QApplication::restoreOverrideCursor();
}
@@ -913,7 +961,7 @@
connect( job, SIGNAL( workgroups( const QList<Smb4KWorkgroup> & ) ), SLOT( slotWorkgroups( const QList<Smb4KWorkgroup> & ) ) );
connect( job, SIGNAL( authError( Smb4KQueryMasterJob * ) ), SLOT( slotAuthError( Smb4KQueryMasterJob * ) ) );

- if ( !hasSubjobs() )
+ if ( !hasSubjobs() && modifyCursor() )
{
QApplication::setOverrideCursor( Qt::BusyCursor );
}
--- trunk/playground/network/smb4k/core/smb4kscanner.h #1286199:1286200
@@ -203,6 +203,19 @@
*/
QDeclarativeListProperty<Smb4KNetworkObject> shares();

+ /**
+ * This function takes a QUrl object and initiates a network scan depending
+ * on the type of the network item.
+ *
+ * Please note that this function only works with network objects that are
+ * already known. All others will be ignored.
+ *
+ * @param url The URL of the network item
+ *
+ * @param type The type of the network item
+ */
+ Q_INVOKABLE void lookup( const QUrl &url, int type );
+
protected:
/**
* Reimplemented from QObject