+ // send the command to all clients
+ for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
+ (*it)->AddCommand(command);
+}
+
+void CLibCEC::Alert(const libcec_alert type, const libcec_parameter ¶m)
+{
+ // send the alert to all clients
+ for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
+ (*it)->Alert(type, param);
+}
+
+CCECClient *CLibCEC::RegisterClient(libcec_configuration &configuration)
+{
+ if (!m_cec)
+ return NULL;
+
+ // create a new client instance
+ CCECClient *newClient = new CCECClient(m_cec, configuration);
+ if (!newClient)
+ return NULL;
+ m_clients.push_back(newClient);
+
+ // if the default client isn't set, set it
+ if (!m_client)
+ m_client = newClient;
+
+ // register the new client
+ if (m_cec->CECInitialised())
+ m_cec->RegisterClient(newClient);
+
+ return newClient;
+}
+
+void CLibCEC::UnregisterClients(void)
+{
+ if (m_cec && m_cec->IsRunning())
+ m_cec->UnregisterClients();
+
+ m_clients.clear();
+
+ DELETE_AND_NULL(m_client);
+}
+
+void * CECInitialise(libcec_configuration *configuration)
+{
+ if (!configuration)
+ return NULL;
+
+ // create a new libCEC instance
+ CLibCEC *lib = new CLibCEC;
+
+ // register a new client
+ CCECClient *client(NULL);
+ if (lib && configuration)
+ client = lib->RegisterClient(*configuration);
+
+ // update the current configuration
+ if (client)
+ client->GetCurrentConfiguration(*configuration);
+
+ // ensure that the correct server version is set
+ configuration->serverVersion = LIBCEC_VERSION_CURRENT;
+
+ return static_cast< void* > (lib);