From d133701c83a732a42dfb37f471fddf58b940bfcd Mon Sep 17 00:00:00 2001 From: focus Date: Wed, 12 May 2010 12:10:12 +0000 Subject: [PATCH] Search mtd device to update by name git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@581 e54a6e83-5905-42d5-8d5c-058d10e6a962 --- src/gui/update.cpp | 10 +++++++++- src/gui/update.h | 1 + src/neutrino_menue.cpp | 42 ++++++++++++++++++++++++++++++++++++++-- src/system/flashtool.cpp | 13 +++++++++++++ src/system/flashtool.h | 2 +- 5 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/gui/update.cpp b/src/gui/update.cpp index 8360a80fd..9db9d8ec1 100644 --- a/src/gui/update.cpp +++ b/src/gui/update.cpp @@ -83,6 +83,8 @@ CFlashUpdate::CFlashUpdate() :CProgressWindow() { setTitle(LOCALE_FLASHUPDATE_HEAD); + sysfs = CMTDInfo::getInstance()->findMTDsystem(); + printf("Mtd partition to update: %s\n", sysfs.c_str()); } @@ -358,6 +360,11 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &) paint(); + if(sysfs.size() < 8) { + ShowHintUTF(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_FLASHUPDATE_CANTOPENMTD)); + hide(); + return menu_return::RETURN_REPAINT; + } if(!checkVersion4Update()) { hide(); return menu_return::RETURN_REPAINT; @@ -389,7 +396,8 @@ int CFlashUpdate::exec(CMenuTarget* parent, const std::string &) showGlobalStatus(40); CFlashTool ft; - ft.setMTDDevice(MTD_DEVICE_OF_UPDATE_PART); + //ft.setMTDDevice(MTD_DEVICE_OF_UPDATE_PART); + ft.setMTDDevice(sysfs); ft.setStatusViewer(this); showStatusMessageUTF(g_Locale->getText(LOCALE_FLASHUPDATE_MD5CHECK)); // UTF-8 diff --git a/src/gui/update.h b/src/gui/update.h index 9728b1cbb..99b4aaae7 100644 --- a/src/gui/update.h +++ b/src/gui/update.h @@ -46,6 +46,7 @@ class CFlashUpdate : public CProgressWindow private: std::string filename; std::string file_md5; + std::string sysfs; char fileType; std::string installedVersion; diff --git a/src/neutrino_menue.cpp b/src/neutrino_menue.cpp index 2060f87c3..fc7c14ff5 100644 --- a/src/neutrino_menue.cpp +++ b/src/neutrino_menue.cpp @@ -461,6 +461,7 @@ public: #include #include +extern int cs_test_card(int unit, char * str); int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) { if (parent) @@ -527,7 +528,43 @@ int CTestMenu::exec(CMenuTarget* parent, const std::string &actionKey) close(fd); ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); } - else if (actionKey == "card") { + else if (actionKey == "card0") { + char str[255]; + int ret = cs_test_card(0, str); + switch(ret) { + case 0: + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); + break; + case -1: + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + break; + case -2: + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + break; + default: + case -3: + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 1 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + break; + } + } + else if (actionKey == "card1") { + char str[255]; + int ret = cs_test_card(1, str); + switch(ret) { + case 0: + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, str, CMessageBox::mbrBack, CMessageBox::mbBack, "info.raw"); + break; + case -1: + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 ATR read failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + break; + case -2: + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 reset failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + break; + default: + case -3: + ShowMsgUTF(LOCALE_MESSAGEBOX_INFO, "Smardcard 2 open failed", CMessageBox::mbrBack, CMessageBox::mbBack, "info"); + break; + } } else if (actionKey == "hdd") { char buffer[255]; @@ -643,7 +680,8 @@ void CNeutrinoApp::InitMainMenu(CMenuWidget &mainMenu, CMenuWidget &mainSettings CTestMenu * testHandler = new CTestMenu(); TestMenu->addItem(new CMenuForwarderNonLocalized("VFD", true, NULL, testHandler, "vfd")); TestMenu->addItem(new CMenuForwarderNonLocalized("Network", true, NULL, testHandler, "network")); - TestMenu->addItem(new CMenuForwarderNonLocalized("Smartcard", true, NULL, testHandler, "card")); + TestMenu->addItem(new CMenuForwarderNonLocalized("Smartcard 1", true, NULL, testHandler, "card0")); + TestMenu->addItem(new CMenuForwarderNonLocalized("Smartcard 2", true, NULL, testHandler, "card1")); TestMenu->addItem(new CMenuForwarderNonLocalized("HDD", true, NULL, testHandler, "hdd")); TestMenu->addItem(new CMenuForwarderNonLocalized("Buttons", true, NULL, testHandler, "buttons")); TestMenu->addItem(new CMenuForwarderNonLocalized("Scan 12538000", true, NULL, testHandler, "scan")); diff --git a/src/system/flashtool.cpp b/src/system/flashtool.cpp index c319c0df9..4f61ec192 100644 --- a/src/system/flashtool.cpp +++ b/src/system/flashtool.cpp @@ -539,3 +539,16 @@ int CMTDInfo::getMTDEraseSize( const std::string & filename ) { return getMTDEraseSize( findMTDNumber(filename) ); } + +std::string CMTDInfo::findMTDsystem() +{ + std::string sysfs = "systemFS"; + + for(int i = 0; i < getMTDCount(); i++) { + if(getMTDName(i) == sysfs) { +printf("systemFS: %d dev %s\n", i, getMTDFileName(i).c_str()); + return getMTDFileName(i); + } + } + return ""; +} diff --git a/src/system/flashtool.h b/src/system/flashtool.h index 18eaf4b8d..4b8b55bdb 100644 --- a/src/system/flashtool.h +++ b/src/system/flashtool.h @@ -124,7 +124,7 @@ class CMTDInfo int getMTDEraseSize( const std::string & filename ); int findMTDNumber(const std::string & filename); - + std::string findMTDsystem(); };