| 808 | } |
| 809 | |
| 810 | bool MainWindow::load_config_from_json(QJsonDocument &doc, bool &haveDecoder) |
| 811 | { |
| 812 | haveDecoder = false; |
| 813 | |
| 814 | QJsonObject sessionObj = doc.object(); |
| 815 | |
| 816 | int mode = _device_agent->get_work_mode(); |
| 817 | |
| 818 | // check config file version |
| 819 | if (!sessionObj.contains("Version")) |
| 820 | { |
| 821 | dsv_dbg("Profile version is not exists!"); |
| 822 | return false; |
| 823 | } |
| 824 | |
| 825 | int format_ver = sessionObj["Version"].toInt(); |
| 826 | |
| 827 | if (format_ver < 2) |
| 828 | { |
| 829 | dsv_err("Profile version is error!"); |
| 830 | return false; |
| 831 | } |
| 832 | |
| 833 | if (sessionObj.contains("CollectMode") && _device_agent->is_hardware()){ |
| 834 | int collect_mode = sessionObj["CollectMode"].toInt(); |
| 835 | _session->set_collect_mode((DEVICE_COLLECT_MODE)collect_mode); |
| 836 | } |
| 837 | |
| 838 | int conf_dev_mode = sessionObj["DeviceMode"].toInt(); |
| 839 | |
| 840 | if (_device_agent->is_hardware()) |
| 841 | { |
| 842 | QString driverName = _device_agent->driver_name(); |
| 843 | QString sessionDevice = sessionObj["Device"].toString(); |
| 844 | // check device and mode |
| 845 | if (driverName != sessionDevice || mode != conf_dev_mode) |
| 846 | { |
| 847 | MsgBox::Show(NULL, L_S(STR_PAGE_MSG, S_ID(IDS_MSG_PROFILE_NOT_COMPATIBLE), "Profile is not compatible with current device or mode!"), this); |
| 848 | return false; |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | // load device settings |
| 853 | GVariant *gvar_opts = _device_agent->get_config_list(NULL, SR_CONF_DEVICE_SESSIONS); |
| 854 | gsize num_opts; |
| 855 | |
| 856 | if (gvar_opts != NULL) |
| 857 | { |
| 858 | const int *const options = (const int32_t *)g_variant_get_fixed_array( |
| 859 | gvar_opts, &num_opts, sizeof(int32_t)); |
| 860 | |
| 861 | for (unsigned int i = 0; i < num_opts; i++) |
| 862 | { |
| 863 | const struct sr_config_info *info = _device_agent->get_config_info(options[i]); |
| 864 | |
| 865 | if (!sessionObj.contains(info->name)) |
| 866 | continue; |
| 867 |
nothing calls this directly
no test coverage detected