diff options
author | Thierry Vignaud <tv@mageia.org> | 2012-10-01 16:17:07 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2012-10-01 16:17:07 +0000 |
commit | 81b65921e06b0ecffc4cfabc3d87973d04515486 (patch) | |
tree | 9559b1e94936ece8f639a8bb31500202acfc23f0 | |
parent | a19ee1313d2e05bb0d334ef2c5912bf98489ea31 (diff) | |
download | perl-Hal-Cdroms-81b65921e06b0ecffc4cfabc3d87973d04515486.tar perl-Hal-Cdroms-81b65921e06b0ecffc4cfabc3d87973d04515486.tar.gz perl-Hal-Cdroms-81b65921e06b0ecffc4cfabc3d87973d04515486.tar.bz2 perl-Hal-Cdroms-81b65921e06b0ecffc4cfabc3d87973d04515486.tar.xz perl-Hal-Cdroms-81b65921e06b0ecffc4cfabc3d87973d04515486.zip |
rename 'hal_path' as 'udisks_path' since we no longuer use Hal
-rw-r--r-- | lib/Hal/Cdroms.pm | 108 |
1 files changed, 54 insertions, 54 deletions
diff --git a/lib/Hal/Cdroms.pm b/lib/Hal/Cdroms.pm index 17fbc9e..b171e5a 100644 --- a/lib/Hal/Cdroms.pm +++ b/lib/Hal/Cdroms.pm @@ -28,14 +28,14 @@ Hal::Cdroms - access cdroms through HAL and D-Bus my $cdroms = Hal::Cdroms->new; - foreach my $hal_path ($cdroms->list) { - my $m = $cdroms->get_mount_point($hal_path); - print "$hal_path ", $m ? "is mounted in $m" : "is not mounted", "\n"; + foreach my $udisks_path ($cdroms->list) { + my $m = $cdroms->get_mount_point($udisks_path); + print "$udisks_path ", $m ? "is mounted in $m" : "is not mounted", "\n"; } - my $hal_path = $cdroms->wait_for_insert; - my $m = $cdroms->mount($hal_path); - print "$hal_path is now mounted in $m\n"; + my $udisks_path = $cdroms->wait_for_insert; + my $m = $cdroms->mount($udisks_path); + print "$udisks_path is now mounted in $m\n"; =head1 DESCRIPTION @@ -66,7 +66,7 @@ sub new { =head2 $cdroms->list -Returns the list of C<hal_path> of the cdroms (mounted or not). +Returns the list of C<udisks_path> of the cdroms (mounted or not). =cut @@ -80,25 +80,25 @@ sub list { grep { _GetProperty(_get_device($o, $_), 'DeviceIsOpticalDisc') } @{$manager->EnumerateDevices}; } -=head2 $cdroms->get_mount_point($hal_path) +=head2 $cdroms->get_mount_point($udisks_path) -Return the mount point associated to the C<hal_path>, or undef it is not mounted. +Return the mount point associated to the C<udisks_path>, or undef it is not mounted. =cut sub _get_udisks_device { - my ($o, $hal_path) = @_; - $o->{service}->get_object($hal_path, "$dn.Device"); + my ($o, $udisks_path) = @_; + $o->{service}->get_object($udisks_path, "$dn.Device"); } sub _get_device { - my ($o, $hal_path) = @_; - $o->{service}->get_object($hal_path, 'org.freedesktop.DBus.Properties'); + my ($o, $udisks_path) = @_; + $o->{service}->get_object($udisks_path, 'org.freedesktop.DBus.Properties'); } sub _get_volume { - my ($o, $hal_path) = @_; - $o->{service}->get_object($hal_path, "$dn.Device.Volume"); + my ($o, $udisks_path) = @_; + $o->{service}->get_object($udisks_path, "$dn.Device.Volume"); } sub _GetProperty { @@ -107,9 +107,9 @@ sub _GetProperty { } sub get_mount_point { - my ($o, $hal_path) = @_; + my ($o, $udisks_path) = @_; - my $device = _get_device($o, $hal_path); + my $device = _get_device($o, $udisks_path); eval { _GetProperty($device, 'DeviceIsMounted') && @{_GetProperty($device, 'DeviceMountPaths')}[0] }; } @@ -125,60 +125,60 @@ sub _try { } } -=head2 $cdroms->ensure_mounted($hal_path) +=head2 $cdroms->ensure_mounted($udisks_path) -Mount the C<hal_path> if not already mounted. -Return the mount point associated to the C<hal_path>, or undef it cannot be mounted successfully (see $cdroms->{error}). +Mount the C<udisks_path> if not already mounted. +Return the mount point associated to the C<udisks_path>, or undef it cannot be mounted successfully (see $cdroms->{error}). =cut sub ensure_mounted { - my ($o, $hal_path) = @_; + my ($o, $udisks_path) = @_; - $o->get_mount_point($hal_path) # check if it is already mounted - || $o->mount($hal_path) # otherwise try to mount - || $o->get_mount_point($hal_path); # checking wether a volume manager did it for us + $o->get_mount_point($udisks_path) # check if it is already mounted + || $o->mount($udisks_path) # otherwise try to mount + || $o->get_mount_point($udisks_path); # checking wether a volume manager did it for us } -=head2 $cdroms->mount_through_hal($hal_path) +=head2 $cdroms->mount_through_hal($udisks_path) -Mount the C<hal_path> through HAL -Return the mount point associated to the C<hal_path>, or undef it cannot be mounted successfully (see $cdroms->{error}). +Mount the C<udisks_path> through HAL +Return the mount point associated to the C<udisks_path>, or undef it cannot be mounted successfully (see $cdroms->{error}). If the cdrom is listed in fstab, HAL will refuse to mount it. =cut sub mount_hal { - my ($o, $hal_path) = @_; + my ($o, $udisks_path) = @_; - my $device = _get_udisks_device($o, $hal_path); + my $device = _get_udisks_device($o, $udisks_path); my $mountpoint; _try($o, sub { $mountpoint = $device->FilesystemMount(undef, []) }) or return; $mountpoint; } -=head2 $cdroms->mount($hal_path) +=head2 $cdroms->mount($udisks_path) -Mount the C<hal_path> through HAL or fallback to plain mount(8). -Return the mount point associated to the C<hal_path>, or undef it cannot be mounted successfully (see $cdroms->{error}) +Mount the C<udisks_path> through HAL or fallback to plain mount(8). +Return the mount point associated to the C<udisks_path>, or undef it cannot be mounted successfully (see $cdroms->{error}) =cut sub mount { - my ($o, $hal_path) = @_; + my ($o, $udisks_path) = @_; - my $mntpoint = mount_hal($o, $hal_path); + my $mntpoint = mount_hal($o, $udisks_path); if (!$mntpoint) { # this usually means HAL refused to mount a cdrom listed in fstab - my $dev = _GetProperty(_get_device($o, $hal_path), 'NativePath'); + my $dev = _GetProperty(_get_device($o, $udisks_path), 'NativePath'); # try to get real path: $dev =~ s!.*/!/dev/!; if (my $wanted = $dev && _rdev($dev)) { my ($fstab_dev) = grep { $wanted == _rdev($_) } _fstab_devices(); system("mount", $fstab_dev) == 0 - and $mntpoint = get_mount_point($o, $hal_path); + and $mntpoint = get_mount_point($o, $udisks_path); } } $mntpoint; @@ -193,52 +193,52 @@ sub _fstab_devices() { map { /(\S+)/ } <$F>; } -=head2 $cdroms->unmount($hal_path) +=head2 $cdroms->unmount($udisks_path) -Unmount the C<hal_path>. Return true on success (see $cdroms->{error} on failure) +Unmount the C<udisks_path>. Return true on success (see $cdroms->{error} on failure) If the cdrom is listed in not mounted by HAL, HAL will refuse to unmount it. =cut sub unmount_hal { - my ($o, $hal_path) = @_; + my ($o, $udisks_path) = @_; - my $volume = _get_udisks_device($o, $hal_path); + my $volume = _get_udisks_device($o, $udisks_path); _try($o, sub { $volume->FilesystemUnmount([]) }); } -=head2 $cdroms->unmount($hal_path) +=head2 $cdroms->unmount($udisks_path) -Unmount the C<hal_path> through HAL or fallback on umount(8). +Unmount the C<udisks_path> through HAL or fallback on umount(8). Return true on success (see $cdroms->{error} on failure) =cut sub unmount { - my ($o, $hal_path) = @_; + my ($o, $udisks_path) = @_; - unmount_hal($o, $hal_path) and return 1; + unmount_hal($o, $udisks_path) and return 1; - system('umount', get_mount_point($o, $hal_path)) == 0; + system('umount', get_mount_point($o, $udisks_path)) == 0; } -=head2 $cdroms->eject($hal_path) +=head2 $cdroms->eject($udisks_path) -Ejects the C<hal_path>. Return true on success (see $cdroms->{error} on failure) +Ejects the C<udisks_path>. Return true on success (see $cdroms->{error} on failure) =cut sub eject { - my ($o, $hal_path) = @_; + my ($o, $udisks_path) = @_; - my $volume = _get_udisks_device($o, $hal_path); + my $volume = _get_udisks_device($o, $udisks_path); _try($o, sub { $volume->FilesystemUnmount([]); $volume->DriveEject([]) }); } =head2 $cdroms->wait_for_insert([$timeout]) Waits until a cdrom is inserted. -Returns the inserted C<hal_path> on success. Otherwise returns undef. +Returns the inserted C<udisks_path> on success. Otherwise returns undef. You can give an optional timeout in milliseconds. @@ -260,7 +260,7 @@ sub wait_for_insert { =head2 $cdroms->wait_for_mounted([$timeout]) Waits until a cdrom is inserted and mounted by a volume manager (eg: gnome-volume-manager). -Returns the mounted C<hal_path> on success. Otherwise returns undef. +Returns the mounted C<udisks_path> on success. Otherwise returns undef. You can give an optional timeout in milliseconds. @@ -276,10 +276,10 @@ sub wait_for_mounted { my (undef, $modified_properties) = $msg->get_args_list; grep { $_->[0] eq 'volume.is_mounted' } @$modified_properties or return; - my $hal_path = $msg->get_path; - my $device = _get_device($o, $hal_path); + my $udisks_path = $msg->get_path; + my $device = _get_device($o, $udisks_path); - eval { _GetProperty($device, 'DeviceIsMounted') } && $hal_path; + eval { _GetProperty($device, 'DeviceIsMounted') } && $udisks_path; }); } |