Ticket #2612: utf8_recording_filenames_fix.patch

File utf8_recording_filenames_fix.patch, 5.6 KB (added by Pekka Jääskeläinen <pekka.jaaskelainen@…>, 14 years ago)

the patch

  • libs/libmythtv/programinfo.cpp

    Fixes couple of problems with UTF8 recording filenames. You can get such 
    filenames after running the 'mythrename.pl' for the recordings.
    Without this patch one cannot play files with UTF8 characters 
    in the recording menu nor display the thumbnails in MythWeb Recordings page.
    
    Adds some comments to clarify which functions expect UTF8 encoded filenames.
    
    Expects filenames from database to be in UTF8 format (like rest of the
    strings).
    
    old new  
    863863        proginfo->playgroup = query.value(21).toString();
    864864        proginfo->recpriority = query.value(22).toInt();
    865865
    866         proginfo->pathname = query.value(25).toString();
     866        proginfo->pathname = QString::fromUtf8(query.value(25).toString());
    867867
    868868        return proginfo;
    869869    }
     
    42914291                proginfo->hasAirDate      = true;
    42924292            }
    42934293
    4294             proginfo->pathname = query.value(28).toString();
     4294            proginfo->pathname = QString::fromUtf8(query.value(28).toString());
    42954295
    42964296
    42974297            if (proginfo->hostname.isEmpty() || proginfo->hostname.isNull())
  • libs/libmythtv/previewgenerator.cpp

    old new  
    232232    }
    233233}
    234234
    235 bool PreviewGenerator::SavePreview(QString filename,
     235/** \fn PreviewGenerator::SavePreview(const QString&, const unsigned char*,
     236 *  uint, uint, float)
     237 *
     238 *  \brief Saves a given preview image to a .png file.
     239 *
     240 *  \param filename The filename (in UTF8 encoding!) to store the PNG data in.
     241 *  \param data The image data.
     242 *  \param width Width of the image.
     243 *  \param height Height of the image.
     244 *  \param aspect Aspect ratio of the image.
     245 */
     246bool PreviewGenerator::SavePreview(const QString &filename,
    236247                                   const unsigned char *data,
    237248                                   uint width, uint height, float aspect)
    238249{
     
    255266
    256267    QImage small_img = img.smoothScale((int) ppw, (int) pph);
    257268
    258     if (small_img.save(filename.ascii(), "PNG"))
     269    if (small_img.save(filename, "PNG"))
    259270    {
    260271        chmod(filename.ascii(), 0666); // Let anybody update it
    261272        return true;
     
    323334 *  \brief Returns a PIX_FMT_RGBA32 buffer containg a frame from the video.
    324335 *
    325336 *  \param pginfo       Recording to grab from.
    326  *  \param filename     File containing recording.
     337 *  \param filename     Filename (in UTF8 encoding!) of the recording.
    327338 *  \param secondsin    Seconds into the video to seek before
    328339 *                      capturing a frame.
    329340 *  \param bufferlen    Returns size of buffer returned (in bytes).
     
    346357    (void) video_height;
    347358    char *retbuf = NULL;
    348359    bufferlen = 0;
     360
    349361#ifdef USING_FRONTEND
    350362    if (!MSqlQuery::testDBConnection())
    351363    {
     
    354366    }
    355367
    356368    // pre-test local files for existence and size. 500 ms speed-up...
    357     if (filename.left(1)=="/")
     369    if (filename.left(1) == "/")
    358370    {
    359371        QFileInfo info(filename);
    360372        bool invalid = !info.exists() || !info.isReadable() || !info.isFile();
  • programs/mythbackend/mainserver.cpp

    old new  
    5050    #include <sensors/chips.h>
    5151#endif
    5252
    53 
    5453/** Milliseconds to wait for an existing thread from
    5554 *  process request thread pool.
    5655 */
     
    11331132                proginfo->hasAirDate = true;
    11341133            }
    11351134
    1136             QString basename = query.value(28).toString();
     1135            QString basename = QString::fromUtf8(query.value(28).toString());
    11371136
    11381137            if (proginfo->hostname.isEmpty() || proginfo->hostname.isNull())
    11391138                proginfo->hostname = gContext->GetHostName();
     
    13541353                             
    13551354    QString name = QString("deleteThread%1%2").arg(getpid()).arg(rand());
    13561355    QFile checkFile(ds->filename);
     1356    QFile utf8CheckFile(QString::fromUtf8(ds->filename));
     1357
     1358    if (!checkFile.exists() && utf8CheckFile.exists())
     1359        checkFile.setName(QString::fromUtf8(ds->filename));
    13571360
    13581361    if (!MSqlQuery::testDBConnection())
    13591362    {
     
    19011904
    19021905    QFile checkFile(filename);
    19031906    bool fileExists = checkFile.exists();
     1907    if (!fileExists)
     1908    {
     1909        QFile checkFileUTF8(QString::fromUtf8(filename));
     1910        if (fileExists = checkFileUTF8.exists())
     1911            filename = QString::fromUtf8(filename);
     1912           
     1913    }
    19041914
    19051915    // Allow deleting of files where the recording failed meaning size == 0
    19061916    // But do not allow deleting of files that appear to be completely absent.
  • libs/libmythtv/previewgenerator.h

    old new  
    2222    void Start(void);
    2323    void Run(void);
    2424
    25     static bool SavePreview(QString filename,
     25    static bool SavePreview(const QString &filename,
    2626                            const unsigned char *data,
    2727                            uint width, uint height, float aspect);
    2828