[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/runtime/nepomuk
From: Sebastian Trueg <sebastian () trueg ! de>
Date: 2010-03-18 11:21:55
Message-ID: 20100318112155.DF017AC855 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1104721 by trueg:
* Filewatch service integration: watch mounted media for file operations.
* New DBus method which returns a list of all mount paths that are indexed.
This will be used by the strigi service.
M +3 -0 interfaces/org.kde.nepomuk.RemovableStorage.xml
M +1 -0 services/removablestorage/CMakeLists.txt
M +48 -9 services/removablestorage/removablestorageservice.cpp
M +3 -0 services/removablestorage/removablestorageservice.h
--- trunk/KDE/kdebase/runtime/nepomuk/interfaces/org.kde.nepomuk.RemovableStorage.xml \
#1104720:1104721 @@ -6,5 +6,8 @@
<arg type="s" direction="out"/>
<arg name="url" type="s" direction="in"/>
</method>
+ <method name="currentlyMountedAndIndexed">
+ <arg type="as" direction="out"/>
+ </method>
</interface>
</node>
--- trunk/KDE/kdebase/runtime/nepomuk/services/removablestorage/CMakeLists.txt \
#1104720:1104721 @@ -16,6 +16,7 @@
soprano_add_ontology(SRCS ${SHAREDDESKTOPONTOLOGIES_ROOT_DIR}/nie/nie.trig "NIE" \
"Nepomuk::Vocabulary" "trig")
qt4_add_dbus_interface(SRCS ../../interfaces/org.kde.nepomuk.Strigi.xml \
strigiserviceinterface) +qt4_add_dbus_interface(SRCS \
../../interfaces/org.kde.nepomuk.FileWatch.xml filewatchserviceinterface)
kde4_add_plugin(nepomukremovablestorageservice ${SRCS})
--- trunk/KDE/kdebase/runtime/nepomuk/services/removablestorage/removablestorageservice.cpp \
#1104720:1104721 @@ -20,6 +20,7 @@
#include "nfo.h"
#include "nie.h"
#include "strigiserviceinterface.h"
+#include "filewatchserviceinterface.h"
#include <QtDBus/QDBusConnection>
#include <QtCore/QUuid>
@@ -172,6 +173,26 @@
}
+QStringList Nepomuk::RemovableStorageService::currentlyMountedAndIndexed()
+{
+ if( KConfig( "nepomukstrigirc" ).group( "General" ).readEntry( "index newly \
mounted", false ) ) { + QStringList paths;
+ for ( QHash<QString, Entry>::ConstIterator it = \
m_metadataCache.constBegin(); + it != m_metadataCache.constEnd(); ++it ) \
{ + const Entry& entry = it.value();
+ const Solid::StorageAccess* storage = \
entry.m_device.as<Solid::StorageAccess>(); + if ( storage && \
storage->isAccessible() ) { + paths << storage->filePath();
+ }
+ }
+ return paths;
+ }
+ else {
+ return QStringList();
+ }
+}
+
+
void Nepomuk::RemovableStorageService::initCacheEntries()
{
QList<Solid::Device> devices
@@ -248,14 +269,25 @@
//
entry.m_lastMountPath = \
entry.m_device.as<Solid::StorageAccess>()->filePath();
- //
- // tell Strigi to update the newly mounted device
- //
- if( KConfig( "nepomukstrigirc" ).group( "General" ).readEntry( "index newly \
mounted", false ) ) {
- org::kde::nepomuk::Strigi interface( \
"org.kde.nepomuk.services.nepomukstrigiservice",
- "/nepomukstrigiservice",
- QDBusConnection::sessionBus() );
- interface.indexFolder( entry.m_lastMountPath, false );
+ if ( entry.hasLastMountPath() ) {
+ //
+ // tell the filewatch service that it should monitor the new medium
+ //
+ org::kde::nepomuk::FileWatch( \
"org.kde.nepomuk.services.nepomukfilewatch", + \
"/nepomukfilewatch", + \
QDBusConnection::sessionBus() ) + .watchFolder( entry.m_lastMountPath \
); +
+
+ //
+ // tell Strigi to update the newly mounted device
+ //
+ if( KConfig( "nepomukstrigirc" ).group( "General" ).readEntry( "index \
newly mounted", false ) ) { + org::kde::nepomuk::Strigi( \
"org.kde.nepomuk.services.nepomukstrigiservice", + \
"/nepomukstrigiservice", + \
QDBusConnection::sessionBus() ) + .indexFolder( \
entry.m_lastMountPath, false ); + }
}
//
@@ -284,7 +316,7 @@
}
}
}
- else {
+ else if ( entry.hasLastMountPath() ) {
//
// The first thing we need to do is to inform nepomuk:/ kio slave instances \
that something has changed
// so any caches will be cleared. Otherwise KDirModel and friends might try \
to access the old media URLs @@ -367,6 +399,13 @@
return path;
}
+
+bool Nepomuk::RemovableStorageService::Entry::hasLastMountPath() const
+{
+ return( !m_lastMountPath.isEmpty() &&
+ m_lastMountPath != QLatin1String( "/" ) );
+}
+
NEPOMUK_EXPORT_SERVICE( Nepomuk::RemovableStorageService, \
"nepomukremovablestorageservice")
#include "removablestorageservice.moc"
--- trunk/KDE/kdebase/runtime/nepomuk/services/removablestorage/removablestorageservice.h \
#1104720:1104721 @@ -65,6 +65,8 @@
*/
Q_SCRIPTABLE QString resourceUriFromLocalFileUrl( const QString& url );
+ Q_SCRIPTABLE QStringList currentlyMountedAndIndexed();
+
private Q_SLOTS:
void slotSolidDeviceAdded( const QString& udi );
void slotSolidDeviceRemoved( const QString& udi );
@@ -89,6 +91,7 @@
KUrl constructRelativeUrl( const QString& path ) const;
QString constructLocalPath( const KUrl& filexUrl ) const;
+ bool hasLastMountPath() const;
Solid::Device m_device;
QString m_lastMountPath;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic