|
4 | 4 | #include "AppConfig.h" |
5 | 5 | #include "CubicSDR.h" |
6 | 6 |
|
| 7 | +#include <wx/msgdlg.h> |
| 8 | + |
7 | 9 | DeviceConfig::DeviceConfig() : deviceId("") { |
8 | 10 | ppm.store(0); |
9 | 11 | offset.store(0); |
@@ -505,6 +507,51 @@ bool AppConfig::getBookmarksVisible() { |
505 | 507 | return bookmarksVisible.load(); |
506 | 508 | } |
507 | 509 |
|
| 510 | +void AppConfig::setRecordingPath(std::string recPath) { |
| 511 | + recordingPath = recPath; |
| 512 | +} |
| 513 | + |
| 514 | +std::string AppConfig::getRecordingPath() { |
| 515 | + return recordingPath; |
| 516 | +} |
| 517 | + |
| 518 | +bool AppConfig::verifyRecordingPath() { |
| 519 | + string recPathStr = wxGetApp().getConfig()->getRecordingPath(); |
| 520 | + |
| 521 | + if (recPathStr.empty()) { |
| 522 | + wxMessageBox( wxT("Recording path is not set. Please use 'Set Recording Path' from the 'File' Menu."), wxT("Recording Path Error"), wxICON_INFORMATION); |
| 523 | + |
| 524 | + return false; |
| 525 | + } |
| 526 | + |
| 527 | + wxFileName recPath(recPathStr); |
| 528 | + |
| 529 | + if (!recPath.Exists() || !recPath.IsDirWritable()) { |
| 530 | + wxMessageBox( wxT("Recording path does not exist or is not writable. Please use 'Set Recording Path' from the 'File' Menu."), wxT("Recording Path Error"), wxICON_INFORMATION); |
| 531 | + |
| 532 | + return false; |
| 533 | + } |
| 534 | + |
| 535 | + return true; |
| 536 | +} |
| 537 | + |
| 538 | + |
| 539 | +void AppConfig::setRecordingSquelchOption(int enumChoice) { |
| 540 | + recordingSquelchOption = enumChoice; |
| 541 | +} |
| 542 | + |
| 543 | +int AppConfig::getRecordingSquelchOption() { |
| 544 | + return recordingSquelchOption; |
| 545 | +} |
| 546 | + |
| 547 | +void AppConfig::setRecordingFileTimeLimit(int nbSeconds) { |
| 548 | + recordingFileTimeLimitSeconds = nbSeconds; |
| 549 | +} |
| 550 | + |
| 551 | +int AppConfig::getRecordingFileTimeLimit() { |
| 552 | + return recordingFileTimeLimitSeconds; |
| 553 | +} |
| 554 | + |
508 | 555 |
|
509 | 556 | void AppConfig::setConfigName(std::string configName) { |
510 | 557 | this->configName = configName; |
@@ -559,6 +606,12 @@ bool AppConfig::save() { |
559 | 606 | *window_node->newChild("bookmark_visible") = bookmarksVisible.load(); |
560 | 607 | } |
561 | 608 |
|
| 609 | + //Recording settings: |
| 610 | + DataNode *rec_node = cfg.rootNode()->newChild("recording"); |
| 611 | + *rec_node->newChild("path") = recordingPath; |
| 612 | + *rec_node->newChild("squelch") = recordingSquelchOption; |
| 613 | + *rec_node->newChild("file_time_limit") = recordingFileTimeLimitSeconds; |
| 614 | + |
562 | 615 | DataNode *devices_node = cfg.rootNode()->newChild("devices"); |
563 | 616 |
|
564 | 617 | std::map<std::string, DeviceConfig *>::iterator device_config_i; |
@@ -741,6 +794,26 @@ bool AppConfig::load() { |
741 | 794 | } |
742 | 795 | } |
743 | 796 |
|
| 797 | + //Recording settings: |
| 798 | + if (cfg.rootNode()->hasAnother("recording")) { |
| 799 | + DataNode *rec_node = cfg.rootNode()->getNext("recording"); |
| 800 | + |
| 801 | + if (rec_node->hasAnother("path")) { |
| 802 | + DataNode *rec_path = rec_node->getNext("path"); |
| 803 | + recordingPath = rec_path->element()->toString(); |
| 804 | + } |
| 805 | + |
| 806 | + if (rec_node->hasAnother("squelch")) { |
| 807 | + DataNode *rec_squelch = rec_node->getNext("squelch"); |
| 808 | + rec_squelch->element()->get(recordingSquelchOption); |
| 809 | + } |
| 810 | + |
| 811 | + if (rec_node->hasAnother("file_time_limit")) { |
| 812 | + DataNode *rec_file_time_limit = rec_node->getNext("file_time_limit"); |
| 813 | + rec_file_time_limit->element()->get(recordingFileTimeLimitSeconds); |
| 814 | + } |
| 815 | + } |
| 816 | + |
744 | 817 | if (cfg.rootNode()->hasAnother("devices")) { |
745 | 818 | DataNode *devices_node = cfg.rootNode()->getNext("devices"); |
746 | 819 |
|
|
0 commit comments