summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2005-08-15 06:45:15 (UTC)
committer llornkcor <llornkcor>2005-08-15 06:45:15 (UTC)
commitfb0e4444f79ad253998f1a2e5c706e3fcf29ad08 (patch) (unidiff)
treefba795d9d82f0e7002b7711a72ed1bac5d2522a4
parent1dc2675c1bf557ba0032781535faf033809bae48 (diff)
downloadopie-fb0e4444f79ad253998f1a2e5c706e3fcf29ad08.zip
opie-fb0e4444f79ad253998f1a2e5c706e3fcf29ad08.tar.gz
opie-fb0e4444f79ad253998f1a2e5c706e3fcf29ad08.tar.bz2
cleanup. fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opie-smb/qsmb.cpp83
-rw-r--r--noncore/net/opie-smb/qsmb.h11
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
@@ -4,12 +4,13 @@
4 4
5#include <string.h> 5#include <string.h>
6#include <qstring.h> 6#include <qstring.h>
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>
13#include <qstringlist.h> 14#include <qstringlist.h>
14#include <qcheckbox.h> 15#include <qcheckbox.h>
15#include <qtextview.h> 16#include <qtextview.h>
@@ -30,17 +31,12 @@ Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl )
30{ 31{
31 connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); 32 connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int)));
32 connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); 33 connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked()));
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);
44 40
45 top_element = NULL; 41 top_element = NULL;
46 scanning = false; 42 scanning = false;
@@ -200,25 +196,25 @@ void Qsmb::hostSelected(int index)
200 char result[256]; 196 char result[256];
201 197
202 FILE *pipe; 198 FILE *pipe;
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
222 TextViewOutput->append(cmd); 218 TextViewOutput->append(cmd);
223 219
224 /* run smbclient & read output */ 220 /* run smbclient & read output */
@@ -296,51 +292,41 @@ void Qsmb::DoIt()
296 QString text = mountpt->currentText(); 292 QString text = mountpt->currentText();
297 293
298 FILE *pipe,*pipe2; 294 FILE *pipe,*pipe2;
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
322 strcpy(share,(const char *)element->text(0)); 317 strcpy(share,(const char *)element->text(0));
323 318
324 for(i = 0; i < 256; i++) { 319 for(i = 0; i < 256; i++) {
325 if(isalpha( share[i])) { 320 if(isalpha( share[i])) {
326 strcpy( share, share + i); 321 strcpy( share, share + i);
327 break; 322 break;
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());
344 330
345 331
346 if(onbootBtn->isChecked()) { 332 if(onbootBtn->isChecked()) {
@@ -397,6 +383,23 @@ void Qsmb::DoIt()
397 TextViewOutput->append(result); 383 TextViewOutput->append(result);
398 } 384 }
399 385
400 TextViewOutput->append("\n\n============================================\n"); 386 TextViewOutput->append("\n\n============================================\n");
401 scanning = false; 387 scanning = false;
402} 388}
389
390bool 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
@@ -25,15 +25,18 @@ private:
25 QListViewItem *top_element; 25 QListViewItem *top_element;
26 QComboBox *hosts; 26 QComboBox *hosts;
27 pthread_t tpid; 27 pthread_t tpid;
28 bool scanning; 28 bool scanning;
29 29
30public slots: 30public 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};
36void* runit(void *arg); 39void* runit(void *arg);
37void* runitm(void *arg); 40void* runitm(void *arg);
38 41
39#endif // QSMB_H 42#endif // QSMB_H