diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 9ebb8f4c4..fbd81df70 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -599,7 +599,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); @@ -706,7 +706,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); @@ -2605,7 +2605,7 @@ void CAudioPlayerGui::savePlaylist() absPlaylistDir += file->getFileName(); const int filenamesize = 30; - char filename[filenamesize + 1] = ""; + std::string filename; if (file->getType() == CFile::FILE_PLAYLIST) { @@ -2616,15 +2616,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, diff --git a/src/gui/bedit/bouqueteditor_bouquets.cpp b/src/gui/bedit/bouqueteditor_bouquets.cpp index 91a9700e9..e57b7c7c3 100644 --- a/src/gui/bedit/bouqueteditor_bouquets.cpp +++ b/src/gui/bedit/bouqueteditor_bouquets.cpp @@ -526,11 +526,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/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index d750f323f..ebebd8f1b 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -82,12 +82,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 a07ea0209..db0608019 100644 --- a/src/gui/cam_menu.cpp +++ b/src/gui/cam_menu.cpp @@ -410,21 +410,20 @@ int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t printf("CCAMMenuHandler::handleCamMsg: slot %d input request, text %s\n", curslot, convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 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->enguiryText, strlen(pMmiEnquiry->enguiryText), 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; } } diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index 65650bb70..f41534c1f 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -101,12 +101,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; diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index b93f43586..eff2d9506 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -2951,9 +2951,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); @@ -2968,8 +2968,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); @@ -3031,9 +3031,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 @@ -3122,13 +3122,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; isetNumericInput(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") { 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 3f9dc798d..b8098cbf5 100644 --- a/src/gui/personalize.cpp +++ b/src/gui/personalize.cpp @@ -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); 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/scan_setup.cpp b/src/gui/scan_setup.cpp index 58f35dc42..1d203d60f 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -214,7 +214,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() @@ -808,7 +808,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(); @@ -1038,9 +1038,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); diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 4f3ca671d..146c782b3 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -1085,7 +1085,7 @@ int CTimerList::modifyTimer() 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"); 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); @@ -1167,7 +1167,7 @@ int CTimerList::newTimer() 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); @@ -1217,7 +1217,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,"---"); @@ -1251,6 +1252,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; countaddItem(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/widget/menue.cpp b/src/gui/widget/menue.cpp index 625505c24..8348dcac7 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -1247,7 +1247,7 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*) 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); + CIntInput cii(name, optionValue, size, LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); cii.exec(NULL, ""); if (*optionValue > upper_bound) *optionValue = upper_bound; @@ -2037,38 +2037,38 @@ 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; 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; 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 1d7423737..5eac43348 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -572,14 +572,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; }; @@ -595,7 +595,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; @@ -611,7 +611,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) @@ -625,7 +625,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/stringinput.cpp b/src/gui/widget/stringinput.cpp index 1be9a80f6..c7f0970e0 100644 --- a/src/gui/widget/stringinput.cpp +++ b/src/gui/widget/stringinput.cpp @@ -4,6 +4,7 @@ Copyright (C) 2001 Steffen Hehn 'McClean' Homepage: http://dbox.cyberphoria.org/ + Copyright (C) 2009-2012 Stefan Seyfried License: GPL @@ -38,58 +39,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; @@ -104,11 +62,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; @@ -124,19 +82,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] = { @@ -160,11 +114,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())) { @@ -205,18 +155,36 @@ 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) + { + if (current_value <= lower_bound) + current_value = lower_bound + 1; + else if (current_value >= upper_bound) + current_value = upper_bound - 1; + 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)) { selected++; paintChar(selected - 1); } - paintChar(selected); + if (tmp != current_value) + { + for (tmp = 0; tmp < size; tmp++) + paintChar(tmp); + } + else + paintChar(selected); }else{ - snprintf(value, size,"%s",tmp_value.c_str()); + *valueString = tmp_value; } } } @@ -228,10 +196,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); } } @@ -242,7 +210,7 @@ void CStringInput::keyRedPressed() if(lower_bound == -1 || upper_bound == -1){ if (index(validchars, ' ') != NULL) { - value[selected] = ' '; + valueString->at(selected) = ' '; if (selected < (size - 1)) { @@ -259,22 +227,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); } } @@ -283,40 +249,72 @@ 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) + { + if (current_value <= lower_bound) + current_value = lower_bound + 1; + else if (current_value >= upper_bound) + current_value = upper_bound - 1; + 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) ){ - paintChar(selected); + if (tmp != current_value) + { + for (tmp = 0; tmp < size; tmp++) + paintChar(tmp); + } + else + paintChar(selected); }else{ - snprintf(value, size,"%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) + { + if (current_value <= lower_bound) + current_value = lower_bound + 1; + else if (current_value >= upper_bound) + current_value = upper_bound - 1; + 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) ){ - paintChar(selected); + if (tmp != current_value) + { + for (tmp = 0; tmp < size; tmp++) + paintChar(tmp); + } + else + paintChar(selected); }else{ - snprintf(value, size,"%s",tmp_value.c_str()); + *valueString = tmp_value; } } @@ -349,11 +347,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); } } @@ -364,48 +362,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; - dispval[size] = 0; + 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(); @@ -414,11 +405,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 ); @@ -458,7 +448,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)) { @@ -492,11 +482,11 @@ int CStringInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { - if ( ( strcmp(value, oldval) != 0) && + if ((*valueString != oldval) && (ShowLocalizedMessage(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; } @@ -522,39 +512,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; } @@ -582,7 +552,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)) @@ -617,8 +587,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) @@ -650,13 +620,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); @@ -723,7 +693,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); @@ -731,7 +701,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 */ } @@ -745,8 +715,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); } @@ -778,7 +748,7 @@ void CStringInputSMS::keyDownPressed() selected = size - 1; - while (value[selected] == ' ') + while (valueString->at(selected) == ' ') { selected--; if (selected < 0) @@ -811,7 +781,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 & ) @@ -824,8 +794,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(); @@ -878,25 +848,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; @@ -905,9 +865,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) @@ -946,7 +906,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 @@ -957,9 +917,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 0766b235f..56f8410dd 100644 --- a/src/gui/widget/stringinput_ext.cpp +++ b/src/gui/widget/stringinput_ext.cpp @@ -36,14 +36,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; @@ -111,11 +112,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; @@ -138,24 +142,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]); @@ -163,11 +157,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 ); @@ -195,8 +188,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; @@ -223,8 +215,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) @@ -241,10 +232,10 @@ int CExtendedInput::exec( CMenuTarget* parent, const std::string & ) } else if ( (msg==CRCInput::RC_home) || (msg==CRCInput::RC_timeout) ) { - if(strcmp(value, oldval)!= 0){ + if(*valueString != oldval){ int erg = ShowLocalizedMessage(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; @@ -268,7 +259,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; @@ -278,15 +269,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; } @@ -428,11 +416,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") ); @@ -449,47 +434,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) ); @@ -507,24 +490,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; @@ -559,18 +540,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") ); @@ -590,41 +570,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") ); @@ -635,66 +639,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 (Size