author | llornkcor <llornkcor> | 2005-08-15 08:31:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-08-15 08:31:15 (UTC) |
commit | 75eb12d42636cbd837d49f9c1347387e96e4174b (patch) (unidiff) | |
tree | c49c0aa4f126888fdf3b6cc107b9452be3bec2f3 | |
parent | fb0e4444f79ad253998f1a2e5c706e3fcf29ad08 (diff) | |
download | opie-75eb12d42636cbd837d49f9c1347387e96e4174b.zip opie-75eb12d42636cbd837d49f9c1347387e96e4174b.tar.gz opie-75eb12d42636cbd837d49f9c1347387e96e4174b.tar.bz2 |
better way for get ip
-rw-r--r-- | noncore/net/opie-smb/qsmb.cpp | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/noncore/net/opie-smb/qsmb.cpp b/noncore/net/opie-smb/qsmb.cpp index 8aa4987..d6d1b23 100644 --- a/noncore/net/opie-smb/qsmb.cpp +++ b/noncore/net/opie-smb/qsmb.cpp | |||
@@ -1,194 +1,193 @@ | |||
1 | #include "qsmb.h" | 1 | #include "qsmb.h" |
2 | #include <qpushbutton.h> | 2 | #include <qpushbutton.h> |
3 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.h> |
4 | 4 | ||
5 | #include <string.h> | 5 | #include <string.h> |
6 | #include <qstring.h> | 6 | #include <qstring.h> |
7 | #include <qstringlist.h> | ||
7 | #include <qdir.h> | 8 | #include <qdir.h> |
8 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
9 | 10 | ||
10 | #include <qpe/process.h> | 11 | #include <qpe/process.h> |
11 | #include <qlabel.h> | 12 | #include <qlabel.h> |
12 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
13 | #include <qcombobox.h> | 14 | #include <qcombobox.h> |
14 | #include <qstringlist.h> | 15 | #include <qstringlist.h> |
15 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
16 | #include <qtextview.h> | 17 | #include <qtextview.h> |
17 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
18 | 19 | ||
19 | 20 | ||
20 | #include <pthread.h> | 21 | #include <pthread.h> |
21 | #include <signal.h> | 22 | #include <signal.h> |
22 | #include <ctype.h> | 23 | #include <ctype.h> |
23 | 24 | ||
24 | 25 | ||
26 | #include <netinet/in.h> | ||
27 | #include <arpa/inet.h> | ||
28 | |||
29 | #include <rpc/clnt.h> | ||
30 | |||
31 | |||
25 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
26 | using namespace Opie::Core; | 33 | using namespace Opie::Core; |
27 | 34 | ||
28 | 35 | ||
29 | Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) | 36 | Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) |
30 | : FormQPESMBBase( parent, name, fl ) | 37 | : FormQPESMBBase( parent, name, fl ) |
31 | { | 38 | { |
32 | connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); | 39 | connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); |
33 | connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); | 40 | connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); |
34 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); | 41 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); |
35 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); | 42 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); |
36 | 43 | ||
37 | mountpt->insertItem("/mnt/samba1",-1); | 44 | mountpt->insertItem("/mnt/samba1",-1); |
38 | mountpt->insertItem("/mnt/samba2",-1); | 45 | mountpt->insertItem("/mnt/samba2",-1); |
39 | mountpt->insertItem("/mnt/samba3",-1); | 46 | mountpt->insertItem("/mnt/samba3",-1); |
40 | 47 | ||
41 | top_element = NULL; | 48 | top_element = NULL; |
42 | scanning = false; | 49 | scanning = false; |
43 | } | 50 | } |
44 | 51 | ||
45 | Qsmb::~Qsmb() | 52 | Qsmb::~Qsmb() |
46 | { | 53 | { |
47 | } | 54 | } |
48 | 55 | ||
49 | void Qsmb::clear() | 56 | void Qsmb::clear() |
50 | { | 57 | { |
51 | if (scanning) return; | 58 | if (scanning) return; |
52 | ListViewScan->clear(); | 59 | ListViewScan->clear(); |
53 | TextViewOutput->setText(""); | 60 | TextViewOutput->setText(""); |
54 | top_element = NULL; | 61 | top_element = NULL; |
55 | } | 62 | } |
56 | 63 | ||
57 | void Qsmb::scanClicked() | 64 | void Qsmb::scanClicked() |
58 | { | 65 | { |
59 | if (scanning) return; | 66 | if (scanning) return; |
60 | pthread_create(&tpid, NULL, runit, (void *)this); | 67 | pthread_create(&tpid, NULL, runit, (void *)this); |
61 | } | 68 | } |
62 | 69 | ||
63 | void Qsmb::DoItClicked() | 70 | void Qsmb::DoItClicked() |
64 | { | 71 | { |
65 | 72 | ||
66 | if(! ListViewScan->selectedItem()) { | 73 | if(! ListViewScan->selectedItem()) { |
67 | QMessageBox::warning(this, tr("Error"),tr("<p>No share selected!</p>")); | 74 | QMessageBox::warning(this, tr("Error"),tr("<p>No share selected!</p>")); |
68 | return; | 75 | return; |
69 | } | 76 | } |
70 | if (scanning) return; | 77 | if (scanning) return; |
71 | pthread_create(&tpid, NULL, runitm, (void *)this); | 78 | pthread_create(&tpid, NULL, runitm, (void *)this); |
72 | } | 79 | } |
73 | 80 | ||
74 | void* runit(void* arg) | 81 | void* runit(void* arg) |
75 | { | 82 | { |
76 | Qsmb* caller = (Qsmb*)arg; | 83 | Qsmb* caller = (Qsmb*)arg; |
77 | caller->scan(); | 84 | caller->scan(); |
78 | return(0); | 85 | return(0); |
79 | } | 86 | } |
80 | 87 | ||
81 | void* runitm(void* arg) | 88 | void* runitm(void* arg) |
82 | { | 89 | { |
83 | Qsmb* caller = (Qsmb*)arg; | 90 | Qsmb* caller = (Qsmb*)arg; |
84 | caller->DoIt(); | 91 | caller->DoIt(); |
85 | return(0); | 92 | return(0); |
86 | } | 93 | } |
87 | 94 | ||
88 | void Qsmb::scan() | 95 | void Qsmb::scan() |
89 | { | 96 | { |
90 | int i; | 97 | int i; |
91 | 98 | ||
92 | if (scanning) return; | 99 | if (scanning) return; |
93 | scanning = true; | 100 | scanning = true; |
94 | 101 | ||
95 | char match[512], lmhosts[512]; | 102 | QString match; |
103 | char lmhosts[512]; | ||
96 | QString cmd; | 104 | QString cmd; |
97 | char result[256]; | 105 | char result[256]; |
98 | 106 | ||
99 | FILE *pipe, *pipe2; | 107 | FILE *pipe, *pipe2; |
100 | 108 | ||
101 | LScan->setText("Scanning..."); | 109 | LScan->setText("Scanning..."); |
102 | qApp->processEvents(); | 110 | qApp->processEvents(); |
103 | 111 | ||
104 | cmd = "ifconfig |grep 'addr:'|awk '{print $2}'|awk 'BEGIN{FS=\":\"}{print $2}'|sed 's/\\.[0-9]*$//'|head -n1"; | 112 | sockaddr_in my_addr; |
113 | get_myaddress( &my_addr); | ||
105 | 114 | ||
106 | owarn << "cmd: " << cmd << oendl; | 115 | QString ip = inet_ntoa( my_addr.sin_addr); |
116 | owarn << "IP Address : " << ip<< oendl; | ||
107 | 117 | ||
108 | /* run findsmb & read output */ | 118 | match = ip.left(5); |
109 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { | ||
110 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | ||
111 | TextViewOutput->append(result); | ||
112 | return; | ||
113 | } | ||
114 | while(fgets(result, 256, pipe) != NULL) { | ||
115 | strcpy( match, result); | ||
116 | match[5]='\0'; | ||
117 | break; | ||
118 | } | ||
119 | owarn << "match: " << match << oendl; | ||
120 | 119 | ||
121 | cmd = "smbfind"; | 120 | cmd = "smbfind"; |
122 | owarn <<"cmd: " << cmd << oendl; | 121 | owarn <<"cmd: " << cmd << oendl; |
123 | 122 | ||
124 | TextViewOutput->append(cmd); | 123 | TextViewOutput->append(cmd); |
125 | 124 | ||
126 | snprintf(lmhosts, 512, "echo '127.0.0.1 localhost'>/etc/samba/lmhosts"); | 125 | snprintf(lmhosts, 512, "echo '127.0.0.1 localhost'>/etc/samba/lmhosts"); |
127 | 126 | ||
128 | if ((pipe2 = popen(lmhosts, "r")) == NULL) { | 127 | if ((pipe2 = popen(lmhosts, "r")) == NULL) { |
129 | snprintf(result, 256, "Error: Can't run %s", lmhosts); | 128 | snprintf(result, 256, "Error: Can't run %s", lmhosts); |
130 | //TextViewOutput->append(result); | 129 | //TextViewOutput->append(result); |
131 | return; | 130 | return; |
132 | } | 131 | } |
133 | 132 | ||
134 | /* run command & read output */ | 133 | /* run command & read output */ |
135 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { | 134 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { |
136 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 135 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
137 | TextViewOutput->append(result); | 136 | TextViewOutput->append(result); |
138 | return; | 137 | return; |
139 | } | 138 | } |
140 | 139 | ||
141 | /* parse output and display in ListViewScan */ | 140 | /* parse output and display in ListViewScan */ |
142 | while(fgets(result, 256, pipe) != NULL) { | 141 | while(fgets(result, 256, pipe) != NULL) { |
143 | /* put result into TextViewOutput */ | 142 | /* put result into TextViewOutput */ |
144 | TextViewOutput->append(result); | 143 | TextViewOutput->append(result); |
145 | 144 | ||
146 | if( strstr(result, match) != NULL ) { | 145 | if( strstr(result, match.latin1()) != NULL ) { |
147 | char ip_addr[256], host[256], *ptr1; | 146 | char ip_addr[256], host[256], *ptr1; |
148 | 147 | ||
149 | strcpy( ip_addr, result); | 148 | strcpy( ip_addr, result); |
150 | ptr1 = strchr(ip_addr,' '); | 149 | ptr1 = strchr(ip_addr,' '); |
151 | strcpy( host, ptr1); | 150 | strcpy( host, ptr1); |
152 | ip_addr[ptr1 - ip_addr]='\0'; | 151 | ip_addr[ptr1 - ip_addr]='\0'; |
153 | 152 | ||
154 | for(i = 0; i < 256; i++) { | 153 | for(i = 0; i < 256; i++) { |
155 | if(host[i]!=' ') { | 154 | if(host[i]!=' ') { |
156 | strcpy( host, host + i); | 155 | strcpy( host, host + i); |
157 | break; | 156 | break; |
158 | } | 157 | } |
159 | } | 158 | } |
160 | ptr1 = strchr(host,' '); | 159 | ptr1 = strchr(host,' '); |
161 | host[ptr1 - host] = '\0'; | 160 | host[ptr1 - host] = '\0'; |
162 | 161 | ||
163 | owarn << "add host: " << host << oendl; | 162 | owarn << "add host: " << host << oendl; |
164 | 163 | ||
165 | CBHost->insertItem( host, -1); | 164 | CBHost->insertItem( host, -1); |
166 | snprintf( lmhosts, 512, "echo '%s %s'>>/etc/samba/lmhosts", ip_addr,host); | 165 | snprintf( lmhosts, 512, "echo '%s %s'>>/etc/samba/lmhosts", ip_addr,host); |
167 | 166 | ||
168 | owarn << "lmhosts: " << lmhosts << oendl; | 167 | owarn << "lmhosts: " << lmhosts << oendl; |
169 | 168 | ||
170 | if ((pipe2 = popen(lmhosts, "r")) == NULL) { | 169 | if ((pipe2 = popen(lmhosts, "r")) == NULL) { |
171 | snprintf(result, 256, "Error: Can't run %s", lmhosts); | 170 | snprintf(result, 256, "Error: Can't run %s", lmhosts); |
172 | return; | 171 | return; |
173 | } | 172 | } |
174 | } | 173 | } |
175 | } | 174 | } |
176 | 175 | ||
177 | TextViewOutput->append("\n\n============================================\n"); | 176 | TextViewOutput->append("\n\n============================================\n"); |
178 | LScan->setText(""); | 177 | LScan->setText(""); |
179 | scanning = false; | 178 | scanning = false; |
180 | } | 179 | } |
181 | 180 | ||
182 | void Qsmb::hostSelected(int index) | 181 | void Qsmb::hostSelected(int index) |
183 | { | 182 | { |
184 | owarn << "hostSelected" << oendl; | 183 | owarn << "hostSelected" << oendl; |
185 | int i; | 184 | int i; |
186 | 185 | ||
187 | QListViewItem *element; | 186 | QListViewItem *element; |
188 | QListViewItem *parent; | 187 | QListViewItem *parent; |
189 | 188 | ||
190 | QString text = CBHost->currentText(); | 189 | QString text = CBHost->currentText(); |
191 | 190 | ||
192 | if (scanning) return; | 191 | if (scanning) return; |
193 | scanning = true; | 192 | scanning = true; |
194 | 193 | ||
@@ -238,168 +237,170 @@ void Qsmb::hostSelected(int index) | |||
238 | share[ptr1 - share]='\0'; | 237 | share[ptr1 - share]='\0'; |
239 | 238 | ||
240 | owarn<< "add share: " << share << oendl; | 239 | owarn<< "add share: " << share << oendl; |
241 | 240 | ||
242 | if(top_element != NULL) { | 241 | if(top_element != NULL) { |
243 | bool found = false; | 242 | bool found = false; |
244 | element = top_element; | 243 | element = top_element; |
245 | 244 | ||
246 | while(element != NULL && !found) { | 245 | while(element != NULL && !found) { |
247 | if(strcmp( element->text(0).ascii(), share)==0) { | 246 | if(strcmp( element->text(0).ascii(), share)==0) { |
248 | parent = element; | 247 | parent = element; |
249 | found = true; | 248 | found = true; |
250 | } | 249 | } |
251 | element = element->nextSibling(); | 250 | element = element->nextSibling(); |
252 | } | 251 | } |
253 | 252 | ||
254 | if(!found) { | 253 | if(!found) { |
255 | element = new QListViewItem(ListViewScan,share); | 254 | element = new QListViewItem(ListViewScan,share); |
256 | element->setOpen(true); | 255 | element->setOpen(true); |
257 | parent=element; | 256 | parent=element; |
258 | } | 257 | } |
259 | } else { | 258 | } else { |
260 | element = new QListViewItem(ListViewScan,share); | 259 | element = new QListViewItem(ListViewScan,share); |
261 | element->setOpen(true); | 260 | element->setOpen(true); |
262 | top_element = element; | 261 | top_element = element; |
263 | parent = element; | 262 | parent = element; |
264 | } | 263 | } |
265 | } | 264 | } |
266 | } | 265 | } |
267 | 266 | ||
268 | TextViewOutput->append("\n\n============================================\n"); | 267 | TextViewOutput->append("\n\n============================================\n"); |
269 | LScan->setText(""); | 268 | LScan->setText(""); |
270 | scanning = false; | 269 | scanning = false; |
271 | } | 270 | } |
272 | 271 | ||
273 | void Qsmb::DoIt() | 272 | void Qsmb::DoIt() |
274 | { | 273 | { |
275 | QListViewItem *element; | 274 | QListViewItem *element; |
276 | element = ListViewScan->selectedItem(); | 275 | element = ListViewScan->selectedItem(); |
277 | if(!element) { | 276 | if(!element) { |
278 | QMessageBox::warning(this, tr("Error!!"),tr("<p><b>No</b> share selected!!</p>")); | 277 | QMessageBox::warning(this, tr("Error!!"),tr("<p><b>No</b> share selected!!</p>")); |
279 | return; | 278 | return; |
280 | } | 279 | } |
281 | 280 | ||
282 | if (scanning) return; | 281 | if (scanning) return; |
283 | scanning = true; | 282 | scanning = true; |
284 | 283 | ||
285 | int i; | 284 | int i; |
285 | bool err = false; | ||
286 | 286 | ||
287 | char share[512]; | 287 | char share[512]; |
288 | QString cmd; | 288 | QString cmd; |
289 | QString cmd2; | 289 | QString cmd2; |
290 | char result[256]; | 290 | char result[256]; |
291 | // QString result; | 291 | // QString result; |
292 | QString text = mountpt->currentText(); | 292 | QString text = mountpt->currentText(); |
293 | 293 | ||
294 | FILE *pipe,*pipe2; | 294 | FILE *pipe,*pipe2; |
295 | 295 | ||
296 | LScan->setText("Mounting..."); | 296 | LScan->setText("Mounting..."); |
297 | qApp->processEvents(); | 297 | qApp->processEvents(); |
298 | 298 | ||
299 | 299 | ||
300 | if(! QFileInfo(text).exists()) { | 300 | if(! QFileInfo(text).exists()) { |
301 | cmd = "mkdir -p "+ text; | 301 | // /* make sure mount exists! */ |
302 | owarn<<"cmd: "<< cmd << oendl; | 302 | |
303 | /* make sure mount exists! */ | 303 | // cmd = "mkdir -p "+ text; |
304 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { | 304 | // owarn<<"cmd: "<< cmd << oendl; |
305 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 305 | // if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { |
306 | // result = "Error: Can't run " + cmd; | 306 | // snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
307 | TextViewOutput->append(result); | 307 | // TextViewOutput->append(result); |
308 | return; | 308 | // return; |
309 | } | 309 | // } |
310 | while(fgets(result, 256, pipe2) != NULL) { | 310 | // while(fgets(result, 256, pipe2) != NULL) { |
311 | /* put result into TextViewOutput */ | 311 | // /* put result into TextViewOutput */ |
312 | TextViewOutput->append(result); | 312 | // TextViewOutput->append(result); |
313 | } | 313 | // } |
314 | QStringList ccmd; | ||
315 | ccmd << "mkdir"; | ||
316 | ccmd << "-p"; | ||
317 | ccmd << text; | ||
318 | |||
319 | owarn<<"cmd: "<< ccmd << oendl; | ||
320 | runCommand(ccmd); | ||
314 | } | 321 | } |
315 | 322 | ||
316 | 323 | ||
317 | strcpy(share,(const char *)element->text(0)); | 324 | strcpy(share,(const char *)element->text(0)); |
318 | 325 | ||
319 | for(i = 0; i < 256; i++) { | 326 | for(i = 0; i < 256; i++) { |
320 | if(isalpha( share[i])) { | 327 | if(isalpha( share[i])) { |
321 | strcpy( share, share + i); | 328 | strcpy( share, share + i); |
322 | break; | 329 | break; |
323 | } | 330 | } |
324 | } | 331 | } |
325 | 332 | ||
326 | cmd = "/usr/bin/smbmount //"+CBHost->currentText()+"/"+share+" "+mountpt->currentText()+" -o username="+username->text()+",password="+password->text(); | 333 | cmd = "/usr/bin/smbmount //"+CBHost->currentText()+"/"+share+" "+mountpt->currentText()+" -o username="+username->text()+",password="+password->text(); |
327 | 334 | ||
328 | owarn << "cmd: " << cmd << oendl; | 335 | owarn << "cmd: " << cmd << oendl; |
329 | TextViewOutput->append(cmd.latin1()); | 336 | TextViewOutput->append(cmd.latin1()); |
330 | 337 | ||
331 | 338 | ||
332 | if(onbootBtn->isChecked()) { | 339 | if(onbootBtn->isChecked()) { |
333 | owarn << "Saving Setting permanently..." << oendl; | 340 | owarn << "Saving Setting permanently..." << oendl; |
334 | cmd2 = "echo '" + cmd + "'>/opt/QtPalmtop/etc/samba.env"; | 341 | cmd2 = "echo '" + cmd + "'>/opt/QtPalmtop/etc/samba.env"; |
335 | |||
336 | /* run command & read output */ | 342 | /* run command & read output */ |
337 | if ((pipe = popen(cmd2.latin1(), "r")) == NULL) { | 343 | if ((pipe = popen(cmd2.latin1(), "r")) == NULL) { |
338 | |||
339 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 344 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
340 | // result = "Error: Can't run "+ cmd; | ||
341 | //TextViewOutput->append(result); | ||
342 | return; | 345 | return; |
343 | } | 346 | } |
344 | /* parse output and display in ListViewScan */ | 347 | /* parse output and display in ListViewScan */ |
345 | while(fgets(result, 256, pipe) != NULL) { | 348 | while(fgets(result, 256, pipe) != NULL) { |
346 | /* put result into TextViewOutput */ | ||
347 | //TextViewOutput->append(result); | ||
348 | } | 349 | } |
349 | } | 350 | } |
350 | 351 | ||
352 | |||
351 | /* run command & read output */ | 353 | /* run command & read output */ |
352 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { | 354 | if ((pipe = popen(cmd.latin1(), "r")) == NULL) { |
353 | |||
354 | // result = "Error: Can't run "+ cmd; | ||
355 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 355 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
356 | |||
357 | TextViewOutput->append(result); | 356 | TextViewOutput->append(result); |
358 | return; | 357 | return; |
359 | } | 358 | } |
360 | 359 | ||
361 | /* parse output and display in ListViewScan */ | 360 | /* parse output and display in ListViewScan */ |
362 | while(fgets(result, 256, pipe) != NULL) { | 361 | while(fgets(result, 256, pipe) != NULL) { |
363 | /* put result into TextViewOutput */ | 362 | /* put result into TextViewOutput */ |
364 | TextViewOutput->append(result); | 363 | TextViewOutput->append(result); |
365 | } | 364 | } |
365 | |||
366 | |||
366 | TextViewOutput->append("\n\n================CheckMounts==================\n"); | 367 | TextViewOutput->append("\n\n================CheckMounts==================\n"); |
367 | LScan->setText(""); | 368 | LScan->setText(""); |
368 | 369 | ||
369 | cmd = "/bin/mount 2>&1"; | 370 | cmd = "/bin/mount 2>&1"; |
370 | owarn << "cmd: " << cmd << oendl; | 371 | owarn << "cmd: " << cmd << oendl; |
371 | 372 | ||
372 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { | 373 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { |
373 | 374 | ||
374 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | 375 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); |
375 | // result = "Error: Can't run "+ cmd; | 376 | // result = "Error: Can't run "+ cmd; |
376 | 377 | ||
377 | TextViewOutput->append(result); | 378 | TextViewOutput->append(result); |
378 | return; | 379 | return; |
379 | } | 380 | } |
380 | /* parse output and display in ListViewScan */ | 381 | /* parse output and display in ListViewScan */ |
381 | while(fgets(result, 256, pipe2) != NULL) { | 382 | while(fgets(result, 256, pipe2) != NULL) { |
382 | /* put result into TextViewOutput */ | 383 | /* put result into TextViewOutput */ |
383 | TextViewOutput->append(result); | 384 | TextViewOutput->append(result); |
384 | } | 385 | } |
385 | 386 | ||
386 | TextViewOutput->append("\n\n============================================\n"); | 387 | TextViewOutput->append("\n\n============================================\n"); |
387 | scanning = false; | 388 | scanning = false; |
388 | } | 389 | } |
389 | 390 | ||
390 | bool Qsmb::runCommand(const QStringList & command) { | 391 | bool Qsmb::runCommand(const QStringList & command) { |
391 | owarn << "runCommand " << command.join(" ") << oendl; | 392 | owarn << "runCommand " << command.join(" ") << oendl; |
392 | out = ""; | 393 | out = ""; |
393 | Process ipkg_status( command); | 394 | Process ipkg_status( command); |
394 | bool r = ipkg_status.exec("",out); | 395 | bool r = ipkg_status.exec("",out); |
395 | 396 | ||
396 | if(!r) { | 397 | if(!r) { |
397 | QMessageBox::warning(this, tr("Error!!"),tr("<p>"+out+"</p>")); | 398 | QMessageBox::warning(this, tr("Error!!"),tr("<p>"+out+"</p>")); |
398 | } | 399 | } |
399 | 400 | ||
400 | owarn << "Output " << out << oendl; | 401 | owarn << "Output " << out << oendl; |
401 | TextViewOutput->append(out.latin1()); | 402 | TextViewOutput->append(out.latin1()); |
402 | return r; | 403 | return r; |
403 | } | 404 | } |
404 | 405 | ||
405 | 406 | ||