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
|
Chris@109
|
21 #include "hgaction.h"
|
Chris@109
|
22
|
jtkorhonen@0
|
23 #include <QProgressBar>
|
jtkorhonen@0
|
24 #include <QProcess>
|
jtkorhonen@0
|
25 #include <QByteArray>
|
jtkorhonen@0
|
26 #include <QRect>
|
Chris@75
|
27 #include <QFile>
|
jtkorhonen@0
|
28
|
Chris@109
|
29 #include <deque>
|
Chris@109
|
30
|
jtkorhonen@0
|
31 class HgRunner : public QProgressBar
|
jtkorhonen@0
|
32 {
|
jtkorhonen@0
|
33 Q_OBJECT
|
jtkorhonen@0
|
34
|
Chris@62
|
35 public:
|
Chris@62
|
36 HgRunner(QWidget * parent = 0);
|
Chris@62
|
37 ~HgRunner();
|
jtkorhonen@0
|
38
|
Chris@109
|
39 void requestAction(HgAction action);
|
Chris@109
|
40 /*
|
Chris@62
|
41 bool isCommandRunning();
|
Chris@62
|
42 void killCurrentCommand();
|
jtkorhonen@0
|
43
|
Chris@109
|
44 void hideProgBar();
|
Chris@109
|
45 */
|
Chris@109
|
46 signals:
|
Chris@109
|
47 void commandCompleted(HgAction action, QString stdout);
|
Chris@109
|
48 void commandFailed(HgAction action, QString stderr);
|
jtkorhonen@0
|
49
|
Chris@109
|
50 private slots:
|
Chris@109
|
51 void started();
|
Chris@109
|
52 void finished(int procExitCode, QProcess::ExitStatus procExitStatus);
|
Chris@109
|
53 void dataReady();
|
Chris@62
|
54
|
Chris@62
|
55 private:
|
Chris@109
|
56 void checkQueue();
|
Chris@109
|
57 void startCommand(HgAction action);
|
Chris@62
|
58 QString getHgBinaryName();
|
Chris@84
|
59 void closeProcInput();
|
Chris@109
|
60 void killCurrentCommand();
|
Chris@75
|
61
|
Chris@84
|
62 void noteUsername(QString);
|
Chris@84
|
63 void noteRealm(QString);
|
Chris@84
|
64 void getUsername();
|
Chris@84
|
65 void getPassword();
|
Chris@84
|
66 void checkPrompts(QString);
|
Chris@84
|
67
|
Chris@84
|
68 int m_ptyMasterFd;
|
Chris@84
|
69 int m_ptySlaveFd;
|
Chris@84
|
70 QString m_ptySlaveFilename;
|
Chris@84
|
71 QFile *m_procInput;
|
Chris@62
|
72
|
Chris@84
|
73 bool m_isRunning;
|
Chris@84
|
74 QProcess *m_proc;
|
Chris@84
|
75 QString m_output;
|
Chris@84
|
76
|
Chris@84
|
77 QString m_userName;
|
Chris@84
|
78 QString m_realm;
|
Chris@62
|
79
|
Chris@109
|
80 typedef std::deque<HgAction> ActionQueue;
|
Chris@109
|
81 ActionQueue m_queue;
|
Chris@109
|
82 HgAction m_currentAction;
|
jtkorhonen@0
|
83 };
|
jtkorhonen@0
|
84
|
jtkorhonen@0
|
85 #endif // HGRUNNER_H
|