annotate hgrunner.h @ 75:295e3ee4a257

* Allocate a pty for the subprocess, and ask the user for password. Very rudimentary and non-portable.
author Chris Cannam
date Fri, 19 Nov 2010 18:39:40 +0000
parents 68aebc316898
children 8a4e26dc3182
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@57 2
Chris@57 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@57 6 Based on HgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@57 8 Copyright (c) 2010 Chris Cannam
Chris@57 9 Copyright (c) 2010 Queen Mary, University of London
Chris@57 10
Chris@57 11 This program is free software; you can redistribute it and/or
Chris@57 12 modify it under the terms of the GNU General Public License as
Chris@57 13 published by the Free Software Foundation; either version 2 of the
Chris@57 14 License, or (at your option) any later version. See the file
Chris@57 15 COPYING included with this distribution for more information.
Chris@57 16 */
Chris@57 17
jtkorhonen@0 18 #ifndef HGRUNNER_H
jtkorhonen@0 19 #define HGRUNNER_H
jtkorhonen@0 20
jtkorhonen@0 21 #include <QProgressBar>
jtkorhonen@0 22 #include <QProcess>
jtkorhonen@0 23 #include <QByteArray>
jtkorhonen@0 24 #include <QRect>
Chris@75 25 #include <QFile>
jtkorhonen@0 26
jtkorhonen@0 27 class HgRunner : public QProgressBar
jtkorhonen@0 28 {
jtkorhonen@0 29 Q_OBJECT
jtkorhonen@0 30
Chris@62 31 public:
Chris@62 32 HgRunner(QWidget * parent = 0);
Chris@62 33 ~HgRunner();
jtkorhonen@0 34
Chris@62 35 void startHgCommand(QString workingDir, QStringList params);
Chris@62 36 void startCommand(QString command, QString workingDir, QStringList params);
jtkorhonen@0 37
Chris@62 38 bool isCommandRunning();
Chris@62 39 void killCurrentCommand();
jtkorhonen@0 40
Chris@62 41 int getExitCode();
Chris@62 42 QProcess::ExitStatus getExitStatus();
jtkorhonen@0 43
Chris@62 44 void hideProgBar();
jtkorhonen@0 45
Chris@62 46 QString getStdOut();
Chris@62 47
Chris@62 48 signals:
Chris@62 49 void commandCompleted();
Chris@62 50 void commandFailed();
Chris@62 51
Chris@62 52 private:
Chris@62 53 void saveOutput();
Chris@62 54 void setProcExitInfo(int procExitCode, QProcess::ExitStatus procExitStatus);
Chris@62 55 QString getLastCommandLine();
Chris@62 56 void presentErrorToUser();
Chris@62 57 QString getHgBinaryName();
Chris@75 58
Chris@75 59 int ptyMasterFd;
Chris@75 60 int ptySlaveFd;
Chris@75 61 QString ptySlaveFilename;
Chris@75 62 QFile *procInput;
Chris@62 63
Chris@62 64 bool reportErrors;
Chris@62 65 bool isRunning;
Chris@62 66 QProcess *proc;
Chris@62 67 QString stdOut;
Chris@62 68 QString stdErr;
Chris@62 69 int exitCode;
Chris@62 70 QProcess::ExitStatus exitStatus;
Chris@62 71 QString lastHgCommand;
Chris@62 72 QString lastParams;
Chris@62 73
Chris@62 74 private slots:
Chris@62 75 void started();
Chris@62 76 void finished(int procExitCode, QProcess::ExitStatus procExitStatus);
Chris@75 77 void stdOutReady();
Chris@75 78 void stdErrReady();
jtkorhonen@0 79 };
jtkorhonen@0 80
jtkorhonen@0 81 #endif // HGRUNNER_H