author | llornkcor <llornkcor> | 2005-08-15 06:45:15 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-08-15 06:45:15 (UTC) |
commit | fb0e4444f79ad253998f1a2e5c706e3fcf29ad08 (patch) (unidiff) | |
tree | fba795d9d82f0e7002b7711a72ed1bac5d2522a4 | |
parent | 1dc2675c1bf557ba0032781535faf033809bae48 (diff) | |
download | opie-fb0e4444f79ad253998f1a2e5c706e3fcf29ad08.zip opie-fb0e4444f79ad253998f1a2e5c706e3fcf29ad08.tar.gz opie-fb0e4444f79ad253998f1a2e5c706e3fcf29ad08.tar.bz2 |
cleanup. fix
-rw-r--r-- | noncore/net/opie-smb/qsmb.cpp | 83 | ||||
-rw-r--r-- | noncore/net/opie-smb/qsmb.h | 11 |
2 files changed, 50 insertions, 44 deletions
diff --git a/noncore/net/opie-smb/qsmb.cpp b/noncore/net/opie-smb/qsmb.cpp index 880573b..8aa4987 100644 --- a/noncore/net/opie-smb/qsmb.cpp +++ b/noncore/net/opie-smb/qsmb.cpp | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | #include <qfileinfo.h> | 8 | #include <qfileinfo.h> |
9 | 9 | ||
10 | #include <qpe/process.h> | ||
10 | #include <qlabel.h> | 11 | #include <qlabel.h> |
11 | #include <qlineedit.h> | 12 | #include <qlineedit.h> |
12 | #include <qcombobox.h> | 13 | #include <qcombobox.h> |
@@ -33,11 +34,6 @@ Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) | |||
33 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); | 34 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); |
34 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); | 35 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); |
35 | 36 | ||
36 | //TODO configurable mount points | ||
37 | if(!QFileInfo("/mnt/samba1").exists()) system("mkdir /mnt/samba1"); | ||
38 | if(!QFileInfo("/mnt/samba2").exists()) system("mkdir /mnt/samba2"); | ||
39 | if(!QFileInfo("/mnt/samba2").exists()) system("mkdir /mnt/samba3"); | ||
40 | |||
41 | mountpt->insertItem("/mnt/samba1",-1); | 37 | mountpt->insertItem("/mnt/samba1",-1); |
42 | mountpt->insertItem("/mnt/samba2",-1); | 38 | mountpt->insertItem("/mnt/samba2",-1); |
43 | mountpt->insertItem("/mnt/samba3",-1); | 39 | mountpt->insertItem("/mnt/samba3",-1); |
@@ -203,19 +199,19 @@ void Qsmb::hostSelected(int index) | |||
203 | 199 | ||
204 | LScan->setText("Scanning..."); | 200 | LScan->setText("Scanning..."); |
205 | 201 | ||
206 | if((const char *)username->text() == '\0') | 202 | if(username->text().isEmpty()) |
207 | cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N 2>&1 |grep Disk"; | 203 | cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N 2>&1 |grep Disk"; |
208 | else | 204 | else |
209 | cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N -U"+username->text()+":"+password->text()+" 2>&1 |grep Disk"; | 205 | cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N -U "+username->text()+"\%"+password->text()+" 2>&1 |grep Disk"; |
210 | 206 | ||
211 | for(i = 0; i < 512; i++) { | 207 | // for(i = 0; i < 512; i++) { |
212 | if(cmd[i]==':') { | 208 | // if(cmd[i]==':') { |
213 | cmd[i]='%'; | 209 | // cmd[i]='%'; |
214 | break; | 210 | // break; |
215 | } | 211 | // } |
216 | if(cmd[i]=='\0') | 212 | // if(cmd[i]=='\0') |
217 | break; | 213 | // break; |
218 | } | 214 | // } |
219 | 215 | ||
220 | owarn << "i="<< index << "cmd:" << cmd << oendl; | 216 | owarn << "i="<< index << "cmd:" << cmd << oendl; |
221 | 217 | ||
@@ -299,23 +295,22 @@ void Qsmb::DoIt() | |||
299 | 295 | ||
300 | LScan->setText("Mounting..."); | 296 | LScan->setText("Mounting..."); |
301 | qApp->processEvents(); | 297 | qApp->processEvents(); |
302 | |||
303 | cmd = "mkdir -p "+ text; | ||
304 | |||
305 | owarn<<"cmd: "<< cmd << oendl; | ||
306 | 298 | ||
307 | /* make sure mount exists! */ | ||
308 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { | ||
309 | |||
310 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | ||
311 | // result = "Error: Can't run " + cmd; | ||
312 | TextViewOutput->append(result); | ||
313 | return; | ||
314 | } | ||
315 | 299 | ||
316 | while(fgets(result, 256, pipe2) != NULL) { | 300 | if(! QFileInfo(text).exists()) { |
317 | /* put result into TextViewOutput */ | 301 | cmd = "mkdir -p "+ text; |
318 | TextViewOutput->append(result); | 302 | owarn<<"cmd: "<< cmd << oendl; |
303 | /* make sure mount exists! */ | ||
304 | if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) { | ||
305 | snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); | ||
306 | // result = "Error: Can't run " + cmd; | ||
307 | TextViewOutput->append(result); | ||
308 | return; | ||
309 | } | ||
310 | while(fgets(result, 256, pipe2) != NULL) { | ||
311 | /* put result into TextViewOutput */ | ||
312 | TextViewOutput->append(result); | ||
313 | } | ||
319 | } | 314 | } |
320 | 315 | ||
321 | 316 | ||
@@ -328,16 +323,7 @@ void Qsmb::DoIt() | |||
328 | } | 323 | } |
329 | } | 324 | } |
330 | 325 | ||
331 | cmd = "/usr/bin/smbmount //"+CBHost->currentText()+"/"+share+" "+mountpt->currentText()+" -U"+username->text()+":"+password->text(); | 326 | cmd = "/usr/bin/smbmount //"+CBHost->currentText()+"/"+share+" "+mountpt->currentText()+" -o username="+username->text()+",password="+password->text(); |
332 | |||
333 | for(i = 0; i < 512; i++) { | ||
334 | if(cmd[i]==':') { | ||
335 | cmd[i]='%'; | ||
336 | break; | ||
337 | } | ||
338 | if(cmd[i]=='\0') | ||
339 | break; | ||
340 | } | ||
341 | 327 | ||
342 | owarn << "cmd: " << cmd << oendl; | 328 | owarn << "cmd: " << cmd << oendl; |
343 | TextViewOutput->append(cmd.latin1()); | 329 | TextViewOutput->append(cmd.latin1()); |
@@ -400,3 +386,20 @@ void Qsmb::DoIt() | |||
400 | TextViewOutput->append("\n\n============================================\n"); | 386 | TextViewOutput->append("\n\n============================================\n"); |
401 | scanning = false; | 387 | scanning = false; |
402 | } | 388 | } |
389 | |||
390 | bool Qsmb::runCommand(const QStringList & command) { | ||
391 | owarn << "runCommand " << command.join(" ") << oendl; | ||
392 | out = ""; | ||
393 | Process ipkg_status( command); | ||
394 | bool r = ipkg_status.exec("",out); | ||
395 | |||
396 | if(!r) { | ||
397 | QMessageBox::warning(this, tr("Error!!"),tr("<p>"+out+"</p>")); | ||
398 | } | ||
399 | |||
400 | owarn << "Output " << out << oendl; | ||
401 | TextViewOutput->append(out.latin1()); | ||
402 | return r; | ||
403 | } | ||
404 | |||
405 | |||
diff --git a/noncore/net/opie-smb/qsmb.h b/noncore/net/opie-smb/qsmb.h index 8fefe91..b406a1e 100644 --- a/noncore/net/opie-smb/qsmb.h +++ b/noncore/net/opie-smb/qsmb.h | |||
@@ -28,10 +28,13 @@ private: | |||
28 | bool scanning; | 28 | bool scanning; |
29 | 29 | ||
30 | public slots: | 30 | public slots: |
31 | void clear(); | 31 | void clear(); |
32 | void scanClicked(); | 32 | void scanClicked(); |
33 | void hostSelected(int); | 33 | void hostSelected(int); |
34 | void DoItClicked(); | 34 | void DoItClicked(); |
35 | QString out; | ||
36 | bool runCommand(const QStringList &); | ||
37 | |||
35 | }; | 38 | }; |
36 | void* runit(void *arg); | 39 | void* runit(void *arg); |
37 | void* runitm(void *arg); | 40 | void* runitm(void *arg); |