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