author | llornkcor <llornkcor> | 2005-08-16 09:55:52 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2005-08-16 09:55:52 (UTC) |
commit | dd4792fe0ac89205e7d7a7e38f3d4350e19f25d7 (patch) (unidiff) | |
tree | 4a9bcee8e558a66ab9ecd0c1c6337581821c9d95 /noncore/net/opie-smb/qsmb.cpp | |
parent | 8c44cc4fdb67ea6b96cf7e49ec648de4049a9f1c (diff) | |
download | opie-dd4792fe0ac89205e7d7a7e38f3d4350e19f25d7.zip opie-dd4792fe0ac89205e7d7a7e38f3d4350e19f25d7.tar.gz opie-dd4792fe0ac89205e7d7a7e38f3d4350e19f25d7.tar.bz2 |
fix a few things
Diffstat (limited to 'noncore/net/opie-smb/qsmb.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opie-smb/qsmb.cpp | 19 |
1 files changed, 17 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 | |||
@@ -23,48 +23,49 @@ | |||
23 | #include <pthread.h> | 23 | #include <pthread.h> |
24 | #include <signal.h> | 24 | #include <signal.h> |
25 | #include <ctype.h> | 25 | #include <ctype.h> |
26 | 26 | ||
27 | 27 | ||
28 | #include <netinet/in.h> | 28 | #include <netinet/in.h> |
29 | #include <arpa/inet.h> | 29 | #include <arpa/inet.h> |
30 | #include <rpc/clnt.h> | 30 | #include <rpc/clnt.h> |
31 | 31 | ||
32 | #include <sys/vfs.h> | 32 | #include <sys/vfs.h> |
33 | #include <mntent.h> | 33 | #include <mntent.h> |
34 | 34 | ||
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); |
59 | setTabOrder(DoItBtn, UnmountBtn); | 60 | setTabOrder(DoItBtn, UnmountBtn); |
60 | 61 | ||
61 | top_element = NULL; | 62 | top_element = NULL; |
62 | scanning = false; | 63 | scanning = false; |
63 | } | 64 | } |
64 | 65 | ||
65 | Qsmb::~Qsmb() | 66 | Qsmb::~Qsmb() |
66 | { | 67 | { |
67 | } | 68 | } |
68 | 69 | ||
69 | void Qsmb::clear() | 70 | void Qsmb::clear() |
70 | { | 71 | { |
@@ -332,59 +333,63 @@ void Qsmb::DoIt() | |||
332 | smbv << ccmd.join(" ") ; | 333 | smbv << ccmd.join(" ") ; |
333 | sambenv.close(); | 334 | sambenv.close(); |
334 | } | 335 | } |
335 | 336 | ||
336 | noerr = runCommand(ccmd); | 337 | noerr = runCommand(ccmd); |
337 | 338 | ||
338 | LScan->setText(""); | 339 | LScan->setText(""); |
339 | 340 | ||
340 | if(noerr && isMounted(mount)) { | 341 | if(noerr && isMounted(mount)) { |
341 | element->setText(2, mount); | 342 | element->setText(2, mount); |
342 | TextViewOutput->append("\n\n================CheckMounts==================\n"); | 343 | TextViewOutput->append("\n\n================CheckMounts==================\n"); |
343 | ccmd = "/bin/mount"; | 344 | ccmd = "/bin/mount"; |
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, ""); |
379 | 384 | ||
380 | ccmd = "/bin/mount"; | 385 | ccmd = "/bin/mount"; |
381 | runCommand(ccmd); | 386 | runCommand(ccmd); |
382 | } | 387 | } |
383 | 388 | ||
384 | bool Qsmb::runCommand(const QStringList & command) { | 389 | bool Qsmb::runCommand(const QStringList & command) { |
385 | qWarning( "runCommand " + command.join(" ") ); | 390 | qWarning( "runCommand " + command.join(" ") ); |
386 | TextViewOutput->append(command.join(" ")); | 391 | TextViewOutput->append(command.join(" ")); |
387 | out = ""; | 392 | out = ""; |
388 | Process ipkg_status( command); | 393 | Process ipkg_status( command); |
389 | bool r = ipkg_status.exec("",out); | 394 | bool r = ipkg_status.exec("",out); |
390 | 395 | ||
@@ -414,24 +419,34 @@ bool Qsmb::isMounted(const QString &mountPoint) | |||
414 | mounted = true; | 419 | mounted = true; |
415 | } | 420 | } |
416 | } | 421 | } |
417 | endmntent( mntfp ); | 422 | endmntent( mntfp ); |
418 | return mounted; | 423 | return mounted; |
419 | } | 424 | } |
420 | 425 | ||
421 | QString Qsmb::getMount(const QString &shareName) | 426 | QString Qsmb::getMount(const QString &shareName) |
422 | { | 427 | { |
423 | struct mntent *me; | 428 | struct mntent *me; |
424 | QString mount; | 429 | QString mount; |
425 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); | 430 | FILE *mntfp = setmntent( "/etc/mtab", "r" ); |
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 | } | ||