This commit is contained in:
fgerlits 2005-08-26 13:11:35 +00:00
parent 9053f1dad3
commit 72355ecfd5
3 changed files with 22 additions and 11 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.16 $
Version : $Revision: 1.17 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/UploadFileWindow.cxx,v $
------------------------------------------------------------------------------*/
@ -244,7 +244,11 @@ UploadFileWindow :: updateFileInfo(void) throw ()
try {
playlength = readPlaylength(fileName);
} catch (std::invalid_argument &e) {
statusBar->set_text(e.what());
statusBar->set_text(*getResourceUstring("unsupportedFileTypeMsg"));
return;
}
if (!playlength) {
statusBar->set_text(*getResourceUstring("couldNotReadLengthMsg"));
playlength.reset(new time_duration(0,0,0,0));
}
@ -369,15 +373,17 @@ UploadFileWindow :: readPlaylength(const std::string & fileName)
throw (std::invalid_argument)
{
TagLib::FileRef fileRef(fileName.c_str());
TagLib::AudioProperties * audioProperties = fileRef.audioProperties();
if (fileRef.isNull()) {
throw std::invalid_argument("unsupported file type");
}
TagLib::AudioProperties * audioProperties = fileRef.audioProperties();
Ptr<time_duration>::Ref length;
if (audioProperties) {
Ptr<time_duration>::Ref length(new time_duration(
length.reset(new time_duration(
seconds( audioProperties->length() )
+ microseconds(audioProperties->length_microseconds()) ));
return length;
} else {
throw std::invalid_argument("could not read file length");
}
return length;
}

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Version : $Revision: 1.7 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/UploadFileWindow.h,v $
------------------------------------------------------------------------------*/
@ -87,7 +87,7 @@ using namespace LiveSupport::Widgets;
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.6 $
* @version $Revision: 1.7 $
*/
class UploadFileWindow : public WhiteWindow, public LocalizedObject
{
@ -273,9 +273,10 @@ class UploadFileWindow : public WhiteWindow, public LocalizedObject
* Determine the length of an audio file on disk.
*
* @param fileName a binary audio file (e.g., /tmp/some_clip.mp3)
* @return the length of the file
* @return the length of the file; a null pointer if the
* length could not be read (see bug #1426)
* @exception std::invalid_argument if the file is not found, or its
* length could not be determined
* format is not supported by TagLib
*/
Ptr<time_duration>::Ref
readPlaylength(const std::string & fileName)

View file

@ -115,6 +115,10 @@ root:table
{ "Choose a File" }
clipUploadedMsg:string { "Uploaded clip ''{0}''." }
couldNotOpenFileMsg:string { "The file could not be opened." }
couldNotReadLengthMsg:string
{ "Could not determine audio clip length." }
unsupportedFileTypeMsg:string
{ "Unsupported file type." }
missingTitleMsg:string { "Please enter a title." }
}