author | llornkcor <llornkcor> | 2005-08-14 21:45:59 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-08-14 21:45:59 (UTC) |
commit | 1dc2675c1bf557ba0032781535faf033809bae48 (patch) (side-by-side diff) | |
tree | a949c816bc2fcc3213b38f4b5aed54254f7bd7c0 | |
parent | ab6f37a50ef2a0d95f25eff4a749bfcf39057d65 (diff) | |
download | opie-1dc2675c1bf557ba0032781535faf033809bae48.zip opie-1dc2675c1bf557ba0032781535faf033809bae48.tar.gz opie-1dc2675c1bf557ba0032781535faf033809bae48.tar.bz2 |
use shell script smbfind and not perl script findsmb
-rw-r--r-- | noncore/net/opie-smb/opie-smb.control | 2 | ||||
-rw-r--r-- | noncore/net/opie-smb/qsmb.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/noncore/net/opie-smb/opie-smb.control b/noncore/net/opie-smb/opie-smb.control index 98a23b4..fc8c316 100644 --- a/noncore/net/opie-smb/opie-smb.control +++ b/noncore/net/opie-smb/opie-smb.control @@ -1,11 +1,11 @@ Package: opie-smb -Files: plugins/application/libopie-smb.so* bin/opie-smb pics/opie-smb apps/Applications/opie-smb.desktop +Files: plugins/application/libopie-smb.so* bin/opie-smb bin/smbfind pics/opie-smb apps/Applications/opie-smb.desktop Version: $QPE_VERSION$EXTRAVERSION Architecture: arm Arch: arm Maintainer: Kurt Korbatits (support@midget.net.au) Section: Network Priority: optional Description: Gui front end for samba utilities. Source: Depends: smbclient diff --git a/noncore/net/opie-smb/qsmb.cpp b/noncore/net/opie-smb/qsmb.cpp index 527ab38..880573b 100644 --- a/noncore/net/opie-smb/qsmb.cpp +++ b/noncore/net/opie-smb/qsmb.cpp @@ -29,193 +29,193 @@ Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) : FormQPESMBBase( parent, name, fl ) { connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); //TODO configurable mount points if(!QFileInfo("/mnt/samba1").exists()) system("mkdir /mnt/samba1"); if(!QFileInfo("/mnt/samba2").exists()) system("mkdir /mnt/samba2"); if(!QFileInfo("/mnt/samba2").exists()) system("mkdir /mnt/samba3"); mountpt->insertItem("/mnt/samba1",-1); mountpt->insertItem("/mnt/samba2",-1); mountpt->insertItem("/mnt/samba3",-1); top_element = NULL; scanning = false; } Qsmb::~Qsmb() { } void Qsmb::clear() { if (scanning) return; ListViewScan->clear(); TextViewOutput->setText(""); top_element = NULL; } void Qsmb::scanClicked() { if (scanning) return; pthread_create(&tpid, NULL, runit, (void *)this); } void Qsmb::DoItClicked() { if(! ListViewScan->selectedItem()) { QMessageBox::warning(this, tr("Error"),tr("<p>No share selected!</p>")); return; } if (scanning) return; pthread_create(&tpid, NULL, runitm, (void *)this); } void* runit(void* arg) { Qsmb* caller = (Qsmb*)arg; caller->scan(); return(0); } void* runitm(void* arg) { Qsmb* caller = (Qsmb*)arg; caller->DoIt(); return(0); } void Qsmb::scan() { int i; if (scanning) return; scanning = true; char match[512], lmhosts[512]; QString cmd; char result[256]; FILE *pipe, *pipe2; LScan->setText("Scanning..."); qApp->processEvents(); cmd = "ifconfig |grep 'addr:'|awk '{print $2}'|awk 'BEGIN{FS=\":\"}{print $2}'|sed 's/\\.[0-9]*$//'|head -n1"; owarn << "cmd: " << cmd << oendl; /* run findsmb & read output */ if ((pipe = popen(cmd.latin1(), "r")) == NULL) { snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); TextViewOutput->append(result); return; } while(fgets(result, 256, pipe) != NULL) { strcpy( match, result); match[5]='\0'; break; } owarn << "match: " << match << oendl; - cmd = "/usr/bin/findsmb"; + cmd = "smbfind"; owarn <<"cmd: " << cmd << oendl; TextViewOutput->append(cmd); snprintf(lmhosts, 512, "echo '127.0.0.1 localhost'>/etc/samba/lmhosts"); if ((pipe2 = popen(lmhosts, "r")) == NULL) { snprintf(result, 256, "Error: Can't run %s", lmhosts); //TextViewOutput->append(result); return; } /* run command & read output */ if ((pipe = popen(cmd.latin1(), "r")) == NULL) { snprintf(result, 256, "Error: Can't run %s", cmd.latin1()); TextViewOutput->append(result); return; } /* parse output and display in ListViewScan */ while(fgets(result, 256, pipe) != NULL) { /* put result into TextViewOutput */ TextViewOutput->append(result); if( strstr(result, match) != NULL ) { char ip_addr[256], host[256], *ptr1; strcpy( ip_addr, result); ptr1 = strchr(ip_addr,' '); strcpy( host, ptr1); ip_addr[ptr1 - ip_addr]='\0'; for(i = 0; i < 256; i++) { if(host[i]!=' ') { strcpy( host, host + i); break; } } ptr1 = strchr(host,' '); host[ptr1 - host] = '\0'; owarn << "add host: " << host << oendl; CBHost->insertItem( host, -1); snprintf( lmhosts, 512, "echo '%s %s'>>/etc/samba/lmhosts", ip_addr,host); owarn << "lmhosts: " << lmhosts << oendl; if ((pipe2 = popen(lmhosts, "r")) == NULL) { snprintf(result, 256, "Error: Can't run %s", lmhosts); return; } } } TextViewOutput->append("\n\n============================================\n"); LScan->setText(""); scanning = false; } void Qsmb::hostSelected(int index) { owarn << "hostSelected" << oendl; int i; QListViewItem *element; QListViewItem *parent; QString text = CBHost->currentText(); if (scanning) return; scanning = true; QString cmd; char result[256]; FILE *pipe; LScan->setText("Scanning..."); if((const char *)username->text() == '\0') cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N 2>&1 |grep Disk"; else cmd = "/usr/bin/smbclient -L //"+CBHost->currentText()+" -N -U"+username->text()+":"+password->text()+" 2>&1 |grep Disk"; for(i = 0; i < 512; i++) { if(cmd[i]==':') { cmd[i]='%'; break; } if(cmd[i]=='\0') break; } owarn << "i="<< index << "cmd:" << cmd << oendl; |