diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index b3fc76430..291745661 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -167,7 +167,7 @@ audioplayer.receiving_list Liste wird empfangen, bitte warten... audioplayer.repeat_on Repeatmodus aktivieren audioplayer.rewind schneller Rückl. audioplayer.save_playlist Playlist speichern -audioplayer.screensaver_timeout Bildschirmschoner (min, 0=aus) +audioplayer.screensaver_timeout Bildschirmschoner audioplayer.select_title_by_name Titelsuche nach Name (SMS) audioplayer.show_playlist Playlist anzeigen audioplayer.shuffle Zufällig @@ -266,6 +266,7 @@ colorchooser.blue blau colorchooser.green grün colorchooser.red rot colormenu.background Hintergrundfarbe +colormenu.clock_textcolor Ziffernfarbe colormenu.contrast_fonts Schriftkontrast colormenu.fade Ein-/Ausblenden colormenu.font Neutrino Schriftart @@ -399,7 +400,7 @@ extra.lodirection Längengrad-Ausrichtung extra.longitude Längengrad extra.menu_left_exit "links" = Menü zurück extra.north Norden -extra.record_time Max. Aufnahmezeit in Stunden +extra.record_time Maximale Aufnahmezeit extra.rotor_swap Rotor dreht Ost/West extra.rounded_corners Eckendarstellung extra.rounded_corners_off eckig @@ -437,7 +438,7 @@ extra.zap_cycle Zap nur in Bouquet extra.zapit_fe_timeout Tuning Timeout extra.zapit_hvoltage High (13.5/ 18.5) Voltage extra.zapit_make_bouquet Kanalliste auffüllen -extra.zapit_motor_speed Rotor Drehzeit (10 = 1°/ sec) +extra.zapit_motor_speed Rotor Drehzeit extra.zapit_scanpids PIDs scannen/nutzen extra.zapit_sdt_changed Kanalliste wird neu geladen. fan_speed CPU-Lüftergeschwindigkeit @@ -817,6 +818,7 @@ menu.hint_clock_background Lassen Sie die Uhr mit Hintergrund anzeigen menu.hint_clock_mode Schalten Sie die Uhr ein oder aus menu.hint_clock_seconds Legen Sie fest, ob die Sekunden angezeigt werden sollen menu.hint_clock_size Stellen Sie die Größe der Uhr ein +menu.hint_clock_textcolor Konfigurieren Sie die Farbe der Ziffern menu.hint_colors Konfigurieren Sie die Menü-Farben menu.hint_content_back Ändern Sie die Hintergrundfarbe für den Fensterinhalt menu.hint_content_textcolor Ändern Sie die Textfarbe für den Fensterinhalt @@ -1005,6 +1007,7 @@ menu.hint_numeric_adjust Adjust channel list mode on numeric zap menu.hint_osd Farben, Schriftarten, Anzeigegröße, Ansichtsoptionen der Menüs und mehr menu.hint_osd_language Wählen Sie ihre Menü-Sprache menu.hint_osd_preset Wählen Sie zwischen Röhren-TV (CRT) oder Flachbildschirm (LCD) +menu.hint_osd_timing Einblendzeit, die das OSD auf dem TV angezeigt wird menu.hint_parentallock_changepin Geben Sie den 4-stelligen PIN-Code ein, der dann ggf. abgefragt wird menu.hint_parentallock_lockage Legen Sie fest, bei welcher Altersklasse die Abfrage der PIN erfolgt menu.hint_parentallock_menu Menüs mit PIN Code sichern @@ -1032,7 +1035,7 @@ menu.hint_record_data Daten-Spuren (Teletext, Untertitel) für die Aufnahme menu.hint_record_data_dvbsub Untertitel-Spur zu Aufnahme hinzufügen menu.hint_record_data_vtxt Teletext-Spur zu Aufnahme hinzufügen menu.hint_record_dir Wählen Sie das Aufnahmeverzeichnis -menu.hint_record_end Wählen Sie zwischen max. Aufnahmezeit oder einem Aufnahmeende anhand der EPG-Daten +menu.hint_record_end Wählen Sie zwischen maximaler Aufnahmezeit oder einem Aufnahmeende anhand der EPG-Daten menu.hint_record_slow_warn Zeige Warnung, wenn der Aufnahmepuffer zu überlaufen droht menu.hint_record_tdir Wählen Sie ein Verzeichnis für Ihre Timeshift-Aufnahmen im temporären Timeshift-Modus menu.hint_record_time Geben Sie eine maximale Aufnahmezeit in Stunden ein, wenn Sie die Aufnahme nicht vorzeitig stoppen @@ -1270,7 +1273,7 @@ miscsettings.shutdown_real_rcdelay Verzögertes Ausschalten miscsettings.sleeptimer Ausschalten nach Inaktivität miscsettings.sleeptimer_min Sleeptimer Vorgabe miscsettings.volume Lautstärke -miscsettings.zapto_pre_time Umschaltstart-Vorlaufzeit (Minuten) +miscsettings.zapto_pre_time Umschaltstart-Vorlaufzeit motorcontrol.calc_positions Positionen (Neu)-Berechne(n)) motorcontrol.disable_limit Deaktiviere (soft) Limit motorcontrol.drive_mode Fahr-Modus @@ -1693,8 +1696,6 @@ recordingmenu.vcr Videorekorder recordingmenu.vtxt_pid Teletext aufnehmen recordingmenu.zap_on_announce Umschalten bei Ankündigung recordtimer.announce Die Aufnahme beginnt in wenigen Minuten. -repeatblocker.hint_1 Mindestzeit (in ms) zwischen 2 Tastendrücken -repeatblocker.hint_2 0 schaltet den Blocker aus (Rot ist " ") reset_all Werkseinstellungen und Reboot reset_channels Lösche Kanäle reset_confirm Sind Sie sich sicher? diff --git a/data/locale/english.locale b/data/locale/english.locale index 81a9fdad7..e4839f722 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -167,7 +167,7 @@ audioplayer.receiving_list Receiving list, please wait audioplayer.repeat_on enable repeat mode audioplayer.rewind rewind audioplayer.save_playlist save play list -audioplayer.screensaver_timeout screensaver timeout (min, 0=off) +audioplayer.screensaver_timeout screensaver timeout audioplayer.select_title_by_name search title by name (SMS) audioplayer.show_playlist Show Playlist audioplayer.shuffle shuffle @@ -266,6 +266,7 @@ colorchooser.blue blue colorchooser.green green colorchooser.red red colormenu.background Background +colormenu.clock_textcolor Digit color colormenu.contrast_fonts Contrast fonts colormenu.fade Fade GUI colormenu.font Select GUI font @@ -399,7 +400,7 @@ extra.lodirection LoDirection extra.longitude Longitude extra.menu_left_exit "Left" = menu back extra.north North -extra.record_time Max. recording time in hours +extra.record_time Maximal recording time extra.rotor_swap Swap rotor east/west extra.rounded_corners Shape of corners extra.rounded_corners_off angular @@ -437,7 +438,7 @@ extra.zap_cycle Zap cycle extra.zapit_fe_timeout Tune timeout extra.zapit_hvoltage 18V for rotor moving extra.zapit_make_bouquet Make Remaining Channels list -extra.zapit_motor_speed Motor moving speed (10 = 1deg/sec) +extra.zapit_motor_speed Motor moving speed extra.zapit_scanpids Scan/Use pids extra.zapit_sdt_changed Channels changed, reload settings. fan_speed CPU Fan speed @@ -817,6 +818,7 @@ menu.hint_clock_background Show clock with theme's background color menu.hint_clock_mode Switch clock on or off menu.hint_clock_seconds Show time format with seconds menu.hint_clock_size Set the size of the info clock +menu.hint_clock_textcolor Configure digit colors menu.hint_colors Configure GUI colors menu.hint_content_back Change GUI window background color menu.hint_content_textcolor Change GUI window text color @@ -1005,6 +1007,7 @@ menu.hint_numeric_adjust Adjust channel list mode on numeric zap menu.hint_osd Colors, fonts, screen size\nGUI look and feel options menu.hint_osd_language Select OSD language menu.hint_osd_preset Pre-configured screen margins for CRT and LCD TV +menu.hint_osd_timing After this time the OSD will be faded out menu.hint_parentallock_changepin Change PIN code menu.hint_parentallock_lockage Select age allowed to watch menu.hint_parentallock_menu Lock menus with pin code @@ -1032,7 +1035,7 @@ menu.hint_record_data Record (VideoText, subtitles) data streams menu.hint_record_data_dvbsub subtitle stream menu.hint_record_data_vtxt VideoText stream menu.hint_record_dir Select directory to store recordings -menu.hint_record_end Stop direct record after max. time\nor after current event end time +menu.hint_record_end Stop direct record after maximal time or after current event end time menu.hint_record_slow_warn Show warning, when record buffer is close to overflow menu.hint_record_tdir Select directory to save timeshift recordings\nin temporary timeshift mode menu.hint_record_time Record time before stop when\nusing direct record with record button @@ -1270,7 +1273,7 @@ miscsettings.shutdown_real_rcdelay Delayed shutdown miscsettings.sleeptimer Inactivity shutdown timer miscsettings.sleeptimer_min Sleeptimer default miscsettings.volume Volume -miscsettings.zapto_pre_time Zapto Start Time Correction (minutes) +miscsettings.zapto_pre_time Zapto Start Time Correction motorcontrol.calc_positions (Re)-Calculate Positions motorcontrol.disable_limit Disable (soft) Limits motorcontrol.drive_mode Drive Mode @@ -1693,8 +1696,6 @@ recordingmenu.vcr vcr recordingmenu.vtxt_pid record teletext recordingmenu.zap_on_announce zap on recording announce recordtimer.announce Recording starts in a few minutes -repeatblocker.hint_1 Shortest time (in ms) to recognize 2 keystrokes -repeatblocker.hint_2 Enter 0 to switch of the blocker (red is space) reset_all Factory reset and reboot reset_channels Delete all channels reset_confirm Are you sure ? diff --git a/lib/libcoolstream2/ca_cs.h b/lib/libcoolstream2/ca_cs.h index ab14441aa..ffb92dfac 100644 --- a/lib/libcoolstream2/ca_cs.h +++ b/lib/libcoolstream2/ca_cs.h @@ -26,6 +26,14 @@ enum CA_SLOT_TYPE { CA_SLOT_TYPE_ALL }; +enum CA_DVBCI_TS_INPUT { + CA_DVBCI_TS_INPUT_0 = 0, + CA_DVBCI_TS_INPUT_1, + CA_DVBCI_TS_INPUT_2, + CA_DVBCI_TS_INPUT_3, + CA_DVBCI_TS_INPUT_DISABLED +}; + enum CA_MESSAGE_FLAGS { CA_MESSAGE_EMPTY = (1 << 0), CA_MESSAGE_HAS_PARAM1_DATA = (1 << 1), /// Free after use! @@ -130,6 +138,8 @@ public: /// Sets which modules to initialize. It is only /// possible to change this once! void SetInitMask(enum CA_INIT_MASK InitMask); + /// Sets the tuner input (only valid for CI) + void SetTS(enum CA_DVBCI_TS_INPUT TsInput); /// Sets the frequency (in Hz) of the TS stream input (only valid for CI) void SetTSClock(u32 Speed); /// Start the CA module diff --git a/lib/libnet/Makefile.am b/lib/libnet/Makefile.am index ac17412c3..5818bc9b4 100644 --- a/lib/libnet/Makefile.am +++ b/lib/libnet/Makefile.am @@ -2,5 +2,5 @@ noinst_LIBRARIES = libtuxbox-net.a AM_CXXFLAGS = -fno-rtti -fno-exceptions -libtuxbox_net_a_SOURCES = libnet.c network_interfaces.cpp +libtuxbox_net_a_SOURCES = libnet.cpp network_interfaces.cpp diff --git a/lib/libnet/libnet.c b/lib/libnet/libnet.cpp similarity index 76% rename from lib/libnet/libnet.c rename to lib/libnet/libnet.cpp index c371cd8bd..fff4b2d8d 100644 --- a/lib/libnet/libnet.c +++ b/lib/libnet/libnet.cpp @@ -9,7 +9,9 @@ #include #include -#if 0 +#include "libnet.h" + +#if 0 //never used static void scanip( char *str, unsigned char *to ) { @@ -83,16 +85,16 @@ abbruch: return rc; } #endif -void netGetIP( char *dev, char *ip, char *mask, char *brdcast ) +void netGetIP(std::string &dev, std::string &ip, std::string &mask, std::string &brdcast) { int fd; struct ifreq req; struct sockaddr_in *saddr; unsigned char *addr; - *ip=0; - *mask=0; - *brdcast=0; + ip = ""; + mask = ""; + brdcast = ""; fd=socket(AF_INET,SOCK_DGRAM,0); if ( !fd ) @@ -100,23 +102,28 @@ void netGetIP( char *dev, char *ip, char *mask, char *brdcast ) memset(&req,0,sizeof(req)); - strcpy(req.ifr_name,dev); + strncpy(req.ifr_name, dev.c_str(), sizeof(req.ifr_name)); saddr = (struct sockaddr_in *) &req.ifr_addr; addr= (unsigned char*) &saddr->sin_addr.s_addr; + char tmp[80]; + if( ioctl(fd,SIOCGIFADDR,&req) == 0 ) - sprintf(ip,"%d.%d.%d.%d",addr[0],addr[1],addr[2],addr[3]); + snprintf(tmp, sizeof(tmp),"%d.%d.%d.%d",addr[0],addr[1],addr[2],addr[3]); + ip = std::string(tmp); if( ioctl(fd,SIOCGIFNETMASK,&req) == 0 ) - sprintf(mask,"%d.%d.%d.%d",addr[0],addr[1],addr[2],addr[3]); + snprintf(tmp, sizeof(tmp),"%d.%d.%d.%d",addr[0],addr[1],addr[2],addr[3]); + mask = std::string(tmp); if( ioctl(fd,SIOCGIFBRDADDR,&req) == 0 ) - sprintf(brdcast,"%d.%d.%d.%d",addr[0],addr[1],addr[2],addr[3]); + snprintf(tmp, sizeof(tmp),"%d.%d.%d.%d",addr[0],addr[1],addr[2],addr[3]); + brdcast = std::string(tmp); close(fd); return; } -#if 0 +#if 0 //never used void netSetDefaultRoute( char *gw ) { @@ -153,7 +160,7 @@ void netSetDefaultRoute( char *gw ) return; } #endif -void netGetDefaultRoute( char *ip ) +void netGetDefaultRoute( std::string &ip ) { FILE *fp; char interface[9]; @@ -162,7 +169,7 @@ void netGetDefaultRoute( char *ip ) uint8_t gateway[4]; char zeile[256]; - *ip = 0 ; + ip = ""; fp = fopen("/proc/net/route","r"); if (fp == NULL) return; @@ -175,15 +182,15 @@ void netGetDefaultRoute( char *ip ) continue; /* big/little endian kernels have reversed entries, so this is correct */ memcpy(gateway, &gw, 4); - sprintf(ip, "%d.%d.%d.%d", gateway[0], gateway[1], gateway[2], gateway[3]); + char tmp[80]; + snprintf(tmp, sizeof(tmp), "%d.%d.%d.%d", gateway[0], gateway[1], gateway[2], gateway[3]); + ip = std::string(tmp); break; } fclose(fp); } -static char hostbuf[256]; -static char hostis=0; -#if 0 +#if 0 static char dombuf[256]; static char domis=0; //never used @@ -202,29 +209,27 @@ void netSetDomainname( char *dom ) setdomainname(dombuf,strlen(dombuf)+1); } #endif -char *netGetHostname( void ) +void netGetHostname( std::string &host ) { - if (!hostis) - gethostname( hostbuf, 256 ); - hostis=1; - return hostbuf; + host = ""; + char hostbuf[256]; + if (!gethostname(hostbuf, sizeof(hostbuf))) + host = std::string(hostbuf); } -void netSetHostname( char *host ) +void netSetHostname( std::string &host ) { FILE * fp; - strcpy(hostbuf,host); - hostis=1; - sethostname(hostbuf,strlen(hostbuf)+1); + sethostname(host.c_str(), host.length()); fp = fopen("/etc/hostname", "w"); if(fp != NULL) { - fprintf(fp, "%s\n", hostbuf); + fprintf(fp, "%s\n", host.c_str()); fclose(fp); } } -void netSetNameserver(const char * const ip) +void netSetNameserver(std::string &ip) { FILE *fp; @@ -239,19 +244,19 @@ void netSetNameserver(const char * const ip) fprintf(fp,"search %s\n",dom); #endif fprintf(fp, "# generated by neutrino\n"); - if ((ip != NULL) && (strlen(ip) > 0)) - fprintf(fp,"nameserver %s\n",ip); + if (!ip.empty()) + fprintf(fp,"nameserver %s\n",ip.c_str()); fclose(fp); } -void netGetNameserver( char *ip ) +void netGetNameserver( std::string &ip ) { FILE *fp; char zeile[256]; char *indexLocal; unsigned zaehler; - *ip = 0; + ip = ""; fp = fopen("/etc/resolv.conf","r"); if (!fp) return; @@ -260,32 +265,33 @@ void netGetNameserver( char *ip ) { if (!strncasecmp(zeile,"nameserver",10)) { + char tmp[20]; indexLocal = zeile + 10; while ( (*indexLocal == ' ') || (*indexLocal == '\t') ) indexLocal++; zaehler = 0; while ( (zaehler < 15) && ( ((*indexLocal >= '0') && (*indexLocal <= '9')) || (*indexLocal == '.'))) - ip[zaehler++] = *(indexLocal++); - ip[zaehler] = 0; + tmp[zaehler++] = *(indexLocal++); + tmp[zaehler] = 0; + ip = std::string(tmp); break; } } fclose(fp); } -void netGetMacAddr(char * ifname, unsigned char * mac) +void netGetMacAddr(std::string &ifname, unsigned char *mac) { int fd; struct ifreq ifr; - memset(mac, 0, 6); fd = socket(AF_INET, SOCK_DGRAM, 0); if(fd < 0) return; ifr.ifr_addr.sa_family = AF_INET; - strncpy(ifr.ifr_name, ifname, IFNAMSIZ-1); + strncpy(ifr.ifr_name, ifname.c_str(), sizeof(ifr.ifr_name)); if(ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) return; diff --git a/lib/libnet/libnet.h b/lib/libnet/libnet.h index 2f1d7fe97..37b179442 100644 --- a/lib/libnet/libnet.h +++ b/lib/libnet/libnet.h @@ -1,28 +1,18 @@ #ifndef __libnet__ #define __libnet__ -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - - -extern int netSetIP( char *dev, char *ip, char *mask, char *brdcast ); -extern void netGetIP( char *dev, char *ip, char *mask, char *brdcast ); -extern void netSetDefaultRoute( char *gw ); -extern void netGetDefaultRoute( char *ip ); -extern char *netGetDomainname( void ); -extern void netSetDomainname( char *dom ); -extern char *netGetHostname( void ); -extern void netSetHostname( char *host ); -extern void netSetNameserver(const char *ip); -extern void netGetNameserver( char *ip ); -extern void netGetMacAddr(char * ifname, unsigned char * mac); - - -#ifdef __cplusplus -} -#endif +#include +int netSetIP(std::string &dev, std::string &ip, std::string &mask, std::string &brdcast ); +void netGetIP(std::string &dev, std::string &ip, std::string &mask, std::string &brdcast ); +void netSetDefaultRoute( std::string &gw ); +void netGetDefaultRoute( std::string &ip ); +void netGetDomainname( std::string &dom ); +void netSetDomainname( std::string &dom ); +void netGetHostname( std::string &host ); +void netSetHostname( std::string &host ); +void netSetNameserver(std::string &ip); +void netGetNameserver( std::string &ip ); +void netGetMacAddr(std::string & ifname, unsigned char *); #endif diff --git a/src/Makefile.am b/src/Makefile.am index ad69b8376..2bb2ad126 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -130,7 +130,7 @@ neutrino_LDADD += -lcoolstream-mt -lca-sc if ENABLE_TMSDK else if BOXMODEL_APOLLO -neutrino_LDADD += -llnxtmvssUsr -llnxUKAL -llnxplatUsr -llnxtmasUsr -llnxdvbciUsr -llnxpvrUsr -llnxcssUsr -llnxnotifyqUsr -ltmpvrDataManager -ltmpvrIndexStorage -llnxscsUsr +neutrino_LDADD += -lca-ci -llnxtmvssUsr -llnxUKAL -llnxplatUsr -llnxtmasUsr -llnxdvbciUsr -llnxpvrUsr -llnxcssUsr -llnxnotifyqUsr -ltmpvrDataManager-cst -ltmpvrIndexStorage -llnxscsUsr else neutrino_LDADD += -lnxp endif diff --git a/src/daemonc/remotecontrol.cpp b/src/daemonc/remotecontrol.cpp index 942529090..57364ee1e 100644 --- a/src/daemonc/remotecontrol.cpp +++ b/src/daemonc/remotecontrol.cpp @@ -458,7 +458,7 @@ void CRemoteControl::processAPIDnames() /* processAPIDnames called 2 times, TODO find better way to detect second call */ if(strlen( desc ) != 3) continue; - if(strlen(g_settings.pref_lang[i]) == 0) + if(g_settings.pref_lang[i].empty()) continue; std::string temp(g_settings.pref_lang[i]); diff --git a/src/driver/audiometadata.cpp b/src/driver/audiometadata.cpp index 043effd60..c94689be1 100644 --- a/src/driver/audiometadata.cpp +++ b/src/driver/audiometadata.cpp @@ -55,7 +55,10 @@ CAudioMetaData::CAudioMetaData( const CAudioMetaData& src ) : type( src.type ), type_info( src.type_info ), filesize( src.filesize ), bitrate( src.bitrate ), avg_bitrate( src.avg_bitrate ), samplerate( src.samplerate ), - layer( src.layer ), mode( src.mode ), total_time( src.total_time ), +#ifndef ENABLE_FFMPEGDEC + layer( src.layer ), mode( src.mode ), +#endif + total_time( src.total_time ), audio_start_pos( src.audio_start_pos ), vbr( src.vbr ), hasInfoOrXingTag( src.hasInfoOrXingTag ), artist( src.artist ), title( src.title ), album( src.album ), sc_station( src.sc_station ), @@ -78,8 +81,10 @@ void CAudioMetaData::operator=( const CAudioMetaData& src ) bitrate = src.bitrate; avg_bitrate = src.avg_bitrate; samplerate = src.samplerate; +#ifndef ENABLE_FFMPEGDEC layer = src.layer; mode = src.mode; +#endif total_time = src.total_time; audio_start_pos = src.audio_start_pos; vbr = src.vbr; diff --git a/src/driver/audiometadata.h b/src/driver/audiometadata.h index 5d93a4639..3f25fd79e 100644 --- a/src/driver/audiometadata.h +++ b/src/driver/audiometadata.h @@ -36,8 +36,15 @@ #ifndef __AUDIO_METADATA__ #define __AUDIO_METADATA__ +#ifdef HAVE_CONFIG_H +#include +#endif + #include + +#ifndef ENABLE_FFMPEGDEC #include +#endif class CAudioMetaData { @@ -69,8 +76,10 @@ public: unsigned int bitrate; /* overall bitrate, vbr file: current bitrate */ unsigned int avg_bitrate; /* average bitrate in case of vbr file */ unsigned int samplerate; +#ifndef ENABLE_FFMPEGDEC enum mad_layer layer; enum mad_mode mode; +#endif time_t total_time; long audio_start_pos; /* position of first audio frame */ bool vbr; diff --git a/src/driver/neutrinofonts.cpp b/src/driver/neutrinofonts.cpp index 1e42bd049..908c2ec1d 100644 --- a/src/driver/neutrinofonts.cpp +++ b/src/driver/neutrinofonts.cpp @@ -134,11 +134,11 @@ void CNeutrinoFonts::SetupNeutrinoFonts(bool initRenderClass/*=true*/) old_fontDescr.size_offset = fontDescr.size_offset; old_fontDescr.filename = fontDescr.filename; fontDescr.filename = ""; - printf("[neutrino] settings font file %s\n", g_settings.font_file); - if (access(g_settings.font_file, F_OK)) { + printf("[neutrino] settings font file %s\n", g_settings.font_file.c_str()); + if (access(g_settings.font_file.c_str(), F_OK)) { if (!access(FONTDIR"/neutrino.ttf", F_OK)) { fontDescr.filename = FONTDIR"/neutrino.ttf"; - strcpy(g_settings.font_file, fontDescr.filename.c_str()); + g_settings.font_file = fontDescr.filename; } else { fprintf( stderr,"[neutrino] font file [%s] not found\n neutrino exit\n",FONTDIR"/neutrino.ttf"); diff --git a/src/driver/record.cpp b/src/driver/record.cpp index ddd901639..c348a9a36 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -615,12 +615,12 @@ record_error_msg_t CRecordInstance::MakeFileName(CZapitChannel * channel) if(check_dir(Directory.c_str())) { /* check if Directory and network_nfs_recordingdir the same */ - if(strcmp(g_settings.network_nfs_recordingdir, Directory.c_str())) { + if(g_settings.network_nfs_recordingdir != Directory) { /* not the same, check network_nfs_recordingdir and return error if not ok */ - if(check_dir(g_settings.network_nfs_recordingdir)) + if(check_dir(g_settings.network_nfs_recordingdir.c_str())) return RECORD_INVALID_DIRECTORY; /* fallback to g_settings.network_nfs_recordingdir */ - Directory = std::string(g_settings.network_nfs_recordingdir); + Directory = g_settings.network_nfs_recordingdir; }else{ return RECORD_INVALID_DIRECTORY; } diff --git a/src/driver/record.h b/src/driver/record.h index 236333e99..366037b78 100644 --- a/src/driver/record.h +++ b/src/driver/record.h @@ -214,8 +214,8 @@ class CRecordManager : public CMenuTarget /*, public CChangeObserver*/ StreamSubtitlePids = stream_subtitle_pids; StreamPmtPid = stream_pmt_pid; }; - void SetDirectory(const char * const directory) { Directory = directory; }; - void SetTimeshiftDirectory(const char * const directory) { TimeshiftDirectory = directory; }; + void SetDirectory(std::string directory) { Directory = directory; }; + void SetTimeshiftDirectory(std::string directory) { TimeshiftDirectory = directory; }; bool RecordingStatus(const t_channel_id channel_id = 0); bool TimeshiftOnly(); bool Timeshift() { return (autoshift || shift_timer); }; diff --git a/src/driver/scanepg.cpp b/src/driver/scanepg.cpp index beecd5679..a2bd09bc6 100644 --- a/src/driver/scanepg.cpp +++ b/src/driver/scanepg.cpp @@ -136,7 +136,7 @@ void CEpgScan::Start(bool instandby) { if (!g_settings.epg_scan) return; - if (!standby && (CFEManager::getInstance()->getEnabledCount() <= 1)) + if (!instandby && (CFEManager::getInstance()->getEnabledCount() <= 1)) return; live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); diff --git a/src/driver/shutdown_count.cpp b/src/driver/shutdown_count.cpp index d3081f224..159319f73 100644 --- a/src/driver/shutdown_count.cpp +++ b/src/driver/shutdown_count.cpp @@ -76,8 +76,8 @@ void* SHTDCNT::TimeThread(void *) void SHTDCNT::init() { - shutdown_cnt = atoi(g_settings.shutdown_count) * 60; - sleep_cnt = atoi(g_settings.shutdown_min)*60; + shutdown_cnt = g_settings.shutdown_count * 60; + sleep_cnt = g_settings.shutdown_min * 60; thread_running = true; if (pthread_create (&thrTime, NULL, TimeThread, NULL) != 0 ) { @@ -90,7 +90,7 @@ void SHTDCNT::init() void SHTDCNT::shutdown_counter() { static bool sleeptimer_active = true; - if (atoi(g_settings.shutdown_count) > 0) + if (g_settings.shutdown_count > 0) { if ((CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_standby) && (!CNeutrinoApp::getInstance ()->recordingstatus)) { @@ -110,11 +110,11 @@ void SHTDCNT::shutdown_counter() else { // reset counter - shutdown_cnt = atoi(g_settings.shutdown_count) * 60; + shutdown_cnt = g_settings.shutdown_count * 60; } } - if(atoi(g_settings.shutdown_min) > 0) { + if(g_settings.shutdown_min > 0) { if(sleep_cnt > 0) { sleeptimer_active = true; sleep_cnt--; @@ -133,5 +133,5 @@ void SHTDCNT::shutdown_counter() void SHTDCNT::resetSleepTimer() { - sleep_cnt = atoi(g_settings.shutdown_min)*60; + sleep_cnt = g_settings.shutdown_min * 60; } diff --git a/src/eitd/edvbstring.cpp b/src/eitd/edvbstring.cpp index fa0fa1459..003e067bf 100644 --- a/src/eitd/edvbstring.cpp +++ b/src/eitd/edvbstring.cpp @@ -2301,30 +2301,40 @@ int isUTF8(const std::string &string) { unsigned int len=string.size(); - for (unsigned int i=0; i < len; ++i) + for (unsigned int i=0; i < len;) { - if (!(string[i]&0x80)) // normal ASCII + int trailing = 0; + if (string[i] >> 7 == 0) // 0xxxxxxx + { + i++; continue; - if ((string[i] & 0xE0) == 0xC0) // one char following. + } + if (string[i] >> 5 == 6) // 110xxxxx 10xxxxxx { - // first, length check: - if (i+1 >= len) - return 0; // certainly NOT utf-8 - i++; - if ((string[i]&0xC0) != 0x80) - return 0; // no, not UTF-8. - } else if ((string[i] & 0xF0) == 0xE0) + if (++i >= len) + return 0; + trailing = 1; + } + else if (string[i] >> 4 == 14) // 1110xxxx 10xxxxxx 10xxxxxx { - if ((i+1) >= len) + if (++i >= len) return 0; + trailing = 2; + } + else if ((string[i] >> 3) == 30) // 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + { + if (++i >= len) + return 0; + trailing = 3; + } else + return 0; + + while (trailing) { + if (i >= len || string[i] >> 6 != 2) + return 0; + trailing--; i++; - if ((string[i]&0xC0) != 0x80) - return 0; - i++; - if ((string[i]&0xC0) != 0x80) - return 0; } } return 1; // can be UTF8 (or pure ASCII, at least no non-UTF-8 8bit characters) } - diff --git a/src/gui/audio_setup.cpp b/src/gui/audio_setup.cpp index 10f1dbf59..466933e73 100644 --- a/src/gui/audio_setup.cpp +++ b/src/gui/audio_setup.cpp @@ -192,11 +192,6 @@ int CAudioSetup::showAudioSetup() as_oj_srsonoff->setHint("", LOCALE_MENU_HINT_AUDIO_SRS); #endif -#if 0 - CStringInput * audio_PCMOffset = new CStringInput(LOCALE_AUDIOMENU_PCMOFFSET, g_settings.audio_PCMOffset, 2, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789 ", audioSetupNotifier); - CMenuForwarder *mf = new CMenuForwarder(LOCALE_AUDIOMENU_PCMOFFSET, true, g_settings.audio_PCMOffset, audio_PCMOffset ); -#endif - //paint items audioSettings->addIntroItems(LOCALE_MAINSETTINGS_AUDIO); //--------------------------------------------------------- diff --git a/src/gui/audioplayer.cpp b/src/gui/audioplayer.cpp index 184623686..bfebe7190 100644 --- a/src/gui/audioplayer.cpp +++ b/src/gui/audioplayer.cpp @@ -179,8 +179,8 @@ void CAudioPlayerGui::Init(void) m_select_title_by_name = g_settings.audioplayer_select_title_by_name==1; - if (strlen(g_settings.network_nfs_audioplayerdir)!=0) - m_Path = g_settings.network_nfs_audioplayerdir; + if (!g_settings.network_nfs_audioplayerdir.empty()) + m_Path = g_settings.network_nfs_audioplayerdir.c_str(); else m_Path = "/"; @@ -376,7 +376,7 @@ int CAudioPlayerGui::show() if ( msg == CRCInput::RC_timeout || msg == NeutrinoMessages::EVT_TIMER) { int timeout = time(NULL) - m_idletime; - int screensaver_timeout = atoi(g_settings.audioplayer_screensaver); + int screensaver_timeout = g_settings.audioplayer_screensaver; if (screensaver_timeout !=0 && timeout > screensaver_timeout*60 && !m_screensaver) screensaver(true); @@ -1219,7 +1219,7 @@ bool CAudioPlayerGui::openFilebrowser(void) { bool result = false; CFileBrowser filebrowser((g_settings.filebrowser_denydirectoryleave) - ? g_settings.network_nfs_audioplayerdir : ""); + ? g_settings.network_nfs_audioplayerdir.c_str() : ""); filebrowser.Multi_Select = true; filebrowser.Dirs_Selectable = true; @@ -1390,8 +1390,8 @@ bool CAudioPlayerGui::openFilebrowser(void) printTimevalDiff(start,end); #endif //store last dir - if( (sizeof(g_settings.network_nfs_audioplayerdir)) > m_Path.size() && (strcmp(g_settings.network_nfs_audioplayerdir,m_Path.c_str()) != 0)) - strcpy(g_settings.network_nfs_audioplayerdir,m_Path.c_str()); + if( (g_settings.network_nfs_audioplayerdir.size()) > m_Path.size() && g_settings.network_nfs_audioplayerdir != m_Path.c_str() ) + g_settings.network_nfs_audioplayerdir = m_Path; result = true; } @@ -2585,8 +2585,8 @@ void CAudioPlayerGui::savePlaylist() dirFilter.addFilter("m3u"); browser.Filter = &dirFilter; // select preferred directory if exists - if (strlen(g_settings.network_nfs_audioplayerdir) != 0) - path = g_settings.network_nfs_audioplayerdir; + if (!g_settings.network_nfs_audioplayerdir.empty()) + path = g_settings.network_nfs_audioplayerdir.c_str(); else path = "/"; diff --git a/src/gui/audioplayer_setup.cpp b/src/gui/audioplayer_setup.cpp index 1d952128a..74dbcc725 100644 --- a/src/gui/audioplayer_setup.cpp +++ b/src/gui/audioplayer_setup.cpp @@ -75,8 +75,8 @@ int CAudioPlayerSetup::exec(CMenuTarget* parent, const std::string &actionKey) { CFileBrowser b; b.Dir_Mode=true; - if (b.exec(g_settings.network_nfs_audioplayerdir)) - strncpy(g_settings.network_nfs_audioplayerdir, b.getSelectedFile()->Name.c_str(), sizeof(g_settings.network_nfs_audioplayerdir)-1); + if (b.exec(g_settings.network_nfs_audioplayerdir.c_str())) + g_settings.network_nfs_audioplayerdir = b.getSelectedFile()->Name; return res; } @@ -125,10 +125,10 @@ int CAudioPlayerSetup::showAudioPlayerSetup() mc->setHint("", LOCALE_MENU_HINT_AUDIOPLAYER_PLAYLIST); audioplayerSetup->addItem(mc); - CStringInput audio_screensaver(LOCALE_AUDIOPLAYER_SCREENSAVER_TIMEOUT, g_settings.audioplayer_screensaver, 2, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789 "); - mf = new CMenuForwarder(LOCALE_AUDIOPLAYER_SCREENSAVER_TIMEOUT, true, g_settings.audioplayer_screensaver, &audio_screensaver); - mf->setHint("", LOCALE_MENU_HINT_AUDIOPLAYER_SCREENSAVER); - audioplayerSetup->addItem(mf); + CMenuOptionNumberChooser *cc = new CMenuOptionNumberChooser(LOCALE_AUDIOPLAYER_SCREENSAVER_TIMEOUT, &g_settings.audioplayer_screensaver, true, 0, 999, NULL, 0, 0, LOCALE_OPTIONS_OFF); + cc->setNumberFormat(std::string("%d ") + g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE)); + cc->setHint("", LOCALE_MENU_HINT_AUDIOPLAYER_SCREENSAVER); + audioplayerSetup->addItem(cc); mc = new CMenuOptionChooser(LOCALE_AUDIOPLAYER_HIGHPRIO, &g_settings.audioplayer_highprio, MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true ); mc->setHint("", LOCALE_MENU_HINT_AUDIOPLAYER_HIGHPRIO); diff --git a/src/gui/bookmarkmanager.cpp b/src/gui/bookmarkmanager.cpp index 045c62222..1a9c6adc8 100644 --- a/src/gui/bookmarkmanager.cpp +++ b/src/gui/bookmarkmanager.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -118,17 +119,10 @@ void CBookmarkManager::renameBookmark (unsigned int index) { } } #endif -#define BOOKMARKSTRINGLENGTH (10 + 1) -#define BOOKMARKSTRINGMODIFICATIONPOINT 8 -const char * const BOOKMARKSTRING = "bookmark0."; - //------------------------------------------------------------------------ void CBookmarkManager::readBookmarkFile() { if (bookmarkfile.loadConfig(BOOKMARKFILE)) { - char bookmarkstring[BOOKMARKSTRINGLENGTH]; - strcpy(bookmarkstring, BOOKMARKSTRING); - bookmarksmodified = false; bookmarks.clear(); @@ -139,19 +133,11 @@ void CBookmarkManager::readBookmarkFile() { while (bookmarkcount-- > 0) { - std::string tmp = bookmarkstring; - tmp += "name"; - std::string bookmarkname = bookmarkfile.getString(tmp, ""); - tmp = bookmarkstring; - tmp += "url"; - std::string bookmarkurl = bookmarkfile.getString(tmp, ""); - tmp = bookmarkstring; - tmp += "time"; - std::string bookmarktime = bookmarkfile.getString(tmp, ""); - + std::string bookmarkstring = "bookmark" + to_string(bookmarkcount) + "."; + std::string bookmarkname = bookmarkfile.getString(bookmarkstring + "name", ""); + std::string bookmarkurl = bookmarkfile.getString(bookmarkstring + "url", ""); + std::string bookmarktime = bookmarkfile.getString(bookmarkstring + "time", ""); bookmarks.push_back(CBookmark(bookmarkname, bookmarkurl, bookmarktime)); - - bookmarkstring[BOOKMARKSTRINGMODIFICATIONPOINT]++; } } else @@ -160,24 +146,16 @@ void CBookmarkManager::readBookmarkFile() { //------------------------------------------------------------------------ void CBookmarkManager::writeBookmarkFile() { - char bookmarkstring[BOOKMARKSTRINGLENGTH]; - strcpy(bookmarkstring, BOOKMARKSTRING); printf("CBookmarkManager: Writing bookmark file\n"); - for (std::vector::const_iterator it = bookmarks.begin(); it != bookmarks.end(); ++it) + unsigned int bookmarkcount = 0; + for (std::vector::const_iterator it = bookmarks.begin(); it != bookmarks.end(); ++it, bookmarkcount++) { - std::string tmp = bookmarkstring; - tmp += "name"; - bookmarkfile.setString(tmp, it->getName()); - tmp = bookmarkstring; - tmp += "url"; - bookmarkfile.setString(tmp, it->getUrl()); - tmp = bookmarkstring; - tmp += "time"; - bookmarkfile.setString(tmp, it->getTime()); - - bookmarkstring[BOOKMARKSTRINGMODIFICATIONPOINT]++; + std::string bookmarkstring = "bookmark" + to_string(bookmarkcount) + "."; + bookmarkfile.setString(bookmarkstring + "name", it->getName()); + bookmarkfile.setString(bookmarkstring + "url", it->getUrl()); + bookmarkfile.setString(bookmarkstring + "time", it->getTime()); } bookmarkfile.setInt32("bookmarkcount", bookmarks.size()); bookmarkfile.saveConfig(BOOKMARKFILE); diff --git a/src/gui/color.h b/src/gui/color.h index 8e6a2e75c..f25513b9b 100644 --- a/src/gui/color.h +++ b/src/gui/color.h @@ -110,6 +110,7 @@ #define COL_MENUCONTENTSELECTED_TEXT_PLUS_1 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 12)]) #define COL_MENUCONTENTSELECTED_TEXT_PLUS_2 (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 13)]) #define COL_MENUCONTENTINACTIVE_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 14)]) +#define COL_INFOCLOCK_TEXT (CFrameBuffer::getInstance()->realcolor[(COL_NEUTRINO_TEXT + 15)]) #endif diff --git a/src/gui/components/Makefile.am b/src/gui/components/Makefile.am index 5a6ac6cf3..bf58bbc7b 100644 --- a/src/gui/components/Makefile.am +++ b/src/gui/components/Makefile.am @@ -20,12 +20,14 @@ libneutrino_gui_components_a_SOURCES = \ cc_detailsline.cpp \ cc_frm_button.cpp \ cc_frm.cpp \ + cc_frm_chain.cpp \ cc_frm_clock.cpp \ cc_frm_footer.cpp \ cc_frm_header.cpp \ cc_frm_ext_text.cpp \ cc_frm_icons.cpp \ cc_frm_signalbars.cpp \ + cc_frm_slider.cpp \ cc_frm_window.cpp \ cc_item.cpp \ cc_item_infobox.cpp \ diff --git a/src/gui/components/cc.h b/src/gui/components/cc.h index 7842a0c10..54e612954 100644 --- a/src/gui/components/cc.h +++ b/src/gui/components/cc.h @@ -44,8 +44,10 @@ Basic attributes and member functions for component sub classes #include "cc_frm.h" #include "cc_frm_button.h" +#include "cc_frm_chain.h" #include "cc_frm_clock.h" #include "cc_frm_signalbars.h" +#include "cc_frm_slider.h" diff --git a/src/gui/components/cc_base.cpp b/src/gui/components/cc_base.cpp index f2bb38dba..4684ceb28 100644 --- a/src/gui/components/cc_base.cpp +++ b/src/gui/components/cc_base.cpp @@ -177,6 +177,9 @@ void CComponents::paintFbItems(bool do_save_bg) //screen area save inline fb_pixel_t* CComponents::getScreen(int ax, int ay, int dx, int dy) { + if (dx * dy == 0) + return NULL; + fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy]; frameBuffer->waitForIdle("CComponents::getScreen()"); frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf); @@ -187,14 +190,13 @@ inline fb_pixel_t* CComponents::getScreen(int ax, int ay, int dx, int dy) inline void CComponents::hide() { for(size_t i =0; i< v_fbdata.size() ;i++) { - if (v_fbdata[i].pixbuf != NULL){ + if (v_fbdata[i].pixbuf){ frameBuffer->waitForIdle("CComponents::hide()"); frameBuffer->RestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf); - delete[] v_fbdata[i].pixbuf; - v_fbdata[i].pixbuf = NULL; } } - v_fbdata.clear(); + + clear(); is_painted = false; } @@ -212,7 +214,7 @@ void CComponents::kill() inline void CComponents::clear() { for(size_t i =0; i< v_fbdata.size() ;i++) - if (v_fbdata[i].pixbuf != NULL) + if (v_fbdata[i].pixbuf) delete[] v_fbdata[i].pixbuf; v_fbdata.clear(); } diff --git a/src/gui/components/cc_detailsline.cpp b/src/gui/components/cc_detailsline.cpp index 8b319ce21..8eab8b047 100644 --- a/src/gui/components/cc_detailsline.cpp +++ b/src/gui/components/cc_detailsline.cpp @@ -35,26 +35,17 @@ using namespace std; //sub class CComponentsDetailLine from CComponents -CComponentsDetailLine::CComponentsDetailLine() +CComponentsDetailLine::CComponentsDetailLine( const int& x_pos, const int& y_pos_top, + const int& y_pos_down, const int& h_mark_top_, const int& h_mark_down_, + fb_pixel_t color_line, fb_pixel_t color_shadow) { - initVarDline(); - - //CComponents - x = 0; - y = 0; - col_shadow = COL_MENUCONTENTDARK_PLUS_0; - col_body = COL_MENUCONTENT_PLUS_6; - - //CComponentsDetailLine - y_down = 0; - h_mark_top = CC_HEIGHT_MIN; - h_mark_down = CC_HEIGHT_MIN; + initVarDline(x_pos, y_pos_top, y_pos_down, h_mark_top_, h_mark_down_, color_line, color_shadow); } -CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_top, const int y_pos_down, const int h_mark_top_, const int h_mark_down_, fb_pixel_t color_line, fb_pixel_t color_shadow) +void CComponentsDetailLine::initVarDline( const int& x_pos, const int& y_pos_top, + const int& y_pos_down, const int& h_mark_top_, const int& h_mark_down_, + fb_pixel_t color_line, fb_pixel_t color_shadow) { - initVarDline(); - //CComponents x = x_pos; y = y_pos_top; @@ -65,10 +56,7 @@ CComponentsDetailLine::CComponentsDetailLine(const int x_pos, const int y_pos_to y_down = y_pos_down; h_mark_top = h_mark_top_; h_mark_down = h_mark_down_; -} -void CComponentsDetailLine::initVarDline() -{ shadow_w = 1; //CComponentsDetailLine diff --git a/src/gui/components/cc_detailsline.h b/src/gui/components/cc_detailsline.h index 5276cf75e..f9c314afd 100644 --- a/src/gui/components/cc_detailsline.h +++ b/src/gui/components/cc_detailsline.h @@ -50,12 +50,13 @@ class CComponentsDetailLine : public CComponents int h_mark_down; ///initialize all internal attributes - void initVarDline(); + void initVarDline( const int& x_pos, const int& y_pos_top, const int& y_pos_down, + const int& h_mark_top_, const int& h_mark_down_, + fb_pixel_t color_line, fb_pixel_t color_shadow); public: - CComponentsDetailLine(); - CComponentsDetailLine( const int x_pos,const int y_pos_top, const int y_pos_down, - const int h_mark_up = CC_HEIGHT_MIN , const int h_mark_down = CC_HEIGHT_MIN, + CComponentsDetailLine( const int& x_pos = 1,const int& y_pos_top = 1, const int& y_pos_down = 1, + const int& h_mark_top_ = CC_HEIGHT_MIN , const int& h_mark_down_ = CC_HEIGHT_MIN, fb_pixel_t color_line = COL_MENUCONTENT_PLUS_6, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); ~CComponentsDetailLine(); diff --git a/src/gui/components/cc_frm.cpp b/src/gui/components/cc_frm.cpp index ce7418d78..bfa2839ae 100644 --- a/src/gui/components/cc_frm.cpp +++ b/src/gui/components/cc_frm.cpp @@ -151,6 +151,12 @@ void CComponentsForm::addCCItem(CComponentsItem* cc_Item) #endif } +void CComponentsForm::addCCItem(const std::vector &cc_Items) +{ + for (size_t i= 0; i< cc_Items.size(); i++) + addCCItem(cc_Items[i]); +} + int CComponentsForm::getCCItemId(CComponentsItem* cc_Item) { if (cc_Item){ @@ -297,6 +303,15 @@ void CComponentsForm::paintCCItems() int xpos = cc_item->getXPos(); int ypos = cc_item->getYPos(); + //check item for corrupt position, skip current item if found problems + //TODO: need a solution with possibility for scrolling + if (ypos > height || xpos > width){ + printf("[CComponentsForm] %s: [form: %d] [item-index %d] [type=%d] WARNING: item position is out of form size:\ndefinied x=%d, defined width=%d \ndefinied y=%d, defined height=%d \n", + __func__, cc_item_index, cc_item->getIndex(), cc_item->getItemType(), xpos, width, ypos, height); + if (this->cc_item_type != CC_ITEMTYPE_FRM_CHAIN) + continue; + } + //set required x-position to item: //append vertical if (xpos == CC_APPEND){ diff --git a/src/gui/components/cc_frm.h b/src/gui/components/cc_frm.h index 6b2bd31cc..183ca728f 100644 --- a/src/gui/components/cc_frm.h +++ b/src/gui/components/cc_frm.h @@ -57,6 +57,7 @@ class CComponentsForm : public CComponentsItem void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); void hide(bool no_restore = false); virtual void addCCItem(CComponentsItem* cc_Item); + virtual void addCCItem(const std::vector &cc_items); virtual void insertCCItem(const uint& cc_item_id, CComponentsItem* cc_Item); virtual void removeCCItem(const uint& cc_item_id); virtual void removeCCItem(CComponentsItem* cc_Item); diff --git a/src/gui/components/cc_frm_button.cpp b/src/gui/components/cc_frm_button.cpp index 639cfe683..37ea6c3d7 100644 --- a/src/gui/components/cc_frm_button.cpp +++ b/src/gui/components/cc_frm_button.cpp @@ -136,14 +136,13 @@ void CComponentsButton::initCaption() //if we have an icon, we must calculate positions for booth items together //also the icon width and left position = 0 int face_w = 0; - int face_x = 0; //calculate width and left position of icon, if available, picture position is default centered if (cc_btn_icon_obj){ //if found a picture object, then get width from it... face_w = cc_btn_icon_obj->getWidth(); //...and set position as centered - face_x = width/2 - face_w/2; + int face_x = width/2 - face_w/2; cc_btn_icon_obj->setXPos(face_x); } diff --git a/src/gui/components/cc_frm_chain.cpp b/src/gui/components/cc_frm_chain.cpp new file mode 100644 index 000000000..6603b18bf --- /dev/null +++ b/src/gui/components/cc_frm_chain.cpp @@ -0,0 +1,126 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2013, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include +#include "cc_frm_chain.h" + +using namespace std; + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsFrmChain +CComponentsFrmChain::CComponentsFrmChain( const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::vector *v_items, + bool horizontal, + bool dynamic_width, + bool dynamic_height, + bool has_shadow, + fb_pixel_t& color_frame, + fb_pixel_t& color_body, + fb_pixel_t& color_shadow) +{ + initVarChain(x_pos, y_pos, w, h, v_items, horizontal, dynamic_width, dynamic_height, has_shadow, color_frame, color_body, color_shadow); +} + + +void CComponentsFrmChain::initVarChain( const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::vector *v_items, + bool horizontal, + bool dynamic_width, + bool dynamic_height, + bool has_shadow, + fb_pixel_t& color_frame, + fb_pixel_t& color_body, + fb_pixel_t& color_shadow) +{ + cc_item_type = CC_ITEMTYPE_FRM_CHAIN; + corner_rad = 0; + + x = x_pos; + y = y_pos; + width = w; + height = h; + + shadow = has_shadow; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + + chn_horizontal = horizontal; + chn_dyn_height = dynamic_height; + chn_dyn_width = dynamic_width; + + if (v_items){ + addCCItem(*v_items); + initCChainItems(); + } +} + +void CComponentsFrmChain::initCChainItems() +{ + if (!v_cc_items.empty()){ + if (chn_dyn_height) + height = 0; + if (chn_dyn_width) + width = 0; + } + + for (size_t i= 0; i< v_cc_items.size(); i++){ + //set general start position for all items + if (i == 0) + v_cc_items[i]->setPos(0, 0); + + //set arrangement with required direction + if (chn_horizontal){ + if (i > 0) + v_cc_items[i]->setPos(CC_APPEND, 0); + } + else{ + if (i > 0) + v_cc_items[i]->setPos(0, CC_APPEND); + } + + //assign size + if (chn_horizontal){ + //assign dynamic width + if (chn_dyn_width) + width += v_cc_items[i]->getWidth(); + //assign dynamic height + if (chn_dyn_height) + height = max(v_cc_items[i]->getHeight(), height); + else + v_cc_items[i]->setHeight(height); + } + else{ + //assign dynamic height + if (chn_dyn_height) + height += v_cc_items[i]->getHeight(); + //assign dynamic width + if (chn_dyn_width) + width = max(v_cc_items[i]->getWidth(), width); + else + v_cc_items[i]->setWidth(width); + } + } +} + diff --git a/src/gui/components/cc_frm_chain.h b/src/gui/components/cc_frm_chain.h new file mode 100644 index 000000000..d18461f06 --- /dev/null +++ b/src/gui/components/cc_frm_chain.h @@ -0,0 +1,78 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2013, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef __CC_FORM_CHAIN_H__ +#define __CC_FORM_CHAIN_H__ + + +#include +#include "cc_frm.h" + + +//! Sub class of CComponentsForm. Creates a dynamic form with chained items. +/*! +Paint chained cc-items on screen. +You can set default form parameters like position, size, colors etc. and additional values +to display with defined direction. +*/ + +class CComponentsFrmChain : public CComponentsForm +{ + private: + ///property: defined arrangement mode of items, can be vertical or horizontal + int chn_horizontal; + + ///property: defines height from sum of all contained items + bool chn_dyn_height; + ///property: defines width from sum of all contained items + bool chn_dyn_width; + + ///init all required variables + void initVarChain( const int& x_pos, const int& y_pos, const int& w, const int& h, + const std::vector *v_items, + bool horizontal, + bool dynamic_width, + bool dynamic_height, + bool has_shadow, + fb_pixel_t& color_frame, + fb_pixel_t& color_body, + fb_pixel_t& color_shadow); + + void initCChainItems(); + protected: + + + public: + CComponentsFrmChain( const int& x_pos = 1, const int& y_pos = 1, const int& w = 720, const int& h = 32, + const std::vector *v_items = NULL, + bool horizontal = true, + bool dynamic_width = false, + bool dynamic_height = false, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t& color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t& color_body = COL_MENUHEAD_PLUS_0, + fb_pixel_t& color_shadow = COL_MENUCONTENTDARK_PLUS_0); +// ~CComponentsSlider(); //inherited from CComponentsForm +}; + +#endif diff --git a/src/gui/components/cc_frm_clock.cpp b/src/gui/components/cc_frm_clock.cpp index 3f3b45c6d..6802476d3 100644 --- a/src/gui/components/cc_frm_clock.cpp +++ b/src/gui/components/cc_frm_clock.cpp @@ -41,18 +41,19 @@ using namespace std; -CComponentsFrmClock::CComponentsFrmClock() -{ - initVarClock(); -} -CComponentsFrmClock::CComponentsFrmClock( const int x_pos, const int y_pos, const int w, const int h, +CComponentsFrmClock::CComponentsFrmClock( const int& x_pos, const int& y_pos, const int& w, const int& h, const char* format_str, bool activ, bool has_shadow, fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) { - initVarClock(); + initVarClock(x_pos, y_pos, w, h, format_str, activ, has_shadow, color_frame, color_body, color_shadow); +} +void CComponentsFrmClock::initVarClock( const int& x_pos, const int& y_pos, const int& w, const int& h, + const char* format_str, bool activ, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow) +{ x = x_pos; y = y_pos; width = w; @@ -63,15 +64,6 @@ CComponentsFrmClock::CComponentsFrmClock( const int x_pos, const int y_pos, cons col_body = color_body; col_shadow = color_shadow; - cl_format_str = format_str; - paintClock = false; - activeClock = activ; - if (activeClock) - startThread(); -} - -void CComponentsFrmClock::initVarClock() -{ cc_item_type = CC_ITEMTYPE_FRM_CLOCK; corner_rad = RADIUS_SMALL; @@ -80,7 +72,7 @@ void CComponentsFrmClock::initVarClock() dyn_font_size = 0; cl_col_text = COL_MENUCONTENT_TEXT; - cl_format_str = "%H:%M"; + cl_format_str = format_str; cl_align = CC_ALIGN_VER_CENTER | CC_ALIGN_HOR_CENTER; cl_thread = 0; @@ -88,6 +80,11 @@ void CComponentsFrmClock::initVarClock() activeClock = true; cl_blink_str = ""; + paintClock = false; + + activeClock = activ; + if (activeClock) + startThread(); } CComponentsFrmClock::~CComponentsFrmClock() diff --git a/src/gui/components/cc_frm_clock.h b/src/gui/components/cc_frm_clock.h index 44fd7ffe0..d08336310 100644 --- a/src/gui/components/cc_frm_clock.h +++ b/src/gui/components/cc_frm_clock.h @@ -78,7 +78,9 @@ class CComponentsFrmClock : public CComponentsForm int cl_align; ///initialize all attributes and required objects - void initVarClock(); + void initVarClock( const int& x_pos, const int& y_pos, const int& w, const int& h, + const char* format_str, bool activ, bool has_shadow, + fb_pixel_t color_frame, fb_pixel_t color_body, fb_pixel_t color_shadow); ///initialize clock contents void initCCLockItems(); @@ -91,8 +93,7 @@ class CComponentsFrmClock : public CComponentsForm inline Font** getClockFont(); public: - CComponentsFrmClock(); - CComponentsFrmClock( const int x_pos, const int y_pos, const int w, const int h, + CComponentsFrmClock( const int& x_pos = 1, const int& y_pos = 1, const int& w = 200, const int& h = 48, const char* format_str = "%H:%M", bool activ=true, bool has_shadow = CC_SHADOW_OFF, fb_pixel_t color_frame = COL_LIGHT_GRAY, fb_pixel_t color_body = COL_MENUCONTENT_PLUS_0, fb_pixel_t color_shadow = COL_MENUCONTENTDARK_PLUS_0); virtual ~CComponentsFrmClock(); diff --git a/src/gui/components/cc_frm_slider.cpp b/src/gui/components/cc_frm_slider.cpp new file mode 100644 index 000000000..50b5f5fbd --- /dev/null +++ b/src/gui/components/cc_frm_slider.cpp @@ -0,0 +1,168 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2013, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include +#include +#include "cc_frm_slider.h" + +using namespace std; + +//------------------------------------------------------------------------------------------------------- +//sub class CComponentsSlider +CComponentsSlider::CComponentsSlider( const int& x_pos, const int& y_pos, const int& w, const int& h, + const int& current_value, + const int& min_value, + const int& max_value, + bool has_shadow, + fb_pixel_t& color_frame, + fb_pixel_t& color_body, + fb_pixel_t& color_shadow) +{ + initVarSlider(x_pos, y_pos, w, h, current_value, min_value, max_value, has_shadow, color_frame, color_body, color_shadow); + initCCSlItems(); +} + + +void CComponentsSlider::initVarSlider( const int& x_pos, const int& y_pos, const int& w, const int& h, + const int& current_value, + const int& min_value, + const int& max_value, + bool has_shadow, + fb_pixel_t& color_frame, + fb_pixel_t& color_body, + fb_pixel_t& color_shadow) +{ + cc_item_type = CC_ITEMTYPE_SLIDER; + corner_rad = 0; + + x = x_pos; + y = y_pos; + width = w; + height = h; + + csl_current_value = current_value; + csl_min_value = min_value; + csl_max_value = max_value; + + shadow = has_shadow; + col_frame = color_frame; + col_body = color_body; + col_shadow = color_shadow; + + csl_body_obj = NULL; + csl_slider_obj = NULL; + + csl_body_icon = NEUTRINO_ICON_VOLUMEBODY; + csl_slider_icon =NEUTRINO_ICON_VOLUMESLIDER2; +} + +//set current value +void CComponentsSlider::setValuePos(const int& current_value) +{ + csl_current_value = current_value; + if (csl_slider_obj->isPicPainted()) + csl_slider_obj->hide(); + initCCSlItems(); +} + +//set current scale values +void CComponentsSlider::setValueScale(const int& min_value, const int& max_value) +{ + csl_min_value = min_value; + csl_max_value = max_value; + initCCSlItems(); +} + +//init slider body object and add to container +void CComponentsSlider::initCCSlBody() +{ + if (!csl_body_icon.empty()){ + printf("[CComponentsSlider] [%s] missing or undefinied slider body icon %s\n", __func__, csl_body_icon.c_str()); + if (csl_body_obj == NULL){ + csl_body_obj = new CComponentsPicture(0, 0, 0, height, csl_body_icon); + csl_body_obj->doPaintBg(false); + addCCItem(csl_body_obj); + } + else + csl_body_obj->setPicture(csl_body_icon); + } + else + return; + + //get first icon dimensions + int icon_w = csl_body_obj->getWidth(); + int icon_h = csl_body_obj->getHeight(); + + //position of icon default centered + int icon_x = width/2-icon_w/2; + int icon_y = height/2-icon_h/2; + + if (csl_body_obj){ + csl_body_obj->setDimensionsAll(icon_x, icon_y, icon_w, icon_h); + csl_body_obj->setPictureAlign(CC_ALIGN_HOR_CENTER | CC_ALIGN_VER_CENTER); + } +} + +//init slider caption object and add to container +void CComponentsSlider::initCCSlSlider() +{ + if (!csl_slider_icon.empty()){ + printf("[CComponentsSlider] [%s] missing or undefinied slider icon %s\n", __func__, csl_slider_icon.c_str()); + if (csl_slider_obj == NULL){ + csl_slider_obj = new CComponentsPicture(0, 0, 0, 0, csl_slider_icon); + csl_slider_obj->doPaintBg(false); + addCCItem(csl_slider_obj); + } + else + csl_slider_obj->setPicture(csl_slider_icon); + } + else + return; + + //get first icon dimensions + int slider_w = csl_slider_obj->getWidth(); + int slider_h = csl_slider_obj->getHeight(); + + //position of slider icon + int slider_x = csl_body_obj->getXPos() - slider_w/2 + csl_body_obj->getWidth() * (abs(csl_min_value) + csl_current_value) / (abs(csl_min_value) + abs(csl_max_value)); + int slider_y = height/2-slider_h/2; + + if (csl_slider_obj) + csl_slider_obj->setDimensionsAll(slider_x, slider_y, slider_w, slider_h); +} + +void CComponentsSlider::initCCSlItems() +{ + initCCSlBody(); + initCCSlSlider(); +} + +// void CComponentsSlider::paint(bool do_save_bg) +// { +// //prepare items before paint +// initCCSlItems(); +// +// //paint form contents +// paintForm(do_save_bg); +// } + diff --git a/src/gui/components/cc_frm_slider.h b/src/gui/components/cc_frm_slider.h new file mode 100644 index 000000000..9f6672f9d --- /dev/null +++ b/src/gui/components/cc_frm_slider.h @@ -0,0 +1,92 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Classes for generic GUI-related components. + Copyright (C) 2013, Thilo Graf 'dbt' + + License: GPL + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef __CC_FORM_SLIDER_H__ +#define __CC_FORM_SLIDER_H__ + + +#include +#include "cc_frm.h" + + +//! Sub class of CComponentsForm. Shows a slider. +/*! +Paint a simple slider on screen. +You can set default form parameters like position, size, colors etc. and additional values +to display current values with a slider icon. +*/ + +class CComponentsSlider : public CComponentsForm +{ + private: + ///names of slider icons + std::string csl_body_icon, csl_slider_icon; + + ///property: current value that should be displayed by slider button, see also setValuePos() + int csl_current_value; + + ///property: minimal scale value, see also setValueScale() + int csl_min_value; + ///property: maximal scale value, see also setValueScale() + int csl_max_value; + + ///object: image objects for slider button and body + CComponentsPicture *csl_body_obj, *csl_slider_obj; + + ///init body image object + void initCCSlBody(); + ///init slider image object + void initCCSlSlider(); + ///init all items at once + void initCCSlItems(); + + ///init all required variables + void initVarSlider( const int& x_pos, const int& y_pos, const int& w, const int& h, + const int& current_value, + const int& min_value, + const int& max_value, + bool has_shadow, + fb_pixel_t& color_frame, + fb_pixel_t& color_body, + fb_pixel_t& color_shadow); + protected: + + + public: + CComponentsSlider( const int& x_pos = 1, const int& y_pos = 1, const int& w = 120+16, const int& h = 32, + const int& current_value = 0, + const int& min_value = 0, + const int& max_value = 100, + bool has_shadow = CC_SHADOW_OFF, + fb_pixel_t& color_frame = COL_MENUCONTENT_PLUS_6, + fb_pixel_t& color_body = COL_MENUHEAD_PLUS_0, + fb_pixel_t& color_shadow = COL_MENUCONTENTDARK_PLUS_0); +// ~CComponentsSlider(); //inherited from CComponentsForm + + void setValuePos(const int& current_value); + void setValueScale(const int& min_value, const int& max_value); + +// void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); +}; + +#endif diff --git a/src/gui/components/cc_types.h b/src/gui/components/cc_types.h index 5a5fb5fe9..401c3c44d 100644 --- a/src/gui/components/cc_types.h +++ b/src/gui/components/cc_types.h @@ -43,6 +43,7 @@ typedef enum CC_ITEMTYPE_SHAPE_CIRCLE, CC_ITEMTYPE_PIP, CC_ITEMTYPE_FRM, + CC_ITEMTYPE_FRM_CHAIN, CC_ITEMTYPE_FRM_CLOCK, CC_ITEMTYPE_FRM_HEADER, CC_ITEMTYPE_FOOTER, @@ -56,6 +57,7 @@ typedef enum CC_ITEMTYPE_BUTTON_GREEN, CC_ITEMTYPE_BUTTON_YELLOW, CC_ITEMTYPE_BUTTON_BLUE, + CC_ITEMTYPE_SLIDER, CC_ITEMTYPES }CC_ITEMTYPES_T; diff --git a/src/gui/components/unmaintained/cc_item_box.cpp b/src/gui/components/unmaintained/cc_item_box.cpp deleted file mode 100644 index 4a2175dc7..000000000 --- a/src/gui/components/unmaintained/cc_item_box.cpp +++ /dev/null @@ -1,615 +0,0 @@ -/* - Based up Neutrino-GUI - Tuxbox-Project - Copyright (C) 2001 by Steffen Hehn 'McClean' - - Classes for generic GUI-related components. - Copyright (C) 2012, 2013, Thilo Graf 'dbt' - Copyright (C) 2012, Michael Liebmann 'micha-bbg' - - License: GPL - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include -#include "cc_misc.h" - -using namespace std; - -//sub class CComponentsItemBox from CComponentsItem -CComponentsItemBox::CComponentsItemBox() -{ - //CComponentsItemBox - initVarItemBox(); -} - -CComponentsItemBox::~CComponentsItemBox() -{ - hide(); - clearElements(); - clearSavedScreen(); - clear(); -} - -void CComponentsItemBox::initVarItemBox() -{ - //CComponents, CComponentsItem - initVarItem(); - - //CComponentsItemBox - it_col_text = COL_MENUCONTENT_TEXT; - hSpacer = 2; - hOffset = 4; - vOffset = 1; - digit_h = 0; - digit_offset = 0; - font_text = NULL; - paintElements = true; - hMax = 0; - has_TextElement = false; - firstElementLeft = FIRST_ELEMENT_INIT; - firstElementRight = FIRST_ELEMENT_INIT; - prevElementLeft = 0; - prevElementRight = 0; - onlyOneTextElement = false; - isCalculated = false; - v_element_data.clear(); -} - -int CComponentsItemBox::getHeight() -{ - if (!isCalculated) - calculateElements(); - return height; -} - -void CComponentsItemBox::clearElements() -{ - for(size_t i = 0; i < v_element_data.size(); i++) { - switch (v_element_data[i].type) { - case CC_ITEMBOX_ICON: - case CC_ITEMBOX_PICTURE: - if (v_element_data[i].handler1 != NULL) - delete static_cast(v_element_data[i].handler1); - break; - case CC_ITEMBOX_TEXT: - if (v_element_data[i].handler1 != NULL) - delete static_cast(v_element_data[i].handler1); - if (v_element_data[i].handler2 != NULL) - delete static_cast(v_element_data[i].handler2); - break; - default: - break; - } - } - isCalculated = false; - v_element_data.clear(); -} -extern CPictureViewer * g_PicViewer; -bool CComponentsItemBox::addLogoOrText(int align, const std::string& logo, const std::string& text, size_t *index) -{ - comp_element_data_t data; - int dx=0, dy=0; - - data.align = align; - data.x = x; - data.y = y; - data.width = 0; - data.height = 0; - data.handler1 = NULL; - data.handler2 = NULL; - - g_PicViewer->getSize(logo.c_str(), &dx, &dy); - if ((dx != 0) && (dy != 0)) { - // logo OK - data.type = CC_ITEMBOX_PICTURE; - data.element = logo; - } - else { - // no logo - if ((text == "") || ((onlyOneTextElement) && (has_TextElement))) - return false; - else - has_TextElement = true; - if (font_text != NULL) - data.height = font_text->getHeight(); - data.type = CC_ITEMBOX_TEXT; - data.element = text; - } - - v_element_data.push_back(data); - if (index != NULL) - *index = v_element_data.size()-1; - isCalculated = false; - return true; -} - -void CComponentsItemBox::addText(const std::string& s_text, const int align, size_t *index) -{ - addElement(align, CC_ITEMBOX_TEXT, s_text, index); -} - -void CComponentsItemBox::addText(neutrino_locale_t locale_text, const int align, size_t *index) -{ - addElement(align, CC_ITEMBOX_TEXT, g_Locale->getText(locale_text), index); -} - -void CComponentsItemBox::addIcon(const std::string& s_icon_name, const int align, size_t *index) -{ - addElement(align, CC_ITEMBOX_ICON, s_icon_name, index); -} - -void CComponentsItemBox::addPicture(const std::string& s_picture_path, const int align, size_t *index) -{ - addElement(align, CC_ITEMBOX_PICTURE, s_picture_path, index); -} - -void CComponentsItemBox::addClock(const int align, size_t *index) -{ - addElement(align, CC_ITEMBOX_CLOCK, "", index); -} - -bool CComponentsItemBox::addElement(int align, int type, const std::string& element, size_t *index) -{ - comp_element_data_t data; - int dx=0, dy=0; - - switch (type) - { - case CC_ITEMBOX_ICON: - frameBuffer->getIconSize(element.c_str(), &dx, &dy); - if ((dx == 0) || (dy == 0)) - return false; - break; - case CC_ITEMBOX_TEXT: - if ((element == "") || ((onlyOneTextElement) && (has_TextElement))) - return false; - else - has_TextElement = true; - break; - default: - break; - } - - data.type = type; - data.align = align; - data.element = element; - data.x = x; - data.y = y; - data.width = 0; - data.height = 0; - data.handler1 = NULL; - data.handler2 = NULL; - - v_element_data.push_back(data); - if (index != NULL) - *index = v_element_data.size()-1; - isCalculated = false; - return true; -} - -void CComponentsItemBox::refreshElement(size_t index, const std::string& element) -{ - CComponentsPicture* pic = NULL; - switch (v_element_data[index].type) { - case CC_ITEMBOX_PICTURE: - pic = static_cast(v_element_data[index].handler1); - if (pic != NULL) { - pic->hide(); - delete pic; - } - v_element_data[index].element = element; - v_element_data[index].x = x; - v_element_data[index].y = y; - v_element_data[index].width = 0; - v_element_data[index].height = 0; - v_element_data[index].handler1 = NULL; - v_element_data[index].handler2 = NULL; - break; - default: - break; - } - calculateElements(); -} - -//paint image into item box -void CComponentsItemBox::paintImage(size_t index, bool newElement) -{ - CComponentsPicture* pic = NULL; - pic = static_cast(v_element_data[index].handler1); - - int pw = 0, ph = 0; - - if ((newElement) || (pic == NULL)) { - if (pic != NULL) { - pic->hide(); - delete pic; - pic = NULL; - } - if ((v_element_data[index].type) == CC_ITEMBOX_PICTURE) - pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, v_element_data[index].width, - v_element_data[index].height, v_element_data[index].element); - else - pic = new CComponentsPicture( v_element_data[index].x, v_element_data[index].y, 0, 0, v_element_data[index].element); - v_element_data[index].handler1 = (void*)pic; - } - - pic->getPictureSize(&pw, &ph); - pic->setHeight(ph); - pic->setWidth(pw); - pic->setColorBody(col_body); - pic->paint(); -} - -//paint text into item box -void CComponentsItemBox::paintText(size_t index, bool newElement) -{ - //prepare textbox dimension instances - CBox* box = NULL; - box = static_cast(v_element_data[index].handler1); - - if ((newElement) || (box == NULL)) { - if (box != NULL) { - delete box; - box = NULL; - } - box = new CBox(); - v_element_data[index].handler1 = (void*)box; - } - - box->iX = v_element_data[index].x; - box->iY = v_element_data[index].y; - box->iWidth = v_element_data[index].width; - box->iHeight = v_element_data[index].height; - - - //prepare text - CTextBox* textbox = NULL; - textbox = static_cast(v_element_data[index].handler2); - - if ((newElement) || (textbox == NULL)) { - if (textbox != NULL) { - textbox->hide(); - delete textbox; - textbox = NULL; - } - textbox = new CTextBox(v_element_data[index].element.c_str(), font_text, CTextBox::AUTO_WIDTH|CTextBox::AUTO_HIGH, box, col_body); - v_element_data[index].handler2 = (void*)textbox; - } - - textbox->setTextBorderWidth(0,0); - textbox->enableBackgroundPaint(false); - textbox->setTextFont(font_text); - textbox->movePosition(box->iX, box->iY); - textbox->setTextColor(it_col_text); - - if (textbox->setText(&v_element_data[index].element)) - textbox->paint(); -} - - -//paint available elements at one task -void CComponentsItemBox::paintElement(size_t index, bool newElement) -{ - switch (v_element_data[index].type) { - case CC_ITEMBOX_ICON: - case CC_ITEMBOX_PICTURE: - paintImage(index,newElement); - break; - case CC_ITEMBOX_TEXT: - paintText(index,newElement); - break; - case CC_ITEMBOX_CLOCK: - font_text->RenderString(v_element_data[index].x, v_element_data[index].y, v_element_data[index].width, - v_element_data[index].element.c_str(), it_col_text); - break; - default: - break; - } -} - -void CComponentsItemBox::calSizeOfElements() -{ - size_t i; - - // Set element size - for (i = 0; i < v_element_data.size(); i++) { - switch (v_element_data[i].type) - { - case CC_ITEMBOX_ICON: - frameBuffer->getIconSize(v_element_data[i].element.c_str(), &v_element_data[i].width, &v_element_data[i].height); - break; - case CC_ITEMBOX_PICTURE: - g_PicViewer->getSize(v_element_data[i].element.c_str(), &v_element_data[i].width, &v_element_data[i].height); - break; - case CC_ITEMBOX_TEXT: - if (font_text != NULL) - v_element_data[i].height = font_text->getHeight(); - break; - case CC_ITEMBOX_CLOCK: { - if (!g_Sectionsd->getIsTimeSet()) - break; - if (font_text != NULL) { - char timestr[10] = {0}; - time_t now = time(NULL); - struct tm *tm = localtime(&now); - strftime(timestr, sizeof(timestr)-1, "%H:%M", tm); - - digit_h = font_text->getDigitHeight(); - digit_offset = font_text->getDigitOffset(); - v_element_data[i].height = digit_h + (int)((float)digit_offset*1.5); -// v_element_data[i].width = font_text->getMaxDigitWidth() + font->getRenderWidth(":"); - v_element_data[i].width = font_text->getRenderWidth(timestr); - v_element_data[i].element = timestr; - } - } - break; - default: - break; - } - } - - // Calculate largest height without CC_ITEMBOX_PICTURE - firstElementLeft = FIRST_ELEMENT_INIT; - firstElementRight = FIRST_ELEMENT_INIT; - for (i = 0; i < v_element_data.size(); i++) { - if ((firstElementLeft == FIRST_ELEMENT_INIT) && (v_element_data[i].align == CC_ALIGN_LEFT)) - firstElementLeft = i; - if ((firstElementRight == FIRST_ELEMENT_INIT) && (v_element_data[i].align == CC_ALIGN_RIGHT)) - firstElementRight = i; - if (v_element_data[i].type != CC_ITEMBOX_PICTURE) - hMax = max(v_element_data[i].height, hMax); - } -} - -void CComponentsItemBox::calPositionOfElements() -{ - size_t i; - - // Calculate y-positions - height = hMax + 2*vOffset; - for (i = 0; i < v_element_data.size(); i++) { - v_element_data[i].y = y + (height - v_element_data[i].height) / 2; - if (v_element_data[i].type == CC_ITEMBOX_CLOCK) - v_element_data[i].y += v_element_data[i].height + digit_offset/4; - } - - // Calculate x-positions - for (i = 0; i < v_element_data.size(); i++) { - if (firstElementLeft == i){ - prevElementLeft = i; - v_element_data[i].x = x + hOffset + corner_rad/2; - } - else if (firstElementRight == i){ - prevElementRight = i; - v_element_data[i].x = x + width - v_element_data[i].width - hOffset - corner_rad/2; - } - else { - if (v_element_data[i].align == CC_ALIGN_LEFT) { - // left elements - v_element_data[i].x = v_element_data[prevElementLeft].x + v_element_data[prevElementLeft].width + hSpacer; - prevElementLeft = i; - } - else { - // right elements - v_element_data[i].x = v_element_data[prevElementRight].x - v_element_data[i].width - hSpacer; - prevElementRight = i; - } - } - } -} - -void CComponentsItemBox::calculateElements() -{ - if (v_element_data.empty()) - return; - - size_t i; - - calSizeOfElements(); - - // hMax correction if no text element. - if (!has_TextElement) - hMax = max(font_text->getHeight(), hMax); - - // Calculate logo - for (i = 0; i < v_element_data.size(); i++) { - if (v_element_data[i].type == CC_ITEMBOX_PICTURE) { - if ((v_element_data[i].width > LOGO_MAX_WIDTH) || (v_element_data[i].height > hMax)) - g_PicViewer->rescaleImageDimensions(&v_element_data[i].width, &v_element_data[i].height, LOGO_MAX_WIDTH, hMax); - } - } - - // Calculate text width - int allWidth = 0; - for (i = 0; i < v_element_data.size(); i++) { - if (v_element_data[i].type != CC_ITEMBOX_TEXT) - allWidth += v_element_data[i].width + hSpacer; - } - for (i = 0; i < v_element_data.size(); i++) { - if (v_element_data[i].type == CC_ITEMBOX_TEXT) { - v_element_data[i].width = width - (allWidth + 2*hSpacer); - // If text is too long, number of rows = 2 - if (font_text->getRenderWidth(v_element_data[i].element) > v_element_data[i].width) { - v_element_data[i].height = font_text->getHeight() * 2; - hMax = max(v_element_data[i].height, hMax); - } - break; - } - } - - calPositionOfElements(); - isCalculated = true; -} - -void CComponentsItemBox::paintItemBox(bool do_save_bg) -{ - // paint background - paintInit(do_save_bg); - - if ((v_element_data.empty()) || (!paintElements)) - return; - - // paint elements - for (size_t i = 0; i < v_element_data.size(); i++) - paintElement(i); -} - -void CComponentsItemBox::clearTitlebar() -{ - clearElements(); - paintElements = false; - paint(false); - paintElements = true; -} - - - -//------------------------------------------------------------------------------------------------------- -//sub class CComponentsTitleBar from CComponentsItemBox -CComponentsTitleBar::CComponentsTitleBar() -{ - //CComponentsTitleBar - initVarTitleBar(); -} - -void CComponentsTitleBar::initVarTitleBar() -{ - //CComponentsItemBox - initVarItemBox(); - onlyOneTextElement = true; - - font_text = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]; - it_col_text = COL_MENUHEAD_TEXT; - - //CComponents - x = 0; - y = 0; - height = font_text->getHeight() + 2*hSpacer; - width = frameBuffer->getScreenWidth(true);; - col_body = COL_MENUHEAD_PLUS_0; - corner_type = CORNER_TOP; - corner_rad = RADIUS_LARGE; - - //CComponentsTitleBar - tb_text_align = CC_ALIGN_LEFT; - tb_icon_align = CC_ALIGN_LEFT; - tb_c_text = NULL; - tb_s_text = ""; - tb_locale_text = NONEXISTANT_LOCALE; - tb_icon_name = ""; -} - -CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h, const char* c_text, const std::string& s_icon, - fb_pixel_t color_text, fb_pixel_t color_body) -{ - //CComponentsItemBox - initVarTitleBar(); - it_col_text = color_text; - - //CComponents - x = x_pos; - y = y_pos; - height = h; - width = w; - col_body = color_body; - - //CComponentsTitleBar - tb_c_text = c_text; - tb_icon_name = s_icon; - - initElements(); -} - -CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h, const string& s_text, const std::string& s_icon, - fb_pixel_t color_text, fb_pixel_t color_body) -{ - //CComponentsItemBox - initVarTitleBar(); - it_col_text = color_text; - - //CComponents - x = x_pos; - y = y_pos; - height = h; - width = w; - col_body = color_body; - - //CComponentsTitleBar - tb_s_text = s_text; - tb_icon_name = s_icon; - - initElements(); -} - -CComponentsTitleBar::CComponentsTitleBar(const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t locale_text, const std::string& s_icon, - fb_pixel_t color_text, fb_pixel_t color_body) -{ - //CComponentsItemBox - initVarTitleBar(); - it_col_text = color_text; - - //CComponents - x = x_pos; - y = y_pos; - height = h; - width = w; - col_body = color_body; - - //CComponentsTitleBar - tb_locale_text = locale_text; - tb_s_text = g_Locale->getText(tb_locale_text); - tb_icon_name = s_icon; - - initElements(); -} - -///basic init methodes for constructors *************************************** -void CComponentsTitleBar::initIcon() -{ - if (!tb_icon_name.empty()) - addElement (tb_icon_align, CC_ITEMBOX_ICON, tb_icon_name); -} - -void CComponentsTitleBar::initText() -{ - if (tb_c_text){ - addElement (tb_text_align, CC_ITEMBOX_TEXT, tb_c_text); - return; - } - else if (!tb_s_text.empty()){ - addElement (tb_text_align, CC_ITEMBOX_TEXT, tb_s_text); - return; - } -} - -void CComponentsTitleBar::initElements() -{ - initIcon(); - initText(); -} -///***************************************************************************** - -void CComponentsTitleBar::paint(bool do_save_bg) -{ - calculateElements(); - paintItemBox(do_save_bg); -} diff --git a/src/gui/components/unmaintained/cc_misc.h b/src/gui/components/unmaintained/cc_misc.h deleted file mode 100644 index 2c050859c..000000000 --- a/src/gui/components/unmaintained/cc_misc.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - Based up Neutrino-GUI - Tuxbox-Project - Copyright (C) 2001 by Steffen Hehn 'McClean' - - Experimental Classes for generic GUI-related components. Not really used. - Copyright (C) 2012, Michael Liebmann 'micha-bbg - Copyright (C) 2012, Thilo Graf 'dbt' - - License: GPL - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef __CC_MISC__ -#define __CC_MISC__ - -#include "config.h" -#include -#include -#include - - -#define FIRST_ELEMENT_INIT 10000 -#define LOGO_MAX_WIDTH width/4 -class CComponentsItemBox : public CComponentsItem -{ - protected: - int hSpacer; - int hOffset; - int vOffset; - int digit_offset, digit_h; - bool paintElements; - bool onlyOneTextElement; - fb_pixel_t it_col_text; - Font* font_text; - int hMax; - bool has_TextElement; - size_t firstElementLeft; - size_t firstElementRight; - size_t prevElementLeft; - size_t prevElementRight; - std::vector v_element_data; - bool isCalculated; - - void clearElements(); - void initVarItemBox(); - void calSizeOfElements(); - void calPositionOfElements(); - void paintItemBox(bool do_save_bg = CC_SAVE_SCREEN_YES); - void calculateElements(); - bool addElement(int align, int type, const std::string& element="", size_t *index=NULL); - void paintImage(size_t index, bool newElement); - void paintText(size_t index, bool newElement); - - public: - CComponentsItemBox(); - virtual ~CComponentsItemBox(); - - inline virtual void setTextFont(Font* font){font_text = font;}; - inline virtual void setTextColor(fb_pixel_t color_text){ it_col_text = color_text;}; - - virtual void refreshElement(size_t index, const std::string& element); - virtual void paintElement(size_t index, bool newElement= false); - virtual bool addLogoOrText(int align, const std::string& logo, const std::string& text, size_t *index=NULL); - virtual void clearTitlebar(); - virtual void addText(const std::string& s_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL); - virtual void addText(neutrino_locale_t locale_text, const int align=CC_ALIGN_LEFT, size_t *index=NULL); - virtual void addIcon(const std::string& s_icon_name, const int align=CC_ALIGN_LEFT, size_t *index=NULL); - virtual void addPicture(const std::string& s_picture_path, const int align=CC_ALIGN_LEFT, size_t *index=NULL); - virtual void addClock(const int align=CC_ALIGN_RIGHT, size_t *index=NULL); - virtual int getHeight(); -}; - -class CComponentsTitleBar : public CComponentsItemBox -{ - private: - const char* tb_c_text; - std::string tb_s_text, tb_icon_name; - neutrino_locale_t tb_locale_text; - int tb_text_align, tb_icon_align; - - void initText(); - void initIcon(); - void initElements(); - void initVarTitleBar(); - - public: - CComponentsTitleBar(); - CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const char* c_text = NULL, const std::string& s_icon ="", - fb_pixel_t color_text = COL_MENUHEAD_TEXT, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0); - CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, const std::string& s_text ="", const std::string& s_icon ="", - fb_pixel_t color_text = COL_MENUHEAD_TEXT, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0); - CComponentsTitleBar( const int x_pos, const int y_pos, const int w, const int h, neutrino_locale_t locale_text = NONEXISTANT_LOCALE, const std::string& s_icon ="", - fb_pixel_t color_text = COL_MENUHEAD_TEXT, fb_pixel_t color_body = COL_MENUHEAD_PLUS_0); - - void paint(bool do_save_bg = CC_SAVE_SCREEN_YES); - -}; - -#endif /*__CC_MISC__*/ diff --git a/src/gui/dboxinfo.cpp b/src/gui/dboxinfo.cpp index 61ff13176..557042c88 100644 --- a/src/gui/dboxinfo.cpp +++ b/src/gui/dboxinfo.cpp @@ -53,6 +53,8 @@ #include #include #include +#include +#include static const int FSHIFT = 16; /* nr of bits of precision */ #define FIXED_1 (1<getWidth(); int sizeOffset = fontWidth * 7;//9999.99M int percOffset = fontWidth * 3 ;//100% - int nameOffset = fontWidth * 9;//WWWwwwwwww - int offsetw = nameOffset+ (sizeOffset+10)*3 +10+percOffset+10; - offsetw += 20; - width = offsetw + 10 + 120; - height = hheight + 6 * mheight; + int nameOffset = fontWidth * 17;//WWWwwwwwww + height = hheight + 8 * mheight; + + int icon_w = 0, icon_h = 0; + frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icon_w, &icon_h); struct statfs s; FILE * mountFile; @@ -202,10 +204,15 @@ void CDBoxInfoWidget::paint() if ((mountFile = setmntent("/proc/mounts", "r")) == NULL) { perror("/proc/mounts"); } else { + mapseen; while ((mnt = getmntent(mountFile)) != NULL) { if (strcmp(mnt->mnt_fsname, "rootfs") == 0) continue; if (::statfs(mnt->mnt_dir, &s) == 0) { + struct stat st; + if (!stat(mnt->mnt_dir, &st) && seen.find(st.st_dev) != seen.end()) + continue; + seen[st.st_dev] = true; switch (s.f_type) /* f_type is long */ { case 0xEF53L: /*EXT2 & EXT3*/ @@ -216,30 +223,88 @@ void CDBoxInfoWidget::paint() case 0x65735546L: /*fuse for ntfs*/ case 0x58465342L: /*xfs*/ case 0x4d44L: /*msdos*/ - break; case 0x72b6L: /*jffs2*/ - height += mheight; + case 0x5941ff53L: /*yaffs2*/ break; default: continue; } height += mheight; } + nameOffset = std::max(nameOffset, g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(basename(mnt->mnt_dir), true) + icon_w + 20); } endmntent(mountFile); } - width = w_max(width, 0); + int m[2][3] = { { 0, 0, 0 }, { 0, 0, 0 } }; // size, used, available +#define DBINFO_TOTAL 0 +#define DBINFO_USED 1 +#define DBINFO_FREE 2 +#define DBINFO_RAM 0 +#define DBINFO_SWAP 1 + const char *n[2] = { "RAM", "Swap" }; + FILE *procmeminfo = fopen("/proc/meminfo", "r"); + if (procmeminfo) { + char buf[80], a[80]; + int v; + while (fgets(buf, sizeof(buf), procmeminfo)) + if (2 == sscanf(buf, "%[^:]: %d", a, &v)) { + if (!strcasecmp(a, "MemTotal")) + m[DBINFO_RAM][DBINFO_TOTAL] += v; + else if (!strcasecmp(a, "MemFree")) + m[DBINFO_RAM][DBINFO_FREE] += v; + else if (!strcasecmp(a, "Inactive")) + m[DBINFO_RAM][DBINFO_FREE] += v; + else if (!strcasecmp(a, "SwapTotal")) + m[DBINFO_SWAP][DBINFO_TOTAL] = v; + else if (!strcasecmp(a, "SwapFree")) + m[DBINFO_SWAP][DBINFO_FREE] += v; + } + fclose(procmeminfo); + } + bool have_swap = m[DBINFO_SWAP][DBINFO_TOTAL]; + + if (have_swap) + height += mheight; + + int offsetw = nameOffset+ (sizeOffset+10)*3 +10+percOffset+10; + offsetw += 20; + width = offsetw + 10 + 120; + + int _width = w_max(width, 0); + if (_width < width) { + int diff = width - _width; + width = _width; + offsetw -= diff; + nameOffset -= width; + } height = h_max(height, 0); x = getScreenStartX(width); y = getScreenStartY(height); - fprintf(stderr, "CDBoxInfoWidget::CDBoxInfoWidget() x = %d, y = %d, width = %d height = %d\n", x, y, width, height); + // fprintf(stderr, "CDBoxInfoWidget::CDBoxInfoWidget() x = %d, y = %d, width = %d height = %d\n", x, y, width, height); + int ypos=y; int i = 0; frameBuffer->paintBoxRel(x, ypos, width, hheight, COL_MENUHEAD_PLUS_0, RADIUS_LARGE, CORNER_TOP); frameBuffer->paintBoxRel(x, ypos+ hheight, width, height- hheight, COL_MENUCONTENT_PLUS_0, RADIUS_LARGE, CORNER_BOTTOM); + //paint menu head + string iconfile = NEUTRINO_ICON_SHELL; + int HeadiconOffset = 0; + if(!(iconfile.empty())){ + int w, h; + frameBuffer->getIconSize(iconfile.c_str(), &w, &h); + HeadiconOffset = w+6; + } + int fw = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getWidth(); + int binfo_w = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getRenderWidth(g_Locale->getText(LOCALE_EXTRA_DBOXINFO)); + + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+(fw/3)+HeadiconOffset,y+hheight+1, + width-((fw/3)+HeadiconOffset), g_Locale->getText(LOCALE_EXTRA_DBOXINFO), + COL_MENUHEAD_TEXT, 0, true); // UTF-8 + frameBuffer->paintIcon(iconfile, x + fw/4, y, hheight); + ypos+= hheight + (mheight >>1); FILE* fd = fopen("/proc/cpuinfo", "rt"); if (fd==NULL) { @@ -263,8 +328,7 @@ void CDBoxInfoWidget::paint() char *p=rindex(buffer,':'); if (p) hw=++p; - hw+=" Info"; - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10, y + hheight+1, width - 10, hw.c_str(), COL_MENUHEAD_TEXT, 0, true); // UTF-8 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x+10+binfo_w+HeadiconOffset, y + hheight+1, width - 10, hw.c_str(), COL_MENUHEAD_TEXT, 0, true); // UTF-8 break; } i++; @@ -276,6 +340,7 @@ void CDBoxInfoWidget::paint() continue; if (read > 0 && buffer[read-1] == '\n') buffer[read-1] = '\0'; + buffer[0] = toupper(buffer[0]); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, buffer, COL_MENUCONTENT_TEXT); ypos+= mheight; } @@ -328,6 +393,71 @@ void CDBoxInfoWidget::paint() int headOffset=0; int mpOffset=0; bool rec_mp=false, memory_flag = false; + const int headSize_mem = 5; + const char *head_mem[headSize_mem] = {"Memory", "Size", "Used", "Available", "Use%"}; + // paint mount head + for (int j = 0; j < headSize_mem; j++) { + switch (j) + { + case 0: + headOffset = 10; + break; + case 1: + headOffset = nameOffset + 20; + break; + case 2: + headOffset = nameOffset + sizeOffset+10 +20; + break; + case 3: + headOffset = nameOffset + (sizeOffset+10)*2+15; + break; + case 4: + headOffset = nameOffset + (sizeOffset+10)*3+15; + break; + } + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset, ypos+ mheight, width - 10, head_mem[j], COL_MENUCONTENTINACTIVE_TEXT); + } + ypos+= mheight; + + for (int k = 0; k < 1 + have_swap; k++) { + m[k][DBINFO_USED] = m[k][DBINFO_TOTAL] - m[k][DBINFO_FREE]; + for (int j = 0; j < headSize_mem; j++) { + switch (j) { + case 0: + mpOffset = 10; + snprintf(ubuf,buf_size,"%-20.20s", n[k]); + break; + case 1: + mpOffset = nameOffset + 10; + bytes2string(1024 * m[k][DBINFO_TOTAL], ubuf, buf_size); + break; + case 2: + mpOffset = nameOffset+ (sizeOffset+10)*1+10; + bytes2string(1024 * m[k][DBINFO_FREE], ubuf, buf_size); + break; + case 3: + mpOffset = nameOffset+ (sizeOffset+10)*2+10; + bytes2string(1024 * m[k][DBINFO_USED], ubuf, buf_size); + break; + case 4: + mpOffset = nameOffset+ (sizeOffset+10)*3+10; + snprintf(ubuf, buf_size, "%4d%%", m[k][DBINFO_TOTAL] ? (m[k][DBINFO_FREE] * 100) / m[k][DBINFO_TOTAL] : 0); + break; + } + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset, ypos+ mheight, width - 10, ubuf, COL_MENUCONTENT_TEXT); + } + int pbw = width - offsetw - 10; + if (pbw > 8) /* smaller progressbar is not useful ;) */ + { + CProgressBar pb(x+offsetw, ypos+3, pbw, mheight-10); + pb.setBlink(); + pb.setInvert(); + pb.setValues(m[k][0] ? (m[k][1] * 100) / m[k][0] : 0, 100); + pb.paint(false); + } + ypos+= mheight; + } + ypos+= mheight; // paint mount head for (int j = 0; j < headSize; j++) { @@ -357,27 +487,28 @@ void CDBoxInfoWidget::paint() perror("/proc/mounts"); } else { + mapseen; while ((mnt = getmntent(mountFile)) != 0) { if (::statfs(mnt->mnt_dir, &s) == 0) { - if (strcmp(mnt->mnt_fsname, "rootfs") == 0) { - strcpy(mnt->mnt_fsname, "memory"); - memory_flag = true; - } - switch (s.f_type) - { - case (int) 0xEF53: /*EXT2 & EXT3*/ - case (int) 0x6969: /*NFS*/ - case (int) 0xFF534D42: /*CIFS*/ - case (int) 0x517B: /*SMB*/ - case (int) 0x52654973: /*REISERFS*/ - case (int) 0x65735546: /*fuse for ntfs*/ - case (int) 0x58465342: /*xfs*/ - case (int) 0x4d44: /*msdos*/ - case (int) 0x72b6: /*jffs2*/ - break; - default: + struct stat st; + if (!stat(mnt->mnt_dir, &st) && seen.find(st.st_dev) != seen.end()) continue; + seen[st.st_dev] = true; + switch (s.f_type) { + case (int) 0xEF53: /*EXT2 & EXT3*/ + case (int) 0x6969: /*NFS*/ + case (int) 0xFF534D42: /*CIFS*/ + case (int) 0x517B: /*SMB*/ + case (int) 0x52654973: /*REISERFS*/ + case (int) 0x65735546: /*fuse for ntfs*/ + case (int) 0x58465342: /*xfs*/ + case (int) 0x4d44: /*msdos*/ + case (int) 0x72b6: /*jffs2*/ + case (int) 0x5941ff53: /*yaffs2*/ + break; + default: + continue; } if ( s.f_blocks > 0 || memory_flag ) { int percent_used; @@ -400,32 +531,21 @@ void CDBoxInfoWidget::paint() } bytes_used = bytes_total - bytes_free; percent_used = (bytes_used * 200 + bytes_total) / 2 / bytes_total; + struct statfs rec_s; + if (statfs(g_settings.network_nfs_recordingdir.c_str(), &rec_s)) + memset(&rec_s, 0, sizeof(rec_s)); //paint mountpoints for (int j = 0; j < headSize; j++) { - switch (j) - { - case 0: { - if (s.f_type != 0x72b6) - { - char *p1=NULL, *p2=NULL; - p1=strchr(g_settings.network_nfs_recordingdir+1,'/') ; - p2=strchr(mnt->mnt_dir+1,'/') ; - if (p2) { - if (strstr(p1,p2)) { - - rec_mp = true; - } - } - else { - if (strstr(g_settings.network_nfs_recordingdir,mnt->mnt_dir)) { - rec_mp = true; - } - } - } + int _w = width; + switch (j) { + case 0: + rec_mp = !memcmp(&s.f_fsid, &rec_s.f_fsid, sizeof(s.f_fsid)) && (s.f_type != 0x72b6) && (s.f_type != 0x5941ff53); mpOffset = 10; - snprintf(ubuf,buf_size,"%-10.10s",basename(mnt->mnt_fsname)); - } - break; + strncpy(ubuf, basename(mnt->mnt_dir), buf_size); + _w = nameOffset - mpOffset; + if (rec_mp) + _w -= icon_w; + break; case 1: mpOffset = nameOffset + 10; bytes2string(bytes_total, ubuf, buf_size); @@ -443,8 +563,12 @@ void CDBoxInfoWidget::paint() snprintf(ubuf, buf_size, "%4d%%", percent_used); break; } - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset, ypos+ mheight, width - 10, ubuf, rec_mp ? COL_MENUCONTENTINACTIVE_TEXT:COL_MENUCONTENT_TEXT); - rec_mp = false; + g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x + mpOffset, ypos+ mheight, _w - 10, ubuf, COL_MENUCONTENT_TEXT); + if (rec_mp) { + if (icon_w>0 && icon_h>0) + frameBuffer->paintIcon(NEUTRINO_ICON_REC, x + nameOffset - 10 - icon_w, ypos + (mheight/2 - icon_h/2)); + rec_mp = false; + } } int pbw = width - offsetw - 10; memory_flag = false; diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index 939a9e85a..566e69dde 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -788,19 +788,18 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start case CRCInput::RC_red: if (!g_settings.minimode && (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF)) { - char recDir[255]; + std::string recDir; //CTimerdClient timerdclient; if (g_Timerd->isTimerdAvailable()) { bool doRecord = true; - //char *recDir = g_settings.network_nfs_recordingdir; - strcpy(recDir, g_settings.network_nfs_recordingdir); + recDir = g_settings.network_nfs_recordingdir; if (g_settings.recording_choose_direct_rec_dir == 2) { CFileBrowser b; b.Dir_Mode=true; hide(); - if (b.exec(g_settings.network_nfs_recordingdir)) { - strcpy(recDir, b.getSelectedFile()->Name.c_str()); + if (b.exec(g_settings.network_nfs_recordingdir.c_str())) { + recDir = b.getSelectedFile()->Name; } else doRecord = false; if (!bigFonts && g_settings.bigFonts) { @@ -814,7 +813,7 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start else if (g_settings.recording_choose_direct_rec_dir == 1) { int lid = -1; - CMountChooser recDirs(LOCALE_TIMERLIST_RECORDING_DIR,NEUTRINO_ICON_SETTINGS,&lid,NULL,g_settings.network_nfs_recordingdir); + CMountChooser recDirs(LOCALE_TIMERLIST_RECORDING_DIR,NEUTRINO_ICON_SETTINGS,&lid,NULL,g_settings.network_nfs_recordingdir.c_str()); if (recDirs.hasItem()) { hide(); @@ -832,12 +831,8 @@ int CEpgData::show(const t_channel_id channel_id, uint64_t a_id, time_t* a_start printf("no network devices available\n"); } if (lid != -1) - strcpy(recDir, g_settings.network_nfs_local_dir[lid]); - //recDir = g_settings.network_nfs_local_dir[id]; - //else - //recDir = NULL; + recDir = g_settings.network_nfs[lid].local_dir; } - //if (recDir != NULL) if (doRecord) { if (g_Timerd->addRecordTimerEvent(channel_id, diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 957dc9204..b064023b8 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -452,11 +452,11 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c showFunctionBar(true, evtlist[selected].channelID); continue; } - char *recDir = g_settings.network_nfs_recordingdir; + std::string recDir = g_settings.network_nfs_recordingdir; if (g_settings.recording_choose_direct_rec_dir) { int id = -1; - CMountChooser recDirs(LOCALE_TIMERLIST_RECORDING_DIR,NEUTRINO_ICON_SETTINGS,&id,NULL,g_settings.network_nfs_recordingdir); + CMountChooser recDirs(LOCALE_TIMERLIST_RECORDING_DIR,NEUTRINO_ICON_SETTINGS,&id,NULL,g_settings.network_nfs_recordingdir.c_str()); if (recDirs.hasItem()) { hide(); @@ -470,11 +470,11 @@ int CNeutrinoEventList::exec(const t_channel_id channel_id, const std::string& c } if (id != -1) - recDir = g_settings.network_nfs_local_dir[id]; + recDir = g_settings.network_nfs[id].local_dir; else - recDir = NULL; + recDir = ""; } - if (recDir != NULL) //add/remove recording timer events and check/warn for conflicts + if (!recDir.empty()) //add/remove recording timer events and check/warn for conflicts { if (g_Timerd->addRecordTimerEvent(evtlist[selected].channelID , evtlist[selected].startTime, diff --git a/src/gui/hdd_menu.cpp b/src/gui/hdd_menu.cpp index f7767d326..b47116e12 100644 --- a/src/gui/hdd_menu.cpp +++ b/src/gui/hdd_menu.cpp @@ -150,9 +150,14 @@ int CHDDMenuHandler::doMenu () mc->setHint("", LOCALE_MENU_HINT_HDD_SLEEP); hddmenu->addItem(mc); - mc = new CMenuOptionChooser(LOCALE_HDD_NOISE, &g_settings.hdd_noise, HDD_NOISE_OPTIONS, HDD_NOISE_OPTION_COUNT, true); - mc->setHint("", LOCALE_MENU_HINT_HDD_NOISE); - hddmenu->addItem(mc); + const char hdparm[] = "/sbin/hdparm"; + struct stat stat_buf; + bool have_nonbb_hdparm = !::lstat(hdparm, &stat_buf) && !S_ISLNK(stat_buf.st_mode); + if (have_nonbb_hdparm) { + mc = new CMenuOptionChooser(LOCALE_HDD_NOISE, &g_settings.hdd_noise, HDD_NOISE_OPTIONS, HDD_NOISE_OPTION_COUNT, true); + mc->setHint("", LOCALE_MENU_HINT_HDD_NOISE); + hddmenu->addItem(mc); + } //if(n > 0) hddmenu->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_HDD_MANAGE)); @@ -277,38 +282,59 @@ int CHDDMenuHandler::doMenu () int CHDDDestExec::exec(CMenuTarget* /*parent*/, const std::string&) { - char M_opt[50],S_opt[50]; - char opt[100]; struct dirent **namelist; int n = scandir("/sys/block", &namelist, my_filter, alphasort); if (n < 0) - return 0; + return menu_return::RETURN_NONE; + + const char hdidle[] = "/sbin/hd-idle"; + bool have_hdidle = !access(hdidle, X_OK); + + if (have_hdidle) { + system("kill $(pidof hd-idle)"); + int sleep_seconds = g_settings.hdd_sleep; + switch (sleep_seconds) { + case 241: + sleep_seconds = 30 * 60; + break; + case 242: + sleep_seconds = 60 * 60; + break; + default: + sleep_seconds *= 5; + } + if (sleep_seconds) + my_system(3, hdidle, "-i", to_string(sleep_seconds).c_str()); + } const char hdparm[] = "/sbin/hdparm"; - bool hdparm_link = false; + bool have_hdparm = !access(hdparm, X_OK); + if (!have_hdparm) + return menu_return::RETURN_NONE; + struct stat stat_buf; - if(::lstat(hdparm, &stat_buf) == 0) - if( S_ISLNK(stat_buf.st_mode) ) - hdparm_link = true; + bool have_nonbb_hdparm = !::lstat(hdparm, &stat_buf) && !S_ISLNK(stat_buf.st_mode); for (int i = 0; i < n; i++) { printf("CHDDDestExec: noise %d sleep %d /dev/%s\n", g_settings.hdd_noise, g_settings.hdd_sleep, namelist[i]->d_name); - snprintf(S_opt, sizeof(S_opt),"-S%d", g_settings.hdd_sleep); - snprintf(opt, sizeof(opt),"/dev/%s",namelist[i]->d_name); - if(hdparm_link){ - //hdparm -M is not included in busybox hdparm! - my_system(3, hdparm, S_opt, opt); - }else{ - snprintf(M_opt, sizeof(M_opt),"-M%d", g_settings.hdd_noise); + char M_opt[50],S_opt[50], opt[100]; + snprintf(S_opt, sizeof(S_opt), "-S%d", g_settings.hdd_sleep); + snprintf(M_opt, sizeof(M_opt), "-M%d", g_settings.hdd_noise); + snprintf(opt, sizeof(opt), "/dev/%s",namelist[i]->d_name); + + if (have_hdidle) + my_system(3, hdparm, M_opt, opt); + else if (have_nonbb_hdparm) my_system(4, hdparm, M_opt, S_opt, opt); - } + else // busybox hdparm doesn't support "-M" + my_system(3, hdparm, S_opt, opt); free(namelist[i]); } free(namelist); - return 1; + return menu_return::RETURN_NONE; } static int dev_umount(char *dev) diff --git a/src/gui/infoclock.cpp b/src/gui/infoclock.cpp index 5ccf65f4f..f9a08f8ad 100644 --- a/src/gui/infoclock.cpp +++ b/src/gui/infoclock.cpp @@ -65,6 +65,12 @@ void CInfoClock::Init() //use current theme colors syncSysColors(); + //set text color + if (g_settings.infoClockBackground) + setTextColor(COL_MENUCONTENT_TEXT); + else + setTextColor(COL_INFOCLOCK_TEXT); + paint_bg = g_settings.infoClockBackground; if (g_settings.infoClockSeconds) diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index 487cda1e8..7e95df50b 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -642,7 +642,7 @@ void CInfoViewerBB::showSysfsHdd() percent = (int)((u * 100ULL) / t); showBarSys(percent); - if (check_dir(g_settings.network_nfs_recordingdir) == 0) + if (check_dir(g_settings.network_nfs_recordingdir.c_str()) == 0) showBarHdd(hddpercent); else showBarHdd(-1); @@ -653,7 +653,7 @@ void* CInfoViewerBB::hddperThread(void *arg) { CInfoViewerBB *infoViewerBB = (CInfoViewerBB*) arg; uint64_t t, u; - if (get_fs_usage(g_settings.network_nfs_recordingdir, t, u)) + if (get_fs_usage(g_settings.network_nfs_recordingdir.c_str(), t, u)) infoViewerBB->hddpercent = (int)((u * 100ULL) / t); else infoViewerBB->hddpercent = 0; diff --git a/src/gui/keybind_setup.cpp b/src/gui/keybind_setup.cpp index 522de1c0d..54d6f13a7 100644 --- a/src/gui/keybind_setup.cpp +++ b/src/gui/keybind_setup.cpp @@ -238,22 +238,26 @@ int CKeybindSetup::showKeySetup() keySettings->addItem(mf); //rc tuning - CStringInput keySettings_repeat_genericblocker(LOCALE_KEYBINDINGMENU_REPEATBLOCKGENERIC, g_settings.repeat_genericblocker, 3, LOCALE_REPEATBLOCKER_HINT_1, LOCALE_REPEATBLOCKER_HINT_2, "0123456789 ", this); - CStringInput keySettings_repeatBlocker(LOCALE_KEYBINDINGMENU_REPEATBLOCK, g_settings.repeat_blocker, 3, LOCALE_REPEATBLOCKER_HINT_1, LOCALE_REPEATBLOCKER_HINT_2, "0123456789 ", this); - keySettings->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_KEYBINDINGMENU_RC)); if (RC_HW_SELECT) { CMenuOptionChooser * mc = new CMenuOptionChooser(LOCALE_KEYBINDINGMENU_REMOTECONTROL_HARDWARE, &g_settings.remote_control_hardware, KEYBINDINGMENU_REMOTECONTROL_HARDWARE_OPTIONS, KEYBINDINGMENU_REMOTECONTROL_HARDWARE_OPTION_COUNT, true); mc->setHint("", LOCALE_MENU_HINT_KEY_HARDWARE); keySettings->addItem(mc); } - mf = new CMenuForwarder(LOCALE_KEYBINDINGMENU_REPEATBLOCK, true, g_settings.repeat_blocker, &keySettings_repeatBlocker); - mf->setHint("", LOCALE_MENU_HINT_KEY_REPEATBLOCK); - keySettings->addItem(mf); + std::string ms_number_format("%d "); + ms_number_format += g_Locale->getText(LOCALE_UNIT_SHORT_MILLISECOND); + CMenuOptionNumberChooser *cc; + cc = new CMenuOptionNumberChooser(LOCALE_KEYBINDINGMENU_REPEATBLOCK, + &g_settings.repeat_blocker, true, 0, 999); + cc->setNumberFormat(ms_number_format); + cc->setHint("", LOCALE_MENU_HINT_KEY_REPEATBLOCK); + keySettings->addItem(cc); - mf = new CMenuForwarder(LOCALE_KEYBINDINGMENU_REPEATBLOCKGENERIC, true, g_settings.repeat_genericblocker, &keySettings_repeat_genericblocker); - mf->setHint("", LOCALE_MENU_HINT_KEY_REPEATBLOCKGENERIC); - keySettings->addItem(mf); + cc = new CMenuOptionNumberChooser(LOCALE_KEYBINDINGMENU_REPEATBLOCKGENERIC, + &g_settings.repeat_genericblocker, true, 0, 999); + cc->setNumberFormat(ms_number_format); + cc->setHint("", LOCALE_MENU_HINT_KEY_REPEATBLOCKGENERIC); + keySettings->addItem(cc); int res = keySettings->exec(NULL, ""); @@ -434,8 +438,8 @@ bool CKeybindSetup::changeNotify(const neutrino_locale_t OptionName, void * /* d { if (ARE_LOCALES_EQUAL(OptionName, LOCALE_KEYBINDINGMENU_REPEATBLOCKGENERIC) || ARE_LOCALES_EQUAL(OptionName, LOCALE_KEYBINDINGMENU_REPEATBLOCK)) { - unsigned int fdelay = atoi(g_settings.repeat_blocker); - unsigned int xdelay = atoi(g_settings.repeat_genericblocker); + unsigned int fdelay = g_settings.repeat_blocker; + unsigned int xdelay = g_settings.repeat_genericblocker; g_RCInput->repeat_block = fdelay * 1000; g_RCInput->repeat_block_generic = xdelay * 1000; diff --git a/src/gui/miscsettings_menu.cpp b/src/gui/miscsettings_menu.cpp index 312cb2725..4d9b4d12e 100644 --- a/src/gui/miscsettings_menu.cpp +++ b/src/gui/miscsettings_menu.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -252,7 +253,7 @@ int CMiscMenue::showMiscSettingsMenu() if (!g_info.hw_caps->can_shutdown) { /* we don't have the energy menu, but put the sleeptimer directly here */ - mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, g_settings.shutdown_min, new CSleepTimerWidget, "permanent", CRCInput::RC_1); + mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, NULL, new CSleepTimerWidget, "permanent", CRCInput::RC_1); mf->setHint("", LOCALE_MENU_HINT_INACT_TIMER); misc_menue.addItem(mf); } @@ -275,6 +276,12 @@ int CMiscMenue::showMiscSettingsMenu() #endif /*CPU_FREQ*/ int res = misc_menue.exec(NULL, ""); + + g_settings.epg_cache = atoi(epg_cache.c_str()); + g_settings.epg_extendedcache = atoi(epg_extendedcache.c_str()); + g_settings.epg_old_events = atoi(epg_old_events.c_str()); + g_settings.epg_max_events = atoi(epg_max_events.c_str()); + delete fanNotifier; delete sectionsdConfigNotifier; #if 0 @@ -339,8 +346,11 @@ int CMiscMenue::showMiscSettingsMenuEnergy() CMenuOptionChooser *m1 = new CMenuOptionChooser(LOCALE_MISCSETTINGS_SHUTDOWN_REAL_RCDELAY, &g_settings.shutdown_real_rcdelay, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, !g_settings.shutdown_real); m1->setHint("", LOCALE_MENU_HINT_SHUTDOWN_RCDELAY); - CStringInput * miscSettings_shutdown_count = new CStringInput(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, g_settings.shutdown_count, 3, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT1, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT2, "0123456789 "); - CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, g_settings.shutdown_count, miscSettings_shutdown_count); + std::string shutdown_count = to_string(g_settings.shutdown_count); + if (shutdown_count.length() < 3) + shutdown_count.insert(0, 3 - shutdown_count.length(), ' '); + CStringInput * miscSettings_shutdown_count = new CStringInput(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, &shutdown_count, 3, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT1, LOCALE_MISCSETTINGS_SHUTDOWN_COUNT_HINT2, "0123456789 "); + CMenuForwarder *m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SHUTDOWN_COUNT, !g_settings.shutdown_real, shutdown_count.c_str(), miscSettings_shutdown_count); m2->setHint("", LOCALE_MENU_HINT_SHUTDOWN_COUNT); COnOffNotifier * miscNotifier = new COnOffNotifier(1); @@ -354,7 +364,7 @@ int CMiscMenue::showMiscSettingsMenuEnergy() ms_energy->addItem(m1); ms_energy->addItem(m2); - m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, g_settings.shutdown_min, new CSleepTimerWidget, "permanent"); + m2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_SLEEPTIMER, true, NULL, new CSleepTimerWidget, "permanent"); m2->setHint("", LOCALE_MENU_HINT_INACT_TIMER); ms_energy->addItem(m2); @@ -369,6 +379,9 @@ int CMiscMenue::showMiscSettingsMenuEnergy() } int res = ms_energy->exec(NULL, ""); + + g_settings.shutdown_count = atoi(shutdown_count.c_str()); + delete ms_energy; delete miscNotifier; return res; @@ -383,20 +396,32 @@ void CMiscMenue::showMiscSettingsMenuEpg(CMenuWidget *ms_epg) CMenuOptionChooser * mc1 = new CMenuOptionChooser(LOCALE_MISCSETTINGS_EPG_SAVE_STANDBY, &g_settings.epg_save_standby, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, g_settings.epg_save); mc1->setHint("", LOCALE_MENU_HINT_EPG_SAVE_STANDBY); - CStringInput * miscSettings_epg_cache = new CStringInput(LOCALE_MISCSETTINGS_EPG_CACHE, &g_settings.epg_cache, 2,LOCALE_MISCSETTINGS_EPG_CACHE_HINT1, LOCALE_MISCSETTINGS_EPG_CACHE_HINT2 , "0123456789 ", sectionsdConfigNotifier); - CMenuForwarder * mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_CACHE, true, g_settings.epg_cache, miscSettings_epg_cache); + epg_cache = to_string(g_settings.epg_cache); + if (epg_cache.length() < 2) + epg_cache.insert(0, 2 - epg_cache.length(), ' '); + CStringInput * miscSettings_epg_cache = new CStringInput(LOCALE_MISCSETTINGS_EPG_CACHE, &epg_cache, 2,LOCALE_MISCSETTINGS_EPG_CACHE_HINT1, LOCALE_MISCSETTINGS_EPG_CACHE_HINT2 , "0123456789 ", sectionsdConfigNotifier); + CMenuForwarder * mf = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_CACHE, true, NULL, miscSettings_epg_cache); mf->setHint("", LOCALE_MENU_HINT_EPG_CACHE); - CStringInput * miscSettings_epg_cache_e = new CStringInput(LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE, &g_settings.epg_extendedcache, 3,LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE_HINT1, LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE_HINT2 , "0123456789 ", sectionsdConfigNotifier); - CMenuForwarder * mf1 = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE, true, g_settings.epg_extendedcache, miscSettings_epg_cache_e); + epg_extendedcache = to_string(g_settings.epg_extendedcache); + if (epg_extendedcache.length() < 3) + epg_extendedcache.insert(0, 3 - epg_extendedcache.length(), ' '); + CStringInput * miscSettings_epg_cache_e = new CStringInput(LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE, &epg_extendedcache, 3,LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE_HINT1, LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE_HINT2 , "0123456789 ", sectionsdConfigNotifier); + CMenuForwarder * mf1 = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_EXTENDEDCACHE, true, epg_extendedcache.c_str(), miscSettings_epg_cache_e); mf1->setHint("", LOCALE_MENU_HINT_EPG_EXTENDEDCACHE); - CStringInput * miscSettings_epg_old_events = new CStringInput(LOCALE_MISCSETTINGS_EPG_OLD_EVENTS, &g_settings.epg_old_events, 3,LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT1, LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT2 , "0123456789 ", sectionsdConfigNotifier); - CMenuForwarder * mf2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_OLD_EVENTS, true, g_settings.epg_old_events, miscSettings_epg_old_events); + epg_old_events = to_string(g_settings.epg_old_events); + if (epg_old_events.length() < 3) + epg_old_events.insert(0, 3 - epg_old_events.length(), ' '); + CStringInput * miscSettings_epg_old_events = new CStringInput(LOCALE_MISCSETTINGS_EPG_OLD_EVENTS, &epg_old_events, 3,LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT1, LOCALE_MISCSETTINGS_EPG_OLD_EVENTS_HINT2 , "0123456789 ", sectionsdConfigNotifier); + CMenuForwarder * mf2 = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_OLD_EVENTS, true, epg_old_events.c_str(), miscSettings_epg_old_events); mf2->setHint("", LOCALE_MENU_HINT_EPG_OLD_EVENTS); - CStringInput * miscSettings_epg_max_events = new CStringInput(LOCALE_MISCSETTINGS_EPG_MAX_EVENTS, &g_settings.epg_max_events, 6,LOCALE_MISCSETTINGS_EPG_MAX_EVENTS_HINT1, LOCALE_MISCSETTINGS_EPG_MAX_EVENTS_HINT2 , "0123456789 ", sectionsdConfigNotifier); - CMenuForwarder * mf3 = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_MAX_EVENTS, true, g_settings.epg_max_events, miscSettings_epg_max_events); + epg_max_events = to_string(g_settings.epg_max_events); + if (epg_max_events.length() < 6) + epg_max_events.insert(0, 6 - epg_max_events.length(), ' '); + CStringInput * miscSettings_epg_max_events = new CStringInput(LOCALE_MISCSETTINGS_EPG_MAX_EVENTS, &epg_max_events, 6,LOCALE_MISCSETTINGS_EPG_MAX_EVENTS_HINT1, LOCALE_MISCSETTINGS_EPG_MAX_EVENTS_HINT2 , "0123456789 ", sectionsdConfigNotifier); + CMenuForwarder * mf3 = new CMenuDForwarder(LOCALE_MISCSETTINGS_EPG_MAX_EVENTS, true, epg_max_events.c_str(), miscSettings_epg_max_events); mf3->setHint("", LOCALE_MENU_HINT_EPG_MAX_EVENTS); CMenuForwarder * mf4 = new CMenuForwarder(LOCALE_MISCSETTINGS_EPG_DIR, g_settings.epg_save, g_settings.epg_dir, this, "epgdir"); diff --git a/src/gui/miscsettings_menu.h b/src/gui/miscsettings_menu.h index 66afe0796..16c2c2968 100644 --- a/src/gui/miscsettings_menu.h +++ b/src/gui/miscsettings_menu.h @@ -43,6 +43,10 @@ class CMiscMenue : public CMenuTarget, CChangeObserver //COnOffNotifier* miscNotifier; COnOffNotifier* miscEpgNotifier; int width; + std::string epg_cache; + std::string epg_extendedcache; + std::string epg_old_events; + std::string epg_max_events; int showMiscSettingsMenu(); void showMiscSettingsMenuGeneral(CMenuWidget *ms_general); diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser.cpp index dd76c58ae..dddd65a92 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser.cpp @@ -756,23 +756,18 @@ bool CMovieBrowser::loadSettings(MB_SETTINGS* settings) settings->reload = (bool)configfile.getInt32("mb_reload", true ); settings->remount = (bool)configfile.getInt32("mb_remount", false ); - char cfg_key[81]; for(int i = 0; i < MB_MAX_DIRS; i++) { - snprintf(cfg_key, sizeof(cfg_key), "mb_dir_%d", i); - settings->storageDir[i] = configfile.getString( cfg_key, "" ); - snprintf(cfg_key, sizeof(cfg_key), "mb_dir_used%d", i); - settings->storageDirUsed[i] = configfile.getInt32( cfg_key,false ); + settings->storageDir[i] = configfile.getString("mb_dir_" + to_string(i), ""); + settings->storageDirUsed[i] = configfile.getInt32("mb_dir_used" + to_string(i), false ); } /* these variables are used for the listframes */ settings->browserFrameHeight = configfile.getInt32("mb_browserFrameHeight", 50); settings->browserRowNr = configfile.getInt32("mb_browserRowNr", 0); for(int i = 0; i < MB_MAX_ROWS && i < settings->browserRowNr; i++) { - snprintf(cfg_key, sizeof(cfg_key), "mb_browserRowItem_%d", i); - settings->browserRowItem[i] = (MB_INFO_ITEM)configfile.getInt32(cfg_key, MB_INFO_MAX_NUMBER); - snprintf(cfg_key, sizeof(cfg_key), "mb_browserRowWidth_%d", i); - settings->browserRowWidth[i] = configfile.getInt32(cfg_key, 50); + settings->browserRowItem[i] = (MB_INFO_ITEM)configfile.getInt32("mb_browserRowItem_" + to_string(i), MB_INFO_MAX_NUMBER); + settings->browserRowWidth[i] = configfile.getInt32("mb_browserRowWidth_" + to_string(i), 50); } settings->ytmode = configfile.getInt32("mb_ytmode", cYTFeedParser::MOST_POPULAR); settings->ytorderby = configfile.getInt32("mb_ytorderby", cYTFeedParser::ORDERBY_PUBLISHED); @@ -824,23 +819,18 @@ bool CMovieBrowser::saveSettings(MB_SETTINGS* settings) configfile.setInt32("mb_reload", settings->reload); configfile.setInt32("mb_remount", settings->remount); - char cfg_key[81]; for(int i = 0; i < MB_MAX_DIRS; i++) { - snprintf(cfg_key, sizeof(cfg_key), "mb_dir_%d", i); - configfile.setString( cfg_key, settings->storageDir[i] ); - snprintf(cfg_key, sizeof(cfg_key), "mb_dir_used%d", i); - configfile.setInt32( cfg_key, settings->storageDirUsed[i] ); // do not save this so far + configfile.setString("mb_dir_" + to_string(i), settings->storageDir[i] ); + configfile.setInt32("mb_dir_used" + to_string(i), settings->storageDirUsed[i] ); // do not save this so far } /* these variables are used for the listframes */ configfile.setInt32("mb_browserFrameHeight", settings->browserFrameHeight); configfile.setInt32("mb_browserRowNr",settings->browserRowNr); for(int i = 0; i < MB_MAX_ROWS && i < settings->browserRowNr; i++) { - snprintf(cfg_key, sizeof(cfg_key), "mb_browserRowItem_%d", i); - configfile.setInt32(cfg_key, settings->browserRowItem[i]); - snprintf(cfg_key, sizeof(cfg_key), "mb_browserRowWidth_%d", i); - configfile.setInt32(cfg_key, settings->browserRowWidth[i]); + configfile.setInt32("mb_browserRowItem_" + to_string(i), settings->browserRowItem[i]); + configfile.setInt32("mb_browserRowWidth_" + to_string(i), settings->browserRowWidth[i]); } configfile.setInt32("mb_ytmode", settings->ytmode); configfile.setInt32("mb_ytorderby", settings->ytorderby); @@ -1003,8 +993,8 @@ int CMovieBrowser::exec(const char* path) //umount automount dirs for(int i = 0; i < NETWORK_NFS_NR_OF_ENTRIES; i++) { - if(g_settings.network_nfs_automount[i]) - umount2(g_settings.network_nfs_local_dir[i],MNT_FORCE); + if(g_settings.network_nfs[i].automount) + umount2(g_settings.network_nfs[i].local_dir.c_str(), MNT_FORCE); } CFSMounter::automount(); } @@ -2510,10 +2500,9 @@ void CMovieBrowser::updateDir(void) } #endif // check if there is a record dir and if we should use it - if(g_settings.network_nfs_recordingdir[0] != 0 ) + if(!g_settings.network_nfs_recordingdir.empty()) { - std::string name = g_settings.network_nfs_recordingdir; - addDir(name,&m_settings.storageDirRecUsed); + addDir(g_settings.network_nfs_recordingdir, &m_settings.storageDirRecUsed); } for(int i = 0; i < MB_MAX_DIRS; i++) @@ -3991,11 +3980,10 @@ CDirMenu::CDirMenu(std::vector* dir_list) { for(int nfs = 0; nfs < NETWORK_NFS_NR_OF_ENTRIES; nfs++) { - std::string tmp = g_settings.network_nfs_local_dir[nfs]; int result = -1; - if(!tmp.empty()) - result = (*dirList)[i].name.compare( 0,tmp.size(),tmp) ; -printf("[CDirMenu] (nfs%d) %s == (mb%d) %s (%d)\n",nfs,g_settings.network_nfs_local_dir[nfs],i,(*dirList)[i].name.c_str(),result); + if(!g_settings.network_nfs[nfs].local_dir.empty()) + result = (*dirList)[i].name.compare( 0,g_settings.network_nfs[nfs].local_dir.size(),g_settings.network_nfs[nfs].local_dir) ; +printf("[CDirMenu] (nfs%d) %s == (mb%d) %s (%d)\n",nfs,g_settings.network_nfs[nfs].local_dir.c_str(),i,(*dirList)[i].name.c_str(),result); if(result == 0) { @@ -4026,8 +4014,8 @@ int CDirMenu::exec(CMenuTarget* parent, const std::string & actionKey) { if(dirState[number] == DIR_STATE_SERVER_DOWN) { - printf("try to start server: %s %s\n","ether-wake", g_settings.network_nfs_mac[dirNfsMountNr[number]]); - if (my_system(2, "ether-wake", g_settings.network_nfs_mac[dirNfsMountNr[number]]) != 0) + printf("try to start server: %s %s\n","ether-wake", g_settings.network_nfs[dirNfsMountNr[number]].mac.c_str()); + if (my_system(2, "ether-wake", g_settings.network_nfs[dirNfsMountNr[number]].mac.c_str()) != 0) perror("ether-wake failed"); dirOptionText[number]="STARTE SERVER"; @@ -4036,14 +4024,14 @@ int CDirMenu::exec(CMenuTarget* parent, const std::string & actionKey) { printf("[CDirMenu] try to mount %d,%d\n",number,dirNfsMountNr[number]); CFSMounter::MountRes res; - res = CFSMounter::mount( g_settings.network_nfs_ip[dirNfsMountNr[number]].c_str(), - g_settings.network_nfs_dir[dirNfsMountNr[number]] , - g_settings.network_nfs_local_dir[dirNfsMountNr[number]] , - (CFSMounter::FSType)g_settings.network_nfs_type[dirNfsMountNr[number]] , - g_settings.network_nfs_username[dirNfsMountNr[number]] , - g_settings.network_nfs_password[dirNfsMountNr[number]] , - g_settings.network_nfs_mount_options1[dirNfsMountNr[number]] , - g_settings.network_nfs_mount_options2[dirNfsMountNr[number]] ); + res = CFSMounter::mount( g_settings.network_nfs[dirNfsMountNr[number]].ip, + g_settings.network_nfs[dirNfsMountNr[number]].dir, + g_settings.network_nfs[dirNfsMountNr[number]].local_dir, + (CFSMounter::FSType)g_settings.network_nfs[dirNfsMountNr[number]].type , + g_settings.network_nfs[dirNfsMountNr[number]].username, + g_settings.network_nfs[dirNfsMountNr[number]].password, + g_settings.network_nfs[dirNfsMountNr[number]].mount_options1, + g_settings.network_nfs[dirNfsMountNr[number]].mount_options2); if(res == CFSMounter::MRES_OK) // if mount is successful we set the state to active in any case { *(*dirList)[number].used = true; @@ -4084,7 +4072,7 @@ void CDirMenu::updateDirState(void) printf("updateDirState: %d: state %d nfs %d\n", i, dirState[i], dirNfsMountNr[i]); if(dirNfsMountNr[i] != -1) { - int retvalue = pinghost(g_settings.network_nfs_ip[dirNfsMountNr[i]].c_str()); + int retvalue = pinghost(g_settings.network_nfs[dirNfsMountNr[i]].ip.c_str()); if (retvalue == 0)//LOCALE_PING_UNREACHABLE { dirOptionText[i]="Server, offline"; @@ -4092,7 +4080,7 @@ printf("updateDirState: %d: state %d nfs %d\n", i, dirState[i], dirNfsMountNr[i] } else if (retvalue == 1)//LOCALE_PING_OK { - if(CFSMounter::isMounted (g_settings.network_nfs_local_dir[dirNfsMountNr[i]]) == 0) + if(!CFSMounter::isMounted (g_settings.network_nfs[dirNfsMountNr[i]].local_dir)) { dirOptionText[i]="Not mounted"; dirState[i]=DIR_STATE_NOT_MOUNTED; diff --git a/src/gui/movieplayer.cpp b/src/gui/movieplayer.cpp index e94cdf93c..67fadb87b 100644 --- a/src/gui/movieplayer.cpp +++ b/src/gui/movieplayer.cpp @@ -139,10 +139,10 @@ void CMoviePlayerGui::Init(void) tsfilefilter.addFilter("wmv"); #endif - if (strlen(g_settings.network_nfs_moviedir) != 0) - Path_local = g_settings.network_nfs_moviedir; - else + if (g_settings.network_nfs_moviedir.empty()) Path_local = "/"; + else + Path_local = g_settings.network_nfs_moviedir; if (g_settings.filebrowser_denydirectoryleave) filebrowser = new CFileBrowser(Path_local.c_str()); @@ -384,7 +384,7 @@ bool CMoviePlayerGui::SelectFile() printf("CMoviePlayerGui::SelectFile: isBookmark %d timeshift %d isMovieBrowser %d\n", isBookmark, timeshift, isMovieBrowser); if (has_hdd) - wakeup_hdd(g_settings.network_nfs_recordingdir); + wakeup_hdd(g_settings.network_nfs_recordingdir.c_str()); if (timeshift) { t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); @@ -492,9 +492,7 @@ bool CMoviePlayerGui::SelectFile() printf("CMoviePlayerGui::SelectFile: full_name [%s] file_name [%s]\n", full_name.c_str(), file_name.c_str()); } //store last multiformat play dir - if( (sizeof(g_settings.network_nfs_moviedir)) > Path_local.size() && (strcmp(g_settings.network_nfs_moviedir,Path_local.c_str()) != 0)){ - strcpy(g_settings.network_nfs_moviedir,Path_local.c_str()); - } + g_settings.network_nfs_moviedir = Path_local; return ret; } diff --git a/src/gui/network_setup.cpp b/src/gui/network_setup.cpp index b860de305..a74ac4106 100644 --- a/src/gui/network_setup.cpp +++ b/src/gui/network_setup.cpp @@ -202,14 +202,14 @@ int CNetworkSetup::showNetworkSetup() int ifcount = scandir("/sys/class/net", &namelist, my_filter, alphasort); - CMenuOptionStringChooser * ifSelect = new CMenuOptionStringChooser(LOCALE_NETWORKMENU_SELECT_IF, g_settings.ifname, ifcount > 1, this, CRCInput::RC_nokey, "", true); + CMenuOptionStringChooser * ifSelect = new CMenuOptionStringChooser(LOCALE_NETWORKMENU_SELECT_IF, &g_settings.ifname, ifcount > 1, this, CRCInput::RC_nokey, "", true); ifSelect->setHint("", LOCALE_MENU_HINT_NET_IF); bool found = false; for(int i = 0; i < ifcount; i++) { ifSelect->addOption(namelist[i]->d_name); - if(strcmp(g_settings.ifname, namelist[i]->d_name) == 0) + if(strcmp(g_settings.ifname.c_str(), namelist[i]->d_name) == 0) found = true; free(namelist[i]); } @@ -218,7 +218,7 @@ int CNetworkSetup::showNetworkSetup() free(namelist); if(!found) - strcpy(g_settings.ifname, "eth0"); + g_settings.ifname = "eth0"; networkConfig->readConfig(g_settings.ifname); readNetworkSettings(); @@ -602,7 +602,7 @@ int CNetworkSetup::saveChangesDialog() //restores settings void CNetworkSetup::restoreNetworkSettings() { - snprintf(g_settings.ifname, sizeof(g_settings.ifname), "%s", old_ifname.c_str()); + g_settings.ifname = old_ifname; networkConfig->readConfig(g_settings.ifname);//FIXME ? mac_addr = networkConfig->mac_addr; @@ -649,7 +649,7 @@ bool CNetworkSetup::changeNotify(const neutrino_locale_t locale, void * Data) } else if(locale == LOCALE_NETWORKMENU_SELECT_IF) { networkConfig->readConfig(g_settings.ifname); readNetworkSettings(); - printf("CNetworkSetup::changeNotify: using %s, static %d\n", g_settings.ifname, CNetworkConfig::getInstance()->inet_static); + printf("CNetworkSetup::changeNotify: using %s, static %d\n", g_settings.ifname.c_str(), CNetworkConfig::getInstance()->inet_static); changeNotify(LOCALE_NETWORKMENU_DHCP, &CNetworkConfig::getInstance()->inet_static); @@ -675,13 +675,7 @@ void CNetworkSetup::setWizardMode(bool mode) void CNetworkSetup::showCurrentNetworkSettings() { - char ip[16] = {0}; - char mask[16] = {0}; - char broadcast[16] = {0}; - char router[16] = {0}; - char nameserver[16] = {0}; - std::string text; - + std::string ip, mask, broadcast, router, nameserver, text; netGetIP(g_settings.ifname, ip, mask, broadcast); if (ip[0] == 0) { text = g_Locale->getText(LOCALE_NETWORKMENU_INACTIVE_NETWORK); @@ -705,9 +699,9 @@ void CNetworkSetup::showCurrentNetworkSettings() ShowMsgUTF(LOCALE_NETWORKMENU_SHOW, text, CMessageBox::mbrBack, CMessageBox::mbBack); // UTF-8 } -const char * CNetworkSetup::mypinghost(const char * const host) +const char * CNetworkSetup::mypinghost(std::string &host) { - int retvalue = pinghost(host); + int retvalue = pinghost(host.c_str()); switch (retvalue) { case 1: return (g_Locale->getText(LOCALE_PING_OK)); @@ -720,11 +714,7 @@ const char * CNetworkSetup::mypinghost(const char * const host) void CNetworkSetup::testNetworkSettings() { - char our_ip[16]; - char our_mask[16]; - char our_broadcast[16]; - char our_gateway[16]; - char our_nameserver[16]; + std::string our_ip, our_mask, our_broadcast, our_gateway, our_nameserver; std::string text, testsite, offset = " "; @@ -747,29 +737,29 @@ void CNetworkSetup::testNetworkSettings() if (networkConfig->inet_static) { - strcpy(our_ip, networkConfig->address.c_str()); - strcpy(our_mask, networkConfig->netmask.c_str()); - strcpy(our_broadcast, networkConfig->broadcast.c_str()); - strcpy(our_gateway, networkConfig->gateway.c_str()); - strcpy(our_nameserver, networkConfig->nameserver.c_str()); + our_ip = networkConfig->address; + our_mask = networkConfig->netmask; + our_broadcast = networkConfig->broadcast; + our_gateway = networkConfig->gateway; + our_nameserver = networkConfig->nameserver; } else { // FIXME test with current, not changed ifname ? - netGetIP((char *) old_ifname.c_str(), our_ip, our_mask, our_broadcast); + netGetIP(old_ifname, our_ip, our_mask, our_broadcast); netGetDefaultRoute(our_gateway); netGetNameserver(our_nameserver); } - printf("testNw IP: %s\n", our_ip); + printf("testNw IP: %s\n", our_ip.c_str()); printf("testNw MAC-address: %s\n", old_mac_addr.c_str()); - printf("testNw Netmask: %s\n", our_mask); - printf("testNw Broadcast: %s\n", our_broadcast); - printf("testNw Gateway: %s\n", our_gateway); - printf("testNw Nameserver: %s\n", our_nameserver); + printf("testNw Netmask: %s\n", our_mask.c_str()); + printf("testNw Broadcast: %s\n", our_broadcast.c_str()); + printf("testNw Gateway: %s\n", our_gateway.c_str()); + printf("testNw Nameserver: %s\n", our_nameserver.c_str()); printf("testNw Testsite: %s\n", testsite.c_str()); - if (our_ip[0] == 0) + if (our_ip.empty()) { text = g_Locale->getText(LOCALE_NETWORKMENU_INACTIVE_NETWORK); } @@ -777,28 +767,28 @@ void CNetworkSetup::testNetworkSettings() { //Box text = "Box (" + old_mac_addr + "):\n"; - text += offset + (std::string)our_ip + " " + (std::string)mypinghost(our_ip) + "\n"; + text += offset + our_ip + " " + mypinghost(our_ip) + "\n"; //Gateway text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_GATEWAY) + " (Router):\n"; - text += offset + (std::string)our_gateway + " " + (std::string)mypinghost(our_gateway) + "\n"; + text += offset + our_gateway + " " + mypinghost(our_gateway) + "\n"; //Nameserver text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_NAMESERVER) + ":\n"; - text += offset + (std::string)our_nameserver + " " + (std::string)mypinghost(our_nameserver) + "\n"; + text += offset + our_nameserver + " " + mypinghost(our_nameserver) + "\n"; //NTPserver - if ( (pinghost(our_nameserver) == 1) && g_settings.network_ntpenable && (g_settings.network_ntpserver != "") ) + if ( (pinghost(our_nameserver.c_str()) == 1) && g_settings.network_ntpenable && (g_settings.network_ntpserver != "") ) { - text += (std::string)g_Locale->getText(LOCALE_NETWORKMENU_NTPSERVER) + ":\n"; - text += offset + g_settings.network_ntpserver + " " + (std::string)mypinghost(g_settings.network_ntpserver.c_str()) + "\n"; + text += std::string(g_Locale->getText(LOCALE_NETWORKMENU_NTPSERVER)) + ":\n"; + text += offset + g_settings.network_ntpserver + " " + mypinghost(g_settings.network_ntpserver) + "\n"; } //Wiki text += wiki_URL + ":\n"; - text += offset + "via IP (" + wiki_IP + "): " + (std::string)mypinghost(wiki_IP.c_str()) + "\n"; - if (pinghost(our_nameserver) == 1) + text += offset + "via IP (" + wiki_IP + "): " + mypinghost(wiki_IP) + "\n"; + if (pinghost(our_nameserver.c_str()) == 1) { - text += offset + "via DNS: " + (std::string)mypinghost(wiki_URL.c_str()) + "\n"; + text += offset + "via DNS: " + mypinghost(wiki_URL) + "\n"; //testsite (or defaultsite) text += testsite + ":\n"; - text += offset + "via DNS: " + (std::string)mypinghost(testsite.c_str()) + "\n"; + text += offset + "via DNS: " + mypinghost(testsite) + "\n"; } } diff --git a/src/gui/network_setup.h b/src/gui/network_setup.h index f2c015c24..993c7c86e 100644 --- a/src/gui/network_setup.h +++ b/src/gui/network_setup.h @@ -95,7 +95,7 @@ class CNetworkSetup : public CMenuTarget, CChangeObserver bool checkStringSettings(); bool checkForIP(); bool settingsChanged(); - const char * mypinghost(const char * const host); + const char * mypinghost(std::string &host); public: enum NETWORK_DHCP_MODE diff --git a/src/gui/nfs.cpp b/src/gui/nfs.cpp index 71d14b114..32c698e98 100644 --- a/src/gui/nfs.cpp +++ b/src/gui/nfs.cpp @@ -72,6 +72,24 @@ const char * nfs_entry_printf_string[3] = "FTPFS %s/%s -> %s auto: %4s" }; +std::string CNFSMountGui::getEntryString(int i) +{ + std::string res; + switch(g_settings.network_nfs[i].type) { + case CFSMounter::NFS: res = "NFS " + g_settings.network_nfs[i].ip + ":"; break; + case CFSMounter::CIFS: res = "CIFS //" + g_settings.network_nfs[i].ip + "/"; break; + case CFSMounter::LUFS: res = "FTPS " + g_settings.network_nfs[i].ip + "/"; break; + } + if (g_settings.network_nfs[i].dir.empty() || g_settings.network_nfs[i].local_dir.empty() || g_settings.network_nfs[i].ip.empty()) + return ""; + return res + + FILESYSTEM_ENCODING_TO_UTF8(g_settings.network_nfs[i].dir) + + " -> " + + FILESYSTEM_ENCODING_TO_UTF8(g_settings.network_nfs[i].local_dir) + + " (auto: " + + g_Locale->getText(g_settings.network_nfs[i].automount ? LOCALE_MESSAGEBOX_YES : LOCALE_MESSAGEBOX_NO) + + ")"; +} int CNFSMountGui::exec( CMenuTarget* parent, const std::string & actionKey ) { @@ -94,12 +112,7 @@ int CNFSMountGui::exec( CMenuTarget* parent, const std::string & actionKey ) parent->hide(); for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES; i++) { - sprintf(m_entry[i], - nfs_entry_printf_string[(g_settings.network_nfs_type[i] == (int) CFSMounter::NFS) ? 0 : ((g_settings.network_nfs_type[i] == (int) CFSMounter::CIFS) ? 1 : 2)], - g_settings.network_nfs_ip[i].c_str(), - FILESYSTEM_ENCODING_TO_UTF8(g_settings.network_nfs_dir[i]), - FILESYSTEM_ENCODING_TO_UTF8(g_settings.network_nfs_local_dir[i]), - g_Locale->getText(g_settings.network_nfs_automount[i] ? LOCALE_MESSAGEBOX_YES : LOCALE_MESSAGEBOX_NO)); + m_entry[i] = getEntryString(i); } returnval = menu(); } @@ -107,24 +120,18 @@ int CNFSMountGui::exec( CMenuTarget* parent, const std::string & actionKey ) { int i = mountMenuWPtr->getSelected() - menu_offset; if (i > -1 && i < NETWORK_NFS_NR_OF_ENTRIES) { - g_settings.network_nfs_ip[i] = ""; - g_settings.network_nfs_dir[i][0] = 0; - g_settings.network_nfs_local_dir[i][0] = 0; - g_settings.network_nfs_automount[i] = 0; - g_settings.network_nfs_type[i] = 0; - g_settings.network_nfs_username[i][0] = 0; - g_settings.network_nfs_password[i][0] = 0; - strcpy(g_settings.network_nfs_mount_options1[i], "ro,soft,udp"); - strcpy(g_settings.network_nfs_mount_options2[i], "nolock,rsize=8192,wsize=8192"); - strcpy(g_settings.network_nfs_mac[i], "11:22:33:44:55:66"); - sprintf(m_entry[i], - nfs_entry_printf_string[(g_settings.network_nfs_type[i] == (int) CFSMounter::NFS) ? 0 : ((g_settings.network_nfs_type[i] == (int) CFSMounter::CIFS) ? 1 : 2)], - g_settings.network_nfs_ip[i].c_str(), - FILESYSTEM_ENCODING_TO_UTF8(g_settings.network_nfs_dir[i]), - FILESYSTEM_ENCODING_TO_UTF8(g_settings.network_nfs_local_dir[i]), - g_Locale->getText(g_settings.network_nfs_automount[i] ? LOCALE_MESSAGEBOX_YES : LOCALE_MESSAGEBOX_NO)); - sprintf(ISO_8859_1_entry[i],ZapitTools::UTF8_to_Latin1(m_entry[i]).c_str()); - mountMenuEntry[i]->setOption(ISO_8859_1_entry[i]); + g_settings.network_nfs[i].ip = ""; + g_settings.network_nfs[i].dir = ""; + g_settings.network_nfs[i].local_dir = ""; + g_settings.network_nfs[i].automount = 0; + g_settings.network_nfs[i].type = 0; + g_settings.network_nfs[i].username = ""; + g_settings.network_nfs[i].password = ""; + g_settings.network_nfs[i].mount_options1 = "ro,soft,udp"; + g_settings.network_nfs[i].mount_options2 = "nolock,rsize=8192,wsize=8192"; + g_settings.network_nfs[i].mac = "11:22:33:44:55:66"; + m_entry[i] = getEntryString(i); + ISO_8859_1_entry[i] = ZapitTools::UTF8_to_Latin1(m_entry[i].c_str()); } } else if(actionKey.substr(0,10)=="mountentry") @@ -133,23 +140,18 @@ int CNFSMountGui::exec( CMenuTarget* parent, const std::string & actionKey ) returnval = menuEntry(actionKey[10]-'0'); for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES; i++) { - sprintf(m_entry[i], - nfs_entry_printf_string[(g_settings.network_nfs_type[i] == (int) CFSMounter::NFS) ? 0 : ((g_settings.network_nfs_type[i] == (int) CFSMounter::CIFS) ? 1 : 2)], - g_settings.network_nfs_ip[i].c_str(), - FILESYSTEM_ENCODING_TO_UTF8(g_settings.network_nfs_dir[i]), - FILESYSTEM_ENCODING_TO_UTF8(g_settings.network_nfs_local_dir[i]), - g_Locale->getText(g_settings.network_nfs_automount[i] ? LOCALE_MESSAGEBOX_YES : LOCALE_MESSAGEBOX_NO)); - sprintf(ISO_8859_1_entry[i],ZapitTools::UTF8_to_Latin1(m_entry[i]).c_str()); + m_entry[i] = getEntryString(i); + ISO_8859_1_entry[i] = ZapitTools::UTF8_to_Latin1(m_entry[i].c_str()); } } else if(actionKey.substr(0,7)=="domount") { int nr=atoi(actionKey.substr(7,1).c_str()); CFSMounter::MountRes mres = CFSMounter::mount( - g_settings.network_nfs_ip[nr].c_str(), g_settings.network_nfs_dir[nr], - g_settings.network_nfs_local_dir[nr], (CFSMounter::FSType) g_settings.network_nfs_type[nr], - g_settings.network_nfs_username[nr], g_settings.network_nfs_password[nr], - g_settings.network_nfs_mount_options1[nr], g_settings.network_nfs_mount_options2[nr]); + g_settings.network_nfs[nr].ip, g_settings.network_nfs[nr].dir, + g_settings.network_nfs[nr].local_dir, (CFSMounter::FSType) g_settings.network_nfs[nr].type, + g_settings.network_nfs[nr].username, g_settings.network_nfs[nr].password, + g_settings.network_nfs[nr].mount_options1, g_settings.network_nfs[nr].mount_options2); if (mres == CFSMounter::MRES_OK || mres == CFSMounter::MRES_FS_ALREADY_MOUNTED) mountMenuEntry[nr]->iconName = NEUTRINO_ICON_MOUNTED; @@ -163,7 +165,7 @@ int CNFSMountGui::exec( CMenuTarget* parent, const std::string & actionKey ) { parent->hide(); int nr=atoi(actionKey.substr(3,1).c_str()); - chooserDir(g_settings.network_nfs_local_dir[nr], false, NULL, sizeof(g_settings.network_nfs_local_dir[nr])-1); + chooserDir(g_settings.network_nfs[nr].local_dir, false, NULL); returnval = menu_return::RETURN_REPAINT; } return returnval; @@ -180,12 +182,12 @@ int CNFSMountGui::menu() for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { sprintf(s2,"mountentry%d",i); - sprintf(ISO_8859_1_entry[i],ZapitTools::UTF8_to_Latin1(m_entry[i]).c_str()); + 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); if (!i) menu_offset = mountMenuW.getItemsCount(); - if (CFSMounter::isMounted(g_settings.network_nfs_local_dir[i])) + if (CFSMounter::isMounted(g_settings.network_nfs[i].local_dir)) { mountMenuEntry[i]->iconName = NEUTRINO_ICON_MOUNTED; } else @@ -216,64 +218,62 @@ const CMenuOptionChooser::keyval NFS_TYPE_OPTIONS[NFS_TYPE_OPTION_COUNT] = int CNFSMountGui::menuEntry(int nr) { - char *dir,*local_dir, *username, *password, *options1, *options2/*, *mac*/; - int* automount; - int* type; + int type, automount; + char cmd[9]; char cmd2[9]; - dir = g_settings.network_nfs_dir[nr]; - local_dir = g_settings.network_nfs_local_dir[nr]; - username = g_settings.network_nfs_username[nr]; - password = g_settings.network_nfs_password[nr]; - automount = &g_settings.network_nfs_automount[nr]; - type = &g_settings.network_nfs_type[nr]; - options1 = g_settings.network_nfs_mount_options1[nr]; - options2 = g_settings.network_nfs_mount_options2[nr]; -// mac = g_settings.network_nfs_mac[nr]; - - sprintf(cmd,"domount%d",nr); - sprintf(cmd2,"dir%d",nr); + snprintf(cmd, sizeof(cmd), "domount%d",nr); + snprintf(cmd2, sizeof(cmd2), "dir%d",nr); /* rewrite fstype in new entries */ - if(strlen(local_dir)==0) + if(g_settings.network_nfs[nr].local_dir.empty()) { if(m_cifs_sup != CFSMounter::FS_UNSUPPORTED && m_nfs_sup == CFSMounter::FS_UNSUPPORTED && m_lufs_sup == CFSMounter::FS_UNSUPPORTED) - *type = (int) CFSMounter::CIFS; + type = (int) CFSMounter::CIFS; else if(m_lufs_sup != CFSMounter::FS_UNSUPPORTED && m_cifs_sup == CFSMounter::FS_UNSUPPORTED && m_nfs_sup == CFSMounter::FS_UNSUPPORTED) - *type = (int) CFSMounter::LUFS; + type = (int) CFSMounter::LUFS; } bool typeEnabled = (m_cifs_sup != CFSMounter::FS_UNSUPPORTED && m_nfs_sup != CFSMounter::FS_UNSUPPORTED && m_lufs_sup != CFSMounter::FS_UNSUPPORTED) || - (m_cifs_sup != CFSMounter::FS_UNSUPPORTED && *type != (int)CFSMounter::CIFS) || - (m_nfs_sup != CFSMounter::FS_UNSUPPORTED && *type != (int)CFSMounter::NFS) || - (m_lufs_sup != CFSMounter::FS_UNSUPPORTED && *type != (int)CFSMounter::LUFS); + (m_cifs_sup != CFSMounter::FS_UNSUPPORTED && type != (int)CFSMounter::CIFS) || + (m_nfs_sup != CFSMounter::FS_UNSUPPORTED && type != (int)CFSMounter::NFS) || + (m_lufs_sup != CFSMounter::FS_UNSUPPORTED && type != (int)CFSMounter::LUFS); CMenuWidget mountMenuEntryW(LOCALE_NFS_MOUNT, NEUTRINO_ICON_NETWORK, width); mountMenuEntryW.addIntroItems(); - CIPInput ipInput(LOCALE_NFS_IP, g_settings.network_nfs_ip[nr], LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); - CStringInputSMS dirInput(LOCALE_NFS_DIR, dir, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE,"abcdefghijklmnopqrstuvwxyz0123456789-_.,:|!?/ "); - CMenuOptionChooser *automountInput= new CMenuOptionChooser(LOCALE_NFS_AUTOMOUNT, automount, MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true); - CStringInputSMS options1Input(LOCALE_NFS_MOUNT_OPTIONS, options1, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_=.,:|!?/ "); - CMenuForwarder *options1_fwd = new CMenuForwarder(LOCALE_NFS_MOUNT_OPTIONS, true, options1, &options1Input); - CStringInputSMS options2Input(LOCALE_NFS_MOUNT_OPTIONS, options2, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_=.,:|!?/ "); - CMenuForwarder *options2_fwd = new CMenuForwarder(LOCALE_NFS_MOUNT_OPTIONS, true, options2, &options2Input); - CStringInputSMS userInput(LOCALE_NFS_USERNAME, username, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_.,:|!?/ "); - CMenuForwarder *username_fwd = new CMenuForwarder(LOCALE_NFS_USERNAME, (*type != (int)CFSMounter::NFS), username, &userInput); - CStringInputSMS passInput(LOCALE_NFS_PASSWORD, 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_mac[nr], LOCALE_IPSETUP_HINT_1, LOCALE_IPSETUP_HINT_2); - CMenuForwarder * macInput_fwd = new CMenuForwarder(LOCALE_RECORDINGMENU_SERVER_MAC, true, g_settings.network_nfs_mac[nr], &macInput); - CMenuForwarder *mountnow_fwd = new CMenuForwarder(LOCALE_NFS_MOUNTNOW, !(CFSMounter::isMounted(g_settings.network_nfs_local_dir[nr])), NULL, this, cmd); + + 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, &automount, MESSAGEBOX_NO_YES_OPTIONS, MESSAGEBOX_NO_YES_OPTION_COUNT, true); + + CStringInputSMS options1Input(LOCALE_NFS_MOUNT_OPTIONS, &g_settings.network_nfs[nr].mount_options1, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_=.,:|!?/ "); + CMenuForwarder *options1_fwd = new CMenuForwarder(LOCALE_NFS_MOUNT_OPTIONS, true, g_settings.network_nfs[nr].mount_options1, &options1Input); + + CStringInputSMS options2Input(LOCALE_NFS_MOUNT_OPTIONS, &g_settings.network_nfs[nr].mount_options2, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_=.,:|!?/ "); + CMenuForwarder *options2_fwd = new CMenuForwarder(LOCALE_NFS_MOUNT_OPTIONS, true, g_settings.network_nfs[nr].mount_options2, &options2Input); + + CStringInputSMS userInput(LOCALE_NFS_USERNAME, &g_settings.network_nfs[nr].username, 30, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "abcdefghijklmnopqrstuvwxyz0123456789-_.,:|!?/ "); + CMenuForwarder *username_fwd = new CMenuForwarder(LOCALE_NFS_USERNAME, (type != (int)CFSMounter::NFS), g_settings.network_nfs[nr].username, &userInput); + + 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); + 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); + mountnow_fwd->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true); COnOffNotifier notifier(CFSMounter::NFS); notifier.addItem(username_fwd); notifier.addItem(password_fwd); - mountMenuEntryW.addItem(new CMenuOptionChooser(LOCALE_NFS_TYPE, type, NFS_TYPE_OPTIONS, NFS_TYPE_OPTION_COUNT, typeEnabled, ¬ifier)); - mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_IP , true, g_settings.network_nfs_ip[nr], &ipInput )); - mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_DIR , true, dir , &dirInput )); - mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_LOCALDIR, true, local_dir , this , cmd2)); + mountMenuEntryW.addItem(new CMenuOptionChooser(LOCALE_NFS_TYPE, &type, NFS_TYPE_OPTIONS, NFS_TYPE_OPTION_COUNT, typeEnabled, ¬ifier)); + mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_IP , true, g_settings.network_nfs[nr].ip, &ipInput )); + mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_DIR , true, g_settings.network_nfs[nr].dir, &dirInput )); + mountMenuEntryW.addItem(new CMenuForwarder(LOCALE_NFS_LOCALDIR, true, g_settings.network_nfs[nr].local_dir, this , cmd2)); mountMenuEntryW.addItem(automountInput); mountMenuEntryW.addItem(options1_fwd); mountMenuEntryW.addItem(options2_fwd); @@ -357,8 +357,8 @@ int CNFSSmallMenu::exec( CMenuTarget* parent, const std::string & actionKey ) //umount automount dirs for(int i = 0; i < NETWORK_NFS_NR_OF_ENTRIES; i++) { - if(g_settings.network_nfs_automount[i]) - umount2(g_settings.network_nfs_local_dir[i],MNT_FORCE); + if(g_settings.network_nfs[i].automount) + umount2(g_settings.network_nfs[i].local_dir.c_str(),MNT_FORCE); } CFSMounter::automount(); return menu_return::RETURN_REPAINT; diff --git a/src/gui/nfs.h b/src/gui/nfs.h index 3caabdcdb..17f33e08b 100644 --- a/src/gui/nfs.h +++ b/src/gui/nfs.h @@ -45,8 +45,10 @@ class CNFSMountGui : public CMenuTarget int menu(); int menuEntry(int nr); - char m_entry[NETWORK_NFS_NR_OF_ENTRIES][200]; - char ISO_8859_1_entry[NETWORK_NFS_NR_OF_ENTRIES][200]; + std::string m_entry[NETWORK_NFS_NR_OF_ENTRIES]; + std::string ISO_8859_1_entry[NETWORK_NFS_NR_OF_ENTRIES]; + + std::string getEntryString(int i); CMenuWidget *mountMenuWPtr; int menu_offset; diff --git a/src/gui/osd_setup.cpp b/src/gui/osd_setup.cpp index 53f83c7bc..1489321bc 100644 --- a/src/gui/osd_setup.cpp +++ b/src/gui/osd_setup.cpp @@ -65,8 +65,6 @@ extern CRemoteControl * g_RemoteControl; -static CTimingSettingsNotifier timingsettingsnotifier; - extern const char * locale_real_names[]; extern std::string ttx_font_file; @@ -75,6 +73,7 @@ COsdSetup::COsdSetup(bool wizard_mode) frameBuffer = CFrameBuffer::getInstance(); colorSetupNotifier = new CColorSetupNotifier(); fontsizenotifier = new CFontSizeNotifier; + colorInfoclockNotifier = NULL; osd_menu = NULL; submenu_menus = NULL; mfFontFile = NULL; @@ -205,7 +204,7 @@ int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey) fileBrowser.Filter = &fileFilter; if (fileBrowser.exec(FONTDIR) == true) { - strcpy(g_settings.font_file, fileBrowser.getSelectedFile()->Name.c_str()); + g_settings.font_file = fileBrowser.getSelectedFile()->Name; printf("[neutrino] new font file %s\n", fileBrowser.getSelectedFile()->Name.c_str()); CNeutrinoApp::getInstance()->SetupFonts(CNeutrinoFonts::FONTSETUP_ALL); osdFontFile = "(" + getBaseName(fileBrowser.getSelectedFile()->Name) + ")"; @@ -221,7 +220,7 @@ int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey) fileBrowser.Filter = &fileFilter; if (fileBrowser.exec(FONTDIR) == true) { - strcpy(g_settings.ttx_font_file, fileBrowser.getSelectedFile()->Name.c_str()); + g_settings.ttx_font_file = fileBrowser.getSelectedFile()->Name; ttx_font_file = fileBrowser.getSelectedFile()->Name; printf("[neutrino] ttx font file %s\n", fileBrowser.getSelectedFile()->Name.c_str()); CNeutrinoApp::getInstance()->SetupFonts(CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT | CNeutrinoFonts::FONTSETUP_NEUTRINO_FONT_INST); @@ -331,8 +330,6 @@ int COsdSetup::exec(CMenuTarget* parent, const std::string &actionKey) else if(actionKey=="osd.def") { for (int i = 0; i < SNeutrinoSettings::TIMING_SETTING_COUNT; i++) g_settings.timing[i] = timing_setting[i].default_timing; - - CNeutrinoApp::getInstance()->SetupTiming(); return res; } else if(actionKey=="logo_dir") { @@ -644,6 +641,7 @@ int COsdSetup::showOsdSetup() } } + delete colorInfoclockNotifier; delete osd_menu; return res; } @@ -840,10 +838,14 @@ void COsdSetup::showOsdTimeoutSetup(CMenuWidget* menu_timeout) { menu_timeout->addIntroItems(LOCALE_COLORMENU_TIMING); + std::string nf("%d "); + nf += g_Locale->getText(LOCALE_UNIT_SHORT_SECOND); for (int i = 0; i < SNeutrinoSettings::TIMING_SETTING_COUNT; i++) { - CStringInput * timing_item = new CStringInput(timing_setting[i].name, g_settings.timing_string[i], 3, LOCALE_TIMING_HINT_1, LOCALE_TIMING_HINT_2, "0123456789 ", &timingsettingsnotifier); - menu_timeout->addItem(new CMenuDForwarder(timing_setting[i].name, true, g_settings.timing_string[i], timing_item)); + CMenuOptionNumberChooser *ch = new CMenuOptionNumberChooser(timing_setting[i].name, &g_settings.timing[i], true, 0, 180); + ch->setNumberFormat(nf); + ch->setHint("", LOCALE_MENU_HINT_OSD_TIMING); + menu_timeout->addItem(ch); } menu_timeout->addItem(GenericMenuSeparatorLine); @@ -1064,10 +1066,20 @@ void COsdSetup::showOsdInfoclockSetup(CMenuWidget *menu_infoclock) mc->setHint("", LOCALE_MENU_HINT_CLOCK_SECONDS); menu_infoclock->addItem(mc); + colorInfoclockNotifier = new COnOffNotifier(1); + // clock with background - mc = new CMenuOptionChooser(LOCALE_CLOCK_BACKGROUND, &g_settings.infoClockBackground, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + mc = new CMenuOptionChooser(LOCALE_CLOCK_BACKGROUND, &g_settings.infoClockBackground, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, colorInfoclockNotifier); mc->setHint("", LOCALE_MENU_HINT_CLOCK_BACKGROUND); menu_infoclock->addItem(mc); + + // digit color + CColorChooser* cc = new CColorChooser(LOCALE_COLORMENU_CLOCK_TEXTCOLOR, &g_settings.clock_Digit_red, &g_settings.clock_Digit_green, &g_settings.clock_Digit_blue, + NULL, colorSetupNotifier); + CMenuDForwarder* mf = new CMenuDForwarder(LOCALE_COLORMENU_CLOCK_TEXTCOLOR, !g_settings.infoClockBackground, NULL, cc); + mf->setHint("", LOCALE_MENU_HINT_CLOCK_TEXTCOLOR); + menu_infoclock->addItem(mf); + colorInfoclockNotifier->addItem(mf); } bool COsdSetup::changeNotify(const neutrino_locale_t OptionName, void * data) diff --git a/src/gui/osd_setup.h b/src/gui/osd_setup.h index 2d30c064e..be227c04e 100644 --- a/src/gui/osd_setup.h +++ b/src/gui/osd_setup.h @@ -53,6 +53,7 @@ class COsdSetup : public CMenuTarget, public CChangeObserver char window_size_value[10]; std::string osdFontFile, osdTtxFontFile; CComponentsShapeSquare *win_demo; + COnOffNotifier* colorInfoclockNotifier; int width; bool is_wizard; diff --git a/src/gui/osdlang_setup.cpp b/src/gui/osdlang_setup.cpp index f4a82d14b..ffc0d47bb 100644 --- a/src/gui/osdlang_setup.cpp +++ b/src/gui/osdlang_setup.cpp @@ -130,7 +130,7 @@ CMenuOptionStringChooser* COsdLangSetup::getTzItems() CMenuOptionStringChooser* tzSelect = NULL; if (parser != NULL) { - tzSelect = new CMenuOptionStringChooser(LOCALE_MAINSETTINGS_TIMEZONE, g_settings.timezone, true, tzNotifier, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN, true); + tzSelect = new CMenuOptionStringChooser(LOCALE_MAINSETTINGS_TIMEZONE, &g_settings.timezone, true, tzNotifier, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN, true); tzSelect->setHint("", LOCALE_MENU_HINT_TIMEZONE); xmlNodePtr search = xmlDocGetRootElement(parser)->xmlChildrenNode; bool found = false; @@ -215,7 +215,7 @@ void COsdLangSetup::showPrefMenu(CMenuWidget *prefMenu, CLangSelectNotifier *lan 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); + CMenuOptionStringChooser * langSelect = new CMenuOptionStringChooser(LOCALE_AUDIOMENU_PREF_LANG, &g_settings.pref_lang[i], true, langNotifier, CRCInput::convertDigitToKey(i+1), "", true); langSelect->setHint("", LOCALE_MENU_HINT_PREF_LANG); langSelect->addOption("none"); std::map::const_iterator it; @@ -231,7 +231,7 @@ void COsdLangSetup::showPrefMenu(CMenuWidget *prefMenu, CLangSelectNotifier *lan prefMenu->addItem(mc); for(int i = 0; i < 3; i++) { - CMenuOptionStringChooser * langSelect = new CMenuOptionStringChooser(LOCALE_AUDIOMENU_PREF_SUBS, g_settings.pref_subs[i], true, NULL, CRCInput::convertDigitToKey(i+4), "", true); + CMenuOptionStringChooser * langSelect = new CMenuOptionStringChooser(LOCALE_AUDIOMENU_PREF_SUBS, &g_settings.pref_subs[i], true, NULL, CRCInput::convertDigitToKey(i+4), "", true); langSelect->setHint("", LOCALE_MENU_HINT_PREF_SUBS); std::map::const_iterator it; langSelect->addOption("none"); @@ -245,7 +245,7 @@ void COsdLangSetup::showPrefMenu(CMenuWidget *prefMenu, CLangSelectNotifier *lan bool COsdLangSetup::changeNotify(const neutrino_locale_t, void *) { //apply osd language - g_Locale->loadLocale(g_settings.language); + g_Locale->loadLocale(g_settings.language.c_str()); return true; } @@ -259,14 +259,13 @@ bool CLangSelectNotifier::changeNotify(const neutrino_locale_t, void *) //prefered audio languages for(int i = 0; i < 3; i++) { - if(strlen(g_settings.pref_lang[i]) && strcmp(g_settings.pref_lang[i], "none")) + if(!g_settings.pref_lang[i].empty() && g_settings.pref_lang[i] != "none") { - printf("setLanguages: %d: %s\n", i, g_settings.pref_lang[i]); + printf("setLanguages: %d: %s\n", i, g_settings.pref_lang[i].c_str()); - std::string temp(g_settings.pref_lang[i]); for(it = iso639.begin(); it != iso639.end(); ++it) { - if(temp == it->second) + if(g_settings.pref_lang[i] == it->second) { v_languages.push_back(it->first); printf("setLanguages: adding %s\n", it->first.c_str()); diff --git a/src/gui/pictureviewer.cpp b/src/gui/pictureviewer.cpp index 602b2d32d..559736ecb 100644 --- a/src/gui/pictureviewer.cpp +++ b/src/gui/pictureviewer.cpp @@ -98,10 +98,10 @@ CPictureViewerGui::CPictureViewerGui() selected = 0; m_sort = FILENAME; m_viewer = new CPictureViewer(); - if (strlen(g_settings.network_nfs_picturedir)!=0) - Path = g_settings.network_nfs_picturedir; - else + if (g_settings.network_nfs_picturedir.empty()) Path = "/"; + else + Path = g_settings.network_nfs_picturedir; picture_filter.addFilter("png"); picture_filter.addFilter("bmp"); @@ -275,7 +275,7 @@ int CPictureViewerGui::show() timeout=50; // egal else { - timeout=(m_time+atoi(g_settings.picviewer_slide_time)-(long)time(NULL))*10; + timeout=(m_time+g_settings.picviewer_slide_time-(long)time(NULL))*10; if (timeout <0 ) timeout=1; } @@ -427,7 +427,7 @@ int CPictureViewerGui::show() { if (m_state == MENU) { - CFileBrowser filebrowser((g_settings.filebrowser_denydirectoryleave) ? g_settings.network_nfs_picturedir : ""); + CFileBrowser filebrowser((g_settings.filebrowser_denydirectoryleave) ? g_settings.network_nfs_picturedir.c_str() : ""); filebrowser.Multi_Select = true; filebrowser.Dirs_Selectable = true; diff --git a/src/gui/pictureviewer_setup.cpp b/src/gui/pictureviewer_setup.cpp index 6dd9be459..7d3eb96f8 100644 --- a/src/gui/pictureviewer_setup.cpp +++ b/src/gui/pictureviewer_setup.cpp @@ -75,8 +75,8 @@ int CPictureViewerSetup::exec(CMenuTarget* parent, const std::string &actionKey) parent->hide(); CFileBrowser b; b.Dir_Mode=true; - if (b.exec(g_settings.network_nfs_picturedir)) - strncpy(g_settings.network_nfs_picturedir, b.getSelectedFile()->Name.c_str(), sizeof(g_settings.network_nfs_picturedir)-1); + if (b.exec(g_settings.network_nfs_picturedir.c_str())) + g_settings.network_nfs_picturedir = b.getSelectedFile()->Name; return res; } @@ -105,12 +105,12 @@ int CPictureViewerSetup::showPictureViewerSetup() mc->setHint("", LOCALE_MENU_HINT_PICTUREVIEWER_SCALING); picviewsetup->addItem(mc); - CStringInput pic_timeout(LOCALE_PICTUREVIEWER_SLIDE_TIME, g_settings.picviewer_slide_time, 2, NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, "0123456789 "); - CMenuForwarder * mf = new CMenuForwarder(LOCALE_PICTUREVIEWER_SLIDE_TIME, true, g_settings.picviewer_slide_time, &pic_timeout); - mf->setHint("", LOCALE_MENU_HINT_PICTUREVIEWER_SLIDE_TIME); - picviewsetup->addItem(mf); + CMenuOptionNumberChooser *cc = new CMenuOptionNumberChooser(LOCALE_PICTUREVIEWER_SLIDE_TIME, &g_settings.picviewer_slide_time, true, 0, 999); + cc->setNumberFormat(std::string("%d ") + g_Locale->getText(LOCALE_UNIT_SHORT_SECOND)); + cc->setHint("", LOCALE_MENU_HINT_PICTUREVIEWER_SLIDE_TIME); + picviewsetup->addItem(cc); - mf = new CMenuForwarder(LOCALE_PICTUREVIEWER_DEFDIR, true, g_settings.network_nfs_picturedir, this, "picturedir"); + CMenuForwarder *mf = new CMenuForwarder(LOCALE_PICTUREVIEWER_DEFDIR, true, g_settings.network_nfs_picturedir, this, "picturedir"); mf->setHint("", LOCALE_MENU_HINT_PICTUREVIEWER_DEFDIR); picviewsetup->addItem(mf); diff --git a/src/gui/record_setup.cpp b/src/gui/record_setup.cpp index 9e69ca291..02b8aebfc 100644 --- a/src/gui/record_setup.cpp +++ b/src/gui/record_setup.cpp @@ -67,7 +67,7 @@ int CRecordSetup::exec(CMenuTarget* parent, const std::string &actionKey) { dprintf(DEBUG_DEBUG, "init record setup\n"); int res = menu_return::RETURN_REPAINT; - char timeshiftDir[255]; + std::string timeshiftDir; if (parent) { @@ -88,13 +88,13 @@ int CRecordSetup::exec(CMenuTarget* parent, const std::string &actionKey) { //parent->hide(); const char *action_str = "recordingdir"; - if(chooserDir(g_settings.network_nfs_recordingdir, true, action_str, sizeof(g_settings.network_nfs_recordingdir)-1)){ - printf("New recordingdir: %s (timeshift %s)\n", g_settings.network_nfs_recordingdir, g_settings.timeshiftdir); - if(strlen(g_settings.timeshiftdir) == 0) + if(chooserDir(g_settings.network_nfs_recordingdir, true, action_str)){ + printf("New recordingdir: %s (timeshift %s)\n", g_settings.network_nfs_recordingdir.c_str(), g_settings.timeshiftdir.c_str()); + if(g_settings.timeshiftdir.empty()) { - sprintf(timeshiftDir, "%s/.timeshift", g_settings.network_nfs_recordingdir); - safe_mkdir(timeshiftDir); - printf("New timeshift dir: %s\n", timeshiftDir); + timeshiftDir = g_settings.network_nfs_recordingdir + "/.timeshift"; + safe_mkdir(timeshiftDir.c_str()); + printf("New timeshift dir: %s\n", timeshiftDir.c_str()); } CRecordManager::getInstance()->SetTimeshiftDirectory(timeshiftDir); } @@ -105,7 +105,7 @@ int CRecordSetup::exec(CMenuTarget* parent, const std::string &actionKey) //parent->hide(); CFileBrowser b; b.Dir_Mode=true; - if (b.exec(g_settings.timeshiftdir)) + if (b.exec(g_settings.timeshiftdir.c_str())) { const char * newdir = b.getSelectedFile()->Name.c_str(); printf("New timeshift: selected %s\n", newdir); @@ -113,21 +113,21 @@ int CRecordSetup::exec(CMenuTarget* parent, const std::string &actionKey) printf("Wrong/unsupported recording dir %s\n", newdir); else { - printf("New timeshift dir: old %s (record %s)\n", g_settings.timeshiftdir, g_settings.network_nfs_recordingdir); - if(strcmp(newdir, g_settings.network_nfs_recordingdir)) + printf("New timeshift dir: old %s (record %s)\n", g_settings.timeshiftdir.c_str(), g_settings.network_nfs_recordingdir.c_str()); + if(newdir != g_settings.network_nfs_recordingdir) { printf("New timeshift != rec dir\n"); - strncpy(g_settings.timeshiftdir, b.getSelectedFile()->Name.c_str(), sizeof(g_settings.timeshiftdir)-1); - strcpy(timeshiftDir, g_settings.timeshiftdir); + g_settings.timeshiftdir = b.getSelectedFile()->Name; + timeshiftDir = g_settings.timeshiftdir; } else { - sprintf(timeshiftDir, "%s/.timeshift", g_settings.network_nfs_recordingdir); - strcpy(g_settings.timeshiftdir, newdir); - safe_mkdir(timeshiftDir); + timeshiftDir = g_settings.network_nfs_recordingdir + "/.timeshift"; + g_settings.timeshiftdir = newdir; + safe_mkdir(timeshiftDir.c_str()); printf("New timeshift == rec dir\n"); } - printf("New timeshift dir: %s\n", timeshiftDir); + printf("New timeshift dir: %s\n", timeshiftDir.c_str()); CRecordManager::getInstance()->SetTimeshiftDirectory(timeshiftDir); } } @@ -218,6 +218,7 @@ int CRecordSetup::showRecordSetup() //rec hours CMenuOptionNumberChooser * mc = new CMenuOptionNumberChooser(LOCALE_EXTRA_RECORD_TIME, &g_settings.record_hours, true, 1, 24, NULL); + mc->setNumberFormat(std::string("%d ") + g_Locale->getText(LOCALE_UNIT_SHORT_HOUR)); mc->setHint("", LOCALE_MENU_HINT_RECORD_TIME); recordingSettings->addItem(mc); @@ -280,31 +281,40 @@ void CRecordSetup::showRecordTimerSetup(CMenuWidget *menu_timersettings) //recording start/end correcture int pre,post; g_Timerd->getRecordingSafety(pre,post); - sprintf(g_settings.record_safety_time_before, "%02d", pre/60); - sprintf(g_settings.record_safety_time_after, "%02d", post/60); - - //start - CStringInput * timerBefore = new CStringInput(LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_BEFORE, g_settings.record_safety_time_before, 2, LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_BEFORE_HINT_1, LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_BEFORE_HINT_2,"0123456789 ", this); - CMenuForwarder *fTimerBefore = new CMenuDForwarder(LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_BEFORE, true, g_settings.record_safety_time_before, timerBefore); - fTimerBefore->setHint("", LOCALE_MENU_HINT_RECORD_TIMEBEFORE); - - //end - CStringInput * timerAfter = new CStringInput(LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_AFTER, g_settings.record_safety_time_after, 2, LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_AFTER_HINT_1, LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_AFTER_HINT_2,"0123456789 ", this); - CMenuForwarder *fTimerAfter = new CMenuDForwarder(LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_AFTER, true, g_settings.record_safety_time_after, timerAfter); - fTimerAfter->setHint("", LOCALE_MENU_HINT_RECORD_TIMEAFTER); - - //announce - CMenuOptionChooser* chzapAnnounce = new CMenuOptionChooser(LOCALE_RECORDINGMENU_ZAP_ON_ANNOUNCE, &g_settings.recording_zap_on_announce, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); - chzapAnnounce->setHint("", LOCALE_MENU_HINT_RECORD_ZAP); - - CMenuOptionNumberChooser *chzapCorr = new CMenuOptionNumberChooser(LOCALE_MISCSETTINGS_ZAPTO_PRE_TIME, &g_settings.zapto_pre_time, true, 0, 10); - chzapCorr->setHint("", LOCALE_MENU_HINT_RECORD_ZAP_PRE_TIME); + g_settings.record_safety_time_before = pre/60; + g_settings.record_safety_time_after = post/60; menu_timersettings->addIntroItems(LOCALE_TIMERSETTINGS_SEPARATOR); - menu_timersettings->addItem(fTimerBefore); - menu_timersettings->addItem(fTimerAfter); + + std::string nf = "%d "; + nf += g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE); + + //start + CMenuOptionNumberChooser *ch = new CMenuOptionNumberChooser(LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_BEFORE, + &g_settings.record_safety_time_before, true, 0, 99, NULL); + ch->setNumberFormat(nf); + ch->setHint("", LOCALE_MENU_HINT_RECORD_TIMEBEFORE); + menu_timersettings->addItem(ch); + + //end + ch = new CMenuOptionNumberChooser(LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_AFTER, + &g_settings.record_safety_time_after, true, 0, 99, NULL); + ch->setNumberFormat(nf); + ch->setHint("", LOCALE_MENU_HINT_RECORD_TIMEAFTER); + menu_timersettings->addItem(ch); + + //announce + CMenuOptionChooser* chzapAnnounce = new CMenuOptionChooser(LOCALE_RECORDINGMENU_ZAP_ON_ANNOUNCE, + &g_settings.recording_zap_on_announce, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); + chzapAnnounce->setHint("", LOCALE_MENU_HINT_RECORD_ZAP); menu_timersettings->addItem(chzapAnnounce); - menu_timersettings->addItem(chzapCorr); + + //zapto + ch = new CMenuOptionNumberChooser(LOCALE_MISCSETTINGS_ZAPTO_PRE_TIME, + &g_settings.zapto_pre_time, true, 0, 10); + ch->setHint("", LOCALE_MENU_HINT_RECORD_ZAP_PRE_TIME); + ch->setNumberFormat(nf); + menu_timersettings->addItem(ch); } @@ -381,7 +391,7 @@ bool CRecordSetup::changeNotify(const neutrino_locale_t OptionName, void * /*dat { if (ARE_LOCALES_EQUAL(OptionName, LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_BEFORE) || ARE_LOCALES_EQUAL(OptionName, LOCALE_TIMERSETTINGS_RECORD_SAFETY_TIME_AFTER)) { - g_Timerd->setRecordingSafety(atoi(g_settings.record_safety_time_before)*60, atoi(g_settings.record_safety_time_after)*60); + g_Timerd->setRecordingSafety(g_settings.record_safety_time_before*60, g_settings.record_safety_time_after); } else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_RECORDINGMENU_APIDS_STD) || ARE_LOCALES_EQUAL(OptionName, LOCALE_RECORDINGMENU_APIDS_ALT) || ARE_LOCALES_EQUAL(OptionName, LOCALE_RECORDINGMENU_APIDS_AC3)) { diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index 99d158287..2cff96f7b 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -448,7 +449,7 @@ printf("C: %d S: %d T: %d\n", CFEManager::getInstance()->haveCable(),CFEManager: //tune timeout if(CFEManager::getInstance()->getFrontendCount() <= 1) { CMenuOptionNumberChooser * nc = new CMenuOptionNumberChooser(LOCALE_EXTRA_ZAPIT_FE_TIMEOUT, (int *)&zapitCfg.feTimeout, true, 6, 100); - nc->setNumberFormat(std::string("%d0 ") + g_Locale->getText(LOCALE_UNIT_SHORT_MILLISECOND)); + nc->setNumberFormat(std::string("%d00 ") + g_Locale->getText(LOCALE_UNIT_SHORT_MILLISECOND)); nc->setHint("", LOCALE_MENU_HINT_SCAN_FETIMEOUT); settings->addItem(nc); } @@ -598,7 +599,7 @@ int CScanSetup::showScanMenuFrontendSetup() frontendSetup = mf; } CMenuOptionNumberChooser * nc = new CMenuOptionNumberChooser(LOCALE_EXTRA_ZAPIT_FE_TIMEOUT, (int *)&zapitCfg.feTimeout, true, 6, 100); - nc->setNumberFormat(std::string("%d0 ") + g_Locale->getText(LOCALE_UNIT_SHORT_MILLISECOND)); + nc->setNumberFormat(std::string("%d00 ") + g_Locale->getText(LOCALE_UNIT_SHORT_MILLISECOND)); nc->setHint("", LOCALE_MENU_HINT_SCAN_FETIMEOUT); setupMenu->addItem(nc); @@ -643,6 +644,11 @@ int CScanSetup::showScanMenuFrontendSetup() return res; } +static std::string rotationSpeed2str(int i) +{ + return to_string(i/10) + g_Locale->getText(LOCALE_UNIT_DECIMAL) + to_string(i%10) + "°/" + g_Locale->getText(LOCALE_UNIT_SHORT_SECOND); +} + int CScanSetup::showFrontendSetup(int number) { int shortcut = 1; @@ -774,6 +780,7 @@ int CScanSetup::showFrontendSetup(int number) setupMenu->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SATSETUP_EXTENDED_MOTOR)); CMenuOptionNumberChooser * nc = new CMenuOptionNumberChooser(LOCALE_EXTRA_ZAPIT_MOTOR_SPEED, (int *)&fe_config.motorRotationSpeed, allow_moptions, 0, 64, NULL); + nc->setNumberFormat(rotationSpeed2str); nc->setHint("", LOCALE_MENU_HINT_SCAN_MOTOR_SPEED); setupMenu->addItem(nc); msettings.Add(nc); diff --git a/src/gui/sleeptimer.cpp b/src/gui/sleeptimer.cpp index 936355f3c..52c531357 100644 --- a/src/gui/sleeptimer.cpp +++ b/src/gui/sleeptimer.cpp @@ -62,7 +62,7 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) parent->hide(); if(permanent) { - strcpy(value,g_settings.shutdown_min); + sprintf(value,"%03d", g_settings.shutdown_min); } else { shutdown_min = g_Timerd->getSleepTimerRemaining(); // remaining shutdown time? sprintf(value,"%03d", shutdown_min); @@ -101,8 +101,8 @@ int CSleepTimerWidget::exec(CMenuTarget* parent, const std::string &actionKey) int new_val = atoi(value); if(permanent) { - sprintf(g_settings.shutdown_min,"%03d", new_val); - printf("permanent sleeptimer min: %s\n", g_settings.shutdown_min); + g_settings.shutdown_min = new_val; + printf("permanent sleeptimer min: %d\n", g_settings.shutdown_min); } else if(shutdown_min != new_val) { shutdown_min = new_val; diff --git a/src/gui/themes.cpp b/src/gui/themes.cpp index 176f85a5d..5786a237d 100644 --- a/src/gui/themes.cpp +++ b/src/gui/themes.cpp @@ -235,6 +235,10 @@ void CThemes::rememberOldTheme(bool remember) oldThemeValues[41] = g_settings.colored_events_red; oldThemeValues[42] = g_settings.colored_events_green; oldThemeValues[43] = g_settings.colored_events_blue; + oldThemeValues[44] = g_settings.clock_Digit_alpha; + oldThemeValues[45] = g_settings.clock_Digit_red; + oldThemeValues[46] = g_settings.clock_Digit_green; + oldThemeValues[47] = g_settings.clock_Digit_blue; } else { g_settings.menu_Head_alpha = oldThemeValues[0]; g_settings.menu_Head_red = oldThemeValues[1]; @@ -280,6 +284,10 @@ void CThemes::rememberOldTheme(bool remember) g_settings.colored_events_red = oldThemeValues[41]; g_settings.colored_events_green = oldThemeValues[42]; g_settings.colored_events_blue = oldThemeValues[43]; + g_settings.clock_Digit_alpha = oldThemeValues[44]; + g_settings.clock_Digit_red = oldThemeValues[45]; + g_settings.clock_Digit_green = oldThemeValues[46]; + g_settings.clock_Digit_blue = oldThemeValues[47]; notifier = new CColorSetupNotifier; notifier->changeNotify(NONEXISTANT_LOCALE, NULL); @@ -336,6 +344,10 @@ void CThemes::readFile(char* themename) g_settings.colored_events_red = themefile.getInt32( "colored_events_red", 95 ); g_settings.colored_events_green = themefile.getInt32( "colored_events_green", 70 ); g_settings.colored_events_blue = themefile.getInt32( "colored_events_blue", 0 ); + g_settings.clock_Digit_alpha = themefile.getInt32( "clock_Digit_alpha", g_settings.menu_Content_Text_alpha ); + g_settings.clock_Digit_red = themefile.getInt32( "clock_Digit_red", g_settings.menu_Content_Text_red ); + g_settings.clock_Digit_green = themefile.getInt32( "clock_Digit_green", g_settings.menu_Content_Text_green ); + g_settings.clock_Digit_blue = themefile.getInt32( "clock_Digit_blue", g_settings.menu_Content_Text_blue ); notifier = new CColorSetupNotifier; notifier->changeNotify(NONEXISTANT_LOCALE, NULL); @@ -392,6 +404,10 @@ void CThemes::saveFile(char * themename) themefile.setInt32( "colored_events_red", g_settings.colored_events_red ); themefile.setInt32( "colored_events_green", g_settings.colored_events_green ); themefile.setInt32( "colored_events_blue", g_settings.colored_events_blue ); + themefile.setInt32( "clock_Digit_alpha", g_settings.clock_Digit_alpha ); + themefile.setInt32( "clock_Digit_red", g_settings.clock_Digit_red ); + themefile.setInt32( "clock_Digit_green", g_settings.clock_Digit_green ); + themefile.setInt32( "clock_Digit_blue", g_settings.clock_Digit_blue ); if (!themefile.saveConfig(themename)) printf("[neutrino theme] %s write error\n", themename); @@ -456,7 +472,9 @@ void CThemes::setupDefaultColors() g_settings.colored_events_red = 95; g_settings.colored_events_green = 70; g_settings.colored_events_blue = 0; + + g_settings.clock_Digit_alpha = 0x00; + g_settings.clock_Digit_red = 0x64; + g_settings.clock_Digit_green = 0x64; + g_settings.clock_Digit_blue = 0x64; } - - - diff --git a/src/gui/themes.h b/src/gui/themes.h index 39d6bff8b..78f09cff0 100644 --- a/src/gui/themes.h +++ b/src/gui/themes.h @@ -35,7 +35,7 @@ class CThemes : public CMenuTarget, CChangeObserver CColorSetupNotifier *notifier; int width; - int oldThemeValues[44]; + int oldThemeValues[48]; bool hasThemeChanged; diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 3bcdf5247..bc166044d 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -1091,7 +1091,7 @@ int CTimerList::modifyTimer() //printf("TIMER: rec dir %s len %s\n", timer->recordingDir, strlen(timer->recordingDir)); if (!strlen(timer->recordingDir)) - strncpy(timer->recordingDir,g_settings.network_nfs_recordingdir,sizeof(timer->recordingDir)-1); + strncpy(timer->recordingDir,g_settings.network_nfs_recordingdir.c_str(),sizeof(timer->recordingDir)-1); bool recDirEnabled = (timer->eventType == CTimerd::TIMER_RECORD) && (g_settings.recording_type == RECORDING_FILE); CMenuForwarder* m6 = new CMenuForwarder(LOCALE_TIMERLIST_RECORDING_DIR, recDirEnabled, timer->recordingDir, this, "rec_dir1", CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN); @@ -1144,7 +1144,7 @@ int CTimerList::newTimer() timerNew.channel_id = 0; strcpy(timerNew.message, ""); timerNew_standby_on =false; - strncpy(timerNew.recordingDir,g_settings.network_nfs_recordingdir,sizeof(timerNew.recordingDir)-1); + strncpy(timerNew.recordingDir,g_settings.network_nfs_recordingdir.c_str(),sizeof(timerNew.recordingDir)-1); CMenuWidget timerSettings(LOCALE_TIMERLIST_MENUNEW, NEUTRINO_ICON_SETTINGS); diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 4ce1bac7b..c3df4c2b8 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -290,7 +290,7 @@ bool CFlashUpdate::getUpdateImage(const std::string & version) if(fname != NULL) fname++; else return false; - sprintf(dest_name, "%s/%s", g_settings.update_dir, fname); + sprintf(dest_name, "%s/%s", g_settings.update_dir.c_str(), fname); showStatusMessageUTF(std::string(g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILE)) + ' ' + version); // UTF-8 printf("get update (url): %s - %s\n", filename.c_str(), dest_name); @@ -360,7 +360,7 @@ printf("[update] mode is %d\n", softupdate_mode); UpdatesBrowser.Filter = &UpdatesFilter; CFile * CFileSelected = NULL; - if (!(UpdatesBrowser.exec(g_settings.update_dir))) { + if (!(UpdatesBrowser.exec(g_settings.update_dir.c_str()))) { menu_ret = UpdatesBrowser.getMenuRet(); return false; } @@ -443,7 +443,7 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_GETUPDATEFILEERROR)); // UTF-8 return menu_return::RETURN_REPAINT; } - sprintf(fullname, "%s/%s", g_settings.update_dir, fname); + sprintf(fullname, "%s/%s", g_settings.update_dir.c_str(), fname); filename = std::string(fullname); } @@ -524,10 +524,10 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &actionKey) { const char install_sh[] = "/bin/install.sh"; #ifdef DEBUG1 - printf("[update] calling %s %s %s\n",install_sh, g_settings.update_dir, filename.c_str() ); + printf("[update] calling %s %s %s\n",install_sh, g_settings.update_dir.c_str(), filename.c_str() ); #else - printf("[update] calling %s %s %s\n",install_sh, g_settings.update_dir, filename.c_str() ); - my_system(3, install_sh, g_settings.update_dir, filename.c_str()); + printf("[update] calling %s %s %s\n",install_sh, g_settings.update_dir.c_str(), filename.c_str() ); + 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 @@ -684,7 +684,8 @@ void CFlashExpert::readmtd(int preadmtd) { std::string filename; CMTDInfo* mtdInfo = CMTDInfo::getInstance(); - std::string hostName = netGetHostname(); + std::string hostName =""; + netGetHostname(hostName); std::string timeStr = getNowTimeStr("_%Y%m%d_%H%M"); std::string tankStr = ""; @@ -847,7 +848,7 @@ int CFlashExpert::showFileSelector(const std::string & actionkey) fileselector->addIntroItems(LOCALE_FLASHUPDATE_FILESELECTOR, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL); struct dirent **namelist; - int n = scandir(g_settings.update_dir, &namelist, 0, alphasort); + int n = scandir(g_settings.update_dir.c_str(), &namelist, 0, alphasort); if (n < 0) { perror("no flashimages available"); diff --git a/src/gui/update_ext.cpp b/src/gui/update_ext.cpp index dad3e296f..f8cc39f7c 100644 --- a/src/gui/update_ext.cpp +++ b/src/gui/update_ext.cpp @@ -151,7 +151,8 @@ bool CExtUpdate::applySettings(std::string & filename, int mode) DBG_TIMER_START() std::string oldFilename = imgFilename; - std::string hostName = netGetHostname(); + std::string hostName =""; + netGetHostname(hostName); std::string orgPath = getPathName(imgFilename); std::string orgName = getBaseName(imgFilename); orgName = getFileName(orgName); diff --git a/src/gui/update_settings.cpp b/src/gui/update_settings.cpp index eb9609c33..37d6d5d7f 100644 --- a/src/gui/update_settings.cpp +++ b/src/gui/update_settings.cpp @@ -95,8 +95,8 @@ int CUpdateSettings::exec(CMenuTarget* parent, const std::string &actionKey) if(actionKey == "update_dir") { const char *action_str = "update"; - if(chooserDir(g_settings.update_dir, true, action_str, sizeof(g_settings.update_dir)-1,true)) - printf("[neutrino] new %s dir %s\n", action_str, g_settings.update_dir); + if(chooserDir(g_settings.update_dir, true, action_str, true)) + printf("[neutrino] new %s dir %s\n", action_str, g_settings.update_dir.c_str()); return res; } diff --git a/src/gui/upnpbrowser.cpp b/src/gui/upnpbrowser.cpp index a871a2270..4717557e7 100644 --- a/src/gui/upnpbrowser.cpp +++ b/src/gui/upnpbrowser.cpp @@ -599,7 +599,7 @@ void CUpnpBrowserGui::playnext(void) } else if (mime.substr(0,6) == "image/") { if (m_folderplay) - timeout = time(NULL) + atoi(g_settings.picviewer_slide_time); + timeout = time(NULL) + g_settings.picviewer_slide_time; showPicture((*entries)[0].resources[preferred].url); } return; diff --git a/src/gui/widget/menue.cpp b/src/gui/widget/menue.cpp index 371f74407..b152d7113 100644 --- a/src/gui/widget/menue.cpp +++ b/src/gui/widget/menue.cpp @@ -161,7 +161,16 @@ void CMenuItem::paintItemCaption(const bool select_mode, const int &item_height, if (right_bgcol) { if (!right_text) stringstartposOption -= 60; - CComponentsShapeSquare col(stringstartposOption, y + 2, dx - stringstartposOption + x - 2, item_height - 4, false, COL_MENUCONTENT_PLUS_6, right_bgcol); + fb_pixel_t right_frame_col, right_bg_col; + if (active) { + right_bg_col = right_bgcol; + right_frame_col = COL_MENUCONTENT_PLUS_6; + } + else { + right_bg_col = COL_MENUCONTENTINACTIVE_TEXT; + right_frame_col = COL_MENUCONTENTINACTIVE_TEXT; + } + CComponentsShapeSquare col(stringstartposOption, y + 2, dx - stringstartposOption + x - 2, item_height - 4, false, right_frame_col, right_bg_col); col.setFrameThickness(3); col.setCorner(RADIUS_LARGE); col.paint(false); @@ -1174,6 +1183,7 @@ CMenuOptionNumberChooser::CMenuOptionNumberChooser(const neutrino_locale_t name, optionString = non_localized_name; numberFormat = "%d"; + numberFormatFunction = NULL; observ = Observ; slider_on = sliderOn; } @@ -1202,11 +1212,15 @@ int CMenuOptionNumberChooser::exec(CMenuTarget*) int CMenuOptionNumberChooser::paint(bool selected) { const char * l_option; - char option_value[11]; + char option_value[40]; if ((localized_value_name == NONEXISTANT_LOCALE) || ((*optionValue) != localized_value)) { - sprintf(option_value, numberFormat.c_str(), ((*optionValue) + display_offset)); + if (numberFormatFunction) { + std::string s = numberFormatFunction(*optionValue + display_offset); + strncpy(option_value, s.c_str(), s.length()); + } else + sprintf(option_value, numberFormat.c_str(), *optionValue + display_offset); l_option = option_value; } else @@ -1258,7 +1272,10 @@ int CMenuOptionNumberChooser::getWidth(void) width += (w1 > w2) ? w1 : w2; - if (numberFormat != "%d") { + if (numberFormatFunction) { + std::string s = numberFormatFunction(0); + width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(s.c_str(), true) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0", true); // arbitrary + } else if (numberFormat != "%d") { char format[numberFormat.length()]; snprintf(format, numberFormat.length(), numberFormat.c_str(), 0); width += g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth(format, true) - g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getRenderWidth("0", true); @@ -1512,6 +1529,23 @@ CMenuOptionStringChooser::CMenuOptionStringChooser(const char* OptionName, char* 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(); + optionValueString = OptionValue; + observ = Observ; + optionValueString = NULL; directKey = DirectKey; iconName = IconName; @@ -1562,8 +1596,13 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) } menu->exec(NULL, ""); ret = menu_return::RETURN_REPAINT; - if(select >= 0) - strcpy(optionValue, options[select].c_str()); + if(select >= 0) { + if (optionValueString) { + *optionValueString = options[select]; + optionValue = (char *)optionValueString->c_str(); + } else + strcpy(optionValue, options[select].c_str()); + } delete menu; delete selector; } else { @@ -1571,12 +1610,26 @@ int CMenuOptionStringChooser::exec(CMenuTarget* parent) for(unsigned int count = 0; count < options.size(); count++) { if (strcmp(options[count].c_str(), optionValue) == 0) { if(msg == CRCInput::RC_left) { - if(count > 0) - strcpy(optionValue, options[(count - 1) % options.size()].c_str()); - else - strcpy(optionValue, options[options.size() - 1].c_str()); - } else - strcpy(optionValue, options[(count + 1) % options.size()].c_str()); + 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()); + } //wantsRepaint = true; break; } @@ -1628,7 +1681,7 @@ CMenuOptionLanguageChooser::~CMenuOptionLanguageChooser() int CMenuOptionLanguageChooser::exec(CMenuTarget*) { - strncpy(g_settings.language, optionValue.c_str(), sizeof(g_settings.language)-1); + g_settings.language = optionValue; if(observ) observ->changeNotify(LOCALE_LANGUAGESETUP_SELECT, (void *) optionValue.c_str()); return menu_return::RETURN_EXIT; diff --git a/src/gui/widget/menue.h b/src/gui/widget/menue.h index 21e5e7297..886f501bd 100644 --- a/src/gui/widget/menue.h +++ b/src/gui/widget/menue.h @@ -299,7 +299,7 @@ private: 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 ); @@ -309,6 +309,7 @@ private: int isMenueOptionChooser(void) const{return 1;} int getWidth(void); void setNumberFormat(std::string format) { numberFormat = format; } + void setNumberFormat(std::string (*fun)(int)) { numberFormatFunction = fun; } }; class CMenuOptionChooser : public CAbstractMenuOptionChooser @@ -370,12 +371,14 @@ class CMenuOptionStringChooser : public CMenuItem std::string optionNameString; int height; char * optionValue; + std::string * optionValueString; std::vector options; 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(); diff --git a/src/gui/widget/mountchooser.cpp b/src/gui/widget/mountchooser.cpp index b205b99d7..ff3f25ebe 100644 --- a/src/gui/widget/mountchooser.cpp +++ b/src/gui/widget/mountchooser.cpp @@ -47,20 +47,14 @@ CMountChooser::CMountChooser(const neutrino_locale_t Name, const std::string & I char indexStr[2]; for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { - if (g_settings.network_nfs_local_dir[i] != NULL && - strcmp(g_settings.network_nfs_local_dir[i],"") != 0 && - (strstr(g_settings.network_nfs_mount_options1[i],"rw") != NULL || - strstr(g_settings.network_nfs_mount_options2[i],"rw") != NULL)) + if (!g_settings.network_nfs[i].local_dir.empty() && + (g_settings.network_nfs[i].mount_options1.find("rw") != string::npos || + g_settings.network_nfs[i].mount_options2.find("rw") != string::npos)) { - std::string s(g_settings.network_nfs_local_dir[i]); - s += " ("; - s += g_settings.network_nfs_ip[i]; - s += ":"; - s += g_settings.network_nfs_dir[i]; - s +=")"; - snprintf(indexStr,2,"%d",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()), - (strcmp(selectedLocalDir,g_settings.network_nfs_local_dir[i]) == 0)); + selectedLocalDir == g_settings.network_nfs[i].local_dir); } } } @@ -78,8 +72,9 @@ int CMountChooser::exec(CMenuTarget* parent, const std::string & actionKey) { if (index) *index = mount_id; - if (localDir) - strcpy(localDir,g_settings.network_nfs_local_dir[mount_id]); + + if (localDir.empty()) // ??? + localDir = g_settings.network_nfs[mount_id].local_dir; } hide(); return menu_return::RETURN_EXIT; diff --git a/src/gui/widget/mountchooser.h b/src/gui/widget/mountchooser.h index d8a558b0a..98966eb4b 100644 --- a/src/gui/widget/mountchooser.h +++ b/src/gui/widget/mountchooser.h @@ -52,7 +52,7 @@ class CMountChooser : public CMenuWidget { private: int * index; - char * localDir; + std::string localDir; public: diff --git a/src/gui/widget/stringinput_ext.cpp b/src/gui/widget/stringinput_ext.cpp index d7111334e..f997d4b50 100644 --- a/src/gui/widget/stringinput_ext.cpp +++ b/src/gui/widget/stringinput_ext.cpp @@ -567,9 +567,11 @@ void CDateInput::onAfterExec() } //-----------------------------#################################------------------------------------------------------- -CMACInput::CMACInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ) - : CExtendedInput(Name, Value, 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, MAC, Hint_1, Hint_2, Observ) { + mac = &Value; frameBuffer = CFrameBuffer::getInstance(); addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); addInputField( new CExtendedInput_Item_Char("0123456789ABCDEF") ); @@ -601,7 +603,7 @@ void CMACInput::onBeforeExec() return; } int _mac[6]; - sscanf( value, "%x:%x:%x:%x:%x:%x", &_mac[0], &_mac[1], &_mac[2], &_mac[3], &_mac[4], &_mac[5] ); + 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]); } @@ -611,7 +613,11 @@ void CMACInput::onAfterExec() 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) - value[0] = 0; /* strcpy(value, ""); */ + { + (*mac) = ""; + } + else + (*mac) = value; } //-----------------------------#################################------------------------------------------------------- diff --git a/src/gui/widget/stringinput_ext.h b/src/gui/widget/stringinput_ext.h index 2fe9d7fea..26e1c0d6f 100644 --- a/src/gui/widget/stringinput_ext.h +++ b/src/gui/widget/stringinput_ext.h @@ -187,12 +187,15 @@ class CDateInput : public CExtendedInput class CMACInput : public CExtendedInput { + char MAC[32]; + std::string * mac; + protected: virtual void onBeforeExec(); virtual void onAfterExec(); public: - CMACInput(const neutrino_locale_t Name, char* Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL); + CMACInput(const neutrino_locale_t Name, std::string & Value, const neutrino_locale_t Hint_1, const neutrino_locale_t Hint_2, CChangeObserver* Observ = NULL); }; //---------------------------------------------------------------------------------------------------- diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f6d178c83..41d98d131 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -137,7 +137,7 @@ char zapit_lat[20]="#"; char zapit_long[20]="#"; bool autoshift = false; uint32_t scrambled_timer; -t_channel_id standby_channel_id; +t_channel_id standby_channel_id = 0; //NEW static pthread_t timer_thread; @@ -416,11 +416,11 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.shutdown_real = configfile.getBool("shutdown_real" , false ); g_settings.shutdown_real_rcdelay = configfile.getBool("shutdown_real_rcdelay", false ); - strcpy(g_settings.shutdown_count, configfile.getString("shutdown_count","0").c_str()); + g_settings.shutdown_count = configfile.getInt32("shutdown_count", 0); - strcpy(g_settings.shutdown_min, "000"); + g_settings.shutdown_min = 0; if (can_deepstandby || cs_get_revision() == 1) - strcpy(g_settings.shutdown_min, configfile.getString("shutdown_min","180").c_str()); + g_settings.shutdown_min = configfile.getInt32("shutdown_min", 180); g_settings.sleeptimer_min = configfile.getInt32("sleeptimer_min", 0); g_settings.infobar_sat_display = configfile.getBool("infobar_sat_display" , true ); @@ -470,31 +470,30 @@ int CNeutrinoApp::loadSetup(const char * fname) for(int i = 0; i < 3; i++) { sprintf(cfg_key, "pref_lang_%d", i); - strncpy(g_settings.pref_lang[i], configfile.getString(cfg_key, "none").c_str(), 30); + g_settings.pref_lang[i] = configfile.getString(cfg_key, "none"); sprintf(cfg_key, "pref_subs_%d", i); - strncpy(g_settings.pref_subs[i], configfile.getString(cfg_key, "none").c_str(), 30); + g_settings.pref_subs[i] = configfile.getString(cfg_key, "none"); } g_settings.zap_cycle = configfile.getInt32( "zap_cycle", 0 ); - strcpy( g_settings.audio_PCMOffset, configfile.getString( "audio_PCMOffset", "0" ).c_str() ); //vcr g_settings.vcr_AutoSwitch = configfile.getBool("vcr_AutoSwitch" , true ); //language - strcpy(g_settings.language, configfile.getString("language", "").c_str()); - strcpy(g_settings.timezone, configfile.getString("timezone", "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Vienna").c_str()); + g_settings.language = configfile.getString("language", ""); + g_settings.timezone = configfile.getString("timezone", "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Vienna"); //epg dir - g_settings.epg_cache = configfile.getString("epg_cache_time", "14"); - g_settings.epg_extendedcache = configfile.getString("epg_extendedcache_time", "360"); - g_settings.epg_old_events = configfile.getString("epg_old_events", "1"); - g_settings.epg_max_events = configfile.getString("epg_max_events", "30000"); + g_settings.epg_cache = configfile.getInt32("epg_cache_time", 14); + g_settings.epg_extendedcache = configfile.getInt32("epg_extendedcache_time", 360); + g_settings.epg_old_events = configfile.getInt32("epg_old_events", 1); + g_settings.epg_max_events = configfile.getInt32("epg_max_events", 30000); g_settings.epg_dir = configfile.getString("epg_dir", "/media/sda1/epg"); // NTP-Server for sectionsd g_settings.network_ntpserver = configfile.getString("network_ntpserver", "time.fu-berlin.de"); g_settings.network_ntprefresh = configfile.getString("network_ntprefresh", "30" ); g_settings.network_ntpenable = configfile.getBool("network_ntpenable", false); - snprintf(g_settings.ifname, sizeof(g_settings.ifname), "%s", configfile.getString("ifname", "eth0").c_str());; + g_settings.ifname = configfile.getString("ifname", "eth0"); g_settings.epg_save = configfile.getBool("epg_save", false); g_settings.epg_save_standby = configfile.getBool("epg_save_standby", true); @@ -504,6 +503,11 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.widget_fade = configfile.getBool("widget_fade" , false ); //colors (neutrino defaultcolors) + g_settings.clock_Digit_alpha = configfile.getInt32( "clock_Digit_alpha", 0x00 ); + g_settings.clock_Digit_red = configfile.getInt32( "clock_Digit_red", 0x64 ); + g_settings.clock_Digit_green = configfile.getInt32( "clock_Digit_green", 0x64 ); + g_settings.clock_Digit_blue = configfile.getInt32( "clock_Digit_blue", 0x64 ); + g_settings.menu_Head_alpha = configfile.getInt32( "menu_Head_alpha", 0x00 ); g_settings.menu_Head_red = configfile.getInt32( "menu_Head_red", 0x00 ); g_settings.menu_Head_green = configfile.getInt32( "menu_Head_green", 0x0A ); @@ -569,53 +573,46 @@ int CNeutrinoApp::loadSetup(const char * fname) //network for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { - sprintf(cfg_key, "network_nfs_ip_%d", i); - g_settings.network_nfs_ip[i] = configfile.getString(cfg_key, ""); - sprintf(cfg_key, "network_nfs_dir_%d", i); - strcpy( g_settings.network_nfs_dir[i], configfile.getString( cfg_key, "" ).c_str() ); - sprintf(cfg_key, "network_nfs_local_dir_%d", i); - strcpy( g_settings.network_nfs_local_dir[i], configfile.getString( cfg_key, "" ).c_str() ); - sprintf(cfg_key, "network_nfs_automount_%d", i); - g_settings.network_nfs_automount[i] = configfile.getInt32( cfg_key, 0); - sprintf(cfg_key, "network_nfs_type_%d", i); - g_settings.network_nfs_type[i] = configfile.getInt32( cfg_key, 0); - sprintf(cfg_key,"network_nfs_username_%d", i); - strcpy( g_settings.network_nfs_username[i], configfile.getString( cfg_key, "" ).c_str() ); - sprintf(cfg_key, "network_nfs_password_%d", i); - strcpy( g_settings.network_nfs_password[i], configfile.getString( cfg_key, "" ).c_str() ); - sprintf(cfg_key, "network_nfs_mount_options1_%d", i); - strcpy( g_settings.network_nfs_mount_options1[i], configfile.getString( cfg_key, "ro,soft,udp" ).c_str() ); - sprintf(cfg_key, "network_nfs_mount_options2_%d", i); - strcpy( g_settings.network_nfs_mount_options2[i], configfile.getString( cfg_key, "nolock,rsize=8192,wsize=8192" ).c_str() ); - sprintf(cfg_key, "network_nfs_mac_%d", i); - strcpy( g_settings.network_nfs_mac[i], configfile.getString( cfg_key, "11:22:33:44:55:66").c_str() ); + std::string i_str(to_string(i)); + g_settings.network_nfs[i].ip = configfile.getString("network_nfs_ip_" + i_str, ""); + g_settings.network_nfs[i].dir = configfile.getString("network_nfs_dir_" + i_str, ""); + g_settings.network_nfs[i].local_dir = configfile.getString("network_nfs_local_dir_" + i_str, ""); + if (g_settings.network_nfs[i].local_dir.empty()) + g_settings.network_nfs[i].local_dir = "/mnt/mnt" + i_str; + g_settings.network_nfs[i].automount = configfile.getInt32("network_nfs_automount_" + i_str, 0); + g_settings.network_nfs[i].type = configfile.getInt32("network_nfs_type_" + i_str, 0); + g_settings.network_nfs[i].username = configfile.getString("network_nfs_username_" + i_str, "" ); + g_settings.network_nfs[i].password = configfile.getString("network_nfs_password_" + i_str, "" ); + g_settings.network_nfs[i].mount_options1 = configfile.getString("network_nfs_mount_options1_" + i_str, "ro,soft,udp" ); + g_settings.network_nfs[i].mount_options2 = configfile.getString("network_nfs_mount_options2_" + i_str, "nolock,rsize=8192,wsize=8192" ); + g_settings.network_nfs[i].mac = configfile.getString("network_nfs_mac_" + i_str, "11:22:33:44:55:66"); } - strcpy( g_settings.network_nfs_audioplayerdir, configfile.getString( "network_nfs_audioplayerdir", "/media/sda1/music" ).c_str() ); - strcpy( g_settings.network_nfs_picturedir, configfile.getString( "network_nfs_picturedir", "/media/sda1/pictures" ).c_str() ); - strcpy( g_settings.network_nfs_moviedir, configfile.getString( "network_nfs_moviedir", "/media/sda1/movies" ).c_str() ); - strcpy( g_settings.network_nfs_recordingdir, configfile.getString( "network_nfs_recordingdir", "/media/sda1/movies" ).c_str() ); - strcpy( g_settings.timeshiftdir, configfile.getString( "timeshiftdir", "" ).c_str() ); + g_settings.network_nfs_audioplayerdir = configfile.getString( "network_nfs_audioplayerdir", "/media/sda1/music" ); + g_settings.network_nfs_picturedir = configfile.getString( "network_nfs_picturedir", "/media/sda1/pictures" ); + g_settings.network_nfs_moviedir = configfile.getString( "network_nfs_moviedir", "/media/sda1/movies" ); + g_settings.network_nfs_recordingdir = configfile.getString( "network_nfs_recordingdir", "/media/sda1/movies" ); + g_settings.timeshiftdir = configfile.getString( "timeshiftdir", "" ); g_settings.temp_timeshift = configfile.getInt32( "temp_timeshift", 0 ); g_settings.auto_timeshift = configfile.getInt32( "auto_timeshift", 0 ); g_settings.auto_delete = configfile.getInt32( "auto_delete", 1 ); - char timeshiftDir[255]; - if(strlen(g_settings.timeshiftdir) == 0) { - sprintf(timeshiftDir, "%s/.timeshift", g_settings.network_nfs_recordingdir); - safe_mkdir(timeshiftDir); + std::string timeshiftDir; + if(g_settings.timeshiftdir.empty()) { + timeshiftDir = g_settings.network_nfs_recordingdir + "/.timeshift"; + safe_mkdir(timeshiftDir.c_str()); } else { - if(strcmp(g_settings.timeshiftdir, g_settings.network_nfs_recordingdir)) - strncpy(timeshiftDir, g_settings.timeshiftdir, sizeof(timeshiftDir)); + if(g_settings.timeshiftdir != g_settings.network_nfs_recordingdir) + timeshiftDir = g_settings.timeshiftdir; else - sprintf(timeshiftDir, "%s/.timeshift", g_settings.network_nfs_recordingdir); + timeshiftDir = g_settings.network_nfs_recordingdir + "/.timeshift"; } - printf("***************************** rec dir %s timeshift dir %s\n", g_settings.network_nfs_recordingdir, timeshiftDir); - CRecordManager::getInstance()->SetTimeshiftDirectory(timeshiftDir); + printf("***************************** rec dir %s timeshift dir %s\n", g_settings.network_nfs_recordingdir.c_str(), timeshiftDir.c_str()); + CRecordManager::getInstance()->SetTimeshiftDirectory(timeshiftDir.c_str()); if(g_settings.auto_delete) { - if(strcmp(g_settings.timeshiftdir, g_settings.network_nfs_recordingdir)) { - DIR *d = opendir(timeshiftDir); + if(g_settings.timeshiftdir == g_settings.network_nfs_recordingdir) { + DIR *d = opendir(timeshiftDir.c_str()); if(d){ while (struct dirent *e = readdir(d)) { @@ -740,10 +737,10 @@ int CNeutrinoApp::loadSetup(const char * fname) strcpy(g_settings.softupdate_proxyusername, configfile.getString("softupdate_proxyusername", "" ).c_str()); strcpy(g_settings.softupdate_proxypassword, configfile.getString("softupdate_proxypassword", "" ).c_str()); // - strcpy( g_settings.font_file, configfile.getString( "font_file", FONTDIR"/neutrino.ttf" ).c_str() ); - strcpy( g_settings.ttx_font_file, configfile.getString( "ttx_font_file", FONTDIR"/DejaVuLGCSansMono-Bold.ttf" ).c_str() ); - ttx_font_file = g_settings.ttx_font_file; - strcpy( g_settings.update_dir, configfile.getString( "update_dir", "/tmp" ).c_str() ); + 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"); + ttx_font_file = g_settings.ttx_font_file.c_str(); + g_settings.update_dir = configfile.getString("update_dir", "/tmp"); // parentallock if (!parentallocked) { @@ -766,14 +763,14 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.lcd_info_line = configfile.getInt32("lcd_info_line", 0);//channel name or clock //Picture-Viewer - strcpy( g_settings.picviewer_slide_time, configfile.getString( "picviewer_slide_time", "10" ).c_str() ); + g_settings.picviewer_slide_time = configfile.getInt32( "picviewer_slide_time", 10); g_settings.picviewer_scaling = configfile.getInt32("picviewer_scaling", 1 /*(int)CPictureViewer::SIMPLE*/); g_settings.picviewer_decode_server_ip = configfile.getString("picviewer_decode_server_ip", ""); //Audio-Player g_settings.audioplayer_display = configfile.getInt32("audioplayer_display",(int)CAudioPlayerGui::ARTIST_TITLE); g_settings.audioplayer_follow = configfile.getInt32("audioplayer_follow",0); - strcpy( g_settings.audioplayer_screensaver, configfile.getString( "audioplayer_screensaver", "1" ).c_str() ); + g_settings.audioplayer_screensaver = configfile.getInt32("audioplayer_screensaver", 1); g_settings.audioplayer_highprio = configfile.getInt32("audioplayer_highprio",0); g_settings.audioplayer_select_title_by_name = configfile.getInt32("audioplayer_select_title_by_name",0); g_settings.audioplayer_repeat_on = configfile.getInt32("audioplayer_repeat_on",0); @@ -958,8 +955,8 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32( "hdd_noise", g_settings.hdd_noise); configfile.setBool("shutdown_real" , g_settings.shutdown_real ); configfile.setBool("shutdown_real_rcdelay", g_settings.shutdown_real_rcdelay); - configfile.setString("shutdown_count" , g_settings.shutdown_count); - configfile.setString("shutdown_min" , g_settings.shutdown_min ); + configfile.setInt32("shutdown_count" , g_settings.shutdown_count); + configfile.setInt32("shutdown_min" , g_settings.shutdown_min ); configfile.setInt32("sleeptimer_min", g_settings.sleeptimer_min); configfile.setBool("infobar_sat_display" , g_settings.infobar_sat_display ); configfile.setBool("infobar_show_channeldesc" , g_settings.infobar_show_channeldesc ); @@ -993,7 +990,6 @@ void CNeutrinoApp::saveSetup(const char * fname) sprintf(cfg_key, "pref_subs_%d", i); configfile.setString(cfg_key, g_settings.pref_subs[i]); } - configfile.setString( "audio_PCMOffset", g_settings.audio_PCMOffset ); //vcr configfile.setBool("vcr_AutoSwitch" , g_settings.vcr_AutoSwitch ); @@ -1005,10 +1001,10 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setBool("epg_save", g_settings.epg_save); configfile.setBool("epg_save_standby", g_settings.epg_save_standby); configfile.setInt32("epg_scan", g_settings.epg_scan); - configfile.setString("epg_cache_time" ,g_settings.epg_cache ); - configfile.setString("epg_extendedcache_time" ,g_settings.epg_extendedcache); - configfile.setString("epg_old_events" ,g_settings.epg_old_events ); - configfile.setString("epg_max_events" ,g_settings.epg_max_events ); + configfile.setInt32("epg_cache_time" ,g_settings.epg_cache ); + configfile.setInt32("epg_extendedcache_time" ,g_settings.epg_extendedcache); + configfile.setInt32("epg_old_events" ,g_settings.epg_old_events ); + configfile.setInt32("epg_max_events" ,g_settings.epg_max_events ); configfile.setString("epg_dir" ,g_settings.epg_dir); // NTP-Server for sectionsd @@ -1022,6 +1018,11 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setBool("widget_fade" , g_settings.widget_fade ); //colors + configfile.setInt32( "clock_Digit_alpha", g_settings.clock_Digit_alpha ); + configfile.setInt32( "clock_Digit_red", g_settings.clock_Digit_red ); + configfile.setInt32( "clock_Digit_green", g_settings.clock_Digit_green ); + configfile.setInt32( "clock_Digit_blue", g_settings.clock_Digit_blue ); + configfile.setInt32( "menu_Head_alpha", g_settings.menu_Head_alpha ); configfile.setInt32( "menu_Head_red", g_settings.menu_Head_red ); configfile.setInt32( "menu_Head_green", g_settings.menu_Head_green ); @@ -1088,25 +1089,25 @@ void CNeutrinoApp::saveSetup(const char * fname) //network for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { sprintf(cfg_key, "network_nfs_ip_%d", i); - configfile.setString( cfg_key, g_settings.network_nfs_ip[i] ); + configfile.setString(cfg_key, g_settings.network_nfs[i].ip); sprintf(cfg_key, "network_nfs_dir_%d", i); - configfile.setString( cfg_key, g_settings.network_nfs_dir[i] ); + configfile.setString(cfg_key, g_settings.network_nfs[i].dir); sprintf(cfg_key, "network_nfs_local_dir_%d", i); - configfile.setString( cfg_key, g_settings.network_nfs_local_dir[i] ); + configfile.setString(cfg_key, g_settings.network_nfs[i].local_dir); sprintf(cfg_key, "network_nfs_automount_%d", i); - configfile.setInt32( cfg_key, g_settings.network_nfs_automount[i]); + configfile.setInt32(cfg_key, g_settings.network_nfs[i].automount); sprintf(cfg_key, "network_nfs_type_%d", i); - configfile.setInt32( cfg_key, g_settings.network_nfs_type[i]); - sprintf(cfg_key,"network_nfs_username_%d", i); - configfile.setString( cfg_key, g_settings.network_nfs_username[i] ); + configfile.setInt32(cfg_key, g_settings.network_nfs[i].type); + sprintf(cfg_key, "network_nfs_username_%d", i); + configfile.setString(cfg_key, g_settings.network_nfs[i].username); sprintf(cfg_key, "network_nfs_password_%d", i); - configfile.setString( cfg_key, g_settings.network_nfs_password[i] ); + configfile.setString(cfg_key, g_settings.network_nfs[i].password); sprintf(cfg_key, "network_nfs_mount_options1_%d", i); - configfile.setString( cfg_key, g_settings.network_nfs_mount_options1[i]); + configfile.setString(cfg_key, g_settings.network_nfs[i].mount_options1); sprintf(cfg_key, "network_nfs_mount_options2_%d", i); - configfile.setString( cfg_key, g_settings.network_nfs_mount_options2[i]); + configfile.setString(cfg_key, g_settings.network_nfs[i].mount_options2); sprintf(cfg_key, "network_nfs_mac_%d", i); - configfile.setString( cfg_key, g_settings.network_nfs_mac[i]); + configfile.setString(cfg_key, g_settings.network_nfs[i].mac); } configfile.setString( "network_nfs_audioplayerdir", g_settings.network_nfs_audioplayerdir); configfile.setString( "network_nfs_picturedir", g_settings.network_nfs_picturedir); @@ -1224,7 +1225,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32("lcd_info_line", g_settings.lcd_info_line);//channel name or clock //Picture-Viewer - configfile.setString( "picviewer_slide_time", g_settings.picviewer_slide_time ); + configfile.setInt32( "picviewer_slide_time", g_settings.picviewer_slide_time); configfile.setInt32( "picviewer_scaling", g_settings.picviewer_scaling ); configfile.setString( "picviewer_decode_server_ip", g_settings.picviewer_decode_server_ip ); configfile.setString( "picviewer_decode_server_port", g_settings.picviewer_decode_server_port); @@ -1232,7 +1233,7 @@ void CNeutrinoApp::saveSetup(const char * fname) //Audio-Player configfile.setInt32( "audioplayer_display", g_settings.audioplayer_display ); configfile.setInt32( "audioplayer_follow", g_settings.audioplayer_follow ); - configfile.setString( "audioplayer_screensaver", g_settings.audioplayer_screensaver ); + configfile.setInt32( "audioplayer_screensaver", g_settings.audioplayer_screensaver ); configfile.setInt32( "audioplayer_highprio", g_settings.audioplayer_highprio ); configfile.setInt32( "audioplayer_select_title_by_name", g_settings.audioplayer_select_title_by_name ); configfile.setInt32( "audioplayer_repeat_on", g_settings.audioplayer_repeat_on ); @@ -1665,22 +1666,16 @@ void CNeutrinoApp::SetupFonts(int fmode) /************************************************************************************** * CNeutrinoApp - setup the menu timouts * **************************************************************************************/ -void CNeutrinoApp::SetupTiming() -{ - for (int i = 0; i < SNeutrinoSettings::TIMING_SETTING_COUNT; i++) - sprintf(g_settings.timing_string[i], "%d", g_settings.timing[i]); -} - #define LCD_UPDATE_TIME_RADIO_MODE (6 * 1000 * 1000) #define LCD_UPDATE_TIME_TV_MODE (60 * 1000 * 1000) void CNeutrinoApp::MakeSectionsdConfig(CSectionsdClient::epg_config& config) { - config.epg_cache = atoi(g_settings.epg_cache.c_str()); - config.epg_old_events = atoi(g_settings.epg_old_events.c_str()); - config.epg_max_events = atoi(g_settings.epg_max_events.c_str()); - config.epg_extendedcache = atoi(g_settings.epg_extendedcache.c_str()); + config.epg_cache = g_settings.epg_cache; + config.epg_old_events = g_settings.epg_old_events; + config.epg_max_events = g_settings.epg_max_events; + config.epg_extendedcache = g_settings.epg_extendedcache; config.epg_dir = g_settings.epg_dir; config.network_ntpserver = g_settings.network_ntpserver; config.network_ntprefresh = atoi(g_settings.network_ntprefresh.c_str()); @@ -1876,19 +1871,17 @@ fprintf(stderr, "[neutrino start] %d -> %5ld ms\n", __LINE__, time_monotonic_ms initialize_iso639_map(); bool show_startwizard = false; - CLocaleManager::loadLocale_ret_t loadLocale_ret = g_Locale->loadLocale(g_settings.language); + CLocaleManager::loadLocale_ret_t loadLocale_ret = g_Locale->loadLocale(g_settings.language.c_str()); if (loadLocale_ret == CLocaleManager::NO_SUCH_LOCALE) { - strcpy(g_settings.language, "english"); - loadLocale_ret = g_Locale->loadLocale(g_settings.language); + g_settings.language = "english"; + loadLocale_ret = g_Locale->loadLocale(g_settings.language.c_str()); show_startwizard = true; } fprintf(stderr, "[neutrino start] %d -> %5ld ms\n", __LINE__, time_monotonic_ms() - starttime); /* setup GUI */ neutrinoFonts = CNeutrinoFonts::getInstance(); SetupFonts(); -fprintf(stderr, "[neutrino start] %d -> %5ld ms\n", __LINE__, time_monotonic_ms() - starttime); - SetupTiming(); fprintf(stderr, "[neutrino start] %d -> %5ld ms\n", __LINE__, time_monotonic_ms() - starttime); g_PicViewer = new CPictureViewer(); CColorSetupNotifier::setPalette(); @@ -2158,13 +2151,14 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu) ShowMsgUTF(LOCALE_PLUGINS_RESULT, g_PluginList->getScriptOutput(), CMessageBox::mbrBack,CMessageBox::mbBack,NEUTRINO_ICON_SHELL); } g_RCInput->clearRCMsg(); - if(g_settings.power_standby || init_cec_setting) - standbyMode(true, true); InfoClock = CInfoClock::getInstance(); if(g_settings.mode_clock) g_settings.mode_clock = InfoClock->StartClock(); + if(g_settings.power_standby || init_cec_setting) + standbyMode(true, true); + //cCA::GetInstance()->Ready(true); while( true ) { @@ -2652,11 +2646,8 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) struct timeval endtime; time_t seconds; - int timeout = 0; - int timeout1 = 0; - - sscanf(g_settings.repeat_blocker, "%d", &timeout); - sscanf(g_settings.repeat_genericblocker, "%d", &timeout1); + int timeout = g_settings.repeat_blocker; + int timeout1 = g_settings.repeat_genericblocker; if (timeout1 > timeout) timeout = timeout1; @@ -2815,6 +2806,12 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) if(!CRecordManager::getInstance()->RecordingStatus() && (!data)) { if(mode == mode_standby) { + // zap back to pre-recording channel if necessary + t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID(); + if (standby_channel_id && (live_channel_id != standby_channel_id)) { + live_channel_id = standby_channel_id; + channelList->zapTo_ChannelID(live_channel_id); + } /* do not put zapit to standby, if epg scan not finished */ if (!CEpgScan::getInstance()->Running()) g_Zapit->setStandby(true); @@ -2929,15 +2926,15 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data) if (g_settings.recording_type == RECORDING_FILE) { char * recordingDir = eventinfo->recordingDir; for(int i=0 ; i < NETWORK_NFS_NR_OF_ENTRIES ; i++) { - if (strcmp(g_settings.network_nfs_local_dir[i],recordingDir) == 0) { - printf("[neutrino] waking up %s (%s)\n",g_settings.network_nfs_ip[i].c_str(),recordingDir); - if (my_system(2, "ether-wake", g_settings.network_nfs_mac[i]) != 0) + if (g_settings.network_nfs[i].local_dir == recordingDir) { + printf("[neutrino] waking up %s (%s)\n", g_settings.network_nfs[i].ip.c_str(), recordingDir); + if (my_system(2, "ether-wake", g_settings.network_nfs[i].mac.c_str()) != 0) perror("ether-wake failed"); break; } } if(has_hdd) { - wakeup_hdd(g_settings.network_nfs_recordingdir); + wakeup_hdd(g_settings.network_nfs_recordingdir.c_str()); } } @@ -3789,7 +3786,7 @@ int CNeutrinoApp::exec(CMenuTarget* parent, const std::string & actionKey) else if(actionKey == "moviedir") { parent->hide(); - chooserDir(g_settings.network_nfs_moviedir, false, NULL, sizeof(g_settings.network_nfs_moviedir)-1); + chooserDir(g_settings.network_nfs_moviedir, false, NULL); return menu_return::RETURN_REPAINT; } @@ -3847,7 +3844,7 @@ bool CNeutrinoApp::changeNotify(const neutrino_locale_t OptionName, void * /*dat { if (ARE_LOCALES_EQUAL(OptionName, LOCALE_LANGUAGESETUP_SELECT)) { - g_Locale->loadLocale(g_settings.language); + g_Locale->loadLocale(g_settings.language.c_str()); return true; } return false; @@ -4051,8 +4048,8 @@ void CNeutrinoApp::loadKeys(const char * fname) g_settings.menu_left_exit = tconfig.getInt32( "menu_left_exit", 0 ); g_settings.audio_run_player = tconfig.getInt32( "audio_run_player", 1 ); g_settings.key_click = tconfig.getInt32( "key_click", 1 ); - strcpy(g_settings.repeat_blocker, tconfig.getString("repeat_blocker", "450").c_str()); - strcpy(g_settings.repeat_genericblocker, tconfig.getString("repeat_genericblocker", "100").c_str()); + g_settings.repeat_blocker = tconfig.getInt32("repeat_blocker", 450); + g_settings.repeat_genericblocker = tconfig.getInt32("repeat_genericblocker", 100); g_settings.bouquetlist_mode = tconfig.getInt32( "bouquetlist_mode", 0 ); g_settings.sms_channel = tconfig.getInt32( "sms_channel", 0 ); @@ -4118,8 +4115,8 @@ void CNeutrinoApp::saveKeys(const char * fname) tconfig.setInt32( "menu_left_exit", g_settings.menu_left_exit ); tconfig.setInt32( "audio_run_player", g_settings.audio_run_player ); tconfig.setInt32( "key_click", g_settings.key_click ); - tconfig.setString( "repeat_blocker", g_settings.repeat_blocker ); - tconfig.setString( "repeat_genericblocker", g_settings.repeat_genericblocker ); + tconfig.setInt32( "repeat_blocker", g_settings.repeat_blocker ); + tconfig.setInt32( "repeat_genericblocker", g_settings.repeat_genericblocker ); tconfig.setInt32( "bouquetlist_mode", g_settings.bouquetlist_mode ); tconfig.setInt32( "sms_channel", g_settings.sms_channel ); @@ -4163,7 +4160,7 @@ void CNeutrinoApp::SelectSubtitles() return; for(int i = 0; i < 3; i++) { - if(strlen(g_settings.pref_subs[i]) == 0 || !strcmp(g_settings.pref_subs[i], "none")) + if(g_settings.pref_subs[i].empty() || g_settings.pref_subs[i] == "none") continue; std::string temp(g_settings.pref_subs[i]); diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index 9a670c427..295a5b947 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -1095,6 +1095,11 @@ void CControlAPI::GetBouquetsCGI(CyhookHandler *hh) { fav = true; int mode = NeutrinoAPI->Zapit->getMode(); + if (hh->ParamList["mode"].compare("TV") == 0) + mode = CZapitClient::MODE_TV; + else if (hh->ParamList["mode"].compare("RADIO") == 0) + mode = CZapitClient::MODE_RADIO; + std::string bouquet; for (int i = 0, size = (int) g_bouquetManager->Bouquets.size(); i < size; i++) { std::string item = ""; diff --git a/src/nhttpd/web/Y_Blocks.txt b/src/nhttpd/web/Y_Blocks.txt index e604de86b..f10a0d762 100644 --- a/src/nhttpd/web/Y_Blocks.txt +++ b/src/nhttpd/web/Y_Blocks.txt @@ -73,7 +73,6 @@ start-block~video_audio_save_settings {=ini-set:/var/tuxbox/config/neutrino.conf;audio_left_right_selectable;{=audio_left_right_selectable=}~cache=} {=ini-set:/var/tuxbox/config/neutrino.conf;audio_avs_Control;{=h_audio_avs_Control=}~cache=} {=ini-set:/var/tuxbox/config/neutrino.conf;audio_DolbyDigital;{=audio_DolbyDigital=}~cache=} -{=ini-set:/var/tuxbox/config/neutrino.conf;audio_PCMOffset;{=audio_PCMOffset=}~cache=} {=ini-set:/var/tuxbox/config/neutrino.conf;audio_step;{=audio_step=}~save=} {=ini-set:/var/tuxbox/config/controld.conf;vcroutput;{=h_vcroutput=}~open=} {=ini-set:/var/tuxbox/config/controld.conf;videooutput;{=h_videooutput=}~save=} diff --git a/src/nhttpd/web/Y_Settings_video_audio.yhtm b/src/nhttpd/web/Y_Settings_video_audio.yhtm index d35642433..0f7a6ee9a 100644 --- a/src/nhttpd/web/Y_Settings_video_audio.yhtm +++ b/src/nhttpd/web/Y_Settings_video_audio.yhtm @@ -33,8 +33,6 @@ function do_init() obj_set_radio_value('audio_DolbyDigital', "{=ini-get:/var/tuxbox/config/neutrino.conf;audio_DolbyDigital;false~cache=}"); val = "{=ini-get:/var/tuxbox/config/neutrino.conf;audio_avs_Control;1~cache=}"; document.f.audio_avs_Control.selectedIndex = val; - val = "{=ini-get:/var/tuxbox/config/neutrino.conf;audio_PCMOffset;0~cache=}" - document.f.audio_PCMOffset.value = val; val = "{=ini-get:/var/tuxbox/config/neutrino.conf;audio_step;5~cache=}" document.f.audio_step.value = val; } @@ -165,11 +163,6 @@ function do_submit() (*) - Lautstärkeabsenkung PCM - - - - Lautstärke Schrittweite diff --git a/src/system/configure_network.cpp b/src/system/configure_network.cpp index b62728c39..59c2427bb 100644 --- a/src/system/configure_network.cpp +++ b/src/system/configure_network.cpp @@ -34,10 +34,7 @@ CNetworkConfig::CNetworkConfig() { - char our_nameserver[16]; - - netGetNameserver(our_nameserver); - nameserver = our_nameserver; + netGetNameserver(nameserver); ifname = "eth0"; orig_automatic_start = false; orig_inet_static = false; @@ -73,13 +70,13 @@ void CNetworkConfig::readConfig(std::string iname) void CNetworkConfig::init_vars(void) { - char mask[16]; - char _broadcast[16]; - char router[16]; - char ip[16]; + std::string mask; + std::string _broadcast; + std::string router; + std::string ip; unsigned char addr[6]; - hostname = netGetHostname(); + netGetHostname(hostname); netGetDefaultRoute(router); gateway = router; @@ -87,13 +84,13 @@ void CNetworkConfig::init_vars(void) /* FIXME its enough to read IP for dhcp only ? * static config should not be different from settings in etc/network/interfaces */ if(!inet_static) { - netGetIP((char *) ifname.c_str(), ip, mask, _broadcast); + netGetIP(ifname, ip, mask, _broadcast); netmask = mask; broadcast = _broadcast; address = ip; } - netGetMacAddr((char *) ifname.c_str(), addr); + netGetMacAddr(ifname, addr); std::stringstream mac_tmp; for(int i=0;i<6;++i) @@ -190,7 +187,7 @@ void CNetworkConfig::commitConfig(void) printf("CNetworkConfig::commitConfig: modified, saving (wireless %d, ssid %s key %s)...\n", wireless, ssid.c_str(), key.c_str()); #endif if(orig_hostname != hostname) - netSetHostname((char *) hostname.c_str()); + netSetHostname(hostname); if (inet_static) { @@ -211,7 +208,7 @@ void CNetworkConfig::commitConfig(void) if (nameserver != orig_nameserver) { orig_nameserver = nameserver; - netSetNameserver(nameserver.c_str()); + netSetNameserver(nameserver); } } diff --git a/src/system/fsmounter.cpp b/src/system/fsmounter.cpp index d8d384220..beac75691 100644 --- a/src/system/fsmounter.cpp +++ b/src/system/fsmounter.cpp @@ -155,10 +155,10 @@ CFSMounter::FS_Support CFSMounter::fsSupported(const CFSMounter::FSType fstype, return CFSMounter::FS_UNSUPPORTED; } -bool CFSMounter::isMounted(const char * const local_dir) +bool CFSMounter::isMounted(const std::string &local_dir) { std::ifstream in; - if (local_dir == NULL) + if (local_dir.empty()) return false; #ifdef PATH_MAX @@ -166,8 +166,8 @@ bool CFSMounter::isMounted(const char * const local_dir) #else char mount_point[4096]; #endif - if (realpath(local_dir, mount_point) == NULL) { - printf("[CFSMounter] could not resolve dir: %s: %s\n",local_dir, strerror(errno)); + if (realpath(local_dir.c_str(), mount_point) == NULL) { + printf("[CFSMounter] could not resolve dir: %s: %s\n",local_dir.c_str(), strerror(errno)); return false; } in.open("/proc/mounts", std::ifstream::in); @@ -184,9 +184,9 @@ bool CFSMounter::isMounted(const char * const local_dir) return false; } -CFSMounter::MountRes CFSMounter::mount(const char * const ip, const char * const dir, const char * const local_dir, - const FSType fstype, const char * const username, const char * const password, - char * options1, char * options2) +CFSMounter::MountRes CFSMounter::mount(const std::string &ip, const std::string &dir, const std::string &local_dir, + const FSType fstype, const std::string &username, const std::string &password, + std::string options1, std::string options2) { std::string cmd; pthread_mutex_init(&g_mut, NULL); @@ -201,36 +201,36 @@ CFSMounter::MountRes CFSMounter::mount(const char * const ip, const char * const return MRES_FS_NOT_SUPPORTED; } - printf("[CFSMounter] Mount(%d) %s:%s -> %s\n", (int) fstype, ip, dir, local_dir); + printf("[CFSMounter] Mount(%d) %s:%s -> %s\n", (int) fstype, ip.c_str(), dir.c_str(), local_dir.c_str()); if (isMounted(local_dir)) { - printf("[CFSMounter] FS mount error %s already mounted\n", local_dir); + printf("[CFSMounter] FS mount error %s already mounted\n", local_dir.c_str()); return MRES_FS_ALREADY_MOUNTED; } - if(options1[0] == '\0') + if(options1.empty()) { - strcpy(options1,options2); - options2[0] = '\0'; + options1 = options2; + options2 = ""; } - if((options1[0] == '\0') && (options2[0] == '\0')) + if(options1.empty() && options2.empty()) { if(fstype == NFS) { - strcpy(options1,"ro,soft,udp"); - strcpy(options2,"nolock,rsize=8192,wsize=8192"); + options1 = "ro,soft,udp"; + options2 = "nolock,rsize=8192,wsize=8192"; } else if(fstype == CIFS) { - strcpy(options1,"ro"); - strcpy(options2,""); + options1 = "ro"; + options2 = ""; } else if(fstype == LUFS) { - strcpy(options1,""); - strcpy(options2,""); + options1 = ""; + options2 = ""; } } @@ -315,12 +315,12 @@ bool CFSMounter::automount() bool res = true; for(int i = 0; i < NETWORK_NFS_NR_OF_ENTRIES; i++) { - if(g_settings.network_nfs_automount[i]) + if(g_settings.network_nfs[i].automount) { - res = (MRES_OK == mount(g_settings.network_nfs_ip[i].c_str(), g_settings.network_nfs_dir[i], g_settings.network_nfs_local_dir[i], - (FSType) g_settings.network_nfs_type[i], g_settings.network_nfs_username[i], - g_settings.network_nfs_password[i], g_settings.network_nfs_mount_options1[i], - g_settings.network_nfs_mount_options2[i])) && res; + res = (MRES_OK == mount(g_settings.network_nfs[i].ip, g_settings.network_nfs[i].dir, g_settings.network_nfs[i].local_dir, + (FSType) g_settings.network_nfs[i].type, g_settings.network_nfs[i].username, + g_settings.network_nfs[i].password, g_settings.network_nfs[i].mount_options1, + g_settings.network_nfs[i].mount_options2)) && res; } } return res; diff --git a/src/system/fsmounter.h b/src/system/fsmounter.h index 35d133636..6cd6a2a9d 100644 --- a/src/system/fsmounter.h +++ b/src/system/fsmounter.h @@ -91,10 +91,10 @@ class CFSMounter */ public: CFSMounter(); - static bool isMounted(const char * const local_dir); - static CFSMounter::MountRes mount(const char * const ip, const char * const dir, const char * const local_dir, - const FSType fstype, const char * const username, const char * const password, - char * options1, char * options2); + static bool isMounted(const std::string &local_dir); + static CFSMounter::MountRes mount(const std::string &ip, const std::string &dir, const std::string &local_dir, + const FSType fstype, const std::string &username, const std::string &password, + std::string options1, std::string options2); static bool automount(); static CFSMounter::UMountRes umount(const char * const dir = NULL); static void getMountedFS(MountInfos& fs); diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index f1ad53548..a0e9e003c 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -539,14 +539,8 @@ bool CFileHelpers::createDir(const char *Dir, mode_t mode) createDir(dirPath, mode); } } - else { - if (ret == 0) - return true; - if (errno == EEXIST) - return true; - else - return false; - } + else + return !ret || (errno == EEXIST); } errno = 0; return true; diff --git a/src/system/locals.h b/src/system/locals.h index b8fb0fc24..f3573b6f9 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -293,6 +293,7 @@ typedef enum LOCALE_COLORCHOOSER_GREEN, LOCALE_COLORCHOOSER_RED, LOCALE_COLORMENU_BACKGROUND, + LOCALE_COLORMENU_CLOCK_TEXTCOLOR, LOCALE_COLORMENU_CONTRAST_FONTS, LOCALE_COLORMENU_FADE, LOCALE_COLORMENU_FONT, @@ -844,6 +845,7 @@ typedef enum LOCALE_MENU_HINT_CLOCK_MODE, LOCALE_MENU_HINT_CLOCK_SECONDS, LOCALE_MENU_HINT_CLOCK_SIZE, + LOCALE_MENU_HINT_CLOCK_TEXTCOLOR, LOCALE_MENU_HINT_COLORS, LOCALE_MENU_HINT_CONTENT_BACK, LOCALE_MENU_HINT_CONTENT_TEXTCOLOR, @@ -1032,6 +1034,7 @@ typedef enum LOCALE_MENU_HINT_OSD, LOCALE_MENU_HINT_OSD_LANGUAGE, LOCALE_MENU_HINT_OSD_PRESET, + LOCALE_MENU_HINT_OSD_TIMING, LOCALE_MENU_HINT_PARENTALLOCK_CHANGEPIN, LOCALE_MENU_HINT_PARENTALLOCK_LOCKAGE, LOCALE_MENU_HINT_PARENTALLOCK_MENU, @@ -1720,8 +1723,6 @@ typedef enum LOCALE_RECORDINGMENU_VTXT_PID, LOCALE_RECORDINGMENU_ZAP_ON_ANNOUNCE, LOCALE_RECORDTIMER_ANNOUNCE, - LOCALE_REPEATBLOCKER_HINT_1, - LOCALE_REPEATBLOCKER_HINT_2, LOCALE_RESET_ALL, LOCALE_RESET_CHANNELS, LOCALE_RESET_CONFIRM, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 808e8fe4b..e7ce80868 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -293,6 +293,7 @@ const char * locale_real_names[] = "colorchooser.green", "colorchooser.red", "colormenu.background", + "colormenu.clock_textcolor", "colormenu.contrast_fonts", "colormenu.fade", "colormenu.font", @@ -844,6 +845,7 @@ const char * locale_real_names[] = "menu.hint_clock_mode", "menu.hint_clock_seconds", "menu.hint_clock_size", + "menu.hint_clock_textcolor", "menu.hint_colors", "menu.hint_content_back", "menu.hint_content_textcolor", @@ -1032,6 +1034,7 @@ const char * locale_real_names[] = "menu.hint_osd", "menu.hint_osd_language", "menu.hint_osd_preset", + "menu.hint_osd_timing", "menu.hint_parentallock_changepin", "menu.hint_parentallock_lockage", "menu.hint_parentallock_menu", @@ -1720,8 +1723,6 @@ const char * locale_real_names[] = "recordingmenu.vtxt_pid", "recordingmenu.zap_on_announce", "recordtimer.announce", - "repeatblocker.hint_1", - "repeatblocker.hint_2", "reset_all", "reset_channels", "reset_confirm", diff --git a/src/system/mtdutils/Makefile.am b/src/system/mtdutils/Makefile.am index 42426fee2..a95d77890 100644 --- a/src/system/mtdutils/Makefile.am +++ b/src/system/mtdutils/Makefile.am @@ -14,7 +14,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/lib/libconfigfile \ -I$(top_srcdir)/lib/libmd5sum \ -I$(top_srcdir)/lib/xmltree \ - -I$(top_srcdir)/src/system/mtdutils/include + -I$(top_srcdir)/src/system/mtdutils/include \ @FREETYPE_CFLAGS@ \ @HWLIB_CFLAGS@ diff --git a/src/system/setting_helpers.cpp b/src/system/setting_helpers.cpp index 302b3fd54..c86d9d203 100644 --- a/src/system/setting_helpers.cpp +++ b/src/system/setting_helpers.cpp @@ -256,6 +256,11 @@ void CColorSetupNotifier::setPalette() convertSetupColor2RGB(g_settings.menu_Content_inactive_Text_red, g_settings.menu_Content_inactive_Text_green, g_settings.menu_Content_inactive_Text_blue), convertSetupAlpha2Alpha(g_settings.menu_Content_inactive_alpha)); + // COL_INFOCLOCK_TEXT + frameBuffer->paletteSetColor(COL_NEUTRINO_TEXT + 15, + convertSetupColor2RGB(g_settings.clock_Digit_red, g_settings.clock_Digit_green, g_settings.clock_Digit_blue), + convertSetupAlpha2Alpha(g_settings.clock_Digit_alpha)); + frameBuffer->paletteSet(); } @@ -298,20 +303,6 @@ bool CAudioSetupNotifier::changeNotify(const neutrino_locale_t OptionName, void return false; } -// used in ./gui/osd_setup.cpp: -bool CTimingSettingsNotifier::changeNotify(const neutrino_locale_t OptionName, void *) -{ - for (int i = 0; i < SNeutrinoSettings::TIMING_SETTING_COUNT; i++) - { - if (ARE_LOCALES_EQUAL(OptionName, timing_setting[i].name)) - { - g_settings.timing[i] = atoi(g_settings.timing_string[i]); - return true; - } - } - return false; -} - // used in ./gui/osd_setup.cpp: bool CFontSizeNotifier::changeNotify(const neutrino_locale_t, void *) { @@ -499,7 +490,7 @@ bool CTZChangeNotifier::changeNotify(const neutrino_locale_t, void * Data) while (search) { if (!strcmp(xmlGetName(search), "zone")) { name = xmlGetAttribute(search, "name"); - if(!strcmp(g_settings.timezone, name.c_str())) { + if(g_settings.timezone == name) { zone = xmlGetAttribute(search, "zone"); if (!access(("/usr/share/zoneinfo/" + zone).c_str(), R_OK)) found = true; @@ -561,7 +552,6 @@ int CDataResetNotifier::exec(CMenuTarget* /*parent*/, const std::string& actionK CNeutrinoApp::getInstance()->saveSetup(NEUTRINO_SETTINGS_FILE); //CNeutrinoApp::getInstance()->loadColors(NEUTRINO_SETTINGS_FILE); CNeutrinoApp::getInstance()->SetupFonts(); - CNeutrinoApp::getInstance()->SetupTiming(); CColorSetupNotifier::setPalette(); CVFD::getInstance()->setlcdparameter(); CFrameBuffer::getInstance()->Clear(); diff --git a/src/system/setting_helpers.h b/src/system/setting_helpers.h index 88207dc36..52db018f1 100644 --- a/src/system/setting_helpers.h +++ b/src/system/setting_helpers.h @@ -97,12 +97,6 @@ class CAudioSetupNotifier : public CChangeObserver bool changeNotify(const neutrino_locale_t OptionName, void *); }; -class CTimingSettingsNotifier : public CChangeObserver -{ - public: - bool changeNotify(const neutrino_locale_t OptionName, void *); -}; - class CFontSizeNotifier : public CChangeObserver { public: diff --git a/src/system/settings.h b/src/system/settings.h index b4fc77683..b8e652217 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -73,11 +73,11 @@ struct SNeutrinoSettings //misc int shutdown_real; int shutdown_real_rcdelay; - char shutdown_count[4]; - char shutdown_min[4]; + int shutdown_count; + int shutdown_min; int sleeptimer_min; - char record_safety_time_before[3]; - char record_safety_time_after[3]; + int record_safety_time_before; + int record_safety_time_after; int zapto_pre_time; int infobar_sat_display; int infobar_show_channeldesc; @@ -105,7 +105,6 @@ struct SNeutrinoSettings int audio_DolbyDigital; int auto_lang; int auto_subs; - char audio_PCMOffset[3]; int srs_enable; int srs_algo; int srs_ref_volume; @@ -138,19 +137,19 @@ struct SNeutrinoSettings int vcr_AutoSwitch; //language - char language[25]; - char timezone[150]; + std::string language; + std::string timezone; - char pref_lang[3][30]; - char pref_subs[3][30]; + std::string pref_lang[3]; + std::string pref_subs[3]; // EPG int epg_save; int epg_save_standby; - std::string epg_cache; - std::string epg_old_events; - std::string epg_max_events; - std::string epg_extendedcache; + int epg_cache; + int epg_old_events; + int epg_max_events; + int epg_extendedcache; std::string epg_dir; int epg_scan; @@ -162,7 +161,7 @@ struct SNeutrinoSettings std::string network_ntpserver; std::string network_ntprefresh; int network_ntpenable; - char ifname[10]; + std::string ifname; //personalize enum PERSONALIZE_SETTINGS //settings.h @@ -262,13 +261,17 @@ struct SNeutrinoSettings TIMING_SETTING_COUNT }; - int timing [TIMING_SETTING_COUNT] ; - char timing_string[TIMING_SETTING_COUNT][4]; + int timing [TIMING_SETTING_COUNT]; //widget settings int widget_fade; //colors + unsigned char clock_Digit_alpha; + unsigned char clock_Digit_red; + unsigned char clock_Digit_green; + unsigned char clock_Digit_blue; + unsigned char menu_Head_alpha; unsigned char menu_Head_red; unsigned char menu_Head_green; @@ -329,21 +332,24 @@ struct SNeutrinoSettings //network #define NETWORK_NFS_NR_OF_ENTRIES 8 - std::string network_nfs_ip[NETWORK_NFS_NR_OF_ENTRIES]; - char network_nfs_mac[NETWORK_NFS_NR_OF_ENTRIES][31]; - char network_nfs_local_dir[NETWORK_NFS_NR_OF_ENTRIES][100]; - char network_nfs_dir[NETWORK_NFS_NR_OF_ENTRIES][100]; - int network_nfs_automount[NETWORK_NFS_NR_OF_ENTRIES]; - char network_nfs_mount_options1[NETWORK_NFS_NR_OF_ENTRIES][31]; - char network_nfs_mount_options2[NETWORK_NFS_NR_OF_ENTRIES][31]; - int network_nfs_type[NETWORK_NFS_NR_OF_ENTRIES]; - char network_nfs_username[NETWORK_NFS_NR_OF_ENTRIES][31]; - char network_nfs_password[NETWORK_NFS_NR_OF_ENTRIES][31]; - char network_nfs_audioplayerdir[100]; - char network_nfs_picturedir[100]; - char network_nfs_moviedir[100]; - char network_nfs_recordingdir[100]; - char timeshiftdir[100]; + struct { + std::string ip; + std::string mac; + std::string local_dir; + std::string dir; + int automount; + std::string mount_options1; + std::string mount_options2; + int type; + std::string username; + std::string password; + } network_nfs[NETWORK_NFS_NR_OF_ENTRIES]; + std::string network_nfs_audioplayerdir; + std::string network_nfs_picturedir; + std::string network_nfs_moviedir; + std::string network_nfs_recordingdir; + std::string timeshiftdir; + std::string downloadcache_dir; //recording int recording_type; @@ -463,8 +469,8 @@ struct SNeutrinoSettings int channellist_new_zap_mode; int channellist_sort_mode; int channellist_numeric_adjust; - char repeat_blocker[4]; - char repeat_genericblocker[4]; + int repeat_blocker; + int repeat_genericblocker; int remote_control_hardware; int audiochannel_up_down_enable; @@ -582,15 +588,15 @@ struct SNeutrinoSettings #define FILESYSTEM_ENCODING_TO_UTF8_STRING(a) (isUTF8(a) ? (a) : ZapitTools::Latin1_to_UTF8(a)) // pictureviewer - char picviewer_slide_time[3]; - int picviewer_scaling; + int picviewer_slide_time; + int picviewer_scaling; std::string picviewer_decode_server_ip; char picviewer_decode_server_port[6]; //audioplayer int audioplayer_display; int audioplayer_follow; - char audioplayer_screensaver[3]; + int audioplayer_screensaver; int audioplayer_highprio; int audioplayer_select_title_by_name; int audioplayer_repeat_on; @@ -616,9 +622,9 @@ struct SNeutrinoSettings int hdd_fs; int zap_cycle; int sms_channel; - char font_file[100]; - char ttx_font_file[100]; - char update_dir[100]; + std::string font_file; + std::string ttx_font_file; + std::string update_dir; // USERMENU typedef enum { diff --git a/src/timerd/timerd.cpp b/src/timerd/timerd.cpp index 2a7d9ddec..dc3595cca 100644 --- a/src/timerd/timerd.cpp +++ b/src/timerd/timerd.cpp @@ -63,8 +63,8 @@ bool timerd_parse_command(CBasicMessage::Header &rmsg, int connfd) { for (pos = events.begin(); pos != events.end(); ++pos) { - printf("ID: %u type: %u\n",pos->second->eventID,pos->second->eventType); - if(pos->second->eventType == CTimerd::TIMER_SLEEPTIMER) +// printf("ID: %u type: %u\n",pos->second->eventID,pos->second->eventType); + if(pos->second->eventType == CTimerd::TIMER_SLEEPTIMER && pos->second->eventState != CTimerd::TIMERSTATE_TERMINATED) { rspGetSleeptimer.eventID = pos->second->eventID; break; diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index 1539f8c42..5104c71bc 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -63,6 +63,7 @@ #include #include #include +#include #endif #if USE_STB_HAL || HAVE_TRIPLEDRAGON #include @@ -564,6 +565,10 @@ bool CZapit::ZapIt(const t_channel_id channel_id, bool forupdate, bool startplay StopPip(); #endif +#ifdef BOXMODEL_APOLLO + cCA::GetInstance()->SetTS((CA_DVBCI_TS_INPUT)live_fe->getNumber()); +#endif + if (current_channel->getServiceType() == ST_NVOD_REFERENCE_SERVICE) { current_is_nvod = true; return true;