Diffstat (limited to 'noncore/net/opieftp/opieftp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opieftp/opieftp.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/noncore/net/opieftp/opieftp.cpp b/noncore/net/opieftp/opieftp.cpp index a3b29a1..814d706 100644 --- a/noncore/net/opieftp/opieftp.cpp +++ b/noncore/net/opieftp/opieftp.cpp | |||
@@ -442,137 +442,137 @@ bool OpieFtp::remoteChDir(const QString &dir) | |||
442 | { | 442 | { |
443 | QCopEnvelope ( "QPE/System", "busy()" ); | 443 | QCopEnvelope ( "QPE/System", "busy()" ); |
444 | if (!FtpChdir( dir.latin1(), conn )) { | 444 | if (!FtpChdir( dir.latin1(), conn )) { |
445 | QString msg; | 445 | QString msg; |
446 | msg.sprintf("Unable to change directories\n"+dir+"\n%s",FtpLastResponse(conn)); | 446 | msg.sprintf("Unable to change directories\n"+dir+"\n%s",FtpLastResponse(conn)); |
447 | msg.replace(QRegExp(":"),"\n"); | 447 | msg.replace(QRegExp(":"),"\n"); |
448 | QMessageBox::message("Note",msg); | 448 | QMessageBox::message("Note",msg); |
449 | qDebug(msg); | 449 | qDebug(msg); |
450 | // FtpQuit(conn); | 450 | // FtpQuit(conn); |
451 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 451 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
452 | return FALSE; | 452 | return FALSE; |
453 | } | 453 | } |
454 | QCopEnvelope ( "QPE/System", "notBusy()" ); | 454 | QCopEnvelope ( "QPE/System", "notBusy()" ); |
455 | return TRUE; | 455 | return TRUE; |
456 | } | 456 | } |
457 | 457 | ||
458 | void OpieFtp::populateLocalView() | 458 | void OpieFtp::populateLocalView() |
459 | { | 459 | { |
460 | Local_View->clear(); | 460 | Local_View->clear(); |
461 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 461 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
462 | currentDir.setMatchAllDirs(TRUE); | 462 | currentDir.setMatchAllDirs(TRUE); |
463 | currentDir.setNameFilter(filterStr); | 463 | currentDir.setNameFilter(filterStr); |
464 | QString fileL, fileS, fileDate; | 464 | QString fileL, fileS, fileDate; |
465 | bool isDir=FALSE; | 465 | bool isDir=FALSE; |
466 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 466 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
467 | QFileInfoListIterator it(*list); | 467 | QFileInfoListIterator it(*list); |
468 | QFileInfo *fi; | 468 | QFileInfo *fi; |
469 | while ( (fi=it.current()) ) { | 469 | while ( (fi=it.current()) ) { |
470 | if (fi->isSymLink() ){ | 470 | if (fi->isSymLink() ){ |
471 | QString symLink=fi->readLink(); | 471 | QString symLink=fi->readLink(); |
472 | // qDebug("Symlink detected "+symLink); | 472 | // qDebug("Symlink detected "+symLink); |
473 | QFileInfo sym( symLink); | 473 | QFileInfo sym( symLink); |
474 | fileS.sprintf( "%10li", sym.size() ); | 474 | fileS.sprintf( "%10li", sym.size() ); |
475 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 475 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
476 | fileDate = sym.lastModified().toString(); | 476 | fileDate = sym.lastModified().toString(); |
477 | } else { | 477 | } else { |
478 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 478 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
479 | fileS.sprintf( "%10li", fi->size() ); | 479 | fileS.sprintf( "%10li", fi->size() ); |
480 | fileL.sprintf( "%s",fi->fileName().data() ); | 480 | fileL.sprintf( "%s",fi->fileName().data() ); |
481 | fileDate= fi->lastModified().toString(); | 481 | fileDate= fi->lastModified().toString(); |
482 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 482 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
483 | fileL+="/"; | 483 | fileL+="/"; |
484 | isDir=TRUE; | 484 | isDir=TRUE; |
485 | // qDebug( fileL); | 485 | // qDebug( fileL); |
486 | } | 486 | } |
487 | } | 487 | } |
488 | if(fileL !="./") { | 488 | if(fileL !="./") { |
489 | item = new QListViewItem( Local_View,fileL,fileS, fileDate); | 489 | item = new QListViewItem( Local_View,fileL,fileS, fileDate); |
490 | if(isDir) | 490 | if(isDir || fileL.find("/",0,TRUE) != -1) |
491 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 491 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
492 | else | 492 | else |
493 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 493 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
494 | } | 494 | } |
495 | isDir=FALSE; | 495 | isDir=FALSE; |
496 | ++it; | 496 | ++it; |
497 | } | 497 | } |
498 | Local_View->setSorting( 3,FALSE); | 498 | Local_View->setSorting( 3,FALSE); |
499 | currentPathEdit->setText( currentDir.canonicalPath() ); | 499 | currentPathEdit->setText( currentDir.canonicalPath() ); |
500 | } | 500 | } |
501 | 501 | ||
502 | bool OpieFtp::populateRemoteView( ) | 502 | bool OpieFtp::populateRemoteView( ) |
503 | { | 503 | { |
504 | // qDebug("populate remoteview"); | 504 | // qDebug("populate remoteview"); |
505 | QString sfile=QDir::homeDirPath(); | 505 | QString sfile=QDir::homeDirPath(); |
506 | if(sfile.right(1) != "/") | 506 | if(sfile.right(1) != "/") |
507 | sfile+="/._temp"; | 507 | sfile+="/._temp"; |
508 | else | 508 | else |
509 | sfile+="._temp"; | 509 | sfile+="._temp"; |
510 | QFile file( sfile); | 510 | QFile file( sfile); |
511 | Remote_View->clear(); | 511 | Remote_View->clear(); |
512 | QString s, File_Name; | 512 | QString s, File_Name; |
513 | QListViewItem *itemDir=NULL, *itemFile=NULL; | 513 | QListViewItem *itemDir=NULL, *itemFile=NULL; |
514 | QString fileL, fileS, fileDate; | 514 | QString fileL, fileS, fileDate; |
515 | if ( file.open(IO_ReadOnly)) { | 515 | if ( file.open(IO_ReadOnly)) { |
516 | QTextStream t( &file ); // use a text stream | 516 | QTextStream t( &file ); // use a text stream |
517 | while ( !t.eof()) { | 517 | while ( !t.eof()) { |
518 | s = t.readLine(); | 518 | s = t.readLine(); |
519 | fileL = s.right(s.length()-55); | 519 | fileL = s.right(s.length()-55); |
520 | fileL = fileL.stripWhiteSpace(); | 520 | fileL = fileL.stripWhiteSpace(); |
521 | if(s.left(1) == "d") | 521 | if(s.left(1) == "d") |
522 | fileL = fileL+"/"; | 522 | fileL = fileL+"/"; |
523 | // fileL = "/"+fileL+"/"; | 523 | // fileL = "/"+fileL+"/"; |
524 | fileS = s.mid( 30, 42-30); | 524 | fileS = s.mid( 30, 42-30); |
525 | fileS = fileS.stripWhiteSpace(); | 525 | fileS = fileS.stripWhiteSpace(); |
526 | fileDate = s.mid( 42, 55-42); | 526 | fileDate = s.mid( 42, 55-42); |
527 | fileDate = fileDate.stripWhiteSpace(); | 527 | fileDate = fileDate.stripWhiteSpace(); |
528 | if(fileL.find("total",0,TRUE) == -1) { | 528 | if(fileL.find("total",0,TRUE) == -1) { |
529 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate); | 529 | QListViewItem * item = new QListViewItem( Remote_View, fileL, fileS, fileDate); |
530 | if(s.left(1) == "d") { | 530 | if(s.left(1) == "d" || fileL.find("/",0,TRUE) != -1) { |
531 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); | 531 | item->setPixmap( 0, Resource::loadPixmap( "folder" )); |
532 | if(itemDir) | 532 | if(itemDir) |
533 | item->moveItem(itemDir); | 533 | item->moveItem(itemDir); |
534 | itemDir=item; | 534 | itemDir=item; |
535 | } else { | 535 | } else { |
536 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); | 536 | item->setPixmap( 0, Resource::loadPixmap( "fileopen" )); |
537 | if(itemFile) | 537 | if(itemFile) |
538 | item->moveItem(itemFile); | 538 | item->moveItem(itemFile); |
539 | itemFile=item; | 539 | itemFile=item; |
540 | } | 540 | } |
541 | } | 541 | } |
542 | } | 542 | } |
543 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); | 543 | QListViewItem * item1 = new QListViewItem( Remote_View, "../"); |
544 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); | 544 | item1->setPixmap( 0, Resource::loadPixmap( "folder" )); |
545 | file.close(); | 545 | file.close(); |
546 | if( file.exists()) | 546 | if( file.exists()) |
547 | file. remove(); | 547 | file. remove(); |
548 | } else | 548 | } else |
549 | qDebug("temp file not opened successfullly "+sfile); | 549 | qDebug("temp file not opened successfullly "+sfile); |
550 | Remote_View->setSorting( 4,TRUE); | 550 | Remote_View->setSorting( 4,TRUE); |
551 | 551 | ||
552 | return true; | 552 | return true; |
553 | } | 553 | } |
554 | 554 | ||
555 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) | 555 | void OpieFtp::remoteListClicked(QListViewItem *selectedItem) |
556 | { | 556 | { |
557 | QCopEnvelope ( "QPE/System", "busy()" ); | 557 | QCopEnvelope ( "QPE/System", "busy()" ); |
558 | QString oldRemoteCurrentDir = currentRemoteDir; | 558 | QString oldRemoteCurrentDir = currentRemoteDir; |
559 | QString strItem=selectedItem->text(0); | 559 | QString strItem=selectedItem->text(0); |
560 | strItem=strItem.simplifyWhiteSpace(); | 560 | strItem=strItem.simplifyWhiteSpace(); |
561 | if(strItem == "../") { // the user wants to go ^ | 561 | if(strItem == "../") { // the user wants to go ^ |
562 | if( FtpCDUp( conn) == 0) { | 562 | if( FtpCDUp( conn) == 0) { |
563 | QString msg; | 563 | QString msg; |
564 | msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn)); | 564 | msg.sprintf("Unable to cd up\n%s",FtpLastResponse(conn)); |
565 | msg.replace(QRegExp(":"),"\n"); | 565 | msg.replace(QRegExp(":"),"\n"); |
566 | QMessageBox::message("Note",msg); | 566 | QMessageBox::message("Note",msg); |
567 | qDebug(msg); | 567 | qDebug(msg); |
568 | } | 568 | } |
569 | char path[256]; | 569 | char path[256]; |
570 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string | 570 | if( FtpPwd( path,sizeof(path),conn) == 0) { //this is easier than fudging the string |
571 | QString msg; | 571 | QString msg; |
572 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); | 572 | msg.sprintf("Unable to get working dir\n%s",FtpLastResponse(conn)); |
573 | msg.replace(QRegExp(":"),"\n"); | 573 | msg.replace(QRegExp(":"),"\n"); |
574 | QMessageBox::message("Note",msg); | 574 | QMessageBox::message("Note",msg); |
575 | qDebug(msg); | 575 | qDebug(msg); |
576 | } | 576 | } |
577 | currentRemoteDir=path; | 577 | currentRemoteDir=path; |
578 | } else { | 578 | } else { |
@@ -650,113 +650,113 @@ void OpieFtp::doLocalCd() | |||
650 | void OpieFtp:: doRemoteCd() | 650 | void OpieFtp:: doRemoteCd() |
651 | { | 651 | { |
652 | remoteListClicked( Remote_View->currentItem()); | 652 | remoteListClicked( Remote_View->currentItem()); |
653 | 653 | ||
654 | } | 654 | } |
655 | 655 | ||
656 | void OpieFtp::showHidden() | 656 | void OpieFtp::showHidden() |
657 | { | 657 | { |
658 | if (!b) { | 658 | if (!b) { |
659 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 659 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
660 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); | 660 | localMenu->setItemChecked(localMenu->idAt(0),TRUE); |
661 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 661 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
662 | b=TRUE; | 662 | b=TRUE; |
663 | 663 | ||
664 | } else { | 664 | } else { |
665 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 665 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
666 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); | 666 | localMenu->setItemChecked(localMenu->idAt(0),FALSE); |
667 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 667 | // currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
668 | b=FALSE; | 668 | b=FALSE; |
669 | } | 669 | } |
670 | populateLocalView(); | 670 | populateLocalView(); |
671 | } | 671 | } |
672 | 672 | ||
673 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 673 | void OpieFtp::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
674 | { | 674 | { |
675 | switch (mouse) { | 675 | switch (mouse) { |
676 | case 1: | 676 | case 1: |
677 | break; | 677 | break; |
678 | case 2: | 678 | case 2: |
679 | showLocalMenu(item); | 679 | showLocalMenu(item); |
680 | break; | 680 | break; |
681 | }; | 681 | }; |
682 | } | 682 | } |
683 | 683 | ||
684 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 684 | void OpieFtp::RemoteListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
685 | { | 685 | { |
686 | switch (mouse) { | 686 | switch (mouse) { |
687 | case 1: | 687 | case 1: |
688 | break; | 688 | break; |
689 | case 2: | 689 | case 2: |
690 | showRemoteMenu(item); | 690 | showRemoteMenu(item); |
691 | break; | 691 | break; |
692 | }; | 692 | }; |
693 | } | 693 | } |
694 | 694 | ||
695 | void OpieFtp::showRemoteMenu(QListViewItem * item) | 695 | void OpieFtp::showRemoteMenu(QListViewItem * item) |
696 | { | 696 | { |
697 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 697 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
698 | if(item->text(0).right(1) == "/") | 698 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE)) |
699 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); | 699 | m.insertItem( tr( "Change Directory" ), this, SLOT( doRemoteCd() )); |
700 | else | 700 | else |
701 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); | 701 | m.insertItem( tr( "Download" ), this, SLOT( remoteDownload() )); |
702 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); | 702 | m.insertItem( tr( "Make Directory" ), this, SLOT( remoteMakDir() )); |
703 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); | 703 | m.insertItem( tr( "Rename" ), this, SLOT( remoteRename() )); |
704 | m.insertSeparator(); | 704 | m.insertSeparator(); |
705 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); | 705 | m.insertItem( tr( "Delete" ), this, SLOT( remoteDelete() )); |
706 | m.exec( QCursor::pos() ); | 706 | m.exec( QCursor::pos() ); |
707 | } | 707 | } |
708 | 708 | ||
709 | void OpieFtp::showLocalMenu(QListViewItem * item) | 709 | void OpieFtp::showLocalMenu(QListViewItem * item) |
710 | { | 710 | { |
711 | QPopupMenu m; | 711 | QPopupMenu m; |
712 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); | 712 | m.insertItem( tr( "Show Hidden Files" ), this, SLOT( showHidden() )); |
713 | m.insertSeparator(); | 713 | m.insertSeparator(); |
714 | if(item->text(0).right(1) == "/") | 714 | if( /*item->text(0).right(1) == "/" ||*/ item->text(0).find("/",0,TRUE)) |
715 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); | 715 | m.insertItem( tr( "Change Directory" ), this, SLOT( doLocalCd() )); |
716 | else | 716 | else |
717 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); | 717 | m.insertItem( tr( "Upload" ), this, SLOT( localUpload() )); |
718 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); | 718 | m.insertItem( tr( "Make Directory" ), this, SLOT( localMakDir() )); |
719 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 719 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
720 | m.insertSeparator(); | 720 | m.insertSeparator(); |
721 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 721 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
722 | m.setCheckable(TRUE); | 722 | m.setCheckable(TRUE); |
723 | if (b) | 723 | if (b) |
724 | m.setItemChecked(m.idAt(0),TRUE); | 724 | m.setItemChecked(m.idAt(0),TRUE); |
725 | else | 725 | else |
726 | m.setItemChecked(m.idAt(0),FALSE); | 726 | m.setItemChecked(m.idAt(0),FALSE); |
727 | 727 | ||
728 | m.exec( QCursor::pos() ); | 728 | m.exec( QCursor::pos() ); |
729 | } | 729 | } |
730 | 730 | ||
731 | void OpieFtp::localMakDir() | 731 | void OpieFtp::localMakDir() |
732 | { | 732 | { |
733 | InputDialog *fileDlg; | 733 | InputDialog *fileDlg; |
734 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 734 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
735 | fileDlg->exec(); | 735 | fileDlg->exec(); |
736 | if( fileDlg->result() == 1 ) { | 736 | if( fileDlg->result() == 1 ) { |
737 | QString filename = fileDlg->LineEdit1->text(); | 737 | QString filename = fileDlg->LineEdit1->text(); |
738 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 738 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
739 | } | 739 | } |
740 | populateLocalView(); | 740 | populateLocalView(); |
741 | } | 741 | } |
742 | 742 | ||
743 | void OpieFtp::localDelete() | 743 | void OpieFtp::localDelete() |
744 | { | 744 | { |
745 | QString f = Local_View->currentItem()->text(0); | 745 | QString f = Local_View->currentItem()->text(0); |
746 | if(QDir(f).exists() ) { | 746 | if(QDir(f).exists() ) { |
747 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | 747 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
748 | " ?\nIt must be empty","Yes","No",0,0,1) ) { | 748 | " ?\nIt must be empty","Yes","No",0,0,1) ) { |
749 | case 0: { | 749 | case 0: { |
750 | f=currentDir.canonicalPath()+"/"+f; | 750 | f=currentDir.canonicalPath()+"/"+f; |
751 | QString cmd="rmdir "+f; | 751 | QString cmd="rmdir "+f; |
752 | system( cmd.latin1()); | 752 | system( cmd.latin1()); |
753 | populateLocalView(); | 753 | populateLocalView(); |
754 | } | 754 | } |
755 | break; | 755 | break; |
756 | case 1: | 756 | case 1: |
757 | // exit | 757 | // exit |
758 | break; | 758 | break; |
759 | }; | 759 | }; |
760 | 760 | ||
761 | } else { | 761 | } else { |
762 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | 762 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |