GUIAction::GUIAction(xml_node<>* node) : GUIObject(node) { xml_node<>* child; xml_node<>* actions; xml_attribute<>* attr; if (!node) { return; } if (mf.empty()) { #define ADD_ACTION(n) mf[#n] = &GUIAction::n #define ADD_ACTION_EX(name, func) mf[name] = &GUIAction::func // These actions will be run in the caller's thread ADD_ACTION(reboot); ADD_ACTION(home); ADD_ACTION(key); ADD_ACTION(page); ADD_ACTION(reload); ADD_ACTION(set); ADD_ACTION(clear); ADD_ACTION(restoredefaultsettings); ADD_ACTION(compute); ADD_ACTION_EX("addsubtract", compute); ADD_ACTION(setguitimezone); ADD_ACTION(overlay); ADD_ACTION(sleep); ADD_ACTION(screenshot); ADD_ACTION(setbrightness); ADD_ACTION(setlanguage); ADD_ACTION(autoboot_cancel); // remember actions that run in the caller thread for (auto it = mf.cbegin(); it != mf.cend(); ++it) { setActionsRunningInCallerThread.insert(it->first); } // These actions will run in a separate thread ADD_ACTION(autoboot); ADD_ACTION(switch_rom); } // First, get the action actions = FindNode(node, "actions"); if (actions) { child = FindNode(actions, "action"); } else { child = FindNode(node, "action"); } if (!child) { return; } while (child) { Action action; attr = child->first_attribute("function"); if (!attr) { return; } action.mFunction = attr->value(); action.mArg = child->value(); mActions.push_back(action); child = child->next_sibling("action"); } // Now, let's get either the key or region child = FindNode(node, "touch"); if (child) { attr = child->first_attribute("key"); if (attr) { std::vector<std::string> keys = mb::util::split(attr->value(), "+"); for (size_t i = 0; i < keys.size(); ++i) { const int key = getKeyByName(keys[i]); mKeys[key] = false; } } else { attr = child->first_attribute("x"); if (!attr) { return; } mActionX = atol(attr->value()); attr = child->first_attribute("y"); if (!attr) { return; } mActionY = atol(attr->value()); attr = child->first_attribute("w"); if (!attr) { return; } mActionW = atol(attr->value()); attr = child->first_attribute("h"); if (!attr) { return; } mActionH = atol(attr->value()); } } }
GUIAction::GUIAction(xml_node<>* node) : GUIObject(node) { xml_node<>* child; xml_node<>* actions; xml_attribute<>* attr; if (!node) return; if (mf.empty()) { #define ADD_ACTION(n) mf[#n] = &GUIAction::n #define ADD_ACTION_EX(name, func) mf[name] = &GUIAction::func // These actions will be run in the caller's thread ADD_ACTION(reboot); ADD_ACTION(home); ADD_ACTION(key); ADD_ACTION(page); ADD_ACTION(reload); ADD_ACTION(readBackup); ADD_ACTION(set); ADD_ACTION(clear); ADD_ACTION(mount); ADD_ACTION(unmount); ADD_ACTION_EX("umount", unmount); ADD_ACTION(restoredefaultsettings); ADD_ACTION(copylog); ADD_ACTION(compute); ADD_ACTION_EX("addsubtract", compute); ADD_ACTION(setguitimezone); ADD_ACTION(overlay); ADD_ACTION(queuezip); ADD_ACTION(cancelzip); ADD_ACTION(queueclear); ADD_ACTION(sleep); ADD_ACTION(appenddatetobackupname); ADD_ACTION(generatebackupname); ADD_ACTION(checkpartitionlist); ADD_ACTION(getpartitiondetails); ADD_ACTION(screenshot); ADD_ACTION(setbrightness); ADD_ACTION(fileexists); ADD_ACTION(killterminal); ADD_ACTION(checkbackupname); ADD_ACTION(adbsideloadcancel); ADD_ACTION(fixsu); ADD_ACTION(startmtp); ADD_ACTION(stopmtp); ADD_ACTION(cancelbackup); ADD_ACTION(checkpartitionlifetimewrites); ADD_ACTION(mountsystemtoggle); // remember actions that run in the caller thread for (mapFunc::const_iterator it = mf.begin(); it != mf.end(); ++it) setActionsRunningInCallerThread.insert(it->first); // These actions will run in a separate thread ADD_ACTION(flash); ADD_ACTION(wipe); ADD_ACTION(refreshsizes); ADD_ACTION(nandroid); ADD_ACTION(fixpermissions); ADD_ACTION(dd); ADD_ACTION(partitionsd); ADD_ACTION(installhtcdumlock); ADD_ACTION(htcdumlockrestoreboot); ADD_ACTION(htcdumlockreflashrecovery); ADD_ACTION(cmd); ADD_ACTION(terminalcommand); ADD_ACTION(reinjecttwrp); ADD_ACTION(decrypt); ADD_ACTION(adbsideload); ADD_ACTION(openrecoveryscript); ADD_ACTION(installsu); ADD_ACTION(decrypt_backup); ADD_ACTION(repair); ADD_ACTION(resize); ADD_ACTION(changefilesystem); ADD_ACTION(flashimage); } // First, get the action actions = FindNode(node, "actions"); if (actions) child = FindNode(actions, "action"); else child = FindNode(node, "action"); if (!child) return; while (child) { Action action; attr = child->first_attribute("function"); if (!attr) return; action.mFunction = attr->value(); action.mArg = child->value(); mActions.push_back(action); child = child->next_sibling("action"); } // Now, let's get either the key or region child = FindNode(node, "touch"); if (child) { attr = child->first_attribute("key"); if (attr) { std::vector<std::string> keys = TWFunc::Split_String(attr->value(), "+"); for(size_t i = 0; i < keys.size(); ++i) { const int key = getKeyByName(keys[i]); mKeys[key] = false; } } else { attr = child->first_attribute("x"); if (!attr) return; mActionX = atol(attr->value()); attr = child->first_attribute("y"); if (!attr) return; mActionY = atol(attr->value()); attr = child->first_attribute("w"); if (!attr) return; mActionW = atol(attr->value()); attr = child->first_attribute("h"); if (!attr) return; mActionH = atol(attr->value()); } } }