~ubuntu-branches/ubuntu/oneiric/kdenetwork/oneiric-updates

« back to all changes in this revision

Viewing changes to kget/core/nepomukhandler.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac, Philip Muškovac
  • Date: 2011-07-10 12:36:35 UTC
  • mfrom: (1.1.59 upstream)
  • Revision ID: package-import@ubuntu.com-20110710123635-3db9oyxdswp4sp1e
Tags: 4:4.6.90-0ubuntu1
* New upstream release
 - Bump on kde-sc-dev-latest
 - s/kdebase-runtime-dev/kde-runtime-dev
* Dropped kubuntu_05_samba_sharing.diff <- went upstream
* Added kubuntu_05_make_old_symbols_reappear_and_fix_building.diff
* Refreshed *.install
* Refreshed symbols

[ Philip Muškovac ]
* fix debug package depends on kdebase-runtime-dbg -> kde-runtime-dbg 
  and recommends on kde-workspace-dbg

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
#include "nepomukcontroller.h"
17
17
#include "verifier.h"
18
18
 
19
 
#include "nfo.h"
20
 
#include "ndo.h"
21
 
#include "nie.h"
22
 
#include <Soprano/Vocabulary/Xesam>
23
19
#include <Nepomuk/Variant>
24
20
#include <Nepomuk/Tag>
 
21
#include <Nepomuk/Vocabulary/NDO>
 
22
#include <Nepomuk/Vocabulary/NFO>
 
23
#include <Nepomuk/Vocabulary/NIE>
 
24
 
 
25
using namespace Nepomuk::Vocabulary;
25
26
 
26
27
NepomukHandler::NepomukHandler(Transfer *transfer)
27
28
  : QObject(transfer),
52
53
{
53
54
    const QList<KUrl> destinations = m_transfer->files();
54
55
 
55
 
    QPair<QUrl, Nepomuk::Variant> property = qMakePair(Nepomuk::Vocabulary::NIE::url(), Nepomuk::Variant(m_transfer->source()));
56
 
    KGet::nepomukController()->setProperty(QList<KUrl>() << m_transfer->source(), property, Nepomuk::Vocabulary::NFO::RemoteDataObject());
57
 
    Nepomuk::Resource srcFileRes(m_transfer->source(), Nepomuk::Vocabulary::NFO::RemoteDataObject());
 
56
    const KUrl src = m_transfer->source();
 
57
    const QUrl srcType = (src.isLocalFile() ? NFO::FileDataObject() : NFO::RemoteDataObject());
 
58
    QPair<QUrl, Nepomuk::Variant> property = qMakePair(NIE::url(), Nepomuk::Variant(src));
 
59
    KGet::nepomukController()->setProperty(QList<KUrl>() << src, property, srcType);
 
60
    Nepomuk::Resource srcFileRes(src, srcType);
58
61
 
59
62
    foreach (const KUrl &destination, destinations) {
60
63
        //set all the properties
61
64
        QList<QPair<QUrl, Nepomuk::Variant> > properties;
62
 
        properties.append(qMakePair(Nepomuk::Vocabulary::NIE::url(), Nepomuk::Variant(destination)));
63
 
        properties.append(qMakePair(Nepomuk::Vocabulary::NDO::copiedFrom(), Nepomuk::Variant(srcFileRes)));
64
 
        properties.append(qMakePair(Soprano::Vocabulary::Xesam::originURL(), Nepomuk::Variant(m_transfer->source().url())));
 
65
        properties.append(qMakePair(NIE::url(), Nepomuk::Variant(destination)));
 
66
        properties.append(qMakePair(NDO::copiedFrom(), Nepomuk::Variant(srcFileRes)));
65
67
 
66
 
        //just adds one Hash as otherwise it would not be clear in KFileMetaDataWidget which hash belongs
67
 
        //to which algorithm
68
68
        Verifier *verifier = m_transfer->verifier(destination);
69
69
        if (verifier) {
70
 
            const QPair<QString, QString> checksum = verifier->availableChecksum(Verifier::Strongest);
71
 
            QString hashType = checksum.first;
72
 
            const QString hash = checksum.second;
73
 
            if (!hashType.isEmpty() && !hash.isEmpty()) {
74
 
                //use the offical names, i.e. uppercase and in the case of SHA with a '-'
75
 
                hashType = hashType.toUpper();
76
 
                if (hashType.contains(QRegExp("^SHA\\d+"))) {
77
 
                    hashType.insert(3, '-');
 
70
            const QList<Checksum> checksums = verifier->availableChecksums();
 
71
            QList<Nepomuk::Variant> hashes;
 
72
            foreach (const Checksum &checksum, checksums) {
 
73
                QString hashType = Verifier::cleanChecksumType(checksum.first);
 
74
                const QString hash = checksum.second;
 
75
                if (!hashType.isEmpty() && !hash.isEmpty()) {
 
76
                    Nepomuk::Resource hashRes(hash, NFO::FileHash());
 
77
                    hashRes.addProperty(NFO::hashAlgorithm(), hashType);
 
78
                    hashRes.addProperty(NFO::hashValue(), hash);
 
79
                    hashRes.setLabel(hashType);
 
80
                    hashes << hashRes;
78
81
                }
79
 
                properties.append(qMakePair(Nepomuk::Vocabulary::NFO::hashAlgorithm(), Nepomuk::Variant(hashType)));
80
 
                properties.append(qMakePair(Nepomuk::Vocabulary::NFO::hashValue(), Nepomuk::Variant(hash)));
 
82
            }
 
83
            if (!hashes.isEmpty()) {
 
84
                properties.append(qMakePair(NFO::hasHash(), Nepomuk::Variant(hashes)));
81
85
            }
82
86
        }
83
87