+
+ObActionsAct* actions_parse(ObParseInst *i,
+ xmlDocPtr doc,
+ xmlNodePtr node)
+{
+ GSList *it;
+ gchar *name;
+ ObActionsDefinition *def;
+ ObActionsAct *act = NULL;
+
+ if (!parse_attr_string("name", node, &name)) return NULL;
+
+ /* find the requested action */
+ for (it = registered; it; it = g_slist_next(it)) {
+ def = it->data;
+ if (!g_ascii_strcasecmp(name, def->name))
+ break;
+ }
+
+ /* if we found the action */
+ if (it != NULL) {
+ act = g_new(ObActionsAct, 1);
+ act->ref = 1;
+ act->def = def;
+ actions_definition_ref(act->def);
+ act->options = def->setup(i, doc, node->children);
+ } else
+ g_message(_("Invalid action '%s' requested. No such action exists."),
+ name);
+
+ g_free(name);
+
+ return act;
+}
+
+void actions_act_ref(ObActionsAct *act)
+{
+ ++act->ref;
+}
+
+void actions_act_unref(ObActionsAct *act)
+{
+ if (act && --act->ref == 0) {
+ /* free the action specific options */
+ act->def->free(act->options);
+ /* unref the definition */
+ actions_definition_unref(act->def);
+ g_free(act);
+ }
+}