diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index e6cc70ac0..2af2a5e7f 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -487,9 +487,11 @@ flashupdate.squashfs.noversion Bei Updates werden Versionsüberprüfungen derzei flashupdate.titlereadflash Flash auslesen flashupdate.titlewriteflash Flash schreiben flashupdate.update_with_settings_del_skipped Ordner [%s] kann nicht gelöscht werden. Eintrag wird übersprungen. +flashupdate.update_with_settings_error Error Flashspeicher!\n \nIm neuen Image sind nur noch %ld KB (von %ld KB) frei,\ndas ist zu wenig, um einen sicheren Betrieb zu gewährleisten.\n \nDer Vorgang wird abgebrochen! flashupdate.update_with_settings_processed Image wird bearbeitet... flashupdate.update_with_settings_skipped Ordner [%s] kann nicht gesichert werden. Eintrag wird übersprungen. flashupdate.update_with_settings_successfully Settingsübernahme erfolgreich.\nDas Image kann jetzt geflasht werden. +flashupdate.update_with_settings_warning Warnung Flashspeicher!\n \nIm neuen Image sind nur noch %ld KB (von %ld KB) frei,\ndas ist möglicherweise zu wenig, um einen sicheren Betrieb zu gewährleisten.\n \nSoll der Vorgang trotzdem fortgesetzt werden? flashupdate.updatemode Updatemodus flashupdate.updatemode_internet Internet flashupdate.updatemode_manual von lokalem Update-Verzeichnis diff --git a/data/locale/english.locale b/data/locale/english.locale index 305cf064d..7534161c2 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -487,9 +487,11 @@ flashupdate.squashfs.noversion SquashFS version checks are currently only suppor flashupdate.titlereadflash Reading Flash flashupdate.titlewriteflash Writing Flash flashupdate.update_with_settings_del_skipped Folder [%s] can not be deleted. Entry is skipped. +flashupdate.update_with_settings_error Flash Error!\n \nNew Image only has %ld KB (out of %ld KB) left. Not\nenough space to complete this operation.\n \nCanceling operation! flashupdate.update_with_settings_processed Image is being processed... flashupdate.update_with_settings_skipped Folder [%s] can not be saved. Entry is skipped. flashupdate.update_with_settings_successfully Setting takeover successfully.\nThe image can now be flashed. +flashupdate.update_with_settings_warning Flash Warning!\n \nNew Image only has %ld KB (out of %ld KB) left. Probably not\nenough space to complete this operation...\n \nDo you really want to proceed? flashupdate.updatemode Updatemode flashupdate.updatemode_internet internet flashupdate.updatemode_manual from local update directory diff --git a/data/settingsupdate.conf b/data/settingsupdate.conf index 45eafcac9..5234dc041 100644 --- a/data/settingsupdate.conf +++ b/data/settingsupdate.conf @@ -21,7 +21,17 @@ ## Die Verzeichnisse "/", "/dev", "/proc", "/sys", "/mnt", "/tmp" können nicht gesichert werden!! #------------------------------------------------------------------------------------------------ +#--------------------------------------------------------------------------- +## vor der Sicherung aus dem neuen Image zu löschende Dateien/Verzeichnisse, +## gekennzeichnet durch ein vorangestelltes ~ +# z.B. +# ~/share/tuxbox/neutrino/themes/Classic.theme +#--------------------------------------------------------------------------- + + +#------------- ## Sicherungen +#------------- /etc/hostname /etc/hosts /etc/network @@ -30,6 +40,7 @@ /var/etc /var/tuxbox/config + #---------------------------------------------------------------------------------------- ## von der Sicherung auszuschließende Dateien, gekennzeichnet durch ein vorangestelltes - #---------------------------------------------------------------------------------------- @@ -41,10 +52,3 @@ -/var/tuxbox/config/satellites.xml -/var/tuxbox/config/settingsupdate.conf -/var/tuxbox/config/tobackup.conf - -#---------------------------------------------------------------------------- -## nach der Sicherung aus dem neuen Image zu löschende Dateien/Verzeichnisse, -## gekennzeichnet durch ein vorangestelltes ~ -# z.B. -# ~/share/tuxbox/neutrino/themes/Classic.theme -#---------------------------------------------------------------------------- diff --git a/src/driver/framebuffer.cpp b/src/driver/framebuffer.cpp index 64b18314a..74924ccec 100644 --- a/src/driver/framebuffer.cpp +++ b/src/driver/framebuffer.cpp @@ -774,7 +774,9 @@ void CFrameBuffer::paintBoxRel(const int x, const int y, const int dx, const int char *c = (char *)&col; dfbdest->SetColor(dfbdest, c[1], c[2], c[3], c[0]); #else -#ifndef USE_NEVIS_GXA +#ifdef USE_NEVIS_GXA + OpenThreads::ScopedLock m_lock(mutex); +#else int swidth = stride / sizeof(fb_pixel_t); fb_pixel_t *fbp = getFrameBufferPointer() + (swidth * y); #endif @@ -922,6 +924,7 @@ void CFrameBuffer::paintVLine(int x, int ya, int yb, const fb_pixel_t col) return; #ifdef USE_NEVIS_GXA + OpenThreads::ScopedLock m_lock(mutex); /* draw a single vertical line from point x/ya to x/yb */ unsigned int cmd = GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(2) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA; @@ -947,6 +950,7 @@ void CFrameBuffer::paintVLineRel(int x, int y, int dy, const fb_pixel_t col) return; #ifdef USE_NEVIS_GXA + OpenThreads::ScopedLock m_lock(mutex); /* draw a single vertical line from point x/y with hight dx */ unsigned int cmd = GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(2) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA; @@ -970,6 +974,7 @@ void CFrameBuffer::paintHLine(int xa, int xb, int y, const fb_pixel_t col) return; #ifdef USE_NEVIS_GXA + OpenThreads::ScopedLock m_lock(mutex); /* draw a single horizontal line from point xa/y to xb/y */ unsigned int cmd = GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(2) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA; @@ -994,6 +999,7 @@ void CFrameBuffer::paintHLineRel(int x, int dx, int y, const fb_pixel_t col) return; #ifdef USE_NEVIS_GXA + OpenThreads::ScopedLock m_lock(mutex); /* draw a single horizontal line from point x/y with width dx */ unsigned int cmd = GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(2) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(2) | GXA_CMD_NOT_ALPHA; @@ -1906,6 +1912,7 @@ void CFrameBuffer::blit2FB(void *fbbuff, uint32_t width, uint32_t height, uint32 //printf("CFrameBuffer::blit2FB: data %x Kva %x\n", (int) fbbuff, (int) uKva); if(uKva != NULL) { + OpenThreads::ScopedLock m_lock(mutex); cmd = GXA_CMD_BLT | GXA_CMD_NOT_TEXT | GXA_SRC_BMP_SEL(1) | GXA_DST_BMP_SEL(2) | GXA_PARAM_COUNT(3); _write_gxa(gxa_base, GXA_BMP1_TYPE_REG, (3 << 16) | width); diff --git a/src/driver/framebuffer.h b/src/driver/framebuffer.h index a2a83e961..f7cd84b4e 100644 --- a/src/driver/framebuffer.h +++ b/src/driver/framebuffer.h @@ -34,6 +34,8 @@ #include #include +#include +#include #define fb_pixel_t uint32_t @@ -66,6 +68,7 @@ class CFrameBuffer private: CFrameBuffer(); + OpenThreads::Mutex mutex; struct rgbData { diff --git a/src/gui/ext_update.cpp b/src/gui/ext_update.cpp index 7e4d430e4..4c4ffe169 100644 --- a/src/gui/ext_update.cpp +++ b/src/gui/ext_update.cpp @@ -5,7 +5,7 @@ and some other guys Homepage: http://dbox.cyberphoria.org/ - Copyright (C) 2012 M. Liebmann (micha-bbg) + Copyright (C) 2012-2013 M. Liebmann (micha-bbg) License: GPL @@ -73,6 +73,10 @@ CExtUpdate::CExtUpdate() fLogfile = "/tmp/update.log"; mountPkt = "/tmp/image_mount"; FileHelpers = NULL; + flashErrorFlag = false; + total = bsize = used = 0; + free1 = free2 = free3 = 0; + copyList.clear(); blackList.clear(); deleteList.clear(); @@ -130,6 +134,7 @@ bool CExtUpdate::ErrorReset(bool modus, const std::string & msg1, const std::str bool CExtUpdate::applySettings(const std::string & filename, int mode) { +#define ORGFILE_EXT ".org" if(!FileHelpers) FileHelpers = new CFileHelpers(); @@ -139,11 +144,19 @@ bool CExtUpdate::applySettings(const std::string & filename, int mode) imgFilename = FILESYSTEM_ENCODING_TO_UTF8_STRING(filename); DBG_TIMER_START() + + // make backup file + FileHelpers->copyFile(imgFilename.c_str(), (imgFilename + ORGFILE_EXT).c_str(), 0644); + bool ret = applySettings(); DBG_TIMER_STOP("Image editing") if (!ret) { - if (mtdRamError != "") + if ((mtdRamError != "") && (!flashErrorFlag)) DisplayErrorMessage(mtdRamError.c_str()); + + // error, restore original file + unlink(imgFilename.c_str()); + rename((imgFilename + ORGFILE_EXT).c_str(), imgFilename.c_str()); } else { if (mode == MODE_EXPERT) { @@ -300,8 +313,14 @@ bool CExtUpdate::applySettings() if (res) return ErrorReset(RESET_UNLOAD, "mount error"); - if (!readBackupList(mountPkt)) + if (get_fs_usage(mountPkt.c_str(), total, used, &bsize)) + free1 = (total * bsize) / 1024 - (used * bsize) / 1024; + + if (!readBackupList(mountPkt)) { + if (flashErrorFlag) + return false; return ErrorReset(0, "error readBackupList"); + } res = umount(mountPkt.c_str()); if (res) @@ -497,6 +516,7 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) { char buf[PATH_MAX]; static struct stat FileInfo; + vector::iterator it; f1 = fopen(backupList.c_str(), "r"); if (f1 == NULL) { @@ -573,8 +593,33 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) } fclose(f1); + // read DeleteList + for(it = deleteList.begin(); it != deleteList.end(); ++it) { + line = *it; + if (lstat(line.c_str(), &FileInfo) != -1) { + if ((line.find("*") != std::string::npos) || (line.find("?") != std::string::npos)) { + // Wildcards + WRITE_UPDATE_LOG("delete file list: %s\n", line.c_str()); + deleteFileList(line.c_str()); + } + else if (S_ISREG(FileInfo.st_mode)) { + // File + WRITE_UPDATE_LOG("delete file: %s\n", line.c_str()); + unlink(line.c_str()); + } + else if (S_ISDIR(FileInfo.st_mode)){ + // Directory + WRITE_UPDATE_LOG("delete directory: %s\n", line.c_str()); + FileHelpers->removeDir(line.c_str()); + } + } + } + sync(); + + if (get_fs_usage(mountPkt.c_str(), total, used, &bsize)) + free2 = (total * bsize) / 1024 - (used * bsize) / 1024; + // read copyList - vector::iterator it; for(it = copyList.begin(); it != copyList.end(); ++it) { line = *it; line = trim(line); @@ -619,29 +664,30 @@ bool CExtUpdate::readBackupList(const std::string & dstPath) } } + sync(); - // read DeleteList - for(it = deleteList.begin(); it != deleteList.end(); ++it) { - line = *it; - if (lstat(line.c_str(), &FileInfo) != -1) { - if ((line.find("*") != std::string::npos) || (line.find("?") != std::string::npos)) { - // Wildcards - WRITE_UPDATE_LOG("delete file list: %s\n", line.c_str()); - deleteFileList(line.c_str()); - } - else if (S_ISREG(FileInfo.st_mode)) { - // File - WRITE_UPDATE_LOG("delete file: %s\n", line.c_str()); - unlink(line.c_str()); - } - else if (S_ISDIR(FileInfo.st_mode)){ - // Directory - WRITE_UPDATE_LOG("delete directory: %s\n", line.c_str()); - FileHelpers->removeDir(line.c_str()); - } + if (get_fs_usage(mountPkt.c_str(), total, used, &bsize)) { + long flashWarning = 1000; // 1MB + long flashError = 600; // 600KB + char buf1[1024]; + total = (total * bsize) / 1024; + free3 = total - (used * bsize) / 1024; + printf("##### [%s] %ld KB free org, %ld KB free after delete, %ld KB free now\n", __FUNCTION__, free1, free2, free3); + memset(buf1, '\0', sizeof(buf1)); + if (free3 <= flashError) { + snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR), free3, total); + ShowMsgUTF(LOCALE_MESSAGEBOX_ERROR, buf1, CMessageBox::mbrOk, CMessageBox::mbOk, NEUTRINO_ICON_ERROR); + flashErrorFlag = true; + return false; + } + else if (free3 <= flashWarning) { + snprintf(buf1, sizeof(buf1)-1, g_Locale->getText(LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_WARNING), free3, total); + if (ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, buf1, CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo, NEUTRINO_ICON_INFO) != CMessageBox::mbrYes) { + flashErrorFlag = true; + return false; + } } } - sync(); return true; } diff --git a/src/gui/ext_update.h b/src/gui/ext_update.h index e0291641b..2999c9fa2 100644 --- a/src/gui/ext_update.h +++ b/src/gui/ext_update.h @@ -5,7 +5,7 @@ and some other guys Homepage: http://dbox.cyberphoria.org/ - Copyright (C) 2012 M. Liebmann (micha-bbg) + Copyright (C) 2012-2013 M. Liebmann (micha-bbg) License: GPL @@ -56,6 +56,10 @@ class CExtUpdate CFileHelpers* FileHelpers; std::vector copyList, blackList, deleteList; + bool flashErrorFlag; + long total, bsize, used; + long free1, free2, free3; + bool applySettings(void); bool readBackupList(const std::string & dstPath); bool copyFileList(const std::string & fileList, const std::string & dstPath); diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index 6e0f2ee99..2da99e674 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -1575,7 +1575,7 @@ void CControlAPI::StartPluginCGI(CyhookHandler *hh) if (hh->ParamList["name"] != "") { pluginname = hh->ParamList["name"]; - pluginname=decodeString(pluginname); + //pluginname=decodeString(pluginname); NeutrinoAPI->EventServer->sendEvent(NeutrinoMessages::EVT_START_PLUGIN, CEventServer::INITID_HTTPD, (void *) pluginname.c_str(), diff --git a/src/nhttpd/yhttpd_core/helper.cpp b/src/nhttpd/yhttpd_core/helper.cpp index e2449fbbd..d8a6630aa 100644 --- a/src/nhttpd/yhttpd_core/helper.cpp +++ b/src/nhttpd/yhttpd_core/helper.cpp @@ -214,7 +214,7 @@ std::string decodeString(std::string encodedString) { return result; } //----------------------------------------------------------------------------- -// Encode URLEncoded std::string +// HTMLEncode std::string //----------------------------------------------------------------------------- std::string encodeString(std::string decodedString) { unsigned int len = sizeof(char) * decodedString.length() * 5 + 1; diff --git a/src/nhttpd/yhttpd_core/yrequest.cpp b/src/nhttpd/yhttpd_core/yrequest.cpp index f684f9ddd..679b5c1ce 100644 --- a/src/nhttpd/yhttpd_core/yrequest.cpp +++ b/src/nhttpd/yhttpd_core/yrequest.cpp @@ -160,6 +160,7 @@ bool CWebserverRequest::ParseParams(std::string param_string) { if (!ySplitStringExact(param_string, "&", param, param_string)) ende = true; if (ySplitStringExact(param, "=", name, value)) { + name = decodeString(name); value = trim(decodeString(value)); if (ParameterList[name].empty()) ParameterList[name] = value; @@ -168,11 +169,10 @@ bool CWebserverRequest::ParseParams(std::string param_string) { ParameterList[name] += value; } } + else + name = trim(decodeString(name)); number = string_printf("%d", ParameterList.size() + 1); log_level_printf(7, "ParseParams: name: %s value: %s\n", name.c_str(), value.c_str()); - if(value.empty()){ - name = trim(decodeString(name)); - } ParameterList[number] = name; } return true; @@ -212,19 +212,24 @@ bool CWebserverRequest::ParseHeader(std::string header) { // query data is splitted and stored in ParameterList //----------------------------------------------------------------------------- void CWebserverRequest::analyzeURL(std::string url) { + std::string fullurl = ""; if(!ParameterList.empty()) ParameterList.clear(); + // URI decode - url = trim(url, "\r\n"); // non-HTTP-Standard: allow \r or \n in URL. Delete it. - UrlData["fullurl"] = url; + fullurl = decodeString(url); + fullurl = trim(fullurl, "\r\n"); // non-HTTP-Standard: allow \r or \n in URL. Delete it. + UrlData["fullurl"] = fullurl; + // split Params if (ySplitString(url, "?", UrlData["url"], UrlData["paramstring"])){ // split pure URL and all Params + UrlData["url"] = decodeString(UrlData["url"]); ParseParams( UrlData["paramstring"]); // split params to ParameterList }else{ // No Params - url = decodeString(url); - UrlData["url"] = url; + UrlData["url"] = fullurl; } + if (!ySplitStringLast(UrlData["url"], "/", UrlData["path"], UrlData["filename"])) { UrlData["path"] = "/"; // Set "/" if not contained diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index 2e4ff8685..d75385ff9 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -193,7 +193,7 @@ int check_dir(const char * dir) return ret; } -bool get_fs_usage(const char * dir, long &btotal, long &bused) +bool get_fs_usage(const char * dir, long &btotal, long &bused, long *bsize/*=NULL*/) { btotal = bused = 0; struct statfs s; @@ -201,6 +201,8 @@ bool get_fs_usage(const char * dir, long &btotal, long &bused) if (::statfs(dir, &s) == 0 && s.f_blocks) { btotal = s.f_blocks; bused = s.f_blocks - s.f_bfree; + if (bsize != NULL) + *bsize = s.f_bsize; //printf("fs (%s): total %ld used %ld\n", dir, btotal, bused); return true; } diff --git a/src/system/helpers.h b/src/system/helpers.h index 2d9731494..59d04a8bb 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -31,7 +31,7 @@ int safe_mkdir(char * path); bool file_exists(const char *filename); void wakeup_hdd(const char *hdd_dir); int check_dir(const char * dir); -bool get_fs_usage(const char * dir, long &total, long &used); +bool get_fs_usage(const char * dir, long &total, long &used, long *bsize=NULL); bool get_mem_usage(unsigned long &total, unsigned long &free); std::string trim(std::string &str, const std::string &trimChars = " \n\r\t"); diff --git a/src/system/locals.h b/src/system/locals.h index 0efdd2a6b..d0794dbd5 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -514,9 +514,11 @@ typedef enum LOCALE_FLASHUPDATE_TITLEREADFLASH, LOCALE_FLASHUPDATE_TITLEWRITEFLASH, LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_DEL_SKIPPED, + LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_ERROR, LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_PROCESSED, LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SKIPPED, LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_SUCCESSFULLY, + LOCALE_FLASHUPDATE_UPDATE_WITH_SETTINGS_WARNING, LOCALE_FLASHUPDATE_UPDATEMODE, LOCALE_FLASHUPDATE_UPDATEMODE_INTERNET, LOCALE_FLASHUPDATE_UPDATEMODE_MANUAL, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 236957606..e37bf9216 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -514,9 +514,11 @@ const char * locale_real_names[] = "flashupdate.titlereadflash", "flashupdate.titlewriteflash", "flashupdate.update_with_settings_del_skipped", + "flashupdate.update_with_settings_error", "flashupdate.update_with_settings_processed", "flashupdate.update_with_settings_skipped", "flashupdate.update_with_settings_successfully", + "flashupdate.update_with_settings_warning", "flashupdate.updatemode", "flashupdate.updatemode_internet", "flashupdate.updatemode_manual",