diff --git a/configure.ac b/configure.ac index 6d617f9ef..5e6f948b4 100644 --- a/configure.ac +++ b/configure.ac @@ -12,6 +12,21 @@ AC_PROG_CXX AC_DISABLE_STATIC AM_PROG_LIBTOOL +# Add build information to config.h +# --------------------------------- + +# Add host to config.h +AC_DEFINE_UNQUOTED(USED_BUILD, ["$build"], [Build system under which the program was compiled on.]) + +# Add used CXXFLAGS to config.h +AC_DEFINE_UNQUOTED(USED_CXXFLAGS, ["$CXXFLAGS"], [Define to the used CXXFLAGS to compile this package.]) + +# Get compiler (version) +AH_TEMPLATE(USED_COMPILER, [Define to name and version of used compiler]) +if COMPILER=`$CC --version | head -n 1`; then + AC_DEFINE_UNQUOTED(USED_COMPILER, ["$COMPILER"]) +fi + AC_ARG_WITH([tremor], [AS_HELP_STRING([--with-tremor], [use libvorbisidec instead of libogg/libvorbis])], [TREMOR="$withval"], diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index ef4a47c37..3dd828133 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -200,6 +200,12 @@ bouquetname.hdtv HD Kanäle bouquetname.new Neue Kanäle bouquetname.other Unbekannter Provider bouquetname.removed Gelöschte Kanäle +buildinfo.compiled_on Build PC +buildinfo.compiled_with Compiler Version +buildinfo.compiler_flags Compiler Flags +buildinfo.creator Ersteller +buildinfo.kernel Kernel Version +buildinfo.menu Build Informationen cablesetup.provider Kabelanbieter channellist.additional Zusatzinformationen channellist.additional_off aus @@ -788,6 +794,7 @@ menu.hint_back Zurück zum vorherigen Menü.\nDie Taste 'Menü' schließt alle M menu.hint_backlight Konfigurieren Sie die Hintergrundbeleuchtung der Buttons menu.hint_backup Sichern von Konfigurationen und Kanallisten menu.hint_bedit Bearbeiten ihrer Favoriten und der Bouquets +menu.hint_buildinfo Informationen über Compiler, Compilerflags, Kernel menu.hint_cache_txt Startet das Zwischenspeichern des Teletextes nach einem Kanalwechsel menu.hint_cec_mode CEC-Modus menu.hint_cec_standby CEC-Standby diff --git a/data/locale/english.locale b/data/locale/english.locale index ef9a06cc0..7407cd916 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -200,6 +200,12 @@ bouquetname.hdtv HD channels bouquetname.new New channels bouquetname.other Unknown provider bouquetname.removed Removed channels +buildinfo.compiled_on Build PC +buildinfo.compiled_with Compiler version +buildinfo.compiler_flags Compiler flags +buildinfo.creator Creator +buildinfo.kernel Kernel version +buildinfo.menu Build information cablesetup.provider cable provider channellist.additional Additional informations channellist.additional_off off @@ -788,6 +794,7 @@ menu.hint_back Return to previous menu\nPress menu key to close all menus menu.hint_backlight Configure buttons backlight menu.hint_backup Backup configs and channels to selected dir menu.hint_bedit Edit favorites and bouquets +menu.hint_buildinfo Information about compilers, compiler flags, kernel menu.hint_cache_txt Start teletext caching after channel switch menu.hint_cec_mode CEC mode menu.hint_cec_standby CEC standby diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index ec2ff3afd..e26d7aab0 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -52,6 +52,7 @@ libneutrino_gui_a_SOURCES = \ audioplayer_setup.cpp\ bookmarkmanager.cpp \ bouquetlist.cpp \ + buildinfo.cpp \ channellist.cpp \ cec_setup.cpp \ dboxinfo.cpp \ diff --git a/src/gui/buildinfo.cpp b/src/gui/buildinfo.cpp new file mode 100644 index 000000000..0ce04f054 --- /dev/null +++ b/src/gui/buildinfo.cpp @@ -0,0 +1,266 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Copyright (C) 2013, M. Liebmann 'micha-bbg' + 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, 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 +#include +#include +#include +#include +#include +#include +#include + +CBuildInfo::CBuildInfo(): config ('\t') +{ + Init(); +} + +//init all var members +void CBuildInfo::Init(void) +{ + cc_win = NULL; + cc_info = NULL; + item_offset = 10; + bodyHeight = 0; + v_info.clear(); + config.loadConfig("/.version"); +} + +CBuildInfo::~CBuildInfo() +{ + hide(); + delete cc_win; +} + +void CBuildInfo::Clean() +{ + if (cc_win){ + delete cc_win; + cc_win = NULL; + cc_info = NULL; + } +} + +int CBuildInfo::exec(CMenuTarget* parent, const std::string &) +{ + int res = menu_return::RETURN_REPAINT; + if (parent) + parent->hide(); + + //clean up before, because we could have a current instance with already initialized contents + Clean(); + + //init window object, add cc-items and paint all + ShowWindow(); + + neutrino_msg_t msg; + while (1) + { + neutrino_msg_data_t data; + uint64_t timeoutEnd = CRCInput::calcTimeoutEnd_MS(100); + g_RCInput->getMsgAbsoluteTimeout( &msg, &data, &timeoutEnd ); + + if(msg == CRCInput::RC_setup) { + res = menu_return::RETURN_EXIT_ALL; + break; + } + else if((msg == CRCInput::RC_sat) || (msg == CRCInput::RC_favorites)) { + g_RCInput->postMsg (msg, 0); + res = menu_return::RETURN_EXIT_ALL; + break; + } + else if (msg <= CRCInput::RC_MaxRC){ + break; + } + + if ( msg > CRCInput::RC_MaxRC && msg != CRCInput::RC_timeout){ + CNeutrinoApp::getInstance()->handleMsg( msg, data ); + } + } + + hide(); + + return res; +} + +void CBuildInfo::ShowWindow() +{ + if (cc_win == NULL){ + cc_win = new CComponentsWindow(LOCALE_BUILDINFO_MENU, NEUTRINO_ICON_INFO); + cc_win->setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); + CFrameBuffer *frameBuffer = CFrameBuffer::getInstance(); + int w = (frameBuffer->getScreenWidth()*2)/3; + int h = frameBuffer->getScreenHeight(); + cc_win->setDimensionsAll(getScreenStartX(w), getScreenStartY(h), w, h); + + CComponentsForm* bo = cc_win->getBodyObject(); + if (bo) bodyHeight = bo->getHeight(); + + } + + InitInfos(); + + cc_win->paint(); +} + +void CBuildInfo::InitInfos() +{ + v_info.clear(); + +#ifdef USED_COMPILER + build_info_t compiler = {LOCALE_BUILDINFO_COMPILED_WITH, USED_COMPILER}; + v_info.push_back(compiler); +#endif + +#ifdef USED_CXXFLAGS + std::string cxxflags = USED_CXXFLAGS; + cxxflags = trim(cxxflags); + // Remove double spaces + size_t pos = cxxflags.find(" "); + while (pos != std::string::npos) { + cxxflags.erase(pos, 1); + pos = cxxflags.find(" ", pos); + } + build_info_t flags = {LOCALE_BUILDINFO_COMPILER_FLAGS, cxxflags}; + v_info.push_back(flags); +#endif + +#ifdef USED_BUILD + build_info_t build = {LOCALE_BUILDINFO_COMPILED_ON, USED_BUILD}; + v_info.push_back(build); +#endif + + build_info_t creator = {LOCALE_BUILDINFO_CREATOR, config.getString("creator", "n/a")}; + v_info.push_back(creator); + + FILE *fp = fopen("/proc/version", "r"); + if (fp) { + char zeile[1024]; + memset(zeile, 0, sizeof(zeile)); + fgets(zeile, sizeof(zeile)-1, fp); + fclose(fp); + std::string zeile_s = zeile; + zeile_s = trim(zeile_s); + build_info_t kernel = {LOCALE_BUILDINFO_KERNEL, zeile_s}; + v_info.push_back(kernel); + } + +// ########################################################### + + int dx = 0, dy = 27; + Font * item_font = *(CNeutrinoFonts::getInstance()->getDynFont(dx, dy)); + + //initialize container for infos + if (cc_info == NULL) + cc_info = new CComponentsForm(); + cc_win->addWindowItem(cc_info); + cc_info->setPos(item_offset, item_offset); + cc_info->setWidth((cc_win->getWidth())-2*item_offset); + + //calculate max width of label and info_text + int w_label = 0, w_text = 0, w = 0; + for (size_t i = 0; i < v_info.size(); i++) { + w = item_font->getRenderWidth(g_Locale->getText(v_info[i].caption), true); + w_label = std::max(w_label, w); + + w = item_font->getRenderWidth(v_info[i].info_text.c_str(), true); + w_text = std::max(w_text, w); + } + + int x_label = 0, y_text = 0; + int x_text = x_label + w_label + item_offset; + int item_height = item_font->getHeight(); + int item_spacer = item_height / 2; + + //recalc w_text to avoid an overlap with pip TODO: calculate within cc_info itself + w_text = std::min(w_text, cc_win->getWidth() - x_text - 2*item_offset); + //create label and text items + int h_tmp = 0; + size_t i = 0; + + for (i = 0; i < v_info.size(); i++) { + CComponentsLabel *cc_label = new CComponentsLabel(); + cc_label->setDimensionsAll(x_label, y_text, w_label, item_height); + cc_label->setText(v_info[i].caption, CTextBox::NO_AUTO_LINEBREAK, item_font); + + //add label object to window body + cc_info->addCCItem(cc_label); + + CComponentsText *cc_text = new CComponentsText(); + cc_text->setDimensionsAll(x_text, y_text, w_text, item_height); + int textMode = CTextBox::AUTO_HIGH | CTextBox::TOP | CTextBox::AUTO_LINEBREAK_NO_BREAKCHARS; + cc_text->setText(v_info[i].info_text, textMode, item_font); + + //The rest of body height, less 1 line for each additional entry + int rest = bodyHeight-h_tmp-((v_info.size()-(i+1))*(item_height+item_spacer)); + int lines = cc_text->getTextLinesAutoHeight(rest, w_text, textMode); + cc_text->setHeight(lines*item_height); + y_text += lines*item_height + item_spacer; + + //add text object to window body + cc_info->addCCItem(cc_text); + + //
;-) + if (v_info[i].caption == LOCALE_BUILDINFO_CREATOR) { + int w1 = (cc_win->getWidth()*85)/100; + int x1 = cc_win->getRealXPos() + ((cc_win->getWidth() - w1)/2); + CComponentsShapeSquare *cc_shape; + cc_shape = new CComponentsShapeSquare(x1, y_text, w1, 2, CC_SHADOW_OFF, COL_MENUHEAD_PLUS_0, COL_MENUHEAD_PLUS_0); + y_text += item_spacer; + h_tmp += item_spacer; + cc_info->addCCItem(cc_shape); + } + + //set height for info form + h_tmp += lines*item_height + item_spacer; + } + + //assign height of info form + cc_info->setHeight(h_tmp); + + int ho_h = 0, fo_h = 0; + CComponentsHeader* ho = cc_win->getHeaderObject(); + if (ho) ho_h = ho->getHeight(); + CComponentsFooter* fo = cc_win->getFooterObject(); + if (fo) fo_h = fo->getHeight(); + h_tmp += ho_h + fo_h + 12; + cc_win->setHeight(h_tmp); + cc_win->setYPos(getScreenStartY(h_tmp)); +} + +void CBuildInfo::hide() +{ + printf("[CBuildInfo] [%s - %d] hide...\n", __FUNCTION__, __LINE__); + if (cc_win){ + cc_win->hide(); + Clean(); + } +} diff --git a/src/gui/buildinfo.h b/src/gui/buildinfo.h new file mode 100644 index 000000000..7145fb063 --- /dev/null +++ b/src/gui/buildinfo.h @@ -0,0 +1,70 @@ +/* + Based up Neutrino-GUI - Tuxbox-Project + Copyright (C) 2001 by Steffen Hehn 'McClean' + + Copyright (C) 2013, M. Liebmann 'micha-bbg' + 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, write to the + Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + + +#ifndef __buildinfo__ +#define __buildinfo__ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +typedef struct build_info_t +{ + neutrino_locale_t caption; + std::string info_text; + +} build_info_struct_t; + +class CBuildInfo : public CMenuTarget +{ + private: + int item_offset; + int bodyHeight; + std::vector v_info; + + void Clean(); + void Init(); + void InitInfos(); + void ShowWindow(); + + CComponentsWindow *cc_win; + CComponentsForm *cc_info; + CConfigFile config; + + public: + + CBuildInfo(); + ~CBuildInfo(); + + void hide(); + int exec(CMenuTarget* parent, const std::string & actionKey); +}; + +#endif // __buildinfo__ diff --git a/src/gui/info_menue.cpp b/src/gui/info_menue.cpp index 6df35961f..215158fc4 100644 --- a/src/gui/info_menue.cpp +++ b/src/gui/info_menue.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "gui/cam_menu.h" @@ -72,6 +73,7 @@ int CInfoMenu::showMenu() CImageInfo imageinfo; CDBoxInfoWidget boxinfo; CStreamInfo2 streaminfo; + CBuildInfo buildinfo; info->addIntroItems(); CMenuForwarder * mf = new CMenuForwarder(LOCALE_SERVICEMENU_IMAGEINFO, true, NULL, &imageinfo, NULL, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED ); @@ -86,6 +88,10 @@ int CInfoMenu::showMenu() mf->setHint(NEUTRINO_ICON_HINT_STREAMINFO, LOCALE_MENU_HINT_STREAMINFO); info->addItem(mf); + mf = new CMenuForwarder(LOCALE_BUILDINFO_MENU, true, NULL, &buildinfo, NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE ); + mf->setHint(NEUTRINO_ICON_HINT_IMAGEINFO, LOCALE_MENU_HINT_BUILDINFO); + info->addItem(mf); + if (g_settings.easymenu) { mf = new CMenuForwarder(LOCALE_CI_SETTINGS, true, NULL, g_CamHandler, NULL, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE); mf->setHint(NEUTRINO_ICON_HINT_CI, LOCALE_MENU_HINT_CI); diff --git a/src/system/locals.h b/src/system/locals.h index f2e681f7d..50de8652c 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -227,6 +227,12 @@ typedef enum LOCALE_BOUQUETNAME_NEW, LOCALE_BOUQUETNAME_OTHER, LOCALE_BOUQUETNAME_REMOVED, + LOCALE_BUILDINFO_COMPILED_ON, + LOCALE_BUILDINFO_COMPILED_WITH, + LOCALE_BUILDINFO_COMPILER_FLAGS, + LOCALE_BUILDINFO_CREATOR, + LOCALE_BUILDINFO_KERNEL, + LOCALE_BUILDINFO_MENU, LOCALE_CABLESETUP_PROVIDER, LOCALE_CHANNELLIST_ADDITIONAL, LOCALE_CHANNELLIST_ADDITIONAL_OFF, @@ -815,6 +821,7 @@ typedef enum LOCALE_MENU_HINT_BACKLIGHT, LOCALE_MENU_HINT_BACKUP, LOCALE_MENU_HINT_BEDIT, + LOCALE_MENU_HINT_BUILDINFO, LOCALE_MENU_HINT_CACHE_TXT, LOCALE_MENU_HINT_CEC_MODE, LOCALE_MENU_HINT_CEC_STANDBY, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index ee641767d..6b92fa3c9 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -227,6 +227,12 @@ const char * locale_real_names[] = "bouquetname.new", "bouquetname.other", "bouquetname.removed", + "buildinfo.compiled_on", + "buildinfo.compiled_with", + "buildinfo.compiler_flags", + "buildinfo.creator", + "buildinfo.kernel", + "buildinfo.menu", "cablesetup.provider", "channellist.additional", "channellist.additional_off", @@ -815,6 +821,7 @@ const char * locale_real_names[] = "menu.hint_backlight", "menu.hint_backup", "menu.hint_bedit", + "menu.hint_buildinfo", "menu.hint_cache_txt", "menu.hint_cec_mode", "menu.hint_cec_standby",