author | zecke <zecke> | 2004-11-15 15:25:22 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-15 15:25:22 (UTC) |
commit | ef26112d97cd5573642a0f00fd54347229857402 (patch) (unidiff) | |
tree | cb62b1e2a6a6a5ccd301fcbb0faac535ff865ee1 | |
parent | 3b935c93d5576e6590ed89c75066983124e2c628 (diff) | |
download | opie-ef26112d97cd5573642a0f00fd54347229857402.zip opie-ef26112d97cd5573642a0f00fd54347229857402.tar.gz opie-ef26112d97cd5573642a0f00fd54347229857402.tar.bz2 |
-Remove char cast for homedir but use QFile::encodeName
-Make it quicklaunchable
-rw-r--r-- | noncore/settings/sshkeys/main.cpp | 28 | ||||
-rw-r--r-- | noncore/settings/sshkeys/opie-sshkeys.control | 2 | ||||
-rw-r--r-- | noncore/settings/sshkeys/sshkeys.cpp | 16 | ||||
-rw-r--r-- | noncore/settings/sshkeys/sshkeys.h | 1 | ||||
-rw-r--r-- | noncore/settings/sshkeys/sshkeys.pro | 4 |
5 files changed, 20 insertions, 31 deletions
diff --git a/noncore/settings/sshkeys/main.cpp b/noncore/settings/sshkeys/main.cpp index 9f19d0f..d0c0e2b 100644 --- a/noncore/settings/sshkeys/main.cpp +++ b/noncore/settings/sshkeys/main.cpp | |||
@@ -1,49 +1,27 @@ | |||
1 | /* | 1 | /* |
2 | * ssh-agent key manipulation utility | 2 | * ssh-agent key manipulation utility |
3 | * | 3 | * |
4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> | 4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qpe/qpeapplication.h> | 22 | #include <opie2/oapplicationfactory.h> |
23 | #include "sshkeys.h" | 23 | #include "sshkeys.h" |
24 | #include <stdio.h> | ||
25 | #include <sys/types.h> | ||
26 | #include <sys/stat.h> | ||
27 | #include <fcntl.h> | ||
28 | #include <sys/ioctl.h> | ||
29 | #include <unistd.h> | ||
30 | 24 | ||
31 | int main(int argc, char *argv[]) | 25 | OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<SSHKeysApp> ) |
32 | { | ||
33 | QPEApplication a(argc, argv); | ||
34 | SSHKeysApp app; | ||
35 | int fd; | ||
36 | 26 | ||
37 | /* If we had a controlling TTY, detach from it. | ||
38 | This is to ensure that SSH uses ssh-askpass */ | ||
39 | fd = open("/dev/tty", O_RDONLY); | ||
40 | if (fd != -1) { | ||
41 | ioctl(fd, TIOCNOTTY, NULL); | ||
42 | close(fd); | ||
43 | } | ||
44 | |||
45 | a.showMainWidget(&app); | ||
46 | |||
47 | return a.exec(); | ||
48 | } | ||
49 | 27 | ||
diff --git a/noncore/settings/sshkeys/opie-sshkeys.control b/noncore/settings/sshkeys/opie-sshkeys.control index 08e3508..1f2a1fc 100644 --- a/noncore/settings/sshkeys/opie-sshkeys.control +++ b/noncore/settings/sshkeys/opie-sshkeys.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-sshkeys | 1 | Package: opie-sshkeys |
2 | Files: bin/sshkeys apps/Settings/sshkeys.desktop pics/sshkeys/sshkeys.png | 2 | Files: plugins/applications/libsshkeys.so* bin/sshkeys apps/Settings/sshkeys.desktop pics/sshkeys/sshkeys.png |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/settings | 4 | Section: opie/settings |
5 | Maintainer: David Woodhouse <dwmw2@infradead.org> | 5 | Maintainer: David Woodhouse <dwmw2@infradead.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Depends: task-opie-minimal, ssh, opie-sh-ssh-askpass, libopiecore2 | 7 | Depends: task-opie-minimal, ssh, opie-sh-ssh-askpass, libopiecore2 |
8 | Description: Utility for managing ssh-agent keys. | 8 | Description: Utility for managing ssh-agent keys. |
9 | Version: $QPE_VERSION$EXTRAVERSION | 9 | Version: $QPE_VERSION$EXTRAVERSION |
diff --git a/noncore/settings/sshkeys/sshkeys.cpp b/noncore/settings/sshkeys/sshkeys.cpp index cebc845..d8b1014 100644 --- a/noncore/settings/sshkeys/sshkeys.cpp +++ b/noncore/settings/sshkeys/sshkeys.cpp | |||
@@ -1,294 +1,306 @@ | |||
1 | /* | 1 | /* |
2 | * ssh-agent key manipulation utility | 2 | * ssh-agent key manipulation utility |
3 | * | 3 | * |
4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> | 4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | #include "sshkeys.h" | 21 | #include "sshkeys.h" |
22 | 22 | ||
23 | #include <qpe/qpeapplication.h> | 23 | #include <qpe/qpeapplication.h> |
24 | #include <qdir.h> | ||
25 | #include <qfile.h> | ||
24 | #include <qmultilineedit.h> | 26 | #include <qmultilineedit.h> |
25 | #include <qpushbutton.h> | 27 | #include <qpushbutton.h> |
26 | #include <qlistview.h> | 28 | #include <qlistview.h> |
27 | #include <qcombobox.h> | 29 | #include <qcombobox.h> |
28 | 30 | ||
29 | #include <sys/types.h> | 31 | #include <sys/types.h> |
30 | #include <sys/stat.h> | 32 | #include <sys/stat.h> |
33 | #include <fcntl.h> | ||
34 | #include <sys/ioctl.h> | ||
31 | #include <stdlib.h> | 35 | #include <stdlib.h> |
32 | #include <unistd.h> | 36 | #include <unistd.h> |
33 | #include <stdio.h> | 37 | #include <stdio.h> |
34 | #include <ctype.h> | 38 | #include <ctype.h> |
35 | 39 | ||
36 | using namespace Opie::Core; | 40 | using namespace Opie::Core; |
37 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; | 41 | static char *keynames[] = { "identity", "id_rsa", "id_dsa" }; |
38 | 42 | ||
39 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) | 43 | SSHKeysApp::SSHKeysApp( QWidget* parent, const char* name, WFlags fl ) |
40 | : SSHKeysBase( parent, name, fl ) | 44 | : SSHKeysBase( parent, name, fl ) |
41 | { | 45 | { |
42 | char *home = getenv("HOME"); | 46 | /* If we had a controlling TTY, detach from it. |
47 | This is to ensure that SSH uses ssh-askpass */ | ||
48 | int fd = open("/dev/tty", O_RDONLY); | ||
49 | if (fd != -1) { | ||
50 | ioctl(fd, TIOCNOTTY, NULL); | ||
51 | close(fd); | ||
52 | } | ||
53 | |||
54 | QCString home = QFile::encodeName( QDir::homeDirPath() ); | ||
43 | unsigned i; | 55 | unsigned i; |
44 | 56 | ||
45 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); | 57 | connect(AddButton, SIGNAL(clicked()), this, SLOT(doAddButton())); |
46 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); | 58 | connect(RefreshListButton, SIGNAL(clicked()), this, SLOT(doRefreshListButton())); |
47 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); | 59 | connect(RemoveAllButton, SIGNAL(clicked()), this, SLOT(doRemoveAllButton())); |
48 | 60 | ||
49 | connect(&addprocess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), | 61 | connect(&addprocess, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
50 | this, SLOT(log_sshadd_output(Opie::Core::OProcess*,char*,int))); | 62 | this, SLOT(log_sshadd_output(Opie::Core::OProcess*,char*,int))); |
51 | connect(&addprocess, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), | 63 | connect(&addprocess, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
52 | this, SLOT(log_sshadd_stderr(Opie::Core::OProcess*,char*,int))); | 64 | this, SLOT(log_sshadd_stderr(Opie::Core::OProcess*,char*,int))); |
53 | connect(&addprocess, SIGNAL(processExited(Opie::Core::OProcess*)), | 65 | connect(&addprocess, SIGNAL(processExited(Opie::Core::OProcess*)), |
54 | this, SLOT(ssh_add_exited(Opie::Core::OProcess*))); | 66 | this, SLOT(ssh_add_exited(Opie::Core::OProcess*))); |
55 | 67 | ||
56 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), | 68 | connect(KeyFileName, SIGNAL(textChanged(const QString&)), |
57 | this, SLOT(add_text_changed(const QString&))); | 69 | this, SLOT(add_text_changed(const QString&))); |
58 | 70 | ||
59 | if (home) { | 71 | if (home) { |
60 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { | 72 | for (i = 0; i < sizeof(keynames)/sizeof(keynames[0]); i++) { |
61 | char thiskeyname[32]; | 73 | char thiskeyname[32]; |
62 | 74 | ||
63 | thiskeyname[31] = 0; | 75 | thiskeyname[31] = 0; |
64 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home, keynames[i]); | 76 | snprintf(thiskeyname, 31, "%s/.ssh/%s", home.data(), keynames[i]); |
65 | if (!access(thiskeyname, R_OK)) { | 77 | if (!access(thiskeyname, R_OK)) { |
66 | KeyFileName->insertItem(thiskeyname); | 78 | KeyFileName->insertItem(thiskeyname); |
67 | } | 79 | } |
68 | } | 80 | } |
69 | } | 81 | } |
70 | 82 | ||
71 | doRefreshListButton(); | 83 | doRefreshListButton(); |
72 | } | 84 | } |
73 | 85 | ||
74 | SSHKeysApp::~SSHKeysApp() | 86 | SSHKeysApp::~SSHKeysApp() |
75 | { | 87 | { |
76 | } | 88 | } |
77 | 89 | ||
78 | void SSHKeysApp::doRefreshListButton() | 90 | void SSHKeysApp::doRefreshListButton() |
79 | { | 91 | { |
80 | OProcess sshadd_process; | 92 | OProcess sshadd_process; |
81 | QListViewItem *t = KeyList->firstChild(); | 93 | QListViewItem *t = KeyList->firstChild(); |
82 | 94 | ||
83 | while(t) { | 95 | while(t) { |
84 | QListViewItem *next = t->nextSibling(); | 96 | QListViewItem *next = t->nextSibling(); |
85 | KeyList->takeItem(t); | 97 | KeyList->takeItem(t); |
86 | delete(t); | 98 | delete(t); |
87 | t = next; | 99 | t = next; |
88 | } | 100 | } |
89 | 101 | ||
90 | connect(&sshadd_process, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), | 102 | connect(&sshadd_process, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
91 | this, SLOT(get_list_keys_output(Opie::Core::OProcess*,char*,int))); | 103 | this, SLOT(get_list_keys_output(Opie::Core::OProcess*,char*,int))); |
92 | connect(&sshadd_process, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), | 104 | connect(&sshadd_process, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
93 | this, SLOT(log_sshadd_stderr(Opie::Core::OProcess*,char*,int))); | 105 | this, SLOT(log_sshadd_stderr(Opie::Core::OProcess*,char*,int))); |
94 | 106 | ||
95 | keystate = KeySize; | 107 | keystate = KeySize; |
96 | incoming_keyname=""; | 108 | incoming_keyname=""; |
97 | incoming_keysize=""; | 109 | incoming_keysize=""; |
98 | incoming_keyfingerprint=""; | 110 | incoming_keyfingerprint=""; |
99 | 111 | ||
100 | // log_text("Running ssh-add -l"); | 112 | // log_text("Running ssh-add -l"); |
101 | sshadd_process << "ssh-add" << "-l"; | 113 | sshadd_process << "ssh-add" << "-l"; |
102 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); | 114 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); |
103 | if (!ret) { | 115 | if (!ret) { |
104 | log_text(tr("Error running ssh-add")); | 116 | log_text(tr("Error running ssh-add")); |
105 | return; | 117 | return; |
106 | } | 118 | } |
107 | flush_sshadd_output(); | 119 | flush_sshadd_output(); |
108 | if (sshadd_process.exitStatus() == 2) { | 120 | if (sshadd_process.exitStatus() == 2) { |
109 | setEnabled(FALSE); | 121 | setEnabled(FALSE); |
110 | } | 122 | } |
111 | } | 123 | } |
112 | 124 | ||
113 | void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen) | 125 | void SSHKeysApp::get_list_keys_output(OProcess *proc, char *buffer, int buflen) |
114 | { | 126 | { |
115 | int i; | 127 | int i; |
116 | (void) proc; | 128 | (void) proc; |
117 | 129 | ||
118 | for (i=0; i<buflen; i++) { | 130 | for (i=0; i<buflen; i++) { |
119 | switch(keystate) { | 131 | switch(keystate) { |
120 | case Noise: | 132 | case Noise: |
121 | noise: | 133 | noise: |
122 | if (buffer[i] == '\n') { | 134 | if (buffer[i] == '\n') { |
123 | log_text(incoming_noise.local8Bit()); | 135 | log_text(incoming_noise.local8Bit()); |
124 | incoming_noise = ""; | 136 | incoming_noise = ""; |
125 | keystate = KeySize; | 137 | keystate = KeySize; |
126 | } else { | 138 | } else { |
127 | incoming_noise += buffer[i]; | 139 | incoming_noise += buffer[i]; |
128 | } | 140 | } |
129 | break; | 141 | break; |
130 | 142 | ||
131 | case KeySize: | 143 | case KeySize: |
132 | if (isdigit(buffer[i])) { | 144 | if (isdigit(buffer[i])) { |
133 | incoming_keysize += buffer[i]; | 145 | incoming_keysize += buffer[i]; |
134 | } else if (buffer[i] == ' ') { | 146 | } else if (buffer[i] == ' ') { |
135 | keystate = KeyFingerprint; | 147 | keystate = KeyFingerprint; |
136 | } else { | 148 | } else { |
137 | incoming_keysize = ""; | 149 | incoming_keysize = ""; |
138 | incoming_noise = ""; | 150 | incoming_noise = ""; |
139 | keystate = Noise; | 151 | keystate = Noise; |
140 | goto noise; | 152 | goto noise; |
141 | } | 153 | } |
142 | break; | 154 | break; |
143 | 155 | ||
144 | case KeyFingerprint: | 156 | case KeyFingerprint: |
145 | if (isxdigit(buffer[i]) || buffer[i] == ':') { | 157 | if (isxdigit(buffer[i]) || buffer[i] == ':') { |
146 | incoming_keyfingerprint += buffer[i]; | 158 | incoming_keyfingerprint += buffer[i]; |
147 | } else if (buffer[i] == ' ') { | 159 | } else if (buffer[i] == ' ') { |
148 | keystate = KeyName; | 160 | keystate = KeyName; |
149 | } else { | 161 | } else { |
150 | incoming_keysize = ""; | 162 | incoming_keysize = ""; |
151 | incoming_keyfingerprint = ""; | 163 | incoming_keyfingerprint = ""; |
152 | incoming_noise = ""; | 164 | incoming_noise = ""; |
153 | keystate = Noise; | 165 | keystate = Noise; |
154 | goto noise; | 166 | goto noise; |
155 | } | 167 | } |
156 | break; | 168 | break; |
157 | 169 | ||
158 | case KeyName: | 170 | case KeyName: |
159 | if (buffer[i] == '\n') { | 171 | if (buffer[i] == '\n') { |
160 | /* Wheee. Got one. */ | 172 | /* Wheee. Got one. */ |
161 | KeyList->insertItem(new | 173 | KeyList->insertItem(new |
162 | QListViewItem(KeyList, incoming_keyname, incoming_keysize, incoming_keyfingerprint)); | 174 | QListViewItem(KeyList, incoming_keyname, incoming_keysize, incoming_keyfingerprint)); |
163 | incoming_keysize = ""; | 175 | incoming_keysize = ""; |
164 | incoming_keyfingerprint = ""; | 176 | incoming_keyfingerprint = ""; |
165 | incoming_keyname = ""; | 177 | incoming_keyname = ""; |
166 | keystate = KeySize; | 178 | keystate = KeySize; |
167 | } else if (isprint(buffer[i])) { | 179 | } else if (isprint(buffer[i])) { |
168 | incoming_keyname += buffer[i]; | 180 | incoming_keyname += buffer[i]; |
169 | } else { | 181 | } else { |
170 | incoming_keysize = ""; | 182 | incoming_keysize = ""; |
171 | incoming_keyfingerprint = ""; | 183 | incoming_keyfingerprint = ""; |
172 | incoming_noise = ""; | 184 | incoming_noise = ""; |
173 | keystate = Noise; | 185 | keystate = Noise; |
174 | goto noise; | 186 | goto noise; |
175 | } | 187 | } |
176 | break; | 188 | break; |
177 | } | 189 | } |
178 | } | 190 | } |
179 | } | 191 | } |
180 | 192 | ||
181 | void SSHKeysApp::flush_sshadd_output(void) | 193 | void SSHKeysApp::flush_sshadd_output(void) |
182 | { | 194 | { |
183 | if (pending_stdout.length()) { | 195 | if (pending_stdout.length()) { |
184 | log_text(pending_stdout.ascii()); | 196 | log_text(pending_stdout.ascii()); |
185 | } | 197 | } |
186 | pending_stdout = ""; | 198 | pending_stdout = ""; |
187 | 199 | ||
188 | if (pending_stderr.length()) { | 200 | if (pending_stderr.length()) { |
189 | log_text(pending_stderr.ascii()); | 201 | log_text(pending_stderr.ascii()); |
190 | } | 202 | } |
191 | pending_stderr = ""; | 203 | pending_stderr = ""; |
192 | } | 204 | } |
193 | 205 | ||
194 | void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen) | 206 | void SSHKeysApp::log_sshadd_output(OProcess *proc, char *buffer, int buflen) |
195 | { | 207 | { |
196 | (void) proc; | 208 | (void) proc; |
197 | 209 | ||
198 | while (buflen) { | 210 | while (buflen) { |
199 | if (*buffer == '\n') { | 211 | if (*buffer == '\n') { |
200 | log_text(pending_stdout); | 212 | log_text(pending_stdout); |
201 | pending_stdout = ""; | 213 | pending_stdout = ""; |
202 | } else { | 214 | } else { |
203 | pending_stdout += *buffer; | 215 | pending_stdout += *buffer; |
204 | } | 216 | } |
205 | buffer++; | 217 | buffer++; |
206 | buflen--; | 218 | buflen--; |
207 | } | 219 | } |
208 | } | 220 | } |
209 | 221 | ||
210 | void SSHKeysApp::log_sshadd_stderr(OProcess *proc, char *buffer, int buflen) | 222 | void SSHKeysApp::log_sshadd_stderr(OProcess *proc, char *buffer, int buflen) |
211 | { | 223 | { |
212 | (void) proc; | 224 | (void) proc; |
213 | 225 | ||
214 | while (buflen) { | 226 | while (buflen) { |
215 | if (*buffer == '\n') { | 227 | if (*buffer == '\n') { |
216 | log_text(pending_stderr); | 228 | log_text(pending_stderr); |
217 | pending_stderr = ""; | 229 | pending_stderr = ""; |
218 | } else { | 230 | } else { |
219 | pending_stderr += *buffer; | 231 | pending_stderr += *buffer; |
220 | } | 232 | } |
221 | buffer++; | 233 | buffer++; |
222 | buflen--; | 234 | buflen--; |
223 | } | 235 | } |
224 | } | 236 | } |
225 | 237 | ||
226 | void SSHKeysApp::ssh_add_exited(OProcess *proc) | 238 | void SSHKeysApp::ssh_add_exited(OProcess *proc) |
227 | { | 239 | { |
228 | (void)proc; | 240 | (void)proc; |
229 | 241 | ||
230 | doRefreshListButton(); | 242 | doRefreshListButton(); |
231 | setEnabled(TRUE); | 243 | setEnabled(TRUE); |
232 | if (proc->exitStatus() == 2) { | 244 | if (proc->exitStatus() == 2) { |
233 | setEnabled(FALSE); | 245 | setEnabled(FALSE); |
234 | } | 246 | } |
235 | } | 247 | } |
236 | 248 | ||
237 | void SSHKeysApp::add_text_changed(const QString &text) | 249 | void SSHKeysApp::add_text_changed(const QString &text) |
238 | { | 250 | { |
239 | struct stat sbuf; | 251 | struct stat sbuf; |
240 | 252 | ||
241 | if (!text.length() || (!access(text.ascii(), R_OK) && | 253 | if (!text.length() || (!access(text.ascii(), R_OK) && |
242 | !stat(text.ascii(), &sbuf) && | 254 | !stat(text.ascii(), &sbuf) && |
243 | S_ISREG(sbuf.st_mode))) | 255 | S_ISREG(sbuf.st_mode))) |
244 | AddButton->setEnabled(TRUE); | 256 | AddButton->setEnabled(TRUE); |
245 | else | 257 | else |
246 | AddButton->setEnabled(FALSE); | 258 | AddButton->setEnabled(FALSE); |
247 | } | 259 | } |
248 | 260 | ||
249 | void SSHKeysApp::doAddButton() | 261 | void SSHKeysApp::doAddButton() |
250 | { | 262 | { |
251 | addprocess.clearArguments(); | 263 | addprocess.clearArguments(); |
252 | 264 | ||
253 | setEnabled(FALSE); | 265 | setEnabled(FALSE); |
254 | 266 | ||
255 | if (KeyFileName->currentText().length()) { | 267 | if (KeyFileName->currentText().length()) { |
256 | addprocess << "ssh-add" << "--" << KeyFileName->currentText(); | 268 | addprocess << "ssh-add" << "--" << KeyFileName->currentText(); |
257 | // log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText()); | 269 | // log_text(QString(tr("Running ssh-add -- ")) + KeyFileName->currentText()); |
258 | } else { | 270 | } else { |
259 | addprocess << "ssh-add"; | 271 | addprocess << "ssh-add"; |
260 | // log_text(tr("Running ssh-add")); | 272 | // log_text(tr("Running ssh-add")); |
261 | } | 273 | } |
262 | bool ret = addprocess.start(OProcess::NotifyOnExit, OProcess::AllOutput); | 274 | bool ret = addprocess.start(OProcess::NotifyOnExit, OProcess::AllOutput); |
263 | if (!ret) { | 275 | if (!ret) { |
264 | log_text(tr("Error running ssh-add")); | 276 | log_text(tr("Error running ssh-add")); |
265 | doRefreshListButton(); | 277 | doRefreshListButton(); |
266 | setEnabled(TRUE); | 278 | setEnabled(TRUE); |
267 | } | 279 | } |
268 | flush_sshadd_output(); | 280 | flush_sshadd_output(); |
269 | } | 281 | } |
270 | 282 | ||
271 | void SSHKeysApp::log_text(const char *text) | 283 | void SSHKeysApp::log_text(const char *text) |
272 | { | 284 | { |
273 | TextOutput->append(text); | 285 | TextOutput->append(text); |
274 | TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE); | 286 | TextOutput->setCursorPosition(TextOutput->numLines()+1, 0, FALSE); |
275 | } | 287 | } |
276 | 288 | ||
277 | void SSHKeysApp::doRemoveAllButton() | 289 | void SSHKeysApp::doRemoveAllButton() |
278 | { | 290 | { |
279 | OProcess sshadd_process; | 291 | OProcess sshadd_process; |
280 | 292 | ||
281 | connect(&sshadd_process, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), | 293 | connect(&sshadd_process, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int)), |
282 | this, SLOT(log_sshadd_output(Opie::Core::OProcess*,char*,int))); | 294 | this, SLOT(log_sshadd_output(Opie::Core::OProcess*,char*,int))); |
283 | connect(&sshadd_process, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), | 295 | connect(&sshadd_process, SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)), |
284 | this, SLOT(log_sshadd_stderr(Opie::Core::OProcess*,char*,int))); | 296 | this, SLOT(log_sshadd_stderr(Opie::Core::OProcess*,char*,int))); |
285 | 297 | ||
286 | // log_text(tr("Running ssh-add -D")); | 298 | // log_text(tr("Running ssh-add -D")); |
287 | sshadd_process << "ssh-add" << "-D"; | 299 | sshadd_process << "ssh-add" << "-D"; |
288 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); | 300 | bool ret = sshadd_process.start(OProcess::Block, OProcess::AllOutput); |
289 | if (!ret) { | 301 | if (!ret) { |
290 | log_text(tr("Error running ssh-add")); | 302 | log_text(tr("Error running ssh-add")); |
291 | } | 303 | } |
292 | flush_sshadd_output(); | 304 | flush_sshadd_output(); |
293 | doRefreshListButton(); | 305 | doRefreshListButton(); |
294 | } | 306 | } |
diff --git a/noncore/settings/sshkeys/sshkeys.h b/noncore/settings/sshkeys/sshkeys.h index 519f540..0807f74 100644 --- a/noncore/settings/sshkeys/sshkeys.h +++ b/noncore/settings/sshkeys/sshkeys.h | |||
@@ -1,61 +1,62 @@ | |||
1 | /* | 1 | /* |
2 | * ssh-agent key manipulation utility | 2 | * ssh-agent key manipulation utility |
3 | * | 3 | * |
4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> | 4 | * (C) 2002 David Woodhouse <dwmw2@infradead.org> |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef SSHKEYSAPP_H | 22 | #ifndef SSHKEYSAPP_H |
23 | #define SSHKEYSAPP_H | 23 | #define SSHKEYSAPP_H |
24 | 24 | ||
25 | #include "sshkeysbase.h" | 25 | #include "sshkeysbase.h" |
26 | 26 | ||
27 | #include <opie2/oprocess.h> | 27 | #include <opie2/oprocess.h> |
28 | 28 | ||
29 | class SSHKeysApp : public SSHKeysBase | 29 | class SSHKeysApp : public SSHKeysBase |
30 | { | 30 | { |
31 | Q_OBJECT | 31 | Q_OBJECT |
32 | 32 | ||
33 | public: | 33 | public: |
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 | static QString appName() { return QString::fromLatin1( QUICKAPP_NAME); } | ||
36 | 37 | ||
37 | private: | 38 | private: |
38 | void log_text(const char *text); | 39 | void log_text(const char *text); |
39 | void flush_sshadd_output(void); | 40 | void flush_sshadd_output(void); |
40 | 41 | ||
41 | enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; | 42 | enum { Noise, KeyName, KeySize, KeyFingerprint } keystate; |
42 | QString incoming_keyname; | 43 | QString incoming_keyname; |
43 | QString incoming_keysize; | 44 | QString incoming_keysize; |
44 | QString incoming_keyfingerprint; | 45 | QString incoming_keyfingerprint; |
45 | QString incoming_noise; | 46 | QString incoming_noise; |
46 | Opie::Core::OProcess addprocess; | 47 | Opie::Core::OProcess addprocess; |
47 | QString pending_stdout; | 48 | QString pending_stdout; |
48 | QString pending_stderr; | 49 | QString pending_stderr; |
49 | 50 | ||
50 | private slots: | 51 | private slots: |
51 | void doAddButton(); | 52 | void doAddButton(); |
52 | void doRefreshListButton(); | 53 | void doRefreshListButton(); |
53 | void doRemoveAllButton(); | 54 | void doRemoveAllButton(); |
54 | void get_list_keys_output(Opie::Core::OProcess *proc, char *buffer, int buflen); | 55 | void get_list_keys_output(Opie::Core::OProcess *proc, char *buffer, int buflen); |
55 | void log_sshadd_output(Opie::Core::OProcess *proc, char *buffer, int buflen); | 56 | void log_sshadd_output(Opie::Core::OProcess *proc, char *buffer, int buflen); |
56 | void log_sshadd_stderr(Opie::Core::OProcess *proc, char *buffer, int buflen); | 57 | void log_sshadd_stderr(Opie::Core::OProcess *proc, char *buffer, int buflen); |
57 | void ssh_add_exited(Opie::Core::OProcess *proc); | 58 | void ssh_add_exited(Opie::Core::OProcess *proc); |
58 | void add_text_changed(const QString &text); | 59 | void add_text_changed(const QString &text); |
59 | }; | 60 | }; |
60 | #endif | 61 | #endif |
61 | 62 | ||
diff --git a/noncore/settings/sshkeys/sshkeys.pro b/noncore/settings/sshkeys/sshkeys.pro index 87d5ce9..0910d29 100644 --- a/noncore/settings/sshkeys/sshkeys.pro +++ b/noncore/settings/sshkeys/sshkeys.pro | |||
@@ -1,12 +1,10 @@ | |||
1 | TEMPLATE = app | 1 | CONFIG += qt quick-app |
2 | CONFIG += qt warn_on | ||
3 | HEADERS = sshkeys.h | 2 | HEADERS = sshkeys.h |
4 | SOURCES = main.cpp sshkeys.cpp | 3 | SOURCES = main.cpp sshkeys.cpp |
5 | TARGET = sshkeys | 4 | TARGET = sshkeys |
6 | INTERFACES = sshkeysbase.ui | 5 | INTERFACES = sshkeysbase.ui |
7 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 7 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe -lopiecore2 | 8 | LIBS += -lqpe -lopiecore2 |
10 | DESTDIR = $(OPIEDIR)/bin | ||
11 | 9 | ||
12 | include ( $(OPIEDIR)/include.pro ) | 10 | include ( $(OPIEDIR)/include.pro ) |