CPictureViewer: rework GetLogoName

Evaluation with real channel name was broken.


Origin commit data
------------------
Commit: 662fbe2dec
Author: Thilo Graf <dbt@novatux.de>
Date: 2013-10-04 (Fri, 04 Oct 2013)
This commit is contained in:
2013-10-04 16:49:43 +02:00
parent c30bdca3de
commit d965659949
2 changed files with 27 additions and 36 deletions

View File

@@ -498,48 +498,39 @@ void CPictureViewer::getSize(const char* name, int* width, int *height)
} }
} }
#define LOGO_DIR1 DATADIR "/neutrino/icons/logo" bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string& ChannelName, std::string & name, int *width, int *height)
#define LOGO_FMT ".jpg"
bool CPictureViewer::GetLogoName(uint64_t channel_id, std::string ChannelName, std::string & name, int *width, int *height)
{ {
int i, j; std::string fileType[] = { ".png", ".jpg" , ".gif" };
char strChanId[16];
sprintf(strChanId, "%llx", channel_id & 0xFFFFFFFFFFFFULL); //get channel id as string
/* first the channel-id, then the channelname */ char strChnId[16];
std::string strLogoName[2] = { (std::string)strChanId, ChannelName }; snprintf(strChnId, 16, "%llx", channel_id & 0xFFFFFFFFFFFFULL);
/* first png, then jpg, then gif */ strChnId[15] = '\0';
std::string strLogoExt[3] = { ".png", ".jpg" , ".gif" };
for (i = 0; i < 2; i++) for (size_t i = 0; i<(sizeof(fileType) / sizeof(fileType[0])); i++){
{ std::vector<std::string> v_path;
for (j = 0; j < 3; j++) std::string id_tmp_path;
{
std::string tmp(g_settings.logo_hdd_dir + "/" + strLogoName[i] + strLogoExt[j]); //create filename with channel name
if (access(tmp.c_str(), R_OK) != -1) id_tmp_path = g_settings.logo_hdd_dir + "/";
{ id_tmp_path += ChannelName + fileType[i];
v_path.push_back(id_tmp_path);
//create filename with id
id_tmp_path = g_settings.logo_hdd_dir + "/";
id_tmp_path += strChnId + fileType[i];
v_path.push_back(id_tmp_path);
//check if file is available, name with real name is preferred, return true on success
for (size_t j = 0; j < v_path.size(); j++){
if (access(v_path[j].c_str(), R_OK) != -1){
if(width && height) if(width && height)
getSize(tmp.c_str(), width, height); getSize(v_path[j].c_str(), width, height);
name = tmp; name = v_path[j];
return true; return true;
} }
} }
} }
for (i = 0; i < 2; i++)
{
for (j = 0; j < 3; j++)
{
std::string tmp(LOGO_DIR1 "/" + strLogoName[i] + strLogoExt[j]);
if (access(tmp.c_str(), R_OK) != -1)
{
if(width && height)
getSize(tmp.c_str(), width, height);
name = tmp;
return true;
}
}
}
return false; return false;
} }

View File

@@ -65,7 +65,7 @@ class CPictureViewer
static double m_aspect_ratio_correction; static double m_aspect_ratio_correction;
bool DisplayImage (const std::string & name, int posx, int posy, int width, int height, int transp=CFrameBuffer::TM_EMPTY); bool DisplayImage (const std::string & name, int posx, int posy, int width, int height, int transp=CFrameBuffer::TM_EMPTY);
bool DisplayLogo (uint64_t channel_id, int posx, int posy, int width, int height); bool DisplayLogo (uint64_t channel_id, int posx, int posy, int width, int height);
bool GetLogoName(uint64_t channel_id, std::string ChanName, std::string & name, int *width = NULL, int *height = NULL); bool GetLogoName(const uint64_t& channel_id, const std::string& ChanName, std::string & name, int *width = NULL, int *height = NULL);
fb_pixel_t * getImage (const std::string & name, int width, int height); fb_pixel_t * getImage (const std::string & name, int width, int height);
fb_pixel_t * getIcon (const std::string & name, int *width, int *height); fb_pixel_t * getIcon (const std::string & name, int *width, int *height);
void getSize(const char *name, int* width, int *height); void getSize(const char *name, int* width, int *height);