|
Lines 32-37
Link Here
|
| 32 |
#include "tdeglobal.h" |
32 |
#include "tdeglobal.h" |
| 33 |
#include "kiconloader.h" |
33 |
#include "kiconloader.h" |
| 34 |
#include "tdetempfile.h" |
34 |
#include "tdetempfile.h" |
|
|
35 |
#include <kstandarddirs.h> |
| 35 |
|
36 |
|
| 36 |
#include "tdehardwaredevices.h" |
37 |
#include "tdehardwaredevices.h" |
| 37 |
|
38 |
|
|
Lines 601-645
Link Here
|
| 601 |
|
602 |
|
| 602 |
TQString ret = mountPath(); |
603 |
TQString ret = mountPath(); |
| 603 |
|
604 |
|
|
|
605 |
// Device is already mounted |
| 604 |
if (!ret.isNull()) { |
606 |
if (!ret.isNull()) { |
| 605 |
return ret; |
607 |
return ret; |
| 606 |
} |
608 |
} |
| 607 |
|
609 |
|
| 608 |
// Create dummy password file |
610 |
TQString epath = getenv("PATH"); |
| 609 |
KTempFile passwordFile(TQString::null, "tmp", 0600); |
611 |
TQString path = TQString::fromLatin1("/sbin:/bin"); |
| 610 |
passwordFile.setAutoDelete(true); |
612 |
if (!epath.isEmpty()) { |
|
|
613 |
path += ":" + epath; |
| 614 |
} |
| 611 |
|
615 |
|
| 612 |
TQString optionString; |
616 |
TQString command; |
| 613 |
if (mountOptions["ro"] == "true") { |
617 |
TQString devNode = deviceNode(); |
| 614 |
optionString.append(" -r"); |
618 |
devNode.replace("'", "'\\''"); |
| 615 |
} |
619 |
mediaName.replace("'", "'\\''"); |
| 616 |
|
|
|
| 617 |
if (mountOptions["atime"] != "true") { |
| 618 |
optionString.append(" -A"); |
| 619 |
} |
| 620 |
|
| 621 |
if (mountOptions["utf8"] == "true") { |
| 622 |
optionString.append(" -c utf8"); |
| 623 |
} |
| 624 |
|
| 625 |
if (mountOptions["sync"] == "true") { |
| 626 |
optionString.append(" -s"); |
| 627 |
} |
| 628 |
|
620 |
|
| 629 |
if (mountOptions.contains("filesystem")) { |
621 |
// Use 'pmount' command, if available |
| 630 |
optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"])); |
622 |
TQString pmountProg = TDEGlobal::dirs()->findExe("pmount", path); |
|
|
623 |
|
| 624 |
if (!pmountProg.isEmpty()) { |
| 625 |
// Create dummy password file |
| 626 |
KTempFile passwordFile(TQString::null, "tmp", 0600); |
| 627 |
passwordFile.setAutoDelete(true); |
| 628 |
|
| 629 |
TQString optionString; |
| 630 |
if (mountOptions["ro"] == "true") { |
| 631 |
optionString.append(" -r"); |
| 632 |
} |
| 633 |
|
| 634 |
if (mountOptions["atime"] != "true") { |
| 635 |
optionString.append(" -A"); |
| 636 |
} |
| 637 |
|
| 638 |
if (mountOptions["utf8"] == "true") { |
| 639 |
optionString.append(" -c utf8"); |
| 640 |
} |
| 641 |
|
| 642 |
if (mountOptions["sync"] == "true") { |
| 643 |
optionString.append(" -s"); |
| 644 |
} |
| 645 |
|
| 646 |
if (mountOptions.contains("filesystem")) { |
| 647 |
optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"])); |
| 648 |
} |
| 649 |
|
| 650 |
if (mountOptions.contains("locale")) { |
| 651 |
optionString.append(TQString(" -c %1").arg(mountOptions["locale"])); |
| 652 |
} |
| 653 |
|
| 654 |
TQString passFileName = passwordFile.name(); |
| 655 |
passFileName.replace("'", "'\\''"); |
| 656 |
|
| 657 |
command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName); |
| 631 |
} |
658 |
} |
| 632 |
|
659 |
|
| 633 |
if (mountOptions.contains("locale")) { |
660 |
#ifdef WITH_UDISKS2 |
| 634 |
optionString.append(TQString(" -c %1").arg(mountOptions["locale"])); |
661 |
if(command.isEmpty()) { |
|
|
662 |
// Use 'udisksctl' command (from UDISKS2), if available |
| 663 |
TQString udisksctlProg = TDEGlobal::dirs()->findExe("udisksctl", path); |
| 664 |
if (!udisksctlProg.isEmpty()) { |
| 665 |
TQString optionString; |
| 666 |
|
| 667 |
// Sends the filesystem options to 'udisks' command |
| 668 |
optionString.append(TQString("-o rw")); |
| 669 |
|
| 670 |
if (mountOptions["ro"] == "true") { |
| 671 |
optionString.append(",ro"); |
| 672 |
} |
| 673 |
|
| 674 |
if (mountOptions["atime"] != "true") { |
| 675 |
optionString.append(",noatime"); |
| 676 |
} |
| 677 |
|
| 678 |
if (mountOptions["utf8"] == "true") { |
| 679 |
optionString.append(",iocharset=utf8"); |
| 680 |
} |
| 681 |
|
| 682 |
if (mountOptions["sync"] == "true") { |
| 683 |
optionString.append(",sync"); |
| 684 |
} |
| 685 |
|
| 686 |
if (mountOptions.contains("locale")) { |
| 687 |
optionString.append(TQString(",iocharset=%1").arg(mountOptions["locale"])); |
| 688 |
} |
| 689 |
|
| 690 |
if (mountOptions.contains("filesystem")) { |
| 691 |
optionString.append(TQString(" -t %1").arg(mountOptions["filesystem"])); |
| 692 |
} |
| 693 |
|
| 694 |
command = TQString("udisksctl mount -b '%1' %2 2>&1").arg(devNode).arg(optionString); |
| 695 |
} |
| 635 |
} |
696 |
} |
|
|
697 |
#endif // WITH_UDISKS2 |
| 636 |
|
698 |
|
| 637 |
TQString passFileName = passwordFile.name(); |
699 |
#ifdef WITH_UDISKS |
| 638 |
TQString devNode = deviceNode(); |
700 |
if(command.isEmpty()) { |
| 639 |
passFileName.replace("'", "'\\''"); |
701 |
// Use 'udisks' command (from UDISKS1), if available |
| 640 |
devNode.replace("'", "'\\''"); |
702 |
TQString udisksProg = TDEGlobal::dirs()->findExe("udisks", path); |
| 641 |
mediaName.replace("'", "'\\''"); |
703 |
if (!udisksProg.isEmpty()) { |
| 642 |
TQString command = TQString("pmount -p '%1' %2 '%3' '%4' 2>&1").arg(passFileName).arg(optionString).arg(devNode).arg(mediaName); |
704 |
TQString optionString; |
|
|
705 |
|
| 706 |
// Sends the filesystem options to 'udisks' command |
| 707 |
optionString.append(TQString("--mount-options rw")); |
| 708 |
|
| 709 |
if (mountOptions["ro"] == "true") { |
| 710 |
optionString.append(",ro"); |
| 711 |
} |
| 712 |
|
| 713 |
if (mountOptions["atime"] != "true") { |
| 714 |
optionString.append(",noatime"); |
| 715 |
} |
| 716 |
|
| 717 |
if (mountOptions["utf8"] == "true") { |
| 718 |
optionString.append(",iocharset=utf8"); |
| 719 |
} |
| 720 |
|
| 721 |
if (mountOptions["sync"] == "true") { |
| 722 |
optionString.append(",sync"); |
| 723 |
} |
| 724 |
|
| 725 |
if (mountOptions.contains("locale")) { |
| 726 |
optionString.append(TQString(",iocharset=%1").arg(mountOptions["locale"])); |
| 727 |
} |
| 728 |
|
| 729 |
if (mountOptions.contains("filesystem")) { |
| 730 |
optionString.append(TQString(" --mount-fstype %1").arg(mountOptions["filesystem"])); |
| 731 |
} |
| 732 |
|
| 733 |
command = TQString("udisks --mount '%1' %2 2>&1").arg(devNode).arg(optionString); |
| 734 |
} |
| 735 |
} |
| 736 |
#endif // WITH_UDISKS |
| 643 |
|
737 |
|
| 644 |
FILE *exepipe = popen(command.ascii(), "r"); |
738 |
FILE *exepipe = popen(command.ascii(), "r"); |
| 645 |
if (exepipe) { |
739 |
if (exepipe) { |
|
Lines 741-753
Link Here
|
| 741 |
} |
835 |
} |
| 742 |
|
836 |
|
| 743 |
TQString mountpoint = mountPath(); |
837 |
TQString mountpoint = mountPath(); |
|
|
838 |
TQString devNode = deviceNode(); |
| 744 |
|
839 |
|
| 745 |
if (mountpoint.isNull()) { |
840 |
if (mountpoint.isNull()) { |
| 746 |
return true; |
841 |
return true; |
| 747 |
} |
842 |
} |
| 748 |
|
843 |
|
| 749 |
mountpoint.replace("'", "'\\''"); |
844 |
mountpoint.replace("'", "'\\''"); |
| 750 |
TQString command = TQString("pumount '%1' 2>&1").arg(mountpoint); |
845 |
|
|
|
846 |
TQString epath = getenv("PATH"); |
| 847 |
TQString path = TQString::fromLatin1("/sbin:/bin"); |
| 848 |
if (!epath.isEmpty()) { |
| 849 |
path += ":" + epath; |
| 850 |
} |
| 851 |
|
| 852 |
TQString command; |
| 853 |
|
| 854 |
if(!(TDEGlobal::dirs()->findExe("pumount", path).isEmpty())) { |
| 855 |
command = TQString("pumount '%1' 2>&1").arg(mountpoint); |
| 856 |
#ifdef WITH_UDISKS2 |
| 857 |
} else if(!(TDEGlobal::dirs()->findExe("udisksctl", path).isEmpty())) { |
| 858 |
command = TQString("udisksctl unmount -b '%1' 2>&1").arg(devNode); |
| 859 |
#endif // WITH_UDISKS2 |
| 860 |
#ifdef WITH_UDISKS |
| 861 |
} else if(!(TDEGlobal::dirs()->findExe("udisks", path).isEmpty()) ){ |
| 862 |
command = TQString("udisks --unmount '%1' 2>&1").arg(devNode); |
| 863 |
#endif // WITH_UDISKS |
| 864 |
} |
| 865 |
|
| 751 |
FILE *exepipe = popen(command.ascii(), "r"); |
866 |
FILE *exepipe = popen(command.ascii(), "r"); |
| 752 |
if (exepipe) { |
867 |
if (exepipe) { |
| 753 |
TQString pmount_output; |
868 |
TQString pmount_output; |