Ticket #9597: randomsg_master.patch

File randomsg_master.patch, 2.3 KB (added by erictsmith@…, 13 years ago)

master patch with storage group support

  • mythtv/libs/libmythui/mythuiimage.cpp

    diff --git a/mythtv/libs/libmythui/mythuiimage.cpp b/mythtv/libs/libmythui/mythuiimage.cpp
    index 61af1d7..1b64666 100644
    a b  
    1616#include <QRunnable>
    1717#include <QEvent>
    1818#include <QCoreApplication>
     19#include <QStringList>
    1920
    2021// libmythbase
    2122#include "mythverbose.h"
     23#include "mythcorecontext.h"
     24#include "storagegroup.h"
    2225
    2326// Mythui
    2427#include "mythpainter.h"
    bool MythUIImage::ParseElement( 
    10411044    if (element.tagName() == "filename")
    10421045    {
    10431046        m_OrigFilename = m_Filename = getFirstText(element);
     1047        //Parse the artwork directories from the special tags
     1048        QString artworkDir;
     1049        if (m_Filename.startsWith("%SG_") && m_Filename.endsWith("%"))
     1050        {
     1051            QString host = gCoreContext->GetHostName();
     1052            QString group = m_Filename.mid(4,m_Filename.length()-5);
     1053            QStringList sgEntries;
     1054            StorageGroup sgroup(group, host);
     1055            sgEntries = sgroup.GetFileList("");
     1056            if(sgEntries.size() > 0) {
     1057                int sgEntry;
     1058                int cnt = 0;
     1059                while(!(m_Filename.endsWith(".png") || m_Filename.endsWith(".jpg") || m_Filename.endsWith(".gif")) && cnt < 10)
     1060                {
     1061                    cnt += 1;
     1062                    sgEntry = rand() % sgEntries.size();
     1063                    m_Filename = QString("myth://%1@%2:%3/%4")
     1064                                .arg(StorageGroup::GetGroupToUse(host, group))
     1065                                .arg(gCoreContext->GetSettingOnHost("BackendServerIP", host))
     1066                                .arg(gCoreContext->GetSettingOnHost("BackendServerPort", host))
     1067                                .arg(sgEntries.at(sgEntry));
     1068                }
     1069                if(cnt == 10)
     1070                {
     1071                    VERBOSE(VB_GENERAL, QString("Could not find a valid image in storage group: %1").arg(group));
     1072                    m_Filename = "";
     1073                }
     1074            }
     1075            else
     1076            {
     1077                VERBOSE(VB_GENERAL, QString("Could not find files in storage group: %1").arg(group));
     1078                m_Filename = "";
     1079            }
     1080        }
    10441081        if (m_Filename.endsWith('/'))
    10451082        {
    10461083            QDir imageDir(m_Filename);