From 660c17ad442972a27a47be67317f22a197ef907b Mon Sep 17 00:00:00 2001 From: vanhofen Date: Mon, 4 Sep 2017 17:17:27 +0200 Subject: [PATCH] add possibility to signalize available online-updates in infoicons Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/3294d9f74defe91ec41301affdcbec95f072b6a0 Author: vanhofen Date: 2017-09-04 (Mon, 04 Sep 2017) Origin message was: ------------------ - add possibility to signalize available online-updates in infoicons ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- data/icons/status/info/Makefile.am | 4 +- data/icons/status/info/info4_off.png | Bin 0 -> 446 bytes data/icons/status/info/info4_on.png | Bin 0 -> 357 bytes data/locale/deutsch.locale | 2 +- data/locale/english.locale | 2 +- src/gui/Makefile.am | 1 + src/gui/update_check.cpp | 112 +++++++++++++++++++++++++++ src/gui/update_check.h | 45 +++++++++++ src/neutrino.cpp | 18 +++-- version_pseudo.h | 2 +- 10 files changed, 177 insertions(+), 9 deletions(-) create mode 100644 data/icons/status/info/info4_off.png create mode 100644 data/icons/status/info/info4_on.png create mode 100644 src/gui/update_check.cpp create mode 100644 src/gui/update_check.h diff --git a/data/icons/status/info/Makefile.am b/data/icons/status/info/Makefile.am index 2753cb3d8..2f8451945 100644 --- a/data/icons/status/info/Makefile.am +++ b/data/icons/status/info/Makefile.am @@ -9,4 +9,6 @@ install_DATA = \ info2_off.png \ info2_on.png \ info3_off.png \ - info3_on.png + info3_on.png \ + info4_off.png \ + info4_on.png diff --git a/data/icons/status/info/info4_off.png b/data/icons/status/info/info4_off.png new file mode 100644 index 0000000000000000000000000000000000000000..1b0cf02277a265f805b3f915a672bd0fc2a99b05 GIT binary patch literal 446 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjY)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYYs>cdx@v7EBixE7H%skcZGOo1_nlNPZ!4!kK=Er?)7GN6gg5~KF{T# z+Xi8s9GAd{U4K}cdJ_^=qkLsI@{4&MSbxs#(muBhKFW0s3T9D99&vep)ZZZNvZ3Sb zT$P7%6)^8KM5BzDkRmT*;sHY<9 zCYkg1QqNRXTdPTSjZRD})6%ZmHAnE?w&eSsH$OPUsnO;UgR6MOx#USsf7G9B7WsZN zaZ;E}hSel42jK{>jSIyjm+@5DN^Qw}AQT~&ATB#QvXVuCqpAGcdx@v7EBixE7H&&xg%p{4K%q~bE{-7{$KPIE=yy0kr2S*@)d!Lu z0V*0SocWFsO^RX+24;^Y!uW*f7fRJp}gKh@^F zUZtJ2>c;9x>mM&&x%W(i`JKf2Uq>C!{WNA?wzH$dqoSkZ?y_!w&80URdTL*?+hy(2 zFfv=WVx|6UrYvWvCkA|X($8#uq41yE;^dvri +#endif + +#include +#include + +#include +#include + +#include +#include + +#include "update_check.h" + +#define C4U_SLEEP (6 * 60 * 60) // 6 hours +#define C4U_FLAGFILE FLAGDIR "/.update" + +/* ----------------------------------------------------------------- */ + +CFlashUpdateCheck::CFlashUpdateCheck() +{ + c4u_thread = 0; +} + +CFlashUpdateCheck::~CFlashUpdateCheck() +{ + stopThread(); +} + +CFlashUpdateCheck* CFlashUpdateCheck::getInstance() +{ + static CFlashUpdateCheck * c4u = NULL; + if (!c4u) + c4u = new CFlashUpdateCheck(); + + return c4u; +} + +void CFlashUpdateCheck::startThread() +{ + if (!c4u_thread) + { + printf("[CFlashUpdateCheck]: starting thread\n"); + pthread_create(&c4u_thread, NULL, c4u_proc, (void*) NULL); + pthread_detach(c4u_thread); + } +} + +void CFlashUpdateCheck::stopThread() +{ + if (c4u_thread) + { + printf("[CFlashUpdateCheck]: stopping thread\n"); + pthread_cancel(c4u_thread); + } + c4u_thread = 0; +} + +void* CFlashUpdateCheck::c4u_proc(void*) +{ + set_threadname("n:flashupdatecheck"); + + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0); + pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0); + + //printf("[CFlashUpdateCheck] %s: starting loop\n", __FUNCTION__); + while(1) + { + CFlashUpdate flashupdate; + + //printf("[CFlashUpdateCheck]: check for updates\n"); + if (flashupdate.checkOnlineVersion()) + { + //printf("[CFlashUpdateCheck]: update available\n"); + if (FILE *f = fopen(C4U_FLAGFILE, "w")) + fclose(f); + } + else + { + if (access(C4U_FLAGFILE, F_OK) == 0) + unlink(C4U_FLAGFILE); + } + + sleep(C4U_SLEEP); + } + return 0; +} diff --git a/src/gui/update_check.h b/src/gui/update_check.h new file mode 100644 index 000000000..bd57c814b --- /dev/null +++ b/src/gui/update_check.h @@ -0,0 +1,45 @@ +/* + update-check + + Copyright (C) 2017 'vanhofen' + Homepage: http://www.neutrino-images.de/ + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __update_check__ +#define __update_check__ + +class CFlashUpdateCheck +{ + public: + CFlashUpdateCheck(); + ~CFlashUpdateCheck(); + static CFlashUpdateCheck* getInstance(); + + void startThread(); + void stopThread(); + + private: + + pthread_t c4u_thread; + static void* c4u_proc(void *arg); + +}; + +#endif // __update_check__ diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 1f535cd19..e5faeb51b 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -94,6 +94,7 @@ #include "gui/start_wizard.h" #include "gui/update_ext.h" #include "gui/update.h" +#include "gui/update_check.h" #include "gui/videosettings.h" #include "gui/audio_select.h" #include "gui/webtv_setup.h" //NI @@ -376,6 +377,7 @@ int CNeutrinoApp::loadSetup(const char * fname) else if (i==1) sprintf(cfg_value, "/var/etc/.call"); else if (i==2) sprintf(cfg_value, "/var/etc/.srv"); else if (i==3) sprintf(cfg_value, "/var/etc/.card"); + else if (i==4) sprintf(cfg_value, "/var/etc/.update"); else strcpy(cfg_value, ""); g_settings.mode_icons_flag[i] = configfile.getString(cfg_key, cfg_value); } @@ -1081,13 +1083,11 @@ void CNeutrinoApp::upgradeSetup(const char * fname) configfile.setString("usermenu_tv_yellow", g_settings.usermenu[SNeutrinoSettings::BUTTON_YELLOW]->items); } } - //NI if (g_settings.version_pseudo < "20160804110000") { if (g_settings.tmdb_api_key == "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") g_settings.tmdb_api_key = "7270f1b571c4ecbb5b204ddb7f8939b1"; } - //NI if (g_settings.version_pseudo < "20161411235900") { //convert and remove obsolete recording_tevents key @@ -1137,13 +1137,11 @@ void CNeutrinoApp::upgradeSetup(const char * fname) configfile.deleteKey("screen_width"); configfile.deleteKey("screen_height"); } - //NI if (g_settings.version_pseudo < "20170516150000") { if (g_settings.movieplayer_bisection_jump == 1) g_settings.movieplayer_bisection_jump = 5; } - //NI if (g_settings.version_pseudo < "20170606000000") { //remove CProgressBar::PB_GRAPHIC @@ -1153,13 +1151,18 @@ void CNeutrinoApp::upgradeSetup(const char * fname) g_settings.theme.progressbar_gradient = 1; } } - //NI if (g_settings.version_pseudo < "20170606215500") { //align fontsize.filebrowser_item to new default if (configfile.getInt32("fontsize.filebrowser_item", 16) == 16) configfile.setInt32("fontsize.filebrowser_item", 17); } + if (g_settings.version_pseudo < "20170904080000") + { + //add flagfile for periodically update-check + if (g_settings.mode_icons_flag[4].empty()) + g_settings.mode_icons_flag[4] = FLAGDIR "/.update"; + } g_settings.version_pseudo = NEUTRINO_VERSION_PSEUDO; configfile.setString("version_pseudo", g_settings.version_pseudo); @@ -2551,6 +2554,7 @@ TIMER_START(); TIMER_STOP("################################## after all ##################################"); if (g_settings.softupdate_autocheck) { +#if 0 hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, g_Locale->getText(LOCALE_FLASHUPDATE_CHECKUPDATE_INTERNET)); hintBox->paint(); CFlashUpdate flash; @@ -2561,6 +2565,8 @@ TIMER_STOP("################################## after all ####################### } hintBox->hide(); delete hintBox; +#endif + CFlashUpdateCheck::getInstance()->startThread(); } RealRun(); @@ -4720,6 +4726,8 @@ void stop_daemons(bool stopall, bool for_flash) cs_deregister_messenger(); } + delete CFlashUpdateCheck::getInstance(); + if (for_flash) { delete cHddStat::getInstance(); delete CRecordManager::getInstance(); diff --git a/version_pseudo.h b/version_pseudo.h index 8e3fea959..5540dd3fd 100644 --- a/version_pseudo.h +++ b/version_pseudo.h @@ -1 +1 @@ -#define NEUTRINO_VERSION_PSEUDO "20170606215500" +#define NEUTRINO_VERSION_PSEUDO "20170904080000"