Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117748050
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
28 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/file/cleaner/CMakeLists.txt b/src/file/cleaner/CMakeLists.txt
index 93347e8e..d09c672a 100644
--- a/src/file/cleaner/CMakeLists.txt
+++ b/src/file/cleaner/CMakeLists.txt
@@ -1,22 +1,24 @@
set(CLEANER_SRCS
main.cpp
cleaner.cpp
../priority.cpp
../database.cpp
../commitqueue.cpp
../fileindexerconfig.cpp
+ ../storagedevices.cpp
../regexpcache.cpp
../fileexcludefilters.cpp
)
add_executable(baloo_file_cleaner ${CLEANER_SRCS})
target_link_libraries(baloo_file_cleaner
Qt5::Sql
Qt5::DBus
KF5::KIOCore
${XAPIAN_LIBRARIES}
KF5::BalooXapian
+ KF5::Solid
)
install(TARGETS baloo_file_cleaner DESTINATION ${BIN_INSTALL_DIR})
diff --git a/src/file/extractor/CMakeLists.txt b/src/file/extractor/CMakeLists.txt
index 7db6530a..0a446b7d 100644
--- a/src/file/extractor/CMakeLists.txt
+++ b/src/file/extractor/CMakeLists.txt
@@ -1,32 +1,34 @@
remove_definitions(-DTRANSLATION_DOMAIN=\"baloo_file\")
add_definitions(-DTRANSLATION_DOMAIN=\"baloo_file_extractor\")
set(EXTRACTOR_SRCS
main.cpp
app.cpp
result.cpp
../priority.cpp
../basicindexingjob.cpp
../database.cpp
../util.cpp
../fileindexerconfig.cpp
+ ../storagedevices.cpp
../regexpcache.cpp
../fileexcludefilters.cpp
)
add_executable(baloo_file_extractor ${EXTRACTOR_SRCS})
target_link_libraries(baloo_file_extractor
Qt5::Sql
Qt5::DBus
KF5::FileMetaData
KF5::I18n
KF5::ConfigCore
+ KF5::Solid
${XAPIAN_LIBRARIES}
KF5::BalooFiles
KF5::BalooXapian
)
install(TARGETS baloo_file_extractor DESTINATION ${BIN_INSTALL_DIR})
add_subdirectory(autotests)
diff --git a/src/file/fileindexerconfig.cpp b/src/file/fileindexerconfig.cpp
index 4d2dc520..0df8d946 100644
--- a/src/file/fileindexerconfig.cpp
+++ b/src/file/fileindexerconfig.cpp
@@ -1,322 +1,335 @@
/* This file is part of the KDE Project
Copyright (c) 2008-2010 Sebastian Trueg <trueg@kde.org>
Copyright (c) 2013-2014 Vishesh Handa <me@vhanda.in>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "fileindexerconfig.h"
#include "fileexcludefilters.h"
+#include "storagedevices.h"
#include <QUrl>
#include <QStringList>
#include <QDir>
#include <KDirWatch>
#include <QStandardPaths>
#include <KConfigGroup>
#include <QDebug>
namespace
{
/// recursively check if a folder is hidden
bool isDirHidden(QDir& dir)
{
#ifdef __unix__
return dir.absolutePath().contains(QLatin1String("/."));
#else
if (QFileInfo(dir.path()).isHidden())
return true;
else if (dir.cdUp())
return isDirHidden(dir);
else
return false;
#endif
}
}
using namespace Baloo;
FileIndexerConfig::FileIndexerConfig(QObject* parent)
: QObject(parent)
, m_config(QLatin1String("baloofilerc"), KConfig::SimpleConfig)
, m_indexHidden(false)
+ , m_devices(new StorageDevices(this))
{
KDirWatch* dirWatch = KDirWatch::self();
connect(dirWatch, SIGNAL(dirty(QString)),
this, SLOT(slotConfigDirty()));
connect(dirWatch, SIGNAL(created(QString)),
this, SLOT(slotConfigDirty()));
dirWatch->addFile(QStandardPaths::locate(QStandardPaths::ConfigLocation, m_config.name()));
forceConfigUpdate();
}
FileIndexerConfig::~FileIndexerConfig()
{
}
QStringList FileIndexerConfig::includeFolders() const
{
QStringList fl;
for (int i = 0; i < m_folderCache.count(); ++i) {
if (m_folderCache[i].second)
fl << m_folderCache[i].first;
}
return fl;
}
QStringList FileIndexerConfig::excludeFolders() const
{
QStringList fl;
for (int i = 0; i < m_folderCache.count(); ++i) {
if (!m_folderCache[i].second)
fl << m_folderCache[i].first;
}
return fl;
}
QStringList FileIndexerConfig::excludeFilters() const
{
KConfigGroup cfg = m_config.group("General");
// read configured exclude filters
QSet<QString> filters = cfg.readEntry("exclude filters", defaultExcludeFilterList()).toSet();
// make sure we always keep the latest default exclude filters
// TODO: there is one problem here. What if the user removed some of the default filters?
if (cfg.readEntry("exclude filters version", 0) < defaultExcludeFilterListVersion()) {
filters += defaultExcludeFilterList().toSet();
// write the config directly since the KCM does not have support for the version yet
// TODO: make this class public and use it in the KCM
KConfig config(m_config.name());
KConfigGroup cfg = config.group("General");
cfg.writeEntry("exclude filters", QStringList::fromSet(filters));
cfg.writeEntry("exclude filters version", defaultExcludeFilterListVersion());
}
// remove duplicates
return QStringList::fromSet(filters);
}
bool FileIndexerConfig::indexHiddenFilesAndFolders() const
{
return m_indexHidden;
}
void FileIndexerConfig::slotConfigDirty()
{
forceConfigUpdate();
Q_EMIT configChanged();
}
bool FileIndexerConfig::isInitialRun() const
{
return m_config.group("General").readEntry("first run", true);
}
bool FileIndexerConfig::shouldBeIndexed(const QString& path) const
{
QFileInfo fi(path);
if (fi.isDir()) {
return shouldFolderBeIndexed(path);
} else {
return (shouldFolderBeIndexed(fi.absolutePath()) &&
(!fi.isHidden() || indexHiddenFilesAndFolders()) &&
shouldFileBeIndexed(fi.fileName()));
}
}
bool FileIndexerConfig::shouldFolderBeIndexed(const QString& path) const
{
QString folder;
if (folderInFolderList(path, folder)) {
// we always index the folders in the list
// ignoring the name filters
if (folder == path)
return true;
// check for hidden folders
QDir dir(path);
if (!indexHiddenFilesAndFolders() && isDirHidden(dir))
return false;
// reset dir, cause isDirHidden modifies the QDir
dir = path;
// check the exclude filters for all components of the path
// after folder
const QStringList pathComponents = path.mid(folder.count()).split(QLatin1Char('/'), QString::SkipEmptyParts);
Q_FOREACH (const QString& c, pathComponents) {
if (!shouldFileBeIndexed(c)) {
return false;
}
}
return true;
} else {
return false;
}
}
bool FileIndexerConfig::shouldFileBeIndexed(const QString& fileName) const
{
// check the filters
return !m_excludeFilterRegExpCache.exactMatch(fileName);
}
bool FileIndexerConfig::shouldMimeTypeBeIndexed(const QString& mimeType) const
{
return !m_excludeMimetypes.contains(mimeType);
}
bool FileIndexerConfig::folderInFolderList(const QString& path)
{
QString str;
return folderInFolderList(path, str);
}
bool FileIndexerConfig::folderInFolderList(const QString& path, QString& folder) const
{
const QString p = QUrl(path).adjusted(QUrl::StripTrailingSlash).path();
// we traverse the list backwards to catch all exclude folders
int i = m_folderCache.count();
while (--i >= 0) {
const QString& f = m_folderCache[i].first;
const bool include = m_folderCache[i].second;
if (p.startsWith(f)) {
folder = f;
return include;
}
}
// path is not in the list, thus it should not be included
folder.clear();
return false;
}
namespace
{
/**
* Returns true if the specified folder f would already be excluded using the list
* folders.
*/
bool alreadyExcluded(const QList<QPair<QString, bool> >& folders, const QString& f)
{
bool included = false;
for (int i = 0; i < folders.count(); ++i) {
QString path = QUrl(folders[i].first).path();
if (!path.endsWith(QLatin1Char('/')))
path.append(QLatin1Char('/'));
if (f != folders[i].first && f.startsWith(path)) {
included = folders[i].second;
}
}
return !included;
}
/**
* Simple insertion sort
*/
void insertSortFolders(const QStringList& folders, bool include, QList<QPair<QString, bool> >& result)
{
Q_FOREACH (const QString& f, folders) {
int pos = 0;
QString path = QUrl(f).adjusted(QUrl::StripTrailingSlash).path();
while (result.count() > pos &&
result[pos].first < path)
++pos;
result.insert(pos, qMakePair(path, include));
}
}
/**
* Remove useless exclude entries which would confuse the folderInFolderList algo.
* This makes sure all top-level items are include folders.
* This runs in O(n^2) and could be optimized but what for.
*/
void cleanupList(QList<QPair<QString, bool> >& result)
{
int i = 0;
while (i < result.count()) {
if (result[i].first.isEmpty() ||
(!result[i].second &&
alreadyExcluded(result, result[i].first)))
result.removeAt(i);
else
++i;
}
}
}
void FileIndexerConfig::buildFolderCache()
{
KConfigGroup group = m_config.group("General");
QStringList includeFoldersPlain = group.readPathEntry("folders", QStringList() << QDir::homePath());
QStringList excludeFoldersPlain = group.readPathEntry("exclude folders", QStringList());
+ // Add all removable media and network shares as ignored unless they have
+ // been explicitly added in the include list
+ for (auto device: m_devices->allMedia()) {
+ const QString mountPath = device.mountPath();
+ if (!device.isUsable() && !mountPath.isEmpty()) {
+ if (!includeFoldersPlain.contains(mountPath)) {
+ excludeFoldersPlain << mountPath;
+ }
+ }
+ }
+
m_folderCache.clear();
insertSortFolders(includeFoldersPlain, true, m_folderCache);
insertSortFolders(excludeFoldersPlain, false, m_folderCache);
cleanupList(m_folderCache);
}
void FileIndexerConfig::buildExcludeFilterRegExpCache()
{
QStringList newFilters = excludeFilters();
m_excludeFilterRegExpCache.rebuildCacheFromFilterList(newFilters);
}
void FileIndexerConfig::buildMimeTypeCache()
{
m_excludeMimetypes = m_config.group("General").readPathEntry("exclude mimetypes", defaultExcludeMimetypes()).toSet();
}
void FileIndexerConfig::forceConfigUpdate()
{
m_config.reparseConfiguration();
buildFolderCache();
buildExcludeFilterRegExpCache();
buildMimeTypeCache();
m_indexHidden = m_config.group("General").readEntry("index hidden folders", false);
}
void FileIndexerConfig::setInitialRun(bool isInitialRun)
{
m_config.group("General").writeEntry("first run", isInitialRun);
m_config.sync();
}
bool FileIndexerConfig::initialUpdateDisabled() const
{
return m_config.group("General").readEntry("disable initial update", true);
}
diff --git a/src/file/fileindexerconfig.h b/src/file/fileindexerconfig.h
index f37bb69e..6b28e89f 100644
--- a/src/file/fileindexerconfig.h
+++ b/src/file/fileindexerconfig.h
@@ -1,178 +1,183 @@
/*
Copyright (c) 2008-2009 Sebastian Trueg <trueg@kde.org>
Copyright (c) 2012-2014 Vishesh Handa <me@vhanda.in>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _BALOO_FILEINDEXER_SERVICE_CONFIG_H_
#define _BALOO_FILEINDEXER_SERVICE_CONFIG_H_
#include <QtCore/QObject>
#include <QtCore/QList>
#include <QtCore/QSet>
#include <kconfig.h>
#include "regexpcache.h"
namespace Baloo
{
+
+class StorageDevices;
+
/**
* Active config class which emits signals if the config
* was changed, for example if the KCM saved the config file.
*/
class FileIndexerConfig : public QObject
{
Q_OBJECT
public:
/**
* Create a new file indexr config.
*/
FileIndexerConfig(QObject* parent = 0);
~FileIndexerConfig();
/**
* The folders to search for files to analyze. Cached and cleaned up.
*/
QStringList includeFolders() const;
/**
* The folders that should be excluded. Cached and cleaned up.
* It is perfectly possible to include subfolders again.
*/
QStringList excludeFolders() const;
QStringList excludeFilters() const;
bool indexHiddenFilesAndFolders() const;
/**
* true the first time the service is run (or after manually
* tampering with the config.
*/
bool isInitialRun() const;
/**
* A "hidden" config option which allows to disable the initial
* update of all indexed folders.
*
* This should be used in combination with isInitialRun() to make
* sure all folders are at least indexed once.
*/
bool initialUpdateDisabled() const;
/**
* Check if \p path should be indexed taking into account
* the includeFolders(), the excludeFolders(), and the
* excludeFilters().
*
* Be aware that this method does not check if parent dirs
* match any of the exclude filters. Only the name of the
* dir itself it checked.
*
* \return \p true if the file or folder at \p path should
* be indexed according to the configuration.
*/
bool shouldBeIndexed(const QString& path) const;
/**
* Check if the folder at \p path should be indexed.
*
* Be aware that this method does not check if parent dirs
* match any of the exclude filters. Only the name of the
* dir itself it checked.
*
* \return \p true if the folder at \p path should
* be indexed according to the configuration.
*/
bool shouldFolderBeIndexed(const QString& path) const;
/**
* Check \p fileName for all exclude filters. This does
* not take file paths into account.
*
* \return \p true if a file with name \p filename should
* be indexed according to the configuration.
*/
bool shouldFileBeIndexed(const QString& fileName) const;
/**
* Checks if \p mimeType should be indexed
*
* \return \p true if the mimetype should be indexed according
* to the configuration
*/
bool shouldMimeTypeBeIndexed(const QString& mimeType) const;
/**
* Returns true if the folder is in the list indexed directories
* and not in the list of exclude directories
*/
bool folderInFolderList(const QString& path);
Q_SIGNALS:
void configChanged();
public Q_SLOTS:
/**
* Reread the config from disk and update the configuration cache.
* This is only required for testing as normally the config updates
* itself whenever the config file on disk changes.
*
* \return \c true if the config has actually changed
*/
void forceConfigUpdate();
/**
* Should be called once the initial indexing is done, ie. all folders
* have been indexed.
*/
void setInitialRun(bool isInitialRun);
private Q_SLOTS:
void slotConfigDirty();
private:
/**
* Check if \p path is in the list of folders to be indexed taking
* include and exclude folders into account.
* \p folder is set to the folder which was the reason for the descision.
*/
bool folderInFolderList(const QString& path, QString& folder) const;
void buildFolderCache();
void buildExcludeFilterRegExpCache();
void buildMimeTypeCache();
KConfig m_config;
/// Caching cleaned up list (no duplicates, no useless entries, etc.)
QList<QPair<QString, bool> > m_folderCache;
/// cache of regexp objects for all exclude filters
/// to prevent regexp parsing over and over
RegExpCache m_excludeFilterRegExpCache;
/// A set of mimetypes which should never be indexed
QSet<QString> m_excludeMimetypes;
bool m_indexHidden;
+
+ StorageDevices* m_devices;
};
}
#endif
diff --git a/src/file/lib/CMakeLists.txt b/src/file/lib/CMakeLists.txt
index 35b1b073..ab9ec780 100644
--- a/src/file/lib/CMakeLists.txt
+++ b/src/file/lib/CMakeLists.txt
@@ -1,73 +1,74 @@
set(FILE_LIB_SRCS
file.cpp
filefetchjob.cpp
filemodifyjob.cpp
filemapping.cpp
filemonitor.cpp
taglistjob.cpp
db.cpp
indexerconfig.cpp
../fileindexerconfig.cpp
+ ../storagedevices.cpp
../regexpcache.cpp
../fileexcludefilters.cpp
)
add_library(KF5BalooFiles ${FILE_LIB_SRCS})
add_library(KF5::BalooFiles ALIAS KF5BalooFiles)
target_link_libraries(KF5BalooFiles
PUBLIC
Qt5::Core
KF5::CoreAddons
KF5::FileMetaData
PRIVATE
KF5::ConfigCore
Qt5::DBus
Qt5::Sql
KF5::Solid
${XAPIAN_LIBRARIES}
KF5::BalooCore
KF5::BalooXapian
)
set_target_properties(KF5BalooFiles PROPERTIES
VERSION ${BALOO_VERSION_STRING}
SOVERSION ${BALOO_SOVERSION}
EXPORT_NAME BalooFiles
)
target_include_directories(KF5BalooFiles INTERFACE "$<INSTALL_INTERFACE:${KF5_INCLUDE_INSTALL_DIR}/Baloo>")
generate_export_header(KF5BalooFiles BASE_NAME BALOO_FILE EXPORT_FILE_NAME file_export.h)
install(TARGETS KF5BalooFiles EXPORT KF5BalooTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
ecm_generate_headers(KF5BalooFiles_CamelCase_HEADERS
HEADER_NAMES
File
FileFetchJob
FileModifyjob
FileMonitor
TagListJob
IndexerConfig
PREFIX baloo
REQUIRED_HEADERS KF5BalooFiles_HEADERS
)
install(FILES
${KF5BalooFiles_CamelCase_HEADERS}
DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/Baloo/Baloo
COMPONENT Devel
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/file_export.h
${KF5BalooFiles_HEADERS}
DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/Baloo/baloo
COMPONENT Devel
)
add_subdirectory(autotests)
diff --git a/src/file/storagedevices.cpp b/src/file/storagedevices.cpp
index d81dfb43..43834a81 100644
--- a/src/file/storagedevices.cpp
+++ b/src/file/storagedevices.cpp
@@ -1,186 +1,190 @@
/*
This file is part of the KDE Baloo project.
Copyright (C) 2011 Sebastian Trueg <trueg@kde.org>
Copyright (C) 2014 Vishesh Handa <vhanda@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "storagedevices.h"
#include <Solid/DeviceNotifier>
#include <Solid/DeviceInterface>
#include <Solid/Block>
#include <Solid/Device>
#include <Solid/StorageDrive>
#include <Solid/StorageVolume>
#include <Solid/StorageAccess>
#include <Solid/NetworkShare>
#include <Solid/OpticalDisc>
#include <Solid/Predicate>
#include <QDebug>
using namespace Baloo;
StorageDevices::StorageDevices(QObject* parent)
: QObject(parent)
{
initCacheEntries();
connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceAdded(QString)),
this, SLOT(slotSolidDeviceAdded(QString)));
connect(Solid::DeviceNotifier::instance(), SIGNAL(deviceRemoved(QString)),
this, SLOT(slotSolidDeviceRemoved(QString)));
}
StorageDevices::~StorageDevices()
{
}
void StorageDevices::initCacheEntries()
{
QList<Solid::Device> devices
= Solid::Device::listFromQuery(QLatin1String("StorageVolume.usage=='FileSystem'"))
+ Solid::Device::listFromType(Solid::DeviceInterface::NetworkShare);
Q_FOREACH (const Solid::Device& dev, devices) {
createCacheEntry(dev);
}
}
QList<StorageDevices::Entry> StorageDevices::allMedia() const
{
return m_metadataCache.values();
}
StorageDevices::Entry* StorageDevices::createCacheEntry(const Solid::Device& dev)
{
Entry entry(dev);
if (dev.udi().isEmpty())
return 0;
auto it = m_metadataCache.insert(dev.udi(), entry);
const Solid::StorageAccess* storage = dev.as<Solid::StorageAccess>();
connect(storage, SIGNAL(accessibilityChanged(bool,QString)),
this, SLOT(slotAccessibilityChanged(bool,QString)));
//connect(storage, SIGNAL(teardownRequested(QString)),
// this, SLOT(slotTeardownRequested(QString)));
return &it.value();
}
bool StorageDevices::isEmpty() const
{
return m_metadataCache.isEmpty();
}
void StorageDevices::slotSolidDeviceAdded(const QString& udi)
{
qDebug() << udi;
Entry* e = createCacheEntry(Solid::Device(udi));
if (e) {
Q_EMIT deviceAdded(e);
}
}
void StorageDevices::slotSolidDeviceRemoved(const QString& udi)
{
QHash< QString, Entry >::iterator it = m_metadataCache.find(udi);
if (it != m_metadataCache.end()) {
qDebug() << "Found removable storage volume for Baloo undocking:" << udi;
Q_EMIT deviceRemoved(&it.value());
m_metadataCache.erase(it);
}
}
void StorageDevices::slotAccessibilityChanged(bool accessible, const QString& udi)
{
qDebug() << accessible << udi;
Q_UNUSED(accessible);
//
// cache new mount path
//
Entry* entry = &m_metadataCache[udi];
Q_ASSERT(entry != 0);
Q_EMIT deviceAccessibilityChanged(entry);
}
StorageDevices::Entry::Entry()
{
}
StorageDevices::Entry::Entry(const Solid::Device& device)
: m_device(device)
{
}
QString StorageDevices::Entry::mountPath() const
{
if (const Solid::StorageAccess* sa = m_device.as<Solid::StorageAccess>()) {
return sa->filePath();
} else {
return QString();
}
}
bool StorageDevices::Entry::isMounted() const
{
if (const Solid::StorageAccess* sa = m_device.as<Solid::StorageAccess>()) {
return sa->isAccessible();
} else {
return false;
}
}
bool StorageDevices::Entry::isUsable() const
{
+ if (mountPath().isEmpty()) {
+ return false;
+ }
+
bool usable = true;
const Solid::Device& dev = m_device;
if (dev.is<Solid::StorageVolume>() && dev.parent().is<Solid::StorageDrive>()) {
auto parent = dev.parent().as<Solid::StorageDrive>();
if (parent->isRemovable() || parent->isHotpluggable()) {
usable = false;
}
const Solid::StorageVolume* volume = dev.as<Solid::StorageVolume>();
if (volume->isIgnored() || volume->usage() != Solid::StorageVolume::FileSystem) {
usable = false;
}
}
if (dev.is<Solid::NetworkShare>()) {
usable = false;
} else if (dev.is<Solid::OpticalDisc>()) {
usable = false;
}
if (usable) {
if (const Solid::StorageAccess* sa = dev.as<Solid::StorageAccess>()) {
usable = sa->isAccessible();
}
}
return usable;
}
diff --git a/src/file/storagedevices.h b/src/file/storagedevices.h
index e4b91c88..1e8e2ce1 100644
--- a/src/file/storagedevices.h
+++ b/src/file/storagedevices.h
@@ -1,97 +1,95 @@
/*
This file is part of the KDE Baloo project.
Copyright (C) 2011 Sebastian Trueg <trueg@kde.org>
Copyright (C) 2014 Vishesh Handa <vhanda@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) version 3, or any
later version accepted by the membership of KDE e.V. (or its
successor approved by the membership of KDE e.V.), which shall
act as a proxy defined in Section 6 of version 3 of the license.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef REMOVABLEMEDIACACHE_H
#define REMOVABLEMEDIACACHE_H
#include <QObject>
-#include <QMutex>
-#include <QSet>
#include <Solid/Device>
-#include <QUrl>
-
-
namespace Baloo
{
/**
* The removable media cache
* media that are supported by Baloo.
*/
class StorageDevices : public QObject
{
Q_OBJECT
public:
StorageDevices(QObject* parent = 0);
~StorageDevices();
class Entry
{
public:
Entry();
Entry(const Solid::Device& device);
Solid::Device device() const {
return m_device;
}
bool isMounted() const;
QString mountPath() const;
/**
* Returns true if Baloo should be indexing this
* Currently we only index permanentaly mounted media
*/
bool isUsable() const;
+ QString udi() const {
+ return m_device.udi();
+ }
private:
Solid::Device m_device;
};
QList<Entry> allMedia() const;
bool isEmpty() const;
Q_SIGNALS:
void deviceAdded(const Baloo::StorageDevices::Entry* entry);
void deviceRemoved(const Baloo::StorageDevices::Entry* entry);
void deviceAccessibilityChanged(const Baloo::StorageDevices::Entry* entry);
private Q_SLOTS:
void slotSolidDeviceAdded(const QString& udi);
void slotSolidDeviceRemoved(const QString& udi);
void slotAccessibilityChanged(bool accessible, const QString& udi);
private:
void initCacheEntries();
Entry* createCacheEntry(const Solid::Device& dev);
/// maps Solid UDI to Entry
QHash<QString, Entry> m_metadataCache;
};
} // namespace Baloo
#endif // REMOVABLEMEDIACACHE_H
diff --git a/src/file/tests/CMakeLists.txt b/src/file/tests/CMakeLists.txt
index 5b770cf9..d2ef6efb 100644
--- a/src/file/tests/CMakeLists.txt
+++ b/src/file/tests/CMakeLists.txt
@@ -1,62 +1,62 @@
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
)
add_executable(indexerconfigtest
indexerconfigtest.cpp)
target_link_libraries(indexerconfigtest
Qt5::Core
KF5::CoreAddons
KF5::ConfigCore
KF5::BalooCore
baloofilecommon
)
add_executable(basicindexingqueuetest-manual
basicindexingqueuetest.cpp
)
target_link_libraries(basicindexingqueuetest-manual
Qt5::Core
Qt5::Sql
KF5::FileMetaData
KF5::KIOCore
KF5::ConfigCore
${XAPIAN_LIBRARIES}
KF5::BalooCore
KF5::BalooXapian
baloofilecommon
)
add_executable(fileindexingqueuetest-manual
fileindexingqueuetest.cpp
fileextractor.cpp
)
target_link_libraries(fileindexingqueuetest-manual
Qt5::Core
Qt5::Sql
KF5::FileMetaData
KF5::KIOCore
KF5::ConfigCore
${XAPIAN_LIBRARIES}
KF5::BalooCore
KF5::BalooXapian
baloofilecommon
)
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
if(BUILD_KINOTIFY)
add_executable(inotifytest inotify.cpp ../kinotify.cpp)
target_link_libraries(inotifytest
Qt5::Core
)
endif()
endif(CMAKE_SYSTEM_NAME MATCHES "Linux")
#
# Storage Devices
#
-add_executable(storagedevicestest storagedevicestest.cpp ../storagedevices.cpp)
-target_link_libraries(storagedevicestest Qt5::Core KF5::Solid)
+add_executable(storagedevicestest storagedevicestest.cpp)
+target_link_libraries(storagedevicestest Qt5::Core KF5::Solid baloofilecommon)
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Apr 4, 12:45 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18820034
Default Alt Text
(28 KB)
Attached To
Mode
rKB baloo
Attached
Detach File
Event Timeline