From 396d7bb42af94c09688ef8338cbeda7eb43e49da Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 1 Nov 2018 17:26:15 +0100 Subject: [PATCH] Imageinfo: prepare functionality to show privacy policy Note: Contents of policy files are not available with this commit. This should be done related to own conditions by provider himself. Providers are required by law to do this for their users as well. Files must be installed in: installdir = $(DATADIR)/neutrino/policy Providers should modify their buildsystem to install these files. Filename sheme is .policy. eg 'english.policy' If you want to add a policy file, take a look into sample file locale.policy.sample --- configure.ac | 1 + data/Makefile.am | 1 + data/locale/deutsch.locale | 1 + data/locale/english.locale | 1 + data/policy/Makefile.am | 4 ++ data/policy/locale.policy.sample | 6 ++ src/gui/imageinfo.cpp | 120 ++++++++++++++++++------------- src/gui/imageinfo.h | 8 +-- src/system/locals.h | 1 + src/system/locals_intern.h | 1 + 10 files changed, 92 insertions(+), 52 deletions(-) create mode 100644 data/policy/Makefile.am create mode 100644 data/policy/locale.policy.sample diff --git a/configure.ac b/configure.ac index 9d1e342b7..6c5c65056 100644 --- a/configure.ac +++ b/configure.ac @@ -337,6 +337,7 @@ data/neutrino-scripts/Makefile data/pictures/Makefile data/pictures/backgrounds/Makefile data/pictures/screensaver/Makefile +data/policy/Makefile data/scripts/Makefile data/themes/Makefile data/themes/Grey-Blue/Makefile diff --git a/data/Makefile.am b/data/Makefile.am index 89bc24c21..797e664bf 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -8,6 +8,7 @@ SUBDIRS = \ locale \ neutrino-scripts \ pictures \ + policy \ scripts \ themes \ y-web diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 3c76e6207..c05da3c57 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -828,6 +828,7 @@ imageinfo.image Image: imageinfo.kernel Kernel: imageinfo.license Lizenz imageinfo.os System: +imageinfo.policy Datenschutz imageinfo.vcs Git: imageinfo.version Version: imdb.api_key IMDb API Schlüssel diff --git a/data/locale/english.locale b/data/locale/english.locale index eb052bc0c..5b3edb94f 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -827,6 +827,7 @@ imageinfo.image Image: imageinfo.kernel Kernel: imageinfo.license License imageinfo.os System: +imageinfo.policy Privacy Policy imageinfo.vcs Git: imageinfo.version Version: imdb.api_key IMDb API-Key diff --git a/data/policy/Makefile.am b/data/policy/Makefile.am new file mode 100644 index 000000000..4a0ddb347 --- /dev/null +++ b/data/policy/Makefile.am @@ -0,0 +1,4 @@ +installdir = $(DATADIR)/neutrino/policy + +install_DATA = \ + locale.policy.sample diff --git a/data/policy/locale.policy.sample b/data/policy/locale.policy.sample new file mode 100644 index 000000000..f080a98c7 --- /dev/null +++ b/data/policy/locale.policy.sample @@ -0,0 +1,6 @@ +Please modify content of this file and rename sample file. +Filename sheme is .policy. eg 'english.policy' + +Files must be installed in: + + $(DATADIR)/neutrino/policy diff --git a/src/gui/imageinfo.cpp b/src/gui/imageinfo.cpp index b6a866751..6f640328a 100644 --- a/src/gui/imageinfo.cpp +++ b/src/gui/imageinfo.cpp @@ -41,6 +41,7 @@ #include "version.h" #include #define LICENSEDIR DATADIR "/neutrino/license/" +#define POLICY_DIR DATADIR "/neutrino/policy/" #ifdef ENABLE_LUA #include #endif @@ -67,13 +68,15 @@ void CImageInfo::Init(void) cc_tv = NULL; cc_lic = NULL; cc_sub_caption = NULL; - b_info = NULL; btn_red = NULL; + btn_green = NULL; item_offset = OFFSET_INNER_MID; item_font = NULL; item_height = 0; y_tmp = 0; license_txt = ""; + policy_txt = ""; + InitBuildInfos(); v_info.clear(); } @@ -95,9 +98,8 @@ void CImageInfo::Clean() cc_tv = NULL; cc_lic = NULL; cc_sub_caption = NULL; - delete b_info; - b_info = NULL; btn_red = NULL; + btn_green = NULL; } } @@ -110,6 +112,10 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) //clean up before, because we could have a current instance with already initialized contents Clean(); + //fill manifest texts + license_txt = getLicenseText(); + policy_txt = getPolicyText(); + //init window object, add cc-items and paint all ShowWindow(); bool fadeout = false; @@ -134,39 +140,21 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) else break; } - if(msg == CRCInput::RC_setup) { res = menu_return::RETURN_EXIT_ALL; fadeout = true; } - else if (msg == CRCInput::RC_red){ - // init temporarly vars - neutrino_locale_t info_cap , new_btn_cap; - info_cap = new_btn_cap = NONEXISTANT_LOCALE; - string info_txt = ""; - neutrino_locale_t btn_cap = btn_red->getCaptionLocale(); - - //toggle caption and info contents - if (btn_cap == LOCALE_BUILDINFO_MENU){ - info_cap = LOCALE_BUILDINFO_MENU; - for (uint i=0; igetText(b_info->getInfo(i).caption); - info_txt += "\n"; - info_txt += b_info->getInfo(i).info_text + "\n\n"; - } - new_btn_cap = LOCALE_IMAGEINFO_LICENSE; + else if (msg == btn_red->getButtonDirectKey()/* CRCInput::RC_red*/){ + //toggle and assign caption and info contents + if (btn_red->getCaptionLocale() == LOCALE_IMAGEINFO_LICENSE){ + cc_sub_caption->setText(LOCALE_IMAGEINFO_LICENSE, CTextBox::AUTO_WIDTH, item_font); + InitInfoText(license_txt); + btn_red->setCaption(LOCALE_BUILDINFO_MENU); + }else{ + cc_sub_caption->setText(LOCALE_BUILDINFO_MENU, CTextBox::AUTO_WIDTH, item_font); + InitInfoText(build_info_txt); + btn_red->setCaption(LOCALE_IMAGEINFO_LICENSE); } - if (btn_cap == LOCALE_IMAGEINFO_LICENSE){ - info_cap = LOCALE_IMAGEINFO_LICENSE; - info_txt = getLicenseText(); - new_btn_cap = LOCALE_BUILDINFO_MENU; - } - - //assign new caption and info contents - cc_sub_caption->setText(info_cap, CTextBox::AUTO_WIDTH, item_font); - InitInfoText(info_txt); - btn_red->setCaption(new_btn_cap); - //paint items cc_sub_caption->hide(); cc_sub_caption->paint(); @@ -174,6 +162,13 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) btn_red->kill(); btn_red->paint(false); } + else if (msg == btn_green->getButtonDirectKey()/* CRCInput::RC_green*/){ + cc_sub_caption->setText(LOCALE_IMAGEINFO_POLICY, CTextBox::AUTO_WIDTH, item_font); + InitInfoText(policy_txt); + cc_sub_caption->hide(); + cc_sub_caption->paint(); + cc_lic->paint(false); + } else if (CNeutrinoApp::getInstance()->listModeKey(msg)) { postmsg = msg; res = menu_return::RETURN_EXIT_ALL; @@ -192,7 +187,6 @@ int CImageInfo::exec(CMenuTarget* parent, const std::string &) if ( msg > CRCInput::RC_MaxRC && msg != CRCInput::RC_timeout){ CNeutrinoApp::getInstance()->handleMsg( msg, data ); } - } if (postmsg) @@ -210,12 +204,30 @@ void CImageInfo::ShowWindow() cc_win = new CComponentsWindowMax(LOCALE_IMAGEINFO_HEAD, NEUTRINO_ICON_INFO, 0, CC_SHADOW_ON); cc_win->setWindowHeaderButtons(CComponentsHeader::CC_BTN_MENU | CComponentsHeader::CC_BTN_EXIT); footer = cc_win->getFooterObject(); - int h_footer = footer->getHeight(); - fb_pixel_t btn_col = /*g_settings.theme.Button_gradient ? COL_BUTTON_BODY :*/ footer->getColorBody(); //TODO: Button_gradient option - btn_red = new CComponentsButtonRed(10, CC_CENTERED, 250, h_footer-h_footer/4, LOCALE_BUILDINFO_MENU, footer, false , true, false, footer->getColorBody(), btn_col); + + button_label_cc btn; + vector v_buttons; + + btn.button = NEUTRINO_ICON_BUTTON_RED; + btn.locale = LOCALE_BUILDINFO_MENU; + btn.directKeys.push_back(CRCInput::RC_red); + v_buttons.push_back(btn); + + btn.button = !policy_txt.empty() ? NEUTRINO_ICON_BUTTON_GREEN : NEUTRINO_ICON_BUTTON_DUMMY; + btn.locale = LOCALE_IMAGEINFO_POLICY; + btn.directKeys.clear(); + btn.directKeys.push_back(!policy_txt.empty() ? CRCInput::RC_green : RC_NOKEY); + v_buttons.push_back(btn); + + footer->setButtonLabels(v_buttons, 0, footer->getWidth()/v_buttons.size()); + + btn_red = footer->getButtonLabel(0); btn_red->doPaintBg(false); btn_red->setButtonTextColor(COL_MENUFOOT_TEXT); btn_red->setColBodyGradient(CC_COLGRAD_OFF); + + btn_green = footer->getButtonLabel(1); +// btn_green->allowPaint(!policy_txt.empty()); } //prepare minitv @@ -224,11 +236,8 @@ void CImageInfo::ShowWindow() //prepare infos InitInfos(); - //prepare build infos - InitBuildInfos(); - //prepare info text - InitInfoText(getLicenseText()); + InitInfoText(license_txt); //paint window cc_win->StartFadeIn(); @@ -260,8 +269,12 @@ void CImageInfo::InitMinitv() //prepare distribution infos void CImageInfo::InitBuildInfos() { - if (b_info == NULL) - b_info = new CBuildInfo(); + CBuildInfo b_info; + for (uint i=0; igetText(b_info.getInfo(i).caption); + build_info_txt += "\n"; + build_info_txt += b_info.getInfo(i).info_text + "\n\n"; + } } //collect required data from environment @@ -416,25 +429,36 @@ void CImageInfo::InitInfos() } } -//get license -string CImageInfo::getLicenseText() +string CImageInfo::getManifest(const std::string& directory, const std::string& language, const std::string& manifest_type) { - string file = LICENSEDIR; - file += g_settings.language; - file += ".license"; + string file = directory; + file += language; + file += "." + manifest_type; string res = CComponentsText::getTextFromFile(file); //assign default text, if language file is not available if(res.empty()){ - file = LICENSEDIR; - file += "english.license"; + file = directory; + file += "english." + manifest_type; res = CComponentsText::getTextFromFile(file); } return res; } +//get license +string CImageInfo::getLicenseText() +{ + return getManifest(LICENSEDIR, g_settings.language, "license"); +} + +//get policy +string CImageInfo::getPolicyText() +{ + return getManifest(POLICY_DIR, g_settings.language, "policy"); +} + //prepare info text void CImageInfo::InitInfoText(const std::string& text) { diff --git a/src/gui/imageinfo.h b/src/gui/imageinfo.h index 0449b7591..38b72b772 100644 --- a/src/gui/imageinfo.h +++ b/src/gui/imageinfo.h @@ -33,7 +33,6 @@ #include #include -#include #include typedef struct image_info_t @@ -47,7 +46,7 @@ class CImageInfo : public CMenuTarget { private: int item_offset; //distance between items and to boarder - std::string license_txt; + std::string license_txt, policy_txt, build_info_txt; Font* item_font; int item_height; int y_tmp; @@ -61,6 +60,7 @@ class CImageInfo : public CMenuTarget void InitBuildInfos(); void InitInfoText(const std::string& text); std::string getLicenseText(); + std::string getPolicyText(); void ShowWindow(); void ScrollLic(bool scrollDown); std::string getYWebVersion(); @@ -69,9 +69,8 @@ class CImageInfo : public CMenuTarget CComponentsForm *cc_info; CComponentsPIP *cc_tv; CComponentsInfoBox *cc_lic; - CBuildInfo *b_info; CConfigFile config; - CComponentsButtonRed *btn_red; + CComponentsButton *btn_red, *btn_green; CComponentsLabel *cc_sub_caption; public: @@ -81,6 +80,7 @@ class CImageInfo : public CMenuTarget void hide(); int exec(CMenuTarget* parent, const std::string & actionKey); + static std::string getManifest(const std::string& directory, const std::string& language, const std::string& manifest_type); }; #endif diff --git a/src/system/locals.h b/src/system/locals.h index c573ef3e8..6d5d98002 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -855,6 +855,7 @@ typedef enum LOCALE_IMAGEINFO_KERNEL, LOCALE_IMAGEINFO_LICENSE, LOCALE_IMAGEINFO_OS, + LOCALE_IMAGEINFO_POLICY, LOCALE_IMAGEINFO_VCS, LOCALE_IMAGEINFO_VERSION, LOCALE_IMDB_API_KEY, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 2089b304c..a16b26192 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -855,6 +855,7 @@ const char * locale_real_names[] = "imageinfo.kernel", "imageinfo.license", "imageinfo.os", + "imageinfo.policy", "imageinfo.vcs", "imageinfo.version", "imdb.api_key",