File indexing completed on 2024-11-24 04:53:23

0001 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
0002 
0003    This file is part of the Trojita Qt IMAP e-mail client,
0004    http://trojita.flaska.net/
0005 
0006    This program is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU General Public License as
0008    published by the Free Software Foundation; either version 2 of
0009    the License or (at your option) version 3 or any later version
0010    accepted by the membership of KDE e.V. (or its successor approved
0011    by the membership of KDE e.V.), which shall act as a proxy
0012    defined in Section 14 of version 3 of the license.
0013 
0014    This program is distributed in the hope that it will be useful,
0015    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017    GNU General Public License for more details.
0018 
0019    You should have received a copy of the GNU General Public License
0020    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021 */
0022 #include "FakeMSA.h"
0023 
0024 namespace MSA
0025 {
0026 
0027 Fake::Fake(QObject *parent, FakeFactory *factory, const bool supportsBurl, const bool supportsImap):
0028     AbstractMSA(parent), m_factory(factory), m_supportsBurl(supportsBurl), m_supportsImap(supportsImap)
0029 {
0030 }
0031 
0032 Fake::~Fake()
0033 {
0034 }
0035 
0036 void Fake::sendMail(const QByteArray &from, const QList<QByteArray> &to, const QByteArray &data)
0037 {
0038     emit m_factory->requestedSending(from, to, data);
0039 }
0040 
0041 void Fake::sendBurl(const QByteArray &from, const QList<QByteArray> &to, const QByteArray &imapUrl)
0042 {
0043     emit m_factory->requestedBurlSending(from, to, imapUrl);
0044 }
0045 
0046 void Fake::cancel()
0047 {
0048     emit m_factory->requestedCancelling();
0049 }
0050 
0051 FakeFactory::FakeFactory(): m_supportsBurl(false), m_supportsImap(false)
0052 {
0053 }
0054 
0055 FakeFactory::~FakeFactory()
0056 {
0057 }
0058 
0059 AbstractMSA *FakeFactory::create(QObject *parent) const
0060 {
0061     m_lastOne = new Fake(parent, const_cast<FakeFactory *>(this), m_supportsBurl, m_supportsImap);
0062     connect(m_lastOne.data(), &AbstractMSA::connecting, this, &FakeFactory::connecting);
0063     connect(m_lastOne.data(), &AbstractMSA::sending, this, &FakeFactory::sending);
0064     connect(m_lastOne.data(), &AbstractMSA::sent, this, &FakeFactory::sent);
0065     connect(m_lastOne.data(), &AbstractMSA::error, this, &FakeFactory::error);
0066     connect(m_lastOne.data(), &AbstractMSA::progressMax, this, &FakeFactory::progressMax);
0067     connect(m_lastOne.data(), &AbstractMSA::progress, this, &FakeFactory::progress);
0068     return m_lastOne;
0069 }
0070 
0071 Fake *FakeFactory::lastMSA() const
0072 {
0073     return m_lastOne;
0074 }
0075 
0076 void FakeFactory::doEmitConnecting()
0077 {
0078     emit lastMSA()->connecting();
0079 }
0080 
0081 void FakeFactory::doEmitSending()
0082 {
0083     emit lastMSA()->sending();
0084 }
0085 
0086 void FakeFactory::doEmitSent()
0087 {
0088     emit lastMSA()->sent();
0089 }
0090 
0091 void FakeFactory::doEmitError(const QString &message)
0092 {
0093     emit lastMSA()->error(message);
0094 }
0095 
0096 void FakeFactory::doEmitProgressMax(int max)
0097 {
0098     emit lastMSA()->progressMax(max);
0099 }
0100 
0101 void FakeFactory::doEmitProgress(int num)
0102 {
0103     emit lastMSA()->progress(num);
0104 }
0105 
0106 void FakeFactory::setBurlSupport(const bool enabled)
0107 {
0108     m_supportsBurl = enabled;
0109 }
0110 
0111 void FakeFactory::setImapSupport(const bool enabled)
0112 {
0113     m_supportsImap = enabled;
0114 }
0115 
0116 }