~ubuntu-branches/ubuntu/intrepid/kdeplasma-addons/intrepid

« back to all changes in this revision

Viewing changes to dataengines/comic/comicprovider.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2008-09-26 09:26:38 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080926092638-nxuoqv11kd1hpgeo
Tags: 4:4.1.2-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *   Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
3
 
 *
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
7
 
 *
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
12
 
 *
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.
17
 
 */
 
2
*   Copyright (C) 2007 Tobias Koenig <tokoe@kde.org>
 
3
*
 
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
 
7
*
 
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
 
12
*
 
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.
 
17
*/
18
18
 
19
19
#include "comicprovider.h"
20
20
 
21
 
#include <KUrl>
 
21
#include <KIO/Job>
 
22
#include <KIO/StoredTransferJob>
22
23
 
23
24
class ComicProvider::Private
24
25
{
25
26
    public:
26
 
        Private()
27
 
            : mIsCurrent( false )
28
 
        {
29
 
        }
30
 
 
 
27
        Private( ComicProvider *parent )
 
28
        : mParent( parent ),
 
29
        mIsCurrent( false )
 
30
        {
 
31
        }
 
32
 
 
33
        void jobDone( KJob *job )
 
34
        {
 
35
            if ( job->error() ) {
 
36
                mParent->pageError( job->property( "uid" ).toInt(), job->errorText() );
 
37
            } else {
 
38
                KIO::StoredTransferJob *storedJob = qobject_cast<KIO::StoredTransferJob*>( job );
 
39
                mParent->pageRetrieved( job->property( "uid" ).toInt(), storedJob->data() );
 
40
            }
 
41
        }
 
42
 
 
43
        ComicProvider *mParent;
31
44
        QDate mRequestedDate;
32
45
        int mRequestedNumber;
33
46
        QString mRequestedId;
35
48
};
36
49
 
37
50
ComicProvider::ComicProvider( QObject *parent, const QVariantList &args )
38
 
    : QObject( parent ), d( new Private )
 
51
: QObject( parent ), d( new Private( this ) )
39
52
{
40
53
    Q_ASSERT( args.count() == 2 );
41
54
 
96
109
    return d->mRequestedId;
97
110
}
98
111
 
 
112
void ComicProvider::requestPage( const KUrl &url, int id, const MetaInfos &infos )
 
113
{
 
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* ) ) );
 
117
 
 
118
    if ( !infos.isEmpty() ) {
 
119
        QMapIterator<QString, QString> it( infos );
 
120
        while ( it.hasNext() ) {
 
121
            it.next();
 
122
            job->addMetaData( it.key(), it.value() );
 
123
        }
 
124
    }
 
125
}
 
126
 
 
127
void ComicProvider::pageRetrieved( int, const QByteArray& )
 
128
{
 
129
}
 
130
 
 
131
void ComicProvider::pageError( int, const QString& )
 
132
{
 
133
}
 
134
 
99
135
#include "comicprovider.moc"