File indexing completed on 2024-11-24 04:44:44

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2008 Kevin Ottens <ervin@kde.org>
0004 
0005     SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
0006     SPDX-FileContributor: Kevin Ottens <kevin@kdab.com>
0007 
0008     SPDX-License-Identifier: LGPL-2.0-or-later
0009   */
0010 
0011 #pragma once
0012 
0013 #include "kimap/job.h"
0014 
0015 class MockJobPrivate;
0016 
0017 /**
0018  * Provides an easy way to send an arbitrary IMAP client command.
0019  */
0020 class MockJob : public KIMAP::Job
0021 {
0022     Q_OBJECT
0023     Q_DECLARE_PRIVATE(MockJob)
0024 
0025 public:
0026     MockJob(KIMAP::Session *session);
0027 
0028     /**
0029      * Sets the command to execute.
0030      *
0031      * This should not include the command tag.
0032      */
0033     void setCommand(const QByteArray &command);
0034     /**
0035      * The command that will be sent.
0036      */
0037     QByteArray command() const;
0038     /**
0039      * Sets the timeout before the job completes.
0040      */
0041     void setTimeout(int timeout);
0042     /**
0043      * The timeout used by the job.
0044      */
0045     int timeout() const;
0046     /**
0047      * Whether the command is empty.
0048      *
0049      * Equivalent to command().isEmpty().
0050      *
0051      * @return @c true if no command is set, @c false otherwise
0052      */
0053     bool isNull() const;
0054 
0055     /**
0056      * Starts the job.
0057      *
0058      * Do not call this directly.  Use start() instead.
0059      *
0060      * @reimp
0061      */
0062     void doStart() override;
0063 
0064 private Q_SLOTS:
0065     void done();
0066 };