-rw-r--r-- | noncore/settings/sshkeys/sshkeys.cpp | 58 | ||||
-rw-r--r-- | noncore/settings/sshkeys/sshkeys.h | 5 |
2 files changed, 54 insertions, 9 deletions
diff --git a/noncore/settings/sshkeys/sshkeys.cpp b/noncore/settings/sshkeys/sshkeys.cpp index c5e1170..43e02af 100644 --- a/noncore/settings/sshkeys/sshkeys.cpp +++ b/noncore/settings/sshkeys/sshkeys.cpp @@ -51,3 +51,3 @@ SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) connect(&addprocess, SIGNAL(receivedStderr(OProcess*,char*,int)), - this, SLOT(log_sshadd_output(OProcess*,char*,int))); + this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); connect(&addprocess, SIGNAL(processExited(OProcess*)), @@ -92,3 +92,3 @@ void SSHKeysApp::doRefreshListButton() connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), - this, SLOT(log_sshadd_output(OProcess*,char*,int))); + this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); @@ -106,2 +106,3 @@ void SSHKeysApp::doRefreshListButton() } + flush_sshadd_output(); if (sshadd_process.exitStatus() == 2) { @@ -179,8 +180,45 @@ void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen) +void SSHKeysApp::flush_sshadd_output(void) +{ + if (pending_stdout.length()) { + log_text(pending_stdout.ascii()); + } + pending_stdout = ""; + + if (pending_stderr.length()) { + log_text(pending_stderr.ascii()); + } + pending_stderr = ""; +} + void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen) { - (void)proc; - (void)buflen; + (void) proc; - log_text(buffer); + while (buflen) { + if (*buffer == '\n') { + log_text(pending_stdout); + pending_stdout = ""; + } else { + pending_stdout += *buffer; + } + buffer++; + buflen--; + } +} + +void SSHKeysApp::log_sshadd_stderr(OProcess *proc, char *buffer, int buflen) +{ + (void) proc; + + while (buflen) { + if (*buffer == '\n') { + log_text(pending_stderr); + pending_stderr = ""; + } else { + pending_stderr += *buffer; + } + buffer++; + buflen--; + } } @@ -218,6 +256,6 @@ void SSHKeysApp::doAddButton() addprocess << "ssh-add" << "--" << KeyFileName->currentText(); - log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText()); +// log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText()); } else { addprocess << "ssh-add"; - log_text(tr("Running ssh-add")); +// log_text(tr("Running ssh-add")); } @@ -229,2 +267,3 @@ void SSHKeysApp::doAddButton() } + flush_sshadd_output(); } @@ -244,5 +283,5 @@ void SSHKeysApp::doRemoveAllButton() connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), - this, SLOT(log_sshadd_output(OProcess*,char*,int))); + this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); - log_text(tr("Running ssh-add -D")); +// log_text(tr("Running ssh-add -D")); sshadd_process << "ssh-add" << "-D"; @@ -252,2 +291,3 @@ void SSHKeysApp::doRemoveAllButton() } + flush_sshadd_output(); doRefreshListButton(); diff --git a/noncore/settings/sshkeys/sshkeys.h b/noncore/settings/sshkeys/sshkeys.h index 5e306d1..bbc6993 100644 --- a/noncore/settings/sshkeys/sshkeys.h +++ b/noncore/settings/sshkeys/sshkeys.h @@ -37,2 +37,4 @@ class SSHKeysApp : public SSHKeysBase void log_text(const char *text); + void flush_sshadd_output(void); + enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; @@ -43,2 +45,4 @@ class SSHKeysApp : public SSHKeysBase OProcess addprocess; + QString pending_stdout; + QString pending_stderr; @@ -50,2 +54,3 @@ class SSHKeysApp : public SSHKeysBase void log_sshadd_output(OProcess *proc, char *buffer, int buflen); + void log_sshadd_stderr(OProcess *proc, char *buffer, int buflen); void ssh_add_exited(OProcess *proc); |