1 #include "otsdaq-core/ConfigurationPluginDataFormats/DesktopIconConfiguration.h"
2 #include "otsdaq-core/Macros/ConfigurationPluginMacros.h"
3 #include "otsdaq-core/ConfigurationInterface/ConfigurationManager.h"
10 #define DESKTOP_ICONS_FILE std::string(getenv("SERVICE_DATA_PATH")) + "/OtsWizardData/iconList.dat"
13 #define COL_NAME "IconName"
14 #define COL_STATUS "Status"
15 #define COL_CAPTION "Caption"
16 #define COL_ALTERNATE_TEXT "AlternateText"
17 #define COL_FORCE_ONLY_ONE_INSTANCE "ForceOnlyOneInstance"
18 #define COL_REQUIRED_PERMISSION_LEVEL "RequiredPermissionLevel"
19 #define COL_IMAGE_URL "ImageURL"
20 #define COL_WINDOW_CONTENT_URL "WindowContentURL"
21 #define COL_APP_LINK "LinkToApplicationConfiguration"
22 #define COL_PARAMETER_LINK "LinkToParameterConfiguration"
23 #define COL_PARAMETER_KEY "windowParameterKey"
24 #define COL_PARAMETER_VALUE "windowParameterValue"
25 #define COL_FOLDER_PATH "FolderPath"
28 #define COL_APP_ID "Id"
33 DesktopIconConfiguration::DesktopIconConfiguration(
void) :
65 DesktopIconConfiguration::~DesktopIconConfiguration(
void)
71 __MOUT__ <<
"*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*&*" << std::endl;
72 __MOUT__ << configManager->__SELF_NODE__ << std::endl;
81 auto childrenMap = configManager->__SELF_NODE__.getChildren();
86 fs.open(DESKTOP_ICONS_FILE, std::fstream::out | std::fstream::trunc);
89 __SS__ <<
"Failed to open Desktop Icons run file: " << DESKTOP_ICONS_FILE << std::endl;
90 throw std::runtime_error(ss.str());
93 for(
auto &child:childrenMap)
95 child.second.getNode(COL_STATUS ).getValue(status);
98 if(first) first =
false;
101 child.second.getNode(COL_CAPTION ).getValue(val);
102 fs << removeCommas(val,
false,
true);
106 child.second.getNode(COL_ALTERNATE_TEXT ).getValue(val);
107 fs << removeCommas(val,
false,
true);
110 child.second.getNode(COL_FORCE_ONLY_ONE_INSTANCE ).getValue(status);
111 fs << (status?
"1":
"0");
114 child.second.getNode(COL_REQUIRED_PERMISSION_LEVEL ).getValue(val);
115 fs << removeCommas(val);
118 child.second.getNode(COL_IMAGE_URL ).getValue(val);
119 fs << removeCommas(val,
true);
122 child.second.getNode(COL_WINDOW_CONTENT_URL ).getValue(val);
123 val = removeCommas(val,
true);
126 bool addedAppId =
false;
128 if(!child.second.getNode(COL_APP_LINK ).isDisconnected())
132 if(val[val.size()-1] !=
'=')
136 child.second.getNode(COL_APP_LINK ).getNode(COL_APP_ID ).getValue(intVal);
144 if(!child.second.getNode(COL_PARAMETER_LINK ).isDisconnected())
148 if(val.find(
'?') == std::string::npos)
150 else if(addedAppId ||
151 val[val.size()-1] !=
'?')
155 auto paramGroupMap = child.second.getNode(COL_PARAMETER_LINK ).getChildren();
156 bool notFirst =
false;
157 for(
const auto param:paramGroupMap)
163 fs << ConfigurationManager::encodeURIComponent(
164 param.second.getNode(COL_PARAMETER_KEY).getValue<std::string>()) <<
"=" <<
165 ConfigurationManager::encodeURIComponent(
166 param.second.getNode(COL_PARAMETER_VALUE).getValue<std::string>());
171 child.second.getNode(COL_FOLDER_PATH ).getValue(val);
172 if(val == ViewColumnInfo::DATATYPE_STRING_DEFAULT) val =
"";
173 fs << removeCommas(val,
true);
180 std::string DesktopIconConfiguration::removeCommas(
const std::string &str,
181 bool andHexReplace,
bool andHTMLReplace)
183 std::string retStr =
"";
184 retStr.reserve(str.length());
186 for(
unsigned int i=0;i<str.length();++i)
189 else if(andHexReplace)
191 else if(andHTMLReplace)