19 #include <Nepomuk2/Variant>
20 #include <Nepomuk2/Tag>
21 #include <Soprano/Vocabulary/RDF>
22 #include <Nepomuk2/Vocabulary/NDO>
23 #include <Nepomuk2/Vocabulary/NFO>
24 #include <Nepomuk2/Vocabulary/NIE>
26 using namespace Nepomuk2::Vocabulary;
41 foreach (
const KUrl &destination, m_transfer->
files()) {
42 fileItems << KFileItem(KFileItem::Unknown, KFileItem::Unknown, destination,
true);
49 QList<KUrl> usedFiles = (files.isEmpty() ? m_transfer->
files() : files);
52 foreach(
const KUrl &usedFile, usedFiles) {
53 fileUrls.push_back(usedFile);
56 KGet::nepomukController()->setProperties(fileUrls, properties);
61 QList<QUrl> destinations;
63 foreach(
const KUrl &url, m_transfer->
files()) {
64 destinations.push_back(url);
67 const QUrl src = m_transfer->
source();
68 const QUrl srcType = (src.isLocalFile() ? NFO::FileDataObject() : NFO::RemoteDataObject());
69 Nepomuk2::Resource srcFileRes(src);
71 srcFileRes.setProperty(Soprano::Vocabulary::RDF::type(), srcType);
73 foreach (
const QUrl &destination, destinations) {
75 Nepomuk2::Resource destinationRes(destination);
76 QList<QPair<QUrl, Nepomuk2::Variant> > properties;
77 properties.append(qMakePair(NDO::copiedFrom(), Nepomuk2::Variant(srcFileRes.uri())));
82 QList<Nepomuk2::Variant> hashes;
83 foreach (
const Checksum &checksum, checksums) {
85 const QString hash = checksum.second;
86 if (!hashType.isEmpty() && !hash.isEmpty()) {
87 Nepomuk2::Resource hashRes(hash, NFO::FileHash());
88 hashRes.addProperty(NFO::hashAlgorithm(), hashType);
89 hashRes.addProperty(NFO::hashValue(), hash);
90 hashRes.setLabel(hashType);
94 if (!hashes.isEmpty()) {
95 properties.append(qMakePair(NFO::hasHash(), Nepomuk2::Variant(hashes)));
99 KGet::nepomukController()->setProperties(QList<QUrl>() << destinationRes.uri() , properties);
103 KGet::nepomukController()->addTags(destinations, m_transfer->
group()->tags());
112 KGet::nepomukController()->removeResource(m_transfer->
files());
115 #include "nepomukhandler.moc"
const KUrl & source() const
QList< Checksum > availableChecksums() const
Returns all set checksums.
QPair< QString, QString > Checksum
void saveFileProperties()
void setProperties(const QList< QPair< QUrl, Nepomuk2::Variant > > &properties, const QList< KUrl > &files=QList< KUrl >())
Sets properties to a list of files, if the list is empty m_destinations is used.
TransferGroup * group() const
The owner group.
NepomukHandler(Transfer *transfer)
KFileItemList fileItems() const
void deinit()
Removes the resource if the isValid() is false.
static QString cleanChecksumType(const QString &type)
Cleans the checksum type, that it should match the official name, i.e.
virtual QList< KUrl > files() const
virtual Verifier * verifier(const KUrl &file)
virtual ~NepomukHandler()