Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
f678fce3
Commit
f678fce3
authored
May 10, 2010
by
ck
Browse files
SSH: Make interface more Qt-ish.
parent
642116e4
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/plugins/coreplugin/ssh/sshconnection.cpp
View file @
f678fce3
...
...
@@ -151,6 +151,9 @@ struct InteractiveSshConnectionPrivate
GenericSshConnection
conn
;
ConnectionOutputReader
*
outputReader
;
QByteArray
remoteOutput
;
QMutex
mutex
;
QWaitCondition
waitCond
;
};
struct
NonInteractiveSshConnectionPrivate
...
...
@@ -208,8 +211,12 @@ private:
m_mutex
.
unlock
();
QScopedPointer
<
char
,
QScopedPointerArrayDeleter
<
char
>
>
output
(
m_conn
->
d
->
conn
.
ssh
->
readAndReset
(
channel
,
alloc
));
if
(
output
)
emit
m_conn
->
remoteOutput
(
QByteArray
(
output
.
data
()));
if
(
output
)
{
m_conn
->
d
->
mutex
.
lock
();
m_conn
->
d
->
remoteOutput
+=
output
.
data
();
emit
m_conn
->
remoteOutputAvailable
();
m_conn
->
d
->
mutex
.
unlock
();
}
}
}
...
...
@@ -266,10 +273,25 @@ bool InteractiveSshConnection::sendInput(const QByteArray &input)
void
InteractiveSshConnection
::
quit
()
{
d
->
mutex
.
lock
();
d
->
waitCond
.
wakeOne
();
d
->
mutex
.
unlock
();
d
->
outputReader
->
stop
();
d
->
conn
.
quit
();
}
QByteArray
InteractiveSshConnection
::
waitForRemoteOutput
(
int
msecs
)
{
d
->
mutex
.
lock
();
if
(
d
->
remoteOutput
.
isEmpty
())
d
->
waitCond
.
wait
(
&
d
->
mutex
,
msecs
==
-
1
?
ULONG_MAX
:
msecs
);
const
QByteArray
remoteOutput
=
d
->
remoteOutput
;
d
->
remoteOutput
.
clear
();
d
->
mutex
.
unlock
();
return
remoteOutput
;
}
InteractiveSshConnection
::
Ptr
InteractiveSshConnection
::
create
(
const
SshServerInfo
&
server
)
{
return
Ptr
(
new
InteractiveSshConnection
(
server
));
...
...
src/plugins/coreplugin/ssh/sshconnection.h
View file @
f678fce3
...
...
@@ -82,12 +82,13 @@ public:
bool
start
();
void
quit
();
bool
sendInput
(
const
QByteArray
&
input
);
// Should normally end in newline.
QByteArray
waitForRemoteOutput
(
int
msecs
=
-
1
);
bool
hasError
()
const
;
QString
error
()
const
;
~
InteractiveSshConnection
();
signals:
void
remoteOutput
(
const
QByteArray
&
output
);
void
remoteOutput
Available
(
);
private:
InteractiveSshConnection
(
const
SshServerInfo
&
server
);
...
...
src/plugins/debugger/gdb/remotegdbprocess.cpp
View file @
f678fce3
...
...
@@ -71,12 +71,12 @@ void RemoteGdbProcess::start(const QString &cmd, const QStringList &args)
return
;
m_command
=
cmd
;
m_cmdArgs
=
args
;
connect
(
m_gdbConn
.
data
(),
SIGNAL
(
remoteOutput
(
QByteArray
)),
this
,
SLOT
(
handleGdbOutput
(
QByteArray
)));
connect
(
m_appOutputConn
.
data
(),
SIGNAL
(
remoteOutput
(
QByteArray
)),
this
,
SLOT
(
handleAppOutput
(
QByteArray
)));
connect
(
m_errOutputConn
.
data
(),
SIGNAL
(
remoteOutput
(
QByteArray
)),
this
,
SLOT
(
handleErrOutput
(
QByteArray
)));
connect
(
m_gdbConn
.
data
(),
SIGNAL
(
remoteOutput
Available
(
)),
this
,
SLOT
(
handleGdbOutput
()));
connect
(
m_appOutputConn
.
data
(),
SIGNAL
(
remoteOutput
Available
(
)),
this
,
SLOT
(
handleAppOutput
()));
connect
(
m_errOutputConn
.
data
(),
SIGNAL
(
remoteOutput
Available
(
)),
this
,
SLOT
(
handleErrOutput
()));
m_gdbConn
->
start
();
m_errOutputConn
->
start
();
m_appOutputConn
->
start
();
...
...
@@ -130,7 +130,7 @@ QString RemoteGdbProcess::errorString() const
return
m_gdbConn
?
m_gdbConn
->
error
()
:
QString
();
}
void
RemoteGdbProcess
::
handleGdbOutput
(
const
QByteArray
&
output
)
void
RemoteGdbProcess
::
handleGdbOutput
()
{
#if 0
qDebug("%s: output is '%s'", Q_FUNC_INFO, output.data());
...
...
@@ -139,7 +139,8 @@ void RemoteGdbProcess::handleGdbOutput(const QByteArray &output)
if
(
m_gdbState
==
CmdNotYetSent
)
return
;
m_currentGdbOutput
+=
removeCarriageReturn
(
output
);
m_currentGdbOutput
+=
removeCarriageReturn
(
m_gdbConn
->
waitForRemoteOutput
(
0
));
if
(
!
m_currentGdbOutput
.
endsWith
(
'\n'
))
return
;
...
...
@@ -217,15 +218,17 @@ qint64 RemoteGdbProcess::sendInput(const QByteArray &data)
return
m_gdbConn
->
sendInput
(
data
)
?
data
.
size
()
:
0
;
}
void
RemoteGdbProcess
::
handleAppOutput
(
const
QByteArray
&
output
)
void
RemoteGdbProcess
::
handleAppOutput
()
{
const
QByteArray
output
=
m_appOutputConn
->
waitForRemoteOutput
(
0
);
if
(
!
handleAppOrErrOutput
(
m_appOutputConn
,
m_appOutputReaderState
,
m_initialAppOutput
,
AppOutputFile
,
output
))
m_adapter
->
handleApplicationOutput
(
output
);
}
void
RemoteGdbProcess
::
handleErrOutput
(
const
QByteArray
&
output
)
void
RemoteGdbProcess
::
handleErrOutput
()
{
const
QByteArray
output
=
m_errOutputConn
->
waitForRemoteOutput
(
0
);
if
(
!
handleAppOrErrOutput
(
m_errOutputConn
,
m_errOutputReaderState
,
m_initialErrOutput
,
ErrOutputFile
,
output
))
{
m_errorOutput
+=
output
;
...
...
@@ -277,14 +280,14 @@ void RemoteGdbProcess::startGdb()
void
RemoteGdbProcess
::
stopReaders
()
{
if
(
m_appOutputConn
)
{
disconnect
(
m_appOutputConn
.
data
(),
SIGNAL
(
remoteOutput
(
QByteArray
)),
this
,
SLOT
(
handleAppOutput
(
QByteArray
)));
disconnect
(
m_appOutputConn
.
data
(),
SIGNAL
(
remoteOutput
Available
(
)),
this
,
SLOT
(
handleAppOutput
()));
m_appOutputConn
->
sendInput
(
CtrlC
);
m_appOutputConn
->
quit
();
}
if
(
m_errOutputConn
)
{
disconnect
(
m_errOutputConn
.
data
(),
SIGNAL
(
remoteOutput
(
QByteArray
)),
this
,
SLOT
(
handleErrOutput
(
QByteArray
)));
disconnect
(
m_errOutputConn
.
data
(),
SIGNAL
(
remoteOutput
Available
(
)),
this
,
SLOT
(
handleErrOutput
()));
m_errOutputConn
->
sendInput
(
CtrlC
);
m_errOutputConn
->
quit
();
}
...
...
@@ -316,8 +319,8 @@ void RemoteGdbProcess::checkForGdbExit(QByteArray &output)
const
QByteArray
exitString
(
"^exit"
);
const
int
exitPos
=
output
.
indexOf
(
exitString
);
if
(
exitPos
!=
-
1
)
{
disconnect
(
m_gdbConn
.
data
(),
SIGNAL
(
remoteOutput
(
QByteArray
)),
this
,
SLOT
(
handleGdbOutput
(
QByteArray
)));
disconnect
(
m_gdbConn
.
data
(),
SIGNAL
(
remoteOutput
Available
(
)),
this
,
SLOT
(
handleGdbOutput
()));
output
.
remove
(
exitPos
+
exitString
.
size
(),
output
.
size
());
stopReaders
();
emit
finished
(
0
,
QProcess
::
NormalExit
);
...
...
src/plugins/debugger/gdb/remotegdbprocess.h
View file @
f678fce3
...
...
@@ -68,9 +68,9 @@ public:
static
const
QByteArray
CtrlC
;
private
slots
:
void
handleGdbOutput
(
const
QByteArray
&
output
);
void
handleAppOutput
(
const
QByteArray
&
output
);
void
handleErrOutput
(
const
QByteArray
&
output
);
void
handleGdbOutput
();
void
handleAppOutput
();
void
handleErrOutput
();
private:
enum
CmdState
{
CmdNotYetSent
,
CmdSent
,
CmdReceived
};
...
...
src/plugins/qt4projectmanager/qt-maemo/maemosshthread.cpp
View file @
f678fce3
...
...
@@ -102,8 +102,8 @@ MaemoSshRunner::MaemoSshRunner(const Core::SshServerInfo &server,
bool
MaemoSshRunner
::
runInternal
()
{
createConnection
();
connect
(
m_connection
.
data
(),
SIGNAL
(
remoteOutput
(
QByteArray
)),
this
,
SLOT
(
handleRemoteOutput
(
QByteArray
)));
connect
(
m_connection
.
data
(),
SIGNAL
(
remoteOutput
Available
(
)),
this
,
SLOT
(
handleRemoteOutput
()));
m_endMarkerCount
=
0
;
m_promptEncountered
=
false
;
if
(
!
m_connection
->
start
())
...
...
@@ -115,8 +115,10 @@ bool MaemoSshRunner::runInternal()
return
!
m_connection
->
hasError
();
}
void
MaemoSshRunner
::
handleRemoteOutput
(
const
QByteArray
&
output
)
void
MaemoSshRunner
::
handleRemoteOutput
()
{
const
QByteArray
output
=
m_connection
->
waitForRemoteOutput
(
0
);
// Wait for a prompt before sending the command.
if
(
!
m_promptEncountered
)
{
if
(
output
.
indexOf
(
m_prompt
)
!=
-
1
)
{
...
...
src/plugins/qt4projectmanager/qt-maemo/maemosshthread.h
View file @
f678fce3
...
...
@@ -96,7 +96,7 @@ signals:
private:
virtual
bool
runInternal
();
Q_SLOT
void
handleRemoteOutput
(
const
QByteArray
&
output
);
Q_SLOT
void
handleRemoteOutput
();
static
const
QByteArray
EndMarker
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment