summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sshkeys/sshkeys.cpp58
-rw-r--r--noncore/settings/sshkeys/sshkeys.h5
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 )
51 connect(&addprocess, SIGNAL(receivedStderr(OProcess*,char*,int)), 51 connect(&addprocess, SIGNAL(receivedStderr(OProcess*,char*,int)),
52 this, SLOT(log_sshadd_output(OProcess*,char*,int))); 52 this, SLOT(log_sshadd_stderr(OProcess*,char*,int)));
53 connect(&addprocess, SIGNAL(processExited(OProcess*)), 53 connect(&addprocess, SIGNAL(processExited(OProcess*)),
@@ -92,3 +92,3 @@ void SSHKeysApp::doRefreshListButton()
92 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), 92 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)),
93 this, SLOT(log_sshadd_output(OProcess*,char*,int))); 93 this, SLOT(log_sshadd_stderr(OProcess*,char*,int)));
94 94
@@ -106,2 +106,3 @@ void SSHKeysApp::doRefreshListButton()
106 } 106 }
107 flush_sshadd_output();
107 if (sshadd_process.exitStatus() == 2) { 108 if (sshadd_process.exitStatus() == 2) {
@@ -179,8 +180,45 @@ void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen)
179 180
181void SSHKeysApp::flush_sshadd_output(void)
182{
183 if (pending_stdout.length()) {
184 log_text(pending_stdout.ascii());
185 }
186 pending_stdout = "";
187
188 if (pending_stderr.length()) {
189 log_text(pending_stderr.ascii());
190 }
191 pending_stderr = "";
192}
193
180void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen) 194void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen)
181{ 195{
182 (void)proc; 196 (void) proc;
183 (void)buflen;
184 197
185 log_text(buffer); 198 while (buflen) {
199 if (*buffer == '\n') {
200 log_text(pending_stdout);
201 pending_stdout = "";
202 } else {
203 pending_stdout += *buffer;
204 }
205 buffer++;
206 buflen--;
207 }
208}
209
210void SSHKeysApp::log_sshadd_stderr(OProcess *proc, char *buffer, int buflen)
211{
212 (void) proc;
213
214 while (buflen) {
215 if (*buffer == '\n') {
216 log_text(pending_stderr);
217 pending_stderr = "";
218 } else {
219 pending_stderr += *buffer;
220 }
221 buffer++;
222 buflen--;
223 }
186} 224}
@@ -218,6 +256,6 @@ void SSHKeysApp::doAddButton()
218 addprocess << "ssh-add" << "--" << KeyFileName->currentText(); 256 addprocess << "ssh-add" << "--" << KeyFileName->currentText();
219 log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText()); 257 // log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText());
220 } else { 258 } else {
221 addprocess << "ssh-add"; 259 addprocess << "ssh-add";
222 log_text(tr("Running ssh-add")); 260 // log_text(tr("Running ssh-add"));
223 } 261 }
@@ -229,2 +267,3 @@ void SSHKeysApp::doAddButton()
229 } 267 }
268 flush_sshadd_output();
230} 269}
@@ -244,5 +283,5 @@ void SSHKeysApp::doRemoveAllButton()
244 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), 283 connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)),
245 this, SLOT(log_sshadd_output(OProcess*,char*,int))); 284 this, SLOT(log_sshadd_stderr(OProcess*,char*,int)));
246 285
247 log_text(tr("Running ssh-add -D")); 286 //log_text(tr("Running ssh-add -D"));
248 sshadd_process << "ssh-add" << "-D"; 287 sshadd_process << "ssh-add" << "-D";
@@ -252,2 +291,3 @@ void SSHKeysApp::doRemoveAllButton()
252 } 291 }
292 flush_sshadd_output();
253 doRefreshListButton(); 293 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
37 void log_text(const char *text); 37 void log_text(const char *text);
38 void flush_sshadd_output(void);
39
38 enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; 40 enum { Noise, KeyName, KeySize, KeyFingerprint } keystate;
@@ -43,2 +45,4 @@ class SSHKeysApp : public SSHKeysBase
43 OProcess addprocess; 45 OProcess addprocess;
46 QString pending_stdout;
47 QString pending_stderr;
44 48
@@ -50,2 +54,3 @@ class SSHKeysApp : public SSHKeysBase
50 void log_sshadd_output(OProcess *proc, char *buffer, int buflen); 54 void log_sshadd_output(OProcess *proc, char *buffer, int buflen);
55 void log_sshadd_stderr(OProcess *proc, char *buffer, int buflen);
51 void ssh_add_exited(OProcess *proc); 56 void ssh_add_exited(OProcess *proc);