summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -1,21 +1,22 @@
#include "qsmb.h"
#include <qpushbutton.h>
#include <qpe/qpeapplication.h>
#include <string.h>
#include <qstring.h>
#include <qdir.h>
#include <qfileinfo.h>
+#include <qpe/process.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qcombobox.h>
#include <qstringlist.h>
#include <qcheckbox.h>
#include <qtextview.h>
#include <qmessagebox.h>
#include <pthread.h>
#include <signal.h>
#include <ctype.h>
@@ -24,29 +25,24 @@
#include <opie2/odebug.h>
using namespace Opie::Core;
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()
{
}
@@ -194,37 +190,37 @@ void Qsmb::hostSelected(int index)
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')
+ if(username->text().isEmpty())
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";
+ 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;
- }
+// for(i = 0; i < 512; i++) {
+// if(cmd[i]==':') {
+// cmd[i]='%';
+// break;
+// }
+// if(cmd[i]=='\0')
+// break;
+// }
owarn << "i="<< index << "cmd:" << cmd << oendl;
TextViewOutput->append(cmd);
/* run smbclient & read output */
if ((pipe = popen(cmd.latin1(), "r")) == NULL) {
snprintf(result, 256, "Error: Can't run %s", cmd.latin1());
// cmd = "Error: Can't run "+cmd;
TextViewOutput->append(result);
return;
}
@@ -290,63 +286,53 @@ void Qsmb::DoIt()
char share[512];
QString cmd;
QString cmd2;
char result[256];
// QString result;
QString text = mountpt->currentText();
FILE *pipe,*pipe2;
LScan->setText("Mounting...");
qApp->processEvents();
-
- cmd = "mkdir -p "+ text;
-
- owarn<<"cmd: "<< cmd << oendl;
- /* make sure mount exists! */
- if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) {
-
- snprintf(result, 256, "Error: Can't run %s", cmd.latin1());
- // result = "Error: Can't run " + cmd;
- TextViewOutput->append(result);
- return;
- }
- while(fgets(result, 256, pipe2) != NULL) {
- /* put result into TextViewOutput */
- TextViewOutput->append(result);
+ if(! QFileInfo(text).exists()) {
+ cmd = "mkdir -p "+ text;
+ owarn<<"cmd: "<< cmd << oendl;
+ /* make sure mount exists! */
+ if ((pipe2 = popen(cmd.latin1(), "r")) == NULL) {
+ snprintf(result, 256, "Error: Can't run %s", cmd.latin1());
+ // result = "Error: Can't run " + cmd;
+ TextViewOutput->append(result);
+ return;
+ }
+ while(fgets(result, 256, pipe2) != NULL) {
+ /* put result into TextViewOutput */
+ TextViewOutput->append(result);
+ }
}
strcpy(share,(const char *)element->text(0));
for(i = 0; i < 256; i++) {
if(isalpha( share[i])) {
strcpy( share, share + i);
break;
}
}
- cmd = "/usr/bin/smbmount //"+CBHost->currentText()+"/"+share+" "+mountpt->currentText()+" -U"+username->text()+":"+password->text();
-
- for(i = 0; i < 512; i++) {
- if(cmd[i]==':') {
- cmd[i]='%';
- break;
- }
- if(cmd[i]=='\0')
- break;
- }
+ cmd = "/usr/bin/smbmount //"+CBHost->currentText()+"/"+share+" "+mountpt->currentText()+" -o username="+username->text()+",password="+password->text();
owarn << "cmd: " << cmd << oendl;
TextViewOutput->append(cmd.latin1());
if(onbootBtn->isChecked()) {
owarn << "Saving Setting permanently..." << oendl;
cmd2 = "echo '" + cmd + "'>/opt/QtPalmtop/etc/samba.env";
/* run command & read output */
if ((pipe = popen(cmd2.latin1(), "r")) == NULL) {
@@ -391,12 +377,29 @@ void Qsmb::DoIt()
TextViewOutput->append(result);
return;
}
/* parse output and display in ListViewScan */
while(fgets(result, 256, pipe2) != NULL) {
/* put result into TextViewOutput */
TextViewOutput->append(result);
}
TextViewOutput->append("\n\n============================================\n");
scanning = false;
}
+
+bool Qsmb::runCommand(const QStringList & command) {
+ owarn << "runCommand " << command.join(" ") << oendl;
+ out = "";
+ Process ipkg_status( command);
+ bool r = ipkg_status.exec("",out);
+
+ if(!r) {
+ QMessageBox::warning(this, tr("Error!!"),tr("<p>"+out+"</p>"));
+ }
+
+ owarn << "Output " << out << oendl;
+ TextViewOutput->append(out.latin1());
+ return r;
+}
+
+
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
@@ -19,21 +19,24 @@ public:
Qsmb( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~Qsmb();
void scan();
void DoIt();
private:
QListViewItem *top_element;
QComboBox *hosts;
pthread_t tpid;
bool scanning;
public slots:
- void clear();
- void scanClicked();
- void hostSelected(int);
- void DoItClicked();
+ void clear();
+ void scanClicked();
+ void hostSelected(int);
+ void DoItClicked();
+ QString out;
+ bool runCommand(const QStringList &);
+
};
void* runit(void *arg);
void* runitm(void *arg);
#endif // QSMB_H