use empty to check string

This commit is contained in:
Jacek Jendrzej
2015-01-09 17:15:11 +01:00
parent aea7e1f772
commit 2b5e7b5ba3
34 changed files with 170 additions and 170 deletions

View File

@@ -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", &para);
@@ -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));
}