- timerlist: formatting code using astyle; some manual code nicenings

Conflicts:
	src/gui/timerlist.cpp

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
svenhoefer
2021-12-06 05:18:19 +01:00
committed by Thilo Graf
parent 7665fcec9f
commit ee297bc77a
2 changed files with 618 additions and 598 deletions

View File

@@ -136,9 +136,7 @@ public:
m1->setActive(false); m1->setActive(false);
m6->setActive(false); m6->setActive(false);
} }
if (type == CTimerd::TIMER_RECORD || if (type == CTimerd::TIMER_RECORD || type == CTimerd::TIMER_ZAPTO /*|| type == CTimerd::TIMER_NEXTPROGRAM*/)
type == CTimerd::TIMER_ZAPTO)
/*|| type == CTimerd::TIMER_NEXTPROGRAM)*/
{ {
m2->setActive(true); m2->setActive(true);
} }
@@ -256,7 +254,8 @@ public:
} }
}; };
std::string string_printf_helper(const char *fmt, ...) { std::string string_printf_helper(const char *fmt, ...)
{
va_list arglist; va_list arglist;
const int bufferlen = 4 * 1024; const int bufferlen = 4 * 1024;
char buffer[bufferlen] = {0}; char buffer[bufferlen] = {0};
@@ -474,11 +473,13 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
r_url += "&channel_id=" + string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timerlist[selected].channel_id); r_url += "&channel_id=" + string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timerlist[selected].channel_id);
r_url += "&aj=on"; r_url += "&aj=on";
r_url += "&rs=on"; r_url += "&rs=on";
if (timerlist[selected].eventRepeat > CTimerd::TIMERREPEAT_ONCE) { if (timerlist[selected].eventRepeat > CTimerd::TIMERREPEAT_ONCE)
{
r_url += "&rep=" + to_string((int)timerlist[selected].eventRepeat); r_url += "&rep=" + to_string((int)timerlist[selected].eventRepeat);
r_url += "&repcount=" + to_string((int)timerlist[selected].repeatCount); r_url += "&repcount=" + to_string((int)timerlist[selected].repeatCount);
} }
if (timerlist[selected].eventRepeat >= CTimerd::TIMERREPEAT_WEEKDAYS) { if (timerlist[selected].eventRepeat >= CTimerd::TIMERREPEAT_WEEKDAYS)
{
Timer->setWeekdaysToStr(timerlist[selected].eventRepeat, m_weekdaysStr); Timer->setWeekdaysToStr(timerlist[selected].eventRepeat, m_weekdaysStr);
r_url += "&wd=" + m_weekdaysStr; r_url += "&wd=" + m_weekdaysStr;
} }
@@ -546,11 +547,13 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
r_url += "&channel_id=" + string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timerlist[selected].channel_id); r_url += "&channel_id=" + string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timerlist[selected].channel_id);
r_url += "&aj=on"; r_url += "&aj=on";
r_url += "&rs=on"; r_url += "&rs=on";
if (timerlist[selected].eventRepeat > CTimerd::TIMERREPEAT_ONCE) { if (timerlist[selected].eventRepeat > CTimerd::TIMERREPEAT_ONCE)
{
r_url += "&rep=" + to_string((int)timerlist[selected].eventRepeat); r_url += "&rep=" + to_string((int)timerlist[selected].eventRepeat);
r_url += "&repcount=" + to_string((int)timerlist[selected].repeatCount); r_url += "&repcount=" + to_string((int)timerlist[selected].repeatCount);
} }
if (timerlist[selected].eventRepeat >= CTimerd::TIMERREPEAT_WEEKDAYS) { if (timerlist[selected].eventRepeat >= CTimerd::TIMERREPEAT_WEEKDAYS)
{
Timer->setWeekdaysToStr(timerlist[selected].eventRepeat, m_weekdaysStr); Timer->setWeekdaysToStr(timerlist[selected].eventRepeat, m_weekdaysStr);
r_url += "&wd=" + m_weekdaysStr; r_url += "&wd=" + m_weekdaysStr;
} }
@@ -573,7 +576,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
void *data = NULL; void *data = NULL;
if (timerNew.eventType == CTimerd::TIMER_STANDBY) if (timerNew.eventType == CTimerd::TIMER_STANDBY)
data = &(timerNew.standby_on); data = &(timerNew.standby_on);
/* else if (timerNew.eventType==CTimerd::TIMER_NEXTPROGRAM || */ //else if (timerNew.eventType==CTimerd::TIMER_NEXTPROGRAM ||
else if (timerNew.eventType == CTimerd::TIMER_ZAPTO || else if (timerNew.eventType == CTimerd::TIMER_ZAPTO ||
timerNew.eventType == CTimerd::TIMER_RECORD) timerNew.eventType == CTimerd::TIMER_RECORD)
{ {
@@ -945,7 +948,8 @@ int CTimerList::show()
|| (msg == CRCInput::RC_timer || msg == CRCInput::RC_program) || (msg == CRCInput::RC_timer || msg == CRCInput::RC_program)
|| (msg == CRCInput::RC_ok && timerlist.empty()) || (msg == CRCInput::RC_ok && timerlist.empty())
) )
{ //Exit after timeout or cancel key {
// Exit after timeout or cancel key
if (fader.StartFadeOut()) if (fader.StartFadeOut())
{ {
timeoutEnd = CRCInput::calcTimeoutEnd(1); timeoutEnd = CRCInput::calcTimeoutEnd(1);
@@ -1228,6 +1232,11 @@ void CTimerList::paintItem(int pos)
if (currpos < timerlist.size()) if (currpos < timerlist.size())
{ {
CTimerd::responseGetTimer &timer = timerlist[currpos]; CTimerd::responseGetTimer &timer = timerlist[currpos];
if (timer.eventType == CTimerd::TIMER_REMOTEBOX)
{
color = COL_MENUCONTENTINACTIVE_TEXT;
bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0;
}
char zAlarmTime[25] = {0}; char zAlarmTime[25] = {0};
struct tm *alarmTime = localtime(&(timer.alarmTime)); struct tm *alarmTime = localtime(&(timer.alarmTime));
strftime(zAlarmTime, 20, "%d.%m. %H:%M", alarmTime); strftime(zAlarmTime, 20, "%d.%m. %H:%M", alarmTime);
@@ -1284,7 +1293,8 @@ void CTimerList::paintItem(int pos)
case CTimerd::TIMER_ZAPTO: case CTimerd::TIMER_ZAPTO:
case CTimerd::TIMER_RECORD: case CTimerd::TIMER_RECORD:
{ {
zAddData = convertChannelId2String(timer.channel_id); // UTF-8 zAddData = convertChannelId2String(timer.channel_id);
// zAddData += timer.channel_ci ? " (CI)" : ""; // FIXME: channel_ci not available
if (timer.apids != TIMERD_APIDS_CONF) if (timer.apids != TIMERD_APIDS_CONF)
{ {
std::string sep = ""; std::string sep = "";
@@ -1342,7 +1352,8 @@ void CTimerList::paintItem(int pos)
std::string errMsg = ""; std::string errMsg = "";
Json::Value root; Json::Value root;
bool ok = parseJsonFromString(r_url, &root, &errMsg); bool ok = parseJsonFromString(r_url, &root, &errMsg);
if (!ok) { if (!ok)
{
printf("Failed to parse JSON\n"); printf("Failed to parse JSON\n");
printf("%s\n", errMsg.c_str()); printf("%s\n", errMsg.c_str());
} }
@@ -1450,7 +1461,7 @@ void CTimerList::paintFoot()
if (timer != NULL) if (timer != NULL)
{ {
// replace info button with dummy if timer is not type REC or ZAP // replace info button with dummy if timer is not type REC or ZAP
if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_REMOTEBOX || timer->eventType == CTimerd::TIMER_ZAPTO) if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_ZAPTO || timer->eventType == CTimerd::TIMER_REMOTEBOX)
TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_INFO_SMALL; TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_INFO_SMALL;
else else
TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_DUMMY_SMALL; TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_DUMMY_SMALL;
@@ -1478,6 +1489,9 @@ void CTimerList::paint()
CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, g_Locale->getText(LOCALE_TIMERLIST_NAME)); CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8, g_Locale->getText(LOCALE_TIMERLIST_NAME));
paintHead(); paintHead();
// paint plain background and footer first to avoid flicker effects while timerlist construction
frameBuffer->paintBoxRel(x, y + header_height, width, item_height * listmaxshow, COL_MENUCONTENT_PLUS_0);
paintFoot();
for (unsigned int count = 0; count < listmaxshow; count++) for (unsigned int count = 0; count < listmaxshow; count++)
{ {
paintItem(count); paintItem(count);
@@ -1495,7 +1509,7 @@ void CTimerList::paint()
visible = true; visible = true;
} }
const char * CTimerList::convertTimerType2String(const CTimerd::CTimerEventTypes type) // UTF-8 const char *CTimerList::convertTimerType2String(const CTimerd::CTimerEventTypes type)
{ {
switch (type) switch (type)
{ {
@@ -1522,7 +1536,7 @@ const char * CTimerList::convertTimerType2String(const CTimerd::CTimerEventTypes
} }
} }
std::string CTimerList::convertTimerRepeat2String(const CTimerd::CTimerEventRepeat rep) // UTF-8 std::string CTimerList::convertTimerRepeat2String(const CTimerd::CTimerEventRepeat rep)
{ {
switch (rep) switch (rep)
{ {
@@ -1572,7 +1586,7 @@ std::string CTimerList::convertTimerRepeat2String(const CTimerd::CTimerEventRepe
} }
} }
std::string CTimerList::convertChannelId2String(const t_channel_id id) // UTF-8 std::string CTimerList::convertChannelId2String(const t_channel_id id)
{ {
std::string name = CServiceManager::getInstance()->GetServiceName(id); std::string name = CServiceManager::getInstance()->GetServiceName(id);
if (name.empty()) if (name.empty())
@@ -1634,7 +1648,7 @@ int CTimerList::modifyTimer()
timerSettings.addIntroItems(); timerSettings.addIntroItems();
char type[80]; char type[80];
strcpy(type, convertTimerType2String(timer->eventType)); // UTF strcpy(type, convertTimerType2String(timer->eventType));
CMenuForwarder *m0 = new CMenuForwarder(LOCALE_TIMERLIST_TYPE, false, type); CMenuForwarder *m0 = new CMenuForwarder(LOCALE_TIMERLIST_TYPE, false, type);
timerSettings.addItem(m0); timerSettings.addItem(m0);
@@ -1822,15 +1836,10 @@ int CTimerList::newTimer()
CMenuForwarder *m9 = new CMenuForwarder(LOCALE_TIMERLIST_MESSAGE, false, timerNew_message, &timerSettings_msg); CMenuForwarder *m9 = new CMenuForwarder(LOCALE_TIMERLIST_MESSAGE, false, timerNew_message, &timerSettings_msg);
timerNew_pluginName = "---"; timerNew_pluginName = "---";
CPluginChooser plugin_chooser(LOCALE_TIMERLIST_PLUGIN, CPlugins::P_TYPE_SCRIPT | CPlugins::P_TYPE_TOOL CPluginChooser plugin_chooser(LOCALE_TIMERLIST_PLUGIN, CPlugins::P_TYPE_SCRIPT | CPlugins::P_TYPE_TOOL | CPlugins::P_TYPE_LUA, timerNew_pluginName);
| CPlugins::P_TYPE_LUA
, timerNew_pluginName);
CMenuForwarder *m10 = new CMenuForwarder(LOCALE_TIMERLIST_PLUGIN, false, timerNew_pluginName, &plugin_chooser); CMenuForwarder *m10 = new CMenuForwarder(LOCALE_TIMERLIST_PLUGIN, false, timerNew_pluginName, &plugin_chooser);
CTimerListNewNotifier notifier2((int *)&timerNew.eventType, &timerNew.stopTime, m2, m6, m8, m9, m10, m7, &timerSettings_stopTime.getValue());
CTimerListNewNotifier notifier2((int *)&timerNew.eventType,
&timerNew.stopTime,m2,m6,m8,m9,m10,m7,
&timerSettings_stopTime.getValue());
CMenuOptionChooser *m0; CMenuOptionChooser *m0;
if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF) if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF)
m0 = new CMenuOptionChooser(LOCALE_TIMERLIST_TYPE, (int *)&timerNew.eventType, TIMERLIST_TYPE_OPTIONS, TIMERLIST_TYPE_OPTION_COUNT, true, &notifier2, CRCInput::RC_nokey, "", true, true); m0 = new CMenuOptionChooser(LOCALE_TIMERLIST_TYPE, (int *)&timerNew.eventType, TIMERLIST_TYPE_OPTIONS, TIMERLIST_TYPE_OPTION_COUNT, true, &notifier2, CRCInput::RC_nokey, "", true, true);
@@ -1901,7 +1910,7 @@ bool CTimerList::askUserOnRemoteTimerConflict(time_t announceTime, time_t stopTi
{ {
timerbuf += CTimerList::convertTimerType2String(it->eventType); timerbuf += CTimerList::convertTimerType2String(it->eventType);
timerbuf += " ("; timerbuf += " (";
timerbuf += CTimerList::convertChannelId2String(it->channel_id); // UTF-8 timerbuf += CTimerList::convertChannelId2String(it->channel_id);
if (it->epg_id != 0) if (it->epg_id != 0)
{ {
CEPGData epgdata; CEPGData epgdata;
@@ -1932,16 +1941,24 @@ bool CTimerList::askUserOnRemoteTimerConflict(time_t announceTime, time_t stopTi
bool askUserOnTimerConflict(time_t announceTime, time_t stopTime, t_channel_id channel_id) bool askUserOnTimerConflict(time_t announceTime, time_t stopTime, t_channel_id channel_id)
{ {
if (CFEManager::getInstance()->getEnabledCount() == 1) { bool useCI = false;
CZapitChannel *channel = CServiceManager::getInstance()->FindChannel(channel_id);
if (channel)
useCI = channel->bUseCI;
if (CFEManager::getInstance()->getEnabledCount() == 1 || useCI)
{
CTimerdClient Timer; CTimerdClient Timer;
CTimerd::TimerList overlappingTimers = Timer.getOverlappingTimers(announceTime, stopTime); CTimerd::TimerList overlappingTimers = Timer.getOverlappingTimers(announceTime, stopTime);
//printf("[CTimerdClient] attention\n%d\t%d\t%d conflicts with:\n",timerNew.announceTime,timerNew.alarmTime,timerNew.stopTime); //printf("[CTimerdClient] attention\n%d\t%d\t%d conflicts with:\n",timerNew.announceTime,timerNew.alarmTime,timerNew.stopTime);
// Don't ask if there are overlapping timers on the same transponder. // Don't ask if there are overlapping timers on the same transponder.
if (channel_id) { if (channel_id)
{
CTimerd::TimerList::iterator i; CTimerd::TimerList::iterator i;
for (i = overlappingTimers.begin(); i != overlappingTimers.end(); i++) for (i = overlappingTimers.begin(); i != overlappingTimers.end(); i++)
if ((i->eventType != CTimerd::TIMER_RECORD || !SAME_TRANSPONDER(channel_id, i->channel_id))) //if ((i->eventType != CTimerd::TIMER_RECORD || !SAME_TRANSPONDER(channel_id, i->channel_id)))
if ((i->eventType != CTimerd::TIMER_RECORD || !SAME_TRANSPONDER(channel_id, i->channel_id && !useCI) /*|| (useCI && i->channel_ci)*/)) // FIXME: channel_ci not available
break; break;
if (i == overlappingTimers.end()) if (i == overlappingTimers.end())
return true; // yes, add timer return true; // yes, add timer
@@ -1951,9 +1968,12 @@ bool askUserOnTimerConflict(time_t announceTime, time_t stopTime, t_channel_id c
timerbuf += "\n"; timerbuf += "\n";
for (CTimerd::TimerList::iterator it = overlappingTimers.begin(); it != overlappingTimers.end(); ++it) for (CTimerd::TimerList::iterator it = overlappingTimers.begin(); it != overlappingTimers.end(); ++it)
{ {
// if (useCI && !it->channel_ci) // FIXME: channel_ci not available
// continue;
timerbuf += CTimerList::convertTimerType2String(it->eventType); timerbuf += CTimerList::convertTimerType2String(it->eventType);
timerbuf += " ("; timerbuf += " (";
timerbuf += CTimerList::convertChannelId2String(it->channel_id); // UTF-8 timerbuf += CTimerList::convertChannelId2String(it->channel_id);
if (it->epg_id != 0) if (it->epg_id != 0)
{ {
CEPGData epgdata; CEPGData epgdata;
@@ -1978,7 +1998,7 @@ bool askUserOnTimerConflict(time_t announceTime, time_t stopTime, t_channel_id c
//printf("%d\t%d\t%d\n",it->announceTime,it->alarmTime,it->stopTime); //printf("%d\t%d\t%d\n",it->announceTime,it->alarmTime,it->stopTime);
} }
//printf("message:\n%s\n",timerbuf.c_str()); //printf("message:\n%s\n",timerbuf.c_str());
// todo: localize message // TODO: localize message
//g_Locale->getText(TIMERLIST_OVERLAPPING_MESSAGE); //g_Locale->getText(TIMERLIST_OVERLAPPING_MESSAGE);
return (ShowMsg(LOCALE_MESSAGEBOX_INFO, timerbuf, CMsgBox::mbrNo, CMsgBox::mbNo | CMsgBox::mbYes) == CMsgBox::mbrYes); return (ShowMsg(LOCALE_MESSAGEBOX_INFO, timerbuf, CMsgBox::mbrNo, CMsgBox::mbNo | CMsgBox::mbYes) == CMsgBox::mbrYes);

View File

@@ -86,7 +86,7 @@ class CTimerList : public CMenuTarget, public CListHelpers
void hide(); void hide();
int modifyTimer(); int modifyTimer();
int newTimer(); int newTimer();
/* todo: properly import the enum CVFD::MODES */ // TODO: properly import the enum CVFD::MODES
CVFD::MODES saved_displaymode; CVFD::MODES saved_displaymode;
bool RemoteBoxSetup(); bool RemoteBoxSetup();
void RemoteBoxSelect(); void RemoteBoxSelect();
@@ -106,9 +106,9 @@ class CTimerList : public CMenuTarget, public CListHelpers
void updateEvents(void); void updateEvents(void);
int show(); int show();
int exec(CMenuTarget *parent, const std::string &actionKey); int exec(CMenuTarget *parent, const std::string &actionKey);
static const char * convertTimerType2String(const CTimerd::CTimerEventTypes type); // UTF-8 static const char *convertTimerType2String(const CTimerd::CTimerEventTypes type);
static std::string convertTimerRepeat2String(const CTimerd::CTimerEventRepeat rep); // UTF-8 static std::string convertTimerRepeat2String(const CTimerd::CTimerEventRepeat rep);
static std::string convertChannelId2String(const t_channel_id id); // UTF-8 static std::string convertChannelId2String(const t_channel_id id);
void RemoteBoxTimerList(CTimerd::TimerList &timerlist); void RemoteBoxTimerList(CTimerd::TimerList &timerlist);
}; };