Skip to content

Commit

Permalink
Fix the channel icon not loading in the OSD on remote frontends by sw…
Browse files Browse the repository at this point in the history
…itching to using the channel icon storage group. This bug has been around for years so it's nice to finally have a fix.
  • Loading branch information
stuartm committed Mar 3, 2012
1 parent e0e321f commit cda7871
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 141 deletions.
9 changes: 5 additions & 4 deletions mythtv/libs/libmythbase/mythcorecontext.cpp
Expand Up @@ -703,7 +703,7 @@ void MythCoreContext::ConfigureHostAddress(void)
QString("Adding IPv6 loopback to address list."));
d->m_IPv6.append(*it);
}
else if (config_v6.isNull() &&
else if (config_v6.isNull() &&
(it->protocol() == QAbstractSocket::IPv6Protocol))
{
// IPv6 address is not defined, populate one
Expand Down Expand Up @@ -735,7 +735,7 @@ void MythCoreContext::ConfigureHostAddress(void)
}
#if !defined(QT_NO_IPV6)

if (!config_v6.isNull() && !d->m_IPv6.contains(config_v6) &&
if (!config_v6.isNull() && !d->m_IPv6.contains(config_v6) &&
!d->m_IPv6.isEmpty())
{
LOG(VB_GENERAL, LOG_CRIT, LOC + QString("Host is configured to listen "
Expand Down Expand Up @@ -810,7 +810,8 @@ QString MythCoreContext::GenMythURL(QString host, int port, QString path, QStrin
}


QString MythCoreContext::GetMasterHostPrefix(QString storageGroup)
QString MythCoreContext::GetMasterHostPrefix(const QString &storageGroup,
const QString &path)
{
QString ret;

Expand All @@ -834,7 +835,7 @@ QString MythCoreContext::GetMasterHostPrefix(QString storageGroup)

ret = GenMythURL(d->m_serverSock->peerAddress().toString(),
d->m_serverSock->peerPort(),
"",
path,
storageGroup);
}

Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmythbase/mythcorecontext.h
Expand Up @@ -87,7 +87,8 @@ class MBASE_PUBLIC MythCoreContext : public MythObservable, public MythSocketCBs
QString GenMythURL(QString host = QString(), int port = 0,
QString path = QString(), QString storageGroup = QString());

QString GetMasterHostPrefix(QString storageGroup = QString());
QString GetMasterHostPrefix(const QString &storageGroup = QString(),
const QString &path = QString());
QString GetMasterHostName(void);
QString GetHostName(void);
QString GetFilePrefix(void);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.25.20120225-2"
#define MYTH_BINARY_VERSION "0.25.20120303-1"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand Down
14 changes: 7 additions & 7 deletions mythtv/libs/libmythbase/storagegroup.cpp
Expand Up @@ -65,7 +65,7 @@ void StorageGroup::StaticInit(void)

m_staticInitDone = true;

m_builtinGroups["ChannelIcons"] = GetConfDir() + "/ChannelIcons";
m_builtinGroups["ChannelIcons"] = GetConfDir() + "/channels";
m_builtinGroups["Themes"] = GetConfDir() + "/themes";
m_builtinGroups["Temp"] = GetConfDir() + "/tmp";
m_builtinGroups["Streaming"] = GetConfDir() + "/tmp/hls";
Expand Down Expand Up @@ -363,7 +363,7 @@ bool StorageGroup::FileExists(QString filename)
// in the order EXISTS, DATE, SIZE
QStringList StorageGroup::GetFileInfo(QString filename)
{
LOG(VB_FILE, LOG_DEBUG, LOC +
LOG(VB_FILE, LOG_DEBUG, LOC +
QString("GetFileInfo: For '%1'") .arg(filename));

QStringList details;
Expand Down Expand Up @@ -440,7 +440,7 @@ QString StorageGroup::GetRelativePathname(const QString &filename)
if (result.startsWith("/"))
result.replace(0, 1, "");

LOG(VB_FILE, LOG_DEBUG,
LOG(VB_FILE, LOG_DEBUG,
QString("StorageGroup::GetRelativePathname(%1) = '%2'")
.arg(filename).arg(result));
return result;
Expand Down Expand Up @@ -585,7 +585,7 @@ QString StorageGroup::FindFile(QString filename)

QString recDir = FindFileDir(filename);
QString result = "";

if (!recDir.isEmpty())
{
result = recDir + "/" + filename;
Expand Down Expand Up @@ -698,7 +698,7 @@ QString StorageGroup::FindNextDirMostFree(void)
}

if (nextDir.isEmpty())
LOG(VB_FILE, LOG_ERR, LOC +
LOG(VB_FILE, LOG_ERR, LOC +
"FindNextDirMostFree: Unable to find any directories to use.");
else
LOG(VB_FILE, LOG_DEBUG, LOC +
Expand All @@ -724,7 +724,7 @@ void StorageGroup::CheckAllStorageGroupDirs(void)
return;
}

LOG(VB_FILE, LOG_DEBUG, LOC +
LOG(VB_FILE, LOG_DEBUG, LOC +
"CheckAllStorageGroupDirs(): Checking All Storage Group directories");

QFile testFile("");
Expand Down Expand Up @@ -809,7 +809,7 @@ QStringList StorageGroup::getGroupDirs(QString groupname, QString host)
QString sql = QString("SELECT dirname,hostname "
"FROM storagegroup "
"WHERE groupname = :GROUPNAME %1").arg(addHost);

query.prepare(sql);
query.bindValue(":GROUPNAME", groupname);

Expand Down
82 changes: 0 additions & 82 deletions mythtv/libs/libmythtv/dbchannelinfo.cpp
Expand Up @@ -136,88 +136,6 @@ void ChannelInfo::ToMap(InfoMap& infoMap) const
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

bool PixmapChannel::CacheChannelIcon(void)
{
if (icon.isEmpty())
return false;

m_localIcon = icon;

// Is icon local?
if (QFile(icon).exists())
return true;

QString localDirStr = QString("%1/channels").arg(GetConfDir());
QDir localDir(localDirStr);

if (!localDir.exists() && !localDir.mkdir(localDirStr))
{
LOG(VB_GENERAL, LOG_ERR,
QString("Icons directory is missing and could not be created: %1")
.arg(localDirStr));
icon.clear();
return false;
}

// Has it been saved to the local cache?
m_localIcon = QString("%1/%2").arg(localDirStr)
.arg(QFileInfo(icon).fileName());
if (QFile(m_localIcon).exists())
return true;

// Get address of master backed
QString url = gCoreContext->GetMasterHostPrefix("ChannelIcons");
if (url.length() < 1)
{
icon.clear();
return false;
}

url.append(icon);

QUrl qurl = url;
if (qurl.host().isEmpty())
{
icon.clear();
return false;
}

RemoteFile *rf = new RemoteFile(url, false, false, 0);

QByteArray data;
bool ret = rf->SaveAs(data);

delete rf;

if (ret && data.size())
{
QImage image;

image.loadFromData(data);

//if (image.loadFromData(data) && image.width() > 0

if (image.save(m_localIcon))
{
LOG(VB_GENERAL, LOG_INFO,
QString("Caching channel icon %1").arg(m_localIcon));
return true;
}
else
LOG(VB_GENERAL, LOG_ERR,
QString("Failed to save to %1").arg(m_localIcon));
}

// if we get here then the icon is set in the db but couldn't be found
// anywhere so maybe we should remove it from the DB?
icon.clear();

return false;
}

////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////

bool ChannelInsertInfo::SaveScan(uint scanid, uint transportid) const
{
MSqlQuery query(MSqlQuery::InitCon());
Expand Down
16 changes: 1 addition & 15 deletions mythtv/libs/libmythtv/dbchannelinfo.h
Expand Up @@ -17,7 +17,7 @@ using namespace std;
#include "mythtvexp.h"
#include "programtypes.h"

// TODO: Refactor DBChannel, PixmapChannel and ChannelInfo into a single class
// TODO: Refactor DBChannel and ChannelInfo into a single class

class MTV_PUBLIC DBChannel
{
Expand Down Expand Up @@ -72,20 +72,6 @@ class MTV_PUBLIC ChannelInfo
QString recpriority;
};

class MTV_PUBLIC PixmapChannel : public DBChannel
{
public:
PixmapChannel(const PixmapChannel &other) :
DBChannel(other), m_localIcon() { }
PixmapChannel(const DBChannel &other) :
DBChannel(other), m_localIcon() { }

bool CacheChannelIcon(void);

public:
QString m_localIcon;
};

class MTV_PUBLIC ChannelInsertInfo
{
public:
Expand Down
14 changes: 12 additions & 2 deletions mythtv/libs/libmythtv/osd.cpp
Expand Up @@ -416,14 +416,24 @@ void OSD::SetText(const QString &window, QHash<QString,QString> &map,
MythUIImage *icon = dynamic_cast<MythUIImage *> (win->GetChild("iconpath"));
if (icon)
{
icon->Reset();

uint chanid = map["chanid"].toUInt();
QString iconpath;
if (map.contains("iconpath"))
iconpath = map["iconpath"];
else
iconpath = ChannelUtil::GetIcon(chanid);
icon->SetFilename(iconpath);
icon->Load(false);

if (!iconpath.isEmpty())
{
QString iconurl =
gCoreContext->GetMasterHostPrefix("ChannelIcon",
iconpath);

icon->SetFilename(iconurl);
icon->Load(false);
}
}
}
if (map.contains("inetref"))
Expand Down

0 comments on commit cda7871

Please sign in to comment.