pictureviewer: just small code formatting changes in GetLogoName()

Origin commit data
------------------
Commit: c0bcdffbb9
Author: vanhofen <vanhofen@gmx.de>
Date: 2018-12-18 (Tue, 18 Dec 2018)

Origin message was:
------------------
- pictureviewer: just small code formatting changes in GetLogoName()
This commit is contained in:
vanhofen
2018-12-18 00:19:35 +01:00
parent 51ea8c94bb
commit b4d591ff3a
2 changed files with 30 additions and 24 deletions

View File

@@ -527,13 +527,13 @@ void CPictureViewer::getSize(const char* name, int* width, int *height)
} }
} }
bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string& ChannelName, std::string & name, int *width, int *height) bool CPictureViewer::GetLogoName(const uint64_t &ChannelID, const std::string &ChannelName, std::string &name, int *width, int *height)
{ {
std::string fileType[] = { ".png", ".jpg", ".gif" }; std::string fileType[] = { ".png", ".jpg", ".gif" };
//get channel id as string //get channel id as string
char strChnId[16]; char strChnId[16];
snprintf(strChnId, 16, "%llx", channel_id & 0xFFFFFFFFFFFFULL); snprintf(strChnId, 16, "%llx", ChannelID & 0xFFFFFFFFFFFFULL);
strChnId[15] = '\0'; strChnId[15] = '\0';
//create E2 filenames //create E2 filenames
@@ -545,38 +545,38 @@ bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string&
//create special filename from channelname //create special filename from channelname
std::string SpecialChannelName = ChannelName; std::string SpecialChannelName = ChannelName;
std::transform(SpecialChannelName.begin(), SpecialChannelName.end(), SpecialChannelName.begin(), ::tolower); std::transform(SpecialChannelName.begin(), SpecialChannelName.end(), SpecialChannelName.begin(), ::tolower);
SpecialChannelName = str_replace(" ","-",SpecialChannelName); SpecialChannelName = str_replace(" ", "-", SpecialChannelName);
SpecialChannelName = str_replace("ä","a",SpecialChannelName); SpecialChannelName = str_replace("ä", "a", SpecialChannelName);
SpecialChannelName = str_replace("ö","o",SpecialChannelName); SpecialChannelName = str_replace("ö", "o", SpecialChannelName);
SpecialChannelName = str_replace("ü","u",SpecialChannelName); SpecialChannelName = str_replace("ü", "u", SpecialChannelName);
SpecialChannelName = str_replace("+","___plus___",SpecialChannelName); SpecialChannelName = str_replace("+", "___plus___", SpecialChannelName);
SpecialChannelName = str_replace("&","___and___",SpecialChannelName); SpecialChannelName = str_replace("&", "___and___", SpecialChannelName);
CZapitChannel * cc = NULL; CZapitChannel * cc = NULL;
if (channel_id) if (ChannelID && CNeutrinoApp::getInstance()->channelList)
if (CNeutrinoApp::getInstance()->channelList) cc = CNeutrinoApp::getInstance()->channelList->getChannel(ChannelID);
cc = CNeutrinoApp::getInstance()->channelList->getChannel(channel_id);
if (cc) if (cc)
{ {
//create E2 filename1 //create E2 filename1
snprintf(e2filename1, sizeof(e2filename1), "1_0_%X_%X_%X_%X_%X0000_0_0_0", snprintf(e2filename1, sizeof(e2filename1), "1_0_%X_%X_%X_%X_%X0000_0_0_0",
(u_int) cc->getServiceType(true), (u_int) cc->getServiceType(true),
(u_int) channel_id & 0xFFFF, (u_int) ChannelID & 0xFFFF,
(u_int) (channel_id >> 32) & 0xFFFF, (u_int) (ChannelID >> 32) & 0xFFFF,
(u_int) (channel_id >> 16) & 0xFFFF, (u_int) (ChannelID >> 16) & 0xFFFF,
(u_int) cc->getSatellitePosition()); (u_int) cc->getSatellitePosition());
//create E2 filename2 //create E2 filename2
snprintf(e2filename2, sizeof(e2filename2), "1_0_%X_%X_%X_%X_%X0000_0_0_0", snprintf(e2filename2, sizeof(e2filename2), "1_0_%X_%X_%X_%X_%X0000_0_0_0",
(u_int) 1, (u_int) 1,
(u_int) channel_id & 0xFFFF, (u_int) ChannelID & 0xFFFF,
(u_int) (channel_id >> 32) & 0xFFFF, (u_int) (ChannelID >> 32) & 0xFFFF,
(u_int) (channel_id >> 16) & 0xFFFF, (u_int) (ChannelID >> 16) & 0xFFFF,
(u_int) cc->getSatellitePosition()); (u_int) cc->getSatellitePosition());
} }
for (size_t i = 0; i<(sizeof(fileType) / sizeof(fileType[0])); i++){ for (size_t i = 0; i < (sizeof(fileType) / sizeof(fileType[0])); i++)
{
std::vector<std::string> v_path; std::vector<std::string> v_path;
std::string id_tmp_path; std::string id_tmp_path;
@@ -611,7 +611,8 @@ bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string&
v_path.push_back(id_tmp_path); v_path.push_back(id_tmp_path);
} }
if(g_settings.logo_hdd_dir != LOGODIR_VAR){ if (g_settings.logo_hdd_dir != LOGODIR_VAR)
{
//create filename with channel name (LOGODIR_VAR) //create filename with channel name (LOGODIR_VAR)
id_tmp_path = LOGODIR_VAR "/"; id_tmp_path = LOGODIR_VAR "/";
id_tmp_path += ChannelName + fileType[i]; id_tmp_path += ChannelName + fileType[i];
@@ -643,7 +644,9 @@ bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string&
v_path.push_back(id_tmp_path); v_path.push_back(id_tmp_path);
} }
} }
if(g_settings.logo_hdd_dir != LOGODIR){
if (g_settings.logo_hdd_dir != LOGODIR)
{
//create filename with channel name (LOGODIR) //create filename with channel name (LOGODIR)
id_tmp_path = LOGODIR "/"; id_tmp_path = LOGODIR "/";
id_tmp_path += ChannelName + fileType[i]; id_tmp_path += ChannelName + fileType[i];
@@ -675,10 +678,13 @@ bool CPictureViewer::GetLogoName(const uint64_t& channel_id, const std::string&
v_path.push_back(id_tmp_path); v_path.push_back(id_tmp_path);
} }
} }
//check if file is available, name with real name is preferred, return true on success //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++){ for (size_t j = 0; j < v_path.size(); j++)
if (access(v_path[j].c_str(), R_OK) != -1){ {
if(width && height) if (access(v_path[j].c_str(), R_OK) != -1)
{
if (width && height)
getSize(v_path[j].c_str(), width, height); getSize(v_path[j].c_str(), width, height);
name = v_path[j]; name = v_path[j];
return true; return true;

View File

@@ -67,7 +67,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=0 /*CFrameBuffer::TM_EMPTY*/); bool DisplayImage (const std::string & name, int posx, int posy, int width, int height, int transp=0 /*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(const uint64_t& channel_id, const std::string& ChanName, std::string & name, int *width = NULL, int *height = NULL); bool GetLogoName(const uint64_t &ChannelID, const std::string &ChannelName, 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);