-rw-r--r-- | noncore/net/opie-smb/qsmb.cpp | 19 | ||||
-rw-r--r-- | noncore/net/opie-smb/qsmb.h | 4 |
2 files changed, 21 insertions, 2 deletions
diff --git a/noncore/net/opie-smb/qsmb.cpp b/noncore/net/opie-smb/qsmb.cpp index 7f3ae89..d35e09a 100644 --- a/noncore/net/opie-smb/qsmb.cpp +++ b/noncore/net/opie-smb/qsmb.cpp | |||
@@ -35,24 +35,25 @@ | |||
35 | // #include <opie2/odebug.h> | 35 | // #include <opie2/odebug.h> |
36 | // using namespace Opie::Core; | 36 | // using namespace Opie::Core; |
37 | 37 | ||
38 | 38 | ||
39 | Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) | 39 | Qsmb::Qsmb( QWidget* parent, const char* name, WFlags fl ) |
40 | : FormQPESMBBase( parent, name, fl ) | 40 | : FormQPESMBBase( parent, name, fl ) |
41 | { | 41 | { |
42 | connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); | 42 | connect(CBHost, SIGNAL(activated(int)), this, SLOT(hostSelected(int))); |
43 | connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); | 43 | connect(DoItBtn, SIGNAL(clicked()), this, SLOT(DoItClicked())); |
44 | connect(UnmountBtn, SIGNAL(clicked()), this, SLOT(umountIt())); | 44 | connect(UnmountBtn, SIGNAL(clicked()), this, SLOT(umountIt())); |
45 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); | 45 | connect(BtnScan, SIGNAL(clicked()), this, SLOT(scanClicked())); |
46 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); | 46 | connect(BtnClear, SIGNAL(clicked()), this, SLOT(clear())); |
47 | connect(ListViewScan, SIGNAL(clicked(QListViewItem*)), this, SLOT(TextViewClicked(QListViewItem*))); | ||
47 | 48 | ||
48 | mountpt->setEditable(true); | 49 | mountpt->setEditable(true); |
49 | mountpt->insertItem("/mnt/samba1",-1); | 50 | mountpt->insertItem("/mnt/samba1",-1); |
50 | mountpt->insertItem("/mnt/samba2",-1); | 51 | mountpt->insertItem("/mnt/samba2",-1); |
51 | mountpt->insertItem("/mnt/samba3",-1); | 52 | mountpt->insertItem("/mnt/samba3",-1); |
52 | 53 | ||
53 | setTabOrder(BtnScan, username); | 54 | setTabOrder(BtnScan, username); |
54 | setTabOrder(username, password); | 55 | setTabOrder(username, password); |
55 | setTabOrder(password, CBHost); | 56 | setTabOrder(password, CBHost); |
56 | setTabOrder(CBHost, TextViewOutput); | 57 | setTabOrder(CBHost, TextViewOutput); |
57 | setTabOrder(TextViewOutput, mountpt); | 58 | setTabOrder(TextViewOutput, mountpt); |
58 | setTabOrder(mountpt, DoItBtn); | 59 | setTabOrder(mountpt, DoItBtn); |
@@ -344,35 +345,39 @@ void Qsmb::DoIt() | |||
344 | runCommand(ccmd); | 345 | runCommand(ccmd); |
345 | TextViewOutput->append("\n\n============================================\n"); | 346 | TextViewOutput->append("\n\n============================================\n"); |
346 | qApp->processEvents(); | 347 | qApp->processEvents(); |
347 | } else { | 348 | } else { |
348 | //do nothing | 349 | //do nothing |
349 | } | 350 | } |
350 | 351 | ||
351 | scanning = false; | 352 | scanning = false; |
352 | } | 353 | } |
353 | 354 | ||
354 | void Qsmb::umountIt() | 355 | void Qsmb::umountIt() |
355 | { | 356 | { |
357 | QListViewItem *element; | ||
358 | element = ListViewScan->selectedItem(); | ||
359 | if(!element) { | ||
360 | return; | ||
361 | } | ||
362 | |||
356 | QString mount = mountpt->currentText(); | 363 | QString mount = mountpt->currentText(); |
357 | if(!isMounted(mount)) { | 364 | if(!isMounted(mount)) { |
358 | qWarning(mount +" is not mounted"); | 365 | qWarning(mount +" is not mounted"); |
359 | TextViewOutput->append(mount +" is not mounted"); | 366 | TextViewOutput->append(mount +" is not mounted"); |
360 | return; | 367 | return; |
361 | } | 368 | } |
362 | 369 | ||
363 | QStringList ccmd; | 370 | QStringList ccmd; |
364 | QString share; | 371 | QString share; |
365 | QListViewItem *element; | ||
366 | element = ListViewScan->selectedItem(); | ||
367 | share = element->text(0); | 372 | share = element->text(0); |
368 | qWarning("selected share is "+share); | 373 | qWarning("selected share is "+share); |
369 | 374 | ||
370 | if(mount.left(1) != "/") | 375 | if(mount.left(1) != "/") |
371 | mount = QDir::currentDirPath()+"/"+mount; | 376 | mount = QDir::currentDirPath()+"/"+mount; |
372 | mount = mount.stripWhiteSpace(); | 377 | mount = mount.stripWhiteSpace(); |
373 | 378 | ||
374 | ccmd << "/usr/bin/smbumount"; | 379 | ccmd << "/usr/bin/smbumount"; |
375 | ccmd << mount; | 380 | ccmd << mount; |
376 | runCommand(ccmd); | 381 | runCommand(ccmd); |
377 | 382 | ||
378 | element->setText(2, ""); | 383 | element->setText(2, ""); |
@@ -426,12 +431,22 @@ QString Qsmb::getMount(const QString &shareName) | |||
426 | if ( mntfp ){ | 431 | if ( mntfp ){ |
427 | while ( (me = getmntent( mntfp )) != 0 ) { | 432 | while ( (me = getmntent( mntfp )) != 0 ) { |
428 | QString deviceName = me->mnt_fsname; | 433 | QString deviceName = me->mnt_fsname; |
429 | QString mountDir = me->mnt_dir; | 434 | QString mountDir = me->mnt_dir; |
430 | QString fsType = me->mnt_type; | 435 | QString fsType = me->mnt_type; |
431 | if( fsType == "smbfs" && deviceName.find(shareName) != -1) | 436 | if( fsType == "smbfs" && deviceName.find(shareName) != -1) |
432 | mount = mountDir; | 437 | mount = mountDir; |
433 | } | 438 | } |
434 | } | 439 | } |
435 | endmntent( mntfp ); | 440 | endmntent( mntfp ); |
436 | return mount; | 441 | return mount; |
437 | } | 442 | } |
443 | |||
444 | void Qsmb::TextViewClicked(QListViewItem* item) | ||
445 | { | ||
446 | if(item == NULL) return; | ||
447 | |||
448 | QString text = item->text(2); | ||
449 | qWarning(text); | ||
450 | if( !text.isEmpty()) | ||
451 | mountpt->insertItem(text,0); | ||
452 | } | ||
diff --git a/noncore/net/opie-smb/qsmb.h b/noncore/net/opie-smb/qsmb.h index abf27da..175b2c3 100644 --- a/noncore/net/opie-smb/qsmb.h +++ b/noncore/net/opie-smb/qsmb.h | |||
@@ -1,24 +1,26 @@ | |||
1 | #ifndef QSMB_H | 1 | #ifndef QSMB_H |
2 | #define QSMB_H | 2 | #define QSMB_H |
3 | 3 | ||
4 | #include "qsmbbase.h" | 4 | #include "qsmbbase.h" |
5 | 5 | ||
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | 9 | ||
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <pthread.h> | 11 | #include <pthread.h> |
12 | 12 | ||
13 | #include <qlistview.h> | ||
14 | |||
13 | class Qsmb : public FormQPESMBBase | 15 | class Qsmb : public FormQPESMBBase |
14 | { | 16 | { |
15 | Q_OBJECT | 17 | Q_OBJECT |
16 | 18 | ||
17 | public: | 19 | public: |
18 | static QString appName() { return QString::fromLatin1("opie-smb"); } | 20 | static QString appName() { return QString::fromLatin1("opie-smb"); } |
19 | Qsmb( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 21 | Qsmb( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
20 | ~Qsmb(); | 22 | ~Qsmb(); |
21 | void scan(); | 23 | void scan(); |
22 | void DoIt(); | 24 | void DoIt(); |
23 | 25 | ||
24 | private: | 26 | private: |
@@ -29,17 +31,19 @@ private: | |||
29 | bool isMounted(const QString &); | 31 | bool isMounted(const QString &); |
30 | QString getMount(const QString &); | 32 | QString getMount(const QString &); |
31 | 33 | ||
32 | public slots: | 34 | public slots: |
33 | void clear(); | 35 | void clear(); |
34 | void scanClicked(); | 36 | void scanClicked(); |
35 | void hostSelected(int); | 37 | void hostSelected(int); |
36 | void DoItClicked(); | 38 | void DoItClicked(); |
37 | void umountIt(); | 39 | void umountIt(); |
38 | QString out; | 40 | QString out; |
39 | bool runCommand(const QStringList &); | 41 | bool runCommand(const QStringList &); |
40 | 42 | ||
43 | private slots: | ||
44 | void TextViewClicked(QListViewItem*); | ||
41 | }; | 45 | }; |
42 | void* runit(void *arg); | 46 | void* runit(void *arg); |
43 | void* runitm(void *arg); | 47 | void* runitm(void *arg); |
44 | 48 | ||
45 | #endif // QSMB_H | 49 | #endif // QSMB_H |