Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 80324eb..ed280aa 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -563,201 +563,215 @@ bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | |||
563 | int read_fd=0; | 563 | int read_fd=0; |
564 | int write_fd=0; | 564 | int write_fd=0; |
565 | struct stat stat_buf; | 565 | struct stat stat_buf; |
566 | off_t offset = 0; | 566 | off_t offset = 0; |
567 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 567 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
568 | // owarn << "open failed" << oendl; | 568 | // owarn << "open failed" << oendl; |
569 | return success = false; | 569 | return success = false; |
570 | } | 570 | } |
571 | read_fd = srcFile.handle(); | 571 | read_fd = srcFile.handle(); |
572 | if(read_fd != -1) { | 572 | if(read_fd != -1) { |
573 | fstat (read_fd, &stat_buf); | 573 | fstat (read_fd, &stat_buf); |
574 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 574 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
575 | // owarn << "destfile open failed" << oendl; | 575 | // owarn << "destfile open failed" << oendl; |
576 | return success = false; | 576 | return success = false; |
577 | } | 577 | } |
578 | write_fd = destFile.handle(); | 578 | write_fd = destFile.handle(); |
579 | if(write_fd != -1) { | 579 | if(write_fd != -1) { |
580 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 580 | err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
581 | if( err == -1) { | 581 | if( err == -1) { |
582 | QString msg; | 582 | QString msg; |
583 | switch(err) { | 583 | switch(err) { |
584 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 584 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
585 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 585 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
586 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 586 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
587 | case EIO: msg = "Unspecified error while reading from in_fd."; | 587 | case EIO: msg = "Unspecified error while reading from in_fd."; |
588 | }; | 588 | }; |
589 | success = false; | 589 | success = false; |
590 | // owarn << msg << oendl; | 590 | // owarn << msg << oendl; |
591 | } | 591 | } |
592 | } else { | 592 | } else { |
593 | success = false; | 593 | success = false; |
594 | } | 594 | } |
595 | } else { | 595 | } else { |
596 | success = false; | 596 | success = false; |
597 | } | 597 | } |
598 | srcFile.close(); | 598 | srcFile.close(); |
599 | destFile.close(); | 599 | destFile.close(); |
600 | // Set file permissions | 600 | // Set file permissions |
601 | if( stat( QFile::encodeName(src), &status ) == 0 ) { | 601 | if( stat( QFile::encodeName(src), &status ) == 0 ) { |
602 | chmod( QFile::encodeName(dest), status.st_mode ); | 602 | chmod( QFile::encodeName(dest), status.st_mode ); |
603 | } | 603 | } |
604 | 604 | ||
605 | return success; | 605 | return success; |
606 | } | 606 | } |
607 | 607 | ||
608 | void AdvancedFm::runCommand() { | 608 | void AdvancedFm::runCommand() { |
609 | if( !CurrentView()->currentItem()) return; | 609 | if( !CurrentView()->currentItem()) return; |
610 | QDir *thisDir = CurrentDir(); | 610 | QDir *thisDir = CurrentDir(); |
611 | 611 | ||
612 | QString curFile; | 612 | QString curFile; |
613 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 613 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
614 | 614 | ||
615 | InputDialog *fileDlg; | 615 | InputDialog *fileDlg; |
616 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 616 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
617 | fileDlg->setInputText(curFile); | 617 | fileDlg->setInputText(curFile); |
618 | fileDlg->exec(); | 618 | fileDlg->exec(); |
619 | //QString command; | 619 | //QString command; |
620 | 620 | ||
621 | if( fileDlg->result() == 1 ) { | 621 | if( fileDlg->result() == 1 ) { |
622 | // odebug << fileDlg->LineEdit1->text() << oendl; | 622 | // odebug << fileDlg->LineEdit1->text() << oendl; |
623 | QStringList command; | 623 | QStringList command; |
624 | 624 | ||
625 | command << "/bin/sh"; | 625 | command << "/bin/sh"; |
626 | command << "-c"; | 626 | command << "-c"; |
627 | command << fileDlg->LineEdit1->text(); | 627 | command << fileDlg->LineEdit1->text(); |
628 | Output *outDlg; | 628 | Output *outDlg; |
629 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 629 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
630 | QPEApplication::execDialog( outDlg ); | 630 | QPEApplication::execDialog( outDlg ); |
631 | qApp->processEvents(); | 631 | qApp->processEvents(); |
632 | 632 | ||
633 | } | 633 | } |
634 | } | 634 | } |
635 | 635 | ||
636 | void AdvancedFm::runCommandStd() { | 636 | void AdvancedFm::runCommandStd() { |
637 | if( !CurrentView()->currentItem()) return; | 637 | if( !CurrentView()->currentItem()) return; |
638 | QString curFile; | 638 | QString curFile; |
639 | QDir *thisDir = CurrentDir(); | 639 | QDir *thisDir = CurrentDir(); |
640 | QListView *thisView = CurrentView(); | 640 | QListView *thisView = CurrentView(); |
641 | if( thisView->currentItem()) | 641 | if( thisView->currentItem()) |
642 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 642 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
643 | 643 | ||
644 | InputDialog *fileDlg; | 644 | InputDialog *fileDlg; |
645 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 645 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
646 | fileDlg->setInputText(curFile); | 646 | fileDlg->setInputText(curFile); |
647 | fileDlg->exec(); | 647 | fileDlg->exec(); |
648 | 648 | ||
649 | if( fileDlg->result() == 1 ) { | 649 | if( fileDlg->result() == 1 ) { |
650 | qApp->processEvents(); | 650 | qApp->processEvents(); |
651 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 651 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
652 | } | 652 | } |
653 | } | 653 | } |
654 | 654 | ||
655 | void AdvancedFm::fileStatus() { | 655 | void AdvancedFm::fileStatus() { |
656 | if( !CurrentView()->currentItem()) return; | 656 | if( !CurrentView()->currentItem()) return; |
657 | QString curFile; | 657 | QString curFile; |
658 | curFile = CurrentView()->currentItem()->text(0); | 658 | curFile = CurrentView()->currentItem()->text(0); |
659 | 659 | if(QFileInfo("/usr/bin/stat").exists()) { | |
660 | QStringList command; | 660 | QStringList command; |
661 | command << "/bin/sh"; | 661 | command << "/bin/sh"; |
662 | command << "-c"; | 662 | command << "-c"; |
663 | command << "stat -l "+ curFile; | 663 | command << "stat -l "+ curFile; |
664 | |||
665 | Output *outDlg; | 664 | Output *outDlg; |
666 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 665 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
667 | QPEApplication::execDialog( outDlg ); | 666 | QPEApplication::execDialog( outDlg ); |
667 | } else { | ||
668 | /* struct stat buf; | ||
669 | stat( curFile.local8bit(), &buf); | ||
670 | |||
671 | st_dev dev; | ||
672 | st_uid uid; | ||
673 | st_gid gid; | ||
674 | st_size size; | ||
675 | st_atime atime; | ||
676 | st_mtime mtime; | ||
677 | st_ctime ctime; | ||
678 | st_mode mode; | ||
679 | */ | ||
680 | } | ||
681 | |||
668 | qApp->processEvents(); | 682 | qApp->processEvents(); |
669 | } | 683 | } |
670 | 684 | ||
671 | 685 | ||
672 | void AdvancedFm::mkDir() { | 686 | void AdvancedFm::mkDir() { |
673 | makeDir(); | 687 | makeDir(); |
674 | } | 688 | } |
675 | 689 | ||
676 | void AdvancedFm::rn() { | 690 | void AdvancedFm::rn() { |
677 | renameIt(); | 691 | renameIt(); |
678 | } | 692 | } |
679 | 693 | ||
680 | void AdvancedFm::del() { | 694 | void AdvancedFm::del() { |
681 | doDelete(); | 695 | doDelete(); |
682 | } | 696 | } |
683 | 697 | ||
684 | void AdvancedFm::mkSym() { | 698 | void AdvancedFm::mkSym() { |
685 | QString cmd; | 699 | QString cmd; |
686 | QStringList curFileList = getPath(); | 700 | QStringList curFileList = getPath(); |
687 | if( curFileList.count() > 0) { | 701 | if( curFileList.count() > 0) { |
688 | QDir *thisDir = CurrentDir(); | 702 | QDir *thisDir = CurrentDir(); |
689 | QDir * thatDir = OtherDir(); | 703 | QDir * thatDir = OtherDir(); |
690 | 704 | ||
691 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 705 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
692 | 706 | ||
693 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 707 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
694 | if(destName.right(1) == "/") { | 708 | if(destName.right(1) == "/") { |
695 | destName = destName.left( destName.length() -1); | 709 | destName = destName.left( destName.length() -1); |
696 | } | 710 | } |
697 | 711 | ||
698 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 712 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
699 | 713 | ||
700 | if( curFile.right(1) == "/") { | 714 | if( curFile.right(1) == "/") { |
701 | curFile = curFile.left( curFile.length() -1); | 715 | curFile = curFile.left( curFile.length() -1); |
702 | } | 716 | } |
703 | 717 | ||
704 | cmd = "ln -s "+curFile+" "+destName; | 718 | cmd = "ln -s "+curFile+" "+destName; |
705 | // odebug << cmd << oendl; | 719 | // odebug << cmd << oendl; |
706 | startProcess( (const QString)cmd ); | 720 | startProcess( (const QString)cmd ); |
707 | } | 721 | } |
708 | rePopulate(); | 722 | rePopulate(); |
709 | setOtherTabCurrent(); | 723 | setOtherTabCurrent(); |
710 | } | 724 | } |
711 | } | 725 | } |
712 | 726 | ||
713 | void AdvancedFm::doBeam() { | 727 | void AdvancedFm::doBeam() { |
714 | Ir ir; | 728 | Ir ir; |
715 | if(!ir.supported()) { | 729 | if(!ir.supported()) { |
716 | } else { | 730 | } else { |
717 | QStringList curFileList = getPath(); | 731 | QStringList curFileList = getPath(); |
718 | if( curFileList.count() > 0) { | 732 | if( curFileList.count() > 0) { |
719 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 733 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
720 | QString curFile = (*it); | 734 | QString curFile = (*it); |
721 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 735 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
722 | if( curFilePath.right(1) == "/") { | 736 | if( curFilePath.right(1) == "/") { |
723 | curFilePath = curFilePath.left( curFilePath.length() -1); | 737 | curFilePath = curFilePath.left( curFilePath.length() -1); |
724 | } | 738 | } |
725 | Ir *file = new Ir(this, "IR"); | 739 | Ir *file = new Ir(this, "IR"); |
726 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); | 740 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished(Ir*))); |
727 | file->send( curFilePath, curFile ); | 741 | file->send( curFilePath, curFile ); |
728 | } | 742 | } |
729 | } | 743 | } |
730 | } | 744 | } |
731 | } | 745 | } |
732 | 746 | ||
733 | void AdvancedFm::fileBeamFinished( Ir *) { | 747 | void AdvancedFm::fileBeamFinished( Ir *) { |
734 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 748 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
735 | } | 749 | } |
736 | 750 | ||
737 | void AdvancedFm::selectAll() { | 751 | void AdvancedFm::selectAll() { |
738 | QListView *thisView = CurrentView(); | 752 | QListView *thisView = CurrentView(); |
739 | thisView->selectAll(true); | 753 | thisView->selectAll(true); |
740 | thisView->setSelected( thisView->firstChild(),false); | 754 | thisView->setSelected( thisView->firstChild(),false); |
741 | } | 755 | } |
742 | 756 | ||
743 | void AdvancedFm::startProcess(const QString & cmd) { | 757 | void AdvancedFm::startProcess(const QString & cmd) { |
744 | QStringList command; | 758 | QStringList command; |
745 | OProcess *process; | 759 | OProcess *process; |
746 | process = new OProcess(); | 760 | process = new OProcess(); |
747 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); | 761 | connect(process,SIGNAL(processExited(Opie::Core::OProcess*)),this,SLOT(processEnded(Opie::Core::OProcess*))); |
748 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); | 762 | connect(process,SIGNAL(receivedStderr(Opie::Core::OProcess*,char*,int)),this,SLOT(oprocessStderr(Opie::Core::OProcess*,char*,int))); |
749 | 763 | ||
750 | command << "/bin/sh"; | 764 | command << "/bin/sh"; |
751 | command << "-c"; | 765 | command << "-c"; |
752 | command << cmd.latin1(); | 766 | command << cmd.latin1(); |
753 | *process << command; | 767 | *process << command; |
754 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 768 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
755 | odebug << "could not start process" << oendl; | 769 | odebug << "could not start process" << oendl; |
756 | } | 770 | } |
757 | 771 | ||
758 | void AdvancedFm::processEnded(OProcess *) { | 772 | void AdvancedFm::processEnded(OProcess *) { |
759 | rePopulate(); | 773 | rePopulate(); |
760 | } | 774 | } |
761 | 775 | ||
762 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 776 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
763 | // owarn << "received stderrt " << buflen << " bytes" << oendl; | 777 | // owarn << "received stderrt " << buflen << " bytes" << oendl; |