static const std::string state_node_name;
- void set_protocol_states (const XMLNode&);
-
int set_state (const XMLNode&, int version);
XMLNode& get_state (void);
+ sigc::signal<void,ControlProtocolInfo*> ProtocolStatusChange;
+
private:
ControlProtocolManager ();
static ControlProtocolManager* _instance;
control_protocols.push_back (cpi.protocol);
+ ProtocolStatusChange (&cpi);
+
return cpi.protocol;
}
delete cpi.state;
cpi.state = 0;
dlclose (cpi.descriptor->module);
+
+ ProtocolStatusChange (&cpi);
+
return 0;
}
for (citer = clist.begin(); citer != clist.end(); ++citer) {
if ((*citer)->name() == X_("Protocol")) {
- prop = (*citer)->property (X_("active"));
-
- if (prop && string_is_affirmative (prop->value())) {
- if ((prop = (*citer)->property (X_("name"))) != 0) {
- ControlProtocolInfo* cpi = cpi_by_name (prop->value());
-
- if (cpi) {
-
- if (cpi->state) {
- delete cpi->state;
- }
+ if ((prop = (*citer)->property (X_("active"))) == 0) {
+ continue;
+ }
- cpi->state = new XMLNode (**citer);
+ bool active = string_is_affirmative (prop->value());
+
+ if ((prop = (*citer)->property (X_("name"))) == 0) {
+ continue;
+ }
- if (_session) {
- instantiate (*cpi);
- } else {
- cpi->requested = true;
- }
+ ControlProtocolInfo* cpi = cpi_by_name (prop->value());
+
+ if (cpi) {
+
+ if (!(*citer)->children().empty()) {
+ cpi->state = new XMLNode (*((*citer)->children().front ()));
+ } else {
+ cpi->state = 0;
+ }
+
+ if (active) {
+ if (_session) {
+ instantiate (*cpi);
+ } else {
+ cpi->requested = true;
+ }
+ } else {
+ if (_session) {
+ teardown (*cpi);
+ } else {
+ cpi->requested = false;
}
}
}
}
}
+
return 0;
}
return *root;
}
-void
-ControlProtocolManager::set_protocol_states (const XMLNode& node)
-{
- XMLNodeList nlist;
- XMLNodeConstIterator niter;
- XMLProperty* prop;
-
- nlist = node.children();
-
- for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
-
- XMLNode* child = (*niter);
-
- if ((prop = child->property ("name")) == 0) {
- error << _("control protocol XML node has no name property. Ignored.") << endmsg;
- continue;
- }
-
- ControlProtocolInfo* cpi = cpi_by_name (prop->value());
-
- if (!cpi) {
- warning << string_compose (_("control protocol \"%1\" is not known. Ignored"), prop->value()) << endmsg;
- continue;
- }
-
- /* copy the node so that ownership is clear */
-
- cpi->state = new XMLNode (*child);
- }
-}
ControlProtocolManager&
ControlProtocolManager::instance ()
}
}
- if ((child = find_named_node (node, "ControlProtocols")) != 0) {
- ControlProtocolManager::instance().set_protocol_states (*child);
+ if ((child = find_named_node (node, ControlProtocolManager::state_node_name)) != 0) {
+ ControlProtocolManager::instance().set_state (*child, version);
}
update_have_rec_enabled_track ();