File indexing completed on 2024-03-24 16:13:23

0001 /** ===========================================================
0002  * @file
0003  *
0004  * This file is a part of KDE project
0005  * <a href="https://commits.kde.org/libmediawiki">libmediawiki</a>
0006  *
0007  * @date   2011-03-22
0008  * @brief  a MediaWiki C++ interface for KDE
0009  *
0010  * @author Copyright (C) 2011-2012 by Gilles Caulier
0011  *         <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
0012  * @author Copyright (C) 2009 by Paolo de Vathaire
0013  *         <a href="mailto:paolo dot devathaire at gmail dot com">paolo dot devathaire at gmail dot com</a>
0014  *
0015  * This program is free software; you can redistribute it
0016  * and/or modify it under the terms of the GNU General
0017  * Public License as published by the Free Software Foundation;
0018  * either version 2, or (at your option)
0019  * any later version.
0020  *
0021  * This program is distributed in the hope that it will be useful,
0022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0024  * GNU General Public License for more details.
0025  *
0026  * ============================================================ */
0027 
0028 #include "job.h"
0029 
0030 // Qt includes
0031 
0032 #include <QNetworkReply>
0033 
0034 // Local include
0035 
0036 #include "mediawiki.h"
0037 #include "job_p.h"
0038 
0039 namespace mediawiki
0040 {
0041 
0042 Job::Job(JobPrivate& dd, QObject* const parent)
0043     : KJob(parent),
0044       d_ptr(&dd)
0045 {
0046     setCapabilities(Job::Killable);
0047 }
0048 
0049 Job::~Job()
0050 {
0051     delete d_ptr;
0052 }
0053 
0054 bool Job::doKill()
0055 {
0056     Q_D(Job);
0057     if (d->reply != nullptr)
0058     {
0059         d->reply->abort();
0060     }
0061     return true;
0062 }
0063 
0064 void Job::connectReply()
0065 {
0066     Q_D(Job);
0067     connect(d->reply, SIGNAL(uploadProgress(qint64,qint64)),
0068             this, SLOT(processUploadProgress(qint64,qint64)));
0069 }
0070 
0071 void Job::processUploadProgress(qint64 bytesReceived, qint64 bytesTotal)
0072 {
0073     setTotalAmount(Job::Bytes, bytesTotal);
0074     setProcessedAmount(Job::Bytes, bytesReceived);
0075 }
0076 
0077 } // namespace mediawiki