diff --git a/src/daemonc/remotecontrol.cpp b/src/daemonc/remotecontrol.cpp index 69fcb4c9c..98a492f3b 100644 --- a/src/daemonc/remotecontrol.cpp +++ b/src/daemonc/remotecontrol.cpp @@ -433,18 +433,25 @@ void CRemoteControl::processAPIDnames() for(int i = 0; i < 3; i++) { for(int j = 0; j < (int) current_PIDs.APIDs.size(); j++) { /* processAPIDnames called 2 times, TODO find better way to detect second call */ - if (strlen( current_PIDs.APIDs[j].desc ) != 3) + if(strlen( current_PIDs.APIDs[j].desc ) != 3) + continue; + if(strlen(g_settings.pref_lang[i]) == 0) continue; - if(strcasecmp(current_PIDs.APIDs[j].desc, g_settings.pref_lang[i].c_str()) == 0) { - /* remember first pref found index and pid*/ - if(pref_found < 0) { - pref_found = j; - pref_idx = i; - } - if(current_PIDs.APIDs[j].is_ac3 && g_settings.audio_DolbyDigital && (pref_ac3_found < 0)) { - pref_ac3_found = j; - pref_ac3_idx = i; + std::string temp(g_settings.pref_lang[i]); + std::map::const_iterator it; + for(it = iso639.begin(); it != iso639.end(); it++) { + if(temp == it->second && strcasecmp(current_PIDs.APIDs[j].desc, it->first.c_str()) == 0) { + /* remember first pref found index and pid*/ + if(pref_found < 0) { + pref_found = j; + pref_idx = i; + } + if(current_PIDs.APIDs[j].is_ac3 && g_settings.audio_DolbyDigital && (pref_ac3_found < 0)) { + pref_ac3_found = j; + pref_ac3_idx = i; + } + break; } } } /* for all pids */ diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 63ee9ea13..ae6f6e8ad 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -802,7 +802,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.auto_lang = configfile.getInt32( "auto_lang", 0 ); for(int i = 0; i < 3; i++) { sprintf(cfg_key, "pref_lang_%d", i); - g_settings.pref_lang[i] = configfile.getString(cfg_key, ""); + strncpy(g_settings.pref_lang[i], configfile.getString(cfg_key, "").c_str(), 30); } g_settings.zap_cycle = configfile.getInt32( "zap_cycle", 1 ); g_settings.sms_channel = configfile.getInt32( "sms_channel", 0 ); diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index 4fe57b1d8..86af95df0 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -1632,69 +1632,35 @@ const CMenuOptionChooser::keyval AUDIOMENU_CLOCKREC_OPTIONS[AUDIOMENU_CLOCKREC_O void sectionsd_set_languages(const std::vector& newLanguages); -class CLangSelectHandler : public CMenuTarget +class CLangSelectNotifier : public CChangeObserver { public: - void setLanguages(void); - int exec(CMenuTarget* parent, const std::string &actionkey); + bool changeNotify(const neutrino_locale_t, void * data); }; -int CLangSelectHandler::exec(CMenuTarget* parent, const std::string &actionkey) -{ - std::map::const_iterator tI; - int i; - char cnt[5]; - int select = -1; - int num = atoi(actionkey.c_str()); - - if (parent) - parent->hide(); - - CMenuWidget* menu = new CMenuWidget(LOCALE_AUDIOMENU_PREF_LANG, NEUTRINO_ICON_SETTINGS); - CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); - i = 0; - for (tI = iso639.begin(); tI != iso639.end(); tI++) { - sprintf(cnt, "%d", i); - menu->addItem(new CMenuForwarderNonLocalized(tI->second.c_str(), true, NULL, selector, cnt), g_settings.pref_lang[num] == tI->first); - i++; - } - if (i == 0) { - char text[255]; - sprintf(text, "No languages found !\n"); - ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, text, 450, 2); - return menu_return::RETURN_REPAINT; - } - int retval = menu->exec(NULL, ""); - delete menu; - delete selector; - if (select >= 0) { - tI = iso639.begin(); - for(i = 0; i < select; i++) - tI++; - - printf("CLangSelectHandler: selected %d: %s (%s)\n", i, tI->first.c_str(), tI->second.c_str()); - g_settings.pref_lang[num] = tI->first.c_str(); - setLanguages(); - } - if (retval == menu_return::RETURN_EXIT_ALL) - return menu_return::RETURN_EXIT_ALL; - - return menu_return::RETURN_REPAINT; -} - -void CLangSelectHandler::setLanguages(void) +bool CLangSelectNotifier::changeNotify(const neutrino_locale_t, void *) { std::vector languages; bool found = false; + std::map::const_iterator it; for(int i = 0; i < 3; i++) { - if(g_settings.pref_lang[i].size()) { - languages.push_back(g_settings.pref_lang[i]); - found = true; + if(strlen(g_settings.pref_lang[i])) { + printf("setLanguages: %d: %s\n", i, g_settings.pref_lang[i]); + std::string temp(g_settings.pref_lang[i]); + for(it = iso639.begin(); it != iso639.end(); it++) { + if(temp == it->second) { + languages.push_back(it->first); + printf("setLanguages: adding %s\n", it->first.c_str()); + found = true; + } + } } } if(found) sectionsd_set_languages(languages); + + return true; } void CNeutrinoApp::InitAudioSettings(CMenuWidget &audioSettings, CAudioSetupNotifier* audioSetupNotifier) @@ -1715,15 +1681,19 @@ void CNeutrinoApp::InitAudioSettings(CMenuWidget &audioSettings, CAudioSetupNoti audioSettings.addItem(new CMenuOptionNumberChooser(LOCALE_SRS_VOLUME, &g_settings.srs_ref_volume, true, 1, 100, audioSetupNotifier)); audioSettings.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_PREF_LANG_HEAD)); - - CLangSelectHandler * langSelect = new CLangSelectHandler(); audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_DOLBYDIGITAL, &g_settings.audio_DolbyDigital, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, audioSetupNotifier)); audioSettings.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_AUTO_LANG, &g_settings.auto_lang, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, audioSetupNotifier)); - audioSettings.addItem(new CMenuForwarder(LOCALE_AUDIOMENU_PREF_LANG, true, NULL, langSelect, "0")); - audioSettings.addItem(new CMenuForwarder(LOCALE_AUDIOMENU_PREF_LANG, true, NULL, langSelect, "1")); - audioSettings.addItem(new CMenuForwarder(LOCALE_AUDIOMENU_PREF_LANG, true, NULL, langSelect, "2")); - langSelect->setLanguages(); + CLangSelectNotifier * langNotifier = new CLangSelectNotifier(); + for(int i = 0; i < 3; i++) { + CMenuOptionStringChooser * langSelect = new CMenuOptionStringChooser(LOCALE_AUDIOMENU_PREF_LANG, g_settings.pref_lang[i], true, langNotifier, CRCInput::convertDigitToKey(i+1), "", true); + std::map::const_iterator it; + for(it = iso639rev.begin(); it != iso639rev.end(); it++) { + langSelect->addOption(it->first.c_str()); + } + audioSettings.addItem(langSelect); + } + langNotifier->changeNotify(NONEXISTANT_LOCALE, NULL); #if 0 CStringInput * audio_PCMOffset = new CStringInput(LOCALE_AUDIOMENU_PCMOFFSET, g_settings.audio_PCMOffset, 2, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789 ", audioSetupNotifier); diff --git a/src/sectionsd/SIevents.cpp b/src/sectionsd/SIevents.cpp index 70ef73769..85c572f7d 100644 --- a/src/sectionsd/SIevents.cpp +++ b/src/sectionsd/SIevents.cpp @@ -218,6 +218,7 @@ std::string SIevent::getName() const void SIevent::setName(const std::string &lang, const std::string &name) { +//printf("setName: lang %s text %s\n", lang.c_str(), name.c_str()); if (CSectionsdClient::LANGUAGE_MODE_OFF == SIlanguage::getMode()){ langName[languangeOFF] = name; } else { @@ -240,6 +241,7 @@ std::string SIevent::getText() const void SIevent::setText(const std::string &lang, const std::string &text) { +//printf("setText: lang %s text %s\n", lang.c_str(), text.c_str()); if (CSectionsdClient::LANGUAGE_MODE_OFF == SIlanguage::getMode()){ langText[languangeOFF] = text; } else { @@ -271,6 +273,7 @@ void SIevent::appendExtendedText(const std::string &lang, const std::string &tex void SIevent::setExtendedText(const std::string &lang, const std::string &text) { +//printf("setExtendedText: lang %s text %s\n", lang.c_str(), text.c_str()); if (CSectionsdClient::LANGUAGE_MODE_OFF == SIlanguage::getMode()){ langExtendedText[languangeOFF] = text; } else { diff --git a/src/sectionsd/SIlanguage.cpp b/src/sectionsd/SIlanguage.cpp index f2fe00330..383539091 100644 --- a/src/sectionsd/SIlanguage.cpp +++ b/src/sectionsd/SIlanguage.cpp @@ -177,7 +177,8 @@ bool SIlanguage::saveLanguages() for (std::vector::iterator it = languages.begin() ; it != languages.end() ; ++it) { - file << " " << *it; + file << *it; + file << "\n"; if (file.fail()) goto error; } diff --git a/src/sectionsd/SIsections.cpp b/src/sectionsd/SIsections.cpp index 222e024e5..91188cf52 100644 --- a/src/sectionsd/SIsections.cpp +++ b/src/sectionsd/SIsections.cpp @@ -210,7 +210,7 @@ void SIsectionEIT::parseExtendedEventDescriptor(const char *buf, SIevent &e, uns int tsidonid = (e.transport_stream_id << 16) | e.original_network_id; int table = get_table(evt->iso_639_2_language_code_hi, evt->iso_639_2_language_code_mid, evt->iso_639_2_language_code_lo); - char lang[] = {evt->iso_639_2_language_code_hi, evt->iso_639_2_language_code_mid, evt->iso_639_2_language_code_lo, '\0'}; + char lang[] = {tolower(evt->iso_639_2_language_code_hi), tolower(evt->iso_639_2_language_code_mid), tolower(evt->iso_639_2_language_code_lo), '\0'}; std::string language(lang); while(items < (unsigned char *)(buf + sizeof(struct descr_extended_event_header) + evt->length_of_items)) { @@ -379,7 +379,7 @@ void SIsectionEIT::parseShortEventDescriptor(const char *buf, SIevent &e, unsign int tsidonid = (e.transport_stream_id << 16) | e.original_network_id; int table = get_table(evt->language_code_hi, evt->language_code_mid, evt->language_code_lo); - char lang[] = {evt->language_code_hi, evt->language_code_mid, evt->language_code_lo, '\0'}; + char lang[] = {tolower(evt->language_code_hi), tolower(evt->language_code_mid), tolower(evt->language_code_lo), '\0'}; std::string language(lang); buf+=sizeof(struct descr_short_event_header); diff --git a/src/sectionsd/sectionsd.cpp b/src/sectionsd/sectionsd.cpp index e82d787ba..f78cb16b3 100644 --- a/src/sectionsd/sectionsd.cpp +++ b/src/sectionsd/sectionsd.cpp @@ -8499,7 +8499,7 @@ void sectionsd_main_thread(void */*data*/) printf("$Id: sectionsd.cpp,v 1.305 2009/07/30 12:41:39 seife Exp $\n"); - SIlanguage::loadLanguages(); + /* SIlanguage::loadLanguages(); */ tzset(); // TZ auswerten @@ -9353,4 +9353,5 @@ void sectionsd_setPrivatePid(unsigned short /*pid*/) void sectionsd_set_languages(const std::vector& newLanguages) { SIlanguage::setLanguages(newLanguages); + SIlanguage::saveLanguages();//FIXME for debug } diff --git a/src/system/localize.cpp b/src/system/localize.cpp index 03d9252a6..3f8cbb5fb 100644 --- a/src/system/localize.cpp +++ b/src/system/localize.cpp @@ -134,6 +134,7 @@ const char * getISO639Description(const char * const iso) #else std::map iso639; +std::map iso639rev; void initialize_iso639_map(void) { @@ -147,8 +148,10 @@ void initialize_iso639_map(void) { getline(in, v); iso639[s] = v; - if (s != t) + if (s != t) { iso639[t] = v; + } + iso639rev[v] = s; } } else diff --git a/src/system/localize.h b/src/system/localize.h index 61108ce3c..6e90cb5fe 100644 --- a/src/system/localize.h +++ b/src/system/localize.h @@ -42,6 +42,7 @@ void initialize_iso639_map(void); const char * getISO639Description(const char * const iso); extern std::map iso639; +extern std::map iso639rev; #define ARE_LOCALES_EQUAL(a,b) (a == b) diff --git a/src/system/settings.h b/src/system/settings.h index df4cb64b9..3c2d3639c 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -95,7 +95,7 @@ struct SNeutrinoSettings char language[25]; char timezone[150]; - std::string pref_lang[3]; + char pref_lang[3][30]; // EPG int epg_save; diff --git a/src/zapit/src/pmt.cpp b/src/zapit/src/pmt.cpp index 1a5911e26..a92ab4e9d 100644 --- a/src/zapit/src/pmt.cpp +++ b/src/zapit/src/pmt.cpp @@ -104,7 +104,7 @@ unsigned short parse_ES_info(const unsigned char * const buffer, CZapitChannel * case 0x0A: /* ISO_639_language_descriptor */ for (i = 0; i < 3; i++) - description += buffer[pos + i + 2]; + description += tolower(buffer[pos + i + 2]); break; case 0x13: /* Defined in ISO/IEC 13818-6 */