diff --git a/configure.ac b/configure.ac index 5e00a3065..e02797435 100644 --- a/configure.ac +++ b/configure.ac @@ -204,12 +204,24 @@ AC_ARG_ENABLE(pip, [AC_DEFINE(ENABLE_PIP,1,[enable picture in picture support])]) +AC_ARG_ENABLE(testmenu, + AS_HELP_STRING(--enable-testmenu,include test menu in neutrino main menu)) + AM_CONDITIONAL(ENABLE_TEST_MENU,test "$enable_testmenu" = "yes") if test "$enable_testmenu" = "yes"; then AC_DEFINE(ENABLE_TEST_MENU,1,[include test menu in neutrino main menu - not recommended for general users!]) fi +AC_ARG_ENABLE(lua, + AS_HELP_STRING(--enable-lua,enable LUA support)) + +AM_CONDITIONAL(ENABLE_LUA,test "$enable_lua" = "yes") +if test "$enable_lua" = "yes"; then + AC_DEFINE(ENABLE_LUA,1,[include LUA support]) +fi + + if test "$BOXTYPE" = "coolstream"; then if test -e ${srcdir}/lib/libcoolstream/nevis_ir.h; then AC_DEFINE(HAVE_COOLSTREAM_NEVIS_IR_H,1,[Define to 1 if you have the header file.]) diff --git a/cross-configure.apollo.debug b/cross-configure.apollo.debug index 4d7e066fe..de760d9fd 100755 --- a/cross-configure.apollo.debug +++ b/cross-configure.apollo.debug @@ -29,5 +29,5 @@ export FREETYPE_CONFIG=$PREFIX/bin/freetype-config export CURL_CONFIG=$PREFIX/bin/curl-config ./autogen.sh -./configure --prefix=${PREFIX} --build=i386-pc-linux-gnu --host=$HOST --enable-flac --with-target=cdk --with-targetprefix="" --with-boxmodel=apollo --enable-mdev "$@" +./configure --prefix=${PREFIX} --build=i386-pc-linux-gnu --host=$HOST --enable-flac --with-target=cdk --with-targetprefix="" --with-boxmodel=apollo --enable-mdev --enable-pip --enable-ffmpegdec --enable-lua "$@" diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 22d576738..b6fa01057 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -718,6 +718,7 @@ lcdmenu.dim_brightness nach Dimm-Timeout lcdmenu.dim_time Dimm-Timeout lcdmenu.head VFD Einstellungen lcdmenu.lcdcontroler Helligkeit +lcdmenu.scroll Laufschrift lcdmenu.statusline Statuszeile lcdmenu.statusline.both Lautstärke/Fortschritt lcdmenu.statusline.playtime Sendungsfortschritt @@ -1173,6 +1174,7 @@ menu.hint_vfd_brightnessstandby Definiert die Helligkeit im Standby-Modus menu.hint_vfd_defaults Zurücksetzen der Helligkeitswerte auf die Standardeinstellungen menu.hint_vfd_dimtime Geben Sie einen Wert in Sekunden ein, nachdem sich das Display automatisch auf den gewünschten Wert dimmt menu.hint_vfd_infoline Wählen Sie, was in der Infozeile angezeigt werden soll +menu.hint_vfd_scroll Laufschrift im Display ein- oder ausschalten menu.hint_vfd_statusline Wählen Sie, was in der Statuszeile angezeigt werden soll menu.hint_video Video-Ausgang, Auflösung, Format, Seitenverhältnisse und mehr menu.hint_video_43mode Anzeige-Modus für 4:3-Inhalte auf 16:9-Fernsehern diff --git a/lib/libcoolstream/mmi.h b/lib/libcoolstream/mmi.h index 96266ea44..e32ce198e 100644 --- a/lib/libcoolstream/mmi.h +++ b/lib/libcoolstream/mmi.h @@ -47,8 +47,8 @@ typedef struct { typedef struct { int blind; int answerlen; - char enguiryText[MAX_MMI_TEXT_LEN]; -} MMI_ENGUIRY_INFO; + char enquiryText[MAX_MMI_TEXT_LEN]; +} MMI_ENQUIRY_INFO; #endif // __MMI_H_ diff --git a/lib/libcoolstream2/mmi.h b/lib/libcoolstream2/mmi.h index 96266ea44..e32ce198e 100644 --- a/lib/libcoolstream2/mmi.h +++ b/lib/libcoolstream2/mmi.h @@ -47,8 +47,8 @@ typedef struct { typedef struct { int blind; int answerlen; - char enguiryText[MAX_MMI_TEXT_LEN]; -} MMI_ENGUIRY_INFO; + char enquiryText[MAX_MMI_TEXT_LEN]; +} MMI_ENQUIRY_INFO; #endif // __MMI_H_ diff --git a/lib/timerdclient/timerdclient.cpp b/lib/timerdclient/timerdclient.cpp index 2372a8a02..1d441efba 100644 --- a/lib/timerdclient/timerdclient.cpp +++ b/lib/timerdclient/timerdclient.cpp @@ -449,8 +449,10 @@ void CTimerdClient::getRecordingSafety(int &pre, int &post) //------------------------------------------------------------------------- //void CTimerdClient::getWeekdaysFromStr(int *rep, const char* str) -void CTimerdClient::getWeekdaysFromStr(CTimerd::CTimerEventRepeat *eventRepeat, const char* str) +void CTimerdClient::getWeekdaysFromStr(CTimerd::CTimerEventRepeat *eventRepeat, std::string &str) { + if (str.length() < 7) + str.append(7 - str.length(), '-'); int rep = (int) *eventRepeat; if(rep >= (int)CTimerd::TIMERREPEAT_WEEKDAYS) { @@ -469,21 +471,22 @@ void CTimerdClient::getWeekdaysFromStr(CTimerd::CTimerEventRepeat *eventRepeat, *eventRepeat = (CTimerd::CTimerEventRepeat) rep; } //------------------------------------------------------------------------- -void CTimerdClient::setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, char* str) +void CTimerdClient::setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, std::string &str) { + if (str.length() < 7) + str.append(7 - str.length(), '-'); if(rep >= CTimerd::TIMERREPEAT_WEEKDAYS) { for(int n=0;n<7;n++) { if(rep & (1 << (n+9))) - str[n]='X'; + str.at(n)='X'; else - str[n]='-'; + str.at(n)='-'; } - str[7]=0; } else - strcpy(str,"-------"); + str = "-------"; } //------------------------------------------------------------------------- void CTimerdClient::stopTimerEvent( int evId) diff --git a/lib/timerdclient/timerdclient.h b/lib/timerdclient/timerdclient.h index 89ef81d84..16bdcad77 100644 --- a/lib/timerdclient/timerdclient.h +++ b/lib/timerdclient/timerdclient.h @@ -170,8 +170,8 @@ class CTimerdClient:private CBasicClient // Convert String of O and X to repeat type and vice versa //void getWeekdaysFromStr(int *rep, const char* str); - void getWeekdaysFromStr(CTimerd::CTimerEventRepeat *rep, const char* str); - void setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, char* str); + void getWeekdaysFromStr(CTimerd::CTimerEventRepeat *rep, std::string &str); + void setWeekdaysToStr(CTimerd::CTimerEventRepeat rep, std::string &str); }; #endif diff --git a/src/driver/lcdd.cpp b/src/driver/lcdd.cpp index 3363fd64f..3f5032ef5 100644 --- a/src/driver/lcdd.cpp +++ b/src/driver/lcdd.cpp @@ -144,8 +144,9 @@ void CLCD::count_down() { } void CLCD::wake_up() { - if (atoi(g_settings.lcd_setting_dim_time) > 0) { - timeout_cnt = atoi(g_settings.lcd_setting_dim_time); + int tmp = atoi(g_settings.lcd_setting_dim_time.c_str()); + if (tmp > 0) { + timeout_cnt = (unsigned int)tmp; setlcdparameter(); } } @@ -387,7 +388,7 @@ void CLCD::setlcdparameter(int /*dimm*/, const int contrast, const int /*power*/ void CLCD::setlcdparameter(void) { last_toggle_state_power = g_settings.lcd_setting[SNeutrinoSettings::LCD_POWER]; - int dim_time = atoi(g_settings.lcd_setting_dim_time); + int dim_time = atoi(g_settings.lcd_setting_dim_time.c_str()); int dim_brightness = g_settings.lcd_setting_dim_brightness; bool timeouted = (dim_time > 0) && (timeout_cnt == 0); int brightness, power = 0; diff --git a/src/driver/record.cpp b/src/driver/record.cpp index 6d8a8f6b1..e934b7c9b 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -1382,7 +1382,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey ) snprintf(rec_msg1, sizeof(rec_msg1)-1, "%s", g_Locale->getText(LOCALE_RECORDINGMENU_MULTIMENU_ASK_STOP_ALL)); snprintf(rec_msg, sizeof(rec_msg)-1, rec_msg1, records); - if(ShowMsgUTF(LOCALE_SHUTDOWN_RECODING_QUERY, rec_msg, + if(ShowMsg(LOCALE_SHUTDOWN_RECODING_QUERY, rec_msg, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) { snprintf(rec_msg1, sizeof(rec_msg1)-1, "%s", g_Locale->getText(LOCALE_RECORDINGMENU_MULTIMENU_INFO_STOP_ALL)); @@ -1415,7 +1415,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey ) std::string title, duration; inst->GetRecordString(title, duration); title += duration; - tostart = (ShowMsgUTF(LOCALE_RECORDING_IS_RUNNING, title.c_str(), + tostart = (ShowMsg(LOCALE_RECORDING_IS_RUNNING, title.c_str(), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes); } if (tostart) { @@ -1437,7 +1437,7 @@ int CRecordManager::exec(CMenuTarget* parent, const std::string & actionKey ) } else if(actionKey == "Stop_record") { if(!CRecordManager::getInstance()->RecordingStatus()) { - ShowHintUTF(LOCALE_MAINMENU_RECORDING_STOP, g_Locale->getText(LOCALE_RECORDINGMENU_RECORD_IS_NOT_RUNNING), 450, 2); + ShowHint(LOCALE_MAINMENU_RECORDING_STOP, g_Locale->getText(LOCALE_RECORDINGMENU_RECORD_IS_NOT_RUNNING), 450, 2); return menu_return::RETURN_EXIT_ALL; } } @@ -1450,7 +1450,7 @@ bool CRecordManager::ShowMenu(void) { int select = -1, rec_count = recmap.size(); char cnt[5]; - CMenuForwarderNonLocalized * item; + CMenuForwarder * item; CMenuForwarder * iteml; t_channel_id channel_ids[RECORD_MAX_COUNT] = { 0 }; /* initialization avoids false "might */ int recording_ids[RECORD_MAX_COUNT] = { 0 }; /* be used uninitialized" warning */ @@ -1508,7 +1508,7 @@ bool CRecordManager::ShowMenu(void) rc_key = CRCInput::RC_stop; btn_icon = NEUTRINO_ICON_BUTTON_STOP; } - item = new CMenuForwarderNonLocalized(title.c_str(), true, durations[i].c_str(), selector, cnt, rc_key, NULL, mode_icon); + item = new CMenuForwarder(title.c_str(), true, durations[i].c_str(), selector, cnt, rc_key, NULL, mode_icon); item->setItemButton(btn_icon, true); //if only one recording is running, set the focus to this menu item @@ -1569,7 +1569,7 @@ bool CRecordManager::AskToStop(const t_channel_id channel_id, const int recid) if(inst == NULL) return false; - if(ShowMsgUTF(LOCALE_SHUTDOWN_RECODING_QUERY, title.c_str(), + if(ShowMsg(LOCALE_SHUTDOWN_RECODING_QUERY, title.c_str(), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) { #if 0 g_Timerd->stopTimerEvent(recording_id); @@ -1864,7 +1864,7 @@ bool CRecordManager::MountDirectory(const char *recordingDir) strcat(msg,"\nDir: "); strcat(msg,recordingDir); - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, msg, + ShowMsg(LOCALE_MESSAGEBOX_ERROR, msg, CMessageBox::mbrBack, CMessageBox::mbBack,NEUTRINO_ICON_ERROR, 450, 10); // UTF-8 ret = false; } diff --git a/src/driver/vfd.cpp b/src/driver/vfd.cpp index 84b69f5c5..a4bd866fe 100644 --- a/src/driver/vfd.cpp +++ b/src/driver/vfd.cpp @@ -72,6 +72,7 @@ CVFD::CVFD() clearClock = 0; mode = MODE_TVRADIO; switch_name_time_cnt = 0; + timeout_cnt = 0; } CVFD::~CVFD() @@ -117,8 +118,8 @@ void CVFD::count_down() { void CVFD::wake_up() { if(!has_lcd) return; - if (atoi(g_settings.lcd_setting_dim_time) > 0) { - timeout_cnt = atoi(g_settings.lcd_setting_dim_time); + if (atoi(g_settings.lcd_setting_dim_time.c_str()) > 0) { + timeout_cnt = atoi(g_settings.lcd_setting_dim_time.c_str()); g_settings.lcd_setting_dim_brightness > -1 ? setBrightness(g_settings.lcd_setting[SNeutrinoSettings::LCD_BRIGHTNESS]) : setPower(1); } diff --git a/src/gui/audio_select.cpp b/src/gui/audio_select.cpp index c2a5f4a3c..5ec7c5fd7 100644 --- a/src/gui/audio_select.cpp +++ b/src/gui/audio_select.cpp @@ -111,7 +111,7 @@ int CAudioSelectMenuHandler::doMenu () { char apid[5]; sprintf(apid, "%d", i); - CMenuForwarderNonLocalized *fw = new CMenuForwarderNonLocalized(g_RemoteControl->current_PIDs.APIDs[i].desc, + CMenuForwarder *fw = new CMenuForwarder(g_RemoteControl->current_PIDs.APIDs[i].desc, true, NULL, this, apid, CRCInput::convertDigitToKey(i + 1)); fw->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); AudioSelector.addItem(fw, (i == g_RemoteControl->current_PIDs.PIDs.selected_apid)); @@ -156,7 +156,7 @@ int CAudioSelectMenuHandler::doMenu () snprintf(spid,sizeof(spid), "DVB:%d", sd->pId); char item[64]; snprintf(item,sizeof(item), "DVB: %s (pid %x)", sd->ISO639_language_code.c_str(), sd->pId); - AudioSelector.addItem(new CMenuForwarderNonLocalized(item /*sd->ISO639_language_code.c_str()*/, + AudioSelector.addItem(new CMenuForwarder(item /*sd->ISO639_language_code.c_str()*/, sd->pId != dvbsub_getpid(), NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++shortcut_num))); } if (s->thisSubType == CZapitAbsSub::TTX) @@ -174,7 +174,7 @@ int CAudioSelectMenuHandler::doMenu () snprintf(spid,sizeof(spid), "TTX:%d:%03X:%s", sd->pId, page, sd->ISO639_language_code.c_str()); char item[64]; snprintf(item,sizeof(item), "TTX: %s (pid %x page %03X)", sd->ISO639_language_code.c_str(), sd->pId, page); - AudioSelector.addItem(new CMenuForwarderNonLocalized(item /*sd->ISO639_language_code.c_str()*/, + AudioSelector.addItem(new CMenuForwarder(item /*sd->ISO639_language_code.c_str()*/, !tuxtx_subtitle_running(&pid, &page, NULL), NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++shortcut_num))); } } @@ -194,10 +194,9 @@ int CAudioSelectMenuHandler::doMenu () int percent[p_count]; for (uint i=0; i < p_count; i++) { percent[i] = CZapit::getInstance()->GetPidVolume(0, g_RemoteControl->current_PIDs.APIDs[i].pid); - AudioSelector.addItem(new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &percent[i], - i == g_RemoteControl->current_PIDs.PIDs.selected_apid, - 0, 999, CVolume::getInstance(), 0, 0, NONEXISTANT_LOCALE, - g_RemoteControl->current_PIDs.APIDs[i].desc)); + AudioSelector.addItem(new CMenuOptionNumberChooser(g_RemoteControl->current_PIDs.APIDs[i].desc, + &percent[i], i == g_RemoteControl->current_PIDs.PIDs.selected_apid, + 0, 999, CVolume::getInstance())); } return AudioSelector.exec(NULL, ""); diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index bfebe7190..915565a93 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -600,7 +600,7 @@ int CAudioPlayerGui::show() // is no stream, so we do not have to test for this case int seconds=0; CIntInput secondsInput(LOCALE_AUDIOPLAYER_JUMP_DIALOG_TITLE, - seconds, + &seconds, 5, LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT1, LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT2); @@ -707,7 +707,7 @@ int CAudioPlayerGui::show() // is no stream, so we do not have to test for this case int seconds=0; CIntInput secondsInput(LOCALE_AUDIOPLAYER_JUMP_DIALOG_TITLE, - seconds, + &seconds, 5, LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT1, LOCALE_AUDIOPLAYER_JUMP_DIALOG_HINT2); @@ -2606,7 +2606,7 @@ void CAudioPlayerGui::savePlaylist() absPlaylistDir += file->getFileName(); const int filenamesize = 30; - char filename[filenamesize + 1] = ""; + std::string filename; if (file->getType() == CFile::FILE_PLAYLIST) { @@ -2617,15 +2617,14 @@ void CAudioPlayerGui::savePlaylist() bool overwrite = askToOverwriteFile(name); if (!overwrite) return; - - snprintf(filename, name.size(), "%s", name.c_str()); + filename = name; } else if (file->getType() == CFile::FILE_DIR) { // query for filename this->hide(); CStringInputSMS filenameInput(LOCALE_AUDIOPLAYER_PLAYLIST_NAME, - filename, + &filename, filenamesize - 1, LOCALE_AUDIOPLAYER_PLAYLIST_NAME_HINT1, LOCALE_AUDIOPLAYER_PLAYLIST_NAME_HINT2, @@ -2704,7 +2703,7 @@ bool CAudioPlayerGui::askToOverwriteFile(const std::string& filename) "%s\n%s", g_Locale->getText(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_MSG), filename.c_str()); - bool res = (ShowMsgUTF(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_TITLE, + bool res = (ShowMsg(LOCALE_AUDIOPLAYER_PLAYLIST_FILEOVERWRITE_TITLE, msg,CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes); this->paint(); diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 28c961667..4d4093147 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -253,7 +253,7 @@ int CBEBouquetWidget::exec(CMenuTarget* parent, const std::string & /*actionKey* { if (bouquetsChanged) { - int result = ShowLocalizedMessage(LOCALE_BOUQUETEDITOR_NAME, LOCALE_BOUQUETEDITOR_SAVECHANGES, CMessageBox::mbrYes, CMessageBox::mbAll); + int result = ShowMsg(LOCALE_BOUQUETEDITOR_NAME, LOCALE_BOUQUETEDITOR_SAVECHANGES, CMessageBox::mbrYes, CMessageBox::mbAll); switch( result ) { @@ -427,7 +427,7 @@ void CBEBouquetWidget::deleteBouquet() if (selected >= Bouquets->size()) /* Bouquets->size() might be 0 */ return; - if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, (*Bouquets)[selected]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[selected]->Name, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, (*Bouquets)[selected]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : (*Bouquets)[selected]->Name, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) return; g_bouquetManager->deleteBouquet(selected); @@ -524,11 +524,9 @@ void CBEBouquetWidget::switchLockBouquet() std::string CBEBouquetWidget::inputName(const char * const defaultName, const neutrino_locale_t caption) { - char Name[30]; + std::string Name = defaultName; - strncpy(Name, defaultName, sizeof(Name)-1); - - CStringInputSMS * nameInput = new CStringInputSMS(caption, Name, 29, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.,:|!?/ "); + CStringInputSMS * nameInput = new CStringInputSMS(caption, &Name, 29, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.,:|!?/ "); nameInput->exec(this, ""); delete nameInput; diff --git a/src/gui/bedit/bouqueteditor_channels.cpp b/src/gui/bedit/bouqueteditor_channels.cpp index 3c4ee95c7..983b53487 100644 --- a/src/gui/bedit/bouqueteditor_channels.cpp +++ b/src/gui/bedit/bouqueteditor_channels.cpp @@ -446,7 +446,7 @@ void CBEChannelWidget::deleteChannel() if (selected >= Channels->size()) /* Channels.size() might be 0 */ return; - if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, (*Channels)[selected]->getName(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, (*Channels)[selected]->getName(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)!=CMessageBox::mbrYes) return; g_bouquetManager->Bouquets[bouquet]->removeService((*Channels)[selected]->channel_id); diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index 1a9c6adc8..1fb407497 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -83,12 +83,12 @@ inline int CBookmarkManager::createBookmark (const std::string & name, const std } int CBookmarkManager::createBookmark (const std::string & url, const std::string & time) { - char bookmarkname[26]=""; - CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-_"); + std::string bookmarkname; + CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, &bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-_"); bookmarkname_input.exec(NULL, ""); // TODO: return -1 if no name was entered - if (!strlen(bookmarkname)) return -1; - return createBookmark(std::string(bookmarkname), url, time); + if (bookmarkname.empty()) return -1; + return createBookmark(bookmarkname, url, time); } //------------------------------------------------------------------------ diff --git a/src/gui/cam_menu.cpp b/src/gui/cam_menu.cpp index 271a1224f..7e9254c19 100644 --- a/src/gui/cam_menu.cpp +++ b/src/gui/cam_menu.cpp @@ -128,14 +128,14 @@ int CCAMMenuHandler::doMainMenu() char tmp[32]; snprintf(tmp, sizeof(tmp), "ca_ci%d", i); - cammenu->addItem(new CMenuForwarderNonLocalized(name1, true, NULL, this, tmp, CRCInput::RC_1 + cnt++)); + cammenu->addItem(new CMenuForwarder(name1, true, NULL, this, tmp, CRCInput::RC_1 + cnt++)); snprintf(tmp, sizeof(tmp), "ca_ci_reset%d", i); cammenu->addItem(new CMenuForwarder(LOCALE_CI_RESET, true, NULL, this, tmp)); memset(name1,0,sizeof(name1)); } else { snprintf(str1, sizeof(str1), "%s %d", g_Locale->getText(LOCALE_CI_EMPTY), i); tempMenu = new CMenuWidget(str1, NEUTRINO_ICON_SETTINGS); - cammenu->addItem(new CMenuDForwarderNonLocalized(str1, false, NULL, tempMenu)); + cammenu->addItem(new CMenuDForwarder(str1, false, NULL, tempMenu)); memset(str1,0,sizeof(str1)); } if (i < (CiSlots - 1)) @@ -157,7 +157,7 @@ int CCAMMenuHandler::doMainMenu() char tmp[32]; snprintf(tmp, sizeof(tmp), "ca_sc%d", i); - cammenu->addItem(new CMenuForwarderNonLocalized(name1, true, NULL, this, tmp, CRCInput::RC_1 + cnt++)); + cammenu->addItem(new CMenuForwarder(name1, true, NULL, this, tmp, CRCInput::RC_1 + cnt++)); #if 0 // FIXME not implemented yet snprintf(tmp, sizeof(tmp), "ca_sc_reset%d", i); cammenu->addItem(new CMenuForwarder(LOCALE_SC_RESET, true, NULL, this, tmp)); @@ -166,7 +166,7 @@ int CCAMMenuHandler::doMainMenu() } else { snprintf(str1, sizeof(str1), "%s %d", g_Locale->getText(LOCALE_SC_EMPTY), i); tempMenu = new CMenuWidget(str1, NEUTRINO_ICON_SETTINGS); - cammenu->addItem(new CMenuDForwarderNonLocalized(str1, false, NULL, tempMenu)); + cammenu->addItem(new CMenuDForwarder(str1, false, NULL, tempMenu)); memset(str1,0,sizeof(str1)); } if (i < (ScNum - 1)) @@ -218,9 +218,9 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t char cnt[5]; int i; MMI_MENU_LIST_INFO Menu; - MMI_ENGUIRY_INFO MmiEnquiry; + MMI_ENQUIRY_INFO MmiEnquiry; MMI_MENU_LIST_INFO *pMenu = &Menu; - MMI_ENGUIRY_INFO *pMmiEnquiry = &MmiEnquiry; + MMI_ENQUIRY_INFO *pMmiEnquiry = &MmiEnquiry; CA_MESSAGE Msg, *rMsg; if (msg != NeutrinoMessages::EVT_CA_MESSAGE) @@ -250,7 +250,7 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t snprintf(str, sizeof(str), "%s %d", g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_INSERTED : LOCALE_SC_INSERTED), (int)curslot+1); printf("CCAMMenuHandler::handleCamMsg: %s\n", str); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, str); + ShowHint(LOCALE_MESSAGEBOX_INFO, str); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, str, CI_MSG_TIME); #endif @@ -261,7 +261,7 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_REMOVED : LOCALE_SC_REMOVED), (int)curslot+1); printf("CCAMMenuHandler::handleCamMsg: %s\n", str); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, str); + ShowHint(LOCALE_MESSAGEBOX_INFO, str); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, str, CI_MSG_TIME); #endif @@ -279,7 +279,7 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_INIT_OK : LOCALE_SC_INIT_OK), (int)curslot+1, name); printf("CCAMMenuHandler::handleCamMsg: %s\n", str); CCamManager::getInstance()->Start(CZapit::getInstance()->GetCurrentChannelID(), CCamManager::PLAY, true); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, str); + ShowHint(LOCALE_MESSAGEBOX_INFO, str); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, str, CI_MSG_TIME); #endif @@ -294,7 +294,7 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t g_Locale->getText(SlotType == CA_SLOT_TYPE_CI ? LOCALE_CI_INIT_FAILED : LOCALE_SC_INIT_FAILED), (int)curslot+1, name); printf("CCAMMenuHandler::handleCamMsg: %s\n", str); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, str); + ShowHint(LOCALE_MESSAGEBOX_INFO, str); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, str, CI_MSG_TIME); #endif @@ -330,27 +330,27 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t bpos = 0; tptr[li] = 0; printf("CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr); - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); + menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); sptr = &tptr[li+1]; } bpos++; } if(strlen(sptr)) { printf("CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr); - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); + menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); } } for(i = 0; (i < pMenu->choice_nb) && (i < MAX_MMI_ITEMS); i++) { snprintf(cnt, sizeof(cnt), "%d", i); if(sublevel) - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt)); + menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt)); else - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i+1))); + menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i+1))); } slen = strlen(pMenu->bottom); if(slen) { printf("CCAMMenuHandler::handleCamMsg: bottom: %s\n", pMenu->bottom); - menu->addItem(new CMenuForwarderNonLocalized(convertDVBUTF8(pMenu->bottom, slen, 0).c_str(), false)); + menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->bottom, slen, 0).c_str(), false)); } menu->exec(NULL, ""); @@ -371,13 +371,13 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t if(strlen(pMenu->bottom)) slen += snprintf(&lstr[slen], 255-slen, "\n%s", pMenu->bottom); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, convertDVBUTF8(lstr, slen, 0).c_str()); + ShowHint(LOCALE_MESSAGEBOX_INFO, convertDVBUTF8(lstr, slen, 0).c_str()); #else if(strlen(pMenu->subtitle)) slen += snprintf(&lstr[slen], 255-slen, "\n%s", pMenu->subtitle); if(strlen(pMenu->bottom)) slen += snprintf(&lstr[slen], 255-slen, "\n%s", pMenu->bottom); - ShowHintUTF(convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), convertDVBUTF8(lstr, slen, 0).c_str()); + ShowHint(convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), convertDVBUTF8(lstr, slen, 0).c_str()); #endif #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, convertDVBUTF8(lstr, slen, 0).c_str()); @@ -405,26 +405,25 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t if (!(Msg.Flags & CA_MESSAGE_HAS_PARAM1_DATA)) return -1; - memmove(pMmiEnquiry, (MMI_ENGUIRY_INFO *)Msg.Msg.Data[0], sizeof(MMI_ENGUIRY_INFO)); + memmove(pMmiEnquiry, (MMI_ENQUIRY_INFO *)Msg.Msg.Data[0], sizeof(MMI_ENQUIRY_INFO)); free((void *)Msg.Msg.Data[0]); - printf("CCAMMenuHandler::handleCamMsg: slot %d input request, text %s\n", curslot, convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str()); + printf("CCAMMenuHandler::handleCamMsg: slot %d input request, text %s\n", curslot, convertDVBUTF8(pMmiEnquiry->enquiryText, strlen(pMmiEnquiry->enquiryText), 0).c_str()); hideHintBox(); - char ENQAnswer[pMmiEnquiry->answerlen+1]; - ENQAnswer[0] = 0; + std::string ENQAnswer; - CEnquiryInput *Inquiry = new CEnquiryInput((char *)convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str(), ENQAnswer, pMmiEnquiry->answerlen, pMmiEnquiry->blind != 0, NONEXISTANT_LOCALE); + CEnquiryInput *Inquiry = new CEnquiryInput((char *)convertDVBUTF8(pMmiEnquiry->enquiryText, strlen(pMmiEnquiry->enquiryText), 0).c_str(), &ENQAnswer, pMmiEnquiry->answerlen, pMmiEnquiry->blind != 0, NONEXISTANT_LOCALE); Inquiry->exec(NULL, ""); delete Inquiry; - printf("CCAMMenuHandler::handleCamMsg: input=[%s]\n", ENQAnswer); + printf("CCAMMenuHandler::handleCamMsg: input=[%s]\n", ENQAnswer.c_str()); - if((int) strlen(ENQAnswer) != pMmiEnquiry->answerlen) { + if((int) ENQAnswer.length() != pMmiEnquiry->answerlen) { printf("CCAMMenuHandler::handleCamMsg: wrong input len\n"); - ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer, 0); + ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer.c_str(), 0); return 1; //FIXME } else { - ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer, pMmiEnquiry->answerlen); + ca->InputAnswer(SlotType, curslot, (unsigned char *)ENQAnswer.c_str(), pMmiEnquiry->answerlen); return 1; } } @@ -464,7 +463,7 @@ int CCAMMenuHandler::doMenu(int slot, CA_SLOT_TYPE slotType) if (msg == CRCInput::RC_timeout) { printf("CCAMMenuHandler::doMenu: menu timeout\n"); hideHintBox(); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(slotType == CA_SLOT_TYPE_CI ? LOCALE_CI_TIMEOUT : LOCALE_SC_TIMEOUT)); #if 0 showHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_CI_TIMEOUT), 5); diff --git a/src/gui/channellist.cpp b/src/gui/channellist.cpp index 6bbd8e80b..1bbe50a57 100644 --- a/src/gui/channellist.cpp +++ b/src/gui/channellist.cpp @@ -386,7 +386,7 @@ int CChannelList::doChannelMenu(void) switch(select) { case 0: { hide(); - int result = ShowMsgUTF ( LOCALE_BOUQUETEDITOR_DELETE, g_Locale->getText(LOCALE_BOUQUETEDITOR_DELETE_QUESTION), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); + int result = ShowMsg ( LOCALE_BOUQUETEDITOR_DELETE, g_Locale->getText(LOCALE_BOUQUETEDITOR_DELETE_QUESTION), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); if(result == CMessageBox::mbrYes) { bouquet_id = bouquetList->getActiveBouquetNumber(); diff --git a/src/gui/components/cc_frm_signalbars.cpp b/src/gui/components/cc_frm_signalbars.cpp index a046e10da..df2e1d27d 100644 --- a/src/gui/components/cc_frm_signalbars.cpp +++ b/src/gui/components/cc_frm_signalbars.cpp @@ -29,6 +29,7 @@ #include #include +#include #include "cc_frm_signalbars.h" #include @@ -40,6 +41,8 @@ CSignalBar::CSignalBar() { initVarSigBar(); sb_name = "SIG"; + + initDimensions(); initSBItems(); } @@ -53,6 +56,7 @@ CSignalBar::CSignalBar(const int& xpos, const int& ypos, const int& w, const int height = h; sb_name = sbname; + initDimensions(); initSBItems(); } @@ -64,15 +68,14 @@ void CSignalBar::initDimensions() if (sb_scale_height == -1) sb_scale_height = sb_item_height; - //use value in % of signalbox width for scale, rest is reserved for caption - sb_scale_width = width*sb_scale_w_percent/100; + int dx = 0; + int dy = min(sb_item_height, 100); + sb_font = *dy_font->getDynFont(dx, dy, "100% "+sb_name); + dx += dx/10; + sb_scale_width = width - dx; - int dx = width - sb_scale_width; - int dy = sb_item_height; - sb_font = *dy_font->getDynFont(dx, dy); - - //use 15% for value and name label - sb_vlbl_width = sb_lbl_width = dx /2; + sb_vlbl_width = sb_font->getRenderWidth("100% ") + dx/20; + sb_lbl_width = dx - sb_vlbl_width; } void CSignalBar::initSBItems() @@ -86,9 +89,6 @@ void CSignalBar::initSBItems() sb_caption_color = sbx->getTextColor(); } - //reinit dimensions - initDimensions(); - //init items scale, value and name initSBarScale(); initSBarValue(); @@ -104,7 +104,6 @@ void CSignalBar::initVarSigBar() height = SB_MIN_HEIGHT; sb_scale_height = -1; - sb_scale_w_percent = 60; dy_font = CNeutrinoFonts::getInstance(); sb_caption_color= COL_INFOBAR_TEXT; @@ -169,7 +168,7 @@ void CSignalBar::initSBarName() if (sb_lbl == NULL){ sb_lbl = new CComponentsLabel(); sb_lbl->doPaintBg(false); - sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK/* | CTextBox::RIGHT*/, sb_font); + sb_lbl->setText(sb_name, CTextBox::NO_AUTO_LINEBREAK | CTextBox::RIGHT, sb_font); sb_lbl->forceTextPaint(); sb_lbl->doPaintTextBoxBg(true); } @@ -262,7 +261,7 @@ CSignalBox::CSignalBox(const int& xpos, const int& ypos, const int& w, const int initVarSigBox(); vertical = vert; - sbx_frontend = frontend_ref; + sbx_frontend = (frontend_ref == NULL) ? CFEManager::getInstance()->getLiveFE() : frontend_ref; x = xpos; y = ypos; width = w; @@ -298,7 +297,6 @@ void CSignalBox::initVarSigBox() sbx_bar_height = height/2; sbx_bar_x = corner_rad; sbx_caption_color = COL_INFOBAR_TEXT; - sbx_scale_w_percent = 60; vertical = true; } @@ -315,17 +313,22 @@ void CSignalBox::initSignalItems() int sbar_x = sbx_bar_x + fr_thickness; int scale_h = sbar_h * 76 / 100; + int sbar_sw = sbar->getScaleWidth(); + int snrbar_sw = snrbar->getScaleWidth(); + if (sbar_sw < snrbar_sw) + snrbar->setScaleWidth(sbar_sw); + else if (snrbar_sw < sbar_sw) + sbar->setScaleWidth(snrbar_sw); + sbar->setDimensionsAll(sbar_x, fr_thickness, sbar_w, sbar_h); sbar->setFrontEnd(sbx_frontend); sbar->setCorner(0); sbar->setScaleHeight(scale_h); - sbar->setScaleWidth(sbx_scale_w_percent); snrbar->setDimensionsAll(vertical ? sbar_x : CC_APPEND, vertical ? CC_APPEND : fr_thickness, sbar_w, sbar_h); snrbar->setFrontEnd(sbx_frontend); snrbar->setCorner(0); snrbar->setScaleHeight(scale_h); - snrbar->setScaleWidth(sbx_scale_w_percent); } void CSignalBox::paintScale() diff --git a/src/gui/components/cc_frm_signalbars.h b/src/gui/components/cc_frm_signalbars.h index 846e0707e..c7474ffa7 100644 --- a/src/gui/components/cc_frm_signalbars.h +++ b/src/gui/components/cc_frm_signalbars.h @@ -88,9 +88,6 @@ class CSignalBar : public CComponentsForm int sb_lastsig; ///current signal value uint16_t sb_signal; - - ///allowed width of scale bar from full width in %, rest used by caption, default value = 60% of width, use setScaleWidth() to set this value - short sb_scale_w_percent; ///initialize all needed basich attributes and objects void initVarSigBar(); @@ -126,7 +123,7 @@ class CSignalBar : public CComponentsForm ///assigns the height of scale virtual void setScaleHeight(const int& scale_height){sb_scale_height = scale_height;}; ///assigns the width of scale - virtual void setScaleWidth(const short & scale_width_percent){sb_scale_w_percent = scale_width_percent;}; + virtual void setScaleWidth(const int & scale_width){sb_scale_width = scale_width;}; ///assigns the name of signal value in the caption object, see also sb_name virtual void setName(const std::string& name){sb_name = name;}; @@ -136,6 +133,8 @@ class CSignalBar : public CComponentsForm virtual CComponentsLabel* getLabelValObject(){return sb_vlbl;}; ///returns the name label object, type = CComponentsLabel* virtual CComponentsLabel* getLabelNameObject(){return sb_lbl;}; + /// return the scale width + virtual int getScaleWidth(){ return sb_scale_width;}; ///paint this items virtual void paint(bool do_save_bg); @@ -256,9 +255,6 @@ class CSignalBox : public CComponentsForm ///property: text color, see also setTextColor() fb_pixel_t sbx_caption_color; - ///allowed width of scale bar from full width in %, rest used by caption, default value = 60% of width, use setScaleWidth() to set this value - short sbx_scale_w_percent; - // true if vertical arrangement, false if horizontal bool vertical; @@ -272,7 +268,7 @@ class CSignalBox : public CComponentsForm public: ///class constructor for signal noise ratio. - CSignalBox(const int& xpos, const int& ypos, const int& w, const int& h, CFrontend *frontend_ref, const bool vertical = true); + CSignalBox(const int& xpos, const int& ypos, const int& w, const int& h, CFrontend *frontend_ref = NULL, const bool vertical = true); ///returns the signal object, type = CSignalBar* CSignalBar* getScaleObject(){return sbar;}; @@ -283,9 +279,6 @@ class CSignalBox : public CComponentsForm void setTextColor(const fb_pixel_t& caption_color){ sbx_caption_color = caption_color;}; ///get caption color of signalbars, see also property 'sbx_caption_color' fb_pixel_t getTextColor(){return sbx_caption_color;}; - - ///assigns the width of scale in percent related of full width of signal box, the rest is reserved for text - void setScaleWidth(const short & scale_width_percent){sbx_scale_w_percent = scale_width_percent;}; ///paint items void paint(bool do_save_bg); diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index d5f673fc4..a6874743c 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -1285,7 +1285,7 @@ int EpgPlus::MenuTargetAddReminder::exec (CMenuTarget * /*parent*/, const std::s if (g_Timerd->isTimerdAvailable()) { g_Timerd->addZaptoTimerEvent (this->epgPlus->selectedChannelEntry->channel->channel_id, (*It)->channelEvent.startTime - (g_settings.zapto_pre_time * 60), (*It)->channelEvent.startTime - ANNOUNCETIME - (g_settings.zapto_pre_time * 60), 0, (*It)->channelEvent.eventID, (*It)->channelEvent.startTime, 0); - ShowMsgUTF (LOCALE_TIMER_EVENTTIMED_TITLE, g_Locale->getText (LOCALE_TIMER_EVENTTIMED_MSG) + ShowMsg (LOCALE_TIMER_EVENTTIMED_TITLE, g_Locale->getText (LOCALE_TIMER_EVENTTIMED_MSG) , CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } else printf ("timerd not available\n"); @@ -1308,7 +1308,7 @@ int EpgPlus::MenuTargetAddRecordTimer::exec (CMenuTarget * /*parent*/, const std g_Timerd->addRecordTimerEvent (this->epgPlus->selectedChannelEntry->channel->channel_id, (*It)->channelEvent.startTime, (*It)->channelEvent.startTime + (*It)->channelEvent.duration, (*It)->channelEvent.eventID, (*It)->channelEvent.startTime, (*It)->channelEvent.startTime - (ANNOUNCETIME + 120) , TIMERD_APIDS_CONF, true); - ShowMsgUTF (LOCALE_TIMER_EVENTRECORD_TITLE, g_Locale->getText (LOCALE_TIMER_EVENTRECORD_MSG) + ShowMsg (LOCALE_TIMER_EVENTRECORD_TITLE, g_Locale->getText (LOCALE_TIMER_EVENTRECORD_MSG) , CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } else printf ("timerd not available\n"); diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 7e3f4a234..2c68707e1 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -466,7 +466,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start if (epgData.title.empty()) /* no epg info found */ { - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EPGVIEWER_NOTFOUND)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EPGVIEWER_NOTFOUND)); // UTF-8 hide(); return res; } @@ -852,11 +852,11 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start epgData.eventID, epgData.epg_times.startzeit, epgData.epg_times.startzeit - (ANNOUNCETIME + 120 ), TIMERD_APIDS_CONF, true, recDir,true); - ShowLocalizedMessage(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } else { - ShowLocalizedMessage(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } @@ -876,7 +876,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start epgData.epg_times.startzeit - (g_settings.zapto_pre_time * 60), epgData.epg_times.startzeit - ANNOUNCETIME - (g_settings.zapto_pre_time * 60), 0, epgData.eventID, epgData.epg_times.startzeit, 0); - ShowLocalizedMessage(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } else diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index add781f81..1aaafc16f 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -495,13 +495,13 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c TIMERD_APIDS_CONF, true, recDir,true); //ask user whether the timer event should be set anyway - ShowLocalizedMessage(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } else { - //ShowLocalizedMessage(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + //ShowMsg(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_EPG]); } } @@ -528,7 +528,7 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c evtlist[selected].startTime - (g_settings.zapto_pre_time * 60), evtlist[selected].startTime - ANNOUNCETIME - (g_settings.zapto_pre_time * 60), 0, evtlist[selected].eventID, evtlist[selected].startTime, 0); - //ShowLocalizedMessage(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + //ShowMsg(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(evtlist[selected].channelID ); @@ -1289,7 +1289,7 @@ int CEventFinderMenu::exec(CMenuTarget* parent, const std::string &actionkey) m->addItem(GenericMenuSeparatorLine); std::list::iterator it = g_settings.epg_search_history.begin(); for (int i = 0; i < g_settings.epg_search_history_size; i++, ++it) - m->addItem(new CMenuForwarderNonLocalized((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1))); + m->addItem(new CMenuForwarder((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1))); m->exec(NULL, ""); m->hide(); delete m; @@ -1346,7 +1346,7 @@ int CEventFinderMenu::showMenu(void) CMenuForwarder* mf0 = new CMenuForwarder(LOCALE_EVENTFINDER_KEYWORD, true, *m_search_keyword, &stringInput, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); CMenuOptionChooser* mo0 = new CMenuOptionChooser(LOCALE_EVENTFINDER_SEARCH_WITHIN_LIST, m_search_list, SEARCH_LIST_OPTIONS, SEARCH_LIST_OPTION_COUNT, true, this, CRCInput::convertDigitToKey(shortcut++)); - m_search_channelname_mf = new CMenuForwarderNonLocalized("", *m_search_list != CNeutrinoEventList::SEARCH_LIST_ALL, m_search_channelname, this, "#2", CRCInput::convertDigitToKey(shortcut++)); + m_search_channelname_mf = new CMenuForwarder("", *m_search_list != CNeutrinoEventList::SEARCH_LIST_ALL, m_search_channelname, this, "#2", CRCInput::convertDigitToKey(shortcut++)); CMenuOptionChooser* mo1 = new CMenuOptionChooser(LOCALE_EVENTFINDER_SEARCH_WITHIN_EPG, m_search_epg_item, SEARCH_EPG_OPTIONS, SEARCH_EPG_OPTION_COUNT, true, NULL, CRCInput::convertDigitToKey(shortcut++)); CMenuForwarder* mf1 = new CMenuForwarder(LOCALE_EVENTFINDER_START_SEARCH, true, NULL, this, "#1", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN); diff --git a/src/gui/eventlist.h b/src/gui/eventlist.h index 7e83d8391..96f79265b 100644 --- a/src/gui/eventlist.h +++ b/src/gui/eventlist.h @@ -138,7 +138,7 @@ class CEventListHandler : public CMenuTarget class CEventFinderMenu : public CMenuTarget, CChangeObserver { private: - CMenuForwarderNonLocalized* m_search_channelname_mf; + CMenuForwarder* m_search_channelname_mf; int* m_event; int* m_search_epg_item; std::string* m_search_keyword; diff --git a/src/gui/favorites.cpp b/src/gui/favorites.cpp index a6703fd27..c3d978f99 100644 --- a/src/gui/favorites.cpp +++ b/src/gui/favorites.cpp @@ -122,7 +122,7 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) #if 0 if (!bouquetList) { - ShowLocalizedMessage(LOCALE_FAVORITES_BOUQUETNAME, LOCALE_FAVORITES_NOBOUQUETS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, LOCALE_FAVORITES_NOBOUQUETS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return res; } #endif @@ -147,7 +147,7 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) { if (status & 2) str += g_Locale->getText(LOCALE_EXTRA_CHADDED); else str += g_Locale->getText(LOCALE_EXTRA_CHALREADYINBQ); - ShowMsgUTF(LOCALE_EXTRA_ADD_TO_BOUQUET, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + ShowMsg(LOCALE_EXTRA_ADD_TO_BOUQUET, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } else { @@ -155,7 +155,7 @@ int CFavorites::exec(CMenuTarget* parent, const std::string & actionKey) if (status & 2) str += g_Locale->getText(LOCALE_FAVORITES_CHADDED); else str += g_Locale->getText(LOCALE_FAVORITES_CHALREADYINBQ); if (status) str += g_Locale->getText(LOCALE_FAVORITES_FINALHINT); - ShowMsgUTF(LOCALE_FAVORITES_BOUQUETNAME, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + ShowMsg(LOCALE_FAVORITES_BOUQUETNAME, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 } diff --git a/src/gui/filebrowser.cpp b/src/gui/filebrowser.cpp index 36ed59b3e..73dbd0b63 100644 --- a/src/gui/filebrowser.cpp +++ b/src/gui/filebrowser.cpp @@ -933,7 +933,7 @@ bool CFileBrowser::exec(const char * const dirname) _msg << filelist[selected].getFileName(); _msg << " " << g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2); - if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, _msg.str(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, _msg.str(), CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) { std::string n = filelist[selected].Name; recursiveDelete(n.c_str()); diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index b47116e12..b6aea2b14 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -256,7 +256,7 @@ int CHDDMenuHandler::doMenu () tempMenu[i]->addItem(mf); snprintf(sstr, sizeof(sstr), "%s (%s)", g_Locale->getText(LOCALE_HDD_REMOVABLE_DEVICE), namelist[i]->d_name); - mf = new CMenuForwarderNonLocalized((removable ? sstr : namelist[i]->d_name), enabled, tmp_str[i], tempMenu[i]); + mf = new CMenuForwarder((removable ? sstr : namelist[i]->d_name), enabled, tmp_str[i], tempMenu[i]); mf->setHint("", LOCALE_MENU_HINT_HDD_TOOLS); hddmenu->addItem(mf); @@ -497,7 +497,7 @@ int CHDDFmtExec::exec(CMenuTarget* /*parent*/, const std::string& key) printf("CHDDFmtExec: key %s\n", key.c_str()); - res = ShowMsgUTF ( LOCALE_HDD_FORMAT, g_Locale->getText(LOCALE_HDD_FORMAT_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); + res = ShowMsg ( LOCALE_HDD_FORMAT, g_Locale->getText(LOCALE_HDD_FORMAT_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); if(res != CMessageBox::mbrYes) return 0; diff --git a/src/gui/infoviewer.cpp b/src/gui/infoviewer.cpp index becf84e51..ceec4b7ed 100644 --- a/src/gui/infoviewer.cpp +++ b/src/gui/infoviewer.cpp @@ -1087,7 +1087,7 @@ void CInfoViewer::showSubchan () void CInfoViewer::showFailure () { - ShowHintUTF (LOCALE_MESSAGEBOX_ERROR, g_Locale->getText (LOCALE_INFOVIEWER_NOTAVAILABLE), 430); // UTF-8 + ShowHint (LOCALE_MESSAGEBOX_ERROR, g_Locale->getText (LOCALE_INFOVIEWER_NOTAVAILABLE), 430); // UTF-8 } void CInfoViewer::showMotorMoving (int duration) @@ -1096,7 +1096,7 @@ void CInfoViewer::showMotorMoving (int duration) char text[256]; snprintf(text, sizeof(text), "%s (%ds)", g_Locale->getText (LOCALE_INFOVIEWER_MOTOR_MOVING), duration); - ShowHintUTF (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth (text, true) + 10, duration); // UTF-8 + ShowHint (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth (text, true) + 10, duration); // UTF-8 } void CInfoViewer::killRadiotext() diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index 54d6f13a7..82f5bf093 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -103,12 +103,12 @@ int CKeybindSetup::exec(CMenuTarget* parent, const std::string &actionKey) CFileBrowser fileBrowser; fileBrowser.Dir_Mode = true; if (fileBrowser.exec("/var/tuxbox") == true) { - char fname[256] = "keys.conf", sname[256]; - CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVEKEYS, fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. "); + std::string fname = "keys.conf"; + CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVEKEYS, &fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. "); sms->exec(NULL, ""); - sprintf(sname, "%s/%s", fileBrowser.getSelectedFile()->Name.c_str(), fname); - printf("[neutrino keybind_setup] save keys: %s\n", sname); - CNeutrinoApp::getInstance()->saveKeys(sname); + std::string sname = fileBrowser.getSelectedFile()->Name + "/" + fname; + printf("[neutrino keybind_setup] save keys: %s\n", sname.c_str()); + CNeutrinoApp::getInstance()->saveKeys(sname.c_str()); delete sms; } return menu_return::RETURN_REPAINT; @@ -268,7 +268,7 @@ int CKeybindSetup::showKeySetup() strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART2)); strcat(RC_HW_msg, RC_HW_str[g_settings.remote_control_hardware]); strcat(RC_HW_msg, g_Locale->getText(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE_MSG_PART3)); - if(ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, RC_HW_msg, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 450, 15, true) == CMessageBox::mbrNo) { + if(ShowMsg(LOCALE_MESSAGEBOX_INFO, RC_HW_msg, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 450, 15, true) == CMessageBox::mbrNo) { g_settings.remote_control_hardware = org_remote_control_hardware; g_RCInput->CRCInput::set_rc_hw(); } diff --git a/src/gui/luainstance.cpp b/src/gui/luainstance.cpp index 1db573b2d..13526e552 100644 --- a/src/gui/luainstance.cpp +++ b/src/gui/luainstance.cpp @@ -26,6 +26,9 @@ #include #include #include +#include +#include +#include #include #include "luainstance.h" @@ -36,7 +39,7 @@ struct table_key { const char *name; - long code; + uint32_t code; }; struct lua_envexport { @@ -119,6 +122,23 @@ static void set_lua_variables(lua_State *L) { "mute_off", CRCInput::RC_mute_off }, { "analog_on", CRCInput::RC_analog_on }, { "analog_off", CRCInput::RC_analog_off }, +#if !HAVE_COOL_HARDWARE + { "find", CRCInput::RC_find }, + { "pip", CRCInput::RC_pip }, + { "folder", CRCInput::RC_archive }, + { "forward", CRCInput::RC_fastforward }, + { "slow", CRCInput::RC_slow }, + { "playmode", CRCInput::RC_playmode }, + { "usb", CRCInput::RC_usb }, + { "f1", CRCInput::RC_f1 }, + { "f2", CRCInput::RC_f2 }, + { "f3", CRCInput::RC_f3 }, + { "f4", CRCInput::RC_f4 }, + { "prog1", CRCInput::RC_prog1 }, + { "prog2", CRCInput::RC_prog2 }, + { "prog3", CRCInput::RC_prog3 }, + { "prog4", CRCInput::RC_prog4 }, +#endif /* to check if it is in our range */ { "MaxRC", CRCInput::RC_MaxRC }, { NULL, 0 } @@ -204,20 +224,29 @@ static void set_lua_variables(lua_State *L) { "TOP_RIGHT", CORNER_TOP_RIGHT }, { "BOTTOM_LEFT", CORNER_BOTTOM_LEFT }, { "BOTTOM_RIGHT", CORNER_BOTTOM_RIGHT }, - { "RADIUS_LARGE", RADIUS_LARGE }, /* those depend on g_settings.rounded_corners */ - { "RADIUS_MID", RADIUS_MID }, - { "RADIUS_SMALL", RADIUS_SMALL }, - { "RADIUS_MIN", RADIUS_MIN }, + { "RADIUS_LARGE", (uint32_t) RADIUS_LARGE }, /* those depend on g_settings.rounded_corners */ + { "RADIUS_MID", (uint32_t) RADIUS_MID }, + { "RADIUS_SMALL", (uint32_t) RADIUS_SMALL }, + { "RADIUS_MIN", (uint32_t) RADIUS_MIN }, { NULL, 0 } }; /* screen offsets, exported as e.g. SCREEN['END_Y'] */ table_key screenopts[] = { - { "OFF_X", g_settings.screen_StartX }, - { "OFF_Y", g_settings.screen_StartY }, - { "END_X", g_settings.screen_EndX }, - { "END_Y", g_settings.screen_EndY }, + { "OFF_X", (uint32_t) g_settings.screen_StartX }, + { "OFF_Y", (uint32_t) g_settings.screen_StartY }, + { "END_X", (uint32_t) g_settings.screen_EndX }, + { "END_Y", (uint32_t) g_settings.screen_EndY }, + { NULL, 0 } + }; + table_key menureturn[] = + { + { "NONE", menu_return::RETURN_NONE }, + { "REPAINT", menu_return::RETURN_REPAINT }, + { "EXIT", menu_return::RETURN_EXIT }, + { "EXIT_ALL", menu_return::RETURN_EXIT_ALL }, + { "EXIT_REPAINT", menu_return::RETURN_EXIT_REPAINT }, { NULL, 0 } }; @@ -229,6 +258,7 @@ static void set_lua_variables(lua_State *L) { "SCREEN", screenopts }, { "FONT", fontlist }, { "CORNER", corners }, + { "MENU_RETURN", menureturn }, { NULL, NULL } }; @@ -310,6 +340,10 @@ const luaL_Reg CLuaInstance::methods[] = { "PaintIcon", CLuaInstance::PaintIcon }, { "GetInput", CLuaInstance::GetInput }, { "FontHeight", CLuaInstance::FontHeight }, + { "GetSize", CLuaInstance::GetSize }, + { "DisplayImage", CLuaInstance::DisplayImage }, + { "Blit", CLuaInstance::Blit }, + { "GetLanguage", CLuaInstance::GetLanguage }, { NULL, NULL } }; @@ -378,6 +412,11 @@ void CLuaInstance::registerFunctions() lua_pop(lua, 1); lua_register(lua, className, NewWindow); + MenuRegister(lua); + HintboxRegister(lua); + MessageboxRegister(lua); + CWindowRegister(lua); + SignalBoxRegister(lua); } CLuaData *CLuaInstance::CheckData(lua_State *L, int narg) @@ -469,6 +508,39 @@ int CLuaInstance::PaintIcon(lua_State *L) return 0; } +extern CPictureViewer * g_PicViewer; + +int CLuaInstance::DisplayImage(lua_State *L) +{ + DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); + int x, y, w, h; + const char *fname; + + fname = luaL_checkstring(L, 2); + x = luaL_checkint(L, 3); + y = luaL_checkint(L, 4); + w = luaL_checkint(L, 5); + h = luaL_checkint(L, 6); + int trans = 0; + if (lua_isnumber(L, 7)) + trans = luaL_checkint(L, 7); + g_PicViewer->DisplayImage(fname, x, y, w, h, trans); + return 0; +} + +int CLuaInstance::GetSize(lua_State *L) +{ + DBG("CLuaInstance::%s %d\n", __func__, lua_gettop(L)); + int w = 0, h = 0; + const char *fname; + + fname = luaL_checkstring(L, 2); + g_PicViewer->getSize(fname, &w, &h); + lua_pushinteger(L, w); + lua_pushinteger(L, h); + return 2; +} + int CLuaInstance::RenderString(lua_State *L) { int x, y, w, boxh, f, center; @@ -527,7 +599,7 @@ int CLuaInstance::GetInput(lua_State *L) /* TODO: I'm not sure if this works... */ if (msg != CRCInput::RC_timeout && msg > CRCInput::RC_MaxRC) { - DBG("CLuaInstance::%s: msg 0x%08lx data 0x%08lx\n", __func__, msg, data); + DBG("CLuaInstance::%s: msg 0x%08"PRIx32" data 0x%08"PRIx32"\n", __func__, msg, data); CNeutrinoApp::getInstance()->handleMsg(msg, data); } /* signed int is debatable, but the "big" messages can't yet be handled @@ -561,3 +633,809 @@ int CLuaInstance::GCWindow(lua_State *L) delete w; return 0; } + +#if HAVE_COOL_HARDWARE +int CLuaInstance::Blit(lua_State *) +{ + return 0; +} +#else +int CLuaInstance::Blit(lua_State *L) +{ + CLuaData *W = CheckData(L, 1); + if (W && W->fbwin) { + if (lua_isnumber(L, 2)) + W->fbwin->blit((int)lua_tonumber(L, 2)); // enable/disable automatic blit + else + W->fbwin->blit(); + } + return 0; +} +#endif + +int CLuaInstance::GetLanguage(lua_State *L) +{ + // FIXME -- should conform to ISO 639-1/ISO 3166-1 + lua_pushstring(L, g_settings.language.c_str()); + + return 1; +} + +bool CLuaInstance::tableLookup(lua_State *L, const char *what, std::string &value) +{ + bool res = false; + lua_pushstring(L, what); + lua_gettable(L, -2); + res = lua_isstring(L, -1); + if (res) + value = lua_tostring(L, -1); + lua_pop(L, 1); + return res; +} + +bool CLuaInstance::tableLookup(lua_State *L, const char *what, int &value) +{ + bool res = false; + lua_pushstring(L, what); + lua_gettable(L, -2); + res = lua_isnumber(L, -1); + if (res) + value = (int) lua_tonumber(L, -1); + lua_pop(L, 1); + return res; +} + +bool CLuaMenuChangeObserver::changeNotify(lua_State *L, const std::string &luaAction, const std::string &luaId, void *Data) +{ + const char *optionValue = (const char *) Data; + lua_pushglobaltable(L); + lua_getfield(L, -1, luaAction.c_str()); + lua_remove(L, -2); + lua_pushstring(L, luaId.c_str()); + lua_pushstring(L, optionValue); + lua_pcall(L, 2 /* two args */, 1 /* one result */, 0); + int res = lua_isnumber(L, -1) ? (int)lua_tonumber(L, -1) : 0; + lua_pop(L, 2); + return ((res == menu_return::RETURN_REPAINT) || (res == menu_return::RETURN_EXIT_REPAINT)); +} + +void CLuaInstance::MenuRegister(lua_State *L) +{ + luaL_Reg meth[] = { + { "new", CLuaInstance::MenuNew }, + { "addKey", CLuaInstance::MenuAddKey }, + { "addItem", CLuaInstance::MenuAddItem }, + { "exec", CLuaInstance::MenuExec }, + { "hide", CLuaInstance::MenuHide }, + { "__gc", CLuaInstance::MenuDelete }, + { NULL, NULL } + }; + + luaL_newmetatable(L, "menu"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "menu"); + + // keep misspelled "menue" for backwards-compatibility + luaL_newmetatable(L, "menu"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "menue"); +} + +CLuaMenu *CLuaInstance::MenuCheck(lua_State *L, int n) +{ + return *(CLuaMenu **) luaL_checkudata(L, n, "menu"); +} + +CLuaMenu::CLuaMenu() +{ + m = NULL; + observ = new CLuaMenuChangeObserver(); +} + +CLuaMenu::~CLuaMenu() +{ + delete m; + delete observ; +} + +CLuaMenuForwarder::CLuaMenuForwarder(lua_State *_L, std::string _luaAction, std::string _luaId) +{ + L = _L; + luaAction = _luaAction; + luaId = _luaId; +} + +CLuaMenuForwarder::~CLuaMenuForwarder() +{ +} + +int CLuaMenuForwarder::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) +{ + int res = menu_return::RETURN_REPAINT; + if (!luaAction.empty()){ + lua_pushglobaltable(L); + lua_getfield(L, -1, luaAction.c_str()); + lua_remove(L, -2); + lua_pushstring(L, luaId.c_str()); + int status = lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0); + if (status) { + fprintf(stderr, "[CLuaInstance::%s] error in script: %s\n", __func__, lua_tostring(L, -1)); + ShowMsg2UTF("Lua script error:", lua_tostring(L, -1), CMsgBox::mbrBack, CMsgBox::mbBack); + } + if (lua_isnumber(L, -1)) + res = (int) lua_tonumber(L, -1); + lua_pop(L, 1); + } + return res; +} + +CLuaMenuFilebrowser::CLuaMenuFilebrowser(lua_State *_L, std::string _luaAction, std::string _luaId, std::string *_value, bool _dirMode) : CLuaMenuForwarder(_L, _luaAction, _luaId) +{ + value = _value; + dirMode = _dirMode; +} + +int CLuaMenuFilebrowser::exec(CMenuTarget* /*parent*/, const std::string& /*actionKey*/) +{ + CFileBrowser fileBrowser; + fileBrowser.Dir_Mode = dirMode; + + CFileFilter fileFilter; + for (std::vector::iterator it = filter.begin(); it != filter.end(); ++it) + fileFilter.addFilter(*it); + if (!filter.empty()) + fileBrowser.Filter = &fileFilter; + + if (fileBrowser.exec(value->c_str()) == true) + *value = fileBrowser.getSelectedFile()->Name; + + if (!luaAction.empty()){ + lua_pushglobaltable(L); + lua_getfield(L, -1, luaAction.c_str()); + lua_remove(L, -2); + lua_pushstring(L, value->c_str()); + lua_pcall(L, 1 /* one arg */, 1 /* one result */, 0); + lua_pop(L, 1); + } + return menu_return::RETURN_REPAINT; +} + +CLuaMenuStringinput::CLuaMenuStringinput(lua_State *_L, std::string _luaAction, std::string _luaId, const char *_name, std::string *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms) : CLuaMenuForwarder(_L, _luaAction, _luaId) +{ + name = _name; + value = _value; + size = _size; + valid_chars = _valid_chars; + icon = _icon; + observ = _observ; + sms = _sms; +} + +int CLuaMenuStringinput::exec(CMenuTarget* /*parent*/, const std::string & /*actionKey*/) +{ + CStringInput *i; + if (sms) + i = new CStringInputSMS((char *)name, value, size, + NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, valid_chars.c_str(), observ, icon); + else + i = new CStringInput((char *)name, value, size, + NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, valid_chars.c_str(), observ, icon); + i->exec(NULL, ""); + delete i; + if (!luaAction.empty()){ + lua_pushglobaltable(L); + lua_getfield(L, -1, luaAction.c_str()); + lua_remove(L, -2); + lua_pushstring(L, luaId.c_str()); + lua_pushstring(L, value->c_str()); + lua_pcall(L, 2 /* two args */, 1 /* one result */, 0); + lua_pop(L, 2); + } + return menu_return::RETURN_REPAINT; +} + +int CLuaInstance::MenuNew(lua_State *L) +{ + CMenuWidget *m; + + if (lua_istable(L, 1)) { + std::string name, icon; + tableLookup(L, "name", name) || tableLookup(L, "title", name); + tableLookup(L, "icon", icon); + int mwidth; + if(tableLookup(L, "mwidth", mwidth)) + m = new CMenuWidget(name.c_str(), icon.c_str(), mwidth); + else + m = new CMenuWidget(name.c_str(), icon.c_str()); + } else + m = new CMenuWidget(); + + CLuaMenu **udata = (CLuaMenu **) lua_newuserdata(L, sizeof(CLuaMenu *)); + *udata = new CLuaMenu(); + (*udata)->m = m; + luaL_getmetatable(L, "menu"); + lua_setmetatable(L, -2); + return 1; +} + +int CLuaInstance::MenuDelete(lua_State *L) +{ + CLuaMenu *m = MenuCheck(L, 1); + if (!m) + return 0; + + while(!m->targets.empty()) { + delete m->targets.back(); + m->targets.pop_back(); + } + while(!m->tofree.empty()) { + free(m->tofree.back()); + m->tofree.pop_back(); + } + + delete m; + return 0; +} + +int CLuaInstance::MenuAddKey(lua_State *L) +{ + CLuaMenu *m = MenuCheck(L, 1); + if (!m) + return 0; + lua_assert(lua_istable(L, 2)); + + std::string action; tableLookup(L, "action", action); + std::string id; tableLookup(L, "id", id); + int directkey = CRCInput::RC_nokey; tableLookup(L, "directkey", directkey); + if (action != "" && directkey != (int) CRCInput::RC_nokey) { + CLuaMenuForwarder *forwarder = new CLuaMenuForwarder(L, action, id); + m->m->addKey(directkey, forwarder, action); + m->targets.push_back(forwarder); + } + return 0; +} + +int CLuaInstance::MenuAddItem(lua_State *L) +{ + CLuaMenu *m = MenuCheck(L, 1); + if (!m) + return 0; + lua_assert(lua_istable(L, 2)); + + CLuaMenuItem i; + m->items.push_back(i); + CLuaMenuItem *b = &m->items.back(); + + tableLookup(L, "name", b->name); + std::string icon; tableLookup(L, "icon", icon); + std::string type; tableLookup(L, "type", type); + if (type == "back") { + m->m->addItem(GenericMenuBack); + } else if (type == "separator") { + if (!b->name.empty()) { + m->m->addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, b->name.c_str(), NONEXISTANT_LOCALE)); + } else { + m->m->addItem(GenericMenuSeparatorLine); + } + } else { + std::string right_icon; tableLookup(L, "right_icon", right_icon); + std::string action; tableLookup(L, "action", action); + std::string value; tableLookup(L, "value", value); + std::string hint; tableLookup(L, "hint", hint); + std::string hint_icon; tableLookup(L, "hint_icon", hint_icon); + std::string id; tableLookup(L, "id", id); + std::string tmp; + int directkey = CRCInput::RC_nokey; tableLookup(L, "directkey", directkey); + int pulldown = false; tableLookup(L, "pulldown", pulldown); + tmp = "true"; + tableLookup(L, "enabled", tmp) || tableLookup(L, "active", tmp); + bool enabled = (tmp == "true" || tmp == "1" || tmp == "yes"); + tableLookup(L, "range", tmp); + int range_from = 0, range_to = 99; + sscanf(tmp.c_str(), "%d,%d", &range_from, &range_to); + + CMenuItem *mi = NULL; + + if (type == "forwarder") { + b->str_val = value; + CLuaMenuForwarder *forwarder = new CLuaMenuForwarder(L, action, id); + mi = new CMenuForwarder(b->name, enabled, b->str_val, forwarder, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + if (!hint.empty() || !hint_icon.empty()) + mi->setHint(hint_icon, hint); + m->targets.push_back(forwarder); + } else if (type == "chooser") { + int options_count = 0; + lua_pushstring(L, "options"); + lua_gettable(L, -2); + if (lua_istable(L, -1)) + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + options_count++; + } + lua_pop(L, 1); + + CMenuOptionChooser::keyval_ext *kext = (CMenuOptionChooser::keyval_ext *)calloc(options_count, sizeof(CMenuOptionChooser::keyval_ext)); + m->tofree.push_back(kext); + lua_pushstring(L, "options"); + lua_gettable(L, -2); + b->int_val = 0; + int j = 0; + if (lua_istable(L, -1)) + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + const char *key = lua_tostring(L, -1); + const char *val = lua_tostring(L, -2); + kext[j].key = atoi(key); + kext[j].value = NONEXISTANT_LOCALE; + kext[j].valname = strdup(val); + m->tofree.push_back((void *)kext[j].valname); + if (!strcmp(value.c_str(), kext[j].valname)) + b->int_val = kext[j].key; + j++; + } + lua_pop(L, 1); + mi = new CMenuOptionChooser(b->name.c_str(), &b->int_val, kext, options_count, enabled, m->observ, directkey, icon.c_str(), pulldown); + } else if (type == "numeric") { + b->int_val = range_from; + sscanf(value.c_str(), "%d", &b->int_val); + mi = new CMenuOptionNumberChooser(b->name, &b->int_val, enabled, range_from, range_to, m->observ, 0, 0, NONEXISTANT_LOCALE, pulldown); + } else if (type == "string") { + b->str_val = value; + mi = new CMenuOptionStringChooser(b->name.c_str(), &b->str_val, enabled, m->observ, directkey, icon.c_str(), pulldown); + } else if (type == "stringinput") { + b->str_val = value; + std::string valid_chars = "abcdefghijklmnopqrstuvwxyz0123456789!\"§$%&/()=?-. "; + tableLookup(L, "valid_chars", valid_chars); + int sms = 0; tableLookup(L, "sms", sms); + int size = 30; tableLookup(L, "size", size); + CLuaMenuStringinput *stringinput = new CLuaMenuStringinput(L, action, id, b->name.c_str(), &b->str_val, size, valid_chars, m->observ, icon.c_str(), sms); + mi = new CMenuForwarder(b->name, enabled, b->str_val, stringinput, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + m->targets.push_back(stringinput); + } else if (type == "filebrowser") { + b->str_val = value; + int dirMode = 0; tableLookup(L, "dir_mode", dirMode); + CLuaMenuFilebrowser *filebrowser = new CLuaMenuFilebrowser(L, action, id, &b->str_val, dirMode); + lua_pushstring(L, "filter"); + lua_gettable(L, -2); + if (lua_istable(L, -1)) + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + const char *val = lua_tostring(L, -2); + filebrowser->addFilter(val); + } + lua_pop(L, 1); + + mi = new CMenuForwarder(b->name, enabled, b->str_val, filebrowser, NULL/*ActionKey*/, directkey, icon.c_str(), right_icon.c_str()); + m->targets.push_back(filebrowser); + } + if (mi) { + mi->setLua(L, action, id); + if (!hint.empty() || !hint_icon.empty()) + mi->setHint(hint_icon, hint); + m->m->addItem(mi); + } + } + return 0; +} + +int CLuaInstance::MenuHide(lua_State *L) +{ + CLuaMenu *m = MenuCheck(L, 1); + if (!m) + return 0; + m->m->hide(); + return 0; +} + +int CLuaInstance::MenuExec(lua_State *L) +{ + CLuaMenu *m = MenuCheck(L, 1); + if (!m) + return 0; + m->m->exec(NULL, ""); + m->m->hide(); + return 0; +} + +void CLuaInstance::HintboxRegister(lua_State *L) +{ + luaL_Reg meth[] = { + { "new", CLuaInstance::HintboxNew }, + { "exec", CLuaInstance::HintboxExec }, + { "paint", CLuaInstance::HintboxPaint }, + { "hide", CLuaInstance::HintboxHide }, + { "__gc", CLuaInstance::HintboxDelete }, + { NULL, NULL } + }; + + luaL_newmetatable(L, "hintbox"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "hintbox"); +} + +CLuaHintbox *CLuaInstance::HintboxCheck(lua_State *L, int n) +{ + return *(CLuaHintbox **) luaL_checkudata(L, n, "hintbox"); +} + +CLuaHintbox::CLuaHintbox() +{ + caption = NULL; + b = NULL; +} + +CLuaHintbox::~CLuaHintbox() +{ + if (caption) + free(caption); + delete b; +} + +int CLuaInstance::HintboxNew(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + + std::string name, text, icon = std::string(NEUTRINO_ICON_INFO); + tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); + tableLookup(L, "text", text); + tableLookup(L, "icon", icon); + int width = 450; + tableLookup(L, "width", width); + + CLuaHintbox **udata = (CLuaHintbox **) lua_newuserdata(L, sizeof(CLuaHintbox *)); + *udata = new CLuaHintbox(); + (*udata)->caption = strdup(name.c_str()); + (*udata)->b = new CHintBox((*udata)->caption, text.c_str(), width, icon.c_str()); + luaL_getmetatable(L, "hintbox"); + lua_setmetatable(L, -2); + return 1; +} + +int CLuaInstance::HintboxDelete(lua_State *L) +{ + CLuaHintbox *m = HintboxCheck(L, 1); + delete m; + return 0; +} + +int CLuaInstance::HintboxPaint(lua_State *L) +{ + CLuaHintbox *m = HintboxCheck(L, 1); + if (!m) + return 0; + m->b->paint(); + return 0; +} + +int CLuaInstance::HintboxHide(lua_State *L) +{ + CLuaHintbox *m = HintboxCheck(L, 1); + m->b->hide(); + return 0; +} + +int CLuaInstance::HintboxExec(lua_State *L) +{ + CLuaHintbox *m = HintboxCheck(L, 1); + if (!m) + return 0; + int timeout = -1; + if (lua_isnumber(L, -1)) + timeout = (int) lua_tonumber(L, -1); + m->b->paint(); + + // copied from gui/widget/hintbox.cpp + + neutrino_msg_t msg; + neutrino_msg_data_t data; + if ( timeout == -1 ) + timeout = 5; /// default timeout 5 sec + //timeout = g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR]; + + uint64_t timeoutEnd = CRCInput::calcTimeoutEnd( timeout ); + + int res = messages_return::none; + + while ( ! ( res & ( messages_return::cancel_info | messages_return::cancel_all ) ) ) + { + g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); + + if ((msg == CRCInput::RC_timeout) || (msg == CRCInput::RC_ok)) + res = messages_return::cancel_info; + else if(msg == CRCInput::RC_home) + res = messages_return::cancel_all; + else if ((m->b->has_scrollbar()) && ((msg == CRCInput::RC_up) || (msg == CRCInput::RC_down))) + { + if (msg == CRCInput::RC_up) + m->b->scroll_up(); + else + m->b->scroll_down(); + } + else if((msg == CRCInput::RC_sat) || (msg == CRCInput::RC_favorites)) { + } + else if(msg == CRCInput::RC_mode) { + res = messages_return::handled; + break; + } + else if((msg == CRCInput::RC_next) || (msg == CRCInput::RC_prev)) { + res = messages_return::cancel_all; + g_RCInput->postMsg(msg, data); + } + else + { + res = CNeutrinoApp::getInstance()->handleMsg(msg, data); + if (res & messages_return::unhandled) + { + + // leave here and handle above... + g_RCInput->postMsg(msg, data); + res = messages_return::cancel_all; + } + } + } + m->b->hide(); + return 0; +} + +void CLuaInstance::MessageboxRegister(lua_State *L) +{ + luaL_Reg meth[] = { + { "exec", CLuaInstance::MessageboxExec }, + { NULL, NULL } + }; + + luaL_newmetatable(L, "messagebox"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "messagebox"); +} + +// messagebox.exec{caption="Title", text="text", icon="settings", width=500,timeout=-1,return_default_on_timeout=0, +// default = "yes", buttons = { "yes", "no", "cancel", "all", "back", "ok" }, align="center1|center2|left|right" } +int CLuaInstance::MessageboxExec(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + + std::string name, text, icon = std::string(NEUTRINO_ICON_INFO); + tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); + tableLookup(L, "text", text); + tableLookup(L, "icon", icon); + int timeout = -1, width = 450, return_default_on_timeout = 0, show_buttons = 0, default_button = 0; + tableLookup(L, "timeout", timeout); + tableLookup(L, "width", width); + tableLookup(L, "return_default_on_timeout", return_default_on_timeout); + + std::string tmp; + if (tableLookup(L, "align", tmp)) { + lua_pushvalue(L, -2); + const char *val = lua_tostring(L, -2); + table_key mb[] = { + { "center1", CMessageBox::mbBtnAlignCenter1 }, + { "center2", CMessageBox::mbBtnAlignCenter1 }, + { "left", CMessageBox::mbBtnAlignLeft }, + { "right", CMessageBox::mbBtnAlignRight }, + { NULL, 0 } + }; + for (int i = 0; mb[i].name; i++) + if (!strcmp(mb[i].name, val)) { + show_buttons |= mb[i].code; + break; + } + } + lua_pushstring(L, "buttons"); + lua_gettable(L, -2); + for (lua_pushnil(L); lua_next(L, -2); lua_pop(L, 2)) { + lua_pushvalue(L, -2); + const char *val = lua_tostring(L, -2); + table_key mb[] = { + { "yes", CMessageBox::mbYes }, + { "no", CMessageBox::mbNo }, + { "cancel", CMessageBox::mbCancel }, + { "all", CMessageBox::mbAll }, + { "back", CMessageBox::mbBack }, + { "ok", CMessageBox::mbOk }, + { NULL, 0 } + }; + for (int i = 0; mb[i].name; i++) + if (!strcmp(mb[i].name, val)) { + show_buttons |= mb[i].code; + break; + } + } + lua_pop(L, 1); + + table_key mbr[] = { + { "yes", CMessageBox::mbrYes }, + { "no", CMessageBox::mbrNo }, + { "cancel", CMessageBox::mbrCancel }, + { "back", CMessageBox::mbrBack }, + { "ok", CMessageBox::mbrOk }, + { NULL, 0 } + }; + if (tableLookup(L, "default", tmp)) { + lua_pushvalue(L, -2); + const char *val = lua_tostring(L, -2); + for (int i = 0; mbr[i].name; i++) + if (!strcmp(mbr[i].name, val)) { + default_button = mbr[i].code; + break; + } + } + + int res = ShowMsg(name, text, (CMessageBox::result_) default_button, (CMessageBox::buttons_) show_buttons, icon.empty() ? NULL : icon.c_str(), width, timeout, return_default_on_timeout); + + tmp = "cancel"; + for (int i = 0; mbr[i].name; i++) + if ((uint32_t)res == mbr[i].code) { + tmp = mbr[i].name; + break; + } + lua_pushstring(L, tmp.c_str()); + + return 1; +} + +// -------------------------------------------------------------------------------- + +void CLuaInstance::CWindowRegister(lua_State *L) +{ + luaL_Reg meth[] = { + { "new", CLuaInstance::CWindowNew }, + { "paint", CLuaInstance::CWindowPaint }, + { "hide", CLuaInstance::CWindowHide }, + { "__gc", CLuaInstance::CWindowDelete }, + { NULL, NULL } + }; +#if 0 + { "exec", CLuaInstance::CWindowExec }, +#endif + + luaL_newmetatable(L, "cwindow"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "cwindow"); +} + +int CLuaInstance::CWindowNew(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + + std::string name, icon = std::string(NEUTRINO_ICON_INFO); + int x = 100, y = 100, dx = 450, dy = 250; + tableLookup(L, "x", x); + tableLookup(L, "y", y); + tableLookup(L, "dx", dx); + tableLookup(L, "dy", dy); + tableLookup(L, "name", name) || tableLookup(L, "title", name) || tableLookup(L, "caption", name); + tableLookup(L, "icon", icon); + + CLuaCWindow **udata = (CLuaCWindow **) lua_newuserdata(L, sizeof(CLuaCWindow *)); + *udata = new CLuaCWindow(); + (*udata)->w = new CComponentsWindow(x, y, dx, dy, name.c_str(), icon.c_str()); + luaL_getmetatable(L, "cwindow"); + lua_setmetatable(L, -2); + return 1; +} + +CLuaCWindow *CLuaInstance::CWindowCheck(lua_State *L, int n) +{ + return *(CLuaCWindow **) luaL_checkudata(L, n, "cwindow"); +} + +int CLuaInstance::CWindowPaint(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + int do_save_bg = 1; + tableLookup(L, "do_save_bg", do_save_bg); + + CLuaCWindow *m = CWindowCheck(L, 1); + if (!m) + return 0; + + m->w->paint((do_save_bg!=0)?true:false); + return 0; +} + +int CLuaInstance::CWindowHide(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + int no_restore = 0; + tableLookup(L, "no_restore", no_restore); + + CLuaCWindow *m = CWindowCheck(L, 1); + if (!m) + return 0; + + m->w->hide((no_restore!=0)?true:false); + return 0; +} + +int CLuaInstance::CWindowDelete(lua_State *L) +{ + CLuaCWindow *m = CWindowCheck(L, 1); + if (!m) + return 0; + + m->w->kill(); + delete m; + return 0; +} + +// -------------------------------------------------------------------------------- + +CLuaSignalBox *CLuaInstance::SignalBoxCheck(lua_State *L, int n) +{ + return *(CLuaSignalBox **) luaL_checkudata(L, n, "signalbox"); +} + +void CLuaInstance::SignalBoxRegister(lua_State *L) +{ + luaL_Reg meth[] = { + { "new", CLuaInstance::SignalBoxNew }, + { "paint", CLuaInstance::SignalBoxPaint }, + { "__gc", CLuaInstance::SignalBoxDelete }, + { NULL, NULL } + }; + + luaL_newmetatable(L, "signalbox"); + luaL_setfuncs(L, meth, 0); + lua_pushvalue(L, -1); + lua_setfield(L, -1, "__index"); + lua_setglobal(L, "signalbox"); +} + +int CLuaInstance::SignalBoxNew(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + + std::string name, icon = std::string(NEUTRINO_ICON_INFO); + int x = 110, y = 150, dx = 430, dy = 150; + int vertical = true; + tableLookup(L, "x", x); + tableLookup(L, "y", y); + tableLookup(L, "dx", dx); + tableLookup(L, "dy", dy); + tableLookup(L, "vertical", vertical); + + CLuaSignalBox **udata = (CLuaSignalBox **) lua_newuserdata(L, sizeof(CLuaSignalBox *)); + *udata = new CLuaSignalBox(); + (*udata)->s = new CSignalBox(x, y, dx, dy, NULL, (vertical!=0)?true:false); + luaL_getmetatable(L, "signalbox"); + lua_setmetatable(L, -2); + return 1; +} + +int CLuaInstance::SignalBoxPaint(lua_State *L) +{ + lua_assert(lua_istable(L,1)); + int do_save_bg = 1; + tableLookup(L, "do_save_bg", do_save_bg); + + CLuaSignalBox *m = SignalBoxCheck(L, 1); + if (!m) + return 0; + + m->s->paint((do_save_bg!=0)?true:false); + return 0; +} + +int CLuaInstance::SignalBoxDelete(lua_State *L) +{ + CLuaSignalBox *m = SignalBoxCheck(L, 1); + if (!m) + return 0; + + m->s->kill(); + delete m; + return 0; +} + +// -------------------------------------------------------------------------------- diff --git a/src/gui/luainstance.h b/src/gui/luainstance.h index fe1a250ff..74c155fe0 100644 --- a/src/gui/luainstance.h +++ b/src/gui/luainstance.h @@ -26,6 +26,10 @@ extern "C" { #include } #include +#include +#include +#include +#include /* this is stored as userdata in the lua_State */ struct CLuaData @@ -34,11 +38,109 @@ struct CLuaData CRCInput *rcinput; }; +struct CLuaMenuItem +{ + int int_val; + std::string str_val; + std::string name; +}; + +class CLuaMenuChangeObserver : public CChangeObserver +{ + public: + bool changeNotify(lua_State *, const std::string &, const std::string &, void *); +}; + +class CLuaMenu +{ + public: + CMenuWidget *m; + CLuaMenuChangeObserver *observ; + std::list items; + std::list targets; + std::list tofree; + CLuaMenu(); + ~CLuaMenu(); +}; + +class CLuaMenuForwarder : public CMenuTarget +{ + public: + lua_State *L; + std::string luaAction; + std::string luaId; + CLuaMenuForwarder(lua_State *L, std::string _luaAction, std::string _luaId); + ~CLuaMenuForwarder(); + int exec(CMenuTarget* parent, const std::string & actionKey); +}; + +class CLuaMenuFilebrowser : public CLuaMenuForwarder +{ + private: + std::string *value; + bool dirMode; + std::vector filter; + public: + CLuaMenuFilebrowser(lua_State *_L, std::string _luaAction, std::string _luaId, std::string *_value, bool _dirMode); + int exec(CMenuTarget* parent, const std::string & actionKey); + void addFilter(std::string s) { filter.push_back(s); }; +}; + +class CLuaMenuStringinput : public CLuaMenuForwarder +{ + private: + std::string *value; + std::string valid_chars; + const char *name; + const char *icon; + bool sms; + int size; + CChangeObserver *observ; + public: + CLuaMenuStringinput(lua_State *_L, std::string _luaAction, std::string _luaId, const char *_name, std::string *_value, int _size, std::string _valid_chars, CChangeObserver *_observ, const char *_icon, bool _sms); + int exec(CMenuTarget* parent, const std::string & actionKey); +}; + +class CLuaHintbox +{ + public: + CHintBox *b; + char *caption; + CLuaHintbox(); + ~CLuaHintbox(); +}; + +class CLuaMessagebox +{ + public: + CMessageBox *b; + CLuaMessagebox(); + ~CLuaMessagebox(); +}; + +class CLuaCWindow +{ + public: + CComponentsWindow *w; + CLuaCWindow() { w = NULL; } + ~CLuaCWindow() { delete w; } +}; + +class CLuaSignalBox +{ + public: + CSignalBox *s; + CLuaSignalBox() { s = NULL; } + ~CLuaSignalBox() { delete s; } +}; + + /* inspired by Steve Kemp http://www.steve.org.uk/ */ class CLuaInstance { static const char className[]; static const luaL_Reg methods[]; + static const luaL_Reg menu_methods[]; static CLuaData *CheckData(lua_State *L, int narg); public: CLuaInstance(); @@ -56,6 +158,47 @@ private: static int FontHeight(lua_State *L); static int GetInput(lua_State *L); static int GCWindow(lua_State *L); + static int Blit(lua_State *L); + static int GetLanguage(lua_State *L); + static int GetSize(lua_State *L); + static int DisplayImage(lua_State *L); + + void MenuRegister(lua_State *L); + static int MenuNew(lua_State *L); + static int MenuDelete(lua_State *L); + static int MenuAddKey(lua_State *L); + static int MenuAddItem(lua_State *L); + static int MenuHide(lua_State *L); + static int MenuExec(lua_State *L); + static CLuaMenu *MenuCheck(lua_State *L, int n); + + void HintboxRegister(lua_State *L); + static int HintboxNew(lua_State *L); + static int HintboxDelete(lua_State *L); + static int HintboxExec(lua_State *L); + static int HintboxPaint(lua_State *L); + static int HintboxHide(lua_State *L); + static CLuaHintbox *HintboxCheck(lua_State *L, int n); + + void MessageboxRegister(lua_State *L); + static int MessageboxExec(lua_State *L); + static CLuaMessagebox *MessageboxCheck(lua_State *L, int n); + + void CWindowRegister(lua_State *L); + static int CWindowNew(lua_State *L); + static CLuaCWindow *CWindowCheck(lua_State *L, int n); + static int CWindowPaint(lua_State *L); + static int CWindowHide(lua_State *L); + static int CWindowDelete(lua_State *L); + + static CLuaSignalBox *SignalBoxCheck(lua_State *L, int n); + static void SignalBoxRegister(lua_State *L); + static int SignalBoxNew(lua_State *L); + static int SignalBoxPaint(lua_State *L); + static int SignalBoxDelete(lua_State *L); + + static bool tableLookup(lua_State*, const char*, std::string&); + static bool tableLookup(lua_State*, const char*, int&); }; #endif /* _LUAINSTANCE_H */ diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index 03f10ebe7..856683fe9 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -110,7 +110,7 @@ int CMiscMenue::exec(CMenuTarget* parent, const std::string &actionKey) // e.g. vtxt-plugins sprintf(id, "%d", count); enabled_count++; - MoviePluginSelector.addItem(new CMenuForwarderNonLocalized(g_PluginList->getName(count), true, NULL, new COnekeyPluginChangeExec(), id, CRCInput::convertDigitToKey(count)), (cnt == 0)); + MoviePluginSelector.addItem(new CMenuForwarder(g_PluginList->getName(count), true, NULL, new COnekeyPluginChangeExec(), id, CRCInput::convertDigitToKey(count)), (cnt == 0)); cnt++; } } @@ -124,7 +124,7 @@ int CMiscMenue::exec(CMenuTarget* parent, const std::string &actionKey) unsigned num = CEitManager::getInstance()->getEventsCount(); char str[128]; sprintf(str, "Event count: %d", num); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack); return menu_return::RETURN_REPAINT; } else if(actionKey == "energy") @@ -272,7 +272,7 @@ int CMiscMenue::showMiscSettingsMenu() //CPU CMenuWidget misc_menue_cpu("CPU", NEUTRINO_ICON_SETTINGS, width); showMiscSettingsMenuCPUFreq(&misc_menue_cpu); - misc_menue.addItem( new CMenuForwarderNonLocalized("CPU", true, NULL, &misc_menue_cpu, NULL, CRCInput::RC_4)); + misc_menue.addItem( new CMenuForwarder("CPU", true, NULL, &misc_menue_cpu, NULL, CRCInput::RC_4)); #endif /*CPU_FREQ*/ int res = misc_menue.exec(NULL, ""); @@ -364,7 +364,7 @@ int CMiscMenue::showMiscSettingsMenuEnergy() ms_energy->addItem(m1); ms_energy->addItem(m2); - m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, NULL, new CSleepTimerWidget, "permanent"); + m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, NULL, new CSleepTimerWidget(true)); m2->setHint("", LOCALE_MENU_HINT_INACT_TIMER); ms_energy->addItem(m2); diff --git a/src/gui/motorcontrol.cpp b/src/gui/motorcontrol.cpp index ab86826c2..954aad025 100644 --- a/src/gui/motorcontrol.cpp +++ b/src/gui/motorcontrol.cpp @@ -117,7 +117,7 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) CZapitClient::commandSetScanSatelliteList sat; sat.position = CServiceManager::getInstance()->GetSatellitePosition(scansettings.satName); - strncpy(sat.satName, scansettings.satName, 49); + strncpy(sat.satName, scansettings.satName.c_str(), sizeof(sat.satName)); satList.push_back(sat); satellite_map_t & satmap = frontend->getSatellites(); @@ -131,8 +131,8 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) g_Zapit->setScanSatelliteList(satList); CZapit::getInstance()->SetLiveFrontend(frontend); - TP.feparams.dvb_feparams.frequency = atoi(scansettings.sat_TP_freq); - TP.feparams.dvb_feparams.u.qpsk.symbol_rate = atoi(scansettings.sat_TP_rate); + TP.feparams.dvb_feparams.frequency = atoi(scansettings.sat_TP_freq.c_str()); + TP.feparams.dvb_feparams.u.qpsk.symbol_rate = atoi(scansettings.sat_TP_rate.c_str()); TP.feparams.dvb_feparams.u.qpsk.fec_inner = (fe_code_rate_t)scansettings.sat_TP_fec; TP.polarization = scansettings.sat_TP_pol; @@ -223,7 +223,7 @@ int CMotorControl::exec(CMenuTarget* parent, const std::string &) buf += " "; buf += satname; buf += " ?"; - store = (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); + store = (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); } } if(store) @@ -582,7 +582,6 @@ void CMotorControl::showSNR () if (signalbox == NULL){ int xpos1 = x + 10; signalbox = new CSignalBox(xpos1, y + height - mheight - 5, width - 2*(xpos1-x), g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(), frontend, false); - signalbox->setScaleWidth(60); /*%*/ signalbox->setColorBody(COL_MENUCONTENT_PLUS_0); signalbox->setTextColor(COL_MENUCONTENT_TEXT); signalbox->doPaintBg(true); diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index bf62c12e6..d8ee4d71a 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -1837,7 +1837,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) char buf1[1024]; memset(buf1, '\0', sizeof(buf1)); snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_MOVIEBROWSER_ASK_REC_TO_DELETE), delName.c_str()); - if(ShowMsgUTF(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, + if(ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo) onDelete = false; else { @@ -1873,7 +1873,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) } else if (msg == CRCInput::RC_text || msg == CRCInput::RC_radio) { if((show_mode == MB_SHOW_RECORDS) && - (ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, msg == CRCInput::RC_radio ? "Copy jumps from movie to new file ?" : "Copy jumps from movie to new files ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) { + (ShowMsg (LOCALE_MESSAGEBOX_INFO, msg == CRCInput::RC_radio ? "Copy jumps from movie to new file ?" : "Copy jumps from movie to new files ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Coping, please wait"); hintBox->paint(); sleep(1); @@ -1883,7 +1883,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) off64_t res = copy_movie(m_movieSelectionHandler, &m_movieInfo, msg == CRCInput::RC_radio); //g_RCInput->clearRCMsg(); if(res == 0) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Copy failed, is there jump bookmarks ? Or check free space.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Copy failed, is there jump bookmarks ? Or check free space.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else loadMovies(); refresh(); @@ -1892,11 +1892,11 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) else if (msg == CRCInput::RC_audio) { #if 0 if((m_movieSelectionHandler == playing_info) && (NeutrinoMessages::mode_ts == CNeutrinoApp::getInstance()->getMode())) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Impossible to cut playing movie.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Impossible to cut playing movie.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else #endif if((show_mode == MB_SHOW_RECORDS) && - (ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, "Cut jumps from movie ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) { + (ShowMsg (LOCALE_MESSAGEBOX_INFO, "Cut jumps from movie ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Cutting, please wait"); hintBox->paint(); sleep(1); @@ -1906,7 +1906,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) off64_t res = cut_movie(m_movieSelectionHandler, &m_movieInfo); //g_RCInput->clearRCMsg(); if(res == 0) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Cut failed, is there jump bookmarks ? Or check free space.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Cut failed, is there jump bookmarks ? Or check free space.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else { loadMovies(); } @@ -1916,11 +1916,11 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) else if (msg == CRCInput::RC_games) { if((show_mode == MB_SHOW_RECORDS) && m_movieSelectionHandler != NULL) { if((m_movieSelectionHandler == playing_info) && (NeutrinoMessages::mode_ts == CNeutrinoApp::getInstance()->getMode())) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Impossible to truncate playing movie.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Impossible to truncate playing movie.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else if(m_movieSelectionHandler->bookmarks.end == 0) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "No End bookmark defined!", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "No End bookmark defined!", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else { - if(ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, "Truncate movie ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { + if(ShowMsg (LOCALE_MESSAGEBOX_INFO, "Truncate movie ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, "Truncating, please wait"); hintBox->paint(); off64_t res = truncate_movie(m_movieSelectionHandler); @@ -1928,7 +1928,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) delete hintBox; g_RCInput->clearRCMsg(); if(res == 0) - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, "Truncate failed.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, "Truncate failed.", CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); else { //printf("New movie info: size %lld len %d\n", res, m_movieSelectionHandler->bookmarks.end/60); m_movieInfo.saveMovieInfo( *m_movieSelectionHandler); @@ -1940,7 +1940,7 @@ bool CMovieBrowser::onButtonPressMainFrame(neutrino_msg_t msg) } } else if (msg == CRCInput::RC_topleft) { if (m_movieSelectionHandler != NULL) { - if(ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, "Remove screenshot ?", CMessageBox::mbrNo, CMessageBox:: mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { + if(ShowMsg (LOCALE_MESSAGEBOX_INFO, "Remove screenshot ?", CMessageBox::mbrNo, CMessageBox:: mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { std::string fname = getScreenshotName(m_movieSelectionHandler->file.Name); if (fname != "") unlink(fname.c_str()); @@ -2186,7 +2186,7 @@ void CMovieBrowser::onDeleteFile(MI_MOVIE_INFO& movieSelectionHandler, bool skip msg += "\r\n "; msg += g_Locale->getText(LOCALE_FILEBROWSER_DODELETE2); - if ((skipAsk) || (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes)) + if ((skipAsk) || (ShowMsg(LOCALE_FILEBROWSER_DELETE, msg, CMessageBox::mbrYes, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes)) { CHintBox * hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MOVIEBROWSER_DELETE_INFO)); hintBox->paint(); @@ -2952,9 +2952,9 @@ int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info) CIntInput* pBookTypeIntInput[MAX_NUMBER_OF_BOOKMARK_ITEMS]; CMenuWidget* pBookItemMenu[MAX_NUMBER_OF_BOOKMARK_ITEMS]; - CIntInput bookStartIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&)movie_info->bookmarks.start, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); - CIntInput bookLastIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&)movie_info->bookmarks.lastPlayStop, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); - CIntInput bookEndIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&)movie_info->bookmarks.end, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); + CIntInput bookStartIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.start, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); + CIntInput bookLastIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.lastPlayStop, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); + CIntInput bookEndIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.end, 5, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); CMenuWidget bookmarkMenu (LOCALE_MOVIEBROWSER_HEAD , NEUTRINO_ICON_MOVIEPLAYER); @@ -2969,8 +2969,8 @@ int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info) for(int li =0 ; li < MI_MOVIE_BOOK_USER_MAX && li < MAX_NUMBER_OF_BOOKMARK_ITEMS; li++ ) { pBookNameInput[li] = new CStringInputSMS (LOCALE_MOVIEBROWSER_EDIT_BOOK, &movie_info->bookmarks.user[li].name, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_NAME_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_NAME_INFO2, "abcdefghijklmnopqrstuvwxyz0123456789-.: "); - pBookPosIntInput[li] = new CIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&) movie_info->bookmarks.user[li].pos, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); - pBookTypeIntInput[li] = new CIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int&) movie_info->bookmarks.user[li].length, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_TYPE_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_TYPE_INFO2); + pBookPosIntInput[li] = new CIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.user[li].pos, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_POS_INFO2); + pBookTypeIntInput[li] = new CIntInput (LOCALE_MOVIEBROWSER_EDIT_BOOK, (int *)&movie_info->bookmarks.user[li].length, 20, LOCALE_MOVIEBROWSER_EDIT_BOOK_TYPE_INFO1, LOCALE_MOVIEBROWSER_EDIT_BOOK_TYPE_INFO2); pBookItemMenu[li] = new CMenuWidget(LOCALE_MOVIEBROWSER_BOOK_HEAD, NEUTRINO_ICON_MOVIEPLAYER); pBookItemMenu[li]->addItem(GenericMenuSeparator); @@ -2978,7 +2978,7 @@ int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info) pBookItemMenu[li]->addItem( new CMenuForwarder(LOCALE_MOVIEBROWSER_BOOK_POSITION, true, pBookPosIntInput[li]->getValue(), pBookPosIntInput[li])); pBookItemMenu[li]->addItem( new CMenuForwarder(LOCALE_MOVIEBROWSER_BOOK_TYPE, true, pBookTypeIntInput[li]->getValue(),pBookTypeIntInput[li])); - bookmarkMenu.addItem( new CMenuForwarderNonLocalized (movie_info->bookmarks.user[li].name.c_str(), true, pBookPosIntInput[li]->getValue(),pBookItemMenu[li])); + bookmarkMenu.addItem( new CMenuForwarder (movie_info->bookmarks.user[li].name.c_str(), true, pBookPosIntInput[li]->getValue(),pBookItemMenu[li])); } /********************************************************************/ @@ -3032,9 +3032,9 @@ int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info) CStringInputSMS epgUserInput(LOCALE_MOVIEBROWSER_INFO_INFO1, &movie_info->epgInfo1, 20, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.: "); CDateInput dateUserDateInput(LOCALE_MOVIEBROWSER_INFO_LENGTH, &movie_info->dateOfLastPlay, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CDateInput recUserDateInput(LOCALE_MOVIEBROWSER_INFO_LENGTH, &movie_info->file.Time, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput lengthUserIntInput(LOCALE_MOVIEBROWSER_INFO_LENGTH, (int&)movie_info->length, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput lengthUserIntInput(LOCALE_MOVIEBROWSER_INFO_LENGTH, (int *)&movie_info->length, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CStringInputSMS countryUserInput(LOCALE_MOVIEBROWSER_INFO_PRODCOUNTRY, &movie_info->productionCountry, 11, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "ABCDEFGHIJKLMNOPQRSTUVWXYZ "); - CIntInput yearUserIntInput(LOCALE_MOVIEBROWSER_INFO_PRODYEAR, (int&)movie_info->productionDate, 4, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput yearUserIntInput(LOCALE_MOVIEBROWSER_INFO_PRODYEAR, (int *)&movie_info->productionDate, 4, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CMenuWidget movieInfoMenu(LOCALE_MOVIEBROWSER_HEAD, NEUTRINO_ICON_MOVIEPLAYER /*,m_cBoxFrame.iWidth*/); //TODO: check @@ -3123,13 +3123,13 @@ bool CMovieBrowser::showMenu(MI_MOVIE_INFO* /*movie_info*/) /********************************************************************/ /** optionsMenuBrowser **************************************************/ - CIntInput playMaxUserIntInput(LOCALE_MOVIEBROWSER_LAST_PLAY_MAX_ITEMS, (int&) m_settings.lastPlayMaxItems, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput recMaxUserIntInput(LOCALE_MOVIEBROWSER_LAST_RECORD_MAX_ITEMS, (int&) m_settings.lastRecordMaxItems, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput browserFrameUserIntInput(LOCALE_MOVIEBROWSER_BROWSER_FRAME_HIGH, (int&) m_settings.browserFrameHeight, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput browserRowNrIntInput(LOCALE_MOVIEBROWSER_BROWSER_ROW_NR, (int&) m_settings.browserRowNr, 1, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput playMaxUserIntInput(LOCALE_MOVIEBROWSER_LAST_PLAY_MAX_ITEMS, (int *)&m_settings.lastPlayMaxItems, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput recMaxUserIntInput(LOCALE_MOVIEBROWSER_LAST_RECORD_MAX_ITEMS, (int *)&m_settings.lastRecordMaxItems, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput browserFrameUserIntInput(LOCALE_MOVIEBROWSER_BROWSER_FRAME_HIGH, (int *)&m_settings.browserFrameHeight, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput browserRowNrIntInput(LOCALE_MOVIEBROWSER_BROWSER_ROW_NR, (int *)&m_settings.browserRowNr, 1, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CIntInput* browserRowWidthIntInput[MB_MAX_ROWS]; for(i=0; ibookmarks.user[i].pos + m_movieSelectionHandler->bookmarks.user[i].length; snprintf(book[i], 19,"%5d min",position[menu_nr]/60); - startPosSelectionMenu.addItem(new CMenuForwarderNonLocalized (m_movieSelectionHandler->bookmarks.user[i].name.c_str(), true, book[i])); + startPosSelectionMenu.addItem(new CMenuForwarder (m_movieSelectionHandler->bookmarks.user[i].name.c_str(), true, book[i])); menu_nr++; } } @@ -3693,7 +3693,7 @@ int CYTHistory::exec(CMenuTarget* parent, const std::string &actionKey) m->addItem(GenericMenuSeparatorLine); std::list::iterator it = settings->ytsearch_history.begin(); for (int i = 0; i < settings->ytsearch_history_size; i++, ++it) - m->addItem(new CMenuForwarderNonLocalized((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1))); + m->addItem(new CMenuForwarder((*it).c_str(), true, NULL, this, (*it).c_str(), CRCInput::convertDigitToKey(i + 1))); m->exec(NULL, ""); m->hide(); delete m; @@ -3752,9 +3752,8 @@ bool CMovieBrowser::showYTMenu() mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_MAX_RESULTS, &m_settings.ytresults, true, 10, 50, NULL)); mainMenu.addItem(new CMenuOptionNumberChooser(LOCALE_MOVIEBROWSER_YT_MAX_HISTORY, &m_settings.ytsearch_history_max, true, 10, 50, NULL)); - char rstr[20] = {0}; - sprintf(rstr, "%s", m_settings.ytregion.c_str()); - CMenuOptionStringChooser * region = new CMenuOptionStringChooser(LOCALE_MOVIEBROWSER_YT_REGION, rstr, true, NULL, CRCInput::RC_nokey, "", true); + std::string rstr = m_settings.ytregion; + CMenuOptionStringChooser * region = new CMenuOptionStringChooser(LOCALE_MOVIEBROWSER_YT_REGION, &rstr, true, NULL, CRCInput::RC_nokey, "", true); region->addOption("default"); region->addOption("DE"); region->addOption("PL"); @@ -4132,7 +4131,7 @@ int CDirMenu::show(void) { snprintf(tmp, sizeof(tmp),"%d",i); tmp[1]=0; - dirMenu.addItem( new CMenuForwarderNonLocalized ( (*dirList)[i].name.c_str(), (dirState[i] != DIR_STATE_UNKNOWN), dirOptionText[i], this,tmp)); + dirMenu.addItem( new CMenuForwarder ( (*dirList)[i].name.c_str(), (dirState[i] != DIR_STATE_UNKNOWN), dirOptionText[i], this,tmp)); } int ret = dirMenu.exec(NULL," "); return ret; @@ -4340,7 +4339,7 @@ static int get_input(bool * stop) * stop = false; g_RCInput->getMsg(&msg, &data, 1, false); if(msg == CRCInput::RC_home) { - if(ShowMsgUTF (LOCALE_MESSAGEBOX_INFO, "Cancel movie cut/split ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { + if(ShowMsg (LOCALE_MESSAGEBOX_INFO, "Cancel movie cut/split ?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { * stop = true; } } diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index e814a7d80..3871aef22 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -1024,7 +1024,7 @@ void CMoviePlayerGui::selectAudioPid(bool file_player) char cnt[5]; sprintf(cnt, "%d", count); - CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(apidtitle.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1)); + CMenuForwarder * item = new CMenuForwarder(apidtitle.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1)); APIDSelector.addItem(item, defpid); } @@ -1036,10 +1036,9 @@ void CMoviePlayerGui::selectAudioPid(bool file_player) int percent[numpida]; for (uint i=0; i < numpida; i++) { percent[i] = CZapit::getInstance()->GetPidVolume(p_movie_info->epgId, apids[i], ac3flags[i]); - APIDSelector.addItem(new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &percent[i], - currentapid == apids[i], - 0, 999, CVolume::getInstance(), 0, 0, NONEXISTANT_LOCALE, - p_movie_info->audioPids[i].epgAudioPidName.c_str())); + APIDSelector.addItem(new CMenuOptionNumberChooser(p_movie_info->audioPids[i].epgAudioPidName, + &percent[i], currentapid == apids[i], + 0, 999, CVolume::getInstance())); } } @@ -1356,7 +1355,7 @@ void CMoviePlayerGui::selectChapter() char cnt[5]; for (unsigned i = 0; i < positions.size(); i++) { sprintf(cnt, "%d", i); - CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(titles[i].c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i + 1)); + CMenuForwarder * item = new CMenuForwarder(titles[i].c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i + 1)); ChSelector.addItem(item, position > positions[i]); } ChSelector.exec(NULL, ""); @@ -1391,7 +1390,7 @@ void CMoviePlayerGui::selectSubtitle() title = pidnumber; } sprintf(cnt, "%d", count); - CMenuForwarderNonLocalized * item = new CMenuForwarderNonLocalized(title.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1)); + CMenuForwarder * item = new CMenuForwarder(title.c_str(), enabled, NULL, selector, cnt, CRCInput::convertDigitToKey(count + 1)); item->setItemButton(NEUTRINO_ICON_BUTTON_STOP, false); APIDSelector.addItem(item, defpid); } diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp index a74ac4106..fbd91f73e 100644 --- a/src/gui/network_setup.cpp +++ b/src/gui/network_setup.cpp @@ -127,7 +127,7 @@ int CNetworkSetup::exec(CMenuTarget* parent, const std::string &actionKey) } else if(actionKey=="restore") { - int result = ShowMsgUTF(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_RESET_SETTINGS_NOW), CMessageBox::mbrNo, + int result = ShowMsg(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_RESET_SETTINGS_NOW), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo , NEUTRINO_ICON_QUESTION, @@ -233,14 +233,14 @@ int CNetworkSetup::showNetworkSetup() m0->setHint("", LOCALE_MENU_HINT_NET_SETUPNOW); //eth id - CMenuForwarder *mac = new CMenuForwarderNonLocalized("MAC", false, mac_addr); + CMenuForwarder *mac = new CMenuForwarder("MAC", false, mac_addr); //prepare input entries - CIPInput networkSettings_NetworkIP(LOCALE_NETWORKMENU_IPADDRESS , network_address , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2, this); - CIPInput networkSettings_NetMask (LOCALE_NETWORKMENU_NETMASK , network_netmask , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); - CIPInput networkSettings_Broadcast(LOCALE_NETWORKMENU_BROADCAST , network_broadcast , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); - CIPInput networkSettings_Gateway (LOCALE_NETWORKMENU_GATEWAY , network_gateway , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); - CIPInput networkSettings_NameServer(LOCALE_NETWORKMENU_NAMESERVER, network_nameserver, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + CIPInput networkSettings_NetworkIP(LOCALE_NETWORKMENU_IPADDRESS , &network_address , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2, this); + CIPInput networkSettings_NetMask (LOCALE_NETWORKMENU_NETMASK , &network_netmask , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + CIPInput networkSettings_Broadcast(LOCALE_NETWORKMENU_BROADCAST , &network_broadcast , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + CIPInput networkSettings_Gateway (LOCALE_NETWORKMENU_GATEWAY , &network_gateway , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + CIPInput networkSettings_NameServer(LOCALE_NETWORKMENU_NAMESERVER, &network_nameserver, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); //hostname CStringInputSMS networkSettings_Hostname(LOCALE_NETWORKMENU_HOSTNAME, &network_hostname, 30, LOCALE_NETWORKMENU_HOSTNAME_HINT1, LOCALE_NETWORKMENU_HOSTNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-. "); @@ -535,7 +535,7 @@ bool CNetworkSetup::checkForIP() printf("[network setup] empty address %s\n", g_Locale->getText(n_settings[i].addr_name)); char msg[64]; snprintf(msg, 64, g_Locale->getText(LOCALE_NETWORKMENU_ERROR_NO_ADDRESS), g_Locale->getText(n_settings[i].addr_name)); - ShowMsgUTF(LOCALE_MAINSETTINGS_NETWORK, msg, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR, width); + ShowMsg(LOCALE_MAINSETTINGS_NETWORK, msg, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR, width); return false; } } @@ -578,7 +578,7 @@ void CNetworkSetup::applyNetworkSettings() int CNetworkSetup::saveChangesDialog() { // Save the settings after changes, if user wants to! - int result = ShowMsgUTF(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_APPLY_SETTINGS_NOW), CMessageBox::mbrYes, + int result = ShowMsg(LOCALE_MAINSETTINGS_NETWORK, g_Locale->getText(LOCALE_NETWORKMENU_APPLY_SETTINGS_NOW), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo , NEUTRINO_ICON_QUESTION, @@ -696,7 +696,7 @@ void CNetworkSetup::showCurrentNetworkSettings() + g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ": " + nameserver + '\n' + g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY ) + ": " + router; } - ShowMsgUTF(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 } const char * CNetworkSetup::mypinghost(std::string &host) @@ -792,7 +792,7 @@ void CNetworkSetup::testNetworkSettings() } } - ShowMsgUTF(LOCALE_NETWORKMENU_TEST, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_NETWORKMENU_TEST, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 } int CNetworkSetup::showWlanList() @@ -806,7 +806,7 @@ int CNetworkSetup::showWlanList() bool found = get_wlan_list(g_settings.ifname, networks); hintBox.hide(); if (!found) { - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_NETWORKMENU_SSID_SCAN_ERROR), CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_NETWORKMENU_SSID_SCAN_ERROR), CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 return res; } @@ -828,7 +828,7 @@ int CNetworkSetup::showWlanList() const char * icon = NULL; if (networks[i].encrypted) icon = NEUTRINO_ICON_LOCK; - CMenuForwarderNonLocalized * net = new CMenuForwarderNonLocalized(networks[i].ssid.c_str(), true, option[i], selector, cnt, CRCInput::RC_nokey, NULL, icon); + CMenuForwarder * net = new CMenuForwarder(networks[i].ssid.c_str(), true, option[i], selector, cnt, CRCInput::RC_nokey, NULL, icon); net->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); wlist.addItem(net, networks[i].ssid == network_ssid); } diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 4cb28a441..86e8ccc60 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -183,7 +183,7 @@ int CNFSMountGui::menu() { sprintf(s2,"mountentry%d",i); ISO_8859_1_entry[i] = ZapitTools::UTF8_to_Latin1(m_entry[i].c_str()); - mountMenuEntry[i] = new CMenuForwarderNonLocalized("", true, ISO_8859_1_entry[i], this, s2); + mountMenuEntry[i] = new CMenuForwarder("", true, ISO_8859_1_entry[i], this, s2); if (!i) menu_offset = mountMenuW.getItemsCount(); @@ -243,7 +243,7 @@ int CNFSMountGui::menuEntry(int nr) CMenuWidget mountMenuEntryW(LOCALE_NFS_MOUNT, NEUTRINO_ICON_NETWORK, width); mountMenuEntryW.addIntroItems(); - CIPInput ipInput(LOCALE_NFS_IP, g_settings.network_nfs[nr].ip, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + CIPInput ipInput(LOCALE_NFS_IP, &g_settings.network_nfs[nr].ip, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); CStringInputSMS dirInput(LOCALE_NFS_DIR, &g_settings.network_nfs[nr].dir, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"abcdefghijklmnopqrstuvwxyz0123456789-_.,:|!?/ "); CMenuOptionChooser *automountInput= new CMenuOptionChooser(LOCALE_NFS_AUTOMOUNT, &g_settings.network_nfs[nr].automount, MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true); @@ -260,7 +260,7 @@ int CNFSMountGui::menuEntry(int nr) CStringInputSMS passInput(LOCALE_NFS_PASSWORD, &g_settings.network_nfs[nr].password, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_.,:|!?/ "); CMenuForwarder *password_fwd = new CMenuForwarder(LOCALE_NFS_PASSWORD, (type != (int)CFSMounter::NFS), NULL, &passInput); - CMACInput macInput(LOCALE_RECORDINGMENU_SERVER_MAC, g_settings.network_nfs[nr].mac, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + CMACInput macInput(LOCALE_RECORDINGMENU_SERVER_MAC, &g_settings.network_nfs[nr].mac, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs[nr].mac, &macInput); CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, !(CFSMounter::isMounted(g_settings.network_nfs[nr].local_dir)), NULL, this, cmd); @@ -324,7 +324,7 @@ int CNFSUmountGui::menu() s1 += it->mountPoint; std::string s2 = "doumount "; s2 += it->mountPoint; - CMenuForwarder *forwarder = new CMenuForwarderNonLocalized(s1.c_str(), true, NULL, this, s2.c_str()); + CMenuForwarder *forwarder = new CMenuForwarder(s1.c_str(), true, NULL, this, s2.c_str()); forwarder->iconName = NEUTRINO_ICON_MOUNTED; umountMenu.addItem(forwarder); } diff --git a/src/gui/nfs.h b/src/gui/nfs.h index 17f33e08b..1c3be441f 100644 --- a/src/gui/nfs.h +++ b/src/gui/nfs.h @@ -53,7 +53,7 @@ class CNFSMountGui : public CMenuTarget CMenuWidget *mountMenuWPtr; int menu_offset; - CMenuForwarderNonLocalized* mountMenuEntry[NETWORK_NFS_NR_OF_ENTRIES]; + CMenuForwarder* mountMenuEntry[NETWORK_NFS_NR_OF_ENTRIES]; CFSMounter::FS_Support m_nfs_sup; CFSMounter::FS_Support m_cifs_sup; diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index f058733f7..a3662daa2 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -232,42 +232,26 @@ int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey) else if (actionKey == "font_scaling") { int xre = g_settings.screen_xres; int yre = g_settings.screen_yres; - char val_x[4] = {0}; - char val_y[4] = {0}; - snprintf(val_x,sizeof(val_x), "%03d",g_settings.screen_xres); - snprintf(val_y,sizeof(val_y), "%03d",g_settings.screen_yres); CMenuWidget fontscale(LOCALE_FONTMENU_HEAD, NEUTRINO_ICON_COLORS, width, MN_WIDGET_ID_OSDSETUP_FONTSCALE); fontscale.addIntroItems(LOCALE_FONTMENU_SCALING); - CStringInput xres_count(LOCALE_FONTMENU_SCALING_X, val_x,50,200, 3, LOCALE_FONTMENU_SCALING, LOCALE_FONTMENU_SCALING_X_HINT2, "0123456789 "); - CMenuForwarder *m_x = new CMenuForwarder(LOCALE_FONTMENU_SCALING_X, true, val_x, &xres_count); + CMenuOptionNumberChooser* mc = new CMenuOptionNumberChooser(LOCALE_FONTMENU_SCALING_X, &g_settings.screen_xres, true, 50, 200, this); + mc->setNumericInput(true); + mc->setNumberFormat("%d%%"); + fontscale.addItem(mc); - CStringInput yres_count(LOCALE_FONTMENU_SCALING_Y, val_y,50,200, 3, LOCALE_FONTMENU_SCALING, LOCALE_FONTMENU_SCALING_Y_HINT2, "0123456789 "); - CMenuForwarder *m_y = new CMenuForwarder(LOCALE_FONTMENU_SCALING_Y, true, val_y, &yres_count); + mc = new CMenuOptionNumberChooser(LOCALE_FONTMENU_SCALING_Y, &g_settings.screen_yres, true, 50, 200, this); + mc->setNumericInput(true); + mc->setNumberFormat("%d%%"); + fontscale.addItem(mc); - fontscale.addItem(m_x); - fontscale.addItem(m_y); res = fontscale.exec(NULL, ""); - xre = atoi(val_x); - yre = atoi(val_y); - //fallback for min/max bugs ;) - if( xre < 50 || xre > 200 ){ - xre = g_settings.screen_xres; - snprintf(val_x,sizeof(val_x), "%03d",g_settings.screen_xres); - } - if( yre < 50 || yre > 200 ){ - yre = g_settings.screen_yres; - snprintf(val_y,sizeof(val_y), "%03d",g_settings.screen_yres); - } if (xre != g_settings.screen_xres || yre != g_settings.screen_yres) { - printf("[neutrino] new font scale settings x: %d%% y: %d%%\n", xre, yre); - g_settings.screen_xres = xre; - g_settings.screen_yres = yre; + printf("[neutrino] new font scale settings x: %d%% y: %d%%\n", g_settings.screen_xres, g_settings.screen_yres); CNeutrinoApp::getInstance()->SetupFonts(CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT | CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT_INST); } - //return menu_return::RETURN_REPAINT; return res; } else if(actionKey=="window_size") { @@ -739,36 +723,42 @@ private: CChangeObserver * observer; CConfigFile * configfile; int32_t defaultvalue; - char value[11]; + std::string value; protected: - virtual const char * getOption(void) - { - sprintf(value, "%u", configfile->getInt32(locale_real_names[text], defaultvalue)); - return value; - } + std::string getOption(fb_pixel_t * bgcol __attribute__((unused)) = NULL) { + return to_string(configfile->getInt32(locale_real_names[name], defaultvalue)); + } virtual bool changeNotify(const neutrino_locale_t OptionName, void * Data) - { - configfile->setInt32(locale_real_names[text], atoi(value)); - return observer->changeNotify(OptionName, Data); - } + { + configfile->setInt32(locale_real_names[name], atoi(value.c_str())); + return observer->changeNotify(OptionName, Data); + } public: CMenuNumberInput(const neutrino_locale_t Text, const int32_t DefaultValue, CChangeObserver * const Observer, CConfigFile * const Configfile) : CMenuForwarder(Text, true, NULL, this) - { - observer = Observer; - configfile = Configfile; - defaultvalue = DefaultValue; - } + { + observer = Observer; + configfile = Configfile; + defaultvalue = DefaultValue; + } int exec(CMenuTarget * parent, const std::string & action_Key) - { - CStringInput input(text, (char *)getOption(), 3, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2, "0123456789 ", this); - return input.exec(parent, action_Key); - } + { + value = getOption(); + while (value.length() < 3) + value = " " + value; + CStringInput input(name, &value, 3, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2, "0123456789 ", this); + return input.exec(parent, action_Key); + } + + std::string &getValue(void) { + value = getOption(); + return value; + } }; void COsdSetup::AddFontSettingItem(CMenuWidget &font_Settings, const SNeutrinoSettings::FONT_TYPES number_of_fontsize_entry) diff --git a/src/gui/parentallock_setup.cpp b/src/gui/parentallock_setup.cpp index 160d88701..3fcbef378 100644 --- a/src/gui/parentallock_setup.cpp +++ b/src/gui/parentallock_setup.cpp @@ -137,7 +137,7 @@ int CParentalSetup::showParentalSetup() mc = new CMenuOptionChooser(LOCALE_PARENTALLOCK_BOUQUETMODE, &g_settings.parentallock_defaultlocked, PARENTALLOCK_DEFAULTLOCKED_OPTIONS, PARENTALLOCK_DEFAULTLOCKED_OPTION_COUNT, !parentallocked); plock->addItem(mc); - CPINChangeWidget pinChangeWidget(LOCALE_PARENTALLOCK_CHANGEPIN, g_settings.parentallock_pincode, 4, LOCALE_PARENTALLOCK_CHANGEPIN_HINT1); + CPINChangeWidget pinChangeWidget(LOCALE_PARENTALLOCK_CHANGEPIN, &g_settings.parentallock_pincode, 4, LOCALE_PARENTALLOCK_CHANGEPIN_HINT1); mf = new CMenuForwarder(LOCALE_PARENTALLOCK_CHANGEPIN, true, g_settings.parentallock_pincode, &pinChangeWidget); mf->setHint("", LOCALE_MENU_HINT_PARENTALLOCK_CHANGEPIN); plock->addItem(mf); diff --git a/src/gui/personalize.cpp b/src/gui/personalize.cpp index d9637f11a..f8c9b2584 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -324,7 +324,7 @@ int CPersonalizeGui::ShowPersonalizationMenu() } //personalized menues - CMenuForwarderNonLocalized *p_mn[widget_count]; + CMenuForwarder *p_mn[widget_count]; for (int i = 0; i<(widget_count); i++) { ostringstream i_str; @@ -332,7 +332,7 @@ int CPersonalizeGui::ShowPersonalizationMenu() string s(i_str.str()); string action_key = s; string mn_name = v_widget[i]->getName(); - p_mn[i] = new CMenuForwarderNonLocalized(mn_name.c_str(), true, NULL, this, action_key.c_str(), CRCInput::convertDigitToKey(i+1)); + p_mn[i] = new CMenuForwarder(mn_name.c_str(), true, NULL, this, action_key.c_str(), CRCInput::convertDigitToKey(i+1)); pMenu->addItem(p_mn[i]); } @@ -372,7 +372,7 @@ int CPersonalizeGui::ShowPersonalizationMenu() //init pin setup dialog void CPersonalizeGui::ShowPinSetup(CMenuWidget* p_widget, CPINChangeWidget * &pin_widget) { - pin_widget = new CPINChangeWidget(LOCALE_PERSONALIZE_PINCODE, g_settings.personalize_pincode, 4, LOCALE_PERSONALIZE_PINHINT); + pin_widget = new CPINChangeWidget(LOCALE_PERSONALIZE_PINCODE, &g_settings.personalize_pincode, 4, LOCALE_PERSONALIZE_PINHINT); CMenuForwarder * fw_pin_setup = new CMenuForwarder(LOCALE_PERSONALIZE_PINCODE, true, g_settings.personalize_pincode, pin_widget, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); pin_setup_notifier = new CPinSetupNotifier(fw_pin_setup); @@ -467,7 +467,7 @@ void CPersonalizeGui::ShowPluginMenu(CMenuWidget* p_widget) { if( g_PluginList->getType(i)== CPlugins::P_TYPE_TOOL && !g_PluginList->isHidden(i)) //don't show hidden plugins an games { - p_widget->addItem(new CMenuForwarderNonLocalized(g_PluginList->getName(i), true, g_PluginList->getDescription(i), NULL, NULL, getShortcut(d_key))); + p_widget->addItem(new CMenuForwarder(g_PluginList->getName(i), true, g_PluginList->getDescription(i), NULL, NULL, getShortcut(d_key))); d_key++; } } @@ -491,7 +491,7 @@ int CPersonalizeGui::ShowMenuOptions(const int& widget) CMenuSeparator * pm_subhead = new CMenuSeparator(CMenuSeparator::ALIGN_LEFT | CMenuSeparator::SUB_HEAD | CMenuSeparator::STRING); string s_sh = g_Locale->getText(LOCALE_PERSONALIZE_ACCESS); s_sh += ": " + mn_name; - pm_subhead->setString(s_sh); + pm_subhead->setName(s_sh); pm->addItem(pm_subhead); pm->addIntroItems(); @@ -604,10 +604,10 @@ bool CPersonalizeGui::changeNotify(const neutrino_locale_t locale, void *data) if (opt_val == PERSONALIZE_MODE_VISIBLE || opt_val == PERSONALIZE_MODE_PIN) { chooser->setActive(false); - chooser->setOptionValue(PERSONALIZE_MODE_NOTVISIBLE); + chooser->setOption(PERSONALIZE_MODE_NOTVISIBLE); }else{ chooser->setActive(true); - chooser->setOptionValue(PERSONALIZE_MODE_VISIBLE); + chooser->setOption(PERSONALIZE_MODE_VISIBLE); } } } @@ -649,7 +649,7 @@ void CPersonalizeGui::SaveAndExit() ApplySettings(); return; } - if (ShowMsgUTF(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_PERSONALIZE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_PERSONALIZE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) { CHintBox hintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_MAINSETTINGS_SAVESETTINGSNOW_HINT)); // UTF-8 hintBox.paint(); @@ -658,7 +658,7 @@ void CPersonalizeGui::SaveAndExit() } else { - if (ShowMsgUTF(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_MESSAGEBOX_DISCARD), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_PERSONALIZE_HEAD, g_Locale->getText(LOCALE_MESSAGEBOX_DISCARD), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_QUESTION) == CMessageBox::mbrYes) exec(NULL, "restore"); } } diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index 559736ecb..f52114fe9 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -841,7 +841,7 @@ void CPictureViewerGui::endView() void CPictureViewerGui::deletePicFile(unsigned int index, bool mode) { CVFD::getInstance()->showMenuText(0, playlist[index].Name.c_str()); - if (ShowMsgUTF(LOCALE_FILEBROWSER_DELETE, playlist[index].Filename, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) + if (ShowMsg(LOCALE_FILEBROWSER_DELETE, playlist[index].Filename, CMessageBox::mbrNo, CMessageBox::mbYes|CMessageBox::mbNo)==CMessageBox::mbrYes) { unlink(playlist[index].Filename.c_str()); printf("[ %s ] delete file: %s\r\n",__FUNCTION__,playlist[index].Filename.c_str()); diff --git a/src/gui/pluginlist.cpp b/src/gui/pluginlist.cpp index 796b59ab0..1b3aaf4ae 100644 --- a/src/gui/pluginlist.cpp +++ b/src/gui/pluginlist.cpp @@ -359,8 +359,8 @@ CPluginList::result_ CPluginList::pluginSelected() if (!g_PluginList->getScriptOutput().empty()) { hide(); - //ShowMsgUTF(LOCALE_PLUGINS_RESULT, Latin1_to_UTF8(g_PluginList->getScriptOutput()), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); - ShowMsgUTF(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + //ShowMsg(LOCALE_PLUGINS_RESULT, Latin1_to_UTF8(g_PluginList->getScriptOutput()), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); } paint(); return resume; diff --git a/src/gui/plugins.cpp b/src/gui/plugins.cpp index 49592b4e5..90f7b9691 100644 --- a/src/gui/plugins.cpp +++ b/src/gui/plugins.cpp @@ -69,7 +69,9 @@ #endif #include +#if ENABLE_LUA #include +#endif extern CPlugins * g_PluginList; /* neutrino.cpp */ extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ @@ -128,8 +130,10 @@ void CPlugins::scanDir(const char *dir) new_plugin.pluginfile = fname; if (new_plugin.type == CPlugins::P_TYPE_SCRIPT) new_plugin.pluginfile.append(".sh"); +#if ENABLE_LUA else if (new_plugin.type == CPlugins::P_TYPE_LUA) new_plugin.pluginfile.append(".lua"); +#endif else new_plugin.pluginfile.append(".so"); // We do not check if new_plugin.pluginfile exists since .cfg in @@ -343,6 +347,7 @@ void CPlugins::startScriptPlugin(int number) } } +#if ENABLE_LUA void CPlugins::startLuaPlugin(int number) { const char *script = plugin_list[number].pluginfile.c_str(); @@ -357,6 +362,7 @@ void CPlugins::startLuaPlugin(int number) lua->runScript(script); delete lua; } +#endif void CPlugins::startPlugin(int number,int /*param*/) { @@ -383,11 +389,13 @@ void CPlugins::startPlugin(int number,int /*param*/) startScriptPlugin(number); return; } +#if ENABLE_LUA if (plugin_list[number].type == CPlugins::P_TYPE_LUA) { startLuaPlugin(number); return; } +#endif if (!file_exists(plugin_list[number].pluginfile.c_str())) { printf("[CPlugins] could not find %s,\nperhaps wrong plugin type in %s\n", @@ -657,8 +665,10 @@ CPlugins::p_type_t CPlugins::getPluginType(int type) case PLUGIN_TYPE_SCRIPT: return P_TYPE_SCRIPT; break; +#if ENABLE_LUA case PLUGIN_TYPE_LUA: return P_TYPE_LUA; +#endif default: return P_TYPE_DISABLED; } diff --git a/src/gui/plugins.h b/src/gui/plugins.h index 1bd6c614f..349219ec7 100644 --- a/src/gui/plugins.h +++ b/src/gui/plugins.h @@ -51,8 +51,12 @@ class CPlugins P_TYPE_DISABLED = 0x1, P_TYPE_GAME = 0x2, P_TYPE_TOOL = 0x4, - P_TYPE_SCRIPT = 0x8, + P_TYPE_SCRIPT = 0x8 + +#if ENABLE_LUA + , P_TYPE_LUA = 0x10 +#endif } p_type_t; @@ -123,8 +127,9 @@ class CPlugins void startPlugin(int number,int param); void start_plugin_by_name(const std::string & filename,int param);// start plugins by "name=" in .cfg void startScriptPlugin(int number); +#if ENABLE_LUA void startLuaPlugin(int number); - +#endif void startPlugin(const char * const filename); // start plugins also by name bool hasPlugin(CPlugins::p_type_t type); diff --git a/src/gui/proxyserver_setup.cpp b/src/gui/proxyserver_setup.cpp index b4600e7f0..db03bf765 100644 --- a/src/gui/proxyserver_setup.cpp +++ b/src/gui/proxyserver_setup.cpp @@ -80,17 +80,17 @@ int CProxySetup::showProxySetup() neutrino_locale_t subtitle = (menue_title == LOCALE_FLASHUPDATE_PROXYSERVER_SEP ? NONEXISTANT_LOCALE : LOCALE_FLASHUPDATE_PROXYSERVER_SEP); mn->addIntroItems(subtitle); - CStringInputSMS softUpdate_proxy(LOCALE_FLASHUPDATE_PROXYSERVER, g_settings.softupdate_proxyserver, 23, LOCALE_FLASHUPDATE_PROXYSERVER_HINT1, LOCALE_FLASHUPDATE_PROXYSERVER_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-.: "); + CStringInputSMS softUpdate_proxy(LOCALE_FLASHUPDATE_PROXYSERVER, &g_settings.softupdate_proxyserver, 23, LOCALE_FLASHUPDATE_PROXYSERVER_HINT1, LOCALE_FLASHUPDATE_PROXYSERVER_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-.: "); CMenuForwarder * mf = new CMenuForwarder(LOCALE_FLASHUPDATE_PROXYSERVER, true, g_settings.softupdate_proxyserver, &softUpdate_proxy, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); mf->setHint("", LOCALE_MENU_HINT_NET_PROXYSERVER); mn->addItem(mf); - CStringInputSMS softUpdate_proxyuser(LOCALE_FLASHUPDATE_PROXYUSERNAME, g_settings.softupdate_proxyusername, 23, LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT1, LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789!""§$%&/()=?-. "); + CStringInputSMS softUpdate_proxyuser(LOCALE_FLASHUPDATE_PROXYUSERNAME, &g_settings.softupdate_proxyusername, 23, LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT1, LOCALE_FLASHUPDATE_PROXYUSERNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789!""§$%&/()=?-. "); mf = new CMenuForwarder(LOCALE_FLASHUPDATE_PROXYUSERNAME, true, g_settings.softupdate_proxyusername, &softUpdate_proxyuser, NULL, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN); mf->setHint("", LOCALE_MENU_HINT_NET_PROXYUSER); mn->addItem(mf); - CStringInputSMS softUpdate_proxypass(LOCALE_FLASHUPDATE_PROXYPASSWORD, g_settings.softupdate_proxypassword, 20, LOCALE_FLASHUPDATE_PROXYPASSWORD_HINT1, LOCALE_FLASHUPDATE_PROXYPASSWORD_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789!""§$%&/()=?-. "); + CStringInputSMS softUpdate_proxypass(LOCALE_FLASHUPDATE_PROXYPASSWORD, &g_settings.softupdate_proxypassword, 20, LOCALE_FLASHUPDATE_PROXYPASSWORD_HINT1, LOCALE_FLASHUPDATE_PROXYPASSWORD_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789!""§$%&/()=?-. "); mf = new CMenuForwarder(LOCALE_FLASHUPDATE_PROXYPASSWORD, true, g_settings.softupdate_proxypassword, &softUpdate_proxypass, NULL, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW); mf->setHint("", LOCALE_MENU_HINT_NET_PROXYPASS); mn->addItem(mf); diff --git a/src/gui/rc_lock.cpp b/src/gui/rc_lock.cpp index 8999cbd17..1ca5a3728 100644 --- a/src/gui/rc_lock.cpp +++ b/src/gui/rc_lock.cpp @@ -54,7 +54,7 @@ int CRCLock::exec(CMenuTarget* parent, const std::string &actionKey) parent->hide(); bool no_input = (actionKey == NO_USER_INPUT); - if (ShowLocalizedMessage(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_LOCKMSG, + if (ShowMsg(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_LOCKMSG, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel, NEUTRINO_ICON_INFO,450,no_input ? 5 : -1,no_input) == CMessageBox::mbrCancel) return menu_return::RETURN_EXIT_ALL; @@ -64,7 +64,7 @@ int CRCLock::exec(CMenuTarget* parent, const std::string &actionKey) lockBox(); locked = false; - ShowLocalizedMessage(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_UNLOCKMSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO,450, no_input ? 5 : -1); + ShowMsg(LOCALE_RCLOCK_TITLE, LOCALE_RCLOCK_UNLOCKMSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO,450, no_input ? 5 : -1); return menu_return::RETURN_EXIT_ALL; } diff --git a/src/gui/record_setup.cpp b/src/gui/record_setup.cpp index 97812d6d7..207b6ea94 100644 --- a/src/gui/record_setup.cpp +++ b/src/gui/record_setup.cpp @@ -83,7 +83,7 @@ int CRecordSetup::exec(CMenuTarget* parent, const std::string &actionKey) } else if(actionKey == "help_recording") { - ShowLocalizedMessage(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); + ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); return res; } else if(actionKey == "recordingdir") diff --git a/src/gui/scan.cpp b/src/gui/scan.cpp index 855d98220..3a8cdb338 100644 --- a/src/gui/scan.cpp +++ b/src/gui/scan.cpp @@ -155,7 +155,7 @@ void CScanTs::testFunc() sprintf(buffer, "%u", TP.feparams.dvb_feparams.frequency); /* no way int can overflow the buffer */ } printf("CScanTs::testFunc: %s\n", buffer); - paintLine(xpos2, ypos_cur_satellite, w - 95, pname); + paintLine(xpos2, ypos_cur_satellite, w - 95, pname.c_str()); paintLine(xpos2, ypos_frequency, w, buffer); paintRadar(); success = g_Zapit->tune_TP(TP); @@ -234,13 +234,13 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) scan_flags |= CServiceScan::SCAN_NIT; TP.scan_mode = scan_flags; if (deltype == FE_QPSK) { - TP.feparams.dvb_feparams.frequency = atoi(scansettings.sat_TP_freq); - TP.feparams.dvb_feparams.u.qpsk.symbol_rate = atoi(scansettings.sat_TP_rate); + TP.feparams.dvb_feparams.frequency = atoi(scansettings.sat_TP_freq.c_str()); + TP.feparams.dvb_feparams.u.qpsk.symbol_rate = atoi(scansettings.sat_TP_rate.c_str()); TP.feparams.dvb_feparams.u.qpsk.fec_inner = (fe_code_rate_t) scansettings.sat_TP_fec; TP.polarization = scansettings.sat_TP_pol; } else if (deltype == FE_OFDM) { /* DVB-T. TODO: proper menu and parameter setup, not all "AUTO" */ - TP.feparams.dvb_feparams.frequency = atoi(scansettings.terr_TP_freq); + TP.feparams.dvb_feparams.frequency = atoi(scansettings.terr_TP_freq.c_str()); if (TP.feparams.dvb_feparams.frequency < 300000) TP.feparams.dvb_feparams.u.ofdm.bandwidth = BANDWIDTH_7_MHZ; else @@ -252,8 +252,8 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) TP.feparams.dvb_feparams.u.ofdm.guard_interval = GUARD_INTERVAL_AUTO; TP.feparams.dvb_feparams.u.ofdm.hierarchy_information = HIERARCHY_AUTO; } else { - TP.feparams.dvb_feparams.frequency = atoi(scansettings.cable_TP_freq); - TP.feparams.dvb_feparams.u.qam.symbol_rate = atoi(scansettings.cable_TP_rate); + TP.feparams.dvb_feparams.frequency = atoi(scansettings.cable_TP_freq.c_str()); + TP.feparams.dvb_feparams.u.qam.symbol_rate = atoi(scansettings.cable_TP_rate.c_str()); TP.feparams.dvb_feparams.u.qam.fec_inner = (fe_code_rate_t)scansettings.cable_TP_fec; TP.feparams.dvb_feparams.u.qam.modulation = (fe_modulation_t) scansettings.cable_TP_mod; } @@ -273,7 +273,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) } else if(manual || !scan_all) { sat.position = CServiceManager::getInstance()->GetSatellitePosition(pname); - strncpy(sat.satName, pname, 49); + strncpy(sat.satName, pname.c_str(), 49); satList.push_back(sat); } else { satellite_map_t & satmap = CServiceManager::getInstance()->SatelliteList(); @@ -338,7 +338,7 @@ int CScanTs::exec(CMenuTarget* /*parent*/, const std::string & actionKey) else if(msg == CRCInput::RC_home) { if(manual && !scansettings.scan_nit_manual) continue; - if (ShowLocalizedMessage(LOCALE_SCANTS_ABORT_HEADER, LOCALE_SCANTS_ABORT_BODY, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { + if (ShowMsg(LOCALE_SCANTS_ABORT_HEADER, LOCALE_SCANTS_ABORT_BODY, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo) == CMessageBox::mbrYes) { g_Zapit->stopScan(); } } @@ -586,7 +586,6 @@ void CScanTs::showSNR () if (signalbox == NULL){ CFrontend * frontend = CServiceScan::getInstance()->GetFrontend(); signalbox = new CSignalBox(xpos1, y + height - mheight - 5, width - 2*(xpos1-x), g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(), frontend, false); - signalbox->setScaleWidth(60); /*%*/ signalbox->setColorBody(COL_MENUCONTENT_PLUS_0); signalbox->setTextColor(COL_MENUCONTENT_TEXT); signalbox->doPaintBg(true); diff --git a/src/gui/scan.h b/src/gui/scan.h index 54263898f..99a47dbe9 100644 --- a/src/gui/scan.h +++ b/src/gui/scan.h @@ -80,7 +80,7 @@ class CScanTs : public CMenuTarget void prev_next_TP(bool); TP_params TP; int deltype; - char * pname; + std::string pname; public: CScanTs(int dtype = FE_QPSK); diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index fcaf29faa..d744e1123 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -216,7 +216,7 @@ CScanSetup::CScanSetup(bool wizard_mode) in_menu = false; allow_start = true; if (CFEManager::getInstance()->haveCable()) - nid = new CIntInput(LOCALE_SATSETUP_CABLE_NID, (int&) scansettings.cable_nid, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + nid = new CIntInput(LOCALE_SATSETUP_CABLE_NID, (int*) &scansettings.cable_nid, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); } CScanSetup* CScanSetup::getInstance() @@ -420,7 +420,7 @@ printf("C: %d S: %d T: %d\n", CFEManager::getInstance()->haveCable(),CFEManager: CMenuWidget * autoScan = new CMenuWidget(LOCALE_SERVICEMENU_SCANTS, NEUTRINO_ICON_SETTINGS, w/*width*/, MN_WIDGET_ID_SCAN_AUTO_SCAN); addScanMenuAutoScan(autoScan); - mf = new CMenuDForwarderNonLocalized(autoscan, true, NULL, autoScan, "", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); + mf = new CMenuDForwarder(autoscan, true, NULL, autoScan, "", CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED); mf->setHint("", LOCALE_MENU_HINT_SCAN_AUTO); settings->addItem(mf); @@ -466,7 +466,7 @@ printf("C: %d S: %d T: %d\n", CFEManager::getInstance()->haveCable(),CFEManager: CMenuWidget * autoScan = new CMenuWidget(LOCALE_SERVICEMENU_SCANTS, NEUTRINO_ICON_SETTINGS, w/*width*/, MN_WIDGET_ID_SCAN_AUTO_SCAN); addScanMenuAutoScan(autoScan); - mf = new CMenuDForwarderNonLocalized(autoscan, true, NULL, autoScan, "", have_sat ? CRCInput::convertDigitToKey(shortcut++) : CRCInput::RC_red, have_sat ? NULL : NEUTRINO_ICON_BUTTON_RED); + mf = new CMenuDForwarder(autoscan, true, NULL, autoScan, "", have_sat ? CRCInput::convertDigitToKey(shortcut++) : CRCInput::RC_red, have_sat ? NULL : NEUTRINO_ICON_BUTTON_RED); mf->setHint("", LOCALE_MENU_HINT_SCAN_AUTO); settings->addItem(mf); @@ -502,7 +502,7 @@ printf("C: %d S: %d T: %d\n", CFEManager::getInstance()->haveCable(),CFEManager: /* FIXME leak, satSelect added to both auto and manual scan, so one of them cannot be deleted */ CMenuWidget * autoScan = new CMenuWidget(LOCALE_SERVICEMENU_SCANTS, NEUTRINO_ICON_SETTINGS, w, MN_WIDGET_ID_SCAN_AUTO_SCAN); addScanMenuAutoScan(autoScan); - mf = new CMenuForwarderNonLocalized(autoscan, true, NULL, autoScan, "", have_other ? CRCInput::RC_nokey : CRCInput::RC_green, have_other ? NULL : NEUTRINO_ICON_BUTTON_GREEN); + mf = new CMenuDForwarder(autoscan, true, NULL, autoScan, "", have_other ? CRCInput::RC_nokey : CRCInput::RC_green, have_other ? NULL : NEUTRINO_ICON_BUTTON_GREEN); mf->setHint("", LOCALE_MENU_HINT_SCAN_AUTO); settings->addItem(mf); @@ -596,7 +596,7 @@ int CScanSetup::showScanMenuFrontendSetup() modestr[i] = g_Locale->getText(getModeLocale(fe->getMode())); - mf = new CMenuForwarderNonLocalized(name, allow_start, modestr[i], this, tmp, key, icon); + mf = new CMenuForwarder(name, allow_start, modestr[i], this, tmp, key, icon); mf->setHint("", LOCALE_MENU_HINT_SCAN_SETUP_FE); setupMenu->addItem(mf); if(i != 0) @@ -607,16 +607,21 @@ int CScanSetup::showScanMenuFrontendSetup() nc->setHint("", LOCALE_MENU_HINT_SCAN_FETIMEOUT); setupMenu->addItem(nc); + std::string zapit_lat_str; + std::string zapit_long_str; + if (CFEManager::getInstance()->haveSat()) { sprintf(zapit_lat, "%02.6f", zapitCfg.gotoXXLatitude); sprintf(zapit_long, "%02.6f", zapitCfg.gotoXXLongitude); + zapit_lat_str = std::string(zapit_lat); + zapit_long_str = std::string(zapit_long); setupMenu->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SATSETUP_EXTENDED_MOTOR)); CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_EXTRA_LADIRECTION, (int *)&zapitCfg.gotoXXLaDirection, OPTIONS_SOUTH0_NORTH1_OPTIONS, OPTIONS_SOUTH0_NORTH1_OPTION_COUNT, true, NULL, CRCInput::convertDigitToKey(shortcut++)); mc->setHint("", LOCALE_MENU_HINT_SCAN_LADIRECTION); setupMenu->addItem(mc); - CStringInput * toff1 = new CStringInput(LOCALE_EXTRA_LATITUDE, (char *) zapit_lat, 10, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789."); + CStringInput * toff1 = new CStringInput(LOCALE_EXTRA_LATITUDE, &zapit_lat_str, 10, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789."); mf = new CMenuDForwarder(LOCALE_EXTRA_LATITUDE, true, zapit_lat, toff1, "", CRCInput::convertDigitToKey(shortcut++)); mf->setHint("", LOCALE_MENU_HINT_SCAN_LATITUDE); setupMenu->addItem(mf); @@ -625,7 +630,7 @@ int CScanSetup::showScanMenuFrontendSetup() mc->setHint("", LOCALE_MENU_HINT_SCAN_LODIRECTION); setupMenu->addItem(mc); - CStringInput * toff2 = new CStringInput(LOCALE_EXTRA_LONGITUDE, (char *) zapit_long, 10, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789."); + CStringInput * toff2 = new CStringInput(LOCALE_EXTRA_LONGITUDE, &zapit_long_str, 10, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789."); mf = new CMenuDForwarder(LOCALE_EXTRA_LONGITUDE, true, zapit_long, toff2, "", CRCInput::convertDigitToKey(shortcut++)); mf->setHint("", LOCALE_MENU_HINT_SCAN_LONGITUDE); setupMenu->addItem(mf); @@ -636,6 +641,10 @@ int CScanSetup::showScanMenuFrontendSetup() } int res = setupMenu->exec(NULL, ""); + + strncpy(zapit_lat, zapit_lat_str.c_str(), sizeof(zapit_lat)); + strncpy(zapit_long, zapit_long_str.c_str(), sizeof(zapit_long)); + delete setupMenu; if (fe_restart) { fe_restart = false; @@ -837,7 +846,7 @@ int CScanSetup::showUnicableSetup() int unicable_qrg = fe_config.uni_qrg; CMenuOptionNumberChooser *uniscr = new CMenuOptionNumberChooser(LOCALE_UNICABLE_SCR, &unicable_scr, true, 0, 7); - CIntInput *uniqrg = new CIntInput(LOCALE_UNICABLE_QRG, unicable_qrg, 4, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput *uniqrg = new CIntInput(LOCALE_UNICABLE_QRG, &unicable_qrg, 4, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); CMenuWidget *uni_setup = new CMenuWidget(LOCALE_SATSETUP_UNI_SETTINGS, NEUTRINO_ICON_SETTINGS, width); uni_setup->addIntroItems(); @@ -887,7 +896,7 @@ int CScanSetup::showScanMenuLnbSetup() char opt[100]; sprintf(opt, "diseqc %2d / rotor %2d", sit->second.diseqc+1, sit->second.motor_position); satoptions.push_back(opt); - CMenuForwarder * mf = new CMenuForwarderNonLocalized(satname.c_str(), true, satoptions[count].c_str(), tempsat); + CMenuForwarder * mf = new CMenuForwarder(satname.c_str(), true, satoptions[count].c_str(), tempsat); mf->setHint("", LOCALE_MENU_HINT_SCAN_LNBCONFIG); sat_setup->addItem(mf); satmf.push_back(mf); @@ -931,7 +940,7 @@ void CScanSetup::fillSatSelect(CMenuOptionStringChooser * select) select->addOption(satname.c_str()); satpos.insert(sit->first); - if (!sfound && strcmp(scansettings.satName, satname.c_str()) == 0) + if (!sfound && (scansettings.satName == satname)) sfound = true; } } @@ -939,7 +948,7 @@ void CScanSetup::fillSatSelect(CMenuOptionStringChooser * select) if(!sfound && !satpos.empty()) { tmpit = satpos.begin(); std::string satname = CServiceManager::getInstance()->GetSatelliteName(*tmpit); - snprintf(scansettings.satName, sizeof(scansettings.satName), "%s", satname.c_str()); + scansettings.satName = satname; } satellite_map_t & satmap = CServiceManager::getInstance()->SatelliteList(); for (sat_iterator_t sit = satmap.begin(); sit != satmap.end(); sit++) { @@ -974,16 +983,16 @@ void CScanSetup::fillCableSelect(CMenuOptionStringChooser * select) if (fname.empty()) fname = sit->second.name; - if (!sfound && strcmp(scansettings.cableName, sit->second.name.c_str()) == 0) + if (!sfound && (scansettings.cableName == sit->second.name)) sfound = true; dprintf(DEBUG_DEBUG, "got scanprovider (%s): %s\n", what, sit->second.name.c_str()); } if (!sfound && !fname.empty()) { if (r_system == DVB_C) - snprintf(scansettings.cableName, sizeof(scansettings.cableName), "%s", fname.c_str()); + scansettings.cableName = fname; if (r_system == DVB_T) - snprintf(scansettings.terrName, sizeof(scansettings.terrName), "%s", fname.c_str()); + scansettings.terrName = fname; } } @@ -1003,7 +1012,7 @@ int CScanSetup::showScanMenuSatFind() sat_findMenu->setSelected(selected); sat_findMenu->addIntroItems(); - CMenuOptionStringChooser * feSatSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, scansettings.satName, true, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * feSatSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, &scansettings.satName, true, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); feSatSelect->setHint("", LOCALE_MENU_HINT_SCAN_SATSELECT); satellite_map_t & satmap = fe->getSatellites(); @@ -1014,14 +1023,14 @@ int CScanSetup::showScanMenuSatFind() continue; std::string satname = CServiceManager::getInstance()->GetSatelliteName(sit->first); feSatSelect->addOption(satname.c_str()); - if (!sfound && strcmp(scansettings.satName, satname.c_str()) == 0) + if (!sfound && (scansettings.satName == satname)) sfound = true; if (!sfound && firstname.empty()) firstname = satname; count++; } if(count && !sfound) - snprintf(scansettings.satName, sizeof(scansettings.satName), "%s", firstname.c_str()); + scansettings.satName = firstname; sat_findMenu->addItem(feSatSelect); @@ -1076,9 +1085,9 @@ void CScanSetup::addScanMenuTempSat(CMenuWidget *temp_sat, sat_config_t & satcon unilnb = new CMenuOptionNumberChooser(LOCALE_UNICABLE_LNB, &satconfig.diseqc, true, 0, 1); } - CIntInput* lofL = new CIntInput(LOCALE_SATSETUP_LOFL, (int&) satconfig.lnbOffsetLow, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput* lofH = new CIntInput(LOCALE_SATSETUP_LOFH, (int&) satconfig.lnbOffsetHigh, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); - CIntInput* lofS = new CIntInput(LOCALE_SATSETUP_LOFS, (int&) satconfig.lnbSwitch, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput* lofL = new CIntInput(LOCALE_SATSETUP_LOFL, (int*) &satconfig.lnbOffsetLow, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput* lofH = new CIntInput(LOCALE_SATSETUP_LOFH, (int*) &satconfig.lnbOffsetHigh, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); + CIntInput* lofS = new CIntInput(LOCALE_SATSETUP_LOFS, (int*) &satconfig.lnbSwitch, 5, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE); if (!unicable) { temp_sat->addItem(diseqc); @@ -1114,7 +1123,7 @@ void CScanSetup::addScanMenuManualScan(CMenuWidget *manual_Scan) //---------------------------------------------------------------------- if (r_system == DVB_C) { act_test = "ctest"; act_manual = "cmanual"; - CMenuOptionStringChooser * cableSelect = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * cableSelect = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, &scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); cableSelect->setHint("", LOCALE_MENU_HINT_SCAN_CABLE); fillCableSelect(cableSelect); manual_Scan->addItem(cableSelect); @@ -1124,14 +1133,14 @@ void CScanSetup::addScanMenuManualScan(CMenuWidget *manual_Scan) mf = new CMenuDForwarder(LOCALE_SCANTS_SELECT_TP, true, NULL, new CTPSelectHandler(), "cable", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN); } else if (r_system == DVB_T) { act_test = "ttest"; act_manual = "tmanual"; - CMenuOptionStringChooser * terrSelect = new CMenuOptionStringChooser(LOCALE_TERRESTRIALSETUP_PROVIDER, scansettings.terrName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * terrSelect = new CMenuOptionStringChooser(LOCALE_TERRESTRIALSETUP_PROVIDER, &scansettings.terrName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); //terrSelect->setHint("", LOCALE_MENU_HINT_SCAN_CABLE); fillCableSelect(terrSelect); manual_Scan->addItem(terrSelect); mf = new CMenuDForwarder(LOCALE_SCANTS_SELECT_TP, true, NULL, new CTPSelectHandler(), "terrestrial", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN); } else { act_test = "stest"; act_manual = "smanual"; - CMenuOptionStringChooser * satSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, scansettings.satName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * satSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, &scansettings.satName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); satSelect->setHint("", LOCALE_MENU_HINT_SCAN_SATELLITE); /* add configured satellites to satSelect */ fillSatSelect(satSelect); @@ -1226,7 +1235,7 @@ void CScanSetup::addScanMenuAutoScan(CMenuWidget *auto_Scan) const char *action; if (r_system == DVB_C) { //cable - CMenuOptionStringChooser * cableSelect = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * cableSelect = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, &scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); cableSelect->setHint("", LOCALE_MENU_HINT_SCAN_CABLE); fillCableSelect(cableSelect); auto_Scan->addItem(cableSelect); @@ -1235,13 +1244,13 @@ void CScanSetup::addScanMenuAutoScan(CMenuWidget *auto_Scan) auto_Scan->addItem(mf); action = "cauto"; } else if (r_system == DVB_T) { - CMenuOptionStringChooser * terrSelect = new CMenuOptionStringChooser(LOCALE_TERRESTRIALSETUP_PROVIDER, scansettings.terrName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * terrSelect = new CMenuOptionStringChooser(LOCALE_TERRESTRIALSETUP_PROVIDER, &scansettings.terrName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); //terrSelect->setHint("", LOCALE_MENU_HINT_SCAN_CABLE); fillCableSelect(terrSelect); auto_Scan->addItem(terrSelect); action = "tauto"; } else { - CMenuOptionStringChooser * satSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, scansettings.satName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * satSelect = new CMenuOptionStringChooser(LOCALE_SATSETUP_SATELLITE, &scansettings.satName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); satSelect->setHint("", LOCALE_MENU_HINT_SCAN_SATELLITE); /* add configured satellites to satSelect */ fillSatSelect(satSelect); @@ -1268,7 +1277,7 @@ void CScanSetup::addScanMenuCable(CMenuWidget *menu) menu->addIntroItems(); //---------------------------------------------------------------------- - CMenuOptionStringChooser * select = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); + CMenuOptionStringChooser * select = new CMenuOptionStringChooser(LOCALE_CABLESETUP_PROVIDER, &scansettings.cableName, true, this, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED, true); fillCableSelect(select); select->setHint("", LOCALE_MENU_HINT_SCAN_CABLE); menu->addItem(select); @@ -1283,11 +1292,11 @@ void CScanSetup::addScanMenuCable(CMenuWidget *menu) menu->addItem(GenericMenuSeparatorLine); - CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, (char *) scansettings.cable_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, &scansettings.cable_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); CMenuForwarder *Freq = new CMenuDForwarder(LOCALE_EXTRA_TP_FREQ, true, scansettings.cable_TP_freq, freq, "", CRCInput::convertDigitToKey(shortCut++)); Freq->setHint("", LOCALE_MENU_HINT_SCAN_FREQ); - CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, (char *) scansettings.cable_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, &scansettings.cable_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); CMenuForwarder *Rate = new CMenuDForwarder(LOCALE_EXTRA_TP_RATE, true, scansettings.cable_TP_rate, rate, "", CRCInput::convertDigitToKey(shortCut++)); Rate->setHint("", LOCALE_MENU_HINT_SCAN_RATE); @@ -1328,11 +1337,11 @@ int CScanSetup::addScanOptionsItems(CMenuWidget *options_menu, const int &shortc CMenuForwarder *Freq = NULL; CMenuForwarder *Rate = NULL; if (r_system == DVB_S) { - CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, (char *) scansettings.sat_TP_freq, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, &scansettings.sat_TP_freq, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); Freq = new CMenuDForwarder(LOCALE_EXTRA_TP_FREQ, true, scansettings.sat_TP_freq, freq, "", CRCInput::convertDigitToKey(shortCut++)); Freq->setHint("", LOCALE_MENU_HINT_SCAN_FREQ); - CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, (char *) scansettings.sat_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, &scansettings.sat_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); Rate = new CMenuDForwarder(LOCALE_EXTRA_TP_RATE, true, scansettings.sat_TP_rate, rate, "", CRCInput::convertDigitToKey(shortCut++)); Rate->setHint("", LOCALE_MENU_HINT_SCAN_RATE); fec = new CMenuOptionChooser(LOCALE_EXTRA_TP_FEC, (int *)&scansettings.sat_TP_fec, SATSETUP_SCANTP_FEC, SATSETUP_SCANTP_FEC_COUNT, true, NULL, CRCInput::convertDigitToKey(shortCut++), "", true); @@ -1340,17 +1349,17 @@ int CScanSetup::addScanOptionsItems(CMenuWidget *options_menu, const int &shortc mod_pol = new CMenuOptionChooser(LOCALE_EXTRA_TP_POL, (int *)&scansettings.sat_TP_pol, SATSETUP_SCANTP_POL, SATSETUP_SCANTP_POL_COUNT, true, NULL, CRCInput::convertDigitToKey(shortCut++)); mod_pol->setHint("", LOCALE_MENU_HINT_SCAN_POL); } else if (r_system == DVB_C) { - CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, (char *) scansettings.cable_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, &scansettings.cable_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); Freq = new CMenuDForwarder(LOCALE_EXTRA_TP_FREQ, true, scansettings.cable_TP_freq, freq, "", CRCInput::convertDigitToKey(shortCut++)); Freq->setHint("", LOCALE_MENU_HINT_SCAN_FREQ); - CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, (char *) scansettings.cable_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *rate = new CStringInput(LOCALE_EXTRA_TP_RATE, &scansettings.cable_TP_rate, 8, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); Rate = new CMenuDForwarder(LOCALE_EXTRA_TP_RATE, true, scansettings.cable_TP_rate, rate, "", CRCInput::convertDigitToKey(shortCut++)); Rate->setHint("", LOCALE_MENU_HINT_SCAN_RATE); mod_pol = new CMenuOptionChooser(LOCALE_EXTRA_TP_MOD, (int *)&scansettings.cable_TP_mod, SATSETUP_SCANTP_MOD, SATSETUP_SCANTP_MOD_COUNT, true, NULL, CRCInput::convertDigitToKey(shortCut++)); mod_pol->setHint("", LOCALE_MENU_HINT_SCAN_MOD); } else if (r_system == DVB_T) { - CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, (char *)scansettings.terr_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); + CStringInput *freq = new CStringInput(LOCALE_EXTRA_TP_FREQ, &scansettings.terr_TP_freq, 6, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789"); Freq = new CMenuDForwarder(LOCALE_EXTRA_TP_FREQ, true, scansettings.terr_TP_freq, freq, "", CRCInput::convertDigitToKey(shortCut++)); Freq->setHint("", LOCALE_MENU_HINT_SCAN_FREQ); } @@ -1485,11 +1494,11 @@ bool CScanSetup::changeNotify(const neutrino_locale_t OptionName, void * /*data* fe->setMaster(femaster); } else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_CABLESETUP_PROVIDER)) { - printf("[neutrino] CScanSetup::%s: new provider: [%s]\n", __FUNCTION__, scansettings.cableName); + printf("[neutrino] CScanSetup::%s: new provider: [%s]\n", __FUNCTION__, scansettings.cableName.c_str()); satellite_map_t & satmap = CServiceManager::getInstance()->SatelliteList(); for (sat_iterator_t sit = satmap.begin(); sit != satmap.end(); sit++) { - if (strcmp(scansettings.cableName, sit->second.name.c_str()) == 0) { + if (scansettings.cableName == sit->second.name) { if(sit->second.cable_nid > 0) { scansettings.cable_nid = sit->second.cable_nid; nid->updateValue(); @@ -1535,20 +1544,18 @@ void CScanSetup::updateManualSettings() CFrontend * frontend = CFEManager::getInstance()->getLiveFE(); switch (frontend->getType()) { case FE_QPSK: - sprintf(scansettings.sat_TP_freq, "%d", tI->second.feparams.dvb_feparams.frequency); - sprintf(scansettings.sat_TP_rate, "%d", tI->second.feparams.dvb_feparams.u.qpsk.symbol_rate); + scansettings.sat_TP_freq = to_string(tI->second.feparams.dvb_feparams.frequency); + scansettings.sat_TP_rate = to_string(tI->second.feparams.dvb_feparams.u.qpsk.symbol_rate); scansettings.sat_TP_fec = tI->second.feparams.dvb_feparams.u.qpsk.fec_inner; scansettings.sat_TP_pol = tI->second.polarization; - strncpy(scansettings.satName, - CServiceManager::getInstance()->GetSatelliteName(channel->getSatellitePosition()).c_str(), 50); + scansettings.satName = CServiceManager::getInstance()->GetSatelliteName(channel->getSatellitePosition()); break; case FE_QAM: - sprintf(scansettings.cable_TP_freq, "%d", tI->second.feparams.dvb_feparams.frequency); - sprintf(scansettings.cable_TP_rate, "%d", tI->second.feparams.dvb_feparams.u.qam.symbol_rate); + scansettings.cable_TP_freq = to_string(tI->second.feparams.dvb_feparams.frequency); + scansettings.cable_TP_rate = to_string(tI->second.feparams.dvb_feparams.u.qam.symbol_rate); scansettings.cable_TP_fec = tI->second.feparams.dvb_feparams.u.qam.fec_inner; scansettings.cable_TP_mod = tI->second.feparams.dvb_feparams.u.qam.modulation; - strncpy(scansettings.cableName, - CServiceManager::getInstance()->GetSatelliteName(channel->getSatellitePosition()).c_str(), 50); + scansettings.cableName = CServiceManager::getInstance()->GetSatelliteName(channel->getSatellitePosition()); break; case FE_OFDM: case FE_ATSC: @@ -1573,7 +1580,7 @@ int CTPSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) parent->hide(); t_satellite_position position; - char * name; + std::string name; if (actionkey == "sat") name = scansettings.satName; else if (actionkey == "terrestrial") @@ -1581,8 +1588,8 @@ int CTPSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) else name = scansettings.cableName; - position = CServiceManager::getInstance()->GetSatellitePosition(name); - INFO("%s: %s\n", actionkey.c_str(), name); + position = CServiceManager::getInstance()->GetSatellitePosition(name.c_str()); + INFO("%s: %s\n", actionkey.c_str(), name.c_str()); if (old_position != position) { old_selected = 0; @@ -1608,7 +1615,7 @@ int CTPSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) old_selected = i; std::string tname = t.description(); - CMenuForwarderNonLocalized * ts_item = new CMenuForwarderNonLocalized(tname.c_str(), true, NULL, selector, cnt, CRCInput::RC_nokey, NULL)/*, false*/; + CMenuForwarder * ts_item = new CMenuForwarder(tname.c_str(), true, NULL, selector, cnt, CRCInput::RC_nokey, NULL)/*, false*/; ts_item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); menu.addItem(ts_item, old_selected == i); @@ -1619,7 +1626,7 @@ int CTPSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) if (i == 0) { std::string text = "No transponders found for "; text += name; - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, text.c_str(), 450, 2); + ShowHint(LOCALE_MESSAGEBOX_ERROR, text.c_str(), 450, 2); return menu_return::RETURN_REPAINT; } @@ -1638,19 +1645,19 @@ int CTPSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) switch (tmpI->second.deltype) { case FE_QPSK: - sprintf(scansettings.sat_TP_freq, "%d", tmpI->second.feparams.dvb_feparams.frequency); - sprintf(scansettings.sat_TP_rate, "%d", tmpI->second.feparams.dvb_feparams.u.qpsk.symbol_rate); + scansettings.sat_TP_freq = to_string(tmpI->second.feparams.dvb_feparams.frequency); + scansettings.sat_TP_rate = to_string(tmpI->second.feparams.dvb_feparams.u.qpsk.symbol_rate); scansettings.sat_TP_fec = tmpI->second.feparams.dvb_feparams.u.qpsk.fec_inner; scansettings.sat_TP_pol = tmpI->second.polarization; break; case FE_QAM: - sprintf(scansettings.cable_TP_freq, "%d", tmpI->second.feparams.dvb_feparams.frequency); - sprintf(scansettings.cable_TP_rate, "%d", tmpI->second.feparams.dvb_feparams.u.qam.symbol_rate); + scansettings.cable_TP_freq = to_string(tmpI->second.feparams.dvb_feparams.frequency); + scansettings.cable_TP_rate = to_string(tmpI->second.feparams.dvb_feparams.u.qam.symbol_rate); scansettings.cable_TP_fec = tmpI->second.feparams.dvb_feparams.u.qam.fec_inner; scansettings.cable_TP_mod = tmpI->second.feparams.dvb_feparams.u.qam.modulation; break; case FE_OFDM: - sprintf(scansettings.terr_TP_freq, "%d", tmpI->second.feparams.dvb_feparams.frequency); + scansettings.terr_TP_freq = to_string(tmpI->second.feparams.dvb_feparams.frequency); break; case FE_ATSC: break; diff --git a/src/gui/screensetup.cpp b/src/gui/screensetup.cpp index 4109a3d9b..589c8dab6 100644 --- a/src/gui/screensetup.cpp +++ b/src/gui/screensetup.cpp @@ -136,7 +136,7 @@ int CScreenSetup::exec(CMenuTarget* parent, const std::string &) ( g_settings.screen_EndX != x_coord[1] ) || ( g_settings.screen_StartY != y_coord[0] ) || ( g_settings.screen_EndY != y_coord[1] ) ) && - (ShowLocalizedMessage(LOCALE_VIDEOMENU_SCREENSETUP, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) + (ShowMsg(LOCALE_VIDEOMENU_SCREENSETUP, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) break; case CRCInput::RC_timeout: diff --git a/src/gui/settings_manager.cpp b/src/gui/settings_manager.cpp index 2e07244ff..14e7f4c37 100644 --- a/src/gui/settings_manager.cpp +++ b/src/gui/settings_manager.cpp @@ -88,12 +88,13 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) fileBrowser.Dir_Mode = true; if (fileBrowser.exec("/var/tuxbox") == true) { - char fname[256] = "neutrino.conf", sname[256]; - CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVECONFIG, fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. "); + std::string fname = "neutrino.conf"; + CStringInputSMS * sms = new CStringInputSMS(LOCALE_EXTRA_SAVECONFIG, &fname, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789. "); sms->exec(NULL, ""); - sprintf(sname, "%s/%s", fileBrowser.getSelectedFile()->Name.c_str(), fname); - printf("[neutrino] save settings: %s\n", sname); - CNeutrinoApp::getInstance()->saveSetup(sname); + + std::string sname = fileBrowser.getSelectedFile()->Name + "/" + fname; + printf("[neutrino] save settings: %s\n", sname.c_str()); + CNeutrinoApp::getInstance()->saveSetup(sname.c_str()); delete sms; } return res; @@ -112,7 +113,7 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) my_system(2, backup_sh, fileBrowser.getSelectedFile()->Name.c_str()); } else - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_SETTINGS_BACKUP_FAILED),CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_ERROR); } return res; } @@ -122,7 +123,7 @@ int CSettingsManager::exec(CMenuTarget* parent, const std::string &actionKey) fileBrowser.Filter = &fileFilter; if (fileBrowser.exec("/media") == true) { - int result = ShowMsgUTF(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); + int result = ShowMsg(LOCALE_SETTINGS_RESTORE, g_Locale->getText(LOCALE_SETTINGS_RESTORE_WARN), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); if(result == CMessageBox::mbrYes) { const char restore_sh[] = "/bin/restore.sh"; diff --git a/src/gui/sleeptimer.cpp b/src/gui/sleeptimer.cpp index 371132537..28000e59e 100644 --- a/src/gui/sleeptimer.cpp +++ b/src/gui/sleeptimer.cpp @@ -43,7 +43,7 @@ extern CRemoteControl * g_RemoteControl; /* neutrino.cpp */ bool CSleepTimerWidget::is_running = false; -int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) +int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &/*actionKey*/) { int res = menu_return::RETURN_REPAINT; @@ -54,24 +54,21 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) } is_running = true; - shutdown_min = 0; - char value[16]; + int shutdown_min = 0; + std::string value; CStringInput *inbox; - bool permanent = (actionKey == "permanent"); if (parent) parent->hide(); if(permanent) { - sprintf(value,"%03d", g_settings.shutdown_min); + value = to_string(g_settings.shutdown_min); + if (value.length() < 3) + value.insert(0, 3 - value.length(), '0'); + inbox = new CStringInput(LOCALE_SLEEPTIMERBOX_TITLE2, &value, 3, LOCALE_SLEEPTIMERBOX_HINT1, LOCALE_SLEEPTIMERBOX_HINT3, "0123456789 "); } else { shutdown_min = g_Timerd->getSleepTimerRemaining(); // remaining shutdown time? - sprintf(value,"%03d", shutdown_min); - } - - if(permanent) { - inbox = new CStringInput(LOCALE_SLEEPTIMERBOX_TITLE2, value, 3, LOCALE_SLEEPTIMERBOX_HINT1, LOCALE_SLEEPTIMERBOX_HINT3, "0123456789 "); - } else { + value = to_string(shutdown_min); if (g_settings.sleeptimer_min == 0) { CSectionsdClient::CurrentNextInfo info_CurrentNext; g_InfoViewer->getEPG(g_RemoteControl->current_channel_id, info_CurrentNext); @@ -80,14 +77,16 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) int current_epg_zeit_dauer_rest = (info_CurrentNext.current_zeit.dauer+150 - (jetzt - info_CurrentNext.current_zeit.startzeit ))/60 ; if(shutdown_min == 0 && current_epg_zeit_dauer_rest > 0 && current_epg_zeit_dauer_rest < 1000) { - sprintf(value,"%03d", current_epg_zeit_dauer_rest); + value = to_string(current_epg_zeit_dauer_rest); } } + } else { + value = to_string(g_settings.sleeptimer_min); } - else - sprintf(value,"%03d", g_settings.sleeptimer_min); + if (value.length() < 3) + value.insert(0, 3 - value.length(), '0'); - inbox = new CStringInput(LOCALE_SLEEPTIMERBOX_TITLE, value, 3, LOCALE_SLEEPTIMERBOX_HINT1, LOCALE_SLEEPTIMERBOX_HINT2, "0123456789 "); + inbox = new CStringInput(LOCALE_SLEEPTIMERBOX_TITLE, &value, 3, LOCALE_SLEEPTIMERBOX_HINT1, LOCALE_SLEEPTIMERBOX_HINT2, "0123456789 "); } int ret = inbox->exec (NULL, ""); @@ -100,7 +99,7 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) return res; } - int new_val = atoi(value); + int new_val = atoi(value.c_str()); if(permanent) { g_settings.shutdown_min = new_val; printf("permanent sleeptimer min: %d\n", g_settings.shutdown_min); @@ -126,15 +125,13 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) return res; } -const char * CSleepTimerWidget::getTargetValue() +std::string &CSleepTimerWidget::getValue(void) { - shutdown_min = g_Timerd->getSleepTimerRemaining(); - if (shutdown_min > 0) - { - shutdown_min_string = to_string(shutdown_min); - shutdown_min_string += " "; - shutdown_min_string += g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE); - return shutdown_min_string.c_str(); + if (permanent) { + valueStringTmp = (g_settings.shutdown_min > 0) ? to_string(g_settings.shutdown_min) + " " + g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE) : ""; + } else { + int remaining = g_Timerd->getSleepTimerRemaining(); + valueStringTmp = (remaining > 0) ? to_string(remaining) + " " + g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE) : ""; } - return NULL; + return valueStringTmp; } diff --git a/src/gui/sleeptimer.h b/src/gui/sleeptimer.h index f52f9bebc..0d612966e 100644 --- a/src/gui/sleeptimer.h +++ b/src/gui/sleeptimer.h @@ -29,12 +29,12 @@ class CSleepTimerWidget: public CMenuTarget { private: static bool is_running; - int shutdown_min; - std::string shutdown_min_string; + bool permanent; public: + CSleepTimerWidget(bool _permanent = false) { permanent = _permanent; } int exec(CMenuTarget* parent, const std::string & actionKey); - const char * getTargetValue(); + std::string &getValue(void); }; diff --git a/src/gui/start_wizard.cpp b/src/gui/start_wizard.cpp index 02ca63210..59862604c 100644 --- a/src/gui/start_wizard.cpp +++ b/src/gui/start_wizard.cpp @@ -92,7 +92,7 @@ int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) osdl_setup.exec(NULL, ""); #if 0 - if(ShowMsgUTF (LOCALE_WIZARD_WELCOME_HEAD, g_Locale->getText(LOCALE_WIZARD_WELCOME_TEXT), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbrCancel) == CMessageBox::mbrYes) + if(ShowMsg (LOCALE_WIZARD_WELCOME_HEAD, g_Locale->getText(LOCALE_WIZARD_WELCOME_TEXT), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbrCancel) == CMessageBox::mbrYes) #endif { int advanced = 1; @@ -132,7 +132,7 @@ int CStartUpWizard::exec(CMenuTarget* parent, const string & /*actionKey*/) if(advanced && init_settings && (res != menu_return::RETURN_EXIT_ALL)) { - if (ShowMsgUTF(LOCALE_WIZARD_INITIAL_SETTINGS, g_Locale->getText(LOCALE_WIZARD_INSTALL_SETTINGS), + if (ShowMsg(LOCALE_WIZARD_INITIAL_SETTINGS, g_Locale->getText(LOCALE_WIZARD_INSTALL_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrYes) { system("/bin/cp " CONFIGDIR "/initial/* " CONFIGDIR "/zapit/"); CFEManager::getInstance()->loadSettings(); diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index 9a8ef4dc0..2f1be463a 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -887,7 +887,6 @@ void CStreamInfo2::showSNR () { if (signalbox == NULL){ signalbox = new CSignalBox(x + 10, yypos, 240, 50, frontend); - signalbox->setScaleWidth(60); /*%*/ signalbox->setColorBody(COL_MENUHEAD_PLUS_0); signalbox->setTextColor(COL_INFOBAR_TEXT); signalbox->doPaintBg(true); diff --git a/src/gui/subchannel_select.cpp b/src/gui/subchannel_select.cpp index 86b0a6a1c..36867ce1c 100644 --- a/src/gui/subchannel_select.cpp +++ b/src/gui/subchannel_select.cpp @@ -100,11 +100,11 @@ int CSubChannelSelectMenu::getNVODMenu(CMenuWidget* menu) nvod_time_x[0]= 0; sprintf(nvod_s, "%s - %s %s", nvod_time_a, nvod_time_e, nvod_time_x); - menu->addItem(new CMenuForwarderNonLocalized(nvod_s, enabled, NULL, &NVODChanger, nvod_id), (count == g_RemoteControl->selected_subchannel)); + menu->addItem(new CMenuForwarder(nvod_s, enabled, NULL, &NVODChanger, nvod_id), (count == g_RemoteControl->selected_subchannel)); } else { - menu->addItem(new CMenuForwarderNonLocalized(e->subservice_name.c_str(), enabled, NULL, &NVODChanger, nvod_id, CRCInput::convertDigitToKey(count)), (count == g_RemoteControl->selected_subchannel)); + menu->addItem(new CMenuForwarder(e->subservice_name.c_str(), enabled, NULL, &NVODChanger, nvod_id, CRCInput::convertDigitToKey(count)), (count == g_RemoteControl->selected_subchannel)); } count++; diff --git a/src/gui/test_menu.cpp b/src/gui/test_menu.cpp index fe80bf0ce..75bc5bf1b 100644 --- a/src/gui/test_menu.cpp +++ b/src/gui/test_menu.cpp @@ -136,7 +136,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) text[12*len] = 0; CVFD::getInstance()->ShowText(text); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "VFD test, Press OK to return", CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "VFD test, Press OK to return", CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); CVFD::getInstance()->Clear(); return res; @@ -176,7 +176,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) close(fd); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return res; } @@ -188,17 +188,17 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) switch(ret) { case 0: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); break; case -1: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; case -2: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; default: case -3: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; } @@ -211,17 +211,17 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) switch(ret) { case 0: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); break; case -1: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; case -2: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; default: case -3: - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); break; } @@ -245,7 +245,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) sprintf(buffer, "HDD: /dev/sda1 is %s", mounted ? "mounted" : "NOT mounted"); printf("%s\n", buffer); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return res; } @@ -266,7 +266,7 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) sprintf(buffer, "MMC: /dev/mmcblk0p1 is %s", mounted ? "mounted" : "NOT mounted"); printf("%s\n", buffer); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return res; } @@ -307,9 +307,8 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) { int fnum = atoi(actionKey.substr(5, 1).c_str()); printf("22kon: fe %d sat pos %d\n", fnum, test_pos[fnum]); - sprintf(scansettings.sat_TP_freq, "%d", 12000*1000); - strncpy(scansettings.satName, - CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]).c_str(), 50); + scansettings.sat_TP_freq = "12000000"; + scansettings.satName = CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]); CScanTs scanTs(FE_QPSK); scanTs.exec(NULL, "test"); return res; @@ -318,9 +317,8 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) { int fnum = atoi(actionKey.substr(6, 1).c_str()); printf("22koff: fe %d sat pos %d\n", fnum, test_pos[fnum]); - sprintf(scansettings.sat_TP_freq, "%d", 11000*1000); - strncpy(scansettings.satName, - CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]).c_str(), 50); + scansettings.sat_TP_freq = "11000000"; + scansettings.satName = CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]); CScanTs scanTs(FE_QPSK); scanTs.exec(NULL, "test"); return res; @@ -333,12 +331,11 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) CFrontend *frontend = CFEManager::getInstance()->getFE(fnum); switch (frontend->getInfo()->type) { case FE_QPSK: - strncpy(scansettings.satName, - CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]).c_str(), 50); - sprintf(scansettings.sat_TP_freq, "%d", (fnum & 1) ? 12439000: 12538000); - sprintf(scansettings.sat_TP_rate, "%d", (fnum & 1) ? 2500*1000 : 41250*1000); - scansettings.sat_TP_fec = (fnum & 1) ? FEC_3_4 : FEC_1_2; - scansettings.sat_TP_pol = (fnum & 1) ? 0 : 1; + scansettings.satName = CServiceManager::getInstance()->GetSatelliteName(test_pos[fnum]); + scansettings.sat_TP_freq = (fnum & 1) ? "12439000": "12538000"; + scansettings.sat_TP_rate = (fnum & 1) ? "2500000" : "41250000"; + scansettings.sat_TP_fec = (fnum & 1) ? FEC_3_4 : FEC_1_2; + scansettings.sat_TP_pol = (fnum & 1) ? 0 : 1; break; case FE_QAM: { @@ -349,11 +346,11 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) fe->setMode(CFrontend::FE_MODE_UNUSED); } frontend->setMode(CFrontend::FE_MODE_INDEPENDENT); - strncpy(scansettings.cableName, "CST Berlin", 50); - sprintf(scansettings.cable_TP_freq, "%d", 474*1000); - sprintf(scansettings.cable_TP_rate, "%d", 6875*1000); - scansettings.cable_TP_fec = 1; - scansettings.cable_TP_mod = 5; + scansettings.cableName = "CST Berlin"; + scansettings.cable_TP_freq = "474000"; + scansettings.cable_TP_rate = "6875000"; + scansettings.cable_TP_fec = 1; + scansettings.cable_TP_mod = 5; } break; case FE_OFDM: @@ -670,15 +667,15 @@ int CTestMenu::showTestMenu() //hardware CMenuWidget * w_hw = new CMenuWidget("Hardware Test", NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU_HARDWARE); - w_test.addItem(new CMenuForwarderNonLocalized(w_hw->getName().c_str(), true, NULL, w_hw)); + w_test.addItem(new CMenuForwarder(w_hw->getName().c_str(), true, NULL, w_hw)); showHWTests(w_hw); //buttons - w_test.addItem(new CMenuForwarderNonLocalized("Buttons", true, NULL, this, "buttons")); + w_test.addItem(new CMenuForwarder("Buttons", true, NULL, this, "buttons")); //components CMenuWidget * w_cc = new CMenuWidget("OSD-Components Demo", NEUTRINO_ICON_INFO, width, MN_WIDGET_ID_TESTMENU_COMPONENTS); - w_test.addItem(new CMenuForwarderNonLocalized(w_cc->getName().c_str(), true, NULL, w_cc)); + w_test.addItem(new CMenuForwarder(w_cc->getName().c_str(), true, NULL, w_cc)); showCCTests(w_cc); //buildinfo @@ -693,33 +690,33 @@ int CTestMenu::showTestMenu() void CTestMenu::showCCTests(CMenuWidget *widget) { widget->addIntroItems(); - widget->addItem(new CMenuForwarderNonLocalized("Running Clock", true, NULL, this, "running_clock")); - widget->addItem(new CMenuForwarderNonLocalized("Clock", true, NULL, this, "clock")); - widget->addItem(new CMenuForwarderNonLocalized("Button", true, NULL, this, "button")); - widget->addItem(new CMenuForwarderNonLocalized("Circle", true, NULL, this, "circle")); - widget->addItem(new CMenuForwarderNonLocalized("Square", true, NULL, this, "square")); - widget->addItem(new CMenuForwarderNonLocalized("Picture", true, NULL, this, "picture")); - widget->addItem(new CMenuForwarderNonLocalized("Channel-Logo", true, NULL, this, "channellogo")); - widget->addItem(new CMenuForwarderNonLocalized("Form", true, NULL, this, "form")); - widget->addItem(new CMenuForwarderNonLocalized("Text", true, NULL, this, "text")); - widget->addItem(new CMenuForwarderNonLocalized("Header", true, NULL, this, "header")); - widget->addItem(new CMenuForwarderNonLocalized("Footer", true, NULL, this, "footer")); - widget->addItem(new CMenuForwarderNonLocalized("Icon-Form", true, NULL, this, "iconform")); - widget->addItem(new CMenuForwarderNonLocalized("Window", true, NULL, this, "window")); - widget->addItem(new CMenuForwarderNonLocalized("Text-Extended", true, NULL, this, "text_ext")); + widget->addItem(new CMenuForwarder("Running Clock", true, NULL, this, "running_clock")); + widget->addItem(new CMenuForwarder("Clock", true, NULL, this, "clock")); + widget->addItem(new CMenuForwarder("Button", true, NULL, this, "button")); + widget->addItem(new CMenuForwarder("Circle", true, NULL, this, "circle")); + widget->addItem(new CMenuForwarder("Square", true, NULL, this, "square")); + widget->addItem(new CMenuForwarder("Picture", true, NULL, this, "picture")); + widget->addItem(new CMenuForwarder("Channel-Logo", true, NULL, this, "channellogo")); + widget->addItem(new CMenuForwarder("Form", true, NULL, this, "form")); + widget->addItem(new CMenuForwarder("Text", true, NULL, this, "text")); + widget->addItem(new CMenuForwarder("Header", true, NULL, this, "header")); + widget->addItem(new CMenuForwarder("Footer", true, NULL, this, "footer")); + widget->addItem(new CMenuForwarder("Icon-Form", true, NULL, this, "iconform")); + widget->addItem(new CMenuForwarder("Window", true, NULL, this, "window")); + widget->addItem(new CMenuForwarder("Text-Extended", true, NULL, this, "text_ext")); } void CTestMenu::showHWTests(CMenuWidget *widget) { widget->addIntroItems(); - widget->addItem(new CMenuForwarderNonLocalized("VFD", true, NULL, this, "vfd")); - widget->addItem(new CMenuForwarderNonLocalized("Network", true, NULL, this, "network")); + widget->addItem(new CMenuForwarder("VFD", true, NULL, this, "vfd")); + widget->addItem(new CMenuForwarder("Network", true, NULL, this, "network")); #if HAVE_COOL_HARDWARE - widget->addItem(new CMenuForwarderNonLocalized("Smartcard 1", true, NULL, this, "card0")); - widget->addItem(new CMenuForwarderNonLocalized("Smartcard 2", true, NULL, this, "card1")); + widget->addItem(new CMenuForwarder("Smartcard 1", true, NULL, this, "card0")); + widget->addItem(new CMenuForwarder("Smartcard 2", true, NULL, this, "card1")); #endif - widget->addItem(new CMenuForwarderNonLocalized("HDD", true, NULL, this, "hdd")); - widget->addItem(new CMenuForwarderNonLocalized("SD/MMC", true, NULL, this, "mmc")); + widget->addItem(new CMenuForwarder("HDD", true, NULL, this, "hdd")); + widget->addItem(new CMenuForwarder("SD/MMC", true, NULL, this, "mmc")); for (unsigned i = 0; i < sizeof(test_pos)/sizeof(int); i++) { CServiceManager::getInstance()->InitSatPosition(test_pos[i], NULL, true); @@ -739,7 +736,7 @@ void CTestMenu::showHWTests(CMenuWidget *widget) } else continue; - widget->addItem(new CMenuForwarderNonLocalized(title, true, NULL, this, scan)); + widget->addItem(new CMenuForwarder(title, true, NULL, this, scan)); if (frontend->getInfo()->type == FE_QPSK) { frontend->setMode(CFrontend::FE_MODE_INDEPENDENT); @@ -747,20 +744,20 @@ void CTestMenu::showHWTests(CMenuWidget *widget) satmap[test_pos[i]].configured = 1; frontend->setSatellites(satmap); if (i == 0) { - widget->addItem(new CMenuForwarderNonLocalized("Tuner 1: 22 Khz ON", true, NULL, this, "22kon0")); - widget->addItem(new CMenuForwarderNonLocalized("Tuner 1: 22 Khz OFF", true, NULL, this, "22koff0")); + widget->addItem(new CMenuForwarder("Tuner 1: 22 Khz ON", true, NULL, this, "22kon0")); + widget->addItem(new CMenuForwarder("Tuner 1: 22 Khz OFF", true, NULL, this, "22koff0")); } if (i == 1) { - widget->addItem(new CMenuForwarderNonLocalized("Tuner 2: 22 Khz ON", true, NULL, this, "22kon1")); - widget->addItem(new CMenuForwarderNonLocalized("Tuner 2: 22 Khz OFF", true, NULL, this, "22koff1")); + widget->addItem(new CMenuForwarder("Tuner 2: 22 Khz ON", true, NULL, this, "22kon1")); + widget->addItem(new CMenuForwarder("Tuner 2: 22 Khz OFF", true, NULL, this, "22koff1")); } if (i == 2) { - widget->addItem(new CMenuForwarderNonLocalized("Tuner 3: 22 Khz ON", true, NULL, this, "22kon2")); - widget->addItem(new CMenuForwarderNonLocalized("Tuner 3: 22 Khz OFF", true, NULL, this, "22koff2")); + widget->addItem(new CMenuForwarder("Tuner 3: 22 Khz ON", true, NULL, this, "22kon2")); + widget->addItem(new CMenuForwarder("Tuner 3: 22 Khz OFF", true, NULL, this, "22koff2")); } if (i == 3) { - widget->addItem(new CMenuForwarderNonLocalized("Tuner 4: 22 Khz ON", true, NULL, this, "22kon3")); - widget->addItem(new CMenuForwarderNonLocalized("Tuner 4: 22 Khz OFF", true, NULL, this, "22koff3")); + widget->addItem(new CMenuForwarder("Tuner 4: 22 Khz ON", true, NULL, this, "22kon3")); + widget->addItem(new CMenuForwarder("Tuner 4: 22 Khz OFF", true, NULL, this, "22koff3")); } } } diff --git a/src/gui/themes.cpp b/src/gui/themes.cpp index 5786a237d..4f864b1ba 100644 --- a/src/gui/themes.cpp +++ b/src/gui/themes.cpp @@ -129,9 +129,9 @@ void CThemes::readThemes(CMenuWidget &themes) *pos = '\0'; if ( p == 1 ) { userThemeFile = "{U}" + (std::string)file; - oj = new CMenuForwarderNonLocalized((char*)file, true, "", this, userThemeFile.c_str()); + oj = new CMenuForwarder((char*)file, true, "", this, userThemeFile.c_str()); } else - oj = new CMenuForwarderNonLocalized((char*)file, true, "", this, file); + oj = new CMenuForwarder((char*)file, true, "", this, file); themes.addItem( oj ); } free(themelist[count]); @@ -180,7 +180,7 @@ int CThemes::Show() } if (hasThemeChanged) { - if (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_COLORTHEMEMENU_QUESTION, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_SETTINGS) != CMessageBox::mbrYes) rememberOldTheme( false ); else hasThemeChanged = false; diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 6f2fdee07..1df87297c 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -90,12 +90,12 @@ private: CMenuItem* m4; CMenuItem* m5; CMenuItem* m6; - char* display; + std::string * display; int* iType; time_t* stopTime; public: CTimerListNewNotifier( int* Type, time_t* time,CMenuItem* a1, CMenuItem* a2, - CMenuItem* a3, CMenuItem* a4, CMenuItem* a5, CMenuItem* a6,char* d) + CMenuItem* a3, CMenuItem* a4, CMenuItem* a5, CMenuItem* a6, std::string *d) { m1 = a1; m2 = a2; @@ -114,16 +114,18 @@ public: { *stopTime=(time(NULL)/60)*60; struct tm *tmTime2 = localtime(stopTime); - sprintf( display, "%02d.%02d.%04d %02d:%02d", tmTime2->tm_mday, tmTime2->tm_mon+1, + char disp[40]; + snprintf(disp, sizeof(disp), "%02d.%02d.%04d %02d:%02d", tmTime2->tm_mday, tmTime2->tm_mon+1, tmTime2->tm_year+1900, tmTime2->tm_hour, tmTime2->tm_min); + *display = std::string(disp); m1->setActive(true); m6->setActive((g_settings.recording_type == RECORDING_FILE)); } else { *stopTime=0; - strcpy(display," "); + *display = " "; m1->setActive (false); m6->setActive(false); } @@ -160,9 +162,9 @@ private: CMenuForwarder* m2; int* iRepeat; - char * weekdays; + std::string * weekdays; public: - CTimerListRepeatNotifier( int* repeat, CMenuForwarder* a1, CMenuForwarder *a2, char * wstr) + CTimerListRepeatNotifier( int* repeat, CMenuForwarder* a1, CMenuForwarder *a2, std::string * wstr) { m1 = a1; m2 = a2; @@ -174,11 +176,11 @@ public: { if (*iRepeat >= (int)CTimerd::TIMERREPEAT_WEEKDAYS) { m1->setActive (true); - strcpy(weekdays, "XXXXX--"); + *weekdays = "XXXXX--"; } else { m1->setActive (false); - strcpy(weekdays, "-------"); + *weekdays = "-------"; } if (*iRepeat != (int)CTimerd::TIMERREPEAT_ONCE) m2->setActive(true); @@ -598,7 +600,7 @@ int CTimerList::show() if (epgdata.title != "") title = "(" + epgdata.title + ")\n"; snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_TIMERLIST_ASK_TO_DELETE), title.c_str()); - if(ShowMsgUTF(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, + if(ShowMsg(LOCALE_RECORDINGMENU_RECORD_IS_RUNNING, buf1, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, false) == CMessageBox::mbrNo) { killTimer = false; update = false; @@ -650,7 +652,7 @@ int CTimerList::show() if (timer->epgID != 0) res = g_EpgData->show(timer->channel_id, timer->epgID, &timer->epg_starttime); else - ShowLocalizedHint(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NOTFOUND); + ShowHint(LOCALE_MESSAGEBOX_INFO, LOCALE_EPGVIEWER_NOTFOUND); if (res==menu_return::RETURN_EXIT_ALL) loop=false; else @@ -1082,13 +1084,13 @@ int CTimerList::modifyTimer() Timer->setWeekdaysToStr(timer->eventRepeat, m_weekdaysStr); timer->eventRepeat = (CTimerd::CTimerEventRepeat)(((int)timer->eventRepeat) & 0x1FF); - CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); + CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, &m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); CMenuForwarder *m4 = new CMenuForwarder(LOCALE_TIMERLIST_WEEKDAYS, ((int)timer->eventRepeat) >= (int)CTimerd::TIMERREPEAT_WEEKDAYS, m_weekdaysStr, &timerSettings_weekdays ); - CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int&)timer->repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); + CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int*)&timer->repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); CMenuForwarder *m5 = new CMenuForwarder(LOCALE_TIMERLIST_REPEATCOUNT, timer->eventRepeat != (int)CTimerd::TIMERREPEAT_ONCE ,timerSettings_repeatCount.getValue() , &timerSettings_repeatCount); - CTimerListRepeatNotifier notifier((int *)&timer->eventRepeat,m4,m5, m_weekdaysStr); + CTimerListRepeatNotifier notifier((int *)&timer->eventRepeat,m4,m5, &m_weekdaysStr); CMenuOptionChooser* m3 = new CMenuOptionChooser(LOCALE_TIMERLIST_REPEAT, (int *)&timer->eventRepeat, TIMERLIST_REPEAT_OPTIONS, TIMERLIST_REPEAT_OPTION_COUNT, true, ¬ifier); //printf("TIMER: rec dir %s len %s\n", timer->recordingDir, strlen(timer->recordingDir)); @@ -1163,14 +1165,14 @@ int CTimerList::newTimer() CDateInput timerSettings_stopTime(LOCALE_TIMERLIST_STOPTIME, &(timerNew.stopTime) , LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); CMenuForwarder *m2 = new CMenuForwarder(LOCALE_TIMERLIST_STOPTIME, true, timerSettings_stopTime.getValue (), &timerSettings_stopTime ); - CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); + CStringInput timerSettings_weekdays(LOCALE_TIMERLIST_WEEKDAYS, &m_weekdaysStr, 7, LOCALE_TIMERLIST_WEEKDAYS_HINT_1, LOCALE_TIMERLIST_WEEKDAYS_HINT_2, "-X"); CMenuForwarder *m4 = new CMenuForwarder(LOCALE_TIMERLIST_WEEKDAYS, false, m_weekdaysStr, &timerSettings_weekdays); - CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int&)timerNew.repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); + CIntInput timerSettings_repeatCount(LOCALE_TIMERLIST_REPEATCOUNT, (int*)&timerNew.repeatCount,3, LOCALE_TIMERLIST_REPEATCOUNT_HELP1, LOCALE_TIMERLIST_REPEATCOUNT_HELP2); CMenuForwarder *m5 = new CMenuForwarder(LOCALE_TIMERLIST_REPEATCOUNT, false,timerSettings_repeatCount.getValue() , &timerSettings_repeatCount); - CTimerListRepeatNotifier notifier((int *)&timerNew.eventRepeat,m4,m5, m_weekdaysStr); - strcpy(m_weekdaysStr,"XXXXX--"); + CTimerListRepeatNotifier notifier((int *)&timerNew.eventRepeat,m4,m5, &m_weekdaysStr); + m_weekdaysStr = "XXXXX--"; CMenuOptionChooser* m3 = new CMenuOptionChooser(LOCALE_TIMERLIST_REPEAT, (int *)&timerNew.eventRepeat, TIMERLIST_REPEAT_OPTIONS, TIMERLIST_REPEAT_OPTION_COUNT, true, ¬ifier); @@ -1189,20 +1191,20 @@ int CTimerList::newTimer() for (int j = 0; j < (int) channels.size(); j++) { char cChannelId[3+16+1+1]; sprintf(cChannelId, "SC:" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS ",", channels[j]->channel_id); - mwtv->addItem(new CMenuForwarderNonLocalized(channels[j]->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channels[j]->getName()).c_str(), CRCInput::RC_nokey, NULL, channels[j]->scrambled ? NEUTRINO_ICON_SCRAMBLED : NULL)); + mwtv->addItem(new CMenuForwarder(channels[j]->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channels[j]->getName()).c_str(), CRCInput::RC_nokey, NULL, channels[j]->scrambled ? NEUTRINO_ICON_SCRAMBLED : NULL)); } if (!channels.empty()) - mctv.addItem(new CMenuForwarderNonLocalized(g_bouquetManager->Bouquets[i]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : g_bouquetManager->Bouquets[i]->Name.c_str() /*g_bouquetManager->Bouquets[i]->Name.c_str()*/, true, NULL, mwtv)); + mctv.addItem(new CMenuForwarder(g_bouquetManager->Bouquets[i]->bFav ? g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME) : g_bouquetManager->Bouquets[i]->Name.c_str() /*g_bouquetManager->Bouquets[i]->Name.c_str()*/, true, NULL, mwtv)); g_bouquetManager->Bouquets[i]->getRadioChannels(channels); for (int j = 0; j < (int) channels.size(); j++) { char cChannelId[3+16+1+1]; sprintf(cChannelId, "SC:" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS ",", channels[j]->channel_id); - mwradio->addItem(new CMenuForwarderNonLocalized(channels[j]->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channels[j]->getName()).c_str(), CRCInput::RC_nokey, NULL, channels[j]->scrambled ? NEUTRINO_ICON_SCRAMBLED : NULL)); + mwradio->addItem(new CMenuForwarder(channels[j]->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channels[j]->getName()).c_str(), CRCInput::RC_nokey, NULL, channels[j]->scrambled ? NEUTRINO_ICON_SCRAMBLED : NULL)); } if (!channels.empty()) - mcradio.addItem(new CMenuForwarderNonLocalized(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwradio)); + mcradio.addItem(new CMenuForwarder(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwradio)); } } @@ -1216,7 +1218,8 @@ int CTimerList::newTimer() CMenuOptionChooser* m8 = new CMenuOptionChooser(LOCALE_TIMERLIST_STANDBY, &timerNew_standby_on, TIMERLIST_STANDBY_OPTIONS, TIMERLIST_STANDBY_OPTION_COUNT, false); - CStringInputSMS timerSettings_msg(LOCALE_TIMERLIST_MESSAGE, timerNew.message, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.,:!?/ "); + std::string timerNew_message(timerNew.message); + CStringInputSMS timerSettings_msg(LOCALE_TIMERLIST_MESSAGE, &timerNew_message, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-.,:!?/ "); CMenuForwarder *m9 = new CMenuForwarder(LOCALE_TIMERLIST_MESSAGE, false, timerNew.message, &timerSettings_msg ); strcpy(timerNew.pluginName,"---"); @@ -1226,7 +1229,7 @@ int CTimerList::newTimer() CTimerListNewNotifier notifier2((int *)&timerNew.eventType, &timerNew.stopTime,m2,m6,m8,m9,m10,m7, - timerSettings_stopTime.getValue()); + &timerSettings_stopTime.getValue()); CMenuOptionChooser* m0; 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, ¬ifier2); @@ -1250,6 +1253,8 @@ int CTimerList::newTimer() notifier2.changeNotify(NONEXISTANT_LOCALE, NULL); int ret=timerSettings.exec(this,""); + strncpy(timerNew.message, timerNew_message.c_str(), sizeof(timerNew.message)); + // delete dynamic created objects for (unsigned int count=0; countgetText(TIMERLIST_OVERLAPPING_MESSAGE); - return (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO,timerbuf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); + return (ShowMsg(LOCALE_MESSAGEBOX_INFO,timerbuf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes); } else return true; diff --git a/src/gui/timerlist.h b/src/gui/timerlist.h index 4e752c4e6..067d942bb 100644 --- a/src/gui/timerlist.h +++ b/src/gui/timerlist.h @@ -64,7 +64,7 @@ class CTimerList : public CMenuTarget CTimerd::responseGetTimer timerNew; int timerNew_standby_on; char timerNew_channel_name[30]; - char m_weekdaysStr[8]; + std::string m_weekdaysStr; int timer_apids_dflt; int timer_apids_std; diff --git a/src/gui/update.cpp b/src/gui/update.cpp index c3df4c2b8..e030b0f2b 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -162,10 +162,10 @@ bool CFlashUpdate::selectHttpImage(void) SelectionWidget.addItem(GenericMenuBack); SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::LINE)); - SelectionWidget.addItem(new CMenuForwarderNonLocalized(current, false)); - std::ifstream urlFile(g_settings.softupdate_url_file); + SelectionWidget.addItem(new CMenuForwarder(current, false)); + std::ifstream urlFile(g_settings.softupdate_url_file.c_str()); #ifdef DEBUG - printf("[update] file %s\n", g_settings.softupdate_url_file); + printf("[update] file %s\n", g_settings.softupdate_url_file.c_str()); #endif unsigned int i = 0; @@ -194,7 +194,7 @@ bool CFlashUpdate::selectHttpImage(void) } //updates_lists.push_back(url.substr(startpos, endpos - startpos)); - SelectionWidget.addItem(new CNonLocalizedMenuSeparator(updates_lists.rbegin()->c_str(), LOCALE_FLASHUPDATE_SELECTIMAGE)); + SelectionWidget.addItem(new CMenuSeparator(CMenuSeparator::STRING | CMenuSeparator::LINE, updates_lists.rbegin()->c_str())); if (httpTool.downloadFile(url, gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME, 20)) { std::ifstream in(gTmpPath LIST_OF_UPDATES_LOCAL_FILENAME); @@ -230,10 +230,10 @@ bool CFlashUpdate::selectHttpImage(void) descriptions.push_back(description); /* workaround since CMenuForwarder does not store the Option String itself */ - //SelectionWidget.addItem(new CMenuForwarderNonLocalized(names[i].c_str(), enabled, descriptions[i].c_str(), new CUpdateMenuTarget(i, &selected))); + //SelectionWidget.addItem(new CMenuForwarder(names[i].c_str(), enabled, descriptions[i].c_str(), new CUpdateMenuTarget(i, &selected))); CUpdateMenuTarget * up = new CUpdateMenuTarget(i, &selected); update_t_list.push_back(up); - SelectionWidget.addItem(new CMenuForwarderNonLocalized(descriptions[i].c_str(), enabled, names[i].c_str(), up)); + SelectionWidget.addItem(new CMenuForwarder(descriptions[i].c_str(), enabled, names[i].c_str(), up)); i++; } } @@ -243,13 +243,13 @@ bool CFlashUpdate::selectHttpImage(void) if (urls.empty()) { - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR), CMessageBox::mbrOk, CMessageBox::mbOk); // UTF-8 + ShowMsg(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETINFOFILEERROR), CMessageBox::mbrOk, CMessageBox::mbOk); // UTF-8 return false; } if(newfound) - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_FOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_FOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); else - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_NOTFOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_NEW_NOTFOUND), CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); menu_ret = SelectionWidget.exec(NULL, ""); @@ -329,16 +329,16 @@ printf("[update] mode is %d\n", softupdate_mode); if(fileType < '3') { if ((strncmp(RELEASE_CYCLE, versionInfo->getReleaseCycle(), 2) != 0) && - (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) + (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) { delete versionInfo; - //ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE)); // UTF-8 + //ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_WRONGBASE)); // UTF-8 return false; } if ((strcmp("Release", versionInfo->getType()) != 0) && - //(ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) // UTF-8 - (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) + //(ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) // UTF-8 + (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_FLASHUPDATE_EXPERIMENTALIMAGE, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes)) { delete versionInfo; return false; @@ -378,7 +378,7 @@ printf("[update] mode is %d\n", softupdate_mode); else { hide(); printf("flash-file not found: %s\n", filename.c_str()); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENFILE)); // UTF-8 return false; } hide(); @@ -397,7 +397,7 @@ printf("[update] mode is %d\n", softupdate_mode); strcpy(msg, g_Locale->getText(LOCALE_FLASHUPDATE_NOVERSION)); msg_body = LOCALE_FLASHUPDATE_MSGBOX_MANUAL; } - return (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, msg, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes); // UTF-8 + return (ShowMsg(LOCALE_MESSAGEBOX_INFO, msg, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes); // UTF-8 } int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) @@ -415,7 +415,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) paint(); if(sysfs.size() < 8) { - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD)); + ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD)); hide(); return menu_return::RETURN_REPAINT; } @@ -440,7 +440,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) if(!getUpdateImage(newVersion)) { hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILEERROR)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILEERROR)); // UTF-8 return menu_return::RETURN_REPAINT; } sprintf(fullname, "%s/%s", g_settings.update_dir.c_str(), fname); @@ -457,11 +457,11 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_MD5CHECK)); // UTF-8 if((softupdate_mode==1) && !ft.check_md5(filename, file_md5)) { hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_MD5SUMERROR)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_MD5SUMERROR)); // UTF-8 return menu_return::RETURN_REPAINT; } if(softupdate_mode==1) { //internet-update - if ( ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, (fileType < '3') ? "Flash downloaded image ?" : "Install downloaded pack ?", CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 + if ( ShowMsg(LOCALE_MESSAGEBOX_INFO, (fileType < '3') ? "Flash downloaded image ?" : "Install downloaded pack ?", CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 { hide(); return menu_return::RETURN_REPAINT; @@ -478,7 +478,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) #if ENABLE_EXTUPDATE #ifndef BOXMODEL_APOLLO if (g_settings.apply_settings) { - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_APPLY_SETTINGS), CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) == CMessageBox::mbrYes) if (!CExtUpdate::getInstance()->applySettings(filename, CExtUpdate::MODE_SOFTUPDATE)) { hide(); return menu_return::RETURN_REPAINT; @@ -493,7 +493,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) if(!ft.program(filename, 80, 100)) { #endif hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, ft.getErrorMessage().c_str()); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_ERROR, ft.getErrorMessage().c_str()); // UTF-8 return menu_return::RETURN_REPAINT; } @@ -501,7 +501,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) showGlobalStatus(100); showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8 hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_FLASHREADYREBOOT)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_FLASHREADYREBOOT)); // UTF-8 sleep(2); ft.reboot(); } @@ -516,7 +516,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) fread(buffer, (uint32_t)filesize, 1, fd); fclose(fd); buffer[filesize] = 0; - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 + ShowMsg(LOCALE_MESSAGEBOX_INFO, buffer, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 free(buffer); } } @@ -530,7 +530,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) my_system(3, install_sh, g_settings.update_dir.c_str(), filename.c_str()); #endif showGlobalStatus(100); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8 } hide(); return menu_return::RETURN_REPAINT; @@ -569,7 +569,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) std::string path = getPathName(backupFile); if (!file_exists(path.c_str())) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_DIRECTORY_NOT_EXIST), path.c_str()); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); + ShowHint(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } @@ -580,7 +580,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) if (mtd == -1) { // check disk space for image creation if (!get_fs_usage("/", btotal, bused, &bsize)) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), "root0"); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); + ShowHint(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } backupRequiredSize = ((bused * bsize) / 1024ULL) * 2ULL; // twice disk space for summarized image @@ -592,7 +592,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) btotal = 0; bused = 0; bsize = 0; if (!get_fs_usage(path.c_str(), btotal, bused, &bsize)) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_VOLUME_ERROR), path.c_str()); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); + ShowHint(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } uint64_t backupMaxSize = (btotal - bused) * (uint64_t)bsize; @@ -603,7 +603,7 @@ bool CFlashExpert::checkSize(int mtd, std::string &backupFile) if (backupMaxSize < backupRequiredSize) { snprintf(errMsg, sizeof(errMsg)-1, g_Locale->getText(LOCALE_FLASHUPDATE_READ_NO_AVAILABLE_SPACE), path.c_str(), backupMaxSize, backupRequiredSize); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, errMsg); + ShowHint(LOCALE_MESSAGEBOX_ERROR, errMsg); return false; } @@ -676,7 +676,7 @@ void CFlashExpert::readmtdJFFS2(std::string &filename) char message[500]; sprintf(message, g_Locale->getText(LOCALE_FLASHUPDATE_SAVESUCCESS), filename.c_str()); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, message); + ShowHint(LOCALE_MESSAGEBOX_INFO, message); } #endif @@ -751,9 +751,9 @@ void CFlashExpert::readmtd(int preadmtd) hide(); #ifdef BOXMODEL_APOLLO if (!forceOtherFilename) - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, message); + ShowHint(LOCALE_MESSAGEBOX_INFO, message); #else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, message); + ShowHint(LOCALE_MESSAGEBOX_INFO, message); #endif } } @@ -767,7 +767,7 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber) FILESYSTEM_ENCODING_TO_UTF8_STRING(filename).c_str(), CMTDInfo::getInstance()->getMTDName(mtdNumber).c_str()); - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) // UTF-8 return; #ifdef VFD_UPDATE CVFD::getInstance()->showProgressBar2(0,"checking",0,"Update Neutrino"); @@ -788,7 +788,7 @@ void CFlashExpert::writemtd(const std::string & filename, int mtdNumber) showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_READY)); // UTF-8 sleep(2); hide(); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_FLASHREADYREBOOT)); // UTF-8 + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_FLASHREADYREBOOT)); // UTF-8 ft.reboot(); } } @@ -819,7 +819,7 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey) enabled = false; // build jffs2 image from root0 if ((actionkey == "readmtd") && (lx == mtdInfo->findMTDNumberFromName("root0"))) { - CMenuForwarder *mf = new CMenuDForwarderNonLocalized("root0", true, NULL, new CFlashExpertSetup(), NULL, CRCInput::convertDigitToKey(shortcut++)); + CMenuForwarder *mf = new CMenuDForwarder("root0", true, NULL, new CFlashExpertSetup(), NULL, CRCInput::convertDigitToKey(shortcut++)); mtdselector->addItem(mf); continue; } @@ -829,12 +829,12 @@ int CFlashExpert::showMTDSelector(const std::string & actionkey) enabled = false; #endif sprintf(sActionKey, "%s%d", actionkey.c_str(), lx); - mtdselector->addItem(new CMenuForwarderNonLocalized(mtdInfo->getMTDName(lx).c_str(), enabled, NULL, this, sActionKey, CRCInput::convertDigitToKey(shortcut++))); + mtdselector->addItem(new CMenuForwarder(mtdInfo->getMTDName(lx).c_str(), enabled, NULL, this, sActionKey, CRCInput::convertDigitToKey(shortcut++))); } #if ENABLE_EXTUPDATE #ifndef BOXMODEL_APOLLO if (actionkey == "writemtd") - mtdselector->addItem(new CMenuForwarderNonLocalized("systemFS with settings", true, NULL, this, "writemtd10", CRCInput::convertDigitToKey(shortcut++))); + mtdselector->addItem(new CMenuForwarder("systemFS with settings", true, NULL, this, "writemtd10", CRCInput::convertDigitToKey(shortcut++))); #endif #endif int res = mtdselector->exec(NULL,""); @@ -862,7 +862,7 @@ int CFlashExpert::showFileSelector(const std::string & actionkey) int pos = filen.find(".img"); if(pos!=-1) { - fileselector->addItem(new CMenuForwarderNonLocalized(filen.c_str(), true, NULL, this, (actionkey + filen).c_str())); + fileselector->addItem(new CMenuForwarder(filen.c_str(), true, NULL, this, (actionkey + filen).c_str())); //TODO make sure filen is UTF-8 encoded } free(namelist[count]); @@ -959,7 +959,7 @@ int CFlashExpertSetup::exec(CMenuTarget* parent, const std::string &actionKey) // create image warning const char *box = (mtdInfo->getMTDEraseSize(mtdInfo->findMTDsystem()) == 0x40000) ? "Trinity" : "Tank"; snprintf(message, sizeof(message)-1, g_Locale->getText(LOCALE_FLASHUPDATE_CREATEIMAGE_WARNING), box, box); - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, message, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_UPDATE) != CMessageBox::mbrYes) skipImage = true; } if (!skipImage) { diff --git a/src/gui/update_ext.cpp b/src/gui/update_ext.cpp index f8cc39f7c..06b107b5f 100644 --- a/src/gui/update_ext.cpp +++ b/src/gui/update_ext.cpp @@ -549,7 +549,7 @@ bool CExtUpdate::checkSpecialFolders(std::string line, bool copy) neutrino_locale_t msg = (copy) ? LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED : LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_DEL_SKIPPED; snprintf(buf, sizeof(buf), g_Locale->getText(msg), line.c_str()); WRITE_UPDATE_LOG("%s%s", buf, "\n"); - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, buf, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_INFO); return true; } return false; @@ -719,13 +719,13 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) memset(buf1, '\0', sizeof(buf1)); if (free3 <= flashError) { snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR), free3, total); - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, buf1, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, buf1, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR); flashErrorFlag = true; return false; } else if (free3 <= flashWarning) { snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_WARNING), free3, total); - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf1, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) { + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, buf1, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) { flashErrorFlag = true; return false; } diff --git a/src/gui/update_settings.cpp b/src/gui/update_settings.cpp index 37d6d5d7f..d4528276c 100644 --- a/src/gui/update_settings.cpp +++ b/src/gui/update_settings.cpp @@ -109,7 +109,7 @@ int CUpdateSettings::exec(CMenuTarget* parent, const std::string &actionKey) fileFilter.addFilter("urls"); fileBrowser.Filter = &fileFilter; if (fileBrowser.exec("/var/etc") == true) - strncpy(g_settings.softupdate_url_file, fileBrowser.getSelectedFile()->Name.c_str(), 30); + g_settings.softupdate_url_file = fileBrowser.getSelectedFile()->Name; return res; } diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index 3fc03b6e9..773b6a3a8 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -203,13 +203,13 @@ bool CUpnpBrowserGui::discoverDevices() catch (std::runtime_error error) { delete scanBox; - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return false; } delete scanBox; if (m_devices.empty()) { - ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_UPNPBROWSER_NOSERVERS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_UPNPBROWSER_NOSERVERS, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return false; } return true; @@ -237,7 +237,7 @@ bool CUpnpBrowserGui::getResults(std::string id, unsigned int start, unsigned in } catch (std::runtime_error error) { - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, error.what(), CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); return false; } return true; diff --git a/src/gui/user_menue.cpp b/src/gui/user_menue.cpp index bca66a452..744294743 100644 --- a/src/gui/user_menue.cpp +++ b/src/gui/user_menue.cpp @@ -311,8 +311,11 @@ bool CUserMenu::showUserMenu(int button) int cnt = 0; for (unsigned int count = 0; count < (unsigned int) g_PluginList->getNumberOfPlugins(); count++) { - bool show = g_PluginList->getType(count) == CPlugins::P_TYPE_TOOL || - g_PluginList->getType(count) == CPlugins::P_TYPE_LUA; + bool show = g_PluginList->getType(count) == CPlugins::P_TYPE_TOOL; + +#if ENABLE_LUA + show = show || g_PluginList->getType(count) == CPlugins::P_TYPE_LUA; +#endif if (show && !g_PluginList->isHidden(count)) { sprintf(id, "%d", count); @@ -322,7 +325,7 @@ bool CUserMenu::showUserMenu(int button) //printf("[neutrino usermenu] plugin %d, set key %d...\n", count, g_PluginList->getKey(count)); StreamFeaturesChanger = new CStreamFeaturesChangeExec(); keyhelper.get(&key,&icon, d_key); - menu_item = new CMenuForwarderNonLocalized(g_PluginList->getName(count), true, NULL, StreamFeaturesChanger, id, key, icon); + menu_item = new CMenuForwarder(g_PluginList->getName(count), true, NULL, StreamFeaturesChanger, id, key, icon); menu->addItem(menu_item, 0); cnt++; diff --git a/src/gui/user_menue_setup.cpp b/src/gui/user_menue_setup.cpp index 1872aa542..967b5666b 100644 --- a/src/gui/user_menue_setup.cpp +++ b/src/gui/user_menue_setup.cpp @@ -165,8 +165,8 @@ void CUserMenuSetup::checkButtonItems() { CMenuOptionChooser * opt_c = NULL; opt_c = static_cast (ums->getItem(i)); - neutrino_locale_t opt_locale = USERMENU_ITEM_OPTIONS[opt_c->getOptionValue()].value; - int set_key = USERMENU_ITEM_OPTIONS[opt_c->getOptionValue()].key; + neutrino_locale_t opt_locale = USERMENU_ITEM_OPTIONS[opt_c->getOption()].value; + int set_key = USERMENU_ITEM_OPTIONS[opt_c->getOption()].key; opt_c = NULL; if (set_key != SNeutrinoSettings::ITEM_NONE) diff --git a/src/gui/vfd_setup.cpp b/src/gui/vfd_setup.cpp index d631578a3..1d43b02c1 100644 --- a/src/gui/vfd_setup.cpp +++ b/src/gui/vfd_setup.cpp @@ -170,26 +170,26 @@ void CVfdSetup::showBrightnessSetup(CMenuWidget *mn_widget) brightnessstandby = CVFD::getInstance()->getBrightnessStandby(); brightnessdeepstandby = CVFD::getInstance()->getBrightnessDeepStandby(); - nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESS, &brightness, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, NULL, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESS, &brightness, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESS); mn_widget->addItem(nc); - nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, &brightnessstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, NULL, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSSTANDBY, &brightnessstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSSTANDBY); mn_widget->addItem(nc); if(cs_get_revision() > 7) { - nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY, &brightnessdeepstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, NULL, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDCONTROLER_BRIGHTNESSDEEPSTANDBY, &brightnessdeepstandby, true, 0, 15, this, 0, 0, NONEXISTANT_LOCALE, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSDEEPSTANDBY); mn_widget->addItem(nc); } - nc = new CMenuOptionNumberChooser(LOCALE_LCDMENU_DIM_BRIGHTNESS, &g_settings.lcd_setting_dim_brightness, vfd_enabled, -1, 15, NULL, 0, -1, LOCALE_OPTIONS_OFF, NULL, true); + nc = new CMenuOptionNumberChooser(LOCALE_LCDMENU_DIM_BRIGHTNESS, &g_settings.lcd_setting_dim_brightness, vfd_enabled, -1, 15, NULL, 0, -1, LOCALE_OPTIONS_OFF, true); nc->setHint("", LOCALE_MENU_HINT_VFD_BRIGHTNESSDIM); mn_widget->addItem(nc); mn_widget->addItem(GenericMenuSeparatorLine); if (dim_time == NULL) - dim_time = new CStringInput(LOCALE_LCDMENU_DIM_TIME, g_settings.lcd_setting_dim_time, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"0123456789 "); + dim_time = new CStringInput(LOCALE_LCDMENU_DIM_TIME, &g_settings.lcd_setting_dim_time, 3, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"0123456789 "); mf = new CMenuForwarder(LOCALE_LCDMENU_DIM_TIME, vfd_enabled, g_settings.lcd_setting_dim_time,dim_time); mf->setHint("", LOCALE_MENU_HINT_VFD_DIMTIME); diff --git a/src/gui/videosettings.cpp b/src/gui/videosettings.cpp index 59bca2c5a..0b1c5ee53 100644 --- a/src/gui/videosettings.cpp +++ b/src/gui/videosettings.cpp @@ -500,7 +500,7 @@ void CVideoSettings::setupVideoSystem(bool do_ask) if (prev_video_mode != g_settings.video_Mode) { frameBuffer->paintBackground(); - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_VIDEO_MODE_OK), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_VIDEO_MODE_OK), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) { g_settings.video_Mode = prev_video_mode; videoDecoder->SetVideoSystem(g_settings.video_Mode); @@ -602,7 +602,7 @@ void CVideoSettings::next43Mode(void) #ifdef ENABLE_PIP pipDecoder->setAspectRatio(-1, g_settings.video_43mode); #endif - ShowHintUTF(LOCALE_VIDEOMENU_43MODE, g_Locale->getText(text), 450, 2); + ShowHint(LOCALE_VIDEOMENU_43MODE, g_Locale->getText(text), 450, 2); } void CVideoSettings::SwitchFormat() @@ -628,7 +628,7 @@ void CVideoSettings::SwitchFormat() #ifdef ENABLE_PIP pipDecoder->setAspectRatio(g_settings.video_Format, -1); #endif - ShowHintUTF(LOCALE_VIDEOMENU_VIDEOFORMAT, g_Locale->getText(text), 450, 2); + ShowHint(LOCALE_VIDEOMENU_VIDEOFORMAT, g_Locale->getText(text), 450, 2); } void CVideoSettings::nextMode(void) @@ -649,7 +649,7 @@ void CVideoSettings::nextMode(void) while(1) { CVFD::getInstance()->ShowText(text); - int res = ShowHintUTF(LOCALE_VIDEOMENU_VIDEOMODE, text, 450, 2); + int res = ShowHint(LOCALE_VIDEOMENU_VIDEOMODE, text, 450, 2); if(disp_cur && res != messages_return::handled) break; @@ -686,7 +686,7 @@ void CVideoSettings::nextMode(void) break; } CVFD::getInstance()->showServicename(g_RemoteControl->getCurrentChannelName()); - //ShowHintUTF(LOCALE_VIDEOMENU_VIDEOMODE, text, 450, 2); + //ShowHint(LOCALE_VIDEOMENU_VIDEOMODE, text, 450, 2); } //sets menu mode to "wizard" or "default" diff --git a/src/gui/widget/colorchooser.cpp b/src/gui/widget/colorchooser.cpp index 4269fc328..758cce4a7 100644 --- a/src/gui/widget/colorchooser.cpp +++ b/src/gui/widget/colorchooser.cpp @@ -201,7 +201,7 @@ int CColorChooser::exec(CMenuTarget* parent, const std::string &) } case CRCInput::RC_home: if (((*value[VALUE_R] != r_alt) || (*value[VALUE_G] != g_alt) || (*value[VALUE_B] != b_alt) || ((value[VALUE_ALPHA]) && (*(value[VALUE_ALPHA]) != a_alt))) && - (ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) + (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) break; // sonst abbruch... diff --git a/src/gui/widget/hintbox.cpp b/src/gui/widget/hintbox.cpp index 9315b132e..314b0519a 100644 --- a/src/gui/widget/hintbox.cpp +++ b/src/gui/widget/hintbox.cpp @@ -237,14 +237,14 @@ void CHintBox::hide(void) } } -int ShowHintUTF(const neutrino_locale_t Caption, const char * const Text, const int Width, int timeout, const char * const Icon) +int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width, int timeout, const char * const Icon) { const char * caption = g_Locale->getText(Caption); - return ShowHintUTF(caption, Text, Width, timeout, Icon); + return ShowHint(caption, Text, Width, timeout, Icon); } -int ShowHintUTF(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon) +int ShowHint(const char * const Caption, const char * const Text, const int Width, int timeout, const char * const Icon) { neutrino_msg_t msg; neutrino_msg_data_t data; @@ -307,8 +307,13 @@ int ShowHintUTF(const char * const Caption, const char * const Text, const int W return res; } -int ShowLocalizedHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon) +int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon) { - return ShowHintUTF(Caption, g_Locale->getText(Text),Width,timeout,Icon); + return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon); +} + +int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width, int timeout, const char * const Icon) +{ + return ShowHint(Caption, g_Locale->getText(Text),Width,timeout,Icon); } diff --git a/src/gui/widget/hintbox.h b/src/gui/widget/hintbox.h index 7e7a5f36b..d58761c7d 100644 --- a/src/gui/widget/hintbox.h +++ b/src/gui/widget/hintbox.h @@ -77,9 +77,10 @@ class CHintBox }; // Text is UTF-8 encoded -int ShowHintUTF(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); -int ShowHintUTF(const char * const Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); -int ShowLocalizedHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); +int ShowHint(const neutrino_locale_t Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); +int ShowHint(const neutrino_locale_t Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); +int ShowHint(const char * const Caption, const char * const Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); +int ShowHint(const char * const Caption, const neutrino_locale_t Text, const int Width = 450, int timeout = -1, const char * const Icon = NEUTRINO_ICON_INFO); #endif diff --git a/src/gui/widget/hintboxext.cpp b/src/gui/widget/hintboxext.cpp index e5e31b411..4ac14c74c 100644 --- a/src/gui/widget/hintboxext.cpp +++ b/src/gui/widget/hintboxext.cpp @@ -60,16 +60,43 @@ CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, const char * const Tex begin = strtok(NULL, "\n"); } m_bbheight = 0; - init(Caption, Width, Icon); + init(Caption, "", Width, Icon); } +CHintBoxExt::CHintBoxExt(const std::string &CaptionString, const char * const Text, const int Width, const char * const Icon) +{ + m_message = strdup(Text); + + char *begin = m_message; + + begin = strtok(m_message, "\n"); + while (begin != NULL) + { + std::vector oneLine; + std::string s(begin); + DText *d = new DText(s); + oneLine.push_back(d); + m_lines.push_back(oneLine); + begin = strtok(NULL, "\n"); + } + m_bbheight = 0; + init(NONEXISTANT_LOCALE, CaptionString, Width, Icon); +} CHintBoxExt::CHintBoxExt(const neutrino_locale_t Caption, ContentLines& lines, const int Width, const char * const Icon) { m_message = NULL; m_lines = lines; m_bbheight = 0; - init(Caption, Width, Icon); + init(Caption, "", Width, Icon); +} + +CHintBoxExt::CHintBoxExt(const std::string &CaptionString, ContentLines& lines, const int Width, const char * const Icon) +{ + m_message = NULL; + m_lines = lines; + m_bbheight = 0; + init(NONEXISTANT_LOCALE, CaptionString, Width, Icon); } CHintBoxExt::~CHintBoxExt(void) @@ -97,7 +124,7 @@ CHintBoxExt::~CHintBoxExt(void) } } -void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const char * const Icon) +void CHintBoxExt::init(const neutrino_locale_t Caption, const std::string &CaptionString, const int Width, const char * const Icon) { m_width = Width; int nw = 0; @@ -111,6 +138,7 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c bgPainted = false; m_caption = Caption; + m_captionString = CaptionString; int page = 0; int line = 0; @@ -195,7 +223,8 @@ void CHintBoxExt::init(const neutrino_locale_t Caption, const int Width, const c else m_iconfile = ""; - nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(m_caption), true); // UTF-8 + const char *l_caption = (m_caption == NONEXISTANT_LOCALE) ? m_captionString.c_str() : g_Locale->getText(m_caption); + nw = additional_width + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(l_caption, true); // UTF-8 if (nw > m_width) m_width = nw; @@ -251,7 +280,8 @@ void CHintBoxExt::refresh(bool toround) // icon int x_offset = 6, icon_space = x_offset, x_text; - std::string title_text = g_Locale->getText(m_caption); + const char *title_text = (m_caption == NONEXISTANT_LOCALE) ? m_captionString.c_str() : g_Locale->getText(m_caption); + if (!m_iconfile.empty()) { int w, h; @@ -265,7 +295,7 @@ void CHintBoxExt::refresh(bool toround) x_text = x_offset; // title text - m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], x_text, m_theight, m_width, title_text.c_str(), COL_MENUHEAD_TEXT, 0, true); // UTF-8 + m_window->RenderString(g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE], x_text, m_theight, m_width, title_text, COL_MENUHEAD_TEXT, 0, true); // UTF-8 // background of text panel m_window->paintBoxRel(0, m_theight, m_width, (m_maxEntriesPerPage + 1) * m_fheight, (CFBWindow::color_t)COL_MENUCONTENT_PLUS_0, toround ? RADIUS_LARGE : 0, CORNER_BOTTOM);//round diff --git a/src/gui/widget/hintboxext.h b/src/gui/widget/hintboxext.h index 77d1dfc7e..445c2aaeb 100644 --- a/src/gui/widget/hintboxext.h +++ b/src/gui/widget/hintboxext.h @@ -61,6 +61,7 @@ class CHintBoxExt int m_fheight; int m_theight; neutrino_locale_t m_caption; + std::string m_captionString; char * m_message; ContentLines m_lines; std::string m_iconfile; @@ -70,12 +71,13 @@ class CHintBoxExt public: CHintBoxExt(const neutrino_locale_t Caption, const char * const Text, const int Width, const char * const Icon); - CHintBoxExt(const neutrino_locale_t Caption, ContentLines& lines, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO); + CHintBoxExt(const std::string &Caption, const char * const Text, const int Width, const char * const Icon); + CHintBoxExt(const std::string &Caption, ContentLines& lines, const int Width = 450, const char * const Icon = NEUTRINO_ICON_INFO); ~CHintBoxExt(void); - void init(const neutrino_locale_t Caption, const int Width, const char * const Icon); + void init(const neutrino_locale_t Caption, const std::string &CaptionString, const int Width, const char * const Icon); bool has_scrollbar(void); void scroll_up(void); diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index b45e0096f..1259933fb 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -57,25 +58,29 @@ CMenuForwarder * const GenericMenuNext = &CGenericMenuNext; CMenuItem::CMenuItem() { - x = -1; - directKey = CRCInput::RC_nokey; - iconName = ""; + x = -1; + directKey = CRCInput::RC_nokey; + iconName = ""; iconName_Info_right = ""; - used = false; - icon_frame_w = 10; - hint = NONEXISTANT_LOCALE; - isStatic = false; + used = false; + icon_frame_w = 10; + hint = NONEXISTANT_LOCALE; + name = NONEXISTANT_LOCALE; + nameString = ""; + isStatic = false; + marked = false; + inert = false; } void CMenuItem::init(const int X, const int Y, const int DX, const int OFFX) { - x = X; - y = Y; - dx = DX; - offx = OFFX; - name_start_x = x + offx + icon_frame_w; - item_color = COL_MENUCONTENT_TEXT; - item_bgcolor = COL_MENUCONTENT_PLUS_0; + x = X; + y = Y; + dx = DX; + offx = OFFX; + name_start_x = x + offx + icon_frame_w; + item_color = COL_MENUCONTENT_TEXT; + item_bgcolor = COL_MENUCONTENT_PLUS_0; } void CMenuItem::setActive(const bool Active) @@ -88,6 +93,20 @@ void CMenuItem::setActive(const bool Active) paint(); } +void CMenuItem::setMarked(const bool Marked) +{ + marked = Marked; + if (used && x != -1) + paint(); +} + +void CMenuItem::setInert(const bool Inert) +{ + inert = Inert; + if (used && x != -1) + paint(); +} + void CMenuItem::setItemButton(const std::string& icon_Name, const bool is_select_button) { if (is_select_button) @@ -103,11 +122,16 @@ void CMenuItem::initItemColors(const bool select_mode) item_color = COL_MENUCONTENTSELECTED_TEXT; item_bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; } - else if (!active) + else if (!active || inert) { item_color = COL_MENUCONTENTINACTIVE_TEXT; item_bgcolor = COL_MENUCONTENTINACTIVE_PLUS_0; } + else if (marked) + { + item_color = COL_MENUCONTENT_TEXT; + item_bgcolor = COL_MENUCONTENT_PLUS_1; + } else { item_color = COL_MENUCONTENT_TEXT; @@ -152,14 +176,12 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(name_start_x, y+ item_height, _dx- (name_start_x - x), left_text, item_color, 0, true); // UTF-8 //right text - if (right_text || right_bgcol) + if (right_text && (*right_text || right_bgcol)) { - int stringwidth = 0; - if (right_text) - stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text, true); + int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(right_text, true); int stringstartposOption = std::max(name_start_x + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(left_text, true) + icon_frame_w, x + dx - stringwidth - icon_frame_w); //+ offx if (right_bgcol) { - if (!right_text) + if (!*right_text) stringstartposOption -= 60; fb_pixel_t right_frame_col, right_bg_col; if (active) { @@ -175,7 +197,7 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, col.setCorner(RADIUS_LARGE); col.paint(false); } - if (right_text) { + if (*right_text) { stringstartposOption -= (icon_w == 0 ? 0 : icon_w + icon_frame_w); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(stringstartposOption, y+item_height,dx- (stringstartposOption- x), right_text, item_color, 0, true); } @@ -282,6 +304,13 @@ void CMenuItem::paintItemButton(const bool select_mode, const int &item_height, } } +const char *CMenuItem::getName(void) +{ + if (name != NONEXISTANT_LOCALE) + return g_Locale->getText(name); + return nameString.c_str(); +} + //small helper class to manage values e.g.: handling needed but deallocated widget objects CMenuGlobal::CMenuGlobal() { @@ -1166,47 +1195,99 @@ void CMenuWidget::addKey(neutrino_msg_t key, CMenuTarget *menue, const std::stri } //------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, const char * non_localized_name, bool sliderOn) +CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t Name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) { - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionName = name; - active = Active; - optionValue = OptionValue; + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + name = Name; + active = Active; + optionValue = OptionValue; - lower_bound = min_value; - upper_bound = max_value; + lower_bound = min_value; + upper_bound = max_value; - display_offset = print_offset; + display_offset = print_offset; - localized_value = special_value; + localized_value = special_value; localized_value_name = special_value_name; - optionString = non_localized_name; - numberFormat = "%d"; + nameString = ""; + numberFormat = "%d"; + numberFormatFunction = NULL; + observ = Observ; + slider_on = sliderOn; + + numeric_input = false; +} + +CMenuOptionNumberChooser::CMenuOptionNumberChooser(const std::string &Name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ, const int print_offset, const int special_value, const neutrino_locale_t special_value_name, bool sliderOn) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + name = NONEXISTANT_LOCALE; + active = Active; + optionValue = OptionValue; + + lower_bound = min_value; + upper_bound = max_value; + + display_offset = print_offset; + + localized_value = special_value; + localized_value_name = special_value_name; + + nameString = Name; + numberFormat = "%d"; numberFormatFunction = NULL; observ = Observ; slider_on = sliderOn; + + numeric_input = false; } int CMenuOptionNumberChooser::exec(CMenuTarget*) { + int res = menu_return::RETURN_NONE; + if(msg == CRCInput::RC_left) { if (((*optionValue) > upper_bound) || ((*optionValue) <= lower_bound)) *optionValue = upper_bound; else (*optionValue)--; + } else if (numeric_input && msg == CRCInput::RC_ok) { + int size = 0; + int b = lower_bound; + if (b < 0) { + size++, + b = -b; + } + if (b < upper_bound) + b = upper_bound; + for (; b; b /= 10, size++); + CIntInput cii(name, optionValue, size, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); + cii.exec(NULL, ""); + if (*optionValue > upper_bound) + *optionValue = upper_bound; + else if (*optionValue < lower_bound) + *optionValue = lower_bound; + res = menu_return::RETURN_REPAINT; } else { if (((*optionValue) >= upper_bound) || ((*optionValue) < lower_bound)) *optionValue = lower_bound; else (*optionValue)++; } - if(observ) - observ->changeNotify(optionName, optionValue); +#if ENABLE_LUA + if(observ && !luaAction.empty()) { + // optionValue is int* + observ->changeNotify(luaState, luaAction, luaId, (void *) to_string(*optionValue).c_str()); + } else +#endif + if(observ) + observ->changeNotify(name, optionValue); + // give the observer a chance to modify the value paint(true); - return menu_return::RETURN_NONE; + return res; } int CMenuOptionNumberChooser::paint(bool selected) @@ -1226,46 +1307,38 @@ int CMenuOptionNumberChooser::paint(bool selected) else l_option = g_Locale->getText(localized_value_name); - const char * l_optionName = (optionString != NULL) ? optionString : g_Locale->getText(optionName); - //paint item prepareItem(selected, height); //paint item icon paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); if(slider_on) - paintItemSlider( selected, height, *optionValue, (upper_bound - lower_bound) , l_optionName, l_option); + paintItemSlider( selected, height, *optionValue, (upper_bound - lower_bound) , getName(), l_option); //paint text - paintItemCaption(selected, height , l_optionName, l_option); + paintItemCaption(selected, height , getName(), l_option); return y+height; } int CMenuOptionNumberChooser::getWidth(void) { - const char * l_optionName = (optionString != NULL) ? optionString : g_Locale->getText(optionName); - int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_optionName, true); - + int width = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName(), true); int _lower_bound = lower_bound; int _upper_bound = upper_bound; int m = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getMaxDigitWidth(); int w1 = 0; - if (_lower_bound < 0) { + if (_lower_bound < 0) w1 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true); - _lower_bound *= -1; - } - while (_lower_bound > 0) { + while (_lower_bound) { w1 += m; _lower_bound /= 10; } int w2 = 0; - if (_upper_bound < 0) { + if (_upper_bound < 0) w2 += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("-", true); - _upper_bound *= -1; - } - while (_upper_bound > 0) { + while (_upper_bound) { w1 += m; _upper_bound /= 10; } @@ -1284,11 +1357,13 @@ int CMenuOptionNumberChooser::getWidth(void) return width + 10; /* min 10 pixels between option name and value. enough? */ } +//------------------------------------------------------------------------------------------------------------------------------- + CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = g_Locale->getText(OptionName); - optionName = OptionName; + nameString = ""; + name = OptionName; active = Active; optionValue = OptionValue; number_of_options = Number_Of_Options; @@ -1307,11 +1382,11 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * } } -CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = OptionName; - optionName = NONEXISTANT_LOCALE; + nameString = OptionName; + name = NONEXISTANT_LOCALE; active = Active; optionValue = OptionValue; number_of_options = Number_Of_Options; @@ -1335,8 +1410,8 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = g_Locale->getText(OptionName); - optionName = OptionName; + nameString = ""; + name = OptionName; active = Active; optionValue = OptionValue; number_of_options = Number_Of_Options; @@ -1349,13 +1424,13 @@ CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * options.push_back(Options[i]); } -CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval_ext * const Options, +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) { height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = OptionName; - optionName = NONEXISTANT_LOCALE; + nameString = OptionName; + name = NONEXISTANT_LOCALE; active = Active; optionValue = OptionValue; number_of_options = Number_Of_Options; @@ -1368,18 +1443,48 @@ CMenuOptionChooser::CMenuOptionChooser(const char* OptionName, int * const Optio options.push_back(Options[i]); } +CMenuOptionChooser::CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, std::vector &Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = ""; + name = OptionName; + active = Active; + optionValue = OptionValue; + options = Options; + observ = Observ; + directKey = DirectKey; + iconName = IconName; + pulldown = Pulldown; + optionsSort = OptionsSort; +} + +CMenuOptionChooser::CMenuOptionChooser(const std::string &OptionName, int * const OptionValue, std::vector &Options, const bool Active, CChangeObserver * const Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown, bool OptionsSort) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = OptionName; + name = NONEXISTANT_LOCALE; + active = Active; + optionValue = OptionValue; + options = Options; + observ = Observ; + directKey = DirectKey; + iconName = IconName; + pulldown = Pulldown; + optionsSort = OptionsSort; +} + CMenuOptionChooser::~CMenuOptionChooser() { options.clear(); clearChooserOptions(); } -void CMenuOptionChooser::setOptionValue(const int newvalue) +void CMenuOptionChooser::setOption(const int newvalue) { *optionValue = newvalue; } -int CMenuOptionChooser::getOptionValue(void) const +int CMenuOptionChooser::getOption(void) const { return *optionValue; } @@ -1396,7 +1501,9 @@ int CMenuOptionChooser::exec(CMenuTarget*) { bool wantsRepaint = false; int ret = menu_return::RETURN_NONE; - +#if ENABLE_LUA + char *optionValname = NULL; +#endif if (optionsSort) { optionsSort = false; clearChooserOptions(); @@ -1423,8 +1530,7 @@ int CMenuOptionChooser::exec(CMenuTarget*) if((msg == CRCInput::RC_ok) && pulldown) { int select = -1; - char cnt[5]; - CMenuWidget* menu = new CMenuWidget(optionNameString.c_str(), NEUTRINO_ICON_SETTINGS); + CMenuWidget* menu = new CMenuWidget(getName(), NEUTRINO_ICON_SETTINGS); /* FIXME: BACK button with hints enabled - parent menu getting holes, possible solution * to hide parent, or add hints ? */ menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); @@ -1441,8 +1547,7 @@ int CMenuOptionChooser::exec(CMenuTarget*) l_option = options[count].valname; else l_option = g_Locale->getText(options[count].value); - sprintf(cnt, "%d", count); - CMenuForwarderNonLocalized *mn_option = new CMenuForwarderNonLocalized(l_option, true, NULL, selector, cnt); + CMenuForwarder *mn_option = new CMenuForwarder(l_option, true, NULL, selector, to_string(count).c_str()); mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); menu->addItem(mn_option, selected); } @@ -1451,6 +1556,9 @@ int CMenuOptionChooser::exec(CMenuTarget*) if(select >= 0) { *optionValue = options[select].key; +#if ENABLE_LUA + optionValname = (char *) options[select].valname; +#endif } delete menu; delete selector; @@ -1459,18 +1567,33 @@ int CMenuOptionChooser::exec(CMenuTarget*) if (options[count].key == (*optionValue)) { if(msg == CRCInput::RC_left) { if(count > 0) +#if ENABLE_LUA + optionValname = (char *) options[(count-1) % number_of_options].valname, +#endif *optionValue = options[(count-1) % number_of_options].key; else +#if ENABLE_LUA + optionValname = (char *) options[number_of_options-1].valname, +#endif *optionValue = options[number_of_options-1].key; } else +#if ENABLE_LUA + optionValname = (char *) options[(count+1) % number_of_options].valname, +#endif *optionValue = options[(count+1) % number_of_options].key; break; } } } paint(true); - if(observ) - wantsRepaint = observ->changeNotify(optionName, optionValue); +#if ENABLE_LUA + if(observ && !luaAction.empty()) { + if (optionValname) + wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, optionValname); + } else +#endif + if(observ) + wantsRepaint = observ->changeNotify(name, optionValue); if ( wantsRepaint ) ret = menu_return::RETURN_REPAINT; @@ -1480,9 +1603,6 @@ int CMenuOptionChooser::exec(CMenuTarget*) int CMenuOptionChooser::paint( bool selected) { - if(optionName != NONEXISTANT_LOCALE) - optionNameString = g_Locale->getText(optionName); - neutrino_locale_t option = NONEXISTANT_LOCALE; const char * l_option = NULL; @@ -1514,7 +1634,7 @@ int CMenuOptionChooser::paint( bool selected) paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); //paint text - paintItemCaption(selected, height , optionNameString.c_str(), l_option); + paintItemCaption(selected, height , getName(), l_option); return y+height; } @@ -1522,7 +1642,7 @@ int CMenuOptionChooser::paint( bool selected) int CMenuOptionChooser::getWidth(void) { int ow = 0; - int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(optionNameString, true); + int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(getName(), true); int width = tw; for(unsigned int count = 0; count < options.size(); count++) { @@ -1543,47 +1663,29 @@ int CMenuOptionChooser::getWidth(void) //------------------------------------------------------------------------------------------------------------------------------- -CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t OptionName, char* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) -{ - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = g_Locale->getText(OptionName); - optionName = OptionName; - active = Active; - optionValue = OptionValue; - observ = Observ; - optionValueString = NULL; - directKey = DirectKey; - iconName = IconName; - pulldown = Pulldown; -} - -CMenuOptionStringChooser::CMenuOptionStringChooser(const char* OptionName, char* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) -{ - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = OptionName; - optionName = NONEXISTANT_LOCALE; - active = Active; - optionValue = OptionValue; - observ = Observ; - optionValueString = NULL; - - directKey = DirectKey; - iconName = IconName; - pulldown = Pulldown; -} - CMenuOptionStringChooser::CMenuOptionStringChooser(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) { - height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); - optionNameString = g_Locale->getText(OptionName); - optionName = OptionName; - active = Active; - optionValue = (char *) OptionValue->c_str(); + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = ""; + name = OptionName; + active = Active; optionValueString = OptionValue; - observ = Observ; + observ = Observ; + directKey = DirectKey; + iconName = IconName; + pulldown = Pulldown; +} - directKey = DirectKey; - iconName = IconName; +CMenuOptionStringChooser::CMenuOptionStringChooser(const std::string &OptionName, std::string* OptionValue, bool Active, CChangeObserver* Observ, const neutrino_msg_t DirectKey, const std::string & IconName, bool Pulldown) +{ + height = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + nameString = OptionName; + name = NONEXISTANT_LOCALE; + active = Active; + optionValueString = OptionValue; + observ = Observ; + directKey = DirectKey; + iconName = IconName; pulldown = Pulldown; } @@ -1593,9 +1695,9 @@ CMenuOptionStringChooser::~CMenuOptionStringChooser() options.clear(); } -void CMenuOptionStringChooser::addOption(const char * const value) +void CMenuOptionStringChooser::addOption(const std::string &value) { - options.push_back(std::string(value)); + options.push_back(value); } void CMenuOptionStringChooser::sortOptions() @@ -1610,61 +1712,39 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) if((!parent || msg == CRCInput::RC_ok) && pulldown) { int select = -1; - char cnt[5]; if (parent) parent->hide(); - CMenuWidget* menu = new CMenuWidget(optionNameString.c_str(), NEUTRINO_ICON_SETTINGS); + const char *l_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name); + CMenuWidget* menu = new CMenuWidget(l_name, NEUTRINO_ICON_SETTINGS); menu->addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); //if(parent) menu->move(20, 0); CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); for(unsigned int count = 0; count < options.size(); count++) { - bool selected = false; - if (strcmp(options[count].c_str(), optionValue) == 0) - selected = true; - sprintf(cnt, "%d", count); - CMenuForwarderNonLocalized *mn_option = new CMenuForwarderNonLocalized(options[count].c_str(), true, NULL, selector, cnt); + bool selected = optionValueString && (options[count] == *optionValueString); + CMenuForwarder *mn_option = new CMenuForwarder(options[count], true, NULL, selector, to_string(count).c_str()); mn_option->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true /*for selected item*/); menu->addItem(mn_option, selected); } menu->exec(NULL, ""); ret = menu_return::RETURN_REPAINT; - if(select >= 0) { - if (optionValueString) { - *optionValueString = options[select]; - optionValue = (char *)optionValueString->c_str(); - } else - strcpy(optionValue, options[select].c_str()); - } + if(select >= 0 && optionValueString) + *optionValueString = options[select]; delete menu; delete selector; } else { //select next value for(unsigned int count = 0; count < options.size(); count++) { - if (strcmp(options[count].c_str(), optionValue) == 0) { + if (optionValueString && (options[count] == *optionValueString)) { if(msg == CRCInput::RC_left) { - if(count > 0) { - if (optionValueString) { - *optionValueString = options[(count - 1) % options.size()]; - optionValue = (char *)optionValueString->c_str(); - } else - strcpy(optionValue, options[(count - 1) % options.size()].c_str()); - } else { - if (optionValueString) { - *optionValueString = options[options.size() - 1]; - optionValue = (char *)optionValueString->c_str(); - } else - strcpy(optionValue, options[options.size() - 1].c_str()); - } - } else { - if (optionValueString) { - *optionValueString = options[(count + 1) % options.size()]; - optionValue = (char *)optionValueString->c_str(); - } else - strcpy(optionValue, options[(count + 1) % options.size()].c_str()); - } + if(count > 0) + *optionValueString = options[(count - 1) % options.size()]; + else + *optionValueString = options[options.size() - 1]; + } else + *optionValueString = options[(count + 1) % options.size()]; //wantsRepaint = true; break; } @@ -1672,8 +1752,13 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) paint(true); } - if(observ) { - wantsRepaint = observ->changeNotify(optionName, optionValue); +#if ENABLE_LUA + if(observ && !luaAction.empty()) + wantsRepaint = observ->changeNotify(luaState, luaAction, luaId, (void *)(optionValueString ? optionValueString->c_str() : "")); + else +#endif + if(observ) { + wantsRepaint = observ->changeNotify(name, (void *)(optionValueString ? optionValueString->c_str() : "")); } if (wantsRepaint) ret = menu_return::RETURN_REPAINT; @@ -1683,7 +1768,7 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) int CMenuOptionStringChooser::paint( bool selected ) { - const char * l_optionName = optionNameString.c_str(); + const char *l_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name); //paint item prepareItem(selected, height); @@ -1692,7 +1777,7 @@ int CMenuOptionStringChooser::paint( bool selected ) paintItemButton(selected, height, NEUTRINO_ICON_BUTTON_OKAY); //paint text - paintItemCaption(selected, height , l_optionName, optionValue); + paintItemCaption(selected, height , l_name, optionValueString->c_str()); return y+height; } @@ -1742,25 +1827,11 @@ int CMenuOptionLanguageChooser::paint( bool selected ) } //------------------------------------------------------------------------------------------------------------------------------- -CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) -{ - option = Option; - option_string = NULL; - text=Text; - active = Active; - jumpTarget = Target; - actionKey = ActionKey ? ActionKey : ""; - directKey = DirectKey; - iconName = IconName ? IconName : ""; - iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; - isStatic = IsStatic; -} - CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) { - option = NULL; - option_string = &Option; - text=Text; + option_string_ptr = &Option; + name = Text; + nameString = ""; active = Active; jumpTarget = Target; actionKey = ActionKey ? ActionKey : ""; @@ -1770,20 +1841,65 @@ CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, isStatic = IsStatic; } -void CMenuForwarder::setOption(const char * const Option) +CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) { - option = Option; - option_string = NULL; - if (used && x != -1) - paint(); + option_string_ptr = &Option; + name = NONEXISTANT_LOCALE; + nameString = Text; + active = Active; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; + directKey = DirectKey; + iconName = IconName ? IconName : ""; + iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; + isStatic = IsStatic; +} + +CMenuForwarder::CMenuForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) +{ + option_string = Option ? Option : ""; + option_string_ptr = &option_string; + name = Text; + nameString = ""; + active = Active; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; + directKey = DirectKey; + iconName = IconName ? IconName : ""; + iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; + isStatic = IsStatic; +} + +CMenuForwarder::CMenuForwarder(const std::string& Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right, bool IsStatic) +{ + option_string = Option ? Option : ""; + option_string_ptr = &option_string; + name = NONEXISTANT_LOCALE; + nameString = Text; + active = Active; + jumpTarget = Target; + actionKey = ActionKey ? ActionKey : ""; + directKey = DirectKey; + iconName = IconName ? IconName : ""; + iconName_Info_right = IconName_Info_right ? IconName_Info_right : ""; + isStatic = IsStatic; +} + +void CMenuForwarder::setName(const std::string& t) +{ + name = NONEXISTANT_LOCALE; + nameString = t; +} + +void CMenuForwarder::setName(const neutrino_locale_t t) +{ + name = t; + nameString = ""; } void CMenuForwarder::setOption(const std::string &Option) { - option = NULL; - option_string = &Option; - if (used && x != -1) - paint(); + option_string = Option; } int CMenuForwarder::getHeight(void) const @@ -1791,32 +1907,18 @@ int CMenuForwarder::getHeight(void) const return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); } -// used gets set by the addItem() function. This is for set to paint Text from locales by just not calling the addItem() function. -// Without this, the changeNotifiers would become machine-dependent. -void CMenuForwarder::setTextLocale(const neutrino_locale_t Text) -{ - text=Text; - - if (used && x != -1) - paint(); -} - int CMenuForwarder::getWidth(void) { - int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(g_Locale->getText(text), true); - const char * option_text = NULL; - - if (option) - option_text = option; - else if (option_string) - option_text = option_string->c_str(); + const char *_name = (name == NONEXISTANT_LOCALE) ? nameString.c_str() : g_Locale->getText(name); + int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(_name, true); fb_pixel_t bgcol = 0; + std::string option_name = getOption(); if (jumpTarget) bgcol = jumpTarget->getColor(); - if (option_text != NULL) - tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true); + if (!option_name.empty()) + tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_name.c_str(), true); else if (bgcol) tw += 10 + 60; @@ -1835,28 +1937,21 @@ int CMenuForwarder::exec(CMenuTarget* parent) } } -const char * CMenuForwarder::getOption(void) +std::string CMenuForwarder::getOption(void) { - if (option) - return option; - if (option_string) - return option_string->c_str(); + if (!option_string_ptr->empty()) + return *option_string_ptr; if (jumpTarget) - return jumpTarget->getTargetValue(); - return NULL; -} - -const char * CMenuForwarder::getName(void) -{ - return g_Locale->getText(text); + return jumpTarget->getValue(); + return ""; } int CMenuForwarder::paint(bool selected) { int height = getHeight(); - const char * l_text = getName(); + const char * l_name = getName(); - const char * option_text = getOption(); + std::string option_name = getOption(); fb_pixel_t bgcol = 0; if (jumpTarget) bgcol = jumpTarget->getColor(); @@ -1868,110 +1963,49 @@ int CMenuForwarder::paint(bool selected) paintItemButton(selected, height); //caption - paintItemCaption(selected, height, l_text, option_text, bgcol); + paintItemCaption(selected, height, l_name, option_name.c_str(), bgcol); return y+ height; } -CMenuDForwarder::CMenuDForwarder(const neutrino_locale_t Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) - : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ -} - -CMenuDForwarder::CMenuDForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) - : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ -} - -CMenuDForwarder::~CMenuDForwarder() -{ - delete jumpTarget; -} - -//------------------------------------------------------------------------------------------------------------------------------- -const char * CMenuForwarderNonLocalized::getName(void) -{ - return the_text.c_str(); -} - -CMenuForwarderNonLocalized::CMenuForwarderNonLocalized(const char * const Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) : CMenuForwarder(NONEXISTANT_LOCALE, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ - the_text = Text; -} - -CMenuForwarderNonLocalized::CMenuForwarderNonLocalized(const char * const Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) : CMenuForwarder(NONEXISTANT_LOCALE, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ - the_text = Text; -} - -// used gets set by the addItem() function. This is for set to paint non localized Text by just not calling the addItem() function. -// Without this, the changeNotifiers would become machine-dependent. -void CMenuForwarderNonLocalized::setText(const char * const Text) -{ - the_text = Text; - - if (used && x != -1) - paint(); -} - -int CMenuForwarderNonLocalized::getWidth(void) -{ - int tw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(the_text, true); - const char * option_text = NULL; - if (option) - option_text = option; - else if (option_string) - option_text = option_string->c_str(); - - if (option_text != NULL) - tw += 10 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(option_text, true); - - return tw; -} - -CMenuDForwarderNonLocalized::CMenuDForwarderNonLocalized(const char * const Text, const bool Active, const char * const Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) : CMenuForwarderNonLocalized(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ -} - -CMenuDForwarderNonLocalized::CMenuDForwarderNonLocalized(const char * const Text, const bool Active, const std::string &Option, CMenuTarget* Target, const char * const ActionKey, neutrino_msg_t DirectKey, const char * const IconName, const char * const IconName_Info_right) : CMenuForwarderNonLocalized(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) -{ -} - -CMenuDForwarderNonLocalized::~CMenuDForwarderNonLocalized() -{ - delete jumpTarget; -} - //------------------------------------------------------------------------------------------------------------------------------- CMenuSeparator::CMenuSeparator(const int Type, const neutrino_locale_t Text, bool IsStatic) { - directKey = CRCInput::RC_nokey; - iconName = ""; - type = Type; - text = Text; - isStatic = IsStatic; + directKey = CRCInput::RC_nokey; + iconName = ""; + type = Type; + name = Text; + nameString = ""; + isStatic = IsStatic; } +CMenuSeparator::CMenuSeparator(const int Type, const std::string Text, bool IsStatic) +{ + directKey = CRCInput::RC_nokey; + iconName = ""; + type = Type; + name = NONEXISTANT_LOCALE; + nameString = Text; + isStatic = IsStatic; +} int CMenuSeparator::getHeight(void) const { - if (separator_text.empty() && text == NONEXISTANT_LOCALE) + if (nameString.empty() && name == NONEXISTANT_LOCALE) return 10; - else - return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); + return g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getHeight(); } -const char * CMenuSeparator::getString(void) +void CMenuSeparator::setName(const std::string& t) { - if (!separator_text.empty()) - return separator_text.c_str(); - else - return g_Locale->getText(text); + name = NONEXISTANT_LOCALE; + nameString = t; } -void CMenuSeparator::setString(const std::string& s_text) +void CMenuSeparator::setName(const neutrino_locale_t t) { - separator_text = s_text; + name = t; + nameString = ""; } int CMenuSeparator::getWidth(void) @@ -1979,11 +2013,9 @@ int CMenuSeparator::getWidth(void) int w = 0; if (type & LINE) w = 30; /* 15 pixel left and right */ - if ((type & STRING) && text != NONEXISTANT_LOCALE) - { - const char *l_text = getString(); - w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true); - } + const char *l_name = getName(); + if ((type & STRING) && *l_name) + w += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true); return w; } @@ -2011,11 +2043,11 @@ int CMenuSeparator::paint(bool selected) } if ((type & STRING)) { - const char * l_text = getString(); + const char * l_name = getName(); - if (text != NONEXISTANT_LOCALE || strlen(l_text) != 0) + if (*l_name) { - int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_text, true); // UTF-8 + int stringwidth = g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(l_name, true); // UTF-8 /* if no alignment is specified, align centered */ if (type & ALIGN_LEFT) @@ -2027,7 +2059,7 @@ int CMenuSeparator::paint(bool selected) frameBuffer->paintBoxRel(name_start_x-5, y, stringwidth+10, height, item_bgcolor); - paintItemCaption(selected, height, l_text); + paintItemCaption(selected, height, l_name); } } return y+ height; @@ -2035,43 +2067,43 @@ int CMenuSeparator::paint(bool selected) bool CPINProtection::check() { - char cPIN[5]; + hint = NONEXISTANT_LOCALE; + std::string cPIN; do { - cPIN[0] = 0; - CPINInput* PINInput = new CPINInput(title, cPIN, 4, hint); + cPIN = ""; + CPINInput* PINInput = new CPINInput(title, &cPIN, 4, hint); PINInput->exec( getParent(), ""); delete PINInput; hint = LOCALE_PINPROTECTION_WRONGCODE; - } while ((strncmp(cPIN,validPIN,4) != 0) && (cPIN[0] != 0)); - return ( strncmp(cPIN,validPIN,4) == 0); + } while ((cPIN != *validPIN) && !cPIN.empty()); + return (cPIN == *validPIN); } - bool CZapProtection::check() { + hint = NONEXISTANT_LOCALE; int res; - char cPIN[5]; + std::string cPIN; char systemstr[128]; do { - cPIN[0] = 0; + cPIN = ""; - CPLPINInput* PINInput = new CPLPINInput(title, cPIN, 4, hint, fsk); + CPLPINInput* PINInput = new CPLPINInput(title, &cPIN, 4, hint, fsk); res = PINInput->exec(getParent(), ""); delete PINInput; cPIN[4] = 0; strcpy(systemstr, CONFIGDIR "/pinentered.sh "); - strcat(systemstr, cPIN); + strcat(systemstr, cPIN.c_str()); system(systemstr); hint = LOCALE_PINPROTECTION_WRONGCODE; - } while ( (strncmp(cPIN,validPIN,4) != 0) && - (cPIN[0] != 0) && + } while ( (cPIN != *validPIN) && !cPIN.empty() && ( res == menu_return::RETURN_REPAINT ) && ( fsk >= g_settings.parentallock_lockage ) ); - return ( ( strncmp(cPIN,validPIN,4) == 0 ) || + return ( (cPIN == *validPIN) || ( fsk < g_settings.parentallock_lockage ) ); } diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index d5b067093..d80d446c3 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -45,6 +45,14 @@ #include #include +#if ENABLE_LUA +extern "C" { +#include +#include +#include +} +#endif + #define NO_WIDGET_ID -1 typedef int mn_widget_id_t; @@ -69,17 +77,26 @@ class CChangeObserver { return false; } +#if ENABLE_LUA + virtual bool changeNotify(lua_State * /*L*/, const std::string & /*luaId*/, const std::string & /*luaAction*/, void * /*Data*/) + { + return false; + } +#endif }; class CMenuTarget { + protected: + std::string *valueString; + std::string valueStringTmp; public: - CMenuTarget(){} + CMenuTarget(){ valueString = &valueStringTmp; } virtual ~CMenuTarget(){} virtual void hide(){} virtual int exec(CMenuTarget* parent, const std::string & actionKey) = 0; + virtual std::string &getValue(void) { return *valueString; } virtual fb_pixel_t getColor(void) { return 0; } - virtual const char * getTargetValue() { return NULL; } }; class CMenuItem @@ -90,16 +107,26 @@ class CMenuItem fb_pixel_t item_color, item_bgcolor; void initItemColors(const bool select_mode); - +#if ENABLE_LUA + lua_State *luaState; + std::string luaAction; + std::string luaId; +#endif + neutrino_locale_t name; + std::string nameString; + public: - bool active; + bool active; + bool marked; + bool inert; bool isStatic; neutrino_msg_t directKey; neutrino_msg_t msg; - std::string iconName; - std::string selected_iconName; - std::string iconName_Info_right; + std::string iconName; + std::string selected_iconName; + std::string iconName_Info_right; std::string hintIcon; + std::string hintText; neutrino_locale_t hint; CMenuItem(); @@ -130,6 +157,8 @@ class CMenuItem return 0; } virtual void setActive(const bool Active); + virtual void setMarked(const bool Marked); + virtual void setInert(const bool Inert); virtual void paintItemButton(const bool select_mode, const int &item_height, const std::string& icon_Name = NEUTRINO_ICON_BUTTON_RIGHT); @@ -144,132 +173,115 @@ class CMenuItem virtual void paintItemSlider( const bool select_mode, const int &item_height, const int &optionvalue, const int &factor, const char * left_text=NULL, const char * right_text=NULL); virtual int isMenueOptionChooser(void) const{return 0;} - void setHint(std::string icon, neutrino_locale_t text) { hintIcon = icon; hint = text; } + void setHint(const std::string icon, const neutrino_locale_t text) { hintIcon = icon; hint = text; } + void setHint(const std::string icon, const std::string text) { hintIcon = icon; hintText = text; } + +#if ENABLE_LUA + void setLua(lua_State *_luaState, std::string &_luaAction, std::string &_luaId) { luaState = _luaState; luaAction = _luaAction; luaId = _luaId; }; +#endif + virtual const char *getName(); }; class CMenuSeparator : public CMenuItem { - int type; - std::string separator_text; + int type; public: - neutrino_locale_t text; enum { - EMPTY = 0, - LINE = 1, - STRING = 2, - ALIGN_CENTER = 4, - ALIGN_LEFT = 8, - ALIGN_RIGHT = 16, - SUB_HEAD = 32 + EMPTY = 0, + LINE = 1, + STRING = 2, + ALIGN_CENTER = 4, + ALIGN_LEFT = 8, + ALIGN_RIGHT = 16, + SUB_HEAD = 32 }; CMenuSeparator(const int Type = 0, const neutrino_locale_t Text = NONEXISTANT_LOCALE, bool IsStatic = false); + CMenuSeparator(const int Type, const std::string Text, bool IsStatic = false); virtual ~CMenuSeparator(){} int paint(bool selected=false); int getHeight(void) const; int getWidth(void); - virtual const char * getString(void); - void setString(const std::string& text); -}; - -class CNonLocalizedMenuSeparator : public CMenuSeparator -{ - const char * the_text; - -public: - CNonLocalizedMenuSeparator(const char * ptext, const neutrino_locale_t Text1) : CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, Text1) - { - the_text = ptext; - } - - virtual const char * getString(void) - { - return the_text; - } + void setName(const std::string& text); + void setName(const neutrino_locale_t text); }; class CMenuForwarder : public CMenuItem { - std::string actionKey; + std::string actionKey; protected: - const char * option; - const std::string * option_string; - CMenuTarget * jumpTarget; - neutrino_locale_t text; + std::string option_string; + const std::string * option_string_ptr; + CMenuTarget * jumpTarget; - virtual const char * getOption(void); - virtual const char * getName(void); + virtual std::string getOption(void); public: - CMenuForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); - CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const std::string & Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const neutrino_locale_t Text, const bool Active = true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); + CMenuForwarder(const std::string & Text, const bool Active = true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL, bool IsStatic = false); virtual ~CMenuForwarder(){} int paint(bool selected=false); int getHeight(void) const; int getWidth(void); - void setTextLocale(const neutrino_locale_t Text); - neutrino_locale_t getTextLocale() const {return text;}; - CMenuTarget* getTarget() const {return jumpTarget;}; - std::string getActionKey(){return actionKey;}; + neutrino_locale_t getTextLocale() const {return name;} + CMenuTarget* getTarget() const {return jumpTarget;} + std::string getActionKey(){return actionKey;} int exec(CMenuTarget* parent); - bool isSelectable(void) const - { - return active; - } - void setOption(const char * const Option); + bool isSelectable(void) const { return active; } void setOption(const std::string &Option); + void setName(const std::string& text); + void setName(const neutrino_locale_t text); }; class CMenuDForwarder : public CMenuForwarder { public: - CMenuDForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - CMenuDForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); + CMenuDForwarder(const neutrino_locale_t Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) + : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; + CMenuDForwarder(const std::string & Text, const bool Active, const std::string &Option, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) + : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; + CMenuDForwarder(const neutrino_locale_t Text, const bool Active=true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) + : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; + CMenuDForwarder(const std::string & Text, const bool Active=true, const char * const Option=NULL, + CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const char * const IconName = NULL, const char * const IconName_Info_right = NULL) + : CMenuForwarder(Text, Active, Option, Target, ActionKey, DirectKey, IconName, IconName_Info_right) { }; - ~CMenuDForwarder(); -}; - -class CMenuForwarderNonLocalized : public CMenuForwarder -{ - protected: - std::string the_text; - virtual const char * getName(void); - public: - // Text must be UTF-8 encoded: - CMenuForwarderNonLocalized(const char * const Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - CMenuForwarderNonLocalized(const char * const Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - virtual ~CMenuForwarderNonLocalized(){} - - int getWidth(void); - - void setText(const char * const Text); -}; - -class CMenuDForwarderNonLocalized : public CMenuForwarderNonLocalized -{ - public: - CMenuDForwarderNonLocalized(const char * const Text, const bool Active=true, const char * const Option=NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - CMenuDForwarderNonLocalized(const char * const Text, const bool Active, const std::string &Option, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL); - ~CMenuDForwarderNonLocalized(); + ~CMenuDForwarder() { delete jumpTarget; } }; class CAbstractMenuOptionChooser : public CMenuItem { protected: - neutrino_locale_t optionName; - int height; - int * optionValue; + int height; + int * optionValue; int getHeight(void) const{return height;} @@ -277,10 +289,10 @@ class CAbstractMenuOptionChooser : public CMenuItem public: CAbstractMenuOptionChooser() { - optionName = NONEXISTANT_LOCALE; + name = NONEXISTANT_LOCALE; height = 0; optionValue = NULL; - }; + } ~CAbstractMenuOptionChooser(){} }; @@ -288,21 +300,26 @@ class CAbstractMenuOptionChooser : public CMenuItem class CMenuOptionNumberChooser : public CAbstractMenuOptionChooser { private: - const char * optionString; + int lower_bound; + int upper_bound; - int lower_bound; - int upper_bound; + int display_offset; - int display_offset; + int localized_value; + neutrino_locale_t localized_value_name; + bool slider_on; + bool numeric_input; + CChangeObserver * observ; + std::string numberFormat; + std::string (*numberFormatFunction)(int num); - int localized_value; - neutrino_locale_t localized_value_name; - bool slider_on; - CChangeObserver * observ; - std::string numberFormat; - std::string (*numberFormatFunction)(int num); public: - CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, const char * non_localized_name = NULL, bool sliderOn = false ); + CMenuOptionNumberChooser(const neutrino_locale_t name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, + const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, bool sliderOn = false ); + CMenuOptionNumberChooser(const std::string &name, int * const OptionValue, const bool Active, + const int min_value, const int max_value, CChangeObserver * const Observ = NULL, const int print_offset = 0, + const int special_value = 0, const neutrino_locale_t special_value_name = NONEXISTANT_LOCALE, bool sliderOn = false ); int paint(bool selected); @@ -311,6 +328,7 @@ private: int getWidth(void); void setNumberFormat(std::string format) { numberFormat = format; } void setNumberFormat(std::string (*fun)(int)) { numberFormatFunction = fun; } + void setNumericInput(bool _numeric_input) { numeric_input = _numeric_input; } }; class CMenuOptionChooserOptions @@ -345,7 +363,7 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser struct keyval { - const int key; + const int key; const neutrino_locale_t value; }; @@ -354,37 +372,44 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser std::vector option_chooser_options_v; unsigned number_of_options; CChangeObserver * observ; - std::string optionNameString; bool pulldown; bool optionsSort; void clearChooserOptions(); public: - CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval * const Options, + CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false, bool OptionsSort = false); - CMenuOptionChooser(const neutrino_locale_t OptionName, int * const OptionValue, const struct keyval_ext * const Options, + CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false, bool OptionsSort = false); - CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval * const Options, + CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false, bool OptionsSort = false); - CMenuOptionChooser(const char* OptionName, int * const OptionValue, const struct keyval_ext * const Options, + CMenuOptionChooser(const std::string &Name, int * const OptionValue, const struct keyval_ext * const Options, const unsigned Number_Of_Options, const bool Active = false, CChangeObserver * const Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false, bool OptionsSort = false); + CMenuOptionChooser(const neutrino_locale_t Name, int * const OptionValue, std::vector &Options, + const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", + bool Pulldown = false, bool OptionsSort = false); + CMenuOptionChooser(const std::string &Name, int * const OptionValue, std::vector &Options, + const bool Active = false, CChangeObserver * const Observ = NULL, + const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", + bool Pulldown = false, bool OptionsSort = false); ~CMenuOptionChooser(); - void setOptionValue(const int newvalue); - int getOptionValue(void) const; + void setOption(const int newvalue); + int getOption(void) const; int getWidth(void); int paint(bool selected); - std::string getOptionName()const {return optionNameString;}; + std::string getOptionName()const {return nameString;}; int exec(CMenuTarget* parent); int isMenueOptionChooser(void) const{return 1;} @@ -392,33 +417,27 @@ class CMenuOptionChooser : public CAbstractMenuOptionChooser class CMenuOptionStringChooser : public CMenuItem { - neutrino_locale_t optionName; - std::string optionNameString; - int height; - char * optionValue; - std::string * optionValueString; + int height; + std::string * optionValueString; std::vector options; - CChangeObserver * observ; - bool pulldown; + CChangeObserver * observ; + bool pulldown; public: - CMenuOptionStringChooser(const neutrino_locale_t OptionName, char* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false); - CMenuOptionStringChooser(const neutrino_locale_t OptionName, std::string* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false); - CMenuOptionStringChooser(const char* OptionName, char* OptionValue, bool Active = false, CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, const std::string & IconName= "", bool Pulldown = false); + CMenuOptionStringChooser(const neutrino_locale_t Name, std::string* OptionValue, bool Active = false, + CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const std::string & IconName= "", bool Pulldown = false); + CMenuOptionStringChooser(const std::string &Name, std::string* OptionValue, bool Active = false, + CChangeObserver* Observ = NULL, const neutrino_msg_t DirectKey = CRCInput::RC_nokey, + const std::string & IconName= "", bool Pulldown = false); ~CMenuOptionStringChooser(); - void addOption(const char * value); + void addOption(const std::string &value); void removeOptions(){options.clear();}; int paint(bool selected); - int getHeight(void) const - { - return height; - } - bool isSelectable(void) const - { - return active; - } + int getHeight(void) const { return height; } + bool isSelectable(void) const { return active; } void sortOptions(); int exec(CMenuTarget* parent); int isMenueOptionChooser(void) const{return 1;} @@ -560,14 +579,14 @@ class CMenuWidget : public CMenuTarget class CPINProtection { protected: - char* validPIN; + std::string *validPIN; bool check(); virtual CMenuTarget* getParent() = 0; neutrino_locale_t title, hint; public: - CPINProtection( char* validpin) + CPINProtection(std::string &validpin) { - validPIN = validpin; + validPIN = &validpin; hint = NONEXISTANT_LOCALE; title = LOCALE_PINPROTECTION_HEAD; }; @@ -583,7 +602,7 @@ class CZapProtection : public CPINProtection public: int fsk; - CZapProtection( char* validpin, int FSK ) : CPINProtection(validpin) + CZapProtection(std::string &validpin, int FSK ) : CPINProtection(validpin) { fsk = FSK; title = LOCALE_PARENTALLOCK_HEAD; @@ -599,7 +618,7 @@ class CLockedMenuForwarder : public CMenuForwarder, public CPINProtection protected: virtual CMenuTarget* getParent(){ return Parent;}; public: - CLockedMenuForwarder(const neutrino_locale_t Text, char* _validPIN, bool ask=true, const bool Active=true, char *Option=NULL, + CLockedMenuForwarder(const neutrino_locale_t Text, std::string &_validPIN, bool ask=true, const bool Active=true, const char * const Option = NULL, CMenuTarget* Target=NULL, const char * const ActionKey = NULL, neutrino_msg_t DirectKey = CRCInput::RC_nokey, const char * const IconName = NULL, const char * const IconName_Info_right = NULL) @@ -613,7 +632,7 @@ class CLockedMenuForwarder : public CMenuForwarder, public CPINProtection iconName_Info_right = IconName_Info_right ? IconName_Info_right : NEUTRINO_ICON_LOCK; else iconName_Info_right = ""; - }; + }; virtual int exec(CMenuTarget* parent); }; diff --git a/src/gui/widget/messagebox.cpp b/src/gui/widget/messagebox.cpp index 65d231eb1..cb88930de 100644 --- a/src/gui/widget/messagebox.cpp +++ b/src/gui/widget/messagebox.cpp @@ -50,6 +50,16 @@ CMessageBox::CMessageBox(const neutrino_locale_t Caption, ContentLines& Lines, c Init(Default, ShowButtons); } +CMessageBox::CMessageBox(const std::string &Caption, const char * const Text, const int Width, const char * const Icon, const CMessageBox::result_ &Default, const uint32_t ShowButtons) : CHintBoxExt(Caption, Text, Width, Icon) +{ + Init(Default, ShowButtons); +} + +CMessageBox::CMessageBox(const std::string &Caption, ContentLines& Lines, const int Width, const char * const Icon, const CMessageBox::result_ &Default, const uint32_t ShowButtons) : CHintBoxExt(Caption, Lines, Width, Icon) +{ + Init(Default, ShowButtons); +} + void CMessageBox::Init(const CMessageBox::result_ &Default, const uint32_t ShowButtons) { #define BtnCount 3 @@ -106,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_width, m_iconfile == "" ? NULL : m_iconfile.c_str()); + init(m_caption, m_captionString, m_width, m_iconfile == "" ? NULL : m_iconfile.c_str()); m_height += m_bbheight; } @@ -277,7 +287,18 @@ int CMessageBox::exec(int timeout) return res; } -int ShowMsgUTF(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +int ShowMsg(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +{ + CMessageBox* messageBox = new CMessageBox(Caption, Text, Width, Icon, Default, ShowButtons); + messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout); + messageBox->exec(timeout); + int res = messageBox->result; + delete messageBox; + + return res; +} + +int ShowMsg(const std::string &Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) { CMessageBox* messageBox = new CMessageBox(Caption, Text, Width, Icon, Default, ShowButtons); messageBox->returnDefaultValueOnTimeout(returnDefaultOnTimeout); @@ -288,22 +309,32 @@ int ShowMsgUTF(const neutrino_locale_t Caption, const char * const Text, const C return res; } -int ShowLocalizedMessage(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +int ShowMsg(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) { - return ShowMsgUTF(Caption, g_Locale->getText(Text), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); + return ShowMsg(Caption, g_Locale->getText(Text), Default, ShowButtons, Icon, Width, timeout, returnDefaultOnTimeout); } -int ShowMsgUTF(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +int ShowMsg(const std::string &Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) { - return ShowMsgUTF(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); + return ShowMsg(Caption, g_Locale->getText(Text), Default, ShowButtons, Icon, Width, timeout, returnDefaultOnTimeout); +} + +int ShowMsg(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +{ + return ShowMsg(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); +} + +int ShowMsg(const std::string &Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon, const int Width, const int timeout, bool returnDefaultOnTimeout) +{ + return ShowMsg(Caption, Text.c_str(), Default, ShowButtons, Icon, Width, timeout,returnDefaultOnTimeout); } void DisplayErrorMessage(const char * const ErrorMsg) { - ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); + ShowMsg(LOCALE_MESSAGEBOX_ERROR, ErrorMsg, CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); } void DisplayInfoMessage(const char * const ErrorMsg) { - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, ErrorMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); + ShowMsg(LOCALE_MESSAGEBOX_INFO, ErrorMsg, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); } diff --git a/src/gui/widget/messagebox.h b/src/gui/widget/messagebox.h index 4dd740875..9c63d70bc 100644 --- a/src/gui/widget/messagebox.h +++ b/src/gui/widget/messagebox.h @@ -88,8 +88,9 @@ class CMessageBox : public CHintBoxExt // Text & Caption are always UTF-8 encoded CMessageBox(const neutrino_locale_t Caption, const char * const Text, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll); - + CMessageBox(const std::string &Caption, const char * const Text, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll); CMessageBox(const neutrino_locale_t Caption, ContentLines& Lines, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll); + CMessageBox(const std::string &Caption, ContentLines& Lines, const int Width = 500, const char * const Icon = NULL, const CMessageBox::result_ &Default = mbrYes, const uint32_t ShowButtons = mbAll); int exec(int timeout = -1); void returnDefaultValueOnTimeout(bool returnDefault); @@ -99,9 +100,12 @@ class CMessageBox : public CHintBoxExt }; // Text is always UTF-8 encoded -int ShowLocalizedMessage(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); -int ShowMsgUTF(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 -int ShowMsgUTF(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const neutrino_locale_t Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const neutrino_locale_t Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const neutrino_locale_t Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const std::string &Caption, const char * const Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const std::string &Caption, const std::string & Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 +int ShowMsg(const std::string &Caption, const neutrino_locale_t Text, const CMessageBox::result_ &Default, const uint32_t ShowButtons, const char * const Icon = NULL, const int Width = 450, const int timeout = -1, bool returnDefaultOnTimeout = false); // UTF-8 void DisplayErrorMessage(const char * const ErrorMsg); // UTF-8 void DisplayInfoMessage(const char * const InfoMsg); // UTF-8 diff --git a/src/gui/widget/mountchooser.cpp b/src/gui/widget/mountchooser.cpp index ff3f25ebe..fa56e462f 100644 --- a/src/gui/widget/mountchooser.cpp +++ b/src/gui/widget/mountchooser.cpp @@ -53,7 +53,7 @@ CMountChooser::CMountChooser(const neutrino_locale_t Name, const std::string & I { std::string s = g_settings.network_nfs[i].local_dir + " (" + g_settings.network_nfs[i].ip + ":" + g_settings.network_nfs[i].dir + ")"; snprintf(indexStr,sizeof(indexStr),"%d",i); - addItem(new CMenuForwarderNonLocalized(s.c_str(),true,NULL,this,(std::string("MID:") + std::string(indexStr)).c_str()), + addItem(new CMenuForwarder(s.c_str(),true,NULL,this,(std::string("MID:") + std::string(indexStr)).c_str()), selectedLocalDir == g_settings.network_nfs[i].local_dir); } } diff --git a/src/gui/widget/stringinput.cpp b/src/gui/widget/stringinput.cpp index 7904aeb3f..1fead0be5 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -40,58 +40,15 @@ #include #include +#include + #include #include -CStringInput::CStringInput(const neutrino_locale_t Name, char* Value, const int min_value, const int max_value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) -{ - name = Name; - head = NULL; - value = Value; - valueString = NULL; - lower_bound = min_value - 1; - upper_bound = max_value + 1; - size = Size; - - hint_1 = Hint_1; - hint_2 = Hint_2; - validchars = Valid_Chars; - iconfile = Icon ? Icon : ""; - - observ = Observ; - init(); -} - -CStringInput::CStringInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) -{ - name = Name; - head = NULL; - value = Value; - valueString = NULL; - lower_bound = -1; - upper_bound = -1; - - size = Size; - - hint_1 = Hint_1; - hint_2 = Hint_2; - validchars = Valid_Chars; - iconfile = Icon ? Icon : ""; - - observ = Observ; - init(); -} - CStringInput::CStringInput(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) { name = Name; - head = NULL; - value = NULL; -#if 0 - value = new char[Size+1]; - value[Size] = '\0'; - strncpy(value,Value->c_str(),Size); -#endif + head = g_Locale->getText(Name); valueString = Value; lower_bound = -1; upper_bound = -1; @@ -106,11 +63,11 @@ CStringInput::CStringInput(const neutrino_locale_t Name, std::string* Value, int init(); } -CStringInput::CStringInput(char * Head, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) +CStringInput::CStringInput(const std::string &Name, std::string *Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) { - head = strdup(Head); - value = Value; - valueString = NULL; + name = NONEXISTANT_LOCALE; + head = Name; + valueString = Value; lower_bound = -1; upper_bound = -1; size = Size; @@ -126,19 +83,15 @@ CStringInput::CStringInput(char * Head, char* Value, int Size, const neutrino_lo CStringInput::~CStringInput() { -#if 0 - if (valueString != NULL) - { - delete[] value; - } -#endif - if(head) { - free(head); - } - g_RCInput->killTimer (smstimer); } +void CStringInput::setMinMax(const int min_value, const int max_value) +{ + lower_bound = min_value - 1; + upper_bound = max_value + 1; +} + #define CStringInputSMSButtonsCount 2 const struct button_label CStringInputSMSButtons[CStringInputSMSButtonsCount] = { @@ -162,11 +115,7 @@ void CStringInput::init() width = std::max(size*input_w + 2*offset, (int) frameBuffer->getScreenWidth() / 100 * 45); - int tmp_w = 0; - if (head) - tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head, true); // UTF-8 - else - tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(name), true); // UTF-8 + int tmp_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(head.c_str(), true); // UTF-8 if (!(iconfile.empty())) { @@ -207,9 +156,11 @@ void CStringInput::NormalKeyPressed(const neutrino_msg_t key) { if (CRCInput::isNumeric(key)) { - std::string tmp_value = value; - value[selected] = validchars[CRCInput::getNumericValue(key)]; - int current_value = atoi(value); + std::string tmp_value = *valueString; + if (selected >= (int)valueString->length()) + valueString->append(selected - valueString->length() + 1, ' '); + valueString->at(selected) = validchars[CRCInput::getNumericValue(key)]; + int current_value = atoi((*valueString).c_str()); int tmp = current_value; if (lower_bound != -1 || upper_bound != -1) { @@ -217,8 +168,8 @@ void CStringInput::NormalKeyPressed(const neutrino_msg_t key) current_value = lower_bound + 1; else if (current_value >= upper_bound) current_value = upper_bound - 1; - if (tmp != current_value) /* size + 1 is correct, snprintf includes always '\0' */ - snprintf(value, size + 1, "%*d", size, current_value); + if (tmp != current_value) + *valueString = to_string(current_value).substr(0, size); } if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){ if (selected < (size - 1)) @@ -234,7 +185,7 @@ void CStringInput::NormalKeyPressed(const neutrino_msg_t key) else paintChar(selected); }else{ - snprintf(value, size + 1, "%s", tmp_value.c_str()); + *valueString = tmp_value; } } } @@ -246,10 +197,10 @@ void CStringInput::keyBackspacePressed(void) selected--; for (int i = selected; i < size - 1; i++) { - value[i] = value[i + 1]; + valueString->at(i) = valueString->at(i + 1); paintChar(i); } - value[size - 1] = ' '; + valueString->at(size - 1) = ' '; paintChar(size - 1); } } @@ -260,7 +211,7 @@ void CStringInput::keyRedPressed() if(lower_bound == -1 || upper_bound == -1){ if (index(validchars, ' ') != NULL) { - value[selected] = ' '; + valueString->at(selected) = ' '; if (selected < (size - 1)) { @@ -277,22 +228,20 @@ void CStringInput::keyYellowPressed() { if(lower_bound == -1 || upper_bound == -1){ selected=0; + valueString->assign(valueString->length(), ' '); for(int i=0 ; i < size ; i++) - { - value[i]=' '; paintChar(i); - } } } void CStringInput::keyBluePressed() { - if (((value[selected] | 32) >= 'a') && ((value[selected] | 32) <= 'z')) + if (((valueString->at(selected) | 32) >= 'a') && ((valueString->at(selected) | 32) <= 'z')) { - char newValue = value[selected] ^ 32; + char newValue = valueString->at(selected) ^ 32; if (index(validchars, newValue) != NULL) { - value[selected] = newValue; + valueString->at(selected) = newValue; paintChar(selected); } } @@ -301,16 +250,16 @@ void CStringInput::keyBluePressed() void CStringInput::keyUpPressed() { int npos = 0; - std::string tmp_value = value; + std::string tmp_value = *valueString; for(int count=0;count<(int)strlen(validchars);count++) - if(value[selected]==validchars[count]) + if(valueString->at(selected)==validchars[count]) npos = count; npos++; if(npos>=(int)strlen(validchars)) npos = 0; - value[selected]=validchars[npos]; + valueString->at(selected)=validchars[npos]; - int current_value = atoi(value); + int current_value = atoi((*valueString).c_str()); int tmp = current_value; if (lower_bound != -1 || upper_bound != -1) { @@ -318,8 +267,8 @@ void CStringInput::keyUpPressed() current_value = lower_bound + 1; else if (current_value >= upper_bound) current_value = upper_bound - 1; - if (tmp != current_value) /* size + 1 is correct, snprintf includes always '\0' */ - snprintf(value, size + 1, "%*d", size, current_value); + if (tmp != current_value) + *valueString = to_string(current_value).substr(0, size); } if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){ if (tmp != current_value) @@ -330,23 +279,23 @@ void CStringInput::keyUpPressed() else paintChar(selected); }else{ - snprintf(value, size + 1, "%s", tmp_value.c_str()); + *valueString = tmp_value; } } void CStringInput::keyDownPressed() { int npos = 0; - std::string tmp_value = value; + std::string tmp_value = *valueString; for(int count=0;count<(int)strlen(validchars);count++) - if(value[selected]==validchars[count]) + if(valueString->at(selected)==validchars[count]) npos = count; npos--; if(npos<0) npos = strlen(validchars)-1; - value[selected]=validchars[npos]; + valueString->at(selected)=validchars[npos]; - int current_value = atoi(value); + int current_value = atoi((*valueString).c_str()); int tmp = current_value; if (lower_bound != -1 || upper_bound != -1) { @@ -354,8 +303,8 @@ void CStringInput::keyDownPressed() current_value = lower_bound + 1; else if (current_value >= upper_bound) current_value = upper_bound - 1; - if (tmp != current_value) /* size + 1 is correct, snprintf includes always '\0' */ - snprintf(value, size + 1, "%*d", size, current_value); + if (tmp != current_value) + *valueString = to_string(current_value).substr(0, size); } if( (lower_bound == -1 || upper_bound == -1) || (current_value > 0 && current_value > lower_bound && current_value < upper_bound) ){ if (tmp != current_value) @@ -366,7 +315,7 @@ void CStringInput::keyDownPressed() else paintChar(selected); }else{ - snprintf(value, size + 1, "%s", tmp_value.c_str()); + *valueString = tmp_value; } } @@ -399,11 +348,11 @@ void CStringInput::keyMinusPressed() int item = selected; while (item < (size -1)) { - value[item] = value[item+1]; + valueString->at(item) = valueString->at(item+1); paintChar(item); item++; } - value[item] = ' '; + valueString->at(item) = ' '; paintChar(item); } } @@ -414,48 +363,41 @@ void CStringInput::keyPlusPressed() int item = size -1; while (item > selected) { - value[item] = value[item-1]; + valueString->at(item) = valueString->at(item-1); paintChar(item); item--; } - value[item] = ' '; + valueString->at(item) = ' '; paintChar(item); } } +std::string &CStringInput::getValue(void) +{ + return *valueString; +} + int CStringInput::exec( CMenuTarget* parent, const std::string & ) { neutrino_msg_t msg; neutrino_msg_data_t data; int res = menu_return::RETURN_REPAINT; - char *oldval = new char[size+1]; - if(oldval == NULL) - return res; - char *dispval = new char[size+1]; - if(dispval == NULL){ - delete[] oldval; - return res; - } - if (valueString != NULL) { - value = new char[size+1]; - value[size] = '\0'; - strncpy(value,valueString->c_str(),size); - } - oldval[size] = 0; - memset(dispval, 0, size + 1); + std::string oldval = *valueString; + std::string dispval = *valueString; if (parent) parent->hide(); - for(int count=strlen(value)-1;count (int) valueString->length()) + valueString->append(size - valueString->length(), ' '); - fb_pixel_t * pixbuf = new fb_pixel_t[(width + SHADOW_OFFSET) * (height + SHADOW_OFFSET)]; - - if (pixbuf != NULL) - frameBuffer->SaveScreen(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET, pixbuf); + fb_pixel_t * pixbuf = NULL; + if (!parent) { + pixbuf = new fb_pixel_t[(width + SHADOW_OFFSET) * (height + SHADOW_OFFSET)]; + if (pixbuf) + frameBuffer->SaveScreen(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET, pixbuf); + } paint(); @@ -464,11 +406,10 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) bool loop=true; while (loop) { - if ( strncmp(value, dispval, size) != 0) + if (*valueString != dispval) { - std::string tmp = value; - CVFD::getInstance()->showMenuText(1,tmp.c_str() , selected+1); - strncpy(dispval, value, size); + CVFD::getInstance()->showMenuText(1,valueString->c_str() , selected+1); + dispval = *valueString; } g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true ); @@ -508,7 +449,7 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_green) && (index(validchars, '.') != NULL)) { - value[selected] = '.'; + valueString->at(selected) = '.'; if (selected < (size - 1)) { @@ -542,11 +483,11 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { - if ( ( strcmp(value, oldval) != 0) && - (ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) + if ((*valueString != oldval) && + (ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbYes | CMessageBox::mbCancel) == CMessageBox::mbrCancel)) continue; - strncpy(value, oldval, size); + *valueString = oldval; loop=false; res = menu_return::RETURN_EXIT_REPAINT; } @@ -572,39 +513,19 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) } } - hide(); - - if (pixbuf != NULL) + if (pixbuf) { frameBuffer->RestoreScreen(x, y, width + SHADOW_OFFSET, height + SHADOW_OFFSET, pixbuf); delete[] pixbuf;//Mismatching allocation and deallocation: pixbuf - } + } else + hide(); - for(int count=size-1;count>=0;count--) - { - if((value[count]==' ') || (value[count]==0)) - { - value[count]=0; - } - else - break; - } - value[size]=0; - - if ( (valueString != NULL) && (msg == CRCInput::RC_ok) ) - { - *valueString = value; - } + *valueString = trim (*valueString); if ( (observ) && (msg==CRCInput::RC_ok) ) { - observ->changeNotify(name, value); + observ->changeNotify(name, (void *) valueString->c_str()); } - if (valueString != NULL) - delete[] value; - - delete[] dispval; - delete[] oldval; return res; } @@ -632,7 +553,7 @@ void CStringInput::paint(bool sms) icol_o = icol_w + (offset/2); } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ (offset/2)+ icol_o, y+ hheight, width- offset- icol_o, head ? head : g_Locale->getText(name), COL_MENUHEAD_TEXT, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+ (offset/2)+ icol_o, y+ hheight, width- offset- icol_o, head.c_str(), COL_MENUHEAD_TEXT, 0, true); // UTF-8 int tmp_y = y+ hheight+ offset+ input_h+ offset; if ((hint_1 != NONEXISTANT_LOCALE) || (hint_2 != NONEXISTANT_LOCALE)) @@ -667,8 +588,8 @@ void CStringInput::paint(bool sms) void CStringInput::paintChar(int pos) { - if(pos<(int)strlen(value)) - paintChar(pos, value[pos]); + if(pos<(int)valueString->length()) + paintChar(pos, valueString->at(pos)); } void CStringInput::paintChar(int pos, const char c) @@ -700,13 +621,13 @@ void CStringInput::paintChar(int pos, const char c) g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(ch_x, ypos+ input_h, ch_w, ch, color); } -CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) +CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, std::string *Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) : CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, Icon) { initSMS(Valid_Chars); } -CStringInputSMS::CStringInputSMS(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) +CStringInputSMS::CStringInputSMS(const std::string &Name, std::string *Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ, const char * const Icon) : CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, Icon) { initSMS(Valid_Chars); @@ -773,7 +694,7 @@ void CStringInputSMS::NormalKeyPressed(const neutrino_msg_t key) } else keyCounter = (keyCounter + 1) % arraySizes[numericvalue]; - value[selected] = Chars[numericvalue][keyCounter]; + valueString->at(selected) = Chars[numericvalue][keyCounter]; last_digit = numericvalue; paintChar(selected); g_RCInput->killTimer (smstimer); @@ -781,7 +702,7 @@ void CStringInputSMS::NormalKeyPressed(const neutrino_msg_t key) } else { - value[selected] = (char)CRCInput::getUnicodeValue(key); + valueString->at(selected) = (char)CRCInput::getUnicodeValue(key); keyRedPressed(); /* to lower, paintChar */ keyRightPressed(); /* last_digit = -1, move to next position */ } @@ -795,8 +716,8 @@ void CStringInputSMS::keyBackspacePressed(void) void CStringInputSMS::keyRedPressed() // switch between lower & uppercase { - if (((value[selected] | 32) >= 'a') && ((value[selected] | 32) <= 'z')) - value[selected] ^= 32; + if (((valueString->at(selected) | 32) >= 'a') && ((valueString->at(selected) | 32) <= 'z')) + valueString->at(selected) ^= 32; paintChar(selected); } @@ -828,7 +749,7 @@ void CStringInputSMS::keyDownPressed() selected = size - 1; - while (value[selected] == ' ') + while (valueString->at(selected) == ' ') { selected--; if (selected < 0) @@ -861,7 +782,7 @@ void CStringInputSMS::paint(bool /*unused*/) void CPINInput::paintChar(int pos) { - CStringInput::paintChar(pos, (value[pos] == ' ') ? ' ' : '*'); + CStringInput::paintChar(pos, (valueString->at(pos) == ' ') ? ' ' : '*'); } int CPINInput::exec( CMenuTarget* parent, const std::string & ) @@ -874,8 +795,8 @@ int CPINInput::exec( CMenuTarget* parent, const std::string & ) if (parent) parent->hide(); - for(int count=strlen(value)-1;count (int) valueString->length()) + valueString->append(size - valueString->length(), ' '); paint(); @@ -928,25 +849,15 @@ int CPINInput::exec( CMenuTarget* parent, const std::string & ) } } } - } hide(); - for(int count=size-1;count>=0;count--) - { - if((value[count]==' ') || (value[count]==0)) - { - value[count]=0; - } - else - break; - } - value[size]=0; + *valueString = trim (*valueString); if ( (observ) && (msg==CRCInput::RC_ok) ) { - observ->changeNotify(name, value); + observ->changeNotify(name, (void *) valueString->c_str()); } return res; @@ -955,9 +866,9 @@ int CPINInput::exec( CMenuTarget* parent, const std::string & ) void CEnquiryInput::paintChar(int pos) { if (blind) - CStringInput::paintChar(pos, (value[pos] == ' ') ? ' ' : '*'); + CStringInput::paintChar(pos, (valueString->at(pos) == ' ') ? ' ' : '*'); else - CStringInput::paintChar(pos, value[pos]); + CStringInput::paintChar(pos, valueString->at(pos)); } int CPLPINInput::handleOthers(neutrino_msg_t msg, neutrino_msg_data_t data) @@ -996,7 +907,7 @@ int CPLPINInput::exec( CMenuTarget* parent, const std::string & ) { fb_pixel_t * pixbuf = new fb_pixel_t[(width+ 2* borderwidth) * (height+ 2* borderwidth)]; - if (pixbuf != NULL) + if (pixbuf) frameBuffer->SaveScreen(x- borderwidth, y- borderwidth, width+ 2* borderwidth, height+ 2* borderwidth, pixbuf); // clear border @@ -1007,9 +918,9 @@ int CPLPINInput::exec( CMenuTarget* parent, const std::string & ) int res = CPINInput::exec ( parent, "" ); - if (pixbuf != NULL) + if (pixbuf) { - frameBuffer->RestoreScreen(x- borderwidth, y- borderwidth, width+ 2* borderwidth, height+ 2* borderwidth, pixbuf); + frameBuffer->RestoreScreen(x - borderwidth, y- borderwidth, width+ 2* borderwidth, height+ 2* borderwidth, pixbuf); delete[] pixbuf;//Mismatching allocation and deallocation: pixbuf } diff --git a/src/gui/widget/stringinput.h b/src/gui/widget/stringinput.h index c7391dad3..d460b2bae 100644 --- a/src/gui/widget/stringinput.h +++ b/src/gui/widget/stringinput.h @@ -53,13 +53,11 @@ class CStringInput : public CMenuTarget uint32_t smstimer; - char * head; + std::string head; neutrino_locale_t name; neutrino_locale_t hint_1, hint_2; std::string iconfile; const char * validchars; - char * value; - std::string *valueString; int size; int selected; CChangeObserver * observ; @@ -85,18 +83,14 @@ class CStringInput : public CMenuTarget virtual int handleOthers(const neutrino_msg_t msg, const neutrino_msg_data_t data); public: - //CStringInput with max min value option - CStringInput(const neutrino_locale_t Name, char* Value , const int min_value, const int max_value - , int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); - - CStringInput(const neutrino_locale_t Name, char* Value , int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); - CStringInput(char * Head, char* Value , int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); CStringInput(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); + CStringInput(const std::string &Name, std::string* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *) "0123456789. ", CChangeObserver* Observ = NULL, const char * const Icon = NULL); ~CStringInput(); void hide(); int exec( CMenuTarget* parent, const std::string & actionKey ); - + void setMinMax(const int min_value, const int max_value); + virtual std::string &getValue(void); }; class CStringInputSMS : public CStringInput @@ -121,8 +115,8 @@ class CStringInputSMS : public CStringInput void initSMS(const char * const Valid_Chars); public: - CStringInputSMS(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ = NULL, const char * const Icon = NULL); CStringInputSMS(const neutrino_locale_t Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ = NULL, const char * const Icon = NULL); + CStringInputSMS(const std::string &Name, std::string* Value, int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, const char * const Valid_Chars, CChangeObserver* Observ = NULL, const char * const Icon = NULL); }; class CPINInput : public CStringInput @@ -130,10 +124,10 @@ class CPINInput : public CStringInput protected: virtual void paintChar(int pos); public: - CPINInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) - : CStringInput(Name, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *) NEUTRINO_ICON_LOCK) {}; - CPINInput(char * Head, char* Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) - : CStringInput(Head, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *) NEUTRINO_ICON_LOCK) {}; + CPINInput(const neutrino_locale_t Name, std::string *Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) + : CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *) NEUTRINO_ICON_LOCK) {}; + CPINInput(const std::string &Name, std::string *Value, int Size, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) + : CStringInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ, (char *) NEUTRINO_ICON_LOCK) {}; int exec( CMenuTarget* parent, const std::string & actionKey ); }; @@ -146,10 +140,10 @@ class CEnquiryInput : public CPINInput protected: virtual void paintChar(int pos); public: - CEnquiryInput(const neutrino_locale_t Name, char* Value, int Size, bool Blind, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) - : CPINInput(Name, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ) { blind = Blind; } - CEnquiryInput(char * Head, char* Value, int Size, bool Blind, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) - : CPINInput(Head, (char *)Value, Size, Hint_1, Hint_2, Valid_Chars, Observ) { blind = Blind; } + CEnquiryInput(const neutrino_locale_t Name, std::string *Value, int Size, bool Blind, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) + : CPINInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ) { blind = Blind; } + CEnquiryInput(const std::string &Name, std::string *Value, int Size, bool Blind, const neutrino_locale_t Hint_1 = NONEXISTANT_LOCALE, const neutrino_locale_t Hint_2 = NONEXISTANT_LOCALE, const char * const Valid_Chars= (const char *)"0123456789", CChangeObserver* Observ = NULL) + : CPINInput(Name, Value, Size, Hint_1, Hint_2, Valid_Chars, Observ) { blind = Blind; } }; @@ -164,8 +158,8 @@ class CPLPINInput : public CPINInput virtual const char * getHint1(void); public: - CPLPINInput(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_2, int FSK ) - : CPINInput(Name, (char *)Value, Size, NONEXISTANT_LOCALE, Hint_2) { fsk = FSK; }; + CPLPINInput(const neutrino_locale_t Name, std::string *Value, int Size, const neutrino_locale_t Hint_2, int FSK ) + : CPINInput(Name, Value, Size, NONEXISTANT_LOCALE, Hint_2) { fsk = FSK; }; int exec( CMenuTarget* parent, const std::string & actionKey ); }; @@ -173,8 +167,8 @@ class CPLPINInput : public CPINInput class CPINChangeWidget : public CStringInput { public: - CPINChangeWidget(const neutrino_locale_t Name, char* Value, int Size, const neutrino_locale_t Hint_1, const char * const Valid_Chars= (const char *) "0123456789", CChangeObserver* Observ = NULL) - : CStringInput(Name, (char *)Value, Size, Hint_1, NONEXISTANT_LOCALE, Valid_Chars, Observ){}; + CPINChangeWidget(const neutrino_locale_t Name, std::string *Value, int Size, const neutrino_locale_t Hint_1, const char * const Valid_Chars= (const char *) "0123456789", CChangeObserver* Observ = NULL) + : CStringInput(Name, Value, Size, Hint_1, NONEXISTANT_LOCALE, Valid_Chars, Observ){}; }; diff --git a/src/gui/widget/stringinput_ext.cpp b/src/gui/widget/stringinput_ext.cpp index f997d4b50..9a9bb5446 100644 --- a/src/gui/widget/stringinput_ext.cpp +++ b/src/gui/widget/stringinput_ext.cpp @@ -37,14 +37,15 @@ #include +#include #include #include -CExtendedInput::CExtendedInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel) +CExtendedInput::CExtendedInput(const neutrino_locale_t Name, std::string *Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel) { name = Name; - value = Value; + valueString = Value; cancel = Cancel; hint_1 = Hint_1; @@ -112,11 +113,14 @@ void CExtendedInput::calculateDialog() int maxX = 0; int maxY = 0; + if (valueString->size() < inputFields.size()) + valueString->append(inputFields.size() - valueString->size(), ' '); + selectedChar = -1; for(unsigned int i=0; iinit( ix, iy); - inputFields[i]->setDataPointer( &value[i] ); + inputFields[i]->setDataPointer( &valueString->at(i) ); if ((selectedChar==-1) && (inputFields[i]->isSelectable())) { selectedChar = i; @@ -139,24 +143,14 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) neutrino_msg_data_t data; onBeforeExec(); + calculateDialog(); int res = menu_return::RETURN_REPAINT; - char *oldval = new char[inputFields.size()+10]; - if(oldval == NULL) - return res; - char *dispval = new char[inputFields.size()+10]; - if(dispval == NULL){ - delete[] oldval; - return res; - } - if (parent) - { parent->hide(); - } - strcpy(oldval, value); - strcpy(dispval, value); + std::string oldval = *valueString; + std::string dispval = *valueString; paint(); uint64_t timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_MENU] == 0 ? 0xFFFF : g_settings.timing[SNeutrinoSettings::TIMING_MENU]); @@ -164,11 +158,10 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) bool loop=true; while (loop) { - if ( strcmp(value, dispval) != 0) + if (*valueString != dispval) { - std::string tmp = value; - CVFD::getInstance()->showMenuText(1, tmp.c_str(), selectedChar+1); - strcpy(dispval, value); + CVFD::getInstance()->showMenuText(1, valueString->c_str(), selectedChar+1); + dispval = *valueString; } g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd, true ); @@ -196,8 +189,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) if(found) { inputFields[oldSelectedChar]->paint(x+ offset, y+ hheight+ offset, false ); inputFields[selectedChar]->paint(x+ offset, y+ hheight+ offset, true ); - std::string tmp = value; - CVFD::getInstance()->showMenuText(1, tmp.c_str(), selectedChar+1); + CVFD::getInstance()->showMenuText(1, valueString->c_str(), selectedChar+1); } } else if (msg==CRCInput::RC_right) { bool found = false; @@ -224,8 +216,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) if(found) { inputFields[oldSelectedChar]->paint(x+ offset, y+ hheight+ offset, false ); inputFields[selectedChar]->paint(x+ offset, y+ hheight+ offset, true ); - std::string tmp = value; - CVFD::getInstance()->showMenuText(1, tmp.c_str(), selectedChar+1); + CVFD::getInstance()->showMenuText(1, valueString->c_str(), selectedChar+1); } } else if ( (CRCInput::getUnicodeValue(msg) != -1) || (msg == CRCInput::RC_red) || (msg == CRCInput::RC_green) || (msg == CRCInput::RC_blue) || (msg == CRCInput::RC_yellow) @@ -242,10 +233,10 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { - if(strcmp(value, oldval)!= 0){ - int erg = ShowLocalizedMessage(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbNo | CMessageBox::mbYes | CMessageBox::mbCancel); + if(*valueString != oldval){ + int erg = ShowMsg(name, LOCALE_MESSAGEBOX_DISCARD, CMessageBox::mbrYes, CMessageBox::mbNo | CMessageBox::mbYes | CMessageBox::mbCancel); if(erg==CMessageBox::mbrYes){ - strcpy(value, oldval); + *valueString = oldval; loop=false; if(cancel != NULL) *cancel = true; @@ -269,7 +260,7 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) } else if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { - strcpy(value, oldval); + *valueString = oldval; loop=false; if(cancel != NULL) *cancel = true; @@ -279,15 +270,12 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) hide(); + *valueString = trim(*valueString); + onAfterExec(); if ((observ) && (msg == CRCInput::RC_ok)) - { - observ->changeNotify(name, value); - } - - delete[] dispval; - delete[] oldval; + observ->changeNotify(name, (void *)valueString->c_str()); return res; } @@ -429,11 +417,8 @@ void CExtendedInput_Item_Char::keyPressed(const int key) //-----------------------------#################################------------------------------------------------------- -CIPInput::CIPInput(const neutrino_locale_t Name, std::string & Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) - : CExtendedInput(Name, IP, Hint_1, Hint_2, Observ) +CIPInput::CIPInput(const neutrino_locale_t Name, std::string *Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) : CExtendedInput(Name, Value, Hint_1, Hint_2, Observ) { - ip = &Value; - frameBuffer = CFrameBuffer::getInstance(); addInputField( new CExtendedInput_Item_Char("012") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); @@ -450,47 +435,45 @@ CIPInput::CIPInput(const neutrino_locale_t Name, std::string & Value, const neut addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_newLiner(30) ); - calculateDialog(); } void CIPInput::onBeforeExec() { - if (ip->empty()) + if (valueString->empty()) { - strcpy(value, "000.000.000.000"); - //printf("[neutrino] value-before(2): %s\n", value); + *valueString = "000.000.000.000"; return; } - unsigned char _ip[4]; - sscanf(ip->c_str(), "%hhu.%hhu.%hhu.%hhu", &_ip[0], &_ip[1], &_ip[2], &_ip[3]); - sprintf( value, "%03hhu.%03hhu.%03hhu.%03hhu", _ip[0], _ip[1], _ip[2], _ip[3]); + unsigned char ip[4]; + sscanf(valueString->c_str(), "%hhu.%hhu.%hhu.%hhu", &ip[0], &ip[1], &ip[2], &ip[3]); + char s[20]; + snprintf(s, sizeof(s), "%03hhu.%03hhu.%03hhu.%03hhu", ip[0], ip[1], ip[2], ip[3]); + *valueString = std::string(s); } void CIPInput::onAfterExec() { - int _ip[4]; - sscanf( value, "%3d.%3d.%3d.%3d", &_ip[0], &_ip[1], &_ip[2], &_ip[3] ); - sprintf( value, "%d.%d.%d.%d", _ip[0], _ip[1], _ip[2], _ip[3]); - if(strcmp(value,"0.0.0.0")==0) - { - (*ip) = ""; - } - else - (*ip) = value; + int ip[4]; + sscanf(valueString->c_str(), "%3d.%3d.%3d.%3d", &ip[0], &ip[1], &ip[2], &ip[3] ); + char s[20]; + snprintf(s, sizeof(s), "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + *valueString = std::string(s); + if(*valueString == "0.0.0.0") + *valueString = ""; } //-----------------------------#################################------------------------------------------------------- CDateInput::CDateInput(const neutrino_locale_t Name, time_t* Time, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) - : CExtendedInput(Name, (char *) "", Hint_1, Hint_2, Observ) + : CExtendedInput(Name, &valueStringTmp, Hint_1, Hint_2, Observ) { time=Time; - value= new char[20]; + char value[40]; struct tm *tmTime = localtime(time); - sprintf( value, "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1, + snprintf(value, sizeof(value), "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900, tmTime->tm_hour, tmTime->tm_min); + *valueString = std::string(value); - frameBuffer = CFrameBuffer::getInstance(); addInputField( new CExtendedInput_Item_Char("0123") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_Char(".",false) ); @@ -508,24 +491,22 @@ CDateInput::CDateInput(const neutrino_locale_t Name, time_t* Time, const neutrin addInputField( new CExtendedInput_Item_Char("012345") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_newLiner(30) ); - calculateDialog(); -} -CDateInput::~CDateInput() -{ - delete value; } + void CDateInput::onBeforeExec() { + char value[40]; struct tm *tmTime = localtime(time); - sprintf( value, "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1, + snprintf(value, sizeof(value), "%02d.%02d.%04d %02d:%02d", tmTime->tm_mday, tmTime->tm_mon+1, tmTime->tm_year+1900, tmTime->tm_hour, tmTime->tm_min); + *valueString = std::string(value); } void CDateInput::onAfterExec() { struct tm tmTime; - sscanf( value, "%02d.%02d.%04d %02d:%02d", &tmTime.tm_mday, &tmTime.tm_mon, + sscanf(valueString->c_str(), "%02d.%02d.%04d %02d:%02d", &tmTime.tm_mday, &tmTime.tm_mon, &tmTime.tm_year, &tmTime.tm_hour, &tmTime.tm_min); tmTime.tm_mon -= 1; @@ -560,18 +541,17 @@ void CDateInput::onAfterExec() tmTime.tm_sec=0; *time=mktime(&tmTime); + char value[40]; struct tm *tmTime2 = localtime(time); - sprintf( value, "%02d.%02d.%04d %02d:%02d", tmTime2->tm_mday, tmTime2->tm_mon+1, - tmTime2->tm_year+1900, - tmTime2->tm_hour, tmTime2->tm_min); + snprintf(value, sizeof(value), "%02d.%02d.%04d %02d:%02d", tmTime2->tm_mday, tmTime2->tm_mon+1, + tmTime2->tm_year+1900, + tmTime2->tm_hour, tmTime2->tm_min); + *valueString = std::string(value); } //-----------------------------#################################------------------------------------------------------- -CMACInput::CMACInput(const neutrino_locale_t Name, std::string & -Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) - : CExtendedInput(Name, MAC, Hint_1, Hint_2, Observ) +CMACInput::CMACInput(const neutrino_locale_t Name, std::string * Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) : CExtendedInput(Name, Value, Hint_1, Hint_2, Observ) { - mac = &Value; frameBuffer = CFrameBuffer::getInstance(); addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); @@ -591,41 +571,65 @@ Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeOb addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); addInputField( new CExtendedInput_Item_newLiner(30) ); - calculateDialog(); } void CMACInput::onBeforeExec() { - if (value[0] == 0) /* strcmp(value, "") == 0 */ + if (valueString->empty()) { - strcpy(value, "00:00:00:00:00:00"); - printf("[neutrino] value-before(2): %s\n", value); + *valueString = "00:00:00:00:00:00"; return; } - int _mac[6]; - sscanf( mac->c_str(), "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] ); - sprintf( value, "%02x:%02x:%02x:%02x:%02x:%02x", _mac[0], _mac[1], _mac[2], _mac[3], _mac[4], _mac[5]); + int mac[6]; + sscanf(valueString->c_str(), "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ); + char s[20]; + snprintf(s, sizeof(s), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + *valueString = std::string(s); } void CMACInput::onAfterExec() { - int _mac[6]; - sscanf( value, "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] ); - sprintf( value, "%02x:%02x:%02x:%02x:%02x:%02x", _mac[0], _mac[1], _mac[2], _mac[3], _mac[4], _mac[5]); - if(strcmp(value,"00:00:00:00:00:00")==0) - { - (*mac) = ""; - } - else - (*mac) = value; + int mac[6]; + sscanf(valueString->c_str(), "%x:%x:%x:%x:%x:%x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5] ); + char s[20]; + snprintf(s, sizeof(s), "%02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + *valueString = std::string(s); + if(*valueString == "00:00:00:00:00:00") + *valueString = ""; } //-----------------------------#################################------------------------------------------------------- -CTimeInput::CTimeInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel) - : CExtendedInput(Name, Value, Hint_1, Hint_2, Observ, Cancel) +CTimeInput::CTimeInput(const neutrino_locale_t Name, std::string* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ, bool* Cancel) + : CExtendedInput(Name, &valueStringTmp, Hint_1, Hint_2, Observ, Cancel) { + valueString = Value; frameBuffer = CFrameBuffer::getInstance(); +#if 0 + // As nobody else seems to use this class I feel free to make some minor (and mostly backwards-compatible) + // adjustments to make it suitable for movieplayer playtime selection ... --martii + + const char *v = valueString->c_str(); + if (!isdigit(*v)) { + addInputField( new CExtendedInput_Item_Char("=+-") ); + addInputField( new CExtendedInput_Item_Spacer(20) ); + } + addInputField( new CExtendedInput_Item_Char("0123456789") ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + v = strstr(v, ":"); + if (v) { + v++; + addInputField( new CExtendedInput_Item_Char(":",false) ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + v = strstr(v, ":"); + if (v) { + addInputField( new CExtendedInput_Item_Char(":",false) ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + addInputField( new CExtendedInput_Item_Char("0123456789") ); + } + } +#else addInputField( new CExtendedInput_Item_Char("=+-") ); addInputField( new CExtendedInput_Item_Spacer(20) ); addInputField( new CExtendedInput_Item_Char("0123456789") ); @@ -636,66 +640,56 @@ CTimeInput::CTimeInput(const neutrino_locale_t Name, char* Value, const neutrino addInputField( new CExtendedInput_Item_Char(":",false) ); addInputField( new CExtendedInput_Item_Char("0123456789") ); addInputField( new CExtendedInput_Item_Char("0123456789") ); +#endif addInputField( new CExtendedInput_Item_newLiner(30) ); - calculateDialog(); } void CTimeInput::onBeforeExec() { +#if 0 //--martii strcpy(value, "= 00:00:00"); +#endif } void CTimeInput::onAfterExec() { +#if 0 //--martii char tmp[10+1]; strcpy(tmp, value); strcpy(value+1, tmp+2); +#endif } //-----------------------------#################################------------------------------------------------------- -CIntInput::CIntInput(const neutrino_locale_t Name, int& Value, const unsigned int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) - : CExtendedInput(Name, myValueStringInput, Hint_1, Hint_2, Observ) +CIntInput::CIntInput(const neutrino_locale_t Name, int *Value, const unsigned int Size, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) + : CExtendedInput(Name, &valueStringTmp, Hint_1, Hint_2, Observ) { - myValue = &Value; + myValue = Value; if (Sizenumber, channel->channel_id); - CMenuForwarderNonLocalized * chan_item = new CMenuForwarderNonLocalized(channel->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channel->getName()).c_str(), CRCInput::RC_nokey, NULL, channel->scrambled ?NEUTRINO_ICON_SCRAMBLED:NULL); + CMenuForwarder * chan_item = new CMenuForwarder(channel->getName().c_str(), true, NULL, this, (std::string(cChannelId) + channel->getName()).c_str(), CRCInput::RC_nokey, NULL, channel->scrambled ?NEUTRINO_ICON_SCRAMBLED:NULL); chan_item->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); mwtv->addItem(chan_item); } if(!channels.empty() && (!g_bouquetManager->Bouquets[i]->bHidden )) { - mctv.addItem(new CMenuForwarderNonLocalized(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwtv)); + mctv.addItem(new CMenuForwarder(g_bouquetManager->Bouquets[i]->Name.c_str(), true, NULL, mwtv)); } } int res = mctv.exec (NULL, ""); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index efd9f6d3f..bc2859a87 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -560,7 +560,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.infobar_Text_blue = configfile.getInt32( "infobar_Text_blue", 0x64 ); //personalize - strcpy( g_settings.personalize_pincode, configfile.getString( "personalize_pincode", "0000" ).c_str() ); + g_settings.personalize_pincode = configfile.getString( "personalize_pincode", "0000" ); for (int i = 0; i < SNeutrinoSettings::P_SETTINGS_MAX; i++)//settings.h, settings.cpp g_settings.personalize[i] = configfile.getInt32( personalize_settings[i].personalize_settings_name, personalize_settings[i].personalize_default_val ); @@ -736,10 +736,10 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.flashupdate_createimage_add_spare = configfile.getInt32( "flashupdate_createimage_add_spare", 0); g_settings.flashupdate_createimage_add_kernel = configfile.getInt32( "flashupdate_createimage_add_kernel", 1); - strcpy(g_settings.softupdate_url_file, configfile.getString("softupdate_url_file", "/var/etc/update.urls").c_str()); - strcpy(g_settings.softupdate_proxyserver, configfile.getString("softupdate_proxyserver", "" ).c_str()); - strcpy(g_settings.softupdate_proxyusername, configfile.getString("softupdate_proxyusername", "" ).c_str()); - strcpy(g_settings.softupdate_proxypassword, configfile.getString("softupdate_proxypassword", "" ).c_str()); + g_settings.softupdate_url_file = configfile.getString("softupdate_url_file", "/var/etc/update.urls"); + g_settings.softupdate_proxyserver = configfile.getString("softupdate_proxyserver", "" ); + g_settings.softupdate_proxyusername = configfile.getString("softupdate_proxyusername", "" ); + g_settings.softupdate_proxypassword = configfile.getString("softupdate_proxypassword", "" ); // g_settings.font_file = configfile.getString("font_file", FONTDIR"/neutrino.ttf"); g_settings.ttx_font_file = configfile.getString( "ttx_font_file", FONTDIR"/DejaVuLGCSansMono-Bold.ttf"); @@ -755,14 +755,14 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.parentallock_lockage = 18; } g_settings.parentallock_defaultlocked = configfile.getInt32("parentallock_defaultlocked", 0); - strcpy( g_settings.parentallock_pincode, configfile.getString( "parentallock_pincode", "0000" ).c_str() ); + g_settings.parentallock_pincode = configfile.getString( "parentallock_pincode", "0000" ); for (int i = 0; i < SNeutrinoSettings::TIMING_SETTING_COUNT; i++) g_settings.timing[i] = configfile.getInt32(locale_real_names[timing_setting[i].name], timing_setting[i].default_timing); for (int i = 0; i < SNeutrinoSettings::LCD_SETTING_COUNT; i++) g_settings.lcd_setting[i] = configfile.getInt32(lcd_setting[i].name, lcd_setting[i].default_value); - strcpy(g_settings.lcd_setting_dim_time, configfile.getString("lcd_dim_time","0").c_str()); + g_settings.lcd_setting_dim_time = configfile.getString("lcd_dim_time","0"); g_settings.lcd_setting_dim_brightness = configfile.getInt32("lcd_dim_brightness", 0); g_settings.lcd_info_line = configfile.getInt32("lcd_info_line", 0);//channel name or clock @@ -1941,7 +1941,7 @@ fprintf(stderr, "[neutrino start] %d -> %5ld ms\n", __LINE__, time_monotonic_ms /* later on, we'll crash anyway, so tell about it. */ if (! zapit_init) - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, + ShowMsg(LOCALE_MESSAGEBOX_INFO, "Zapit initialization failed.\nThis is a fatal error, sorry.", CMessageBox::mbrBack, CMessageBox::mbBack); @@ -2071,7 +2071,7 @@ fprintf(stderr, "[neutrino start] %d -> %5ld ms\n", __LINE__, time_monotonic_ms if(loadSettingsErg) { hintBox->hide(); dprintf(DEBUG_INFO, "config file or options missing\n"); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, loadSettingsErg == 1 ? g_Locale->getText(LOCALE_SETTINGS_NOCONFFILE) + ShowHint(LOCALE_MESSAGEBOX_INFO, loadSettingsErg == 1 ? g_Locale->getText(LOCALE_SETTINGS_NOCONFFILE) : g_Locale->getText(LOCALE_SETTINGS_MISSINGOPTIONSCONFFILE)); configfile.setModifiedFlag(true); saveSetup(NEUTRINO_SETTINGS_FILE); @@ -2159,7 +2159,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) g_PluginList->startPlugin("startup.cfg"); if (!g_PluginList->getScriptOutput().empty()) { - ShowMsgUTF(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); } g_RCInput->clearRCMsg(); @@ -2362,8 +2362,8 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) usermenu.showUserMenu(SNeutrinoSettings::BUTTON_RED); StartSubtitles(); } - else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + else + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); } else if ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player) { @@ -2380,7 +2380,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) StartSubtitles(); } else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); } else if( msg == CRCInput::RC_yellow ) { // NVODs if (g_settings.personalize[SNeutrinoSettings::P_MAIN_YELLOW_BUTTON] == CPersonalizeGui::PERSONALIZE_ACTIVE_MODE_ENABLED) @@ -2390,7 +2390,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) StartSubtitles(); } else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT),450, 10); } else if( (msg == CRCInput::RC_green) || ((msg == CRCInput::RC_audio) && !g_settings.audio_run_player) ) { @@ -2410,8 +2410,8 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) usermenu.showUserMenu(SNeutrinoSettings::BUTTON_BLUE); StartSubtitles(); } - else - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT), 450, 10); + else + ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_PERSONALIZE_MENUDISABLEDHINT), 450, 10); } else if( (msg == CRCInput::RC_audio) && g_settings.audio_run_player) { //open mediaplayer menu in audio mode, user can select between audioplayer and internetradio @@ -2587,7 +2587,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) scrambled_timer = 0; if(g_settings.scrambled_message && videoDecoder->getBlank() && videoDecoder->getPlayState()) { const char * text = g_Locale->getText(LOCALE_SCRAMBLED_CHANNEL); - ShowHintUTF (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth (text, true) + 10, 5); + ShowHint (LOCALE_MESSAGEBOX_INFO, text, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth (text, true) + 10, 5); } return messages_return::handled; } @@ -2924,7 +2924,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) CTimerd::RecordingInfo * eventinfo = (CTimerd::RecordingInfo *) data; std::string name = g_Locale->getText(LOCALE_ZAPTOTIMER_ANNOUNCE); getAnnounceEpgName( eventinfo, name); - ShowHintUTF( LOCALE_MESSAGEBOX_INFO, name.c_str() ); + ShowHint( LOCALE_MESSAGEBOX_INFO, name.c_str() ); } delete [] (unsigned char*) data; return messages_return::handled; @@ -2960,20 +2960,20 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) if(( mode != mode_scart ) && ( mode != mode_standby ) && g_settings.recording_startstop_msg) { std::string name = g_Locale->getText(LOCALE_RECORDTIMER_ANNOUNCE); getAnnounceEpgName(eventinfo, name); - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, name.c_str()); + ShowHint(LOCALE_MESSAGEBOX_INFO, name.c_str()); } delete[] (unsigned char*) data; return messages_return::handled; } else if( msg == NeutrinoMessages::ANNOUNCE_SLEEPTIMER) { if( mode != mode_scart && mode != mode_standby) - skipSleepTimer = (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); + skipSleepTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE,CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); return messages_return::handled; } else if( msg == NeutrinoMessages::SLEEPTIMER) { if(data) {//INACTIVITY SLEEPTIMER skipShutdownTimer = - (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE, + (ShowMsg(LOCALE_MESSAGEBOX_INFO, g_settings.shutdown_real ? LOCALE_SHUTDOWNTIMER_ANNOUNCE:LOCALE_SLEEPTIMERBOX_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes);//FIXME if(skipShutdownTimer) { printf("NeutrinoMessages::INACTIVITY SLEEPTIMER: skiping\n"); @@ -3022,7 +3022,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } else if( msg == NeutrinoMessages::ANNOUNCE_SHUTDOWN) { if( mode != mode_scart ) - skipShutdownTimer = (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 5) == CMessageBox::mbrYes); + skipShutdownTimer = (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWNTIMER_ANNOUNCE, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 5) == CMessageBox::mbrYes); } else if( msg == NeutrinoMessages::SHUTDOWN ) { if(!skipShutdownTimer) { @@ -3051,9 +3051,9 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) } if (msg == NeutrinoMessages::EVT_POPUP) - ShowHintUTF(LOCALE_MESSAGEBOX_INFO, text.c_str(), 0, atoi(timeout.c_str())); + ShowHint(LOCALE_MESSAGEBOX_INFO, text.c_str(), 0, atoi(timeout.c_str())); else if (msg == NeutrinoMessages::EVT_EXTMSG) - ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO, 0, atoi(timeout.c_str())); + ShowMsg(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO, 0, atoi(timeout.c_str())); } delete[] (unsigned char*) data; @@ -3075,7 +3075,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) text[pos] = '\n'; } if( mode != mode_scart ) - ShowMsgUTF(LOCALE_TIMERLIST_TYPE_REMIND, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 + ShowMsg(LOCALE_TIMERLIST_TYPE_REMIND, text, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); // UTF-8 delete[] (unsigned char*) data; return messages_return::handled; } @@ -3132,7 +3132,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) else if (msg == NeutrinoMessages::EVT_START_PLUGIN) { g_PluginList->startPlugin((const char *)data); if (!g_PluginList->getScriptOutput().empty()) { - ShowMsgUTF(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); + ShowMsg(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); } delete[] (unsigned char*) data; @@ -3145,7 +3145,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) g_RCInput->postMsg(NeutrinoMessages::SHOW_INFOBAR , 0); } return messages_return::handled; -// ShowHintUTF(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EXTRA_ZAPIT_SDT_CHANGED), +// ShowHint(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_EXTRA_ZAPIT_SDT_CHANGED), // CMessageBox::mbrBack,CMessageBox::mbBack, NEUTRINO_ICON_INFO); } if ((msg >= CRCInput::RC_WithData) && (msg < CRCInput::RC_WithData + 0x10000000)) @@ -3165,7 +3165,7 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode) CRecordManager::getInstance()->StopAutoRecord(); if(CRecordManager::getInstance()->RecordingStatus()) { do_shutdown = - (ShowLocalizedMessage(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECODING_QUERY, CMessageBox::mbrNo, + (ShowMsg(LOCALE_MESSAGEBOX_INFO, LOCALE_SHUTDOWN_RECODING_QUERY, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NULL, 450, 30, true) == CMessageBox::mbrYes); } @@ -3695,7 +3695,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) int returnval = menu_return::RETURN_REPAINT; if(actionKey == "help_recording") { - ShowLocalizedMessage(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); + ShowMsg(LOCALE_SETTINGS_HELP, LOCALE_RECORDINGMENU_HELP, CMessageBox::mbrBack, CMessageBox::mbBack); } else if(actionKey=="shutdown") { ExitRun(true, 1); @@ -3813,7 +3813,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) // zB vtxt-plugins sprintf(id, "%d", count); enabled_count++; - MoviePluginSelector.addItem(new CMenuForwarderNonLocalized(g_PluginList->getName(count), true, NULL, MoviePluginChanger, id, CRCInput::convertDigitToKey(count)), (cnt == 0)); + MoviePluginSelector.addItem(new CMenuForwarder(g_PluginList->getName(count), true, NULL, MoviePluginChanger, id, CRCInput::convertDigitToKey(count)), (cnt == 0)); cnt++; } } @@ -3839,7 +3839,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) g_settings.easymenu = (g_settings.easymenu == 0) ? 1 : 0; INFO("change easymenu to %d\n", g_settings.easymenu); const char * text = g_settings.easymenu ? "Easy menu switched ON, restart box ?" : "Easy menu switched OFF, restart box ?"; - if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 0) == CMessageBox::mbrYes) + if (ShowMsg(LOCALE_MESSAGEBOX_INFO, text, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO, 0) == CMessageBox::mbrYes) g_RCInput->postMsg(NeutrinoMessages::REBOOT, 0); } } diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index 92e490b11..a958d2779 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -288,7 +288,7 @@ void CNeutrinoApp::InitMenuMain() } #ifdef ENABLE_TEST_MENU - personalize.addItem(MENU_MAIN, new CMenuForwarderNonLocalized("Test menu", true, NULL, new CTestMenu()), NULL, false, CPersonalizeGui::PERSONALIZE_SHOW_NO); + personalize.addItem(MENU_MAIN, new CMenuForwarder("Test menu", true, NULL, new CTestMenu()), NULL, false, CPersonalizeGui::PERSONALIZE_SHOW_NO); #endif } diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index 70dc544a7..2b45838b6 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -2010,9 +2010,9 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh) hh->printf("\t\t\t\t%s\n",zRepCount.c_str()); hh->printf("\t\t\t\t%d\n",(int)timer->eventRepeat); hh->printf("\t\t\t\t%s\n",zRep.c_str()); - char weekdays[8]= {0}; + std::string weekdays; NeutrinoAPI->Timerd->setWeekdaysToStr(timer->eventRepeat, weekdays); - hh->printf("\t\t\t\t%s\n",weekdays); + hh->printf("\t\t\t\t%s\n", weekdays.c_str()); hh->WriteLn("\t\t\t\n"); // channel infos @@ -2358,7 +2358,7 @@ void CControlAPI::doNewTimer(CyhookHandler *hh) else // default: no repeat rep = (CTimerd::CTimerEventRepeat)0; if(((int)rep) >= ((int)CTimerd::TIMERREPEAT_WEEKDAYS) && hh->ParamList["wd"] != "") - NeutrinoAPI->Timerd->getWeekdaysFromStr(&rep, hh->ParamList["wd"].c_str()); + NeutrinoAPI->Timerd->getWeekdaysFromStr(&rep, hh->ParamList["wd"]); // apids bool changeApids=false; diff --git a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp b/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp index 9d557fbbb..593c74c51 100644 --- a/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/neutrinoyparser.cpp @@ -981,7 +981,7 @@ std::string CNeutrinoYParser::func_set_timer_form(CyhookHandler *hh, std::strin string_printf("\n",(int)CTimerd::TIMERREPEAT_WEEKDAYS, sel.c_str(), zRep.c_str()); // Weekdays - char weekdays[8]; + std::string weekdays; NeutrinoAPI->Timerd->setWeekdaysToStr(timer.eventRepeat, weekdays); hh->ParamList["weekdays"]= weekdays; diff --git a/src/system/httptool.cpp b/src/system/httptool.cpp index c23cd0a08..dfab3521e 100644 --- a/src/system/httptool.cpp +++ b/src/system/httptool.cpp @@ -95,21 +95,18 @@ printf("url is %s\n", URL.c_str()); curl_easy_setopt(curl, CURLOPT_VERBOSE, 1); #endif - if(strcmp(g_settings.softupdate_proxyserver, "")!=0) - {//use proxyserver + if (!g_settings.softupdate_proxyserver.empty()) {//use proxyserver #ifdef DEBUG -printf("use proxyserver : %s\n", g_settings.softupdate_proxyserver); +printf("use proxyserver : %s\n", g_settings.softupdate_proxyserver.c_str()); #endif - curl_easy_setopt(curl, CURLOPT_PROXY, g_settings.softupdate_proxyserver); + curl_easy_setopt(curl, CURLOPT_PROXY, g_settings.softupdate_proxyserver.c_str()); - if(strcmp(g_settings.softupdate_proxyusername,"")!=0) - {//use auth + if (!g_settings.softupdate_proxyusername.empty()) {//use auth //printf("use proxyauth\n"); - char tmp[200]; - strcpy(tmp, g_settings.softupdate_proxyusername); - strcat(tmp, ":"); - strcat(tmp, g_settings.softupdate_proxypassword); - curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, tmp); + std::string tmp = g_settings.softupdate_proxyusername; + tmp += ":"; + tmp += g_settings.softupdate_proxypassword; + curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, tmp.c_str()); } } #ifdef DEBUG diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index c86d9d203..165d38089 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -532,7 +532,7 @@ int CDataResetNotifier::exec(CMenuTarget* /*parent*/, const std::string& actionK /* no need to confirm if we only remove deleted channels */ if (!delete_removed) { - int result = ShowMsgUTF(msg, g_Locale->getText(LOCALE_RESET_CONFIRM), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); + int result = ShowMsg(msg, g_Locale->getText(LOCALE_RESET_CONFIRM), CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo); if (result != CMessageBox::mbrYes) return true; } diff --git a/src/system/settings.cpp b/src/system/settings.cpp index 4a8cf8e72..63e96586a 100644 --- a/src/system/settings.cpp +++ b/src/system/settings.cpp @@ -111,8 +111,8 @@ CScanSettings::CScanSettings(void) delivery_system = DVB_S; bouquetMode = CZapitClient::BM_UPDATEBOUQUETS; scanType = CServiceScan::SCAN_TVRADIO; - strcpy(satName, "none"); - strcpy(cableName, "none"); + satName = "none"; + cableName ="none"; } bool CScanSettings::loadSettings(const char * const fileName, const delivery_system_t dsys) @@ -138,17 +138,17 @@ bool CScanSettings::loadSettings(const char * const fileName, const delivery_sys scan_logical_numbers = configfile.getInt32("scan_logical_numbers", 0); scan_logical_hd = configfile.getInt32("scan_logical_hd", 1); - strcpy(satName, configfile.getString("satName", satName).c_str()); - sat_TP_fec = configfile.getInt32("sat_TP_fec", 1); - sat_TP_pol = configfile.getInt32("sat_TP_pol", 0); - strcpy(sat_TP_freq, configfile.getString("sat_TP_freq", "10100000").c_str()); - strcpy(sat_TP_rate, configfile.getString("sat_TP_rate", "27500000").c_str()); + satName = configfile.getString("satName", satName); + sat_TP_fec = configfile.getInt32("sat_TP_fec", 1); + sat_TP_pol = configfile.getInt32("sat_TP_pol", 0); + sat_TP_freq = configfile.getString("sat_TP_freq", "10100000"); + sat_TP_rate = configfile.getString("sat_TP_rate", "27500000"); - strcpy(cableName, configfile.getString("cableName", cableName).c_str()); - cable_TP_mod = configfile.getInt32("cable_TP_mod", 3); - cable_TP_fec = configfile.getInt32("cable_TP_fec", 1); - strcpy(cable_TP_freq, configfile.getString("cable_TP_freq", "369000").c_str()); - strcpy(cable_TP_rate, configfile.getString("cable_TP_rate", "6875000").c_str()); + cableName = configfile.getString("cableName", cableName); + cable_TP_mod = configfile.getInt32("cable_TP_mod", 3); + cable_TP_fec = configfile.getInt32("cable_TP_fec", 1); + cable_TP_freq = configfile.getString("cable_TP_freq", "369000"); + cable_TP_rate = configfile.getString("cable_TP_rate", "6875000"); #if 1 if(sat_TP_fec == 4) sat_TP_fec = 5; #endif diff --git a/src/system/settings.h b/src/system/settings.h index 68a2fe47f..2e9cf5ab8 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -243,7 +243,7 @@ struct SNeutrinoSettings }; int personalize[P_SETTINGS_MAX]; - char personalize_pincode[5]; + std::string personalize_pincode; //timing enum TIMING_SETTINGS @@ -497,10 +497,10 @@ struct SNeutrinoSettings //Software-update int softupdate_mode; - char softupdate_url_file[31]; - char softupdate_proxyserver[31]; - char softupdate_proxyusername[31]; - char softupdate_proxypassword[31]; + std::string softupdate_url_file; + std::string softupdate_proxyserver; + std::string softupdate_proxyusername; + std::string softupdate_proxypassword; int softupdate_name_mode_apply; int softupdate_name_mode_backup; int apply_settings; @@ -519,7 +519,7 @@ struct SNeutrinoSettings int parentallock_prompt; int parentallock_lockage; int parentallock_defaultlocked; - char parentallock_pincode[5]; + std::string parentallock_pincode; // Font sizes @@ -573,7 +573,7 @@ struct SNeutrinoSettings }; int lcd_setting[LCD_SETTING_COUNT]; int lcd_info_line; - char lcd_setting_dim_time[4]; + std::string lcd_setting_dim_time; int lcd_setting_dim_brightness; int led_tv_mode; int led_standby_mode; @@ -768,20 +768,20 @@ class CScanSettings int fast_op; int cable_nid; - char satName[50]; + std::string satName; int sat_TP_fec; int sat_TP_pol; - char sat_TP_freq[10]; - char sat_TP_rate[9]; + std::string sat_TP_freq; + std::string sat_TP_rate; - char cableName[50]; + std::string cableName; int cable_TP_mod; int cable_TP_fec; - char cable_TP_freq[10]; - char cable_TP_rate[9]; + std::string cable_TP_freq; + std::string cable_TP_rate; - char terrName[50]; - char terr_TP_freq[10]; + std::string terrName; + std::string terr_TP_freq; CScanSettings(); //void useDefaults(const delivery_system_t _delivery_system); @@ -789,5 +789,4 @@ class CScanSettings bool saveSettings(const char * const fileName); }; - #endif