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@244
|
8 Copyright (c) 2011 Chris Cannam
|
Chris@244
|
9 Copyright (c) 2011 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@172
|
36 HgRunner(QString myDirPath, QWidget * parent = 0);
|
Chris@62
|
37 ~HgRunner();
|
jtkorhonen@0
|
38
|
Chris@109
|
39 void requestAction(HgAction action);
|
Chris@182
|
40 void killCurrentActions(); // kill anything running; clear the queue
|
jtkorhonen@0
|
41
|
Chris@109
|
42 signals:
|
Chris@238
|
43 void commandStarting(HgAction action);
|
Chris@142
|
44 void commandCompleted(HgAction action, QString stdOut);
|
Chris@142
|
45 void commandFailed(HgAction action, QString stdErr);
|
jtkorhonen@0
|
46
|
Chris@109
|
47 private slots:
|
Chris@109
|
48 void started();
|
Chris@189
|
49 void error(QProcess::ProcessError);
|
Chris@109
|
50 void finished(int procExitCode, QProcess::ExitStatus procExitStatus);
|
Chris@110
|
51 void dataReadyStdout();
|
Chris@110
|
52 void dataReadyStderr();
|
Chris@113
|
53 void dataReadyPty();
|
Chris@62
|
54
|
Chris@62
|
55 private:
|
Chris@109
|
56 void checkQueue();
|
Chris@109
|
57 void startCommand(HgAction action);
|
Chris@84
|
58 void closeProcInput();
|
Chris@109
|
59 void killCurrentCommand();
|
Chris@75
|
60
|
Chris@84
|
61 void noteUsername(QString);
|
Chris@84
|
62 void noteRealm(QString);
|
Chris@84
|
63 void getUsername();
|
Chris@84
|
64 void getPassword();
|
Chris@113
|
65 bool checkPrompts(QString);
|
Chris@84
|
66
|
Chris@111
|
67 void openTerminal();
|
Chris@111
|
68 void closeTerminal();
|
chris@406
|
69
|
Chris@239
|
70 QString getHgBinaryName();
|
chris@406
|
71 QString getSshBinaryName();
|
Chris@239
|
72 QString getExtensionLocation();
|
Chris@239
|
73
|
Chris@455
|
74 QString getAuthFilePath();
|
Chris@455
|
75 QString getAuthKey();
|
Chris@455
|
76 void pruneOldAuthFiles();
|
Chris@455
|
77
|
Chris@188
|
78 QString getUnbundledFileName();
|
Chris@180
|
79 QString unbundleExtension();
|
Chris@161
|
80
|
Chris@444
|
81 QStringList addExtensionOptions(QStringList);
|
Chris@444
|
82
|
Chris@84
|
83 int m_ptyMasterFd;
|
Chris@84
|
84 int m_ptySlaveFd;
|
Chris@84
|
85 QString m_ptySlaveFilename;
|
Chris@113
|
86 QFile *m_ptyFile;
|
Chris@62
|
87
|
Chris@84
|
88 bool m_isRunning;
|
Chris@84
|
89 QProcess *m_proc;
|
Chris@110
|
90 QString m_stdout;
|
Chris@110
|
91 QString m_stderr;
|
Chris@84
|
92
|
Chris@84
|
93 QString m_userName;
|
Chris@84
|
94 QString m_realm;
|
Chris@172
|
95
|
Chris@172
|
96 QString m_myDirPath;
|
Chris@161
|
97 QString m_extensionPath;
|
Chris@62
|
98
|
Chris@444
|
99 QString m_authKey;
|
Chris@444
|
100 QString m_authFilePath;
|
Chris@444
|
101
|
Chris@109
|
102 typedef std::deque<HgAction> ActionQueue;
|
Chris@109
|
103 ActionQueue m_queue;
|
Chris@109
|
104 HgAction m_currentAction;
|
jtkorhonen@0
|
105 };
|
jtkorhonen@0
|
106
|
jtkorhonen@0
|
107 #endif // HGRUNNER_H
|