author | zecke <zecke> | 2004-03-14 16:01:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-03-14 16:01:52 (UTC) |
commit | f12af18557c8f376f0c6c30e80a85737ff6c592e (patch) (unidiff) | |
tree | d60806f34f4ff6af82491579e80c9ef72cd4071e /noncore/settings/sshkeys | |
parent | 13aeeabab5f2a6262b33de83cc9559a49365e325 (diff) | |
download | opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.zip opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.tar.gz opie-f12af18557c8f376f0c6c30e80a85737ff6c592e.tar.bz2 |
Make use of ODP
-rw-r--r-- | noncore/settings/sshkeys/sshkeys.cpp | 15 | ||||
-rw-r--r-- | noncore/settings/sshkeys/sshkeys.h | 10 |
2 files changed, 13 insertions, 12 deletions
diff --git a/noncore/settings/sshkeys/sshkeys.cpp b/noncore/settings/sshkeys/sshkeys.cpp index e76fd6b..31f6b85 100644 --- a/noncore/settings/sshkeys/sshkeys.cpp +++ b/noncore/settings/sshkeys/sshkeys.cpp | |||
@@ -24,41 +24,42 @@ | |||
24 | #include <qmultilineedit.h> | 24 | #include <qmultilineedit.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qlistview.h> | 26 | #include <qlistview.h> |
27 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
28 | 28 | ||
29 | #include <sys/types.h> | 29 | #include <sys/types.h> |
30 | #include <sys/stat.h> | 30 | #include <sys/stat.h> |
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | #include <unistd.h> | 32 | #include <unistd.h> |
33 | #include <stdio.h> | 33 | #include <stdio.h> |
34 | #include <ctype.h> | 34 | #include <ctype.h> |
35 | 35 | ||
36 | using namespace Opie::Core; | ||
36 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; | 37 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; |
37 | 38 | ||
38 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) | 39 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) |
39 | : SSHKeysBase( parent, name, fl ) | 40 | : SSHKeysBase( parent, name, fl ) |
40 | { | 41 | { |
41 | char *home = getenv("HOME"); | 42 | char *home = getenv("HOME"); |
42 | unsigned i; | 43 | unsigned i; |
43 | 44 | ||
44 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); | 45 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); |
45 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); | 46 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); |
46 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); | 47 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); |
47 | 48 | ||
48 | connect(&addprocess, SIGNAL(receivedStdout(OProcess*,char*,int)), | 49 | connect(&addprocess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
49 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); | 50 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); |
50 | connect(&addprocess, SIGNAL(receivedStderr(OProcess*,char*,int)), | 51 | connect(&addprocess, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
51 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); | 52 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); |
52 | connect(&addprocess, SIGNAL(processExited(OProcess*)), | 53 | connect(&addprocess, SIGNAL(processExited(Opie::Core::OProcess*)), |
53 | this, SLOT(ssh_add_exited(OProcess*))); | 54 | this, SLOT(ssh_add_exited(OProcess*))); |
54 | 55 | ||
55 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), | 56 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), |
56 | this, SLOT(add_text_changed(const QString&))); | 57 | this, SLOT(add_text_changed(const QString&))); |
57 | 58 | ||
58 | if (home) { | 59 | if (home) { |
59 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { | 60 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { |
60 | char thiskeyname[32]; | 61 | char thiskeyname[32]; |
61 | 62 | ||
62 | thiskeyname[31] = 0; | 63 | thiskeyname[31] = 0; |
63 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); | 64 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); |
64 | if (!access(thiskeyname, R_OK)) { | 65 | if (!access(thiskeyname, R_OK)) { |
@@ -77,27 +78,27 @@ SSHKeysApp::~SSHKeysApp() | |||
77 | void SSHKeysApp::doRefreshListButton() | 78 | void SSHKeysApp::doRefreshListButton() |
78 | { | 79 | { |
79 | OProcess sshadd_process; | 80 | OProcess sshadd_process; |
80 | QListViewItem *t = KeyList->firstChild(); | 81 | QListViewItem *t = KeyList->firstChild(); |
81 | 82 | ||
82 | while(t) { | 83 | while(t) { |
83 | QListViewItem *next = t->nextSibling(); | 84 | QListViewItem *next = t->nextSibling(); |
84 | KeyList->takeItem(t); | 85 | KeyList->takeItem(t); |
85 | delete(t); | 86 | delete(t); |
86 | t = next; | 87 | t = next; |
87 | } | 88 | } |
88 | 89 | ||
89 | connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), | 90 | connect(&sshadd_process, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
90 | this, SLOT(get_list_keys_output(OProcess*,char*,int))); | 91 | this, SLOT(get_list_keys_output(OProcess*,char*,int))); |
91 | connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), | 92 | connect(&sshadd_process, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
92 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); | 93 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); |
93 | 94 | ||
94 | keystate = KeySize; | 95 | keystate = KeySize; |
95 | incoming_keyname=""; | 96 | incoming_keyname=""; |
96 | incoming_keysize=""; | 97 | incoming_keysize=""; |
97 | incoming_keyfingerprint=""; | 98 | incoming_keyfingerprint=""; |
98 | 99 | ||
99 | // log_text("Running ssh-add -l"); | 100 | // log_text("Running ssh-add -l"); |
100 | sshadd_process << "ssh-add" << "-l"; | 101 | sshadd_process << "ssh-add" << "-l"; |
101 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); | 102 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); |
102 | if (!ret) { | 103 | if (!ret) { |
103 | log_text(tr("Error running ssh-add")); | 104 | log_text(tr("Error running ssh-add")); |
@@ -268,26 +269,26 @@ void SSHKeysApp::doAddButton() | |||
268 | } | 269 | } |
269 | 270 | ||
270 | void SSHKeysApp::log_text(const char *text) | 271 | void SSHKeysApp::log_text(const char *text) |
271 | { | 272 | { |
272 | TextOutput->append(text); | 273 | TextOutput->append(text); |
273 | TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE); | 274 | TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE); |
274 | } | 275 | } |
275 | 276 | ||
276 | void SSHKeysApp::doRemoveAllButton() | 277 | void SSHKeysApp::doRemoveAllButton() |
277 | { | 278 | { |
278 | OProcess sshadd_process; | 279 | OProcess sshadd_process; |
279 | 280 | ||
280 | connect(&sshadd_process, SIGNAL(receivedStdout(OProcess*,char*,int)), | 281 | connect(&sshadd_process, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
281 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); | 282 | this, SLOT(log_sshadd_output(OProcess*,char*,int))); |
282 | connect(&sshadd_process, SIGNAL(receivedStderr(OProcess*,char*,int)), | 283 | connect(&sshadd_process, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
283 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); | 284 | this, SLOT(log_sshadd_stderr(OProcess*,char*,int))); |
284 | 285 | ||
285 | // log_text(tr("Running ssh-add -D")); | 286 | // log_text(tr("Running ssh-add -D")); |
286 | sshadd_process << "ssh-add" << "-D"; | 287 | sshadd_process << "ssh-add" << "-D"; |
287 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); | 288 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); |
288 | if (!ret) { | 289 | if (!ret) { |
289 | log_text(tr("Error running ssh-add")); | 290 | log_text(tr("Error running ssh-add")); |
290 | } | 291 | } |
291 | flush_sshadd_output(); | 292 | flush_sshadd_output(); |
292 | doRefreshListButton(); | 293 | doRefreshListButton(); |
293 | } | 294 | } |
diff --git a/noncore/settings/sshkeys/sshkeys.h b/noncore/settings/sshkeys/sshkeys.h index 7483bbc..519f540 100644 --- a/noncore/settings/sshkeys/sshkeys.h +++ b/noncore/settings/sshkeys/sshkeys.h | |||
@@ -34,28 +34,28 @@ class SSHKeysApp : public SSHKeysBase | |||
34 | SSHKeysApp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 34 | SSHKeysApp( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
35 | ~SSHKeysApp(); | 35 | ~SSHKeysApp(); |
36 | 36 | ||
37 | private: | 37 | private: |
38 | void log_text(const char *text); | 38 | void log_text(const char *text); |
39 | void flush_sshadd_output(void); | 39 | void flush_sshadd_output(void); |
40 | 40 | ||
41 | enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; | 41 | enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; |
42 | QString incoming_keyname; | 42 | QString incoming_keyname; |
43 | QString incoming_keysize; | 43 | QString incoming_keysize; |
44 | QString incoming_keyfingerprint; | 44 | QString incoming_keyfingerprint; |
45 | QString incoming_noise; | 45 | QString incoming_noise; |
46 | OProcess addprocess; | 46 | Opie::Core::OProcess addprocess; |
47 | QString pending_stdout; | 47 | QString pending_stdout; |
48 | QString pending_stderr; | 48 | QString pending_stderr; |
49 | 49 | ||
50 | private slots: | 50 | private slots: |
51 | void doAddButton(); | 51 | void doAddButton(); |
52 | void doRefreshListButton(); | 52 | void doRefreshListButton(); |
53 | void doRemoveAllButton(); | 53 | void doRemoveAllButton(); |
54 | void get_list_keys_output(OProcess *proc, char *buffer, int buflen); | 54 | void get_list_keys_output(Opie::Core::OProcess *proc, char *buffer, int buflen); |
55 | void log_sshadd_output(OProcess *proc, char *buffer, int buflen); | 55 | void log_sshadd_output(Opie::Core::OProcess *proc, char *buffer, int buflen); |
56 | void log_sshadd_stderr(OProcess *proc, char *buffer, int buflen); | 56 | void log_sshadd_stderr(Opie::Core::OProcess *proc, char *buffer, int buflen); |
57 | void ssh_add_exited(OProcess *proc); | 57 | void ssh_add_exited(Opie::Core::OProcess *proc); |
58 | void add_text_changed(const QString &text); | 58 | void add_text_changed(const QString &text); |
59 | }; | 59 | }; |
60 | #endif | 60 | #endif |
61 | 61 | ||