scsi2sd-util.cc 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. // Copyright (C) 2014 Michael McMaster <michael@codesrc.com>
  2. //
  3. // This file is part of SCSI2SD.
  4. //
  5. // SCSI2SD is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // SCSI2SD is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with SCSI2SD. If not, see <http://www.gnu.org/licenses/>.
  17. // For compilers that support precompilation, includes "wx/wx.h".
  18. #include <wx/wxprec.h>
  19. #ifndef WX_PRECOMP
  20. #include <wx/wx.h>
  21. #endif
  22. #include <wx/filedlg.h>
  23. #include <wx/notebook.h>
  24. #include <wx/progdlg.h>
  25. #include <wx/utils.h>
  26. #include <wx/windowptr.h>
  27. #include <wx/thread.h>
  28. #include <zipper.hh>
  29. #include "ConfigUtil.hh"
  30. #include "TargetPanel.hh"
  31. #include "SCSI2SD_Bootloader.hh"
  32. #include "SCSI2SD_HID.hh"
  33. #include "Firmware.hh"
  34. #include <algorithm>
  35. #include <vector>
  36. #include <set>
  37. #include <sstream>
  38. #if __cplusplus >= 201103L
  39. #include <cstdint>
  40. #include <memory>
  41. using std::shared_ptr;
  42. #else
  43. #include <stdint.h>
  44. #include <tr1/memory>
  45. using std::tr1::shared_ptr;
  46. #endif
  47. using namespace SCSI2SD;
  48. class ProgressWrapper
  49. {
  50. public:
  51. void setProgressDialog(
  52. const wxWindowPtr<wxGenericProgressDialog>& dlg,
  53. size_t maxRows)
  54. {
  55. myProgressDialog = dlg;
  56. myMaxRows = maxRows;
  57. myNumRows = 0;
  58. }
  59. void clearProgressDialog()
  60. {
  61. myProgressDialog.reset();
  62. }
  63. void update(unsigned char arrayId, unsigned short rowNum)
  64. {
  65. if (!myProgressDialog) return;
  66. myNumRows++;
  67. std::stringstream ss;
  68. ss << "Writing flash array " <<
  69. static_cast<int>(arrayId) << " row " <<
  70. static_cast<int>(rowNum);
  71. std::clog << ss.str() << std::endl;
  72. myProgressDialog->Update(myNumRows, ss.str());
  73. }
  74. private:
  75. wxWindowPtr<wxGenericProgressDialog> myProgressDialog;
  76. size_t myMaxRows;
  77. size_t myNumRows;
  78. };
  79. static ProgressWrapper TheProgressWrapper;
  80. extern "C"
  81. void ProgressUpdate(unsigned char arrayId, unsigned short rowNum)
  82. {
  83. TheProgressWrapper.update(arrayId, rowNum);
  84. }
  85. namespace
  86. {
  87. class TimerLock
  88. {
  89. public:
  90. TimerLock(wxTimer* timer) :
  91. myTimer(timer),
  92. myInterval(myTimer->GetInterval())
  93. {
  94. myTimer->Stop();
  95. };
  96. virtual ~TimerLock()
  97. {
  98. if (myTimer && myInterval > 0)
  99. {
  100. myTimer->Start(myInterval);
  101. }
  102. }
  103. private:
  104. wxTimer* myTimer;
  105. int myInterval;
  106. };
  107. class AppFrame : public wxFrame
  108. {
  109. public:
  110. AppFrame() :
  111. wxFrame(NULL, wxID_ANY, "scsi2sd-util", wxPoint(50, 50), wxSize(600, 650)),
  112. myInitialConfig(false),
  113. myTickCounter(0)
  114. {
  115. wxMenu *menuFile = new wxMenu();
  116. menuFile->Append(
  117. ID_ConfigDefaults,
  118. "Load &Defaults",
  119. "Load default configuration options.");
  120. menuFile->Append(
  121. ID_Firmware,
  122. "&Upgrade Firmware...",
  123. "Upgrade or inspect device firmware version.");
  124. menuFile->AppendSeparator();
  125. menuFile->Append(wxID_EXIT);
  126. wxMenu *menuHelp = new wxMenu();
  127. menuHelp->Append(wxID_ABOUT);
  128. wxMenuBar *menuBar = new wxMenuBar();
  129. menuBar->Append( menuFile, "&File" );
  130. menuBar->Append( menuHelp, "&Help" );
  131. SetMenuBar( menuBar );
  132. CreateStatusBar();
  133. SetStatusText( "Searching for SCSI2SD" );
  134. {
  135. wxPanel* cfgPanel = new wxPanel(this);
  136. wxFlexGridSizer *fgs = new wxFlexGridSizer(2, 1, 5, 5);
  137. wxNotebook* tabs = new wxNotebook(cfgPanel, ID_Notebook);
  138. for (int i = 0; i < MAX_SCSI_TARGETS; ++i)
  139. {
  140. TargetPanel* target =
  141. new TargetPanel(tabs, ConfigUtil::Default(i));
  142. myTargets.push_back(target);
  143. std::stringstream ss;
  144. ss << "Device " << (i + 1);
  145. tabs->AddPage(target, ss.str());
  146. }
  147. fgs->Add(tabs);
  148. wxPanel* btnPanel = new wxPanel(cfgPanel);
  149. wxFlexGridSizer *btnFgs = new wxFlexGridSizer(1, 2, 5, 5);
  150. btnFgs->Add(new wxButton(btnPanel, ID_BtnLoad, wxT("Load from device")));
  151. mySaveButton =
  152. new wxButton(btnPanel, ID_BtnSave, wxT("Save to device"));
  153. btnFgs->Add(mySaveButton);
  154. {
  155. wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL);
  156. hbox->Add(btnFgs, 1, wxALL | wxEXPAND, 15);
  157. btnPanel->SetSizer(hbox);
  158. fgs->Add(btnPanel);
  159. }
  160. {
  161. wxBoxSizer* hbox = new wxBoxSizer(wxHORIZONTAL);
  162. hbox->Add(fgs, 1, wxALL | wxEXPAND, 15);
  163. cfgPanel->SetSizer(hbox);
  164. }
  165. }
  166. myTimer = new wxTimer(this, ID_Timer);
  167. myTimer->Start(1000); //ms
  168. }
  169. private:
  170. std::vector<TargetPanel*> myTargets;
  171. wxButton* mySaveButton;
  172. wxTimer* myTimer;
  173. shared_ptr<HID> myHID;
  174. shared_ptr<Bootloader> myBootloader;
  175. bool myInitialConfig;
  176. uint8_t myTickCounter;
  177. void onConfigChanged(wxCommandEvent& event)
  178. {
  179. evaluate();
  180. }
  181. void evaluate()
  182. {
  183. bool valid = true;
  184. // Check for duplicate SCSI IDs
  185. std::set<uint8_t> enabledID;
  186. // Check for overlapping SD sectors.
  187. std::vector<std::pair<uint32_t, uint64_t> > sdSectors;
  188. bool isTargetEnabled = false; // Need at least one enabled
  189. for (size_t i = 0; i < myTargets.size(); ++i)
  190. {
  191. valid = myTargets[i]->evaluate() && valid;
  192. if (myTargets[i]->isEnabled())
  193. {
  194. isTargetEnabled = true;
  195. uint8_t scsiID = myTargets[i]->getSCSIId();
  196. if (enabledID.find(scsiID) != enabledID.end())
  197. {
  198. myTargets[i]->setDuplicateID(true);
  199. valid = false;
  200. }
  201. else
  202. {
  203. enabledID.insert(scsiID);
  204. myTargets[i]->setDuplicateID(false);
  205. }
  206. auto sdSectorRange = myTargets[i]->getSDSectorRange();
  207. for (auto it(sdSectors.begin()); it != sdSectors.end(); ++it)
  208. {
  209. if (sdSectorRange.first < it->second &&
  210. sdSectorRange.second > it->first)
  211. {
  212. valid = false;
  213. myTargets[i]->setSDSectorOverlap(true);
  214. }
  215. else
  216. {
  217. myTargets[i]->setSDSectorOverlap(false);
  218. }
  219. }
  220. sdSectors.push_back(sdSectorRange);
  221. }
  222. else
  223. {
  224. myTargets[i]->setDuplicateID(false);
  225. myTargets[i]->setSDSectorOverlap(false);
  226. }
  227. }
  228. valid = valid && isTargetEnabled; // Need at least one.
  229. mySaveButton->Enable(valid && myHID);
  230. }
  231. enum
  232. {
  233. ID_ConfigDefaults = wxID_HIGHEST + 1,
  234. ID_Firmware,
  235. ID_Timer,
  236. ID_Notebook,
  237. ID_BtnLoad,
  238. ID_BtnSave
  239. };
  240. void OnID_ConfigDefaults(wxCommandEvent& event)
  241. {
  242. for (size_t i = 0; i < myTargets.size(); ++i)
  243. {
  244. myTargets[i]->setConfig(ConfigUtil::Default(i));
  245. }
  246. }
  247. void OnID_Firmware(wxCommandEvent& event)
  248. {
  249. TimerLock lock(myTimer);
  250. doFirmwareUpdate();
  251. }
  252. void doFirmwareUpdate()
  253. {
  254. wxFileDialog dlg(
  255. this,
  256. "Load firmware file",
  257. "",
  258. "",
  259. "SCSI2SD Firmware files (*.cyacd)|*.cyacd",
  260. wxFD_OPEN | wxFD_FILE_MUST_EXIST);
  261. if (dlg.ShowModal() == wxID_CANCEL) return;
  262. std::string filename(dlg.GetPath());
  263. try
  264. {
  265. if (!myHID) myHID.reset(HID::Open());
  266. if (myHID)
  267. {
  268. std::clog << "Resetting SCSI2SD into bootloader" << std::endl;
  269. myHID->enterBootloader();
  270. myHID.reset();
  271. }
  272. if (myBootloader)
  273. {
  274. // Verify the USB HID connection is valid
  275. if (!myBootloader->ping())
  276. {
  277. myBootloader.reset();
  278. }
  279. }
  280. for (int i = 0; !myBootloader && (i < 10); ++i)
  281. {
  282. std::clog << "Searching for bootloader" << std::endl;
  283. myBootloader.reset(Bootloader::Open());
  284. wxMilliSleep(100);
  285. }
  286. }
  287. catch (std::exception& e)
  288. {
  289. std::clog << e.what() << std::endl;
  290. SetStatusText(e.what());
  291. myHID.reset();
  292. myBootloader.reset();
  293. }
  294. if (!myBootloader)
  295. {
  296. wxMessageBox(
  297. "SCSI2SD not found",
  298. "Device not ready",
  299. wxOK | wxICON_ERROR);
  300. return;
  301. }
  302. if (!myBootloader->isCorrectFirmware(filename))
  303. {
  304. // TODO allow "force" option
  305. wxMessageBox(
  306. "Wrong filename",
  307. "Wrong filename",
  308. wxOK | wxICON_ERROR);
  309. return;
  310. }
  311. int totalFlashRows = 0;
  312. try
  313. {
  314. Firmware firmware(filename);
  315. totalFlashRows = firmware.totalFlashRows();
  316. }
  317. catch (std::exception& e)
  318. {
  319. SetStatusText(e.what());
  320. std::stringstream msg;
  321. msg << "Could not open firmware file: " << e.what();
  322. wxMessageBox(
  323. msg.str(),
  324. "Bad file",
  325. wxOK | wxICON_ERROR);
  326. return;
  327. }
  328. {
  329. wxWindowPtr<wxGenericProgressDialog> progress(
  330. new wxGenericProgressDialog(
  331. "Loading firmware",
  332. "Loading firmware",
  333. totalFlashRows,
  334. this,
  335. wxPD_APP_MODAL)
  336. );
  337. TheProgressWrapper.setProgressDialog(progress, totalFlashRows);
  338. }
  339. std::clog << "Upgrading firmware from file: " << filename << std::endl;
  340. try
  341. {
  342. myBootloader->load(filename, &ProgressUpdate);
  343. TheProgressWrapper.clearProgressDialog();
  344. wxMessageBox(
  345. "Firmware update successful",
  346. "Firmware OK",
  347. wxOK);
  348. SetStatusText("Firmware update successful");
  349. myHID.reset();
  350. myBootloader.reset();
  351. }
  352. catch (std::exception& e)
  353. {
  354. TheProgressWrapper.clearProgressDialog();
  355. SetStatusText(e.what());
  356. myHID.reset();
  357. myBootloader.reset();
  358. wxMessageBox(
  359. "Firmware Update Failed",
  360. e.what(),
  361. wxOK | wxICON_ERROR);
  362. }
  363. }
  364. void OnID_Timer(wxTimerEvent& event)
  365. {
  366. // Check if we are connected to the HID device.
  367. // AND/or bootloader device.
  368. try
  369. {
  370. if (myBootloader)
  371. {
  372. // Verify the USB HID connection is valid
  373. if (!myBootloader->ping())
  374. {
  375. myBootloader.reset();
  376. }
  377. }
  378. if (!myBootloader)
  379. {
  380. myBootloader.reset(Bootloader::Open());
  381. if (myBootloader)
  382. {
  383. SetStatusText(wxT("SCSI2SD Bootloader Ready"));
  384. }
  385. }
  386. if (myHID)
  387. {
  388. // Verify the USB HID connection is valid
  389. if (!myHID->ping())
  390. {
  391. myHID.reset();
  392. }
  393. }
  394. if (!myHID)
  395. {
  396. myHID.reset(HID::Open());
  397. if (myHID)
  398. {
  399. uint16_t version = myHID->getFirmwareVersion();
  400. if (version == 0)
  401. {
  402. // Oh dear, old firmware
  403. SetStatusText(wxT("Firmware update required"));
  404. myHID.reset();
  405. }
  406. else
  407. {
  408. SetStatusText(wxT("SCSI2SD Ready"));
  409. if (!myInitialConfig)
  410. {
  411. wxCommandEvent loadEvent(wxEVT_NULL, ID_BtnLoad);
  412. GetEventHandler()->AddPendingEvent(loadEvent);
  413. }
  414. }
  415. }
  416. else
  417. {
  418. char ticks[] = {'/', '-', '\\', '|'};
  419. std::stringstream ss;
  420. ss << "Searching for SCSI2SD device " << ticks[myTickCounter % sizeof(ticks)];
  421. myTickCounter++;
  422. SetStatusText(ss.str());
  423. }
  424. }
  425. }
  426. catch (std::runtime_error& e)
  427. {
  428. std::clog << e.what() << std::endl;
  429. SetStatusText(e.what());
  430. }
  431. evaluate();
  432. }
  433. void doLoad(wxCommandEvent& event)
  434. {
  435. TimerLock lock(myTimer);
  436. if (!myHID) return;
  437. std::clog << "Loading configuration" << std::endl;
  438. wxWindowPtr<wxGenericProgressDialog> progress(
  439. new wxGenericProgressDialog(
  440. "Load config settings",
  441. "Loading config settings",
  442. 100,
  443. this,
  444. wxPD_APP_MODAL | wxPD_CAN_ABORT)
  445. );
  446. int flashRow = SCSI_CONFIG_0_ROW;
  447. int currentProgress = 0;
  448. int totalProgress = myTargets.size() * SCSI_CONFIG_ROWS;
  449. for (size_t i = 0;
  450. i < myTargets.size();
  451. ++i, flashRow += SCSI_CONFIG_ROWS)
  452. {
  453. std::vector<uint8_t> raw(sizeof(TargetConfig));
  454. for (size_t j = 0; j < SCSI_CONFIG_ROWS; ++j)
  455. {
  456. std::stringstream ss;
  457. ss << "Reading flash array " << SCSI_CONFIG_ARRAY <<
  458. " row " << (flashRow + j);
  459. SetStatusText(ss.str());
  460. std::clog << ss.str() << std::endl;
  461. currentProgress += 1;
  462. if (!progress->Update(
  463. (100 * currentProgress) / totalProgress,
  464. ss.str()
  465. )
  466. )
  467. {
  468. goto abort;
  469. }
  470. std::vector<uint8_t> flashData;
  471. try
  472. {
  473. myHID->readFlashRow(
  474. SCSI_CONFIG_ARRAY, flashRow + j, flashData);
  475. }
  476. catch (std::runtime_error& e)
  477. {
  478. SetStatusText(e.what());
  479. goto err;
  480. }
  481. std::copy(
  482. flashData.begin(),
  483. flashData.end(),
  484. &raw[j * SCSI_CONFIG_ROW_SIZE]);
  485. }
  486. myTargets[i]->setConfig(ConfigUtil::fromBytes(&raw[0]));
  487. }
  488. myInitialConfig = true;
  489. SetStatusText("Load Complete");
  490. std::clog << "Load Complete" << std::endl;
  491. while (progress->Update(100, "Load Complete"))
  492. {
  493. // Wait for the user to click "Close"
  494. wxMilliSleep(50);
  495. }
  496. goto out;
  497. err:
  498. SetStatusText("Load failed");
  499. std::clog << "Load failed" << std::endl;
  500. while (progress->Update(100, "Load failed"))
  501. {
  502. // Wait for the user to click "Close"
  503. wxMilliSleep(50);
  504. }
  505. goto out;
  506. abort:
  507. SetStatusText("Load Aborted");
  508. std::clog << "Load Aborted" << std::endl;
  509. out:
  510. return;
  511. }
  512. void doSave(wxCommandEvent& event)
  513. {
  514. TimerLock lock(myTimer);
  515. if (!myHID) return;
  516. std::clog << "Saving configuration" << std::endl;
  517. wxWindowPtr<wxGenericProgressDialog> progress(
  518. new wxGenericProgressDialog(
  519. "Save config settings",
  520. "Saving config settings",
  521. 100,
  522. this,
  523. wxPD_APP_MODAL | wxPD_CAN_ABORT)
  524. );
  525. int flashRow = SCSI_CONFIG_0_ROW;
  526. int currentProgress = 0;
  527. int totalProgress = myTargets.size() * SCSI_CONFIG_ROWS;
  528. for (size_t i = 0;
  529. i < myTargets.size();
  530. ++i, flashRow += SCSI_CONFIG_ROWS)
  531. {
  532. TargetConfig config(myTargets[i]->getConfig());
  533. std::vector<uint8_t> raw(ConfigUtil::toBytes(config));
  534. for (size_t j = 0; j < SCSI_CONFIG_ROWS; ++j)
  535. {
  536. std::stringstream ss;
  537. ss << "Programming flash array " << SCSI_CONFIG_ARRAY <<
  538. " row " << (flashRow + j);
  539. SetStatusText(ss.str());
  540. std::clog << ss.str() << std::endl;
  541. currentProgress += 1;
  542. if (!progress->Update(
  543. (100 * currentProgress) / totalProgress,
  544. ss.str()
  545. )
  546. )
  547. {
  548. goto abort;
  549. }
  550. std::vector<uint8_t> flashData(SCSI_CONFIG_ROW_SIZE, 0);
  551. std::copy(
  552. &raw[j * SCSI_CONFIG_ROW_SIZE],
  553. &raw[(1+j) * SCSI_CONFIG_ROW_SIZE],
  554. flashData.begin());
  555. try
  556. {
  557. myHID->writeFlashRow(
  558. SCSI_CONFIG_ARRAY, flashRow + j, flashData);
  559. }
  560. catch (std::runtime_error& e)
  561. {
  562. std::clog << e.what() << std::endl;
  563. SetStatusText(e.what());
  564. goto err;
  565. }
  566. }
  567. }
  568. // Reboot so new settings take effect.
  569. myHID->enterBootloader();
  570. myHID.reset();
  571. SetStatusText("Save Complete");
  572. std::clog << "Save Complete" << std::endl;
  573. while (progress->Update(100, "Save Complete"))
  574. {
  575. // Wait for the user to click "Close"
  576. wxMilliSleep(50);
  577. }
  578. goto out;
  579. err:
  580. SetStatusText("Save failed");
  581. std::clog << "Save failed" << std::endl;
  582. while (progress->Update(100, "Save failed"))
  583. {
  584. // Wait for the user to click "Close"
  585. wxMilliSleep(50);
  586. }
  587. goto out;
  588. abort:
  589. SetStatusText("Save Aborted");
  590. std::clog << "Save Aborted" << std::endl;
  591. out:
  592. (void) true; // empty statement.
  593. }
  594. void OnExit(wxCommandEvent& event)
  595. {
  596. Close(true);
  597. }
  598. void OnAbout(wxCommandEvent& event)
  599. {
  600. wxMessageBox(
  601. "SCSI2SD (scsi2sd-util)\n"
  602. "Copyright (C) 2014 Michael McMaster <michael@codesrc.com>\n"
  603. "\n"
  604. "This program is free software: you can redistribute it and/or modify\n"
  605. "it under the terms of the GNU General Public License as published by\n"
  606. "the Free Software Foundation, either version 3 of the License, or\n"
  607. "(at your option) any later version.\n"
  608. "\n"
  609. "This program is distributed in the hope that it will be useful,\n"
  610. "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
  611. "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
  612. "GNU General Public License for more details.\n"
  613. "\n"
  614. "You should have received a copy of the GNU General Public License\n"
  615. "along with this program. If not, see <http://www.gnu.org/licenses/>.\n",
  616. "About scsi2sd-util", wxOK | wxICON_INFORMATION );
  617. }
  618. wxDECLARE_EVENT_TABLE();
  619. };
  620. wxBEGIN_EVENT_TABLE(AppFrame, wxFrame)
  621. EVT_MENU(AppFrame::ID_ConfigDefaults, AppFrame::OnID_ConfigDefaults)
  622. EVT_MENU(AppFrame::ID_Firmware, AppFrame::OnID_Firmware)
  623. EVT_MENU(wxID_EXIT, AppFrame::OnExit)
  624. EVT_MENU(wxID_ABOUT, AppFrame::OnAbout)
  625. EVT_TIMER(AppFrame::ID_Timer, AppFrame::OnID_Timer)
  626. EVT_COMMAND(wxID_ANY, ConfigChangedEvent, AppFrame::onConfigChanged)
  627. EVT_BUTTON(ID_BtnSave, AppFrame::doSave)
  628. EVT_BUTTON(ID_BtnLoad, AppFrame::doLoad)
  629. wxEND_EVENT_TABLE()
  630. class App : public wxApp
  631. {
  632. public:
  633. virtual bool OnInit()
  634. {
  635. AppFrame* frame = new AppFrame();
  636. frame->Show(true);
  637. SetTopWindow(frame);
  638. return true;
  639. }
  640. };
  641. } // namespace
  642. // Main Method
  643. wxIMPLEMENT_APP(App);