2
* Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Library General Public License version 2 as
6
* published by the Free Software Foundation
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details
13
* You should have received a copy of the GNU Library General Public
14
* License along with this program; if not, write to the
15
* Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
2
* Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Library General Public License version 2 as
6
* published by the Free Software Foundation
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details
13
* You should have received a copy of the GNU Library General Public
14
* License along with this program; if not, write to the
15
* Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
#include "comicprovider.h"
22
#include <KIO/StoredTransferJob>
23
24
class ComicProvider::Private
27
Private( ComicProvider *parent )
33
void jobDone( KJob *job )
36
mParent->pageError( job->property( "uid" ).toInt(), job->errorText() );
38
KIO::StoredTransferJob *storedJob = qobject_cast<KIO::StoredTransferJob*>( job );
39
mParent->pageRetrieved( job->property( "uid" ).toInt(), storedJob->data() );
43
ComicProvider *mParent;
31
44
QDate mRequestedDate;
32
45
int mRequestedNumber;
33
46
QString mRequestedId;
37
50
ComicProvider::ComicProvider( QObject *parent, const QVariantList &args )
38
: QObject( parent ), d( new Private )
51
: QObject( parent ), d( new Private( this ) )
40
53
Q_ASSERT( args.count() == 2 );
96
109
return d->mRequestedId;
112
void ComicProvider::requestPage( const KUrl &url, int id, const MetaInfos &infos )
114
KIO::StoredTransferJob *job = KIO::storedGet( url, KIO::NoReload, KIO::HideProgressInfo );
115
job->setProperty( "uid", id );
116
connect( job, SIGNAL( result( KJob* ) ), this, SLOT( jobDone( KJob* ) ) );
118
if ( !infos.isEmpty() ) {
119
QMapIterator<QString, QString> it( infos );
120
while ( it.hasNext() ) {
122
job->addMetaData( it.key(), it.value() );
127
void ComicProvider::pageRetrieved( int, const QByteArray& )
131
void ComicProvider::pageError( int, const QString& )
99
135
#include "comicprovider.moc"