File indexing completed on 2024-06-16 04:54:11

0001 /*
0002     This file is part of the KDE project
0003     Copyright (C) 2008 Kevin Ottens <ervin@kde.org>
0004 
0005     Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
0006     Author: Kevin Ottens <kevin@kdab.com>
0007 
0008     This library is free software; you can redistribute it and/or
0009     modify it under the terms of the GNU Library General Public
0010     License as published by the Free Software Foundation; either
0011     version 2 of the License, or (at your option) any later version.
0012 
0013     This library is distributed in the hope that it will be useful,
0014     but WITHOUT ANY WARRANTY; without even the implied warranty of
0015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0016     Library General Public License for more details.
0017 
0018     You should have received a copy of the GNU Library General Public License
0019     along with this library; see the file COPYING.LIB.  If not, write to
0020     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0021     Boston, MA 02110-1301, USA.
0022   */
0023 
0024 #ifndef MOCKJOB_H
0025 #define MOCKJOB_H
0026 
0027 #include <kimap2/job.h>
0028 
0029 class MockJobPrivate;
0030 
0031 /**
0032  * Provides an easy way to send an arbitrary IMAP client command.
0033  */
0034 class MockJob : public KIMAP2::Job
0035 {
0036     Q_OBJECT
0037     Q_DECLARE_PRIVATE(MockJob)
0038 
0039 public:
0040     MockJob(KIMAP2::Session *session);
0041 
0042     /**
0043      * Sets the command to execute.
0044      *
0045      * This should not include the command tag.
0046      */
0047     void setCommand(const QByteArray &command);
0048     /**
0049      * The command that will be sent.
0050      */
0051     QByteArray command() const;
0052     /**
0053      * Sets the timeout before the job completes.
0054      */
0055     void setTimeout(int timeout);
0056     /**
0057      * The timeout used by the job.
0058      */
0059     int timeout() const;
0060     /**
0061      * Whether the command is empty.
0062      *
0063      * Equivalent to command().isEmpty().
0064      *
0065      * @return @c true if no command is set, @c false otherwise
0066      */
0067     bool isNull() const;
0068 
0069     /**
0070      * Starts the job.
0071      *
0072      * Do not call this directly.  Use start() instead.
0073      *
0074      * @reimp
0075      */
0076     void doStart() Q_DECL_OVERRIDE;
0077 
0078 private Q_SLOTS:
0079     void done();
0080 };
0081 
0082 #endif