author | llornkcor <llornkcor> | 2002-04-30 12:35:07 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-30 12:35:07 (UTC) |
commit | 23834bdf2d57d155644234e45e647567d4c027d1 (patch) (unidiff) | |
tree | 4ef44ee01a72360c65bca7e59fc16f7618151eeb | |
parent | aae6ce64221457dbed804d7ebce095a621ea892a (diff) | |
download | opie-23834bdf2d57d155644234e45e647567d4c027d1.zip opie-23834bdf2d57d155644234e45e647567d4c027d1.tar.gz opie-23834bdf2d57d155644234e45e647567d4c027d1.tar.bz2 |
added rescan to popup menu
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index 6d0be57..0b88a35 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -481,787 +481,789 @@ void OpieFtp::localUpload() | |||
481 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); | 481 | QMessageBox::message(tr("Note"),tr("Cannot upload directories")); |
482 | } | 482 | } |
483 | ProgressBar->reset(); | 483 | ProgressBar->reset(); |
484 | nullifyCallBack(); | 484 | nullifyCallBack(); |
485 | it.current()->setSelected(FALSE); | 485 | it.current()->setSelected(FALSE); |
486 | } //end currentSelected | 486 | } //end currentSelected |
487 | } | 487 | } |
488 | for ( ; it.current(); ++it ) { | 488 | for ( ; it.current(); ++it ) { |
489 | Local_View->clearSelection(); | 489 | Local_View->clearSelection(); |
490 | } | 490 | } |
491 | Local_View->clearFocus(); | 491 | Local_View->clearFocus(); |
492 | TabWidget->setCurrentPage(1); | 492 | TabWidget->setCurrentPage(1); |
493 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 493 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
494 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 494 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
495 | } | 495 | } |
496 | 496 | ||
497 | void OpieFtp::nullifyCallBack() | 497 | void OpieFtp::nullifyCallBack() |
498 | { | 498 | { |
499 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); | 499 | FtpOptions(FTPLIB_CALLBACK, NULL, conn); |
500 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); | 500 | FtpOptions(FTPLIB_IDLETIME, NULL, conn); |
501 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); | 501 | FtpOptions(FTPLIB_CALLBACKARG, NULL, conn); |
502 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); | 502 | FtpOptions(FTPLIB_CALLBACKBYTES, NULL, conn); |
503 | } | 503 | } |
504 | 504 | ||
505 | void OpieFtp::remoteDownload() | 505 | void OpieFtp::remoteDownload() |
506 | { | 506 | { |
507 | // qApp->processEvents(); | 507 | // qApp->processEvents(); |
508 | int fsz; | 508 | int fsz; |
509 | // QCopEnvelope ( "QPE/System", "busy()" ); | 509 | // QCopEnvelope ( "QPE/System", "busy()" ); |
510 | 510 | ||
511 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 511 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
512 | QListViewItemIterator it( Remote_View ); | 512 | QListViewItemIterator it( Remote_View ); |
513 | for ( ; it.current(); ++it ) { | 513 | for ( ; it.current(); ++it ) { |
514 | if ( it.current()->isSelected() ) { | 514 | if ( it.current()->isSelected() ) { |
515 | QString strItem = it.current()->text(0); | 515 | QString strItem = it.current()->text(0); |
516 | // strItem=strItem.right(strItem.length()-1); | 516 | // strItem=strItem.right(strItem.length()-1); |
517 | QString localFile = currentDir.canonicalPath(); | 517 | QString localFile = currentDir.canonicalPath(); |
518 | if(localFile.right(1).find("/",0,TRUE) == -1) | 518 | if(localFile.right(1).find("/",0,TRUE) == -1) |
519 | localFile += "/"; | 519 | localFile += "/"; |
520 | localFile += strItem; | 520 | localFile += strItem; |
521 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; | 521 | // QString localFile = currentDir.canonicalPath()+"/"+strItem; |
522 | QString remoteFile= currentRemoteDir+strItem; | 522 | QString remoteFile= currentRemoteDir+strItem; |
523 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) | 523 | if (!FtpSize( remoteFile.latin1(), &fsz, FTPLIB_ASCII, conn)) |
524 | fsz = 0; | 524 | fsz = 0; |
525 | QString temp; | 525 | QString temp; |
526 | temp.sprintf( remoteFile+" "+" %dkb", fsz); | 526 | temp.sprintf( remoteFile+" "+" %dkb", fsz); |
527 | 527 | ||
528 | ProgressBar->setTotalSteps(fsz); | 528 | ProgressBar->setTotalSteps(fsz); |
529 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); | 529 | FtpOptions(FTPLIB_CALLBACK, (long) log_progress, conn); |
530 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); | 530 | FtpOptions(FTPLIB_IDLETIME, (long) 1000, conn); |
531 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); | 531 | FtpOptions(FTPLIB_CALLBACKARG, (long) &fsz, conn); |
532 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); | 532 | FtpOptions(FTPLIB_CALLBACKBYTES, (long) fsz/10, conn); |
533 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); | 533 | qDebug("Get: %s, %s",localFile.latin1(),remoteFile.latin1()); |
534 | 534 | ||
535 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { | 535 | if(!FtpGet( localFile.latin1(), remoteFile.latin1(),FTPLIB_IMAGE, conn ) ) { |
536 | QString msg; | 536 | QString msg; |
537 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); | 537 | msg.sprintf(tr("Unable to download \n")+"%s",FtpLastResponse(conn)); |
538 | msg.replace(QRegExp(":"),"\n"); | 538 | msg.replace(QRegExp(":"),"\n"); |
539 | QMessageBox::message(tr("Note"),msg); | 539 | QMessageBox::message(tr("Note"),msg); |
540 | } | 540 | } |
541 | ProgressBar->reset(); | 541 | ProgressBar->reset(); |
542 | nullifyCallBack(); | 542 | nullifyCallBack(); |
543 | it.current()->setSelected(FALSE); | 543 | it.current()->setSelected(FALSE); |
544 | } | 544 | } |
545 | } | 545 | } |
546 | for ( ; it.current(); ++it ) { | 546 | for ( ; it.current(); ++it ) { |
547 | Remote_View->clearSelection(); | 547 | Remote_View->clearSelection(); |
548 | } | 548 | } |
549 | Remote_View->setFocus(); | 549 | Remote_View->setFocus(); |
550 | TabWidget->setCurrentPage(0); | 550 | TabWidget->setCurrentPage(0); |
551 | populateLocalView(); | 551 | populateLocalView(); |
552 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 552 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
553 | } | 553 | } |
554 | 554 | ||
555 | bool OpieFtp::remoteDirList(const QString &dir) | 555 | bool OpieFtp::remoteDirList(const QString &dir) |
556 | { | 556 | { |
557 | QString tmp = QDir::homeDirPath(); | 557 | QString tmp = QDir::homeDirPath(); |
558 | if(tmp.right(1) != "/") | 558 | if(tmp.right(1) != "/") |
559 | tmp+="/._temp"; | 559 | tmp+="/._temp"; |
560 | else | 560 | else |
561 | tmp+="._temp"; | 561 | tmp+="._temp"; |
562 | // qDebug("Listing remote dir "+tmp); | 562 | // qDebug("Listing remote dir "+tmp); |
563 | // QCopEnvelope ( "QPE/System", "busy()" ); | 563 | // QCopEnvelope ( "QPE/System", "busy()" ); |
564 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { | 564 | if (!FtpDir( tmp.latin1(), dir.latin1(), conn) ) { |
565 | QString msg; | 565 | QString msg; |
566 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); | 566 | msg.sprintf(tr("Unable to list the directory\n")+dir+"\n%s",FtpLastResponse(conn) ); |
567 | msg.replace(QRegExp(":"),"\n"); | 567 | msg.replace(QRegExp(":"),"\n"); |
568 | QMessageBox::message(tr("Note"),msg); | 568 | QMessageBox::message(tr("Note"),msg); |
569 | return false; | 569 | return false; |
570 | } | 570 | } |
571 | populateRemoteView() ; | 571 | populateRemoteView() ; |
572 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 572 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
573 | return true; | 573 | return true; |
574 | } | 574 | } |
575 | 575 | ||
576 | bool OpieFtp::remoteChDir(const QString &dir) | 576 | bool OpieFtp::remoteChDir(const QString &dir) |
577 | { | 577 | { |
578 | // QCopEnvelope ( "QPE/System", "busy()" ); | 578 | // QCopEnvelope ( "QPE/System", "busy()" ); |
579 | if (!FtpChdir( dir.latin1(), conn )) { | 579 | if (!FtpChdir( dir.latin1(), conn )) { |
580 | QString msg; | 580 | QString msg; |
581 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); | 581 | msg.sprintf(tr("Unable to change directories\n")+dir+"\n%s",FtpLastResponse(conn)); |
582 | msg.replace(QRegExp(":"),"\n"); | 582 | msg.replace(QRegExp(":"),"\n"); |
583 | QMessageBox::message(tr("Note"),msg); | 583 | QMessageBox::message(tr("Note"),msg); |
584 | // qDebug(msg); | 584 | // qDebug(msg); |
585 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 585 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
586 | return FALSE; | 586 | return FALSE; |
587 | } | 587 | } |
588 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 588 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
589 | return TRUE; | 589 | return TRUE; |
590 | } | 590 | } |
591 | 591 | ||
592 | void OpieFtp::populateLocalView() | 592 | void OpieFtp::populateLocalView() |
593 | { | 593 | { |
594 | Local_View->clear(); | 594 | Local_View->clear(); |
595 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 595 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
596 | currentDir.setMatchAllDirs(TRUE); | 596 | currentDir.setMatchAllDirs(TRUE); |
597 | currentDir.setNameFilter(filterStr); | 597 | currentDir.setNameFilter(filterStr); |
598 | QString fileL, fileS, fileDate; | 598 | QString fileL, fileS, fileDate; |
599 | bool isDir=FALSE; | 599 | bool isDir=FALSE; |
600 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 600 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
601 | QFileInfoListIterator it(*list); | 601 | QFileInfoListIterator it(*list); |
602 | QFileInfo *fi; | 602 | QFileInfo *fi; |
603 | while ( (fi=it.current()) ) { | 603 | while ( (fi=it.current()) ) { |
604 | if (fi->isSymLink() ){ | 604 | if (fi->isSymLink() ){ |
605 | QString symLink=fi->readLink(); | 605 | QString symLink=fi->readLink(); |
606 | // qDebug("Symlink detected "+symLink); | 606 | // qDebug("Symlink detected "+symLink); |
607 | QFileInfo sym( symLink); | 607 | QFileInfo sym( symLink); |
608 | fileS.sprintf( "%10li", sym.size() ); | 608 | fileS.sprintf( "%10li", sym.size() ); |
609 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 609 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
610 | fileDate = sym.lastModified().toString(); | 610 | fileDate = sym.lastModified().toString(); |
611 | } else { | 611 | } else { |
612 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 612 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
613 | fileS.sprintf( "%10li", fi->size() ); | 613 | fileS.sprintf( "%10li", fi->size() ); |
614 | fileL.sprintf( "%s",fi->fileName().data() ); | 614 | fileL.sprintf( "%s",fi->fileName().data() ); |
615 | fileDate= fi->lastModified().toString(); | 615 | fileDate= fi->lastModified().toString(); |
616 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 616 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
617 | fileL+="/"; | 617 | fileL+="/"; |
618 | isDir=TRUE; | 618 | isDir=TRUE; |
619 | // qDebug( fileL); | 619 | // qDebug( fileL); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | if(fileL !="./" && fi->exists()) { | 622 | if(fileL !="./" && fi->exists()) { |
623 | item= new QListViewItem( Local_View,fileL, fileDate, fileS ); | 623 | item= new QListViewItem( Local_View,fileL, fileDate, fileS ); |
624 | QPixmap pm; | 624 | QPixmap pm; |
625 | 625 | ||
626 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 626 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
627 | if( !QDir( fi->filePath() ).isReadable()) | 627 | if( !QDir( fi->filePath() ).isReadable()) |
628 | pm = Resource::loadPixmap( "lockedfolder" ); | 628 | pm = Resource::loadPixmap( "lockedfolder" ); |
629 | else | 629 | else |
630 | pm= Resource::loadPixmap( "folder" ); | 630 | pm= Resource::loadPixmap( "folder" ); |
631 | item->setPixmap( 0,pm ); | 631 | item->setPixmap( 0,pm ); |
632 | } else { | 632 | } else { |
633 | if( !fi->isReadable() ) | 633 | if( !fi->isReadable() ) |
634 | pm = Resource::loadPixmap( "locked" ); | 634 | pm = Resource::loadPixmap( "locked" ); |
635 | else { | 635 | else { |
636 | MimeType mt(fi->filePath()); | 636 | MimeType mt(fi->filePath()); |
637 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 637 | pm=mt.pixmap(); //sets the correct pixmap for mimetype |
638 | if(pm.isNull()) | 638 | if(pm.isNull()) |
639 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | 639 | pm = Resource::loadPixmap( "UnknownDocument-14" ); |
640 | item->setPixmap( 0,pm); | 640 | item->setPixmap( 0,pm); |
641 | } | 641 | } |
642 | } | 642 | } |
643 | if( fileL.find("->",0,TRUE) != -1) { | 643 | if( fileL.find("->",0,TRUE) != -1) { |
644 | // overlay link image | 644 | // overlay link image |
645 | pm= Resource::loadPixmap( "folder" ); | 645 | pm= Resource::loadPixmap( "folder" ); |
646 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 646 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
647 | QPainter painter( &pm ); | 647 | QPainter painter( &pm ); |
648 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 648 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
649 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 649 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
650 | item->setPixmap( 0, pm); | 650 | item->setPixmap( 0, pm); |
651 | } | 651 | } |
652 | } | 652 | } |
653 | isDir=FALSE; | 653 | isDir=FALSE; |
654 | ++it; | 654 | ++it; |
655 | } | 655 | } |
656 | Local_View->setSorting( 3,FALSE); | 656 | Local_View->setSorting( 3,FALSE); |
657 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); | 657 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath() ); |
658 | fillCombo( (const QString &)currentDir); | 658 | fillCombo( (const QString &)currentDir); |
659 | } | 659 | } |
660 | 660 | ||
661 | bool OpieFtp::populateRemoteView( ) | 661 | bool OpieFtp::populateRemoteView( ) |
662 | { | 662 | { |
663 | // qDebug("populate remoteview"); | 663 | // qDebug("populate remoteview"); |
664 | QString sfile=QDir::homeDirPath(); | 664 | QString sfile=QDir::homeDirPath(); |
665 | if(sfile.right(1) != "/") | 665 | if(sfile.right(1) != "/") |
666 | sfile+="/._temp"; | 666 | sfile+="/._temp"; |
667 | else | 667 | else |
668 | sfile+="._temp"; | 668 | sfile+="._temp"; |
669 | QFile file( sfile); | 669 | QFile file( sfile); |
670 | Remote_View->clear(); | 670 | Remote_View->clear(); |
671 | QString s, File_Name; | 671 | QString s, File_Name; |
672 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 672 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
673 | QString fileL, fileS, fileDate; | 673 | QString fileL, fileS, fileDate; |
674 | if ( file.open(IO_ReadOnly)) { | 674 | if ( file.open(IO_ReadOnly)) { |
675 | QTextStream t( &file ); // use a text stream | 675 | QTextStream t( &file ); // use a text stream |
676 | while ( !t.eof()) { | 676 | while ( !t.eof()) { |
677 | s = t.readLine(); | 677 | s = t.readLine(); |
678 | fileL = s.right(s.length()-55); | 678 | fileL = s.right(s.length()-55); |
679 | fileL = fileL.stripWhiteSpace(); | 679 | fileL = fileL.stripWhiteSpace(); |
680 | if(s.left(1) == "d") | 680 | if(s.left(1) == "d") |
681 | fileL = fileL+"/"; | 681 | fileL = fileL+"/"; |
682 | // fileL = "/"+fileL+"/"; | 682 | // fileL = "/"+fileL+"/"; |
683 | fileS = s.mid( 30, 42-30); | 683 | fileS = s.mid( 30, 42-30); |
684 | fileS = fileS.stripWhiteSpace(); | 684 | fileS = fileS.stripWhiteSpace(); |
685 | fileDate = s.mid( 42, 55-42); | 685 | fileDate = s.mid( 42, 55-42); |
686 | fileDate = fileDate.stripWhiteSpace(); | 686 | fileDate = fileDate.stripWhiteSpace(); |
687 | if(fileL.find("total",0,TRUE) == -1) { | 687 | if(fileL.find("total",0,TRUE) == -1) { |
688 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { | 688 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
689 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); | 689 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"d"); |
690 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 690 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
691 | // if(itemDir) | 691 | // if(itemDir) |
692 | item->moveItem(itemDir); | 692 | item->moveItem(itemDir); |
693 | itemDir=item; | 693 | itemDir=item; |
694 | } else { | 694 | } else { |
695 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); | 695 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileDate, fileS,"f"); |
696 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 696 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
697 | // if(itemFile) | 697 | // if(itemFile) |
698 | item->moveItem(itemDir); | 698 | item->moveItem(itemDir); |
699 | item->moveItem(itemFile); | 699 | item->moveItem(itemFile); |
700 | itemFile=item; | 700 | itemFile=item; |
701 | } | 701 | } |
702 | } | 702 | } |
703 | } | 703 | } |
704 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 704 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
705 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 705 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
706 | file.close(); | 706 | file.close(); |
707 | if( file.exists()) | 707 | if( file.exists()) |
708 | file. remove(); | 708 | file. remove(); |
709 | } else | 709 | } else |
710 | qDebug("temp file not opened successfullly "+sfile); | 710 | qDebug("temp file not opened successfullly "+sfile); |
711 | Remote_View->setSorting( 4,TRUE); | 711 | Remote_View->setSorting( 4,TRUE); |
712 | return true; | 712 | return true; |
713 | } | 713 | } |
714 | 714 | ||
715 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 715 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
716 | { | 716 | { |
717 | if( selectedItem) { | 717 | if( selectedItem) { |
718 | // QCopEnvelope ( "QPE/System", "busy()" ); | 718 | // QCopEnvelope ( "QPE/System", "busy()" ); |
719 | QString oldRemoteCurrentDir = currentRemoteDir; | 719 | QString oldRemoteCurrentDir = currentRemoteDir; |
720 | QString strItem=selectedItem->text(0); | 720 | QString strItem=selectedItem->text(0); |
721 | strItem=strItem.simplifyWhiteSpace(); | 721 | strItem=strItem.simplifyWhiteSpace(); |
722 | if(strItem == "../") { // the user wants to go ^ | 722 | if(strItem == "../") { // the user wants to go ^ |
723 | if( FtpCDUp( conn) == 0) { | 723 | if( FtpCDUp( conn) == 0) { |
724 | QString msg; | 724 | QString msg; |
725 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); | 725 | msg.sprintf(tr("Unable to cd up\n")+"%s",FtpLastResponse(conn)); |
726 | msg.replace(QRegExp(":"),"\n"); | 726 | msg.replace(QRegExp(":"),"\n"); |
727 | QMessageBox::message(tr("Note"),msg); | 727 | QMessageBox::message(tr("Note"),msg); |
728 | // qDebug(msg); | 728 | // qDebug(msg); |
729 | } | 729 | } |
730 | char path[256]; | 730 | char path[256]; |
731 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 731 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
732 | QString msg; | 732 | QString msg; |
733 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); | 733 | msg.sprintf(tr("Unable to get working dir\n")+"%s",FtpLastResponse(conn)); |
734 | msg.replace(QRegExp(":"),"\n"); | 734 | msg.replace(QRegExp(":"),"\n"); |
735 | QMessageBox::message(tr("Note"),msg); | 735 | QMessageBox::message(tr("Note"),msg); |
736 | // qDebug(msg); | 736 | // qDebug(msg); |
737 | } | 737 | } |
738 | currentRemoteDir=path; | 738 | currentRemoteDir=path; |
739 | } else { | 739 | } else { |
740 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers | 740 | if(strItem.find("->",0,TRUE) != -1) { //symlink on some servers |
741 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); | 741 | strItem=strItem.right( strItem.length() - strItem.find("->",0,TRUE) - 2 ); |
742 | strItem = strItem.stripWhiteSpace(); | 742 | strItem = strItem.stripWhiteSpace(); |
743 | currentRemoteDir = strItem; | 743 | currentRemoteDir = strItem; |
744 | if( !remoteChDir( (const QString &)strItem)) { | 744 | if( !remoteChDir( (const QString &)strItem)) { |
745 | currentRemoteDir = oldRemoteCurrentDir; | 745 | currentRemoteDir = oldRemoteCurrentDir; |
746 | strItem=""; | 746 | strItem=""; |
747 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 747 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
748 | } | 748 | } |
749 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory | 749 | } else if(strItem.find("/",0,TRUE) != -1) { // this is a directory |
750 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { | 750 | if( !remoteChDir( (const QString &)currentRemoteDir + strItem)) { |
751 | currentRemoteDir = oldRemoteCurrentDir; | 751 | currentRemoteDir = oldRemoteCurrentDir; |
752 | strItem=""; | 752 | strItem=""; |
753 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); | 753 | // qDebug("RemoteCurrentDir1 "+oldRemoteCurrentDir); |
754 | 754 | ||
755 | } else { | 755 | } else { |
756 | currentRemoteDir = currentRemoteDir+strItem; | 756 | currentRemoteDir = currentRemoteDir+strItem; |
757 | } | 757 | } |
758 | } else { | 758 | } else { |
759 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 759 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
760 | return; | 760 | return; |
761 | } | 761 | } |
762 | } | 762 | } |
763 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 763 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
764 | if(currentRemoteDir.right(1) !="/") | 764 | if(currentRemoteDir.right(1) !="/") |
765 | currentRemoteDir +="/"; | 765 | currentRemoteDir +="/"; |
766 | currentPathCombo->lineEdit()->setText( currentRemoteDir); | 766 | currentPathCombo->lineEdit()->setText( currentRemoteDir); |
767 | fillRemoteCombo( (const QString &)currentRemoteDir); | 767 | fillRemoteCombo( (const QString &)currentRemoteDir); |
768 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 768 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
769 | } | 769 | } |
770 | } | 770 | } |
771 | 771 | ||
772 | void OpieFtp::localListClicked(QListViewItem *selectedItem) | 772 | void OpieFtp::localListClicked(QListViewItem *selectedItem) |
773 | { | 773 | { |
774 | if(selectedItem!= NULL) { | 774 | if(selectedItem!= NULL) { |
775 | 775 | ||
776 | QString strItem=selectedItem->text(0); | 776 | QString strItem=selectedItem->text(0); |
777 | QString strSize=selectedItem->text(1); | 777 | QString strSize=selectedItem->text(1); |
778 | strSize=strSize.stripWhiteSpace(); | 778 | strSize=strSize.stripWhiteSpace(); |
779 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 779 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
780 | // is symlink | 780 | // is symlink |
781 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 781 | QString strItem2 = strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
782 | if(QDir(strItem2).exists() ) { | 782 | if(QDir(strItem2).exists() ) { |
783 | currentDir.cd(strItem2, TRUE); | 783 | currentDir.cd(strItem2, TRUE); |
784 | populateLocalView(); | 784 | populateLocalView(); |
785 | } | 785 | } |
786 | } else { // not a symlink | 786 | } else { // not a symlink |
787 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 787 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
788 | 788 | ||
789 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 789 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
790 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 790 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
791 | currentDir.cd(strItem,FALSE); | 791 | currentDir.cd(strItem,FALSE); |
792 | populateLocalView(); | 792 | populateLocalView(); |
793 | } else { | 793 | } else { |
794 | currentDir.cdUp(); | 794 | currentDir.cdUp(); |
795 | populateLocalView(); | 795 | populateLocalView(); |
796 | } | 796 | } |
797 | if(QDir(strItem).exists()){ | 797 | if(QDir(strItem).exists()){ |
798 | currentDir.cd(strItem, TRUE); | 798 | currentDir.cd(strItem, TRUE); |
799 | populateLocalView(); | 799 | populateLocalView(); |
800 | } | 800 | } |
801 | } else { | 801 | } else { |
802 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 802 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
803 | if( QFile::exists(strItem ) ) { | 803 | if( QFile::exists(strItem ) ) { |
804 | // qDebug("upload "+strItem); | 804 | // qDebug("upload "+strItem); |
805 | return; | 805 | return; |
806 | } | 806 | } |
807 | } //end not symlink | 807 | } //end not symlink |
808 | chdir(strItem.latin1()); | 808 | chdir(strItem.latin1()); |
809 | } | 809 | } |
810 | } | 810 | } |
811 | } | 811 | } |
812 | 812 | ||
813 | void OpieFtp::doLocalCd() | 813 | void OpieFtp::doLocalCd() |
814 | { | 814 | { |
815 | localListClicked( Local_View->currentItem()); | 815 | localListClicked( Local_View->currentItem()); |
816 | } | 816 | } |
817 | 817 | ||
818 | void OpieFtp:: doRemoteCd() | 818 | void OpieFtp:: doRemoteCd() |
819 | { | 819 | { |
820 | remoteListClicked( Remote_View->currentItem()); | 820 | remoteListClicked( Remote_View->currentItem()); |
821 | 821 | ||
822 | } | 822 | } |
823 | 823 | ||
824 | void OpieFtp::showHidden() | 824 | void OpieFtp::showHidden() |
825 | { | 825 | { |
826 | if (!b) { | 826 | if (!b) { |
827 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 827 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
828 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 828 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
829 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 829 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
830 | b=TRUE; | 830 | b=TRUE; |
831 | 831 | ||
832 | } else { | 832 | } else { |
833 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 833 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
834 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 834 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
835 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 835 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
836 | b=FALSE; | 836 | b=FALSE; |
837 | } | 837 | } |
838 | populateLocalView(); | 838 | populateLocalView(); |
839 | } | 839 | } |
840 | 840 | ||
841 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 841 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
842 | { | 842 | { |
843 | // if(item) | 843 | // if(item) |
844 | if (mouse == 2) { | 844 | if (mouse == 2) { |
845 | showLocalMenu(item); | 845 | showLocalMenu(item); |
846 | } | 846 | } |
847 | } | 847 | } |
848 | 848 | ||
849 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 849 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
850 | { | 850 | { |
851 | if(mouse == 2) { | 851 | if(mouse == 2) { |
852 | showRemoteMenu(item); | 852 | showRemoteMenu(item); |
853 | } | 853 | } |
854 | } | 854 | } |
855 | 855 | ||
856 | void OpieFtp::showRemoteMenu(QListViewItem * item) | 856 | void OpieFtp::showRemoteMenu(QListViewItem * item) |
857 | { | 857 | { |
858 | QPopupMenu * m;// = new QPopupMenu( Local_View ); | 858 | QPopupMenu * m;// = new QPopupMenu( Local_View ); |
859 | m = new QPopupMenu(this); | 859 | m = new QPopupMenu(this); |
860 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) | 860 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) != -1) |
861 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 861 | m->insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
862 | else | 862 | else |
863 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 863 | m->insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
864 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 864 | m->insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
865 | m->insertItem( tr("Rescan"), this, SLOT( populateLocalView() )); | ||
865 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 866 | m->insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
866 | m->insertSeparator(); | 867 | m->insertSeparator(); |
867 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 868 | m->insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
868 | m->exec( QCursor::pos() ); | 869 | m->exec( QCursor::pos() ); |
869 | delete m; | 870 | delete m; |
870 | } | 871 | } |
871 | 872 | ||
872 | void OpieFtp::showLocalMenu(QListViewItem * item) | 873 | void OpieFtp::showLocalMenu(QListViewItem * item) |
873 | { | 874 | { |
874 | 875 | ||
875 | QPopupMenu *m; | 876 | QPopupMenu *m; |
876 | m = new QPopupMenu( this); | 877 | m = new QPopupMenu( this); |
877 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 878 | m->insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
878 | m->insertSeparator(); | 879 | m->insertSeparator(); |
879 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) | 880 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE) !=-1) |
880 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 881 | m->insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
881 | else | 882 | else |
882 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 883 | m->insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
883 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 884 | m->insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
885 | m->insertItem( tr("Rescan"), this, SLOT( populateRemoteView() )); | ||
884 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 886 | m->insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
885 | m->insertSeparator(); | 887 | m->insertSeparator(); |
886 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 888 | m->insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
887 | m->setCheckable(TRUE); | 889 | m->setCheckable(TRUE); |
888 | if (b) | 890 | if (b) |
889 | m->setItemChecked(m->idAt(0),TRUE); | 891 | m->setItemChecked(m->idAt(0),TRUE); |
890 | else | 892 | else |
891 | m->setItemChecked(m->idAt(0),FALSE); | 893 | m->setItemChecked(m->idAt(0),FALSE); |
892 | 894 | ||
893 | m->exec( QCursor::pos() ); | 895 | m->exec( QCursor::pos() ); |
894 | delete m; | 896 | delete m; |
895 | } | 897 | } |
896 | 898 | ||
897 | void OpieFtp::localMakDir() | 899 | void OpieFtp::localMakDir() |
898 | { | 900 | { |
899 | InputDialog *fileDlg; | 901 | InputDialog *fileDlg; |
900 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 902 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
901 | fileDlg->exec(); | 903 | fileDlg->exec(); |
902 | if( fileDlg->result() == 1 ) { | 904 | if( fileDlg->result() == 1 ) { |
903 | QString filename = fileDlg->LineEdit1->text(); | 905 | QString filename = fileDlg->LineEdit1->text(); |
904 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 906 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
905 | } | 907 | } |
906 | populateLocalView(); | 908 | populateLocalView(); |
907 | } | 909 | } |
908 | 910 | ||
909 | void OpieFtp::localDelete() | 911 | void OpieFtp::localDelete() |
910 | { | 912 | { |
911 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); | 913 | QList<QListViewItem> * getSelectedItems( QListView * Local_View ); |
912 | QListViewItemIterator it( Local_View ); | 914 | QListViewItemIterator it( Local_View ); |
913 | for ( ; it.current(); ++it ) { | 915 | for ( ; it.current(); ++it ) { |
914 | if ( it.current()->isSelected() ) { | 916 | if ( it.current()->isSelected() ) { |
915 | QString f = it.current()->text(0); | 917 | QString f = it.current()->text(0); |
916 | it.current()->setSelected(FALSE); | 918 | it.current()->setSelected(FALSE); |
917 | 919 | ||
918 | // QString f = Local_View->currentItem()->text(0); | 920 | // QString f = Local_View->currentItem()->text(0); |
919 | if(QDir(f).exists() ) { | 921 | if(QDir(f).exists() ) { |
920 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ | 922 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+ |
921 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { | 923 | tr(" ?\nIt must be empty"),tr("Yes"),tr("No"),0,0,1) ) { |
922 | case 0: { | 924 | case 0: { |
923 | f=currentDir.canonicalPath()+"/"+f; | 925 | f=currentDir.canonicalPath()+"/"+f; |
924 | QString cmd="rmdir "+f; | 926 | QString cmd="rmdir "+f; |
925 | system( cmd.latin1()); | 927 | system( cmd.latin1()); |
926 | } | 928 | } |
927 | break; | 929 | break; |
928 | case 1: | 930 | case 1: |
929 | // exit | 931 | // exit |
930 | break; | 932 | break; |
931 | }; | 933 | }; |
932 | 934 | ||
933 | } else { | 935 | } else { |
934 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f | 936 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f |
935 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { | 937 | +" ?",tr("Yes"),tr("No"),0,0,1) ) { |
936 | case 0: { | 938 | case 0: { |
937 | f=currentDir.canonicalPath()+"/"+f; | 939 | f=currentDir.canonicalPath()+"/"+f; |
938 | QString cmd="rm "+f; | 940 | QString cmd="rm "+f; |
939 | system( cmd.latin1()); | 941 | system( cmd.latin1()); |
940 | } | 942 | } |
941 | break; | 943 | break; |
942 | case 1: | 944 | case 1: |
943 | // exit | 945 | // exit |
944 | break; | 946 | break; |
945 | }; | 947 | }; |
946 | } | 948 | } |
947 | } | 949 | } |
948 | } | 950 | } |
949 | populateLocalView(); | 951 | populateLocalView(); |
950 | 952 | ||
951 | } | 953 | } |
952 | 954 | ||
953 | void OpieFtp::remoteMakDir() | 955 | void OpieFtp::remoteMakDir() |
954 | { | 956 | { |
955 | InputDialog *fileDlg; | 957 | InputDialog *fileDlg; |
956 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 958 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
957 | fileDlg->exec(); | 959 | fileDlg->exec(); |
958 | if( fileDlg->result() == 1 ) { | 960 | if( fileDlg->result() == 1 ) { |
959 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; | 961 | QString filename = fileDlg->LineEdit1->text();//+".playlist"; |
960 | QString tmp=currentRemoteDir+filename; | 962 | QString tmp=currentRemoteDir+filename; |
961 | // QCopEnvelope ( "QPE/System", "busy()" ); | 963 | // QCopEnvelope ( "QPE/System", "busy()" ); |
962 | if(FtpMkdir( tmp.latin1(), conn) == 0) { | 964 | if(FtpMkdir( tmp.latin1(), conn) == 0) { |
963 | QString msg; | 965 | QString msg; |
964 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); | 966 | msg.sprintf(tr("Unable to make directory\n")+"%s",FtpLastResponse(conn)); |
965 | msg.replace(QRegExp(":"),"\n"); | 967 | msg.replace(QRegExp(":"),"\n"); |
966 | QMessageBox::message(tr("Note"),msg); | 968 | QMessageBox::message(tr("Note"),msg); |
967 | } | 969 | } |
968 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 970 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
969 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 971 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
970 | } | 972 | } |
971 | } | 973 | } |
972 | 974 | ||
973 | void OpieFtp::remoteDelete() | 975 | void OpieFtp::remoteDelete() |
974 | { | 976 | { |
975 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); | 977 | QList<QListViewItem> * getSelectedItems( QListView * Remote_View ); |
976 | QListViewItemIterator it( Remote_View ); | 978 | QListViewItemIterator it( Remote_View ); |
977 | for ( ; it.current(); ++it ) { | 979 | for ( ; it.current(); ++it ) { |
978 | if ( it.current()->isSelected() ) { | 980 | if ( it.current()->isSelected() ) { |
979 | QString f = it.current()->text(0); | 981 | QString f = it.current()->text(0); |
980 | // QString f = Remote_View->currentItem()->text(0); | 982 | // QString f = Remote_View->currentItem()->text(0); |
981 | // QCopEnvelope ( "QPE/System", "busy()" ); | 983 | // QCopEnvelope ( "QPE/System", "busy()" ); |
982 | if( f.right(1) =="/") { | 984 | if( f.right(1) =="/") { |
983 | QString path= currentRemoteDir+f; | 985 | QString path= currentRemoteDir+f; |
984 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 986 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
985 | ,tr("Yes"),tr("No"),0,0,1) ) { | 987 | ,tr("Yes"),tr("No"),0,0,1) ) { |
986 | case 0: { | 988 | case 0: { |
987 | f=currentDir.canonicalPath()+"/"+f; | 989 | f=currentDir.canonicalPath()+"/"+f; |
988 | if(FtpRmdir( path.latin1(), conn) ==0) { | 990 | if(FtpRmdir( path.latin1(), conn) ==0) { |
989 | QString msg; | 991 | QString msg; |
990 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); | 992 | msg.sprintf(tr("Unable to remove directory\n")+"%s",FtpLastResponse(conn)); |
991 | msg.replace(QRegExp(":"),"\n"); | 993 | msg.replace(QRegExp(":"),"\n"); |
992 | QMessageBox::message(tr("Note"),msg); | 994 | QMessageBox::message(tr("Note"),msg); |
993 | } | 995 | } |
994 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 996 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
995 | } | 997 | } |
996 | break; | 998 | break; |
997 | }; | 999 | }; |
998 | } else { | 1000 | } else { |
999 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" | 1001 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+f+"?" |
1000 | ,tr("Yes"),tr("No"),0,0,1) ) { | 1002 | ,tr("Yes"),tr("No"),0,0,1) ) { |
1001 | case 0: { | 1003 | case 0: { |
1002 | QString path= currentRemoteDir+f; | 1004 | QString path= currentRemoteDir+f; |
1003 | if(FtpDelete( path.latin1(), conn)==0) { | 1005 | if(FtpDelete( path.latin1(), conn)==0) { |
1004 | QString msg; | 1006 | QString msg; |
1005 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); | 1007 | msg.sprintf(tr("Unable to delete file\n")+"%s",FtpLastResponse(conn)); |
1006 | msg.replace(QRegExp(":"),"\n"); | 1008 | msg.replace(QRegExp(":"),"\n"); |
1007 | QMessageBox::message(tr("Note"),msg); | 1009 | QMessageBox::message(tr("Note"),msg); |
1008 | } | 1010 | } |
1009 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1011 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1010 | } | 1012 | } |
1011 | break; | 1013 | break; |
1012 | }; | 1014 | }; |
1013 | } | 1015 | } |
1014 | } | 1016 | } |
1015 | } | 1017 | } |
1016 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1018 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1017 | } | 1019 | } |
1018 | 1020 | ||
1019 | void OpieFtp::remoteRename() | 1021 | void OpieFtp::remoteRename() |
1020 | { | 1022 | { |
1021 | QString curFile = Remote_View->currentItem()->text(0); | 1023 | QString curFile = Remote_View->currentItem()->text(0); |
1022 | InputDialog *fileDlg; | 1024 | InputDialog *fileDlg; |
1023 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1025 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1024 | fileDlg->setTextEdit((const QString &)curFile); | 1026 | fileDlg->setTextEdit((const QString &)curFile); |
1025 | fileDlg->exec(); | 1027 | fileDlg->exec(); |
1026 | if( fileDlg->result() == 1 ) { | 1028 | if( fileDlg->result() == 1 ) { |
1027 | QString oldName = currentRemoteDir +"/"+ curFile; | 1029 | QString oldName = currentRemoteDir +"/"+ curFile; |
1028 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; | 1030 | QString newName = currentRemoteDir +"/"+ fileDlg->LineEdit1->text();//+".playlist"; |
1029 | // QCopEnvelope ( "QPE/System", "busy()" ); | 1031 | // QCopEnvelope ( "QPE/System", "busy()" ); |
1030 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { | 1032 | if(FtpRename( oldName.latin1(), newName.latin1(),conn) == 0) { |
1031 | QString msg; | 1033 | QString msg; |
1032 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); | 1034 | msg.sprintf(tr("Unable to rename file\n")+"%s",FtpLastResponse(conn)); |
1033 | msg.replace(QRegExp(":"),"\n"); | 1035 | msg.replace(QRegExp(":"),"\n"); |
1034 | QMessageBox::message(tr("Note"),msg); | 1036 | QMessageBox::message(tr("Note"),msg); |
1035 | } | 1037 | } |
1036 | // QCopEnvelope ( "QPE/System", "notBusy()" ); | 1038 | // QCopEnvelope ( "QPE/System", "notBusy()" ); |
1037 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate | 1039 | remoteDirList( (const QString &)currentRemoteDir); //this also calls populate |
1038 | } | 1040 | } |
1039 | } | 1041 | } |
1040 | 1042 | ||
1041 | void OpieFtp::localRename() | 1043 | void OpieFtp::localRename() |
1042 | { | 1044 | { |
1043 | QString curFile = Local_View->currentItem()->text(0); | 1045 | QString curFile = Local_View->currentItem()->text(0); |
1044 | InputDialog *fileDlg; | 1046 | InputDialog *fileDlg; |
1045 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); | 1047 | fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0); |
1046 | fileDlg->setTextEdit((const QString &)curFile); | 1048 | fileDlg->setTextEdit((const QString &)curFile); |
1047 | fileDlg->exec(); | 1049 | fileDlg->exec(); |
1048 | if( fileDlg->result() == 1 ) { | 1050 | if( fileDlg->result() == 1 ) { |
1049 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 1051 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
1050 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 1052 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
1051 | if( rename(oldname.latin1(), newName.latin1())== -1) | 1053 | if( rename(oldname.latin1(), newName.latin1())== -1) |
1052 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 1054 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
1053 | } | 1055 | } |
1054 | populateLocalView(); | 1056 | populateLocalView(); |
1055 | } | 1057 | } |
1056 | 1058 | ||
1057 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { | 1059 | void OpieFtp::currentPathComboActivated(const QString & currentPath) { |
1058 | if (TabWidget->currentPageIndex() == 0) { | 1060 | if (TabWidget->currentPageIndex() == 0) { |
1059 | chdir( currentPath.latin1() ); | 1061 | chdir( currentPath.latin1() ); |
1060 | currentDir.cd( currentPath, TRUE); | 1062 | currentDir.cd( currentPath, TRUE); |
1061 | populateLocalView(); | 1063 | populateLocalView(); |
1062 | update(); | 1064 | update(); |
1063 | } else { | 1065 | } else { |
1064 | // chdir( currentPath.latin1() ); | 1066 | // chdir( currentPath.latin1() ); |
1065 | // currentDir.cd( currentPath, TRUE); | 1067 | // currentDir.cd( currentPath, TRUE); |
1066 | // populateList(); | 1068 | // populateList(); |
1067 | // update(); | 1069 | // update(); |
1068 | 1070 | ||
1069 | } | 1071 | } |
1070 | } | 1072 | } |
1071 | 1073 | ||
1072 | void OpieFtp::fillCombo(const QString ¤tPath) { | 1074 | void OpieFtp::fillCombo(const QString ¤tPath) { |
1073 | 1075 | ||
1074 | currentPathCombo->lineEdit()->setText(currentPath); | 1076 | currentPathCombo->lineEdit()->setText(currentPath); |
1075 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1077 | if( localDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1076 | currentPathCombo->clear(); | 1078 | currentPathCombo->clear(); |
1077 | localDirPathStringList.prepend(currentPath ); | 1079 | localDirPathStringList.prepend(currentPath ); |
1078 | currentPathCombo->insertStringList( localDirPathStringList,-1); | 1080 | currentPathCombo->insertStringList( localDirPathStringList,-1); |
1079 | } | 1081 | } |
1080 | currentPathCombo->lineEdit()->setText(currentPath); | 1082 | currentPathCombo->lineEdit()->setText(currentPath); |
1081 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1083 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1082 | currentPathCombo->clear(); | 1084 | currentPathCombo->clear(); |
1083 | remoteDirPathStringList.prepend(currentPath ); | 1085 | remoteDirPathStringList.prepend(currentPath ); |
1084 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1086 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1085 | } | 1087 | } |
1086 | } | 1088 | } |
1087 | 1089 | ||
1088 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { | 1090 | void OpieFtp::fillRemoteCombo(const QString ¤tPath) { |
1089 | 1091 | ||
1090 | currentPathCombo->lineEdit()->setText(currentPath); | 1092 | currentPathCombo->lineEdit()->setText(currentPath); |
1091 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 1093 | if( remoteDirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
1092 | currentPathCombo->clear(); | 1094 | currentPathCombo->clear(); |
1093 | remoteDirPathStringList.prepend(currentPath ); | 1095 | remoteDirPathStringList.prepend(currentPath ); |
1094 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); | 1096 | currentPathCombo->insertStringList( remoteDirPathStringList,-1); |
1095 | } | 1097 | } |
1096 | } | 1098 | } |
1097 | 1099 | ||
1098 | void OpieFtp::currentPathComboChanged() | 1100 | void OpieFtp::currentPathComboChanged() |
1099 | { | 1101 | { |
1100 | QString oldRemoteCurrentDir = currentRemoteDir; | 1102 | QString oldRemoteCurrentDir = currentRemoteDir; |
1101 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); | 1103 | // qDebug("oldRemoteCurrentDir "+oldRemoteCurrentDir); |
1102 | if (TabWidget->currentPageIndex() == 0) { | 1104 | if (TabWidget->currentPageIndex() == 0) { |
1103 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { | 1105 | if(QDir( currentPathCombo->lineEdit()->text()).exists()) { |
1104 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); | 1106 | currentDir.setPath( currentPathCombo->lineEdit()->text() ); |
1105 | populateLocalView(); | 1107 | populateLocalView(); |
1106 | } else { | 1108 | } else { |
1107 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); | 1109 | QMessageBox::message(tr("Note"),tr("That directory does not exist")); |
1108 | } | 1110 | } |
1109 | } | 1111 | } |
1110 | if (TabWidget->currentPageIndex() == 1) { | 1112 | if (TabWidget->currentPageIndex() == 1) { |
1111 | currentRemoteDir = currentPathCombo->lineEdit()->text(); | 1113 | currentRemoteDir = currentPathCombo->lineEdit()->text(); |
1112 | if(currentRemoteDir.right(1) !="/") { | 1114 | if(currentRemoteDir.right(1) !="/") { |
1113 | currentRemoteDir = currentRemoteDir +"/"; | 1115 | currentRemoteDir = currentRemoteDir +"/"; |
1114 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1116 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1115 | } | 1117 | } |
1116 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { | 1118 | if( !remoteChDir( (const QString &)currentRemoteDir) ) { |
1117 | currentRemoteDir = oldRemoteCurrentDir; | 1119 | currentRemoteDir = oldRemoteCurrentDir; |
1118 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); | 1120 | currentPathCombo->lineEdit()->setText( currentRemoteDir ); |
1119 | } | 1121 | } |
1120 | 1122 | ||
1121 | remoteDirList( (const QString &)currentRemoteDir); | 1123 | remoteDirList( (const QString &)currentRemoteDir); |
1122 | } | 1124 | } |
1123 | } | 1125 | } |
1124 | 1126 | ||
1125 | void OpieFtp::switchToLocalTab() | 1127 | void OpieFtp::switchToLocalTab() |
1126 | { | 1128 | { |
1127 | TabWidget->setCurrentPage(0); | 1129 | TabWidget->setCurrentPage(0); |
1128 | } | 1130 | } |
1129 | 1131 | ||
1130 | void OpieFtp::switchToRemoteTab() | 1132 | void OpieFtp::switchToRemoteTab() |
1131 | { | 1133 | { |
1132 | TabWidget->setCurrentPage(1); | 1134 | TabWidget->setCurrentPage(1); |
1133 | } | 1135 | } |
1134 | 1136 | ||
1135 | void OpieFtp::switchToConfigTab() | 1137 | void OpieFtp::switchToConfigTab() |
1136 | { | 1138 | { |
1137 | TabWidget->setCurrentPage(2); | 1139 | TabWidget->setCurrentPage(2); |
1138 | } | 1140 | } |
1139 | 1141 | ||
1140 | void OpieFtp::readConfig() | 1142 | void OpieFtp::readConfig() |
1141 | { | 1143 | { |
1142 | fillCombos(); | 1144 | fillCombos(); |
1143 | Config cfg("opieftp"); | 1145 | Config cfg("opieftp"); |
1144 | cfg.setGroup("Server"); | 1146 | cfg.setGroup("Server"); |
1145 | currentServerConfig = cfg.readNumEntry("currentServer", -1); | 1147 | currentServerConfig = cfg.readNumEntry("currentServer", -1); |
1146 | // qDebug("Reading %d", currentServerConfig); | 1148 | // qDebug("Reading %d", currentServerConfig); |
1147 | serverComboSelected( currentServerConfig); | 1149 | serverComboSelected( currentServerConfig); |
1148 | } | 1150 | } |
1149 | 1151 | ||
1150 | void OpieFtp::writeConfig() | 1152 | void OpieFtp::writeConfig() |
1151 | { | 1153 | { |
1152 | Config cfg("opieftp"); | 1154 | Config cfg("opieftp"); |
1153 | cfg.setGroup("Server"); | 1155 | cfg.setGroup("Server"); |
1154 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1156 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1155 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1157 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1156 | if( currentServerConfig == -1) { | 1158 | if( currentServerConfig == -1) { |
1157 | for (int i = 1; i <= numberOfEntries; i++) { | 1159 | for (int i = 1; i <= numberOfEntries; i++) { |
1158 | temp.setNum(i); | 1160 | temp.setNum(i); |
1159 | cfg.setGroup("Server"); | 1161 | cfg.setGroup("Server"); |
1160 | QString tempStr = cfg.readEntry( temp,""); | 1162 | QString tempStr = cfg.readEntry( temp,""); |
1161 | } | 1163 | } |
1162 | temp.setNum( numberOfEntries + 1); | 1164 | temp.setNum( numberOfEntries + 1); |
1163 | cfg.setGroup("Server"); | 1165 | cfg.setGroup("Server"); |
1164 | remoteServerStr = cfg.readEntry( temp,""); | 1166 | remoteServerStr = cfg.readEntry( temp,""); |
1165 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1167 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1166 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1168 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1167 | 1169 | ||
1168 | temp.setNum(numberOfEntries+1); | 1170 | temp.setNum(numberOfEntries+1); |
1169 | cfg.setGroup("Server"); | 1171 | cfg.setGroup("Server"); |
1170 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); | 1172 | cfg.writeEntry( temp, ServerComboBox->currentText() +":"+PortSpinBox->cleanText() ); |
1171 | cfg.setGroup(temp); | 1173 | cfg.setGroup(temp); |
1172 | cfg.writeEntry("RemotePath", remotePath->text()); | 1174 | cfg.writeEntry("RemotePath", remotePath->text()); |
1173 | cfg.writeEntry("Username", UsernameComboBox->currentText()); | 1175 | cfg.writeEntry("Username", UsernameComboBox->currentText()); |
1174 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); | 1176 | cfg.writeEntryCrypt( UsernameComboBox->currentText(), PasswordEdit->text()); |
1175 | cfg.setGroup("Server"); | 1177 | cfg.setGroup("Server"); |
1176 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); | 1178 | cfg.writeEntry("numberOfEntries", QString::number(numberOfEntries + 1 )); |
1177 | } | 1179 | } |
1178 | } | 1180 | } |
1179 | 1181 | ||
1180 | void OpieFtp::fillCombos() | 1182 | void OpieFtp::fillCombos() |
1181 | { | 1183 | { |
1182 | Config cfg("opieftp"); | 1184 | Config cfg("opieftp"); |
1183 | cfg.setGroup("Server"); | 1185 | cfg.setGroup("Server"); |
1184 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1186 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1185 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1187 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1186 | for (int i = 1; i <= numberOfEntries; i++) { | 1188 | for (int i = 1; i <= numberOfEntries; i++) { |
1187 | temp.setNum(i); | 1189 | temp.setNum(i); |
1188 | cfg.setGroup("Server"); | 1190 | cfg.setGroup("Server"); |
1189 | remoteServerStr = cfg.readEntry( temp,""); | 1191 | remoteServerStr = cfg.readEntry( temp,""); |
1190 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1192 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1191 | port = remoteServerStr.right( divider - 1); | 1193 | port = remoteServerStr.right( divider - 1); |
1192 | bool ok; | 1194 | bool ok; |
1193 | PortSpinBox->setValue( port.toInt(&ok,10)); | 1195 | PortSpinBox->setValue( port.toInt(&ok,10)); |
1194 | 1196 | ||
1195 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); | 1197 | remoteServerStr = remoteServerStr.left(remoteServerStr.length()-divider); |
1196 | ServerComboBox->insertItem( remoteServerStr ); | 1198 | ServerComboBox->insertItem( remoteServerStr ); |
1197 | // cfg.setGroup(temp); | 1199 | // cfg.setGroup(temp); |
1198 | 1200 | ||
1199 | // remotePathStr = cfg.readEntry(remoteServer,""); | 1201 | // remotePathStr = cfg.readEntry(remoteServer,""); |
1200 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); | 1202 | // int divider = remoteServer.length() - remoteServer.find(":",0,TRUE); |
1201 | // port = remoteServer.right( divider+1); | 1203 | // port = remoteServer.right( divider+1); |
1202 | // PortSpinBox->setValue( port); | 1204 | // PortSpinBox->setValue( port); |
1203 | 1205 | ||
1204 | // remoteServer = remoteServer.left(divider - 1); | 1206 | // remoteServer = remoteServer.left(divider - 1); |
1205 | // remotePath->setText( remotePathStr); | 1207 | // remotePath->setText( remotePathStr); |
1206 | 1208 | ||
1207 | // username = cfg.readEntry(temp); | 1209 | // username = cfg.readEntry(temp); |
1208 | // UsernameComboBox->insertItem(username); | 1210 | // UsernameComboBox->insertItem(username); |
1209 | // password = cfg.readEntryCrypt(username,""); | 1211 | // password = cfg.readEntryCrypt(username,""); |
1210 | // PasswordEdit->setText(password); | 1212 | // PasswordEdit->setText(password); |
1211 | } | 1213 | } |
1212 | } | 1214 | } |
1213 | 1215 | ||
1214 | 1216 | ||
1215 | void OpieFtp::serverComboSelected(int index) | 1217 | void OpieFtp::serverComboSelected(int index) |
1216 | { | 1218 | { |
1217 | currentServerConfig = index; | 1219 | currentServerConfig = index; |
1218 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1220 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1219 | // remoteServerStr = ServerComboBox->text(index); | 1221 | // remoteServerStr = ServerComboBox->text(index); |
1220 | Config cfg("opieftp"); | 1222 | Config cfg("opieftp"); |
1221 | cfg.setGroup("Server"); | 1223 | cfg.setGroup("Server"); |
1222 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1224 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1223 | 1225 | ||
1224 | temp.setNum(index+1); | 1226 | temp.setNum(index+1); |
1225 | remoteServerStr = cfg.readEntry( temp,""); | 1227 | remoteServerStr = cfg.readEntry( temp,""); |
1226 | cfg.setGroup(temp); | 1228 | cfg.setGroup(temp); |
1227 | // qDebug(temp); | 1229 | // qDebug(temp); |
1228 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); | 1230 | int divider = remoteServerStr.length() - remoteServerStr.find(":",0,TRUE); |
1229 | port = remoteServerStr.right( divider - 1); | 1231 | port = remoteServerStr.right( divider - 1); |
1230 | bool ok; | 1232 | bool ok; |
1231 | int portInt = port.toInt(&ok,10); | 1233 | int portInt = port.toInt(&ok,10); |
1232 | if( portInt == 0) portInt = 21; | 1234 | if( portInt == 0) portInt = 21; |
1233 | 1235 | ||
1234 | PortSpinBox->setValue( portInt); | 1236 | PortSpinBox->setValue( portInt); |
1235 | 1237 | ||
1236 | remotePath->setText(cfg.readEntry("RemotePath", "/")); | 1238 | remotePath->setText(cfg.readEntry("RemotePath", "/")); |
1237 | 1239 | ||
1238 | username = cfg.readEntry("Username", "anonymous"); | 1240 | username = cfg.readEntry("Username", "anonymous"); |
1239 | UsernameComboBox->lineEdit()->setText(username); | 1241 | UsernameComboBox->lineEdit()->setText(username); |
1240 | 1242 | ||
1241 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); | 1243 | // qDebug("Password is "+cfg.readEntryCrypt(username, "me@opieftp.org")); |
1242 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); | 1244 | PasswordEdit->setText(cfg.readEntryCrypt(username, "me@opieftp.org")); |
1243 | 1245 | ||
1244 | cfg.setGroup("Server"); | 1246 | cfg.setGroup("Server"); |
1245 | temp.sprintf("%d",currentServerConfig); | 1247 | temp.sprintf("%d",currentServerConfig); |
1246 | cfg.writeEntry("currentServer", temp); | 1248 | cfg.writeEntry("currentServer", temp); |
1247 | update(); | 1249 | update(); |
1248 | } | 1250 | } |
1249 | // UsernameComboBox->lineEdit()->setText("root"); | 1251 | // UsernameComboBox->lineEdit()->setText("root"); |
1250 | // PasswordEdit->setText( tr( "" ) ); | 1252 | // PasswordEdit->setText( tr( "" ) ); |
1251 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); | 1253 | // ServerComboBox->lineEdit()->setText( tr( "192.168.129.201" ) ); |
1252 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); | 1254 | // remotePath->setText( currentRemoteDir = "/home/llornkcor/"); |
1253 | // PortSpinBox->setValue( 4242); | 1255 | // PortSpinBox->setValue( 4242); |
1254 | 1256 | ||
1255 | void OpieFtp::deleteServer() | 1257 | void OpieFtp::deleteServer() |
1256 | { | 1258 | { |
1257 | QString username, remoteServerStr, remotePathStr, password, port, temp; | 1259 | QString username, remoteServerStr, remotePathStr, password, port, temp; |
1258 | remoteServerStr = ServerComboBox->currentText( ); | 1260 | remoteServerStr = ServerComboBox->currentText( ); |
1259 | username = UsernameComboBox->currentText(); | 1261 | username = UsernameComboBox->currentText(); |
1260 | Config cfg("opieftp"); | 1262 | Config cfg("opieftp"); |
1261 | cfg.setGroup("Server"); | 1263 | cfg.setGroup("Server"); |
1262 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); | 1264 | int numberOfEntries = cfg.readNumEntry("numberOfEntries",0); |
1263 | for (int i = 0; i <= numberOfEntries; i++) { | 1265 | for (int i = 0; i <= numberOfEntries; i++) { |
1264 | temp.setNum(i+1); | 1266 | temp.setNum(i+1); |
1265 | cfg.setGroup("Server"); | 1267 | cfg.setGroup("Server"); |
1266 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 | 1268 | if( cfg.readEntry( temp,"").find( remoteServerStr,0,TRUE) != -1 |
1267 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 | 1269 | && cfg.readEntry(temp).find(username,0,TRUE) != -1 |