2
This file is part of KDE.
4
Copyright (c) 2008 Cornelius Schumacher <schumacher@kde.org>
5
Copyright (c) 2009 Marco Martin <notmart@gmail.com>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23
#include "knowledgebaselistjob.h"
25
#include "knowledgebaseparser.h"
32
using namespace Attica;
34
KnowledgeBaseListJob::KnowledgeBaseListJob()
39
void KnowledgeBaseListJob::setUrl( const KUrl &url )
44
void KnowledgeBaseListJob::start()
46
QTimer::singleShot( 0, this, SLOT( doWork() ) );
49
KnowledgeBase::List KnowledgeBaseListJob::knowledgeBaseList() const
51
return m_knowledgeBaseList;
54
KnowledgeBase::Metadata KnowledgeBaseListJob::metadata() const
59
void KnowledgeBaseListJob::doWork()
63
m_job = KIO::get( m_url, KIO::NoReload, KIO::HideProgressInfo );
64
connect( m_job, SIGNAL( result( KJob * ) ),
65
SLOT( slotJobResult( KJob * ) ) );
66
connect( m_job, SIGNAL( data( KIO::Job *, const QByteArray & ) ),
67
SLOT( slotJobData( KIO::Job *, const QByteArray & ) ) );
70
void KnowledgeBaseListJob::slotJobResult( KJob *job )
75
setError( job->error() );
76
setErrorText( job->errorText() );
81
KnowledgeBaseParser parser;
82
m_knowledgeBaseList = parser.parseList(
83
QString::fromUtf8( m_data.data() ) );
84
m_metadata = parser.lastMetadata();
90
void KnowledgeBaseListJob::slotJobData( KIO::Job *, const QByteArray &data )
92
m_data.append( data );