~ubuntu-branches/ubuntu/quantal/kde-runtime/quantal

« back to all changes in this revision

Viewing changes to nepomuk/services/storage/ontologydownloadjob.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-06-03 21:50:00 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120603215000-vn7oarsq0ynrydj5
Tags: upstream-4.8.80
Import upstream version 4.8.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
class Private
3
 
{
4
 
public:
5
 
    void _k_slotHttpGetResult( KJob* job );
6
 
    void _k_slotData(KIO::Job*, const QByteArray&);
7
 
 
8
 
    QUrl ontoNamespace;
9
 
    KTemporaryFile tmpFile;
10
 
};
11
 
 
12
 
 
13
 
void start()
14
 
{
15
 
    KIO::TransferJob* job = KIO::get( d->ontoNamespace );
16
 
    connect( job, SIGNAL(result(KJob*)),
17
 
             this, SLOT(_k_slotHttpGetResult(KJob*)) );
18
 
    connect( job, SIGNAL(data(KIO::Job*, const QByteArray&)),
19
 
             this, SLOT(_k_slotData(KIO::Job*, const QByteArray&)) );
20
 
    job->start();
21
 
}
22
 
 
23
 
 
24
 
void Private::_k_data( KIO::Job*, const QByteArray& data )
25
 
{
26
 
    if( !d->tmpFile.isOpen() ) {
27
 
        d->tmpFile.open();
28
 
    }
29
 
 
30
 
    d->tmpFile.write( data );
31
 
}
32
 
 
33
 
 
34
 
void Private::_k_slotHttpGetResult( KJob* job )
35
 
{
36
 
    d->tmpFile.close();
37
 
 
38
 
    if( !job->error() ) {
39
 
        QString mimeType = job->mimetype();
40
 
        const Soprano::Parser* parser =
41
 
            Soprano::PluginManager::instance()->discoverParserForSerialization( Soprano::mimeTypeToSerialization( mimetype ),
42
 
                                                                                mimetype );
43
 
        if( parser ) {
44
 
            Soprano::StatementIterator it = parser->parseFile( d->tmpFile.fileName(),
45
 
                                                               d->ontoNamespace,
46
 
                                                               Soprano::mimeTypeToSerialization( mimetype ),
47
 
                                                               mimetype );
48
 
 
49
 
        }
50
 
        else {
51
 
            // FIXME: report error: unable to handle data of type XXX
52
 
        }
53
 
    }
54
 
    else {
55
 
        // FIXME: report http error
56
 
    }
57
 
 
58
 
    d->tmpFile.remove();
59
 
}