You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * Copyright (c) 2006-2015 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.actions;
  23. import com.dmdirc.DMDircMBassador;
  24. import com.dmdirc.GlobalWindow;
  25. import com.dmdirc.config.prefs.PreferencesSetting;
  26. import com.dmdirc.config.prefs.PreferencesType;
  27. import com.dmdirc.events.ActionCreatedEvent;
  28. import com.dmdirc.events.ActionDeletedEvent;
  29. import com.dmdirc.events.ActionUpdatedEvent;
  30. import com.dmdirc.events.AppErrorEvent;
  31. import com.dmdirc.events.UserErrorEvent;
  32. import com.dmdirc.interfaces.ActionController;
  33. import com.dmdirc.interfaces.actions.ActionComparison;
  34. import com.dmdirc.interfaces.actions.ActionComponent;
  35. import com.dmdirc.interfaces.actions.ActionType;
  36. import com.dmdirc.interfaces.config.ConfigChangeListener;
  37. import com.dmdirc.interfaces.config.IdentityController;
  38. import com.dmdirc.logger.ErrorLevel;
  39. import com.dmdirc.updater.Version;
  40. import com.dmdirc.util.io.ConfigFile;
  41. import com.dmdirc.util.io.InvalidConfigFileException;
  42. import java.io.IOException;
  43. import java.nio.file.Files;
  44. import java.nio.file.Path;
  45. import java.util.ArrayList;
  46. import java.util.Arrays;
  47. import java.util.HashMap;
  48. import java.util.List;
  49. import java.util.Map;
  50. import javax.inject.Provider;
  51. /**
  52. * Describes a single action.
  53. */
  54. public class Action extends ActionModel implements ConfigChangeListener {
  55. /** The domain name for condition trees. */
  56. private static final String DOMAIN_CONDITIONTREE = "conditiontree";
  57. /** The domain name for format changes. */
  58. private static final String DOMAIN_FORMAT = "format";
  59. /** The domain name for meta-data. */
  60. private static final String DOMAIN_METADATA = "metadata";
  61. /** The domain name for response information. */
  62. private static final String DOMAIN_RESPONSE = "response";
  63. /** The domain name for triggers. */
  64. private static final String DOMAIN_TRIGGERS = "triggers";
  65. /** The domain name for concurrency. */
  66. private static final String DOMAIN_CONCURRENCY = "concurrency";
  67. /** The domain name for misc settings. */
  68. private static final String DOMAIN_MISC = "misc";
  69. /** The base directory to save actions in. */
  70. private final Path actionsDirectory;
  71. /** The controller to use to read and update settings. */
  72. private final IdentityController identityController;
  73. /** The controller to use to retrieve components, comparisons, etc. */
  74. private final ActionController actionController;
  75. /** Event bus to post events to. */
  76. private final DMDircMBassador eventBus;
  77. /** The config file we're using. */
  78. protected ConfigFile config;
  79. /** The location of the file we're reading/saving. */
  80. private Path location;
  81. /**
  82. * Creates a new instance of Action. The group and name specified must be the group and name of
  83. * a valid action already saved to disk.
  84. *
  85. * @param eventBus Event bus to post events to
  86. * @param globalWindowProvider Provider of global windows for triggering actions.
  87. * @param substitutorFactory Factory to use to create action substitutors.
  88. * @param actionController The controller that owns this action.
  89. * @param identityController The controller to use to retrieve and update settings.
  90. * @param actionsDirectory The base directory to store actions in.
  91. * @param group The group the action belongs to
  92. * @param name The name of the action
  93. */
  94. public Action(final DMDircMBassador eventBus,
  95. final Provider<GlobalWindow> globalWindowProvider,
  96. final ActionSubstitutorFactory substitutorFactory,
  97. final ActionController actionController, final IdentityController identityController,
  98. final Path actionsDirectory, final String group, final String name) {
  99. super(globalWindowProvider, substitutorFactory, group, name);
  100. this.eventBus = eventBus;
  101. this.actionController = actionController;
  102. this.identityController = identityController;
  103. this.actionsDirectory = actionsDirectory;
  104. this.location = actionsDirectory.resolve(group).resolve(name);
  105. try {
  106. config = new ConfigFile(location);
  107. config.read();
  108. loadActionFromConfig();
  109. actionController.addAction(this);
  110. } catch (InvalidConfigFileException ex) {
  111. error(ActionErrorType.FILE, "Unable to parse action file: " + ex.getMessage());
  112. } catch (IOException ex) {
  113. error(ActionErrorType.FILE, "I/O error when loading action: " + ex.getMessage());
  114. }
  115. identityController.getGlobalConfiguration().addChangeListener("disable_action",
  116. (group + "/" + name).replace(' ', '.'), this);
  117. checkDisabled();
  118. }
  119. /**
  120. * Creates a new instance of Action with the specified properties and saves it to disk.
  121. *
  122. * @param eventBus Event bus to post events to
  123. * @param globalWindowProvider Provider of global windows for triggering actions.
  124. * @param substitutorFactory Factory to use to create action substitutors.
  125. * @param actionController The controller that owns this action.
  126. * @param identityController The controller to use to retrieve and update settings.
  127. * @param actionsDirectory The base directory to store actions in.
  128. * @param group The group the action belongs to
  129. * @param name The name of the action
  130. * @param triggers The triggers to use
  131. * @param response The response to use
  132. * @param conditions The conditions to use
  133. * @param conditionTree The condition tree to use
  134. * @param newFormat The new formatter to use
  135. */
  136. public Action(final DMDircMBassador eventBus,
  137. final Provider<GlobalWindow> globalWindowProvider,
  138. final ActionSubstitutorFactory substitutorFactory,
  139. final ActionController actionController, final IdentityController identityController,
  140. final Path actionsDirectory, final String group, final String name,
  141. final ActionType[] triggers, final String[] response,
  142. final List<ActionCondition> conditions, final ConditionTree conditionTree,
  143. final String newFormat) {
  144. super(globalWindowProvider, substitutorFactory, group, name,
  145. triggers, response, conditions, conditionTree, newFormat);
  146. this.eventBus = eventBus;
  147. this.actionController = actionController;
  148. this.identityController = identityController;
  149. this.actionsDirectory = actionsDirectory;
  150. this.location = actionsDirectory.resolve(group)
  151. .resolve(name.replaceAll("[^A-Za-z0-9\\-_]", "_"));
  152. try {
  153. Files.createDirectories(location.getParent());
  154. } catch (IOException ex) {
  155. //TODO we don't handle the error now, but we should
  156. }
  157. save();
  158. identityController.getGlobalConfiguration().addChangeListener("disable_action",
  159. (group + "/" + name).replace(' ', '.'), this);
  160. checkDisabled();
  161. actionController.addAction(this);
  162. //TODO This needs to be done somewhere else, remove eventbus when it is.
  163. eventBus.publishAsync(new ActionCreatedEvent(this));
  164. }
  165. /**
  166. * Loads this action from the config instance.
  167. */
  168. protected void loadActionFromConfig() {
  169. if (config.isFlatDomain(DOMAIN_TRIGGERS)) {
  170. if (!loadTriggers(config.getFlatDomain(DOMAIN_TRIGGERS))) {
  171. return;
  172. }
  173. } else {
  174. error(ActionErrorType.TRIGGERS, "No trigger specified");
  175. return;
  176. }
  177. if (config.isFlatDomain(DOMAIN_RESPONSE)) {
  178. response = new String[config.getFlatDomain(DOMAIN_RESPONSE).size()];
  179. int i = 0;
  180. for (String line : config.getFlatDomain(DOMAIN_RESPONSE)) {
  181. response[i++] = line;
  182. }
  183. } else {
  184. error(ActionErrorType.RESPONSE, "No response specified");
  185. return;
  186. }
  187. if (config.isFlatDomain(DOMAIN_FORMAT)) {
  188. newFormat = config.getFlatDomain(DOMAIN_FORMAT).isEmpty() ? ""
  189. : config.getFlatDomain(DOMAIN_FORMAT).get(0);
  190. }
  191. for (int cond = 0; config.isKeyDomain("condition " + cond); cond++) {
  192. if (!readCondition(config.getKeyDomain("condition " + cond))) {
  193. return;
  194. }
  195. }
  196. if (config.isFlatDomain(DOMAIN_CONDITIONTREE)
  197. && !config.getFlatDomain(DOMAIN_CONDITIONTREE).isEmpty()) {
  198. conditionTree = ConditionTree.parseString(
  199. config.getFlatDomain(DOMAIN_CONDITIONTREE).get(0));
  200. if (conditionTree == null) {
  201. error(ActionErrorType.CONDITION_TREE, "Unable to parse condition tree");
  202. return;
  203. }
  204. if (conditionTree.getMaximumArgument() >= conditions.size()) {
  205. error(ActionErrorType.CONDITION_TREE, "Condition tree references condition "
  206. + conditionTree.getMaximumArgument() + " but there are"
  207. + " only " + conditions.size() + " conditions");
  208. return;
  209. }
  210. }
  211. if (config.isKeyDomain(DOMAIN_CONCURRENCY)
  212. && config.getKeyDomain(DOMAIN_CONCURRENCY).containsKey("group")) {
  213. setConcurrencyGroup(config.getKeyDomain(DOMAIN_CONCURRENCY).get("group"));
  214. }
  215. if (config.isKeyDomain(DOMAIN_MISC)
  216. && config.getKeyDomain(DOMAIN_MISC).containsKey("stopping")) {
  217. setStopping(Boolean.parseBoolean(config.getKeyDomain(DOMAIN_MISC).get("stopping")));
  218. }
  219. if (status == ActionStatus.DISABLED) {
  220. status = ActionStatus.ACTIVE;
  221. }
  222. checkMetaData();
  223. }
  224. /**
  225. * Checks to see if this action contains group meta-data, and adds it to the group as
  226. * appropriate.
  227. */
  228. private void checkMetaData() {
  229. if (config.isKeyDomain(DOMAIN_METADATA)) {
  230. final ActionGroup myGroup = actionController.getOrCreateGroup(group);
  231. final Map<String, String> data = config.getKeyDomain(DOMAIN_METADATA);
  232. if (data.containsKey("description")) {
  233. myGroup.setDescription(data.get("description"));
  234. }
  235. if (data.containsKey("author")) {
  236. myGroup.setAuthor(data.get("author"));
  237. }
  238. if (data.containsKey("version")) {
  239. myGroup.setVersion(new Version(data.get("version")));
  240. }
  241. if (data.containsKey("component")) {
  242. try {
  243. myGroup.setComponent(Integer.parseInt(data.get("component")));
  244. } catch (NumberFormatException ex) {
  245. // Do nothing
  246. }
  247. }
  248. }
  249. for (int i = 0; config.isKeyDomain("setting " + i); i++) {
  250. final ActionGroup myGroup = actionController.getOrCreateGroup(group);
  251. final Map<String, String> data = config.getKeyDomain("setting " + i);
  252. if (data.containsKey("type") && data.containsKey("setting")
  253. && data.containsKey("title") && data.containsKey("default")
  254. && data.containsKey("tooltip")) {
  255. actionController.registerSetting(data.get("setting"), data.get("default"));
  256. myGroup.getSettings().put(data.get("setting"), new PreferencesSetting(
  257. PreferencesType.valueOf(data.get("type")), "actions",
  258. data.get("setting"), data.get("title"), data.get("tooltip"),
  259. identityController.getGlobalConfiguration(),
  260. identityController.getUserSettings()));
  261. }
  262. }
  263. }
  264. /**
  265. * Loads a list of triggers with the specified names.
  266. *
  267. * @param newTriggers A list of trigger names
  268. *
  269. * @return True if all triggers are valid and compatible, false otherwise.
  270. */
  271. private boolean loadTriggers(final List<String> newTriggers) {
  272. triggers = new ActionType[newTriggers.size()];
  273. for (int i = 0; i < triggers.length; i++) {
  274. triggers[i] = actionController.getType(newTriggers.get(i));
  275. if (triggers[i] == null) {
  276. error(ActionErrorType.TRIGGERS, "Invalid trigger specified: " + newTriggers.get(i));
  277. return false;
  278. } else if (i != 0 && !triggers[i].getType().equals(triggers[0].getType())) {
  279. error(ActionErrorType.TRIGGERS, "Triggers are not compatible");
  280. return false;
  281. }
  282. }
  283. return true;
  284. }
  285. /**
  286. * Called to save the action.
  287. */
  288. public void save() {
  289. if (!isModified()) {
  290. return;
  291. }
  292. final ConfigFile newConfig = new ConfigFile(location);
  293. final List<String> triggerNames = new ArrayList<>();
  294. final List<String> responseLines = new ArrayList<>();
  295. responseLines.addAll(Arrays.asList(response));
  296. for (ActionType trigger : triggers) {
  297. if (trigger == null) {
  298. eventBus.publish(new AppErrorEvent(ErrorLevel.LOW,
  299. new IllegalArgumentException("Triggers: "+ Arrays.toString(triggers)),
  300. "ActionType was null", ""));
  301. continue;
  302. }
  303. triggerNames.add(trigger.toString());
  304. }
  305. newConfig.addDomain(DOMAIN_TRIGGERS, triggerNames);
  306. newConfig.addDomain(DOMAIN_RESPONSE, responseLines);
  307. if (conditionTree != null) {
  308. newConfig.addDomain(DOMAIN_CONDITIONTREE, new ArrayList<>());
  309. newConfig.getFlatDomain(DOMAIN_CONDITIONTREE).add(conditionTree.toString());
  310. }
  311. if (newFormat != null) {
  312. newConfig.addDomain(DOMAIN_FORMAT, new ArrayList<>());
  313. newConfig.getFlatDomain(DOMAIN_FORMAT).add(newFormat);
  314. }
  315. if (concurrencyGroup != null) {
  316. newConfig.addDomain(DOMAIN_CONCURRENCY, new HashMap<>());
  317. newConfig.getKeyDomain(DOMAIN_CONCURRENCY).put("group", concurrencyGroup);
  318. }
  319. if (stop) {
  320. newConfig.addDomain(DOMAIN_MISC, new HashMap<>());
  321. newConfig.getKeyDomain(DOMAIN_MISC).put("stopping", "true");
  322. }
  323. int i = 0;
  324. for (ActionCondition condition : conditions) {
  325. final Map<String, String> data = new HashMap<>();
  326. data.put("argument", String.valueOf(condition.getArg()));
  327. if (condition.getArg() == -1) {
  328. data.put("starget", condition.getStarget());
  329. } else {
  330. data.put("component", condition.getComponent().toString());
  331. }
  332. data.put("comparison", condition.getComparison().toString());
  333. data.put("target", condition.getTarget());
  334. newConfig.addDomain("condition " + i, data);
  335. i++;
  336. }
  337. if (config != null) {
  338. // Preserve any meta-data
  339. if (config.isKeyDomain(DOMAIN_METADATA)) {
  340. newConfig.addDomain(DOMAIN_METADATA, config.getKeyDomain(DOMAIN_METADATA));
  341. }
  342. for (i = 0; config.isKeyDomain("setting " + i); i++) {
  343. newConfig.addDomain("setting " + i, config.getKeyDomain("setting " + i));
  344. }
  345. }
  346. try {
  347. newConfig.write();
  348. resetModified();
  349. } catch (IOException ex) {
  350. eventBus.publish(new UserErrorEvent(ErrorLevel.HIGH, ex,
  351. "I/O error when saving action: " + group + '/' + name + ": " + ex.getMessage(),
  352. ""));
  353. }
  354. eventBus.publishAsync(new ActionUpdatedEvent(this));
  355. }
  356. /**
  357. * Reads a condition from the specified configuration section.
  358. *
  359. * @param data The relevant section of the action configuration
  360. *
  361. * @return True if the condition is valid, false otherwise
  362. */
  363. private boolean readCondition(final Map<String, String> data) {
  364. final int arg;
  365. ActionComponent component = null;
  366. final ActionComparison comparison;
  367. final String target;
  368. String starget = null;
  369. // ------ Read the argument
  370. try {
  371. arg = Integer.parseInt(data.get("argument"));
  372. } catch (NumberFormatException ex) {
  373. error(ActionErrorType.CONDITIONS,
  374. "Invalid argument number specified: " + data.get("argument"));
  375. return false;
  376. }
  377. if (arg < -1 || arg >= triggers[0].getType().getArity()) {
  378. error(ActionErrorType.CONDITIONS, "Invalid argument number specified: " + arg);
  379. return false;
  380. }
  381. // ------ Read the component or the source
  382. if (arg == -1) {
  383. starget = data.get("starget");
  384. if (starget == null) {
  385. error(ActionErrorType.CONDITIONS, "No starget specified");
  386. return false;
  387. }
  388. } else {
  389. component = readComponent(data, arg);
  390. if (component == null) {
  391. return false;
  392. }
  393. }
  394. // ------ Read the comparison
  395. comparison = actionController.getComparison(data.get("comparison"));
  396. if (comparison == null) {
  397. error(ActionErrorType.CONDITIONS, "Invalid comparison specified: "
  398. + data.get("comparison"));
  399. return false;
  400. }
  401. if ((arg != -1 && !comparison.appliesTo().equals(component.getType()))
  402. || (arg == -1 && !comparison.appliesTo().equals(String.class))) {
  403. error(ActionErrorType.CONDITIONS,
  404. "Comparison cannot be applied to specified component: " + data.get("comparison"));
  405. return false;
  406. }
  407. // ------ Read the target
  408. target = data.get("target");
  409. if (target == null) {
  410. error(ActionErrorType.CONDITIONS, "No target specified for condition");
  411. return false;
  412. }
  413. if (arg == -1) {
  414. conditions.add(new ActionCondition(starget, comparison, target));
  415. } else {
  416. conditions.add(new ActionCondition(arg, component, comparison, target));
  417. }
  418. return true;
  419. }
  420. /**
  421. * Reads a component from the specified data section for the specified argument.
  422. *
  423. * @param data The relevant section of the action configuration
  424. * @param arg The argument number that the component should apply to
  425. *
  426. * @return The corresponding ActionComponent, or null if the specified component is invalid.
  427. */
  428. private ActionComponent readComponent(final Map<String, String> data, final int arg) {
  429. final String componentName = data.get("component");
  430. final ActionComponent component;
  431. if (componentName.indexOf('.') == -1) {
  432. component = actionController.getComponent(componentName);
  433. } else {
  434. try {
  435. component = new ActionComponentChain(triggers[0].getType().getArgTypes()[arg],
  436. componentName, actionController);
  437. } catch (IllegalArgumentException iae) {
  438. error(ActionErrorType.CONDITIONS, iae.getMessage());
  439. return null;
  440. }
  441. }
  442. if (component == null) {
  443. error(ActionErrorType.CONDITIONS, "Unknown component: " + componentName);
  444. return null;
  445. }
  446. if (!component.appliesTo().equals(triggers[0].getType().getArgTypes()[arg])) {
  447. error(ActionErrorType.CONDITIONS,
  448. "Component cannot be applied to specified arg in condition: " + componentName);
  449. return null;
  450. }
  451. return component;
  452. }
  453. /**
  454. * Raises a trivial error, informing the user of the problem.
  455. *
  456. * @param type The type of error that occurred.
  457. * @param message The message to be raised
  458. */
  459. private void error(final ActionErrorType type, final String message) {
  460. this.error = message;
  461. this.errorType = type;
  462. this.status = ActionStatus.FAILED;
  463. eventBus.publish(new UserErrorEvent(ErrorLevel.LOW,
  464. new IllegalStateException("Error when parsing action: " + group + '/' + name + ": "
  465. + message),
  466. "Error when parsing action" + group + '/' + name + ": " + message, ""));
  467. }
  468. @Override
  469. public void setName(final String newName) {
  470. super.setName(newName);
  471. try {
  472. Files.delete(location);
  473. } catch (IOException ex) {
  474. //TODO we don't handle the error now, but we should
  475. }
  476. location = actionsDirectory.resolve(group).resolve(newName);
  477. save();
  478. }
  479. @Override
  480. public void setGroup(final String newGroup) {
  481. super.setGroup(newGroup);
  482. try {
  483. Files.delete(location);
  484. } catch (IOException ex) {
  485. //TODO we don't handle the error now, but we should
  486. }
  487. location = actionsDirectory.resolve(group).resolve(name);
  488. try {
  489. Files.createDirectories(location);
  490. } catch (IOException ex) {
  491. //TODO we don't handle the error now, but we should
  492. }
  493. save();
  494. }
  495. /**
  496. * Deletes this action.
  497. */
  498. public void delete() {
  499. eventBus.publishAsync(new ActionDeletedEvent(actionController.getOrCreateGroup(getGroup()), this));
  500. try {
  501. Files.delete(location);
  502. } catch (IOException ex) {
  503. //TODO we don't handle the error now, but we should
  504. }
  505. }
  506. @Override
  507. public String toString() {
  508. final String parent = super.toString();
  509. return parent.substring(0, parent.length() - 1) + ",location=" + location + "]";
  510. }
  511. @Override
  512. public void configChanged(final String domain, final String key) {
  513. checkDisabled();
  514. }
  515. /**
  516. * Checks if this action is disabled or not.
  517. *
  518. * @since 0.6.3
  519. */
  520. protected void checkDisabled() {
  521. final String key = (group + "/" + name).replace(' ', '.');
  522. final boolean disabled = identityController.getGlobalConfiguration().hasOptionBool(
  523. "disable_action", key)
  524. && identityController.getGlobalConfiguration().getOptionBool("disable_action", key);
  525. if (disabled && status == ActionStatus.ACTIVE) {
  526. status = ActionStatus.DISABLED;
  527. } else if (!disabled && status == ActionStatus.DISABLED) {
  528. status = ActionStatus.ACTIVE;
  529. }
  530. }
  531. /**
  532. * Sets whether this action is enabled or not.
  533. *
  534. * @param enabled true to enable, false to disable
  535. */
  536. public void setEnabled(final boolean enabled) {
  537. if (enabled) {
  538. identityController.getUserSettings().unsetOption("disable_action",
  539. (group + "/" + name).replace(' ', '.'));
  540. } else {
  541. identityController.getUserSettings().setOption("disable_action",
  542. (group + "/" + name).replace(' ', '.'), true);
  543. }
  544. }
  545. }