MythTV  master
mythsettings.cpp
Go to the documentation of this file.
1 #include <QNetworkInterface>
2 #include <QDomDocument>
3 #include <QFile>
4 
5 #include "channelsettings.h" // for ChannelTVFormat::GetFormats()
6 #include "mythsettings.h"
7 #include "frequencies.h"
8 #include "mythcontext.h"
9 #include "mythdb.h"
10 
12 MythSetting::DataType parse_data_type(const QString &str);
13 bool parse_dom(MythSettingList &settings, const QDomElement &element,
14  const QString &filename, const QString &group,
15  bool includeAllChildren, bool &foundGroup);
16 
17 static QString indent(uint level)
18 {
19  QString ret;
20  for (uint i = 0; i < level; i++)
21  ret += " ";
22  return ret;
23 }
24 
25 static QString extract_query_list(
26  const MythSettingList &settings, MythSetting::SettingType stype)
27 {
28  QString list;
29 
30  MythSettingList::const_iterator it = settings.begin();
31  for (; it != settings.end(); ++it)
32  {
33  const MythSettingGroup *group =
34  dynamic_cast<const MythSettingGroup*>(*it);
35  if (group)
36  {
37  list += extract_query_list(group->m_settings, stype);
38  continue;
39  }
40  const MythSetting *setting = dynamic_cast<const MythSetting*>(*it);
41  if (setting && (setting->m_stype == stype))
42  list += QString(",'%1'").arg(setting->m_value);
43  }
44  if (!list.isEmpty() && (list[0] == QChar(',')))
45  list = list.mid(1);
46 
47  return list;
48 }
49 
50 static void fill_setting(
51  MythSettingBase *sb, const QMap<QString,QString> &map,
53 {
54  const MythSettingGroup *group =
55  dynamic_cast<const MythSettingGroup*>(sb);
56  if (group)
57  {
58  MythSettingList::const_iterator it = group->m_settings.begin();
59  for (; it != group->m_settings.end(); ++it)
60  fill_setting(*it, map, stype);
61  return;
62  }
63 
64  MythSetting *setting = dynamic_cast<MythSetting*>(sb);
65  if (setting && (setting->m_stype == stype))
66  {
67  QMap<QString,QString>::const_iterator it = map.find(setting->m_value);
68  if (it != map.end())
69  setting->m_data = *it;
70 
71  bool do_option_check = false;
72  if (MythSetting::kLocalIPAddress == setting->m_dtype)
73  {
74  setting->m_data_list = GetSettingValueList("LocalIPAddress");
75  setting->m_display_list = setting->m_data_list;
76  do_option_check = true;
77  }
78  else if (MythSetting::kSelect == setting->m_dtype)
79  {
80  do_option_check = true;
81  }
82  else if (MythSetting::kTVFormat == setting->m_dtype)
83  {
84  setting->m_data_list = setting->m_display_list =
86  do_option_check = true;
87  }
88  else if (MythSetting::kFrequencyTable == setting->m_dtype)
89  {
90  setting->m_data_list.clear();
91  for (uint i = 0; chanlists[i].name; i++)
92  setting->m_data_list.push_back(chanlists[i].name);
93  setting->m_display_list = setting->m_data_list;
94  do_option_check = true;
95  }
96 
97  if (do_option_check)
98  {
99  if (!setting->m_data_list.empty() &&
100  !setting->m_data_list.contains(setting->m_data.toLower(),
101  Qt::CaseInsensitive))
102  {
103  bool ok;
104  long long idata = setting->m_data.toLongLong(&ok);
105  if (ok)
106  {
107  uint sel = 0;
108  for (int i = setting->m_data_list.size() - 1; i >= 0; i--)
109  {
110  if (idata < setting->m_data_list[i].toLongLong())
111  break;
112  sel = i;
113  }
114  setting->m_data = setting->m_data_list[sel];
115  }
116  else
117  {
118  setting->m_data =
119  (setting->m_data_list.contains(
120  setting->m_default_data, Qt::CaseInsensitive)) ?
121  setting->m_default_data : setting->m_data_list[0];
122  }
123  }
124  }
125  }
126 }
127 
128 static void fill_settings(
129  MythSettingList &settings, MSqlQuery &query, MythSetting::SettingType stype)
130 {
131  QMap<QString,QString> map;
132  while (query.next())
133  map[query.value(0).toString()] = query.value(1).toString();
134 
135  MythSettingList::const_iterator it = settings.begin();
136  for (; it != settings.end(); ++it)
137  fill_setting(*it, map, stype);
138 }
139 
140 QString MythSettingGroup::ToHTML(uint depth) const
141 {
142  QString ret;
143 
144  ret = indent(depth) +
145  QString("<div class=\"group\" id=\"%1\">\r\n").arg(m_unique_label);
146  if (!m_human_label.isEmpty())
147  {
148  ret += indent(depth+1) + QString("<h%1 class=\"config\">%2</h%3>\r\n")
149  .arg(depth+1).arg(m_human_label).arg(depth+1);
150  }
151 
152  MythSettingList::const_iterator it = m_settings.begin();
153  for (; it != m_settings.end(); ++it)
154  ret += (*it)->ToHTML(depth+1);
155 
156  ret += indent(depth) +"</div>";
157 
158  return ret;
159 }
160 
161 QString MythSetting::ToHTML(uint level) const
162 {
163  QString ret = indent(level) +
164  QString("<div class=\"setting\" id=\"%1_div\">\r\n").arg(m_value);
165 
166  int size = 20;
167  switch (m_dtype)
168  {
169  case kFloat:
170  case kInteger:
171  case kIntegerRange:
172  case kUnsignedInteger:
173  size = 20;
174  break;
175  case kTimeOfDay:
176  size = 20;
177  break;
178  case kString:
179  size = 60;
180  break;
181  case kIPAddress:
182  size = 20;
183  break;
184  case kCheckBox:
185  case kSelect:
186  case kComboBox:
187  case kTVFormat:
188  case kFrequencyTable:
189  case kLocalIPAddress:
190  case kOther:
191  case kInvalidDataType:
192  break;
193  }
194 
195  switch (m_dtype)
196  {
197  case kInteger:
198  case kUnsignedInteger:
199  ret += indent(level) +
200  QString("<p class=\"setting_paragraph\"><label class=\"setting_label\" "
201  "for=\"%1\">%2</label>")
202  .arg(m_value).arg(m_label);
203  ret += indent(level) +
204  QString("<input class=\"setting_input\" name=\"%1\" id=\"%2\" type=\"number\""
205  " value='%3' step='1' size='%4'/>\r\n")
206  .arg(m_value).arg(m_value).arg(m_data).arg(size);
207  ret += indent(level) +
208  QString("<a class=\"setting_helplink ui-icon ui-icon-help\" href=\"javascript:showSettingHelp('%1')"
209  "\"></a></label></p>\r\n").arg(m_value);
210  ret += indent(level) +
211  QString("<div class=\"form_error\""
212  "id=\"%1_error\"></div><div style=\"display:none;"
213  "position:absolute;left:-4000px\" "
214  "id=\"%2_default\">%3</div>\r\n")
215  .arg(m_value).arg(m_value).arg(m_default_data);
216  break;
217  case kIntegerRange:
218  ret += indent(level) +
219  QString("<p class=\"setting_paragraph\"><label class=\"setting_label\" "
220  "for=\"%1\">%2</label>")
221  .arg(m_value).arg(m_label);
222  ret += indent(level) +
223  QString("<input class=\"setting_input\" name=\"%1\" id=\"%2\" type=\"number\""
224  " value='%3' min='%4' max='%5' step='1' size='%6'/>\r\n")
225  .arg(m_value).arg(m_value).arg(m_data).arg(m_range_min).arg(m_range_max).arg(size);
226  ret += indent(level) +
227  QString("<a class=\"setting_helplink ui-icon ui-icon-help\" href=\"javascript:showSettingHelp('%1')"
228  "\"></a></label></p>\r\n").arg(m_value);
229  ret += indent(level) +
230  QString("<div class=\"form_error\""
231  "id=\"%1_error\"></div><div style=\"display:none;"
232  "position:absolute;left:-4000px\" "
233  "id=\"%2_default\">%3</div>\r\n")
234  .arg(m_value).arg(m_value).arg(m_default_data);
235  break;
236  case kFloat:
237  case kComboBox:
238  case kIPAddress:
239  case kString:
240  case kTimeOfDay:
241  case kOther:
242  ret += indent(level) +
243  QString("<p class=\"setting_paragraph\"><label class=\"setting_label\" "
244  "for=\"%1\">%2</label>")
245  .arg(m_value).arg(m_label);
246  ret += indent(level) +
247  QString("<input class=\"setting_input\" name=\"%1\" id=\"%2\" type=\"text\""
248  " value=\"%3\" size='%4' placeholder=\"%5\"/>\r\n")
249  .arg(m_value).arg(m_value).arg(m_data).arg(size).arg(m_placeholder_text);
250  ret += indent(level) +
251  QString("<a class=\"setting_helplink ui-icon ui-icon-help\" href=\"javascript:showSettingHelp('%1')"
252  "\"></a></label></p>\r\n").arg(m_value);
253  ret += indent(level) +
254  QString("<div class=\"form_error\""
255  "id=\"%1_error\"></div><div style=\"display:none;"
256  "position:absolute;left:-4000px\" "
257  "id=\"%2_default\">%3</div>\r\n")
258  .arg(m_value).arg(m_value).arg(m_default_data);
259  break;
260  case kCheckBox:
261  ret += indent(level) +
262  QString("<p class=\"setting_paragraph\">"
263  "<input class=\"setting_input\" name=\"%1_input\" id=\"%2\" type=\"checkbox\""
264  " value=\"1\" %3/><label class=\"setting_label_checkbox\" for=\"%5\">%6</label>")
265  .arg(m_value).arg(m_value).arg((m_data.toUInt()) ? "checked" : "").arg(m_value).arg(m_label);
266  ret += indent(level) +
267  QString("<a class=\"setting_helplink ui-icon ui-icon-help\" href=\"javascript:showSettingHelp('%1'"
268  ")\"></a></p><div class=\"form_error\""
269  " id=\"%2_error\"></div>").arg(m_value).arg(m_value);
270  ret += indent(level) +
271  QString("<div style=\"display:none;"
272  "position:absolute;left:-4000px\" "
273  "id=\"%1_default\">%2</div>")
274  .arg(m_value).arg(m_default_data);
275  break;
276  case kLocalIPAddress:
277  case kTVFormat:
278  case kFrequencyTable:
279  case kSelect:
280  ret += indent(level) +
281  QString("<p class=\"setting_paragraph\"><label class=\"setting_label\" "
282  "for=\"%1\">%2</label>")
283  .arg(m_value).arg(m_label);
284  ret += indent(level) +
285  QString("<select class=\"setting_select\" name=\"%1_input\" id=\"%2\">\r\n")
286  .arg(m_value).arg(m_value);
287  for (uint i = 0; (i < (uint)m_data_list.size()) &&
288  (i < (uint)m_display_list.size()); i++)
289  {
290  ret += indent(level+1) +
291  QString("<option value=\"%1\" %2>%3</option>\r\n")
292  .arg(m_data_list[i])
293  .arg((m_data_list[i].toLower() == m_data.toLower()) ?
294  "selected" : "")
295  .arg(m_display_list[i]);
296  }
297  ret += indent(level) + "</select>" +
298  QString("<a class=\"setting_helplink ui-icon ui-icon-help\" href=\"javascript:showSettingHelp('%1')"
299  "\"></a></p>\r\n").arg(m_value);
300  ret += indent(level) +
301  QString("<div class=\"form_error\""
302  "id=\"%1_error\"></div><div style=\"display:none;"
303  "position:absolute;left:-4000px\" "
304  "id=\"%2_default\">%3</div>\r\n")
305  .arg(m_value).arg(m_value).arg(m_default_data);
306  break;
307  case kInvalidDataType:
308  break;
309  }
310 
311  ret += indent(level) + "</div>\r\n";
312 
313  return ret;
314 }
315 
317 {
318  QString s = str.toLower();
319  if (s=="file")
320  return MythSetting::kFile;
321  if (s=="host")
322  return MythSetting::kHost;
323  if (s=="global")
324  return MythSetting::kGlobal;
326 }
327 
329 {
330  QString s = str.toLower();
331  if (s == "integer")
332  return MythSetting::kInteger;
333  if (s == "unsigned")
335  if (s == "integer_range")
337  if (s == "checkbox")
338  return MythSetting::kCheckBox;
339  if (s == "select")
340  return MythSetting::kSelect;
341  if (s == "combobox")
342  return MythSetting::kComboBox;
343  if (s == "tvformat")
344  return MythSetting::kTVFormat;
345  if (s == "frequency_table")
347  if (s == "float")
348  return MythSetting::kFloat;
349  if (s == "ipaddress")
351  if (s == "localipaddress")
353  if (s == "string")
354  return MythSetting::kString;
355  if (s == "timeofday")
357  if (s == "other")
358  return MythSetting::kOther;
359  LOG(VB_GENERAL, LOG_ERR, QString("Unknown type: %1").arg(str));
361 }
362 
363 QMap<QString,QString> GetSettingsMap(MythSettingList &settings,
364  const QString &hostname)
365 {
366  QMap<QString,QString> result;
367  MSqlQuery query(MSqlQuery::InitCon());
368 
369  QString list = extract_query_list(settings, MythSetting::kHost);
370  QString qstr =
371  "SELECT value, data "
372  "FROM settings "
373  "WHERE hostname = '" + hostname + "' AND "
374  " value in (" + list + ")";
375 
376  if (!list.isEmpty())
377  {
378  if (!query.exec(qstr))
379  {
380  MythDB::DBError("GetSettingsMap() 1", query);
381  return result;
382  }
383 
384  while (query.next())
385  result[query.value(0).toString()] = query.value(1).toString();
386  }
387 
388  list = extract_query_list(settings, MythSetting::kGlobal);
389  qstr =
390  "SELECT value, data "
391  "FROM settings "
392  "WHERE hostname IS NULL AND "
393  " value in (" + list + ")";
394 
395  if (!list.isEmpty())
396  {
397  if (!query.exec(qstr))
398  {
399  MythDB::DBError("GetSettingsMap() 2", query);
400  return result;
401  }
402 
403  while (query.next())
404  result[query.value(0).toString()] = query.value(1).toString();
405  }
406 
407  return result;
408 }
409 
410 QStringList GetSettingValueList(const QString &type)
411 {
412  QStringList sList;
413 
414  if (type == "LocalIPAddress")
415  {
416  QList<QHostAddress> list = QNetworkInterface::allAddresses();
417  for (uint i = 0; i < (uint)list.size(); i++)
418  {
419  if (list[i].toString().contains(":"))
420  continue; // ignore IP6 addresses for now
421  sList << list[i].toString();
422  }
423 
424  if (sList.isEmpty())
425  sList << "127.0.0.1";
426  }
427 
428  return sList;
429 }
430 
431 QString StringMapToJSON(const QMap<QString,QString> &map)
432 {
433  QString result;
434 
435  QMap<QString,QString>::const_iterator it = map.begin();
436  for (; it != map.end(); ++it)
437  {
438  if (result.isEmpty())
439  result += "{ ";
440  else
441  result += ", ";
442 
443  // FIXME, howto encode double quotes in JSON?
444  result += "\"" + it.key() + "\": \"" + it.value() + "\"";
445  }
446 
447  if (!result.isEmpty())
448  result += " }";
449  else
450  result = "{ }";
451 
452  return result;
453 }
454 
455 QString StringListToJSON(const QString &key,
456  const QStringList &sList)
457 {
458  QString result;
459 
460  QStringList::const_iterator it = sList.begin();
461  for (; it != sList.end(); ++it)
462  {
463  if (result.isEmpty())
464  result += QString("{ \"%1\" : [ ").arg(key);
465  else
466  result += ", ";
467 
468  // FIXME, howto encode double quotes in JSON?
469  result += "\"" + *it + "\"";
470  }
471 
472  if (!result.isEmpty())
473  result += " ] }";
474  else
475  result = "{ }";
476 
477  return result;
478 }
479 
480 bool parse_dom(MythSettingList &settings, const QDomElement &element,
481  const QString &filename, const QString &group,
482  bool includeAllChildren, bool &foundGroup)
483 {
484 #define LOC QString("parse_dom(%1@~%2), error: ") \
485  .arg(filename).arg(e.lineNumber())
486 
487  bool mFoundGroup = false;
488 
489  QDomNode n = element.firstChild();
490  while (!n.isNull())
491  {
492  const QDomElement e = n.toElement();
493  if (e.isNull())
494  {
495  n = n.nextSibling();
496  continue;
497  }
498 
499  if (e.tagName() == "group")
500  {
501  QString m_human_label = e.attribute("human_label");
502  QString m_unique_label = e.attribute("unique_label");
503  QString m_ecma_script = e.attribute("ecma_script");
504 
505  bool tmpFoundGroup = false;
506  bool tmpIncludeAllChildren = includeAllChildren;
507  if (group.isEmpty() || m_unique_label == group)
508  {
509  mFoundGroup = true;
510  tmpIncludeAllChildren = true;
511  }
512 
514  m_human_label, m_unique_label, m_ecma_script);
515 
516  if ((e.hasChildNodes()) &&
517  (!parse_dom(g->m_settings, e, filename, group, tmpIncludeAllChildren,
518  tmpFoundGroup)))
519  {
520  delete g;
521  return false;
522  }
523 
524  if (tmpFoundGroup || tmpIncludeAllChildren)
525  {
526  settings.push_back(g);
527  mFoundGroup = true;
528  }
529  else
530  delete g;
531 
532  }
533  else if (e.tagName() == "setting" && includeAllChildren)
534  {
535  QMap<QString,QString> m;
536  m["value"] = e.attribute("value");
537  m["setting_type"] = e.attribute("setting_type");
538  m["label"] = e.attribute("label");
539  m["help_text"] = e.attribute("help_text");
540  m["data_type"] = e.attribute("data_type");
541 
542  MythSetting::DataType dtype = parse_data_type(m["data_type"]);
543  if (MythSetting::kInvalidDataType == dtype)
544  {
545  LOG(VB_GENERAL, LOG_ERR, LOC +
546  "Setting has invalid or missing data_type attribute.");
547  return false;
548  }
549 
550  QStringList data_list;
551  QStringList display_list;
552  if ((MythSetting::kComboBox == dtype) ||
553  (MythSetting::kSelect == dtype))
554  {
555  if (!e.hasChildNodes())
556  {
557  LOG(VB_GENERAL, LOG_ERR, LOC +
558  "Setting missing selection items.");
559  return false;
560  }
561 
562  QDomNode n2 = e.firstChild();
563  while (!n2.isNull())
564  {
565  const QDomElement e2 = n2.toElement();
566  if (e2.tagName() != "option")
567  {
568  LOG(VB_GENERAL, LOG_ERR, LOC +
569  "Setting selection contains invalid tags.");
570  return false;
571  }
572  QString display = e2.attribute("display");
573  QString data = e2.attribute("data");
574  if (data.isEmpty())
575  {
576  LOG(VB_GENERAL, LOG_ERR, LOC +
577  "Setting selection item missing data.");
578  return false;
579  }
580  display = (display.isEmpty()) ? data : display;
581  data_list.push_back(data);
582  display_list.push_back(display);
583 
584  n2 = n2.nextSibling();
585  }
586  }
587 
588  if (MythSetting::kIntegerRange == dtype)
589  {
590  m["range_min"] = e.attribute("range_min");
591  m["range_max"] = e.attribute("range_max");
592  }
593 
594  QMap<QString,QString>::const_iterator it = m.begin();
595  for (; it != m.end(); ++it)
596  {
597  if ((*it).isEmpty())
598  {
599  LOG(VB_GENERAL, LOG_ERR, LOC +
600  QString("Setting has invalid or missing %1 attribute")
601  .arg(it.key()));
602  return false;
603  }
604  }
605 
606  m["default_data"] = e.attribute("default_data");
607  m["placeholder_text"] = e.attribute("placeholder_text");
608 
610  parse_setting_type(m["setting_type"]);
612  {
613  LOG(VB_GENERAL, LOG_ERR, LOC +
614  "Setting has invalid setting_type attribute.");
615  return false;
616  }
617 
618  long long range_min = m["range_min"].toLongLong();
619  long long range_max = m["range_max"].toLongLong();
620  if (range_max < range_min)
621  {
622  LOG(VB_GENERAL, LOG_ERR, LOC +
623  "Setting has invalid range attributes");
624  return false;
625  }
626 
627  MythSetting *s = new MythSetting(
628  m["value"], m["default_data"], stype,
629  m["label"], m["help_text"], dtype,
630  data_list, display_list, range_min, range_max,
631  m["placeholder_text"]);
632 
633  settings.push_back(s);
634  }
635  else if (group.isEmpty())
636  {
637  LOG(VB_GENERAL, LOG_ERR, LOC +
638  QString("Unknown element: %1").arg(e.tagName()));
639  return false;
640  }
641  n = n.nextSibling();
642  }
643 
644  if (mFoundGroup)
645  foundGroup = true;
646 
647  return true;
648 #undef LOC
649 }
650 
651 bool parse_settings(MythSettingList &settings, const QString &filename,
652  const QString &group)
653 {
654  QDomDocument doc;
655  QFile f(filename);
656 
657  if (!f.open(QIODevice::ReadOnly))
658  {
659  LOG(VB_GENERAL, LOG_ERR, QString("parse_settings: Can't open: '%1'")
660  .arg(filename));
661  return false;
662  }
663 
664  QString errorMsg;
665  int errorLine = 0;
666  int errorColumn = 0;
667 
668  if (!doc.setContent(&f, false, &errorMsg, &errorLine, &errorColumn))
669  {
670  LOG(VB_GENERAL, LOG_ERR, QString("parse_settings: ") +
671  QString("Parsing: %1 at line: %2 column: %3")
672  .arg(filename).arg(errorLine).arg(errorColumn) +
673  QString("\n\t\t\t%1").arg(errorMsg));
674  f.close();
675  return false;
676  }
677  f.close();
678 
679  settings.clear();
680  bool foundGroup = false;
681  bool includeAllChildren = group.isEmpty();
682  return parse_dom(settings, doc.documentElement(), filename, group,
683  includeAllChildren, foundGroup);
684 }
685 
686 bool load_settings(MythSettingList &settings, const QString &hostname)
687 {
688  MSqlQuery query(MSqlQuery::InitCon());
689 
690  QString list = extract_query_list(settings, MythSetting::kHost);
691  QString qstr =
692  "SELECT value, data "
693  "FROM settings "
694  "WHERE hostname = '" + hostname + "' AND "
695  " value in (" + list + ")";
696 
697  if (!list.isEmpty())
698  {
699  if (!query.exec(qstr))
700  {
701  MythDB::DBError("HttpConfig::LoadMythSettings() 1", query);
702  return false;
703  }
704  fill_settings(settings, query, MythSetting::kHost);
705  }
706 
707  list = extract_query_list(settings, MythSetting::kGlobal);
708  qstr =
709  "SELECT value, data "
710  "FROM settings "
711  "WHERE hostname IS NULL AND "
712  " value in (" + list + ")";
713 
714  if (!list.isEmpty())
715  {
716  if (!query.exec(qstr))
717  {
718  MythDB::DBError("HttpConfig::LoadMythSettings() 2", query);
719  return false;
720  }
721  fill_settings(settings, query, MythSetting::kGlobal);
722  }
723 
724  return true;
725 }
726 
727 bool check_settings(MythSettingList &/*database_settings*/,
728  const QMap<QString,QString> &params,
729  QString &result)
730 {
731  QMap<QString,QString>::const_iterator it = params.begin();
732  for (; it != params.end(); ++it)
733  {
734  if (it.key().startsWith("__"))
735  continue;
736 
737  if (result.isEmpty())
738  result += "{ ";
739  else
740  result += ", ";
741 
742  result += QString("\"%1\": \"DEBUG: New value for '%2' would be '%3'\"")
743  .arg(it.key()).arg(it.key()).arg(*it);
744  }
745 
746  if (!result.isEmpty())
747  result += " }";
748 
749  // FIXME, do some actual validation here
750  return result.isEmpty();
751 }
bool next(void)
Wrap QSqlQuery::next() so we can display the query results.
Definition: mythdbcon.cpp:782
QString m_placeholder_text
Definition: mythsettings.h:116
bool check_settings(MythSettingList &, const QMap< QString, QString > &params, QString &result)
QString toString(MarkTypes type)
QString StringMapToJSON(const QMap< QString, QString > &map)
bool load_settings(MythSettingList &settings, const QString &hostname)
QSqlQuery wrapper that fetches a DB connection from the connection pool.
Definition: mythdbcon.h:125
long long m_range_max
Definition: mythsettings.h:115
MythSetting::DataType parse_data_type(const QString &str)
QStringList m_display_list
Definition: mythsettings.h:113
static QStringList GetFormats(void)
QMap< QString, QString > GetSettingsMap(MythSettingList &settings, const QString &hostname)
unsigned int uint
Definition: compat.h:140
QString StringListToJSON(const QString &key, const QStringList &sList)
bool parse_dom(MythSettingList &settings, const QDomElement &element, const QString &filename, const QString &group, bool includeAllChildren, bool &foundGroup)
QString m_value
Definition: mythsettings.h:105
const char * name
Definition: frequencies.h:102
static void fill_setting(MythSettingBase *sb, const QMap< QString, QString > &map, MythSetting::SettingType stype)
QVariant value(int i) const
Definition: mythdbcon.h:198
QString m_unique_label
div name for stylesheets & javascript
Definition: mythsettings.h:29
static QString extract_query_list(const MythSettingList &settings, MythSetting::SettingType stype)
MythSetting::SettingType parse_setting_type(const QString &str)
bool parse_settings(MythSettingList &settings, const QString &filename, const QString &group)
struct CHANLISTS chanlists[]
list where user input is allowed
Definition: mythsettings.h:50
static QString indent(uint level)
string hostname
Definition: caa.py:17
static MSqlQueryInfo InitCon(ConnectionReuse=kNormalConnection)
Only use this in combination with MSqlQuery constructor.
Definition: mythdbcon.cpp:535
QList< MythSettingBase * > MythSettingList
Definition: mythsettings.h:16
QString ToHTML(uint) const override
static void fill_settings(MythSettingList &settings, MSqlQuery &query, MythSetting::SettingType stype)
long long m_range_min
Definition: mythsettings.h:114
MythSettingList m_settings
Definition: mythsettings.h:30
QString m_default_data
Definition: mythsettings.h:107
#define LOG(_MASK_, _LEVEL_, _STRING_)
Definition: mythlogging.h:41
QStringList m_data_list
Definition: mythsettings.h:112
QString m_label
Definition: mythsettings.h:109
#define LOC
list where only data_list are valid
Definition: mythsettings.h:49
QString m_data
Definition: mythsettings.h:106
SettingType m_stype
Definition: mythsettings.h:108
bool exec(void)
Wrap QSqlQuery::exec() so we can display SQL.
Definition: mythdbcon.cpp:603
static void DBError(const QString &where, const MSqlQuery &query)
Definition: mythdb.cpp:179
DataType m_dtype
Definition: mythsettings.h:111
QString m_human_label
Definition: mythsettings.h:28
unsigned char g
Definition: ParseText.cpp:329
QString ToHTML(uint) const override
QStringList GetSettingValueList(const QString &type)