Diffstat (limited to 'noncore/net/opieftp/opieftp.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 4c39569..fe96103 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -10,67 +10,70 @@ | |||
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | //#define DEVELOPERS_VERSION | 12 | //#define DEVELOPERS_VERSION |
13 | 13 | ||
14 | #include "opieftp.h" | 14 | #include "opieftp.h" |
15 | 15 | ||
16 | extern "C" { | 16 | extern "C" { |
17 | #include "../ftplib/ftplib.h" | 17 | #include "../ftplib/ftplib.h" |
18 | } | 18 | } |
19 | 19 | ||
20 | #include "inputDialog.h" | 20 | #include "inputDialog.h" |
21 | 21 | ||
22 | #include <qmenubar.h> | 22 | /* OPIE */ |
23 | #include <opie2/odebug.h> | ||
23 | #include <qpe/qpeapplication.h> | 24 | #include <qpe/qpeapplication.h> |
24 | #include <qpe/resource.h> | 25 | #include <qpe/resource.h> |
25 | #include <qpe/config.h> | 26 | #include <qpe/config.h> |
26 | #include <qpe/mimetype.h> | 27 | #include <qpe/mimetype.h> |
28 | using namespace Opie::Core; | ||
27 | 29 | ||
28 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
29 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
30 | #include <qtoolbutton.h> | 32 | #include <qtoolbutton.h> |
31 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
32 | #include <qlistview.h> | 34 | #include <qlistview.h> |
33 | #include <qlabel.h> | 35 | #include <qlabel.h> |
34 | #include <qprogressbar.h> | 36 | #include <qprogressbar.h> |
35 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
36 | #include <qtabwidget.h> | 38 | #include <qtabwidget.h> |
37 | #include <qlayout.h> | 39 | #include <qlayout.h> |
38 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
41 | #include <qmenubar.h> | ||
39 | #include <qlineedit.h> | 42 | #include <qlineedit.h> |
40 | #include <qlistbox.h> | 43 | #include <qlistbox.h> |
41 | #include <qvbox.h> | 44 | #include <qvbox.h> |
42 | 45 | ||
46 | /* STD */ | ||
43 | #include <unistd.h> | 47 | #include <unistd.h> |
44 | #include <stdlib.h> | 48 | #include <stdlib.h> |
45 | 49 | ||
46 | |||
47 | QProgressBar *ProgressBar; | 50 | QProgressBar *ProgressBar; |
48 | static netbuf *conn=NULL; | 51 | static netbuf *conn=NULL; |
49 | 52 | ||
50 | static int log_progress(netbuf *, int xfered, void *) | 53 | static int log_progress(netbuf *, int xfered, void *) |
51 | { | 54 | { |
52 | // int fsz = *(int *)arg; | 55 | // int fsz = *(int *)arg; |
53 | // int pct = (xfered * 100) / fsz; | 56 | // int pct = (xfered * 100) / fsz; |
54 | // printf("%3d%%\r", pct); | 57 | // printf("%3d%%\r", pct); |
55 | // fflush(stdout); | 58 | // fflush(stdout); |
56 | ProgressBar->setProgress(xfered); | 59 | ProgressBar->setProgress(xfered); |
57 | qApp->processEvents(); | 60 | qApp->processEvents(); |
58 | return 1; | 61 | return 1; |
59 | } | 62 | } |
60 | 63 | ||
61 | OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) | 64 | OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) |
62 | : QMainWindow( parent, name, fl ) | 65 | : QMainWindow( parent, name, fl ) |
63 | { | 66 | { |
64 | qDebug("OpieFtp constructor"); | 67 | odebug << "OpieFtp constructor" << oendl; |
65 | setCaption( tr( "OpieFtp" ) ); | 68 | setCaption( tr( "OpieFtp" ) ); |
66 | fuckeduphack=FALSE; | 69 | fuckeduphack=FALSE; |
67 | 70 | ||
68 | QVBox* wrapperBox = new QVBox( this ); | 71 | QVBox* wrapperBox = new QVBox( this ); |
69 | setCentralWidget( wrapperBox ); | 72 | setCentralWidget( wrapperBox ); |
70 | 73 | ||
71 | QWidget *view = new QWidget( wrapperBox ); | 74 | QWidget *view = new QWidget( wrapperBox ); |
72 | 75 | ||
73 | QGridLayout *layout = new QGridLayout( view ); | 76 | QGridLayout *layout = new QGridLayout( view ); |
74 | layout->setSpacing( 2); | 77 | layout->setSpacing( 2); |
75 | layout->setMargin( 2); | 78 | layout->setMargin( 2); |
76 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 79 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
@@ -325,25 +328,25 @@ OpieFtp::OpieFtp( QWidget* parent, const char* name, WFlags fl) | |||
325 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); | 328 | layout->addMultiCellWidget( ProgressBar, 4, 4, 0, 4); |
326 | ProgressBar->setMaximumHeight(10); | 329 | ProgressBar->setMaximumHeight(10); |
327 | filterStr="*"; | 330 | filterStr="*"; |
328 | b=FALSE; | 331 | b=FALSE; |
329 | #if 0 | 332 | #if 0 |
330 | populateLocalView(); | 333 | populateLocalView(); |
331 | #endif | 334 | #endif |
332 | readConfig(); | 335 | readConfig(); |
333 | 336 | ||
334 | // ServerComboBox->setCurrentItem(currentServerConfig); | 337 | // ServerComboBox->setCurrentItem(currentServerConfig); |
335 | 338 | ||
336 | TabWidget->setCurrentPage(2); | 339 | TabWidget->setCurrentPage(2); |
337 | qDebug("Constructor done"); | 340 | odebug << "Constructor done" << oendl; |
338 | } | 341 | } |
339 | 342 | ||
340 | OpieFtp::~OpieFtp() | 343 | OpieFtp::~OpieFtp() |
341 | { | 344 | { |
342 | } | 345 | } |
343 | 346 | ||
344 | void OpieFtp::cleanUp() | 347 | void OpieFtp::cleanUp() |
345 | { | 348 | { |
346 | if(conn) | 349 | if(conn) |
347 | FtpQuit(conn); | 350 | FtpQuit(conn); |
348 | QString sfile=QDir::homeDirPath(); | 351 | QString sfile=QDir::homeDirPath(); |
349 | if(sfile.right(1) != "/") | 352 | if(sfile.right(1) != "/") |
@@ -396,25 +399,25 @@ void OpieFtp::newConnection() | |||
396 | { | 399 | { |
397 | UsernameComboBox->lineEdit()->setText(""); | 400 | UsernameComboBox->lineEdit()->setText(""); |
398 | PasswordEdit->setText( "" ); | 401 | PasswordEdit->setText( "" ); |
399 | ServerComboBox->lineEdit()->setText( ""); | 402 | ServerComboBox->lineEdit()->setText( ""); |
400 | remotePath->setText( currentRemoteDir = "/"); | 403 | remotePath->setText( currentRemoteDir = "/"); |
401 | PortSpinBox->setValue( 21); | 404 | PortSpinBox->setValue( 21); |
402 | TabWidget->setCurrentPage(2); | 405 | TabWidget->setCurrentPage(2); |
403 | } | 406 | } |
404 | 407 | ||
405 | void OpieFtp::serverComboEdited(const QString & ) | 408 | void OpieFtp::serverComboEdited(const QString & ) |
406 | { | 409 | { |
407 | // if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { | 410 | // if( ServerComboBox->text(currentServerConfig) != edit /*edit.isEmpty() */) { |
408 | // qDebug("ServerComboEdited"); | 411 | // odebug << "ServerComboEdited" << oendl; |
409 | // // currentServerConfig = -1; | 412 | // // currentServerConfig = -1; |
410 | // } | 413 | // } |
411 | } | 414 | } |
412 | 415 | ||
413 | void OpieFtp::UsernameComboBoxEdited(const QString &) { | 416 | void OpieFtp::UsernameComboBoxEdited(const QString &) { |
414 | // currentServerConfig = -1; | 417 | // currentServerConfig = -1; |
415 | } | 418 | } |
416 | 419 | ||
417 | void OpieFtp::PasswordEditEdited(const QString & ) { | 420 | void OpieFtp::PasswordEditEdited(const QString & ) { |
418 | // currentServerConfig = -1; | 421 | // currentServerConfig = -1; |
419 | } | 422 | } |
420 | 423 | ||
@@ -521,25 +524,25 @@ void OpieFtp::localUpload() | |||
521 | QString strItem = it.current()->text(0); | 524 | QString strItem = it.current()->text(0); |
522 | QString localFile = currentDir.canonicalPath()+"/"+strItem; | 525 | QString localFile = currentDir.canonicalPath()+"/"+strItem; |
523 | QString remoteFile= currentRemoteDir+strItem; | 526 | QString remoteFile= currentRemoteDir+strItem; |
524 | QFileInfo fi(localFile); | 527 | QFileInfo fi(localFile); |
525 | if( !fi.isDir()) { | 528 | if( !fi.isDir()) { |
526 | fsz=fi.size(); | 529 | fsz=fi.size(); |
527 | ProgressBar->setTotalSteps(fsz); | 530 | ProgressBar->setTotalSteps(fsz); |
528 | 531 | ||
529 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 532 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
530 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 533 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
531 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 534 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
532 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 535 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
533 | qDebug("Put: %s, %s",localFile.latin1(),remoteFile.latin1()); | 536 | odebug << "Put: " << localFile.latin1() << ", " << remoteFile.latin1() << "" << oendl; |
534 | 537 | ||
535 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 538 | if( !FtpPut( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
536 | QString msg; | 539 | QString msg; |
537 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); | 540 | msg.sprintf(tr("Unable to upload\n")+"%s",FtpLastResponse(conn)); |
538 | msg.replace(QRegExp(":"),"\n"); | 541 | msg.replace(QRegExp(":"),"\n"); |
539 | QMessageBox::message(tr("Note"),msg); | 542 | QMessageBox::message(tr("Note"),msg); |
540 | } | 543 | } |
541 | } else { | 544 | } else { |
542 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); | 545 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); |
543 | } | 546 | } |
544 | ProgressBar->reset(); | 547 | ProgressBar->reset(); |
545 | nullifyCallBack(); | 548 | nullifyCallBack(); |
@@ -582,25 +585,25 @@ void OpieFtp::remoteDownload() | |||
582 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 585 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
583 | QString remoteFile= currentRemoteDir+strItem; | 586 | QString remoteFile= currentRemoteDir+strItem; |
584 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 587 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
585 | fsz = 0; | 588 | fsz = 0; |
586 | QString temp; | 589 | QString temp; |
587 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 590 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
588 | 591 | ||
589 | ProgressBar->setTotalSteps(fsz); | 592 | ProgressBar->setTotalSteps(fsz); |
590 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 593 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
591 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 594 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
592 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 595 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
593 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 596 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
594 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 597 | odebug << "Get: " << localFile.latin1() << ", " << remoteFile.latin1() << "" << oendl; |
595 | 598 | ||
596 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 599 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
597 | QString msg; | 600 | QString msg; |
598 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); | 601 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); |
599 | msg.replace(QRegExp(":"),"\n"); | 602 | msg.replace(QRegExp(":"),"\n"); |
600 | QMessageBox::message(tr("Note"),msg); | 603 | QMessageBox::message(tr("Note"),msg); |
601 | } | 604 | } |
602 | ProgressBar->reset(); | 605 | ProgressBar->reset(); |
603 | nullifyCallBack(); | 606 | nullifyCallBack(); |
604 | it.current()->setSelected(FALSE); | 607 | it.current()->setSelected(FALSE); |
605 | } | 608 | } |
606 | } | 609 | } |
@@ -611,82 +614,82 @@ void OpieFtp::remoteDownload() | |||
611 | TabWidget->setCurrentPage(0); | 614 | TabWidget->setCurrentPage(0); |
612 | populateLocalView(); | 615 | populateLocalView(); |
613 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 616 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
614 | } | 617 | } |
615 | 618 | ||
616 | bool OpieFtp::remoteDirList(const QString &dir) | 619 | bool OpieFtp::remoteDirList(const QString &dir) |
617 | { | 620 | { |
618 | QString tmp = QDir::homeDirPath(); | 621 | QString tmp = QDir::homeDirPath(); |
619 | if(tmp.right(1) != "/") | 622 | if(tmp.right(1) != "/") |
620 | tmp+="/._temp"; | 623 | tmp+="/._temp"; |
621 | else | 624 | else |
622 | tmp+="._temp"; | 625 | tmp+="._temp"; |
623 | // qDebug("Listing remote dir "+tmp); | 626 | // odebug << "Listing remote dir "+tmp << oendl; |
624 | // QCopEnvelope ( "QPE/System", "busy()" ); | 627 | // QCopEnvelope ( "QPE/System", "busy()" ); |
625 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { | 628 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
626 | QString msg; | 629 | QString msg; |
627 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); | 630 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); |
628 | msg.replace(QRegExp(":"),"\n"); | 631 | msg.replace(QRegExp(":"),"\n"); |
629 | QMessageBox::message(tr("Note"),msg); | 632 | QMessageBox::message(tr("Note"),msg); |
630 | return false; | 633 | return false; |
631 | } | 634 | } |
632 | populateRemoteView() ; | 635 | populateRemoteView() ; |
633 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 636 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
634 | return true; | 637 | return true; |
635 | } | 638 | } |
636 | 639 | ||
637 | bool OpieFtp::remoteChDir(const QString &dir) | 640 | bool OpieFtp::remoteChDir(const QString &dir) |
638 | { | 641 | { |
639 | // QCopEnvelope ( "QPE/System", "busy()" ); | 642 | // QCopEnvelope ( "QPE/System", "busy()" ); |
640 | if (!FtpChdir( dir.latin1(), conn )) { | 643 | if (!FtpChdir( dir.latin1(), conn )) { |
641 | QString msg; | 644 | QString msg; |
642 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 645 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
643 | msg.replace(QRegExp(":"),"\n"); | 646 | msg.replace(QRegExp(":"),"\n"); |
644 | QMessageBox::message(tr("Note"),msg); | 647 | QMessageBox::message(tr("Note"),msg); |
645 | // qDebug(msg); | 648 | // odebug << msg << oendl; |
646 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 649 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
647 | return FALSE; | 650 | return FALSE; |
648 | } | 651 | } |
649 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 652 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
650 | return TRUE; | 653 | return TRUE; |
651 | } | 654 | } |
652 | 655 | ||
653 | void OpieFtp::populateLocalView() | 656 | void OpieFtp::populateLocalView() |
654 | { | 657 | { |
655 | Local_View->clear(); | 658 | Local_View->clear(); |
656 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 659 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
657 | currentDir.setMatchAllDirs(TRUE); | 660 | currentDir.setMatchAllDirs(TRUE); |
658 | currentDir.setNameFilter(filterStr); | 661 | currentDir.setNameFilter(filterStr); |
659 | QString fileL, fileS, fileDate; | 662 | QString fileL, fileS, fileDate; |
660 | bool isDir=FALSE; | 663 | bool isDir=FALSE; |
661 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 664 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
662 | QFileInfoListIterator it(*list); | 665 | QFileInfoListIterator it(*list); |
663 | QFileInfo *fi; | 666 | QFileInfo *fi; |
664 | while ( (fi=it.current()) ) { | 667 | while ( (fi=it.current()) ) { |
665 | if (fi->isSymLink() ){ | 668 | if (fi->isSymLink() ){ |
666 | QString symLink=fi->readLink(); | 669 | QString symLink=fi->readLink(); |
667 | qDebug("Symlink detected "+symLink); | 670 | odebug << "Symlink detected "+symLink << oendl; |
668 | QFileInfo sym( symLink); | 671 | QFileInfo sym( symLink); |
669 | fileS.sprintf( "%10i", sym.size() ); | 672 | fileS.sprintf( "%10i", sym.size() ); |
670 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); | 673 | fileL.sprintf( "%s -> %s", fi->fileName().data(),sym.absFilePath().data() ); |
671 | fileDate = sym.lastModified().toString(); | 674 | fileDate = sym.lastModified().toString(); |
672 | } else { | 675 | } else { |
673 | qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 676 | odebug << "Not a dir: "+currentDir.canonicalPath()+fileL << oendl; |
674 | fileS.sprintf( "%10i", fi->size() ); | 677 | fileS.sprintf( "%10i", fi->size() ); |
675 | fileL.sprintf( "%s",fi->fileName().data() ); | 678 | fileL.sprintf( "%s",fi->fileName().data() ); |
676 | fileDate= fi->lastModified().toString(); | 679 | fileDate= fi->lastModified().toString(); |
677 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 680 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
678 | fileL+="/"; | 681 | fileL+="/"; |
679 | isDir=TRUE; | 682 | isDir=TRUE; |
680 | qDebug( fileL); | 683 | odebug << fileL << oendl; |
681 | } | 684 | } |
682 | } | 685 | } |
683 | if(fileL !="./" && fi->exists()) { | 686 | if(fileL !="./" && fi->exists()) { |
684 | item = new QListViewItem( Local_View,fileL, fileDate, fileS ); | 687 | item = new QListViewItem( Local_View,fileL, fileDate, fileS ); |
685 | QPixmap pm; | 688 | QPixmap pm; |
686 | 689 | ||
687 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 690 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
688 | if( !QDir( fi->filePath() ).isReadable()) | 691 | if( !QDir( fi->filePath() ).isReadable()) |
689 | pm = Resource::loadPixmap( "lockedfolder" ); | 692 | pm = Resource::loadPixmap( "lockedfolder" ); |
690 | else | 693 | else |
691 | pm= Resource::loadPixmap( "folder" ); | 694 | pm= Resource::loadPixmap( "folder" ); |
692 | item->setPixmap( 0,pm ); | 695 | item->setPixmap( 0,pm ); |
@@ -711,25 +714,25 @@ void OpieFtp::populateLocalView() | |||
711 | item->setPixmap( 0,pm); | 714 | item->setPixmap( 0,pm); |
712 | } | 715 | } |
713 | isDir=FALSE; | 716 | isDir=FALSE; |
714 | ++it; | 717 | ++it; |
715 | } | 718 | } |
716 | Local_View->setSorting( 3,FALSE); | 719 | Local_View->setSorting( 3,FALSE); |
717 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); | 720 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); |
718 | fillCombo( (const QString &)currentDir); | 721 | fillCombo( (const QString &)currentDir); |
719 | } | 722 | } |
720 | 723 | ||
721 | bool OpieFtp::populateRemoteView( ) | 724 | bool OpieFtp::populateRemoteView( ) |
722 | { | 725 | { |
723 | // qDebug("populate remoteview"); | 726 | // odebug << "populate remoteview" << oendl; |
724 | QString sfile=QDir::homeDirPath(); | 727 | QString sfile=QDir::homeDirPath(); |
725 | if(sfile.right(1) != "/") | 728 | if(sfile.right(1) != "/") |
726 | sfile+="/._temp"; | 729 | sfile+="/._temp"; |
727 | else | 730 | else |
728 | sfile+="._temp"; | 731 | sfile+="._temp"; |
729 | QFile file( sfile); | 732 | QFile file( sfile); |
730 | Remote_View->clear(); | 733 | Remote_View->clear(); |
731 | QString s, File_Name; | 734 | QString s, File_Name; |
732 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 735 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
733 | QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); | 736 | QRegExp monthRe(" [JFMASOND][eapuecoe][brynlgptvc] [ 0-9][0-9] [ 0-9][0-9][:0-9][0-9][0-9] "); |
734 | QString fileL, fileS, fileDate; | 737 | QString fileL, fileS, fileDate; |
735 | if ( file.open(IO_ReadOnly)) { | 738 | if ( file.open(IO_ReadOnly)) { |
@@ -760,69 +763,69 @@ bool OpieFtp::populateRemoteView( ) | |||
760 | // if(itemFile) | 763 | // if(itemFile) |
761 | item->moveItem(itemDir); | 764 | item->moveItem(itemDir); |
762 | item->moveItem(itemFile); | 765 | item->moveItem(itemFile); |
763 | itemFile=item; | 766 | itemFile=item; |
764 | } | 767 | } |
765 | } | 768 | } |
766 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 769 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
767 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 770 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
768 | file.close(); | 771 | file.close(); |
769 | if( file.exists()) | 772 | if( file.exists()) |
770 | file. remove(); | 773 | file. remove(); |
771 | } else | 774 | } else |
772 | qDebug("temp file not opened successfully "+sfile); | 775 | odebug << "temp file not opened successfully "+sfile << oendl; |
773 | Remote_View->setSorting( 4,TRUE); | 776 | Remote_View->setSorting( 4,TRUE); |
774 | return true; | 777 | return true; |
775 | } | 778 | } |
776 | 779 | ||
777 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 780 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
778 | { | 781 | { |
779 | if( selectedItem) { | 782 | if( selectedItem) { |
780 | // if(selectedItem!= NULL) { | 783 | // if(selectedItem!= NULL) { |
781 | // QCopEnvelope ( "QPE/System", "busy()" ); | 784 | // QCopEnvelope ( "QPE/System", "busy()" ); |
782 | QString oldRemoteCurrentDir = currentRemoteDir; | 785 | QString oldRemoteCurrentDir = currentRemoteDir; |
783 | QString strItem=selectedItem->text(0); | 786 | QString strItem=selectedItem->text(0); |
784 | strItem=strItem.simplifyWhiteSpace(); | 787 | strItem=strItem.simplifyWhiteSpace(); |
785 | if(strItem == "../") { // the user wants to go ^ | 788 | if(strItem == "../") { // the user wants to go ^ |
786 | if( FtpCDUp( conn) == 0) { | 789 | if( FtpCDUp( conn) == 0) { |
787 | QString msg; | 790 | QString msg; |
788 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 791 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
789 | msg.replace(QRegExp(":"),"\n"); | 792 | msg.replace(QRegExp(":"),"\n"); |
790 | QMessageBox::message(tr("Note"),msg); | 793 | QMessageBox::message(tr("Note"),msg); |
791 | // qDebug(msg); | 794 | // odebug << msg << oendl; |
792 | } | 795 | } |
793 | char path[256]; | 796 | char path[256]; |
794 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 797 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
795 | QString msg; | 798 | QString msg; |
796 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 799 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
797 | msg.replace(QRegExp(":"),"\n"); | 800 | msg.replace(QRegExp(":"),"\n"); |
798 | QMessageBox::message(tr("Note"),msg); | 801 | QMessageBox::message(tr("Note"),msg); |
799 | // qDebug(msg); | 802 | // odebug << msg << oendl; |
800 | } | 803 | } |
801 | currentRemoteDir=path; | 804 | currentRemoteDir=path; |
802 | } else { | 805 | } else { |
803 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 806 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
804 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 807 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
805 | strItem = strItem.stripWhiteSpace(); | 808 | strItem = strItem.stripWhiteSpace(); |
806 | currentRemoteDir = strItem; | 809 | currentRemoteDir = strItem; |
807 | if( !remoteChDir( (const QString &)strItem)) { | 810 | if( !remoteChDir( (const QString &)strItem)) { |
808 | currentRemoteDir = oldRemoteCurrentDir; | 811 | currentRemoteDir = oldRemoteCurrentDir; |
809 | strItem=""; | 812 | strItem=""; |
810 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 813 | // odebug << "RemoteCurrentDir1 "+oldRemoteCurrentDir << oendl; |
811 | } | 814 | } |
812 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 815 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
813 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 816 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
814 | currentRemoteDir = oldRemoteCurrentDir; | 817 | currentRemoteDir = oldRemoteCurrentDir; |
815 | strItem=""; | 818 | strItem=""; |
816 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 819 | // odebug << "RemoteCurrentDir1 "+oldRemoteCurrentDir << oendl; |
817 | 820 | ||
818 | } else { | 821 | } else { |
819 | currentRemoteDir = currentRemoteDir+strItem; | 822 | currentRemoteDir = currentRemoteDir+strItem; |
820 | } | 823 | } |
821 | } else { | 824 | } else { |
822 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 825 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
823 | return; | 826 | return; |
824 | } | 827 | } |
825 | } | 828 | } |
826 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 829 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
827 | if(currentRemoteDir.right(1) !="/") | 830 | if(currentRemoteDir.right(1) !="/") |
828 | currentRemoteDir +="/"; | 831 | currentRemoteDir +="/"; |
@@ -857,25 +860,25 @@ void OpieFtp::localListClicked(QListViewItem *selectedItem) | |||
857 | populateLocalView(); | 860 | populateLocalView(); |
858 | } else { | 861 | } else { |
859 | currentDir.cdUp(); | 862 | currentDir.cdUp(); |
860 | populateLocalView(); | 863 | populateLocalView(); |
861 | } | 864 | } |
862 | if(QDir(strItem).exists()){ | 865 | if(QDir(strItem).exists()){ |
863 | currentDir.cd(strItem, TRUE); | 866 | currentDir.cd(strItem, TRUE); |
864 | populateLocalView(); | 867 | populateLocalView(); |
865 | } | 868 | } |
866 | } else { | 869 | } else { |
867 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 870 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
868 | if( QFile::exists(strItem ) ) { | 871 | if( QFile::exists(strItem ) ) { |
869 | // qDebug("upload "+strItem); | 872 | // odebug << "upload "+strItem << oendl; |
870 | return; | 873 | return; |
871 | } | 874 | } |
872 | } //end not symlink | 875 | } //end not symlink |
873 | chdir(strItem.latin1()); | 876 | chdir(strItem.latin1()); |
874 | } | 877 | } |
875 | Local_View->ensureItemVisible(Local_View->firstChild()); | 878 | Local_View->ensureItemVisible(Local_View->firstChild()); |
876 | } | 879 | } |
877 | } | 880 | } |
878 | 881 | ||
879 | void OpieFtp::doLocalCd() | 882 | void OpieFtp::doLocalCd() |
880 | { | 883 | { |
881 | localListClicked( Local_View->currentItem()); | 884 | localListClicked( Local_View->currentItem()); |
@@ -1161,25 +1164,25 @@ void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | |||
1161 | 1164 | ||
1162 | currentPathCombo->lineEdit()->setText(currentPath); | 1165 | currentPathCombo->lineEdit()->setText(currentPath); |
1163 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1166 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1164 | currentPathCombo->clear(); | 1167 | currentPathCombo->clear(); |
1165 | remoteDirPathStringList.prepend(currentPath ); | 1168 | remoteDirPathStringList.prepend(currentPath ); |
1166 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1169 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1167 | } | 1170 | } |
1168 | } | 1171 | } |
1169 | 1172 | ||
1170 | void OpieFtp::currentPathComboChanged() | 1173 | void OpieFtp::currentPathComboChanged() |
1171 | { | 1174 | { |
1172 | QString oldRemoteCurrentDir = currentRemoteDir; | 1175 | QString oldRemoteCurrentDir = currentRemoteDir; |
1173 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 1176 | // odebug << "oldRemoteCurrentDir "+oldRemoteCurrentDir << oendl; |
1174 | if (TabWidget->currentPageIndex() == 0) { | 1177 | if (TabWidget->currentPageIndex() == 0) { |
1175 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 1178 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
1176 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 1179 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
1177 | populateLocalView(); | 1180 | populateLocalView(); |
1178 | } else { | 1181 | } else { |
1179 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 1182 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
1180 | } | 1183 | } |
1181 | } | 1184 | } |
1182 | if (TabWidget->currentPageIndex() == 1) { | 1185 | if (TabWidget->currentPageIndex() == 1) { |
1183 | currentRemoteDir = currentPathCombo->lineEdit()->text(); | 1186 | currentRemoteDir = currentPathCombo->lineEdit()->text(); |
1184 | if(currentRemoteDir.right(1) !="/") { | 1187 | if(currentRemoteDir.right(1) !="/") { |
1185 | currentRemoteDir = currentRemoteDir +"/"; | 1188 | currentRemoteDir = currentRemoteDir +"/"; |
@@ -1207,32 +1210,32 @@ void OpieFtp::switchToRemoteTab() | |||
1207 | void OpieFtp::switchToConfigTab() | 1210 | void OpieFtp::switchToConfigTab() |
1208 | { | 1211 | { |
1209 | TabWidget->setCurrentPage(2); | 1212 | TabWidget->setCurrentPage(2); |
1210 | } | 1213 | } |
1211 | 1214 | ||
1212 | void OpieFtp::readConfig() | 1215 | void OpieFtp::readConfig() |
1213 | { | 1216 | { |
1214 | fillCombos(); | 1217 | fillCombos(); |
1215 | Config cfg("opieftp"); | 1218 | Config cfg("opieftp"); |
1216 | cfg.setGroup("Server"); | 1219 | cfg.setGroup("Server"); |
1217 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1220 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1218 | 1221 | ||
1219 | // qDebug("Reading %d", currentServerConfig); | 1222 | // odebug << "Reading " << currentServerConfig << "" << oendl; |
1220 | serverComboSelected( currentServerConfig-1); | 1223 | serverComboSelected( currentServerConfig-1); |
1221 | 1224 | ||
1222 | } | 1225 | } |
1223 | 1226 | ||
1224 | void OpieFtp::writeConfig() | 1227 | void OpieFtp::writeConfig() |
1225 | { | 1228 | { |
1226 | qDebug("write config"); | 1229 | odebug << "write config" << oendl; |
1227 | Config cfg("opieftp"); | 1230 | Config cfg("opieftp"); |
1228 | cfg.setGroup("Server"); | 1231 | cfg.setGroup("Server"); |
1229 | 1232 | ||
1230 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1233 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1231 | 1234 | ||
1232 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1235 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1233 | 1236 | ||
1234 | if( currentServerConfig == -1) { | 1237 | if( currentServerConfig == -1) { |
1235 | 1238 | ||
1236 | for (int i = 1; i <= numberOfEntries; i++) { | 1239 | for (int i = 1; i <= numberOfEntries; i++) { |
1237 | temp.setNum(i); | 1240 | temp.setNum(i); |
1238 | cfg.setGroup("Server"); | 1241 | cfg.setGroup("Server"); |
@@ -1245,133 +1248,133 @@ void OpieFtp::writeConfig() | |||
1245 | remoteServerStr = cfg.readEntry( temp,""); | 1248 | remoteServerStr = cfg.readEntry( temp,""); |
1246 | 1249 | ||
1247 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1250 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1248 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1251 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1249 | 1252 | ||
1250 | temp.setNum(numberOfEntries+1); | 1253 | temp.setNum(numberOfEntries+1); |
1251 | cfg.setGroup("Server"); | 1254 | cfg.setGroup("Server"); |
1252 | 1255 | ||
1253 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1256 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1254 | cfg.writeEntry("currentServer", numberOfEntries+1); | 1257 | cfg.writeEntry("currentServer", numberOfEntries+1); |
1255 | 1258 | ||
1256 | currentServerConfig = numberOfEntries+1; | 1259 | currentServerConfig = numberOfEntries+1; |
1257 | qDebug("setting currentserverconfig to %d", currentServerConfig); | 1260 | odebug << "setting currentserverconfig to " << currentServerConfig << "" << oendl; |
1258 | 1261 | ||
1259 | cfg.setGroup(temp); | 1262 | cfg.setGroup(temp); |
1260 | if(!newServerName.isEmpty()) | 1263 | if(!newServerName.isEmpty()) |
1261 | cfg.writeEntry("ServerName", newServerName); | 1264 | cfg.writeEntry("ServerName", newServerName); |
1262 | 1265 | ||
1263 | cfg.writeEntry("RemotePath", remotePath->text()); | 1266 | cfg.writeEntry("RemotePath", remotePath->text()); |
1264 | 1267 | ||
1265 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1268 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1266 | 1269 | ||
1267 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1270 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1268 | cfg.setGroup("Server"); | 1271 | cfg.setGroup("Server"); |
1269 | 1272 | ||
1270 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1273 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1271 | 1274 | ||
1272 | } | 1275 | } |
1273 | } | 1276 | } |
1274 | 1277 | ||
1275 | void OpieFtp::clearCombos() { | 1278 | void OpieFtp::clearCombos() { |
1276 | qDebug("clearing"); | 1279 | odebug << "clearing" << oendl; |
1277 | ServerComboBox->clear(); | 1280 | ServerComboBox->clear(); |
1278 | UsernameComboBox->clear(); | 1281 | UsernameComboBox->clear(); |
1279 | PasswordEdit->clear(); | 1282 | PasswordEdit->clear(); |
1280 | serverListView->clear(); | 1283 | serverListView->clear(); |
1281 | } | 1284 | } |
1282 | 1285 | ||
1283 | 1286 | ||
1284 | void OpieFtp::fillCombos() | 1287 | void OpieFtp::fillCombos() |
1285 | { | 1288 | { |
1286 | clearCombos(); | 1289 | clearCombos(); |
1287 | 1290 | ||
1288 | Config cfg("opieftp"); | 1291 | Config cfg("opieftp"); |
1289 | cfg.setGroup("Server"); | 1292 | cfg.setGroup("Server"); |
1290 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1293 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1291 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1294 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1292 | 1295 | ||
1293 | for (int i = 1; i <= numberOfEntries; i++) { | 1296 | for (int i = 1; i <= numberOfEntries; i++) { |
1294 | temp.setNum(i); | 1297 | temp.setNum(i); |
1295 | qDebug(temp); | 1298 | odebug << temp << oendl; |
1296 | cfg.setGroup("Server"); | 1299 | cfg.setGroup("Server"); |
1297 | remoteServerStr = cfg.readEntry( temp,""); | 1300 | remoteServerStr = cfg.readEntry( temp,""); |
1298 | qDebug( remoteServerStr); | 1301 | odebug << remoteServerStr << oendl; |
1299 | 1302 | ||
1300 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1303 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1301 | port = remoteServerStr.right( divider - 1); | 1304 | port = remoteServerStr.right( divider - 1); |
1302 | bool ok; | 1305 | bool ok; |
1303 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1306 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1304 | 1307 | ||
1305 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1308 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1306 | qDebug( "remote server string "+remoteServerStr); | 1309 | odebug << "remote server string "+remoteServerStr << oendl; |
1307 | ServerComboBox->insertItem( remoteServerStr ); | 1310 | ServerComboBox->insertItem( remoteServerStr ); |
1308 | 1311 | ||
1309 | cfg.setGroup(temp); | 1312 | cfg.setGroup(temp); |
1310 | 1313 | ||
1311 | username = cfg.readEntry(temp); | 1314 | username = cfg.readEntry(temp); |
1312 | UsernameComboBox->insertItem(username); | 1315 | UsernameComboBox->insertItem(username); |
1313 | password = cfg.readEntryCrypt(username,""); | 1316 | password = cfg.readEntryCrypt(username,""); |
1314 | PasswordEdit->setText(password); | 1317 | PasswordEdit->setText(password); |
1315 | 1318 | ||
1316 | serverListView->insertItem( cfg.readEntry("ServerName")); | 1319 | serverListView->insertItem( cfg.readEntry("ServerName")); |
1317 | } | 1320 | } |
1318 | } | 1321 | } |
1319 | 1322 | ||
1320 | 1323 | ||
1321 | void OpieFtp::serverComboSelected(int index) | 1324 | void OpieFtp::serverComboSelected(int index) |
1322 | { | 1325 | { |
1323 | currentServerConfig = index+1; | 1326 | currentServerConfig = index+1; |
1324 | qDebug("server combo selected %d", index+1); | 1327 | odebug << "server combo selected " << index+1 << "" << oendl; |
1325 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1328 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1326 | // remoteServerStr = ServerComboBox->text(index); | 1329 | // remoteServerStr = ServerComboBox->text(index); |
1327 | 1330 | ||
1328 | Config cfg("opieftp"); | 1331 | Config cfg("opieftp"); |
1329 | cfg.setGroup("Server"); | 1332 | cfg.setGroup("Server"); |
1330 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1333 | // int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1331 | 1334 | ||
1332 | temp.setNum(index+1); | 1335 | temp.setNum(index+1); |
1333 | remoteServerStr = cfg.readEntry( temp,""); | 1336 | remoteServerStr = cfg.readEntry( temp,""); |
1334 | 1337 | ||
1335 | qDebug("Group" +temp); | 1338 | odebug << "Group" +temp << oendl; |
1336 | cfg.setGroup(temp); | 1339 | cfg.setGroup(temp); |
1337 | // qDebug(temp); | 1340 | // odebug << temp << oendl; |
1338 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1341 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1339 | port = remoteServerStr.right( divider - 1); | 1342 | port = remoteServerStr.right( divider - 1); |
1340 | bool ok; | 1343 | bool ok; |
1341 | int portInt = port.toInt(&ok,10); | 1344 | int portInt = port.toInt(&ok,10); |
1342 | if( portInt == 0) portInt = 21; | 1345 | if( portInt == 0) portInt = 21; |
1343 | 1346 | ||
1344 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); | 1347 | ServerComboBox->lineEdit()->setText(remoteServerStr.left( remoteServerStr.find(":",0,TRUE))); |
1345 | 1348 | ||
1346 | PortSpinBox->setValue( portInt); | 1349 | PortSpinBox->setValue( portInt); |
1347 | 1350 | ||
1348 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1351 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1349 | 1352 | ||
1350 | username = cfg.readEntry("Username", "anonymous"); | 1353 | username = cfg.readEntry("Username", "anonymous"); |
1351 | UsernameComboBox->lineEdit()->setText(username); | 1354 | UsernameComboBox->lineEdit()->setText(username); |
1352 | qDebug(username); | 1355 | odebug << username << oendl; |
1353 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); | 1356 | // odebug << "Password is "+cfg.readEntryCrypt(username << oendl; |
1354 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1357 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1355 | // UsernameComboBox | 1358 | // UsernameComboBox |
1356 | // PasswordEdit | 1359 | // PasswordEdit |
1357 | 1360 | ||
1358 | cfg.setGroup("Server"); | 1361 | cfg.setGroup("Server"); |
1359 | temp.sprintf("%d",currentServerConfig); | 1362 | temp.sprintf("%d",currentServerConfig); |
1360 | cfg.writeEntry("currentServer", temp); | 1363 | cfg.writeEntry("currentServer", temp); |
1361 | 1364 | ||
1362 | fuckeduphack = TRUE; | 1365 | fuckeduphack = TRUE; |
1363 | serverListView->setCurrentItem( index); | 1366 | serverListView->setCurrentItem( index); |
1364 | fuckeduphack=FALSE; | 1367 | fuckeduphack=FALSE; |
1365 | qDebug("server list set selected %d",index); | 1368 | odebug << "server list set selected " << index << "" << oendl; |
1366 | update(); | 1369 | update(); |
1367 | } | 1370 | } |
1368 | 1371 | ||
1369 | void OpieFtp::deleteServer() | 1372 | void OpieFtp::deleteServer() |
1370 | { | 1373 | { |
1371 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; | 1374 | QString username, remoteServerStr, remotePathStr, password, port, temp, servername; |
1372 | remoteServerStr = ServerComboBox->currentText( ); | 1375 | remoteServerStr = ServerComboBox->currentText( ); |
1373 | username = UsernameComboBox->currentText(); | 1376 | username = UsernameComboBox->currentText(); |
1374 | servername=serverListView->currentText(); | 1377 | servername=serverListView->currentText(); |
1375 | 1378 | ||
1376 | Config cfg("opieftp"); | 1379 | Config cfg("opieftp"); |
1377 | cfg.setGroup("Server"); | 1380 | cfg.setGroup("Server"); |
@@ -1382,25 +1385,25 @@ void OpieFtp::deleteServer() | |||
1382 | temp.setNum(i); | 1385 | temp.setNum(i); |
1383 | // cfg.setGroup("Server"); | 1386 | // cfg.setGroup("Server"); |
1384 | cfg.setGroup(QString::number(i)); | 1387 | cfg.setGroup(QString::number(i)); |
1385 | tempname=cfg.readEntry( "ServerName",""); | 1388 | tempname=cfg.readEntry( "ServerName",""); |
1386 | 1389 | ||
1387 | if( tempname.find( servername,0,TRUE) != -1 ) { | 1390 | if( tempname.find( servername,0,TRUE) != -1 ) { |
1388 | // servername.find( cfg.readEntry("ServerName")) != -1 && | 1391 | // servername.find( cfg.readEntry("ServerName")) != -1 && |
1389 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && | 1392 | // remoteServerStr.find( cfg.readEntry("RemotePath")) != -1 && |
1390 | // username.find( cfg.readEntry("Username")) != -1) { | 1393 | // username.find( cfg.readEntry("Username")) != -1) { |
1391 | 1394 | ||
1392 | serverListView->removeItem(i); | 1395 | serverListView->removeItem(i); |
1393 | 1396 | ||
1394 | qDebug("OK DELETE "+tempname); | 1397 | odebug << "OK DELETE "+tempname << oendl; |
1395 | cfg.removeEntry(QString::number(i)); | 1398 | cfg.removeEntry(QString::number(i)); |
1396 | for ( ; i <= numberOfEntries; i++) { | 1399 | for ( ; i <= numberOfEntries; i++) { |
1397 | cfg.setGroup("Server"); | 1400 | cfg.setGroup("Server"); |
1398 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); | 1401 | cfg.writeEntry("Server", QString::number(numberOfEntries + 1 )); |
1399 | 1402 | ||
1400 | cfg.setGroup(QString::number(i+1)); //get next server config | 1403 | cfg.setGroup(QString::number(i+1)); //get next server config |
1401 | servername=cfg.readEntry("ServerName"); | 1404 | servername=cfg.readEntry("ServerName"); |
1402 | remoteServerStr=cfg.readEntry("RemotePath"); | 1405 | remoteServerStr=cfg.readEntry("RemotePath"); |
1403 | username=cfg.readEntry("Username"); | 1406 | username=cfg.readEntry("Username"); |
1404 | password=cfg.readEntryCrypt( username); | 1407 | password=cfg.readEntryCrypt( username); |
1405 | 1408 | ||
1406 | cfg.setGroup(QString::number(i)); | 1409 | cfg.setGroup(QString::number(i)); |
@@ -1437,33 +1440,33 @@ void OpieFtp::upDir() | |||
1437 | dir.cdUp(); | 1440 | dir.cdUp(); |
1438 | current = dir.canonicalPath(); | 1441 | current = dir.canonicalPath(); |
1439 | chdir( current.latin1() ); | 1442 | chdir( current.latin1() ); |
1440 | currentDir.cd( current, TRUE); | 1443 | currentDir.cd( current, TRUE); |
1441 | populateLocalView(); | 1444 | populateLocalView(); |
1442 | update(); | 1445 | update(); |
1443 | } else { | 1446 | } else { |
1444 | if( FtpCDUp( conn) == 0) { | 1447 | if( FtpCDUp( conn) == 0) { |
1445 | QString msg; | 1448 | QString msg; |
1446 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 1449 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
1447 | msg.replace(QRegExp(":"),"\n"); | 1450 | msg.replace(QRegExp(":"),"\n"); |
1448 | QMessageBox::message(tr("Note"),msg); | 1451 | QMessageBox::message(tr("Note"),msg); |
1449 | // qDebug(msg); | 1452 | // odebug << msg << oendl; |
1450 | } | 1453 | } |
1451 | char path[256]; | 1454 | char path[256]; |
1452 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 1455 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
1453 | QString msg; | 1456 | QString msg; |
1454 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 1457 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
1455 | msg.replace(QRegExp(":"),"\n"); | 1458 | msg.replace(QRegExp(":"),"\n"); |
1456 | QMessageBox::message(tr("Note"),msg); | 1459 | QMessageBox::message(tr("Note"),msg); |
1457 | // qDebug(msg); | 1460 | // odebug << msg << oendl; |
1458 | } | 1461 | } |
1459 | currentRemoteDir=path; | 1462 | currentRemoteDir=path; |
1460 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1463 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1461 | if(currentRemoteDir.right(1) !="/") | 1464 | if(currentRemoteDir.right(1) !="/") |
1462 | currentRemoteDir +="/"; | 1465 | currentRemoteDir +="/"; |
1463 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 1466 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
1464 | fillRemoteCombo( (const QString &)currentRemoteDir); | 1467 | fillRemoteCombo( (const QString &)currentRemoteDir); |
1465 | 1468 | ||
1466 | } | 1469 | } |
1467 | } | 1470 | } |
1468 | 1471 | ||
1469 | void OpieFtp::docButtonPushed() { | 1472 | void OpieFtp::docButtonPushed() { |
@@ -1506,24 +1509,24 @@ void OpieFtp::NewServer() { | |||
1506 | } | 1509 | } |
1507 | } | 1510 | } |
1508 | currentServerConfig =-1; | 1511 | currentServerConfig =-1; |
1509 | writeConfig(); | 1512 | writeConfig(); |
1510 | serverListView->insertItem( newServerName ); | 1513 | serverListView->insertItem( newServerName ); |
1511 | serverListView->setCurrentItem( serverListView->count()); | 1514 | serverListView->setCurrentItem( serverListView->count()); |
1512 | } | 1515 | } |
1513 | } | 1516 | } |
1514 | 1517 | ||
1515 | void OpieFtp::serverListClicked( const QString &item) { | 1518 | void OpieFtp::serverListClicked( const QString &item) { |
1516 | if(item.isEmpty()) return; | 1519 | if(item.isEmpty()) return; |
1517 | Config cfg("opieftp"); | 1520 | Config cfg("opieftp"); |
1518 | qDebug("highltined "+item); | 1521 | odebug << "highltined "+item << oendl; |
1519 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1522 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1520 | for (int i = 1; i <= numberOfEntries; i++) { | 1523 | for (int i = 1; i <= numberOfEntries; i++) { |
1521 | cfg.setGroup(QString::number(i)); | 1524 | cfg.setGroup(QString::number(i)); |
1522 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) | 1525 | if(cfg.readEntry( "ServerName").find(item) != -1 && !fuckeduphack) |
1523 | serverComboSelected(i-1); | 1526 | serverComboSelected(i-1); |
1524 | } | 1527 | } |
1525 | } | 1528 | } |
1526 | 1529 | ||
1527 | void OpieFtp::timerOut() { | 1530 | void OpieFtp::timerOut() { |
1528 | 1531 | ||
1529 | } | 1532 | } |