xuiquerylist.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #include <precomp.h>
  2. #include "xuiquerylist.h"
  3. #include <tataki/canvas/ifc_canvas.h>
  4. #include <api/service/svcs/svc_objectdir.h>
  5. // -----------------------------------------------------------------------
  6. char QueryListXuiObjectStr[] = "QueryResults"; // This is the xml tag
  7. char QueryListXuiSvcName[] = "ScriptQueryResults xui object";
  8. XMLParamPair ScriptQueryList::params[] = {
  9. {QUERYLIST_SETTITLE, "TITLE"},
  10. };
  11. // -----------------------------------------------------------------------
  12. ScriptQueryList::ScriptQueryList() {
  13. getScriptObject()->vcpu_setInterface(queryListGuid, (void *)static_cast<ScriptQueryList *>(this));
  14. #ifdef WASABI_COMPILE_METADB
  15. getScriptObject()->vcpu_setInterface(multiQueryServerGuid, (void *)static_cast<MultiQueryServer *>(this));
  16. #endif
  17. getScriptObject()->vcpu_setClassName("QueryList"); // this is the script class name
  18. getScriptObject()->vcpu_setController(queryListController);
  19. myxuihandle = newXuiHandle();
  20. int numParams = sizeof(params) / sizeof(params[0]);
  21. hintNumberOfParams(numParams);
  22. for (int i = 0;i < numParams;i++)
  23. addParam(myxuihandle, params[i], XUI_ATTRIBUTE_IMPLIED);
  24. }
  25. ScriptQueryList::~ScriptQueryList() {
  26. }
  27. // -----------------------------------------------------------------------
  28. int ScriptQueryList::setXuiParam(int xuihandle, int xmlattributeid, const wchar_t *xmlattributename, const wchar_t *value) {
  29. if (xuihandle != myxuihandle)
  30. return QUERYLIST_PARENT::setXuiParam(xuihandle, xmlattributeid, xmlattributename, value);
  31. switch (xmlattributeid) {
  32. case QUERYLIST_SETTITLE: setTitle(value); break;
  33. default: return 0;
  34. }
  35. return 1;
  36. }
  37. // -----------------------------------------------------------------------
  38. void ScriptQueryList::setTitle(const char *name) {
  39. setName(name);
  40. //CUT if (!name || !*name) showLabel(0); else showLabel(1);
  41. }
  42. #ifdef WASABI_COMPILE_METADB
  43. // -----------------------------------------------------------------------
  44. void ScriptQueryList::onResetSubqueries() {
  45. QUERYLIST_PARENT::onResetSubqueries();
  46. QueryListScriptController::querylist_onResetQuery(SCRIPT_CALL, getScriptObject());
  47. }
  48. #endif
  49. #ifdef WASABI_COMPILE_METADB
  50. int ScriptQueryList::onAction(const char *action, const char *param, int x, int y, intptr_t p1, intptr_t p2, void *data, size_t datalen, api_window *source) {
  51. if (STRCASEEQLSAFE(action, "SAVEQUERY")) {
  52. String q = mqs_getMultiQuery();
  53. if (!q.isempty()) {
  54. svc_objectDir *qd = ObjectDirEnum("querydir").getNext();
  55. if (qd != NULL) {
  56. qd->insertObject(q, "gay", "user is gay");
  57. }
  58. }
  59. return 1;
  60. }
  61. return QUERYLIST_PARENT::onAction(action, param, x, y, p1, p2, data, datalen, source);
  62. }
  63. #endif
  64. // -----------------------------------------------------------------------
  65. // Script Object
  66. QueryListScriptController _queryListController;
  67. QueryListScriptController *queryListController = &_queryListController;
  68. // -- Functions table -------------------------------------
  69. function_descriptor_struct QueryListScriptController::exportedFunction[] = {
  70. {"onResetQuery", 0, (void*)QueryListScriptController::querylist_onResetQuery},
  71. };
  72. ScriptObject *QueryListScriptController::instantiate() {
  73. ScriptQueryList *sql = new ScriptQueryList;
  74. ASSERT(sql != NULL);
  75. return sql->getScriptObject();
  76. }
  77. void QueryListScriptController::destroy(ScriptObject *o) {
  78. ScriptQueryList *sql = static_cast<ScriptQueryList *>(o->vcpu_getInterface(queryListGuid));
  79. ASSERT(sql != NULL);
  80. delete sql;
  81. }
  82. void *QueryListScriptController::encapsulate(ScriptObject *o) {
  83. return NULL; // no encapsulation for querylist yet
  84. }
  85. void QueryListScriptController::deencapsulate(void *o) {
  86. }
  87. int QueryListScriptController::getNumFunctions() {
  88. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  89. }
  90. const function_descriptor_struct *QueryListScriptController::getExportedFunctions() {
  91. return exportedFunction;
  92. }
  93. scriptVar QueryListScriptController::querylist_onResetQuery(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  94. SCRIPT_FUNCTION_INIT;
  95. PROCESS_HOOKS0(o, queryListController);
  96. SCRIPT_FUNCTION_CHECKABORTEVENT;
  97. SCRIPT_EXEC_EVENT0(o);
  98. }