2011-10-05 15:32:16 +00:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (c) 2013 Brian McGillion and Hugues Delorme
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-10-05 15:32:16 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-10-05 15:32:16 +00:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2011-10-05 15:32:16 +00:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2011-10-05 15:32:16 +00:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-10-05 15:32:16 +00:00
|
|
|
|
|
|
|
|
#ifndef VCSBASE_COMMAND_H
|
|
|
|
|
#define VCSBASE_COMMAND_H
|
|
|
|
|
|
|
|
|
|
#include "vcsbase_global.h"
|
|
|
|
|
|
2013-08-28 11:32:33 +03:00
|
|
|
#include <utils/synchronousprocess.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
2013-03-25 11:36:51 +01:00
|
|
|
|
2013-07-31 21:12:41 +03:00
|
|
|
QT_BEGIN_NAMESPACE
|
2013-08-26 23:14:44 +03:00
|
|
|
class QMutex;
|
2013-07-31 21:12:41 +03:00
|
|
|
class QStringList;
|
|
|
|
|
class QVariant;
|
|
|
|
|
class QProcessEnvironment;
|
|
|
|
|
template <typename T>
|
|
|
|
|
class QFutureInterface;
|
|
|
|
|
QT_END_NAMESPACE
|
2011-10-05 15:32:16 +00:00
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
namespace VcsBase {
|
2011-10-05 15:32:16 +00:00
|
|
|
|
2012-01-07 03:35:54 +01:00
|
|
|
namespace Internal { class CommandPrivate; }
|
2011-12-08 13:07:00 +01:00
|
|
|
|
2013-08-26 23:14:44 +03:00
|
|
|
class VCSBASE_EXPORT ProgressParser
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ProgressParser();
|
|
|
|
|
virtual ~ProgressParser();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual void parseProgress(const QString &text) = 0;
|
|
|
|
|
void setProgressAndMaximum(int value, int maximum);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void setFuture(QFutureInterface<void> *future);
|
|
|
|
|
|
|
|
|
|
QFutureInterface<void> *m_future;
|
|
|
|
|
QMutex *m_futureMutex;
|
|
|
|
|
friend class Command;
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-05 15:32:16 +00:00
|
|
|
class VCSBASE_EXPORT Command : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Command(const QString &binary,
|
|
|
|
|
const QString &workingDirectory,
|
|
|
|
|
const QProcessEnvironment &environment);
|
|
|
|
|
~Command();
|
|
|
|
|
|
2013-09-24 16:40:10 +02:00
|
|
|
void addJob(const QStringList &arguments, Utils::ExitCodeInterpreter *interpreter = 0);
|
|
|
|
|
void addJob(const QStringList &arguments, int timeout, Utils::ExitCodeInterpreter *interpreter = 0);
|
2011-10-05 15:32:16 +00:00
|
|
|
void execute();
|
|
|
|
|
bool lastExecutionSuccess() const;
|
|
|
|
|
int lastExecutionExitCode() const;
|
|
|
|
|
|
|
|
|
|
const QString &binaryPath() const;
|
|
|
|
|
const QString &workingDirectory() const;
|
|
|
|
|
const QProcessEnvironment &processEnvironment() const;
|
|
|
|
|
|
|
|
|
|
int defaultTimeout() const;
|
|
|
|
|
void setDefaultTimeout(int timeout);
|
|
|
|
|
|
2013-08-13 08:37:27 +03:00
|
|
|
unsigned flags() const;
|
|
|
|
|
void addFlags(unsigned f);
|
2011-10-05 15:32:16 +00:00
|
|
|
|
|
|
|
|
const QVariant &cookie() const;
|
|
|
|
|
void setCookie(const QVariant &cookie);
|
|
|
|
|
|
2013-07-17 22:24:13 +03:00
|
|
|
QTextCodec *codec() const;
|
|
|
|
|
void setCodec(QTextCodec *codec);
|
|
|
|
|
|
2013-08-26 23:14:44 +03:00
|
|
|
void setProgressParser(ProgressParser *parser);
|
2013-08-28 21:27:47 +03:00
|
|
|
void setProgressiveOutput(bool progressive);
|
2013-08-28 11:32:33 +03:00
|
|
|
|
2013-09-24 16:40:10 +02:00
|
|
|
Utils::SynchronousProcessResponse runVcs(const QStringList &arguments, int timeoutMS,
|
|
|
|
|
Utils::ExitCodeInterpreter *interpreter = 0);
|
2013-08-28 11:32:33 +03:00
|
|
|
// Make sure to not pass through the event loop at all:
|
|
|
|
|
bool runFullySynchronous(const QStringList &arguments, int timeoutMS,
|
|
|
|
|
QByteArray *outputData, QByteArray *errorData);
|
|
|
|
|
|
2011-10-05 15:32:16 +00:00
|
|
|
private:
|
2013-07-31 21:12:41 +03:00
|
|
|
void run(QFutureInterface<void> &future);
|
2013-09-24 16:40:10 +02:00
|
|
|
Utils::SynchronousProcessResponse runSynchronous(const QStringList &arguments, int timeoutMS,
|
|
|
|
|
Utils::ExitCodeInterpreter *interpreter = 0);
|
2011-10-05 15:32:16 +00:00
|
|
|
|
2013-09-22 13:13:38 +03:00
|
|
|
public slots:
|
|
|
|
|
void cancel();
|
2013-08-26 23:14:44 +03:00
|
|
|
|
2011-10-05 15:32:16 +00:00
|
|
|
signals:
|
2013-07-30 20:16:56 +03:00
|
|
|
void output(const QString &);
|
2011-10-05 15:32:16 +00:00
|
|
|
void errorText(const QString &);
|
|
|
|
|
void finished(bool ok, int exitCode, const QVariant &cookie);
|
|
|
|
|
void success(const QVariant &cookie);
|
2013-09-22 13:13:38 +03:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void bufferedOutput(const QString &text);
|
|
|
|
|
void bufferedError(const QString &text);
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void terminate(); // Internal
|
2011-10-05 15:32:16 +00:00
|
|
|
|
|
|
|
|
private:
|
2011-12-08 13:07:00 +01:00
|
|
|
class Internal::CommandPrivate *const d;
|
2011-10-05 15:32:16 +00:00
|
|
|
};
|
|
|
|
|
|
2012-01-07 12:31:48 +01:00
|
|
|
} // namespace VcsBase
|
2011-10-05 15:32:16 +00:00
|
|
|
|
|
|
|
|
#endif // VCSBASE_COMMAND_H
|