FRITZBOX: ConvertRingTone creates now directory

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@7453 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
tpoitzsch
2015-01-05 20:05:09 +00:00
parent 6a06a2c999
commit 4aba587937

View File

@@ -1553,9 +1553,9 @@ sub FRITZBOX_SetMOH($@)
sub FRITZBOX_SetCustomerRingTone($@) sub FRITZBOX_SetCustomerRingTone($@)
{ {
my ($hash, $intern, @file) = @_; my ($hash, $intern, @file) = @_;
my $returnStr; my @cmdArray;
my $result;
my $name = $hash->{NAME}; my $name = $hash->{NAME};
my $uploadDir = AttrVal( $name, "defaultUploadDir", "" ); my $uploadDir = AttrVal( $name, "defaultUploadDir", "" );
$uploadDir .= "/" $uploadDir .= "/"
unless $uploadDir =~ /\/$|^$/; unless $uploadDir =~ /\/$|^$/;
@@ -1570,29 +1570,35 @@ sub FRITZBOX_SetCustomerRingTone($@)
return "Error: Only MP3 or G722 files can be uploaded to the phone." return "Error: Only MP3 or G722 files can be uploaded to the phone."
unless $inFile =~ /\.mp3$|.g722$/i; unless $inFile =~ /\.mp3$|.g722$/i;
my $uploadFile = '/var/InternerSpeicher/FRITZ/fonring/'.time().'.g722'; my $uploadFile = '/var/InternerSpeicher/FRITZ/fonring/'.int(time()).'.g722';
push @cmdArray, 'if [! -d /var/InternerSpeicher/FRITZ/fonring ]; mkdir -p "/var/InternerSpeicher/FRITZ/fonring"; fi';
$inFile =~ s/file:\/\///i; $inFile =~ s/file:\/\///i;
if ( $inFile =~ /\.mp3$/i )
{ # mp3 files are converted
# mp3 files are converted if ( $inFile =~ /\.mp3$/i ) {
$returnStr = FRITZBOX_Exec ($hash push @cmdArray, 'picconv.sh "file://'.$inFile.'" "'.$uploadFile.'" ringtonemp3';
, 'picconv.sh "file://'.$inFile.'" "'.$uploadFile.'" ringtonemp3');
} # G722 files are copied
elsif ( $inFile =~ /\.g722$/i ) } elsif ( $inFile =~ /\.g722$/i ) {
{ push @cmdArray, "cp '$inFile' '$uploadFile'";
# G722 files are copied
$returnStr = FRITZBOX_Exec ($hash, # all other formats fail
"cp '$inFile' '$uploadFile'"); } else {
}
else
{
return "Error: only MP3 or G722 files can be uploaded to the phone"; return "Error: only MP3 or G722 files can be uploaded to the phone";
} }
# trigger the loading of the file to the phone, file will be deleted as soon as the upload finished
$returnStr .= "\n".FRITZBOX_Exec ($hash, # trigger the loading of the file to the phone, file will be deleted by the box as soon as the upload has finished
'/usr/bin/pbd --set-ringtone-url --book="255" --id="'.$intern.'" --url="file://'.$uploadFile.'" --name="FHEM'.time().'"'); push @cmdArray, '/usr/bin/pbd --set-ringtone-url --book="255" --id="'.$intern.'" --url="file://'.$uploadFile.'" --name="FHEM'.int(time()).'"';
return $returnStr;
$result = FRITZBOX_Open_Connection( $hash );
return $result if $result;
FRITZBOX_Exec ($hash, \@cmdArray);
FRITZBOX_Close_Connection( $hash );
return "Upload of ring tone will take about 1 minute. Do not work with the phone until its done.";
} }
############################################ ############################################