diff --git a/lib/libupnpclient/UPNPDevice.cpp b/lib/libupnpclient/UPNPDevice.cpp index ae251881b..f5b9e85f5 100644 --- a/lib/libupnpclient/UPNPDevice.cpp +++ b/lib/libupnpclient/UPNPDevice.cpp @@ -157,7 +157,7 @@ CUPnPDevice::CUPnPDevice(std::string url) head = result.substr(0,pos); body = result.substr(pos+4); - if (body == "") + if (body.empty()) throw std::runtime_error(std::string("desc body empty")); if (!check_response(head, charset, rcode)) diff --git a/lib/libupnpclient/UPNPService.cpp b/lib/libupnpclient/UPNPService.cpp index 7e845aa27..32c15aaf3 100644 --- a/lib/libupnpclient/UPNPService.cpp +++ b/lib/libupnpclient/UPNPService.cpp @@ -69,7 +69,7 @@ std::list CUPnPService::SendSOAP(std::string action, std::list"; for (i = attribs.begin(); i != attribs.end(); ++i) { - if (i->second == "") + if (i->second.empty()) post << "<" << i->first << "/>"; else { @@ -157,7 +157,7 @@ std::list CUPnPService::SendSOAP(std::string action, std::listGetType(),"faultstring")) faultstring=std::string(node->GetData()?node->GetData():""); } - if (faultstring != "") + if (!faultstring.empty()) throw std::runtime_error(faultstring + " " + upnpcode + " " + upnpdesc); else throw std::runtime_error(std::string("XML: http error with unknown soap: ")+rcode); diff --git a/src/driver/neutrinofonts.cpp b/src/driver/neutrinofonts.cpp index fa8289d8a..3cf0ddb03 100644 --- a/src/driver/neutrinofonts.cpp +++ b/src/driver/neutrinofonts.cpp @@ -239,7 +239,7 @@ int CNeutrinoFonts::getDynFontSize(int dx, int dy, std::string text, int style) int _height = getFontHeight(dynFont);; std::string tmpText = text; - if (text == "") tmpText = "x"; + if (text.empty()) tmpText = "x"; _width = dynFont->getRenderWidth(tmpText); if ((_height > dy) || (_width > dx)) { if (dynFlag) @@ -302,7 +302,7 @@ Font **CNeutrinoFonts::getDynFontWithID(int &dx, int &dy, std::string text, int { if ((dx <= 0) && (dy <= 0)) return NULL; - if ((fontDescr.name == "") || (fontDescr.filename == "")) + if ((fontDescr.name.empty()) || (fontDescr.filename.empty())) SetupNeutrinoFonts(); if (g_dynFontRenderer == NULL) SetupDynamicFonts(); @@ -314,7 +314,7 @@ Font **CNeutrinoFonts::getDynFontWithID(int &dx, int &dy, std::string text, int if (f_id < v_dyn_fonts.size()) { if ((v_dyn_fonts[f_id].size == dynSize) && (v_dyn_fonts[f_id].font != NULL)) { dy = v_dyn_fonts[f_id].font->getHeight(); - if (text != "") + if (!text.empty()) dx = v_dyn_fonts[f_id].font->getRenderWidth(text); return &(v_dyn_fonts[f_id].font); } @@ -335,7 +335,7 @@ Font **CNeutrinoFonts::getDynFontWithID(int &dx, int &dy, std::string text, int return NULL; dy = (*ret)->getHeight(); - if (text != "") + if (!text.empty()) dx = (*ret)->getRenderWidth(text); #ifdef DEBUG_NFONTS printf("##### [%s] dx: %d, dy: %d, dynSize: %d, dynFont: %p, ret: %p, FontID: %d\n", __FUNCTION__, dx, dy, dynSize, *ret, ret, f_id); @@ -347,7 +347,7 @@ Font **CNeutrinoFonts::getDynFontShare(int &dx, int &dy, std::string text, int s { if ((dx <= 0) && (dy <= 0)) return NULL; - if ((fontDescr.name == "") || (fontDescr.filename == "") || (g_dynFontRenderer == NULL)) + if ((fontDescr.name.empty()) || (fontDescr.filename.empty()) || (g_dynFontRenderer == NULL)) SetupNeutrinoFonts(); int dynSize = getDynFontSize(dx, dy, text, style); @@ -389,7 +389,7 @@ Font **CNeutrinoFonts::getDynFontShare(int &dx, int &dy, std::string text, int s } dy = (*ret)->getHeight(); - if (text != "") + if (!text.empty()) dx = (*ret)->getRenderWidth(text); #ifdef DEBUG_NFONTS printf("##### [%s] dx: %d, dy: %d, dynSize: %d, dynFont: %p, ret: %p, fontAvailable: %d\n", __FUNCTION__, dx, dy, dynSize, *ret, ret, fontAvailable); diff --git a/src/gui/components/cc_item_infobox.cpp b/src/gui/components/cc_item_infobox.cpp index 25ecbe9c4..91e68a09b 100644 --- a/src/gui/components/cc_item_infobox.cpp +++ b/src/gui/components/cc_item_infobox.cpp @@ -100,7 +100,7 @@ void CComponentsInfoBox::paintPicture() pic = NULL; //exit if no image definied - if (pic_name == "") + if (pic_name.empty()) return; //init pic object and set icon paint position diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 366798745..598c4ab8a 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -515,7 +515,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start const int pic_h = 39; - if (text2 != "") + if (!text2.empty()) toph = 2 * topboxheight; else toph = topboxheight; @@ -637,7 +637,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start headerPic = new CComponentsPicture(sx+10, sy + (toph-logo_h)/2, logo_w, logo_h, lname); headerPic->doPaintBg(false); } - std::string textAll = (text2 != "") ? text1 + "\n" + text2 : text1; + std::string textAll = (!text2.empty()) ? text1 + "\n" + text2 : text1; headerText = new CComponentsText(sx+15+pic_offx, sy, ox-15-pic_offx, header_h, textAll, CTextBox::NO_AUTO_LINEBREAK, g_Font[SNeutrinoSettings::FONT_TYPE_EPG_TITLE]); headerText->doPaintBg(false); headerText->setTextColor(COL_MENUHEAD_TEXT); diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index d4f9aa7d5..952f2974c 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -1244,7 +1244,7 @@ int CEventFinderMenu::exec(CMenuTarget* parent, const std::string &actionkey) { int res = menu_return::RETURN_REPAINT; - if(actionkey =="") + if(actionkey.empty()) { if(parent != NULL) parent->hide(); diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index dbe71aac1..505b1a636 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -1243,7 +1243,7 @@ int CLuaInstance::MenuAddKey(lua_State *L) std::string action; tableLookup(L, "action", action); std::string id; tableLookup(L, "id", id); lua_Unsigned directkey = CRCInput::RC_nokey; tableLookup(L, "directkey", directkey); - if ((action != "") && (directkey != CRCInput::RC_nokey)) { + if ((!action.empty()) && (directkey != CRCInput::RC_nokey)) { CLuaMenuForwarder *forwarder = new CLuaMenuForwarder(L, action, id); m->m->addKey(directkey, forwarder, action); m->targets.push_back(forwarder); @@ -1772,22 +1772,22 @@ int CLuaInstance::CWindowNew(lua_State *L) CComponentsFooter* footer = (*udata)->w->getFooterObject(); if (footer) { int btnCount = 0; - if (btnRed != "") btnCount++; - if (btnGreen != "") btnCount++; - if (btnYellow != "") btnCount++; - if (btnBlue != "") btnCount++; + if (!btnRed.empty()) btnCount++; + if (!btnGreen.empty()) btnCount++; + if (!btnYellow.empty()) btnCount++; + if (!btnBlue.empty()) btnCount++; if (btnCount) { fb_pixel_t col = footer->getColorBody(); int btnw = (dx-20) / btnCount; int btnh = footer->getHeight(); int start = 10; - if (btnRed != "") + if (!btnRed.empty()) footer->addCCItem(new CComponentsButtonRed(start, CC_CENTERED, btnw, btnh, btnRed, 0, false , true, false, col, col)); - if (btnGreen != "") + if (!btnGreen.empty()) footer->addCCItem(new CComponentsButtonGreen(start+=btnw, CC_CENTERED, btnw, btnh, btnGreen, 0, false , true, false, col, col)); - if (btnYellow != "") + if (!btnYellow.empty()) footer->addCCItem(new CComponentsButtonYellow(start+=btnw, CC_CENTERED, btnw, btnh, btnYellow, 0, false , true, false, col, col)); - if (btnBlue != "") + if (!btnBlue.empty()) footer->addCCItem(new CComponentsButtonBlue(start+=btnw, CC_CENTERED, btnw, btnh, btnBlue, 0, false , true, false, col, col)); } } diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index c2b7b5b23..71f739c75 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -712,7 +712,7 @@ bool CMovieBrowser::loadSettings(MB_SETTINGS* settings) settings->ytsearch_history.clear(); for (int i = 0; i < settings->ytsearch_history_size; i++) { std::string s = configfile.getString("mb_ytsearch_history_" + to_string(i)); - if (s != "") + if (!s.empty()) settings->ytsearch_history.push_back(configfile.getString("mb_ytsearch_history_" + to_string(i), "")); } settings->ytsearch_history_size = settings->ytsearch_history.size(); @@ -1723,7 +1723,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) CRecordInstance* inst = CRecordManager::getInstance()->getRecordInstance(m_movieSelectionHandler->file.Name); if (inst != NULL) { std::string delName = m_movieSelectionHandler->epgTitle; - if (delName == "") + if (delName.empty()) delName = m_movieSelectionHandler->file.getFileName(); char buf1[1024]; snprintf(buf1, sizeof(buf1), g_Locale->getText(LOCALE_MOVIEBROWSER_ASK_REC_TO_DELETE), delName.c_str()); @@ -1830,7 +1830,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) if (m_movieSelectionHandler != NULL) { if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_MOVIEBROWSER_DELETE_SCREENSHOT, CMessageBox::mbrNo, CMessageBox:: mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { std::string fname = getScreenshotName(m_movieSelectionHandler->file.Name, S_ISDIR(m_movieSelectionHandler->file.Mode)); - if (fname != "") + if (!fname.empty()) unlink(fname.c_str()); refresh(); } @@ -3310,7 +3310,7 @@ int CYTCacheSelectorTarget::exec(CMenuTarget* /*parent*/, const std::string & ac cYTCache::getInstance()->cancel(&movieBrowser->yt_pending[selected - movieBrowser->yt_pending_offset]); } else if (actionKey == "rc_spkr" && movieBrowser->yt_completed_offset && selected >= movieBrowser->yt_completed_offset && selected < movieBrowser->yt_completed_end) { cYTCache::getInstance()->remove(&movieBrowser->yt_completed[selected - movieBrowser->yt_completed_offset]); - } else if (actionKey == "") { + } else if (actionKey.empty()) { if (movieBrowser->yt_pending_offset && selected >= movieBrowser->yt_pending_offset && selected < movieBrowser->yt_pending_end) { if (ShowMsg (LOCALE_MOVIEBROWSER_YT_CACHE, g_Locale->getText(LOCALE_MOVIEBROWSER_YT_CANCEL_TRANSFER), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) cYTCache::getInstance()->cancel(&movieBrowser->yt_pending[selected - movieBrowser->yt_pending_offset]); @@ -3427,7 +3427,7 @@ CYTHistory::CYTHistory(MB_SETTINGS &_settings, std::string &_search) int CYTHistory::exec(CMenuTarget* parent, const std::string &actionKey) { - if (actionKey == "") { + if (actionKey.empty()) { if (parent) parent->hide(); CMenuWidget* m = new CMenuWidget(LOCALE_MOVIEBROWSER_YT_HISTORY, NEUTRINO_ICON_MOVIEPLAYER, width); @@ -3750,7 +3750,7 @@ int CDirMenu::exec(CMenuTarget* parent, const std::string & actionKey) { int returnval = menu_return::RETURN_REPAINT; - if (actionKey == "") + if (actionKey.empty()) { if (parent) parent->hide(); diff --git a/src/gui/movieinfo.cpp b/src/gui/movieinfo.cpp index 9609688de..c42307f91 100644 --- a/src/gui/movieinfo.cpp +++ b/src/gui/movieinfo.cpp @@ -382,7 +382,7 @@ bool CMovieInfo::parseXmlTree(char */*text*/, MI_MOVIE_INFO * /*movie_info*/) } delete parser; - if (movie_info->epgInfo2 == "") { + if (movie_info->epgInfo2.empty()) { movie_info->epgInfo2 = movie_info->epgInfo1; //movie_info->epgInfo1 = ""; } @@ -794,7 +794,7 @@ bool CMovieInfo::parseXmlQuickFix(std::string &_text, MI_MOVIE_INFO * movie_info } } - if (movie_info->epgInfo2 == "") { + if (movie_info->epgInfo2.empty()) { movie_info->epgInfo2 = movie_info->epgInfo1; //movie_info->epgInfo1 = ""; } diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp index 17a5c5ac7..7ece99bf1 100644 --- a/src/gui/network_setup.cpp +++ b/src/gui/network_setup.cpp @@ -774,7 +774,7 @@ void CNetworkSetup::testNetworkSettings() text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ":\n"; text += offset + our_nameserver + " " + mypinghost(our_nameserver) + "\n"; //NTPserver - if ( (pinghost(our_nameserver) == 1) && g_settings.network_ntpenable && (g_settings.network_ntpserver != "") ) + if ( (pinghost(our_nameserver) == 1) && g_settings.network_ntpenable && (!g_settings.network_ntpserver.empty()) ) { text += std::string(g_Locale->getText(LOCALE_NETWORKMENU_NTPSERVER)) + ":\n"; text += offset + g_settings.network_ntpserver + " " + mypinghost(g_settings.network_ntpserver) + "\n"; diff --git a/src/gui/opkg_manager.cpp b/src/gui/opkg_manager.cpp index d002b226b..d4773c456 100644 --- a/src/gui/opkg_manager.cpp +++ b/src/gui/opkg_manager.cpp @@ -96,7 +96,7 @@ int COPKGManager::exec(CMenuTarget* parent, const std::string &actionKey) { int res = menu_return::RETURN_REPAINT; - if (actionKey == "") { + if (actionKey.empty()) { if (parent) parent->hide(); return showMenu(); diff --git a/src/gui/osdlang_setup.cpp b/src/gui/osdlang_setup.cpp index 4f72dbdac..a03536ca1 100644 --- a/src/gui/osdlang_setup.cpp +++ b/src/gui/osdlang_setup.cpp @@ -74,7 +74,7 @@ int COsdLangSetup::exec(CMenuTarget* parent, const std::string &actionKey) if(parent != NULL) parent->hide(); - if (actionKey != "") { + if (!actionKey.empty()) { g_settings.language = actionKey; g_Locale->loadLocale(g_settings.language.c_str()); return menu_return::RETURN_EXIT; diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index bcbfe7bb3..bbc91728a 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -412,27 +412,27 @@ int CPersonalizeGui::ShowPersonalizationMenu() g_settings.plugins_lua = ""; for (int i = 0; i < pcount; i++) { if (pltype[i] & CPlugins::P_TYPE_DISABLED) { - if (g_settings.plugins_disabled != "") + if (!g_settings.plugins_disabled.empty()) g_settings.plugins_disabled += ","; g_settings.plugins_disabled += g_PluginList->getFileName(i); g_PluginList->setType(i, CPlugins::P_TYPE_DISABLED); } else if (pltype[i] & CPlugins::P_TYPE_GAME) { - if (g_settings.plugins_game != "") + if (!g_settings.plugins_game.empty()) g_settings.plugins_game += ","; g_settings.plugins_game += g_PluginList->getFileName(i); g_PluginList->setType(i, CPlugins::P_TYPE_GAME); } else if (pltype[i] & CPlugins::P_TYPE_TOOL) { - if (g_settings.plugins_tool != "") + if (!g_settings.plugins_tool.empty()) g_settings.plugins_tool += ","; g_settings.plugins_tool += g_PluginList->getFileName(i); g_PluginList->setType(i, CPlugins::P_TYPE_TOOL); } else if (pltype[i] & CPlugins::P_TYPE_SCRIPT) { - if (g_settings.plugins_script != "") + if (!g_settings.plugins_script.empty()) g_settings.plugins_script += ","; g_settings.plugins_script += g_PluginList->getFileName(i); g_PluginList->setType(i, CPlugins::P_TYPE_SCRIPT); } else if (pltype[i] & CPlugins::P_TYPE_LUA) { - if (g_settings.plugins_lua != "") + if (!g_settings.plugins_lua.empty()) g_settings.plugins_lua += ","; g_settings.plugins_lua += g_PluginList->getFileName(i); g_PluginList->setType(i, CPlugins::P_TYPE_LUA); diff --git a/src/gui/pluginlist.cpp b/src/gui/pluginlist.cpp index 1e5a09e34..544fdcc4d 100644 --- a/src/gui/pluginlist.cpp +++ b/src/gui/pluginlist.cpp @@ -92,7 +92,7 @@ int CPluginList::exec(CMenuTarget* parent, const std::string &actionKey) const char * dummy = NULL; number = -1; - if (actionKey != "") + if (!actionKey.empty()) number = atoi(actionKey.c_str()); if (number > -1) diff --git a/src/gui/proxyserver_setup.cpp b/src/gui/proxyserver_setup.cpp index 25db5d61d..766ae5c7a 100644 --- a/src/gui/proxyserver_setup.cpp +++ b/src/gui/proxyserver_setup.cpp @@ -99,11 +99,11 @@ int CProxySetup::showProxySetup() int res = mn->exec(NULL, ""); delete mn; - if (g_settings.softupdate_proxyserver == "") + if (g_settings.softupdate_proxyserver.empty()) unsetenv("http_proxy"); else { std::string proxy = "http://"; - if (g_settings.softupdate_proxyusername != "") + if (!g_settings.softupdate_proxyusername.empty()) proxy += g_settings.softupdate_proxyusername + ":" + g_settings.softupdate_proxypassword + "@"; proxy += g_settings.softupdate_proxyserver; setenv("http_proxy", proxy.c_str(), 1); diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 1733a89f1..cf465cb4f 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -601,7 +601,7 @@ int CTimerList::show() CEPGData epgdata; CEitManager::getInstance()->getEPGid(timerlist[selected].epgID, timerlist[selected].epg_starttime, &epgdata); memset(buf1, '\0', sizeof(buf1)); - if (epgdata.title != "") + if (!epgdata.title.empty()) title = "(" + epgdata.title + ")\n"; snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_TIMERLIST_ASK_TO_DELETE), title.c_str()); if(ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, diff --git a/src/gui/update_ext.cpp b/src/gui/update_ext.cpp index 06b107b5f..c946c89b5 100644 --- a/src/gui/update_ext.cpp +++ b/src/gui/update_ext.cpp @@ -122,12 +122,12 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str MTDBuf = NULL; } - if (msg2 == "") + if (msg2.empty()) snprintf(buf, sizeof(buf), "%s\n", msg1.c_str()); else snprintf(buf, sizeof(buf), "%s %s\n", msg1.c_str(), msg2.c_str()); - if ((msg1 != "") || (msg2 != "")) { + if ((!msg1.empty()) || (!msg2.empty())) { mtdRamError = buf; WRITE_UPDATE_LOG("ERROR: %s", buf); printf(mtdRamError.c_str()); @@ -176,7 +176,7 @@ bool CExtUpdate::applySettings(std::string & filename, int mode) bool ret = applySettings(); DBG_TIMER_STOP("Image editing") if (!ret) { - if ((mtdRamError != "") && (!flashErrorFlag)) + if ((!mtdRamError.empty()) && (!flashErrorFlag)) DisplayErrorMessage(mtdRamError.c_str()); // error, delete image file @@ -297,7 +297,7 @@ bool CExtUpdate::applySettings() } fclose(f1); - if (mtdRamFilename == "") + if (mtdRamFilename.empty()) return ErrorReset(RESET_UNLOAD, "no mtdram test device found"); else { // check mtdRamSize / mtdRamEraseSize @@ -416,7 +416,7 @@ int fileSelect(const struct dirent *entry) if ((strcmp(entry->d_name, ".") == 0) || (strcmp(entry->d_name, "..") == 0)) return 0; else - if ((Wildcard != "") && (fnmatch(Wildcard.c_str(), entry->d_name, FNM_FILE_NAME))) + if ((!Wildcard.empty()) && (fnmatch(Wildcard.c_str(), entry->d_name, FNM_FILE_NAME))) return 0; else return 1; @@ -515,13 +515,13 @@ bool CExtUpdate::readConfig(const std::string & line) { std::string tmp1 = line; if (findConfigEntry(tmp1, "Log")) { - if (tmp1 != "") + if (!tmp1.empty()) fLogEnabled = atoi(tmp1.c_str()); return true; } tmp1 = line; if (findConfigEntry(tmp1, "LogFile")) { - if (tmp1 != "") + if (!tmp1.empty()) fLogfile = tmp1; return true; } diff --git a/src/gui/widget/listframe.cpp b/src/gui/widget/listframe.cpp index 9336f3d73..2db6ed003 100644 --- a/src/gui/widget/listframe.cpp +++ b/src/gui/widget/listframe.cpp @@ -394,7 +394,7 @@ void CListFrame::refreshScroll(void) int CListFrame::paintListIcon(int x, int y, int line) { int xDiff = 0; - if ((!m_pLines->Icon.empty()) && (m_pLines->Icon[line] != "")) { + if ((!m_pLines->Icon.empty()) && (!m_pLines->Icon[line].empty())) { int icol_w, icol_h; frameBuffer->getIconSize(m_pLines->Icon[line].c_str(), &icol_w, &icol_h); if ((icol_w > 0) && (icol_h > 0)) { diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index ac08137cc..c63bb23a3 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -2264,7 +2264,7 @@ int CLockedMenuForwarder::exec(CMenuTarget* parent) int CMenuSelectorTarget::exec(CMenuTarget* /*parent*/, const std::string & actionKey) { - if (actionKey != "") + if (!actionKey.empty()) *m_select = atoi(actionKey); else *m_select = -1; diff --git a/src/gui/widget/messagebox.cpp b/src/gui/widget/messagebox.cpp index 31c0a6f9e..8921c7ea7 100644 --- a/src/gui/widget/messagebox.cpp +++ b/src/gui/widget/messagebox.cpp @@ -116,7 +116,7 @@ void CMessageBox::Init(const CMessageBox::result_ &Default, const uint32_t ShowB ButtonDistance = (m_width - b_width * ButtonCount) / (ButtonCount + 1); /* this is ugly: re-init (CHintBoxExt) to recalculate the number of lines and pages */ - init(m_caption, m_captionString, m_width, m_iconfile == "" ? NULL : m_iconfile.c_str()); + init(m_caption, m_captionString, m_width, m_iconfile.empty() ? NULL : m_iconfile.c_str()); m_height += m_bbheight; } diff --git a/src/neutrino.cpp b/src/neutrino.cpp index bf91a54a5..238969bf2 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -737,11 +737,11 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.softupdate_proxyusername = configfile.getString("softupdate_proxyusername", "" ); g_settings.softupdate_proxypassword = configfile.getString("softupdate_proxypassword", "" ); // - if (g_settings.softupdate_proxyserver == "") + if (g_settings.softupdate_proxyserver.empty()) unsetenv("http_proxy"); else { std::string proxy = "http://"; - if (g_settings.softupdate_proxyusername != "") + if (!g_settings.softupdate_proxyusername.empty()) proxy += g_settings.softupdate_proxyusername + ":" + g_settings.softupdate_proxypassword + "@"; proxy += g_settings.softupdate_proxyserver; setenv("http_proxy", proxy.c_str(), 1); @@ -810,7 +810,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.epg_search_history.clear(); for(int i = 0; i < g_settings.epg_search_history_size; i++) { std::string s = configfile.getString("epg_search_history_" + to_string(i)); - if (s != "") + if (!s.empty()) g_settings.epg_search_history.push_back(configfile.getString("epg_search_history_" + to_string(i), "")); } g_settings.epg_search_history_size = g_settings.epg_search_history.size(); diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index d880dc90f..64ead34d3 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -73,7 +73,7 @@ CControlAPI::CControlAPI(CNeutrinoAPI *_NeutrinoAPI) //----------------------------------------------------------------------------- void CControlAPI::init(CyhookHandler *hh) { - if(PLUGIN_DIRS[0] == "") + if(PLUGIN_DIRS[0].empty()) { // given in nhttpd.conf PLUGIN_DIRS[0]=PLUGIN_DIRS[1]=hh->WebserverConfigList["WebsiteMain.override_directory"]; PLUGIN_DIRS[1].append("/scripts"); @@ -253,10 +253,10 @@ void CControlAPI::Execute(CyhookHandler *hh) } // send header - else if(std::string(yCgiCallList[index].mime_type) == "") // decide in function + else if(std::string(yCgiCallList[index].mime_type).empty()) // decide in function ; else if(std::string(yCgiCallList[index].mime_type) == "+xml") // Parameter xml? - if ((hh->ParamList["xml"] != "") ||(hh->ParamList["format"] == "xml")) + if ((!hh->ParamList["xml"].empty()) ||(hh->ParamList["format"] == "xml")) hh->SetHeader(HTTP_OK, "text/xml; charset=UTF-8"); else hh->SetHeader(HTTP_OK, "text/html; charset=UTF-8"); @@ -293,7 +293,7 @@ void CControlAPI::TimerCGI(CyhookHandler *hh) NeutrinoAPI->Timerd->removeTimerEvent(removeId); hh->SendOk(); } - else if(hh->ParamList["get"] != "") + else if(!hh->ParamList["get"].empty()) { int pre=0,post=0; NeutrinoAPI->Timerd->getRecordingSafety(pre,post); @@ -695,11 +695,11 @@ void CControlAPI::RCEmCGI(CyhookHandler *hh) { #if 0 unsigned int repeat = 1; unsigned int delay = 250; - if (hh->ParamList["delay"] != "") + if (!hh->ParamList["delay"].empty()) delay = atoi(hh->ParamList["delay"].c_str()); - if (hh->ParamList["duration"] != "") + if (!hh->ParamList["duration"].empty()) repeat = atoi(hh->ParamList["duration"].c_str()) * 1000 / delay; - if (hh->ParamList["repeat"] != "") + if (!hh->ParamList["repeat"].empty()) repeat = atoi(hh->ParamList["repeat"].c_str()); #endif int evd = open(EVENTDEV, O_RDWR); @@ -795,7 +795,7 @@ void CControlAPI::VolumeCGI(CyhookHandler *hh) else if (hh->ParamList["1"].compare("status") == 0) { // Mute status (NeutrinoAPI->Zapit->getMuteStatus()) ? hh->Write("1") : hh->Write("0"); } - else if(hh->ParamList["1"]!="") { //set volume + else if(!hh->ParamList["1"].empty()) { //set volume char vol = atol( hh->ParamList["1"].c_str() ); NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::EVT_SET_VOLUME, CEventServer::INITID_HTTPD, (void *)&vol, sizeof(char)); hh->SendOk(); @@ -855,11 +855,11 @@ std::string CControlAPI::_GetBouquetActualEPGItem(CyhookHandler *hh, CZapitChann } } - result += hh->outPair("isActiveChannel", (channel->channel_id == current_channel) ? "true" : "false", (firstEPG != "")); - if(firstEPG != "") { + result += hh->outPair("isActiveChannel", (channel->channel_id == current_channel) ? "true" : "false", (!firstEPG.empty())); + if(!firstEPG.empty()) { result += hh->outCollection("firstEPG", firstEPG); } - if(secondEPG != "") { + if(!secondEPG.empty()) { result += hh->outNext(); result += hh->outCollection("secondEPG", secondEPG); } @@ -999,7 +999,7 @@ void CControlAPI::GetBouquetCGI(CyhookHandler *hh) { int BouquetNr = -1; // -1 = all bouquets int startBouquet = 0; int bsize = (int) g_bouquetManager->Bouquets.size(); - if (hh->ParamList["bouquet"] != "") { + if (!hh->ParamList["bouquet"].empty()) { // list for given bouquet BouquetNr = atoi(hh->ParamList["bouquet"].c_str()); if (BouquetNr > 0) @@ -1505,7 +1505,7 @@ void CControlAPI::EpgCGI(CyhookHandler *hh) { } } // query details for given eventid - else if (hh->ParamList["eventid"] != "") { + else if (!hh->ParamList["eventid"].empty()) { //special epg query uint64_t epgid = 0; sscanf(hh->ParamList["eventid"].c_str(), "%llu", &epgid); @@ -1516,8 +1516,8 @@ void CControlAPI::EpgCGI(CyhookHandler *hh) { hh->WriteLn(epg.info2); } } - else if (hh->ParamList["eventid2fsk"] != "") { - if (hh->ParamList["starttime"] != "") { + else if (!hh->ParamList["eventid2fsk"].empty()) { + if (!hh->ParamList["starttime"].empty()) { uint64_t epgid = 0; time_t starttime = 0; sscanf(hh->ParamList["fskid"].c_str(), "%llu", &epgid); @@ -1583,7 +1583,7 @@ void CControlAPI::ScreenshotCGI(CyhookHandler *hh) enableOSD = false; if(hh->ParamList["video"] == "0") enableVideo = false; - if(hh->ParamList["name"] != "") + if(!hh->ParamList["name"].empty()) filename = hh->ParamList["name"]; CScreenShot * sc = new CScreenShot("/tmp/" + filename + ".png", (CScreenShot::screenshot_format_t)0 /*PNG*/); @@ -1682,7 +1682,7 @@ void CControlAPI::ZaptoCGI(CyhookHandler *hh) else hh->SendError(); } - else if (hh->ParamList["name"] != "") + else if (!hh->ParamList["name"].empty()) { t_channel_id channel_id; channel_id = NeutrinoAPI->ChannelNameToChannelId(hh->ParamList["name"]); @@ -1712,7 +1712,7 @@ void CControlAPI::StartPluginCGI(CyhookHandler *hh) std::string pluginname; if (!(hh->ParamList.empty())) { - if (hh->ParamList["name"] != "") + if (!hh->ParamList["name"].empty()) { pluginname = hh->ParamList["name"]; //pluginname=decodeString(pluginname); @@ -2208,7 +2208,7 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh) void CControlAPI::YWebCGI(CyhookHandler *hh) { bool status=true; - if (hh->ParamList["video_stream_pids"] != "") + if (!hh->ParamList["video_stream_pids"].empty()) { int para=0; sscanf( hh->ParamList["video_stream_pids"].c_str(), "%d", ¶); @@ -2235,7 +2235,7 @@ void CControlAPI::YWeb_SendVideoStreamingPids(CyhookHandler *hh, int apid_no) apid_idx=apid_no; if(!pids.APIDs.empty()) apid = pids.APIDs[apid_idx].pid; - if(hh->ParamList["no_commas"] != "") + if(!hh->ParamList["no_commas"].empty()) { hh->printf("0x%04x 0x%04x 0x%04x",pids.PIDs.pmtpid,pids.PIDs.vpid,apid); if (pids.PIDs.pcrpid != pids.PIDs.vpid) @@ -2333,17 +2333,17 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) int alHour=0; // if alarm given then in parameters im time_t format - if(hh->ParamList["alarm"] != "") + if(!hh->ParamList["alarm"].empty()) { alarmTimeT = atoi(hh->ParamList["alarm"].c_str()); - if(hh->ParamList["stop"] != "") + if(!hh->ParamList["stop"].empty()) stopTimeT = atoi(hh->ParamList["stop"].c_str()); - if(hh->ParamList["announce"] != "") + if(!hh->ParamList["announce"].empty()) announceTimeT = atoi(hh->ParamList["announce"].c_str()); else announceTimeT = alarmTimeT; } - else if(hh->ParamList["alDate"] != "") //given formatted + else if(!hh->ParamList["alDate"].empty()) //given formatted { // Alarm Date - Format exact! DD.MM.YYYY tnull = time(NULL); @@ -2356,7 +2356,7 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) } // Alarm Time - Format exact! HH:MM - if(hh->ParamList["alTime"] != "") + if(!hh->ParamList["alTime"].empty()) sscanf(hh->ParamList["alTime"].c_str(),"%2d.%2d",&(alarmTime->tm_hour), &(alarmTime->tm_min)); alHour = alarmTime->tm_hour; correctTime(alarmTime); @@ -2365,11 +2365,11 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) struct tm *stopTime = localtime(&alarmTimeT); stopTime->tm_sec = 0; // Stop Time - Format exact! HH:MM - if(hh->ParamList["stTime"] != "") + if(!hh->ParamList["stTime"].empty()) sscanf(hh->ParamList["stTime"].c_str(),"%2d.%2d",&(stopTime->tm_hour), &(stopTime->tm_min)); // Stop Date - Format exact! DD.MM.YYYY - if(hh->ParamList["stDate"] != "") + if(!hh->ParamList["stDate"].empty()) if(sscanf(hh->ParamList["stDate"].c_str(),"%2d.%2d.%4d",&(stopTime->tm_mday), &(stopTime->tm_mon), &(stopTime->tm_year)) == 3) { stopTime->tm_mon -= 1; @@ -2377,7 +2377,7 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) } correctTime(stopTime); stopTimeT = mktime(stopTime); - if(hh->ParamList["stDate"] == "" && alHour > stopTime->tm_hour) + if(hh->ParamList["stDate"].empty() && alHour > stopTime->tm_hour) stopTimeT += 24* 60 * 60; // add 1 Day } else // alarm/stop time given in pieces @@ -2385,15 +2385,15 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) // alarm time time_t now = time(NULL); struct tm *alarmTime=localtime(&now); - if(hh->ParamList["ad"] != "") + if(!hh->ParamList["ad"].empty()) alarmTime->tm_mday = atoi(hh->ParamList["ad"].c_str()); - if(hh->ParamList["amo"] != "") + if(!hh->ParamList["amo"].empty()) alarmTime->tm_mon = atoi(hh->ParamList["amo"].c_str())-1; - if(hh->ParamList["ay"] != "") + if(!hh->ParamList["ay"].empty()) alarmTime->tm_year = atoi(hh->ParamList["ay"].c_str())-1900; - if(hh->ParamList["ah"] != "") + if(!hh->ParamList["ah"].empty()) alarmTime->tm_hour = atoi(hh->ParamList["ah"].c_str()); - if(hh->ParamList["ami"] != "") + if(!hh->ParamList["ami"].empty()) alarmTime->tm_min = atoi(hh->ParamList["ami"].c_str()); alarmTime->tm_sec = 0; correctTime(alarmTime); @@ -2402,15 +2402,15 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) // stop time struct tm *stopTime = alarmTime; - if(hh->ParamList["sd"] != "") + if(!hh->ParamList["sd"].empty()) stopTime->tm_mday = atoi(hh->ParamList["sd"].c_str()); - if(hh->ParamList["smo"] != "") + if(!hh->ParamList["smo"].empty()) stopTime->tm_mon = atoi(hh->ParamList["smo"].c_str())-1; - if(hh->ParamList["sy"] != "") + if(!hh->ParamList["sy"].empty()) stopTime->tm_year = atoi(hh->ParamList["sy"].c_str())-1900; - if(hh->ParamList["sh"] != "") + if(!hh->ParamList["sh"].empty()) stopTime->tm_hour = atoi(hh->ParamList["sh"].c_str()); - if(hh->ParamList["smi"] != "") + if(!hh->ParamList["smi"].empty()) stopTime->tm_min = atoi(hh->ParamList["smi"].c_str()); stopTime->tm_sec = 0; correctTime(stopTime); @@ -2421,22 +2421,22 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) announceTimeT -= 60; CTimerd::CTimerEventTypes type; - if(hh->ParamList["type"] != "") + if(!hh->ParamList["type"].empty()) type = (CTimerd::CTimerEventTypes) atoi(hh->ParamList["type"].c_str()); else // default is: record type = CTimerd::TIMER_RECORD; // repeat - if(hh->ParamList["repcount"] != "") + if(!hh->ParamList["repcount"].empty()) { repCount = atoi(hh->ParamList["repcount"].c_str()); } CTimerd::CTimerEventRepeat rep; - if(hh->ParamList["rep"] != "") + if(!hh->ParamList["rep"].empty()) rep = (CTimerd::CTimerEventRepeat) atoi(hh->ParamList["rep"].c_str()); else // default: no repeat rep = (CTimerd::CTimerEventRepeat)0; - if(((int)rep) >= ((int)CTimerd::TIMERREPEAT_WEEKDAYS) && hh->ParamList["wd"] != "") + if(((int)rep) >= ((int)CTimerd::TIMERREPEAT_WEEKDAYS) && !hh->ParamList["wd"].empty()) NeutrinoAPI->Timerd->getWeekdaysFromStr(&rep, hh->ParamList["wd"]); // apids @@ -2474,7 +2474,7 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) eventinfo.recordingSafety = (hh->ParamList["rs"] == "1"); // channel by Id or name - if(hh->ParamList["channel_id"] != "") + if(!hh->ParamList["channel_id"].empty()) sscanf(hh->ParamList["channel_id"].c_str(), SCANF_CHANNEL_ID_TYPE, &eventinfo.channel_id); @@ -2495,7 +2495,7 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) data= &eventinfo; else if (type==CTimerd::TIMER_RECORD) { - if(_rec_dir == "") + if(_rec_dir.empty()) { // get Default Recordingdir CConfigFile *Config = new CConfigFile(','); @@ -2526,7 +2526,7 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) // update or add timer if(hh->ParamList["update"]=="1") { - if(hh->ParamList["id"] != "") + if(!hh->ParamList["id"].empty()) { unsigned modyId = atoi(hh->ParamList["id"].c_str()); if(type == CTimerd::TIMER_RECORD) @@ -2570,7 +2570,7 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) //------------------------------------------------------------------------- void CControlAPI::setBouquetCGI(CyhookHandler *hh) { - if (hh->ParamList["selected"] != "") { + if (!hh->ParamList["selected"].empty()) { int selected = atoi(hh->ParamList["selected"].c_str()); if(hh->ParamList["action"].compare("hide") == 0) NeutrinoAPI->Zapit->setBouquetHidden(selected - 1,true); @@ -2595,7 +2595,7 @@ void CControlAPI::saveBouquetCGI(CyhookHandler *hh) //------------------------------------------------------------------------- void CControlAPI::moveBouquetCGI(CyhookHandler *hh) { - if (hh->ParamList["selected"] != "" && ( + if (!hh->ParamList["selected"].empty() && ( hh->ParamList["action"] == "up" || hh->ParamList["action"] == "down")) { @@ -2615,7 +2615,7 @@ void CControlAPI::moveBouquetCGI(CyhookHandler *hh) //------------------------------------------------------------------------- void CControlAPI::deleteBouquetCGI(CyhookHandler *hh) { - if (hh->ParamList["selected"] != "") { + if (!hh->ParamList["selected"].empty()) { int selected = atoi(hh->ParamList["selected"].c_str()); NeutrinoAPI->Zapit->deleteBouquet(selected - 1); hh->SendOk(); @@ -2641,9 +2641,9 @@ void CControlAPI::addBouquetCGI(CyhookHandler *hh) //------------------------------------------------------------------------- void CControlAPI::renameBouquetCGI(CyhookHandler *hh) { - if (hh->ParamList["selected"] != "") + if (!hh->ParamList["selected"].empty()) { - if (hh->ParamList["nameto"] != "") + if (!hh->ParamList["nameto"].empty()) { if (NeutrinoAPI->Zapit->existsBouquet((hh->ParamList["nameto"]).c_str()) == -1) { @@ -2684,7 +2684,7 @@ void CControlAPI::changeBouquetCGI(CyhookHandler *hh) NeutrinoAPI->Zapit->renumChannellist(); NeutrinoAPI->UpdateBouquets(); - if(hh->ParamList["redirect"] != "") + if(!hh->ParamList["redirect"].empty()) hh->SendRewrite(hh->ParamList["redirect"]); else hh->SendOk(); @@ -2712,7 +2712,7 @@ void CControlAPI::build_live_url(CyhookHandler *hh) int apid=0,apid_no=0,apid_idx=0; pids.PIDs.vpid=0; - if(hh->ParamList["audio_no"] !="") + if(!hh->ParamList["audio_no"].empty()) apid_no = atoi(hh->ParamList["audio_no"].c_str()); NeutrinoAPI->Zapit->getPIDS(pids); @@ -2740,7 +2740,7 @@ void CControlAPI::build_live_url(CyhookHandler *hh) hh->SendError(); // build url std::string url = ""; - if(hh->ParamList["host"] !="") + if(!hh->ParamList["host"].empty()) url = "http://"+hh->ParamList["host"]; else url = "http://"+hh->HeaderList["Host"]; @@ -2753,7 +2753,7 @@ void CControlAPI::build_live_url(CyhookHandler *hh) url += xpids; // response url - if(hh->ParamList["vlc_link"] !="") + if(!hh->ParamList["vlc_link"].empty()) { write_to_file("/tmp/vlc.m3u", url); hh->SendRedirect("/tmp/vlc.m3u"); @@ -2845,7 +2845,7 @@ void CControlAPI::ConfigCGI(CyhookHandler *hh) { else if (configFileName == "yweb") config_filename = YWEB_CONFIGFILE; - if (config_filename != "") { + if (!config_filename.empty()) { Config->loadConfig(config_filename); if (load) { // get and output list @@ -2875,19 +2875,19 @@ void CControlAPI::ConfigCGI(CyhookHandler *hh) { Config->setString(key, it->second); } } - if (config_filename != "") + if (!config_filename.empty()) Config->saveConfig(config_filename); } } else { - if(configFileName != "") + if(!configFileName.empty()) error = string_printf("no config defined for: %s", (hh->ParamList["config"]).c_str()); else error = "no config given"; } // write footer - if (error == "") { + if (error.empty()) { if (outType == json) { hh->WriteLn(json_out_success(result)); } diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp index d2219e8e7..40d312d23 100644 --- a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp @@ -171,7 +171,7 @@ std::string CNeutrinoYParser::func_mount_get_list(CyhookHandler *, std::string) yip = Config->getString("network_nfs_ip_"+ynr,""); ydir = Config->getString("network_nfs_dir_"+ynr,""); ylocal_dir = Config->getString("network_nfs_local_dir_"+ynr,""); - if(ydir != "") + if(!ydir.empty()) ydir="("+ydir+")"; yresult += string_printf("%d %s - %s %s %s
", @@ -215,7 +215,7 @@ std::string CNeutrinoYParser::func_get_bouquets_as_dropdown(CyhookHandler *, st int nr=1; ySplitString(para," ",nr_str, do_show_hidden); - if(nr_str != "") + if(!nr_str.empty()) nr = atoi(nr_str.c_str()); int mode = NeutrinoAPI->Zapit->getMode(); @@ -286,7 +286,7 @@ std::string CNeutrinoYParser::func_get_channels_as_dropdown(CyhookHandler *, st int mode = NeutrinoAPI->Zapit->getMode(); ySplitString(para," ",abouquet, achannel_id); - if(abouquet != "") + if(!abouquet.empty()) bnumber = atoi(abouquet.c_str()); if(bnumber > 0) { bnumber--; @@ -323,7 +323,7 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std: int mode = NeutrinoAPI->Zapit->getMode(); ySplitString(para," ",abnumber, tmp); - if(abnumber != "") + if(!abnumber.empty()) BouquetNr = atoi(abnumber.c_str()); if (BouquetNr > 0) { BouquetNr--; @@ -351,7 +351,7 @@ std::string CNeutrinoYParser::func_get_bouquets_with_epg(CyhookHandler *hh, std: std::string timestr; bool have_logos = false; - if(hh->WebserverConfigList["Tuxbox.LogosURL"] != "") + if(!hh->WebserverConfigList["Tuxbox.LogosURL"].empty()) have_logos = true; for(int j = 0; j < (int) channels.size(); j++) { @@ -526,7 +526,7 @@ std::string CNeutrinoYParser::func_get_video_pids(CyhookHandler *, std::string int apid=0,apid_no=0,apid_idx=0; pids.PIDs.vpid=0; - if(para != "") + if(!para.empty()) apid_no = atoi(para.c_str()); NeutrinoAPI->Zapit->getPIDS(pids); @@ -714,7 +714,7 @@ std::string CNeutrinoYParser::func_get_partition_list(CyhookHandler *, std::str in >> ymtd >> dummy >> dummy; //format: mtd# start end "name " in.getline(ytmp, 200); // Rest of line is the mtd description yname = ytmp; - if((j>0) && (ymtd != ""))// iggnore first line + if((j>0) && (!ymtd.empty()))// iggnore first line { ysel = ((j==1) ? "checked=\"checked\"" : ""); yresult += string_printf("%d %s
", @@ -976,7 +976,7 @@ std::string CNeutrinoYParser::func_set_timer_form(CyhookHandler *hh, std::strin if(cmd != "new") { // init timerid - if(stimerid != "") + if(!stimerid.empty()) timerId = (unsigned)atoi(stimerid.c_str()); NeutrinoAPI->Timerd->getTimer(timer, timerId); @@ -1119,7 +1119,7 @@ std::string CNeutrinoYParser::func_bouquet_editor_main(CyhookHandler *hh, std:: if (hh->ParamList["saved"] == "1") hh->ParamList["have_saved"]="true"; - if (hh->ParamList["selected"] != "") + if (!hh->ParamList["selected"].empty()) selected = atoi(hh->ParamList["selected"].c_str()); int bouquetSize = (int) g_bouquetManager->Bouquets.size(); diff --git a/src/nhttpd/yhttpd.cpp b/src/nhttpd/yhttpd.cpp index 2f37c1ce9..63da32cee 100644 --- a/src/nhttpd/yhttpd.cpp +++ b/src/nhttpd/yhttpd.cpp @@ -275,7 +275,7 @@ bool Cyhttpd::Configure() { std::string groupname= ConfigList["server.group_name"]; // get user data - if(username != "") + if(!username.empty()) { if((pwd = getpwnam(username.c_str())) == NULL) { @@ -284,7 +284,7 @@ bool Cyhttpd::Configure() { } } // get group data - if(groupname != "") + if(!groupname.empty()) { if((grp = getgrnam(groupname.c_str())) == NULL) { @@ -313,7 +313,7 @@ bool Cyhttpd::Configure() { } #endif #ifdef Y_CONFIG_FEATURE_HTTPD_USER - if(username != "" && pwd != NULL && grp != NULL) + if(!username.empty() && pwd != NULL && grp != NULL) { log_level_printf(2, "set user and groups\n"); @@ -321,7 +321,7 @@ bool Cyhttpd::Configure() { setgid(grp->gr_gid); setgroups(0, NULL); // set user group - if(groupname != "") + if(!groupname.empty()) initgroups(username.c_str(), grp->gr_gid); // set user if(setuid(pwd->pw_uid) == -1) @@ -481,7 +481,7 @@ void Cyhttpd::ReadConfig(void) { HTTPD_STANDARD_PORT)); Config->setString("WebsiteMain.directory", OrgConfig.getString( "PrivatDocRoot", PRIVATEDOCUMENTROOT)); - if (OrgConfig.getString("PublicDocRoot", "") != "") + if (!OrgConfig.getString("PublicDocRoot", "").empty()) Config->setString("WebsiteMain.override_directory", OrgConfig.getString("PublicDocRoot", PRIVATEDOCUMENTROOT)); @@ -512,7 +512,7 @@ void Cyhttpd::ReadConfig(void) { Config->setInt32("configfile.version", CONF_VERSION); Config->setString("Language.selected", HTTPD_DEFAULT_LANGUAGE); Config->setString("Language.directory", HTTPD_LANGUAGEDIR); - if (Config->getString("WebsiteMain.hosted_directory", "") == "") + if (Config->getString("WebsiteMain.hosted_directory", "").empty()) Config->setString("WebsiteMain.hosted_directory", HOSTEDDOCUMENTROOT); Config->saveConfig(HTTPD_CONFIGFILE); } @@ -549,7 +549,7 @@ void Cyhttpd::ReadConfig(void) { "WebsiteMain.hosted_directory", HOSTEDDOCUMENTROOT); // Check location of logos - if (Config->getString("Tuxbox.LogosURL", "") == "") { + if (Config->getString("Tuxbox.LogosURL", "").empty()) { if (access(ConfigList["WebsiteMain.override_directory"] + "/logos", R_OK) == 0) { Config->setString("Tuxbox.LogosURL", ConfigList["WebsiteMain.override_directory"] + "/logos"); have_config = false; //save config diff --git a/src/nhttpd/yhttpd_core/ylanguage.cpp b/src/nhttpd/yhttpd_core/ylanguage.cpp index f417afbef..0e0e5189c 100644 --- a/src/nhttpd/yhttpd_core/ylanguage.cpp +++ b/src/nhttpd/yhttpd_core/ylanguage.cpp @@ -99,9 +99,9 @@ void CLanguage::setLanguage(std::string _language){ //----------------------------------------------------------------------------- std::string CLanguage::getTranslation(std::string id){ std::string trans=ConfigLanguage->getString(id,""); - if(trans=="") + if(trans.empty()) trans=NeutrinoLanguage->getString(id,""); - if(trans=="") + if(trans.empty()) trans=DefaultLanguage->getString(id,""); return trans; } diff --git a/src/nhttpd/yhttpd_core/yrequest.cpp b/src/nhttpd/yhttpd_core/yrequest.cpp index 9c0dbb449..16a1932c0 100644 --- a/src/nhttpd/yhttpd_core/yrequest.cpp +++ b/src/nhttpd/yhttpd_core/yrequest.cpp @@ -59,7 +59,7 @@ bool CWebserverRequest::HandleRequest(void) { start_line = Connection->sock->ReceiveLine(); if (!Connection->sock->isValid) return false; - if (start_line == "") // Socket empty + if (start_line.empty()) // Socket empty { log_level_printf(1, "HandleRequest: End of line not found\n"); Connection->Response.SendError(HTTP_INTERNAL_SERVER_ERROR); @@ -82,7 +82,7 @@ bool CWebserverRequest::HandleRequest(void) { return false; } - if (tmp_line == "") { + if (tmp_line.empty()) { Connection->Response.SendError(HTTP_INTERNAL_SERVER_ERROR); return false; } @@ -252,7 +252,7 @@ bool CWebserverRequest::HandlePost() { std::string raw_header = "", tmp_line = ""; do { tmp_line = Connection->sock->ReceiveLine(); - if (tmp_line == "") // Socket empty + if (tmp_line.empty()) // Socket empty { log_level_printf(1, "HandleRequest: (Header) End of line not found: %s\n", @@ -266,7 +266,7 @@ bool CWebserverRequest::HandlePost() { // read meesage body unsigned int content_len = 0; - if (HeaderList["Content-Length"] != "") + if (!HeaderList["Content-Length"].empty()) content_len = atoi(HeaderList["Content-Length"].c_str()); // Get Rest of Request from Socket diff --git a/src/nhttpd/yhttpd_core/ysocket.cpp b/src/nhttpd/yhttpd_core/ysocket.cpp index e21eb2cff..4b3f4c6cf 100644 --- a/src/nhttpd/yhttpd_core/ysocket.cpp +++ b/src/nhttpd/yhttpd_core/ysocket.cpp @@ -116,12 +116,12 @@ bool CySocket::initSSL(void) aprintf("ySocket:SSL Error: Create SSL_CTX_new : %s\n", ERR_error_string(ERR_get_error(), NULL) ); return false; } - if(SSL_pemfile == "") + if(SSL_pemfile.empty()) { aprintf("ySocket:SSL Error: no pemfile given\n"); return false; } - if(SSL_CA_file != "") // have a CA? + if(!SSL_CA_file.empty()) // have a CA? if(1 != SSL_CTX_load_verify_locations(SSL_ctx, SSL_CA_file.c_str(), NULL)) { aprintf("ySocket:SSL Error: %s CA-File:%s\n",ERR_error_string(ERR_get_error(), NULL), SSL_CA_file.c_str()); diff --git a/src/nhttpd/yhttpd_mods/mod_auth.cpp b/src/nhttpd/yhttpd_mods/mod_auth.cpp index c11a0f046..3defe1ca8 100644 --- a/src/nhttpd/yhttpd_mods/mod_auth.cpp +++ b/src/nhttpd/yhttpd_mods/mod_auth.cpp @@ -17,7 +17,7 @@ THandleStatus CmAuth::Hook_PrepareResponse(CyhookHandler *hh) { // dont check local calls or calls from NoAuthClient if (authenticate) { if ((hh->UrlData["clientaddr"]).find(IADDR_LOCAL) > 0 - && (no_auth_client == "" || (hh->UrlData["clientaddr"]).compare(no_auth_client) != 0)) + && (no_auth_client.empty() || (hh->UrlData["clientaddr"]).compare(no_auth_client) != 0)) { if (!CheckAuth(hh)) { hh->SetError(HTTP_UNAUTHORIZED); @@ -50,7 +50,7 @@ THandleStatus CmAuth::Hook_ReadConfig(CConfigFile *Config, // check if given username an pssword are valid //----------------------------------------------------------------------------- bool CmAuth::CheckAuth(CyhookHandler *hh) { - if (hh->HeaderList["Authorization"] == "") + if (hh->HeaderList["Authorization"].empty()) return false; std::string encodet = hh->HeaderList["Authorization"].substr(6, hh->HeaderList["Authorization"].length() - 6); diff --git a/src/nhttpd/yhttpd_mods/mod_cache.cpp b/src/nhttpd/yhttpd_mods/mod_cache.cpp index 2f410998a..3f2c705a6 100644 --- a/src/nhttpd/yhttpd_mods/mod_cache.cpp +++ b/src/nhttpd/yhttpd_mods/mod_cache.cpp @@ -38,7 +38,7 @@ THandleStatus CmodCache::Hook_PrepareResponse(CyhookHandler *hh) { // Check if modified time_t if_modified_since = (time_t) - 1; - if (hh->HeaderList["If-Modified-Since"] != "") // Have If-Modified-Since Requested by Browser? + if (!hh->HeaderList["If-Modified-Since"].empty()) // Have If-Modified-Since Requested by Browser? { struct tm mod; if (strptime(hh->HeaderList["If-Modified-Since"].c_str(), @@ -227,11 +227,11 @@ void CmodCache::yshowCacheInfo(CyhookHandler *hh) { //------------------------------------------------------------------------- void CmodCache::yCacheClear(CyhookHandler *hh) { std::string result = ""; - if (hh->ParamList["category"] != "") { + if (!hh->ParamList["category"].empty()) { RemoveCategoryFromCache(hh->ParamList["category"]); result = string_printf("Category (%s) removed from cache.
", hh->ParamList["category"].c_str()); - } else if (hh->ParamList["url"] != "") { + } else if (!hh->ParamList["url"].empty()) { RemoveURLFromCache(hh->ParamList["url"]); result = string_printf("URL (%s) removed from cache.
", hh->ParamList["url"].c_str()); diff --git a/src/nhttpd/yhttpd_mods/mod_sendfile.cpp b/src/nhttpd/yhttpd_mods/mod_sendfile.cpp index 22d97b1ae..4f4482ad7 100644 --- a/src/nhttpd/yhttpd_mods/mod_sendfile.cpp +++ b/src/nhttpd/yhttpd_mods/mod_sendfile.cpp @@ -75,7 +75,7 @@ THandleStatus CmodSendfile::Hook_PrepareResponse(CyhookHandler *hh) { #endif //Y_CONFIG_USE_HOSTEDWEB std::string mime = sendfileTypes[hh->UrlData["fileext"]]; - if (((mime != "") || (hh->WebserverConfigList["mod_sendfile.sendAll"] == "true")) + if (((!mime.empty()) || (hh->WebserverConfigList["mod_sendfile.sendAll"] == "true")) && !(hh->UrlData["fileext"] == "yhtm" || hh->UrlData["fileext"] == "yjs" || hh->UrlData["fileext"] == "ysh")) { //TODO: Check allowed directories / actually in GetFileName // build filename @@ -97,7 +97,7 @@ THandleStatus CmodSendfile::Hook_PrepareResponse(CyhookHandler *hh) { // check If-Modified-Since time_t if_modified_since = (time_t) - 1; - if (hh->HeaderList["If-Modified-Since"] != "") { + if (!hh->HeaderList["If-Modified-Since"].empty()) { struct tm mod; if (strptime(hh->HeaderList["If-Modified-Since"].c_str(), RFC1123FMT, &mod) != NULL) { @@ -116,7 +116,7 @@ THandleStatus CmodSendfile::Hook_PrepareResponse(CyhookHandler *hh) { if (modified) { hh->RangeStart = 0; hh->RangeEnd = hh->ContentLength - 1; - const char *range = (hh->HeaderList["Range"] == "") ? NULL : hh->HeaderList["Range"].c_str(); + const char *range = (hh->HeaderList["Range"].empty()) ? NULL : hh->HeaderList["Range"].c_str(); if ((range && (2 != sscanf(range, "bytes=%lld-%lld", &hh->RangeStart, &hh->RangeEnd)) && (1 != sscanf(range, "bytes=%lld-", &hh->RangeStart))) diff --git a/src/nhttpd/yhttpd_mods/mod_weblog.cpp b/src/nhttpd/yhttpd_mods/mod_weblog.cpp index dff16a901..c4bc48776 100644 --- a/src/nhttpd/yhttpd_mods/mod_weblog.cpp +++ b/src/nhttpd/yhttpd_mods/mod_weblog.cpp @@ -63,7 +63,7 @@ THandleStatus CmWebLog::Hook_ReadConfig(CConfigFile *Config, CStringList &) { } //----------------------------------------------------------------------------- bool CmWebLog::OpenLogFile() { - if (WebLogFilename == "") + if (WebLogFilename.empty()) return false; if (WebLogFile == NULL) { bool isNew = false; diff --git a/src/nhttpd/yhttpd_mods/mod_yparser.cpp b/src/nhttpd/yhttpd_mods/mod_yparser.cpp index 44221f20c..35464dbe4 100644 --- a/src/nhttpd/yhttpd_mods/mod_yparser.cpp +++ b/src/nhttpd/yhttpd_mods/mod_yparser.cpp @@ -54,7 +54,7 @@ CyParser::~CyParser(void) { } //----------------------------------------------------------------------------- void CyParser::init(CyhookHandler *hh) { - if (HTML_DIRS[0] == "") { + if (HTML_DIRS[0].empty()) { CyParser::HTML_DIRS[0] = hh->WebserverConfigList["WebsiteMain.override_directory"]; HTML_DIRS[1] = hh->WebserverConfigList["WebsiteMain.directory"]; PLUGIN_DIRS[0]=PLUGIN_DIRS[1] = HTML_DIRS[0]; @@ -133,10 +133,10 @@ void CyParser::Execute(CyhookHandler *hh) { } // send header - if (std::string(yCgiCallList[index].mime_type) == "") // set by self + if (std::string(yCgiCallList[index].mime_type).empty()) // set by self ; else if (std::string(yCgiCallList[index].mime_type) == "+xml") // Parameter xml? - if (hh->ParamList["xml"] != "") + if (!hh->ParamList["xml"].empty()) hh->SetHeader(HTTP_OK, "text/xml"); else hh->SetHeader(HTTP_OK, "text/plain"); @@ -162,22 +162,22 @@ void CyParser::cgi(CyhookHandler *hh) { std::string htmlfilename, yresult, ycmd; if ( !hh->ParamList.empty() ) { - if (hh->ParamList["tmpl"] != "") // for GET and POST + if (!hh->ParamList["tmpl"].empty()) // for GET and POST htmlfilename = hh->ParamList["tmpl"]; else htmlfilename = hh->ParamList["1"]; bool ydebug = false; - if (hh->ParamList["debug"] != "") // switch debug on + if (!hh->ParamList["debug"].empty()) // switch debug on ydebug = true; - if (hh->ParamList["execute"] != "") // execute done first! + if (!hh->ParamList["execute"].empty()) // execute done first! { ycmd = hh->ParamList["execute"]; ycmd = YPARSER_ESCAPE_START + ycmd + YPARSER_ESCAPE_END; yresult = cgi_cmd_parsing(hh, ycmd, ydebug); // parsing engine } // parsing given file - if (htmlfilename != "") + if (!htmlfilename.empty()) yresult = cgi_file_parsing(hh, htmlfilename, ydebug); } else printf("[CyParser] Y-cgi:no parameter given\n"); @@ -237,9 +237,9 @@ void CyParser::ParseAndSendFile(CyhookHandler *hh) { hh->SetHeader(HTTP_OK, "text/html; charset=UTF-8"); if (hh->Method == M_HEAD) return; - if (hh->ParamList["debug"] != "") // switch debug on + if (!hh->ParamList["debug"].empty()) // switch debug on ydebug = true; - if (hh->ParamList["execute"] != "") // execute done first! + if (!hh->ParamList["execute"].empty()) // execute done first! { ycmd = hh->ParamList["execute"]; ycmd = YPARSER_ESCAPE_START + ycmd + YPARSER_ESCAPE_END; @@ -391,7 +391,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) { else if (ycmd_type == "comment") { std::string comment_y, comment_html; if (ySplitString(ycmd_name, "~", comment_y, comment_html)) { - if (comment_html != "") + if (!comment_html.empty()) yresult = ""; } } else if (ycmd_type == "script") @@ -400,7 +400,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) { std::string if_value, if_then, if_else; if (ySplitString(ycmd_name, "~", if_value, if_then)) { ySplitString(if_then, "~", if_then, if_else); - yresult = (if_value == "") ? if_then : if_else; + yresult = (if_value.empty()) ? if_then : if_else; } } else if (ycmd_type == "if-equal") { std::string if_left_value, if_right_value, if_then, if_else; @@ -451,7 +451,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) { if (ySplitString(filename, ";", filename, tmp)) { ySplitString(tmp, ";", varname, ydefault); yresult = YWeb_cgi_get_ini(hh, filename, varname, yaccess); - if (yresult == "" && ydefault != "") + if (yresult.empty() && !ydefault.empty()) yresult = ydefault; } else yresult = "ycgi: ini-get: no ; found"; @@ -501,7 +501,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) { } } else yresult = "ycgi-type unknown"; - } else if (hh->ParamList[ycmd] != "") { + } else if (!hh->ParamList[ycmd].empty()) { if ((hh->ParamList[ycmd]).find("script") == std::string::npos) yresult = hh->ParamList[ycmd]; else @@ -518,7 +518,7 @@ std::string CyParser::YWeb_cgi_cmd(CyhookHandler *hh, std::string ycmd) { std::string CyParser::YWeb_cgi_get_ini(CyhookHandler *, std::string filename, std::string varname, std::string yaccess) { std::string result; - if ((yaccess == "open") || (yaccess == "")) { + if ((yaccess == "open") || (yaccess.empty())) { yConfig->clear(); yConfig->loadConfig(filename); } @@ -532,12 +532,12 @@ std::string CyParser::YWeb_cgi_get_ini(CyhookHandler *, std::string filename, //------------------------------------------------------------------------- void CyParser::YWeb_cgi_set_ini(CyhookHandler *, std::string filename, std::string varname, std::string varvalue, std::string yaccess) { - if ((yaccess == "open") || (yaccess == "")) { + if ((yaccess == "open") || (yaccess.empty())) { yConfig->clear(); yConfig->loadConfig(filename); } yConfig->setString(varname, varvalue); - if ((yaccess == "save") || (yaccess == "")) + if ((yaccess == "save") || (yaccess.empty())) yConfig->saveConfig(filename); } @@ -732,7 +732,7 @@ std::string CyParser::func_do_reload_httpd_config(CyhookHandler *, std::string) // y-func : Change httpd (process image) on the fly //------------------------------------------------------------------------- std::string CyParser::func_change_httpd(CyhookHandler *hh, std::string para) { - if (para != "" && access(para, R_OK) == 0) { + if (!para.empty() && access(para, R_OK) == 0) { hh->status = HANDLED_ABORT; char * argv[2] = { (char *)para.c_str(), NULL }; int err = execvp(argv[0], argv); // no return if successful @@ -771,7 +771,7 @@ std::string CyParser::func_get_languages_as_dropdown(CyhookHandler *, // y-func : get_header_data //------------------------------------------------------------------------- std::string CyParser::func_set_language(CyhookHandler *, std::string para) { - if (para != "") { + if (!para.empty()) { CConfigFile *Config = new CConfigFile(','); Config->loadConfig(HTTPD_CONFIGFILE); Config->setString("Language.selected", para); diff --git a/src/system/ytcache.cpp b/src/system/ytcache.cpp index 0463d8531..7e15acf35 100644 --- a/src/system/ytcache.cpp +++ b/src/system/ytcache.cpp @@ -151,9 +151,9 @@ bool cYTCache::download(MI_MOVIE_INFO *mi) char cerror[CURL_ERROR_SIZE]; curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, cerror); - if(g_settings.softupdate_proxyserver != "") { + if(!g_settings.softupdate_proxyserver.empty()) { curl_easy_setopt(curl, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str()); - if(g_settings.softupdate_proxyusername != "") { + if(!g_settings.softupdate_proxyusername.empty()) { std::string tmp = g_settings.softupdate_proxyusername + ":" + g_settings.softupdate_proxypassword; curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, tmp.c_str()); } diff --git a/src/system/ytparser.cpp b/src/system/ytparser.cpp index 6a244043c..bb785c02f 100644 --- a/src/system/ytparser.cpp +++ b/src/system/ytparser.cpp @@ -134,9 +134,9 @@ bool cYTFeedParser::getUrl(std::string &url, std::string &answer, CURL *_curl_ha curl_easy_setopt(_curl_handle, CURLOPT_TIMEOUT, URL_TIMEOUT); curl_easy_setopt(_curl_handle, CURLOPT_NOSIGNAL, (long)1); - if(g_settings.softupdate_proxyserver != "") { + if(!g_settings.softupdate_proxyserver.empty()) { curl_easy_setopt(_curl_handle, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str()); - if(g_settings.softupdate_proxyusername != "") { + if(!g_settings.softupdate_proxyusername.empty()) { std::string tmp = g_settings.softupdate_proxyusername + ":" + g_settings.softupdate_proxypassword; curl_easy_setopt(_curl_handle, CURLOPT_PROXYUSERPWD, tmp.c_str()); } @@ -174,9 +174,9 @@ bool cYTFeedParser::DownloadUrl(std::string &url, std::string &file, CURL *_curl curl_easy_setopt(_curl_handle, CURLOPT_TIMEOUT, URL_TIMEOUT); curl_easy_setopt(_curl_handle, CURLOPT_NOSIGNAL, (long)1); - if(g_settings.softupdate_proxyserver != "") { + if(!g_settings.softupdate_proxyserver.empty()) { curl_easy_setopt(_curl_handle, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str()); - if(g_settings.softupdate_proxyusername != "") { + if(!g_settings.softupdate_proxyusername.empty()) { std::string tmp = g_settings.softupdate_proxyusername + ":" + g_settings.softupdate_proxypassword; curl_easy_setopt(_curl_handle, CURLOPT_PROXYUSERPWD, tmp.c_str()); }