2 /***************************************************************************
3 * net_handler.cpp - Fawkes configuration network handler
5 * Generated: Sat Jan 06 22:55:03 2007
6 * Copyright 2006-2007 Tim Niemueller [www.niemueller.de]
8 ****************************************************************************/
10 /* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
24 #include <config/net_handler.h>
25 #include <config/net_messages.h>
26 #include <config/net_list_content.h>
27 #include <utils/logging/liblogger.h>
29 #include <netcomm/fawkes/component_ids.h>
30 #include <netcomm/fawkes/hub.h>
31 #include <config/config.h>
38 /** @class ConfigNetworkHandler <config/net_handler.h>
39 * Fawkes Configuration Network Handler.
40 * It provides access to a given config via the network.
41 * This is mainly used to allow modification of config values over the network.
43 * @author Tim Niemueller
47 * @param config configuration, loaded and ready to be used for getting and
49 * @param hub Fawkes network hub to use for receiving and sending network
52 ConfigNetworkHandler::ConfigNetworkHandler(Configuration *config,
53 FawkesNetworkHub *hub)
54 : Thread("ConfigNetworkHandler", Thread::OPMODE_WAITFORWAKEUP),
55 FawkesNetworkHandler(FAWKES_CID_CONFIGMANAGER),
56 ConfigurationChangeHandler()
63 __config->add_change_handler(this);
64 __hub->add_handler( this );
69 ConfigNetworkHandler::~ConfigNetworkHandler()
73 __config->rem_change_handler(this);
74 __inbound_queue.clear();
78 /** Send invalid value message.
79 * @param clid client ID
83 ConfigNetworkHandler::send_inv_value(unsigned int clid, const char *path)
85 config_invval_msg_t *r = prepare_msg<config_invval_msg_t>(path, false);
86 __hub->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_INV_VALUE, r, sizeof(config_invval_msg_t));
91 * @param clid client ID
95 ConfigNetworkHandler::send_value(unsigned int clid, Configuration::ValueIterator *i)
97 if ( i->is_float() ) {
99 config_float_value_msg_t *r = prepare_msg<config_float_value_msg_t>(i->path(), i->is_default());
100 r->f = i->get_float();
101 __hub->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_FLOAT_VALUE, r, sizeof(config_float_value_msg_t));
102 } catch (Exception &e) {
103 LibLogger::log_warn("ConfigNetworkHandler",
104 "send_value: Value %s could not be sent",
106 LibLogger::log_warn("ConfigNetworkHandler", e);
108 } else if ( i->is_uint() ) {
110 config_uint_value_msg_t *r = prepare_msg<config_uint_value_msg_t>(i->path(), i->is_default());
111 r->u = i->get_uint();
112 __hub->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_UINT_VALUE, r, sizeof(config_uint_value_msg_t));
113 } catch (Exception &e) {
114 LibLogger::log_warn("ConfigNetworkHandler",
115 "send_value: Value %s could not be sent",
117 LibLogger::log_warn("ConfigNetworkHandler", e);
119 } else if ( i->is_int() ) {
121 config_int_value_msg_t *r = prepare_msg<config_int_value_msg_t>(i->path(), i->is_default());
123 __hub->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_INT_VALUE, r, sizeof(config_int_value_msg_t));
124 } catch (Exception &e) {
125 LibLogger::log_warn("ConfigNetworkHandler",
126 "send_value: Value %s could not be sent",
128 LibLogger::log_warn("ConfigNetworkHandler", e);
130 } else if ( i->is_bool() ) {
132 config_bool_value_msg_t *r = prepare_msg<config_bool_value_msg_t>(i->path(), i->is_default());
133 r->b = (i->get_bool() ? 1 : 0);
134 __hub->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_BOOL_VALUE, r, sizeof(config_bool_value_msg_t));
135 } catch (Exception &e) {
136 LibLogger::log_warn("ConfigNetworkHandler",
137 "send_value: Value %s could not be sent",
139 LibLogger::log_warn("ConfigNetworkHandler", e);
141 } else if ( i->is_string() ) {
143 size_t sl = sizeof(config_string_value_msg_t) + i->get_string().length();
144 config_string_value_msg_t *m = (config_string_value_msg_t *)calloc(1, sl);
145 strncpy(m->cp.path, i->path(), CONFIG_MSG_PATH_LENGTH);
146 m->cp.is_default = i->is_default() ? 1 : 0;
147 m->s_length = i->get_string().length();
148 strcpy(m->s, i->get_string().c_str());
149 __hub->send(clid, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_STRING_VALUE, m, sl);
150 } catch (Exception &e) {
151 LibLogger::log_warn("ConfigNetworkHandler",
152 "send_value: Value %s could not be sent",
154 LibLogger::log_warn("ConfigNetworkHandler", e);
160 /** Process all network messages that have been received. */
162 ConfigNetworkHandler::loop()
164 while ( ! __inbound_queue.empty() ) {
165 FawkesNetworkMessage *msg = __inbound_queue.front();
167 // printf("Received message of type %u\n", msg->msgid());
169 if (msg->msgid() == MSG_CONFIG_SUBSCRIBE) {
171 __subscribers.push_back_locked(msg->clid());
172 __subscribers.sort();
173 __subscribers.unique();
176 ConfigListContent *content = new ConfigListContent();
177 Configuration::ValueIterator *i = __config->iterator_default();
178 while ( i->next() ) {
182 i = __config->iterator_hostspecific();
183 while ( i->next() ) {
187 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_LIST, content);
190 } else if (msg->msgid() == MSG_CONFIG_ERASE_VALUE) {
192 config_erase_value_msg_t *m = msg->msg<config_erase_value_msg_t>();
193 char path[CONFIG_MSG_PATH_LENGTH + 1];
194 path[CONFIG_MSG_PATH_LENGTH] = 0;
195 strncpy(path, m->cp.path, CONFIG_MSG_PATH_LENGTH);
197 if ( m->cp.is_default == 1 ) {
198 __config->erase_default(path);
200 __config->erase(path);
203 config_value_erased_msg_t *r = prepare_msg<config_value_erased_msg_t>(path, (m->cp.is_default == 1));
204 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_VALUE_ERASED,
205 r, sizeof(config_value_erased_msg_t));
207 } catch (Exception &e) {
208 send_inv_value(msg->clid(), "?");
209 e.append("Failed to erase value");
210 LibLogger::log_warn("ConfigNetworkHandler", "Failed to erase value");
211 LibLogger::log_warn("ConfigNetworkHandler", e);
214 } else if ( (msg->msgid() >= MSG_CONFIG_GET_BEGIN) &&
215 (msg->msgid() <= MSG_CONFIG_GET_END) ) {
217 if ( msg->payload_size() != sizeof(config_getval_msg_t) ) {
218 LibLogger::log_warn("ConfigNetworkHandler",
219 "CONFIG_GET_FLOAT: invalid payload size "
220 "(received %zu instead of %zu bytes",
221 msg->payload_size(), sizeof(config_getval_msg_t));
223 config_getval_msg_t *m = (config_getval_msg_t *)msg->payload();
224 char path[CONFIG_MSG_PATH_LENGTH + 1];
225 path[CONFIG_MSG_PATH_LENGTH] = 0;
226 strncpy(path, m->cp.path, CONFIG_MSG_PATH_LENGTH);
228 switch (msg->msgid()) {
229 case MSG_CONFIG_GET_FLOAT:
231 float f = __config->get_float(path);
232 bool d = __config->is_default(path);
233 config_float_value_msg_t *r = prepare_msg<config_float_value_msg_t>(path, d);
235 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_FLOAT_VALUE,
236 r, sizeof(config_float_value_msg_t));
237 } catch (Exception &e) {
238 send_inv_value(msg->clid(), path);
239 LibLogger::log_warn("ConfigNetworkHandler",
240 "get float: Value %s could not be found", path);
241 LibLogger::log_warn("ConfigNetworkHandler", e);
245 case MSG_CONFIG_GET_UINT:
247 unsigned int u = __config->get_uint(path);
248 bool d = __config->is_default(path);
249 config_uint_value_msg_t *r = prepare_msg<config_uint_value_msg_t>(path, d);
251 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_UINT_VALUE,
252 r, sizeof(config_uint_value_msg_t));
253 } catch (Exception &e) {
254 send_inv_value(msg->clid(), path);
255 LibLogger::log_warn("ConfigNetworkHandler",
256 "get uint: Value %s could not be found", path);
257 LibLogger::log_warn("ConfigNetworkHandler", e);
261 case MSG_CONFIG_GET_INT:
263 int i = __config->get_int(path);
264 bool d = __config->is_default(path);
265 config_int_value_msg_t *r = prepare_msg<config_int_value_msg_t>(path, d);
267 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_INT_VALUE,
268 r, sizeof(config_int_value_msg_t));
269 } catch (Exception &e) {
270 send_inv_value(msg->clid(), path);
271 LibLogger::log_warn("ConfigNetworkHandler",
272 "get int: Value %s could not be found", path);
273 LibLogger::log_warn("ConfigNetworkHandler", e);
277 case MSG_CONFIG_GET_BOOL:
279 bool b = __config->get_bool(path);
280 bool d = __config->is_default(path);
281 config_bool_value_msg_t *r = prepare_msg<config_bool_value_msg_t>(path, d);
283 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_BOOL_VALUE,
284 r, sizeof(config_bool_value_msg_t));
285 } catch (Exception &e) {
286 send_inv_value(msg->clid(), path);
287 LibLogger::log_warn("ConfigNetworkHandler",
288 "get bool: Value %s could not be found", path);
289 LibLogger::log_warn("ConfigNetworkHandler", e);
293 case MSG_CONFIG_GET_STRING:
295 std::string s = __config->get_string(path);
296 bool d = __config->is_default(path);
297 config_string_value_msg_t *r = prepare_string_msg<config_string_value_msg_t>(path, d, s.length());
298 strcpy(r->s, s.c_str());
299 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_STRING_VALUE,
300 r, sizeof(config_string_value_msg_t));
301 } catch (Exception &e) {
302 send_inv_value(msg->clid(), path);
303 LibLogger::log_warn("ConfigNetworkHandler",
304 "get string: Value %s could not be found", path);
305 LibLogger::log_warn("ConfigNetworkHandler", e);
309 case MSG_CONFIG_GET_VALUE:
311 Configuration::ValueIterator *i = __config->get_value(path);
313 send_value(msg->clid(), i);
315 send_inv_value(msg->clid(), path);
318 } catch (ConfigurationException &e) {
319 LibLogger::log_warn("ConfigNetworkHandler",
320 "get value: Value %s could not be found", path);
321 LibLogger::log_warn("ConfigNetworkHandler", e);
327 } else if ( (msg->msgid() >= MSG_CONFIG_SET_BEGIN) &&
328 (msg->msgid() <= MSG_CONFIG_SET_END) ) {
330 char path[CONFIG_MSG_PATH_LENGTH + 1];
331 if ( msg->payload_size() < sizeof(config_descriptor_t)) {
332 LibLogger::log_warn("ConfigNetworkHandler",
333 "inbound set: payload is too small"
334 "(%zu is less than %zu bytes",
335 msg->payload_size(), sizeof(config_descriptor_t));
336 send_inv_value(msg->clid(), "?");
338 config_descriptor_t *d = (config_descriptor_t *)msg->payload();
339 path[CONFIG_MSG_PATH_LENGTH] = 0;
340 strncpy(path, d->path, CONFIG_MSG_PATH_LENGTH);
342 switch (msg->msgid()) {
343 case MSG_CONFIG_SET_FLOAT:
344 case MSG_CONFIG_SET_DEFAULT_FLOAT:
346 config_float_value_msg_t *m = msg->msg<config_float_value_msg_t>();
347 if ( msg->msgid() == MSG_CONFIG_SET_FLOAT ) {
348 __config->set_float(path, m->f);
350 __config->set_default_float(path, m->f);
352 float f = __config->get_float(path);
353 config_float_value_msg_t *r = prepare_msg<config_float_value_msg_t>(path, (msg->msgid() == MSG_CONFIG_SET_DEFAULT_FLOAT));
355 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_FLOAT_VALUE,
356 r, sizeof(config_float_value_msg_t));
357 } catch (Exception &e) {
358 send_inv_value(msg->clid(), path);
359 LibLogger::log_warn("ConfigNetworkHandler",
360 "set float: Value %s could not be set", path);
361 LibLogger::log_warn("ConfigNetworkHandler", e);
365 case MSG_CONFIG_SET_UINT:
366 case MSG_CONFIG_SET_DEFAULT_UINT:
368 config_uint_value_msg_t *m = msg->msg<config_uint_value_msg_t>();
369 if ( msg->msgid() == MSG_CONFIG_SET_UINT ) {
370 __config->set_uint(path, m->u);
372 __config->set_default_uint(path, m->u);
374 unsigned int u = __config->get_uint(path);
375 config_uint_value_msg_t *r = prepare_msg<config_uint_value_msg_t>(path, (msg->msgid() == MSG_CONFIG_SET_DEFAULT_UINT));
377 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_UINT_VALUE,
378 r, sizeof(config_uint_value_msg_t));
379 } catch (Exception &e) {
380 send_inv_value(msg->clid(), path);
381 LibLogger::log_warn("ConfigNetworkHandler",
382 "set uint: Value %s could not be set", path);
383 LibLogger::log_warn("ConfigNetworkHandler", e);
387 case MSG_CONFIG_SET_INT:
388 case MSG_CONFIG_SET_DEFAULT_INT:
390 config_int_value_msg_t *m = msg->msg<config_int_value_msg_t>();
391 if ( msg->msgid() == MSG_CONFIG_SET_INT ) {
392 __config->set_int(path, m->i);
394 __config->set_default_int(path, m->i);
396 int i = __config->get_int(path);
397 config_int_value_msg_t *r = prepare_msg<config_int_value_msg_t>(path, (msg->msgid() == MSG_CONFIG_SET_DEFAULT_INT));
399 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_INT_VALUE,
400 r, sizeof(config_int_value_msg_t));
401 } catch (Exception &e) {
402 send_inv_value(msg->clid(), path);
403 LibLogger::log_warn("ConfigNetworkHandler",
404 "set int: Value %s could not be set", path);
405 LibLogger::log_warn("ConfigNetworkHandler", e);
409 case MSG_CONFIG_SET_BOOL:
410 case MSG_CONFIG_SET_DEFAULT_BOOL:
412 config_bool_value_msg_t *m = msg->msg<config_bool_value_msg_t>();
413 if ( msg->msgid() == MSG_CONFIG_SET_BOOL ) {
414 __config->set_bool(path, (m->b != 0));
416 __config->set_default_bool(path, (m->b != 0));
418 bool b = __config->get_bool(path);
419 config_bool_value_msg_t *r = prepare_msg<config_bool_value_msg_t>(path, (msg->msgid() == MSG_CONFIG_SET_DEFAULT_BOOL));
421 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_BOOL_VALUE,
422 r, sizeof(config_bool_value_msg_t));
423 } catch (Exception &e) {
424 send_inv_value(msg->clid(), path);
425 LibLogger::log_warn("ConfigNetworkHandler",
426 "set bool: Value %s could not be set", path);
427 LibLogger::log_warn("ConfigNetworkHandler", e);
431 case MSG_CONFIG_SET_STRING:
432 case MSG_CONFIG_SET_DEFAULT_STRING:
434 config_string_value_msg_t *m = msg->msgge<config_string_value_msg_t>();
435 if ( msg->msgid() == MSG_CONFIG_SET_STRING ) {
436 __config->set_string(path, m->s);
438 __config->set_default_string(path, m->s);
440 std::string s = __config->get_string(path);
441 size_t s_length = s.length();
442 config_string_value_msg_t *r = prepare_string_msg<config_string_value_msg_t>(path, (msg->msgid() == MSG_CONFIG_SET_DEFAULT_STRING), s_length);
443 strcpy(r->s, s.c_str());
444 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_STRING_VALUE,
445 r, sizeof(config_string_value_msg_t) + s_length);
446 } catch (Exception &e) {
447 send_inv_value(msg->clid(), path);
448 LibLogger::log_warn("ConfigNetworkHandler",
449 "set string: Value %s could not be set", path);
450 LibLogger::log_warn("ConfigNetworkHandler", e);
454 case MSG_CONFIG_SET_COMMENT:
455 case MSG_CONFIG_SET_DEFAULT_COMMENT:
457 config_comment_msg_t *m = msg->msgge<config_comment_msg_t>();
459 if ( msg->msgid() == MSG_CONFIG_SET_COMMENT ) {
460 __config->set_comment(path, m->s);
461 s = __config->get_comment(path);
463 __config->set_default_comment(path, m->s);
464 s = __config->get_default_comment(path);
466 size_t s_length = s.length();
467 config_comment_msg_t *r = prepare_string_msg<config_comment_msg_t>(path, (msg->msgid() == MSG_CONFIG_SET_DEFAULT_COMMENT), s_length);
468 strcpy(r->s, s.c_str());
469 __hub->send(msg->clid(), FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_COMMENT_VALUE,
470 r, sizeof(config_comment_msg_t) + s_length);
471 } catch (Exception &e) {
472 send_inv_value(msg->clid(), path);
473 LibLogger::log_warn("ConfigNetworkHandler",
474 "set comment: Value %s could not be set", path);
475 LibLogger::log_warn("ConfigNetworkHandler", e);
485 __inbound_queue.pop_locked();
490 /** Handle network message.
491 * The message is put into the inbound queue and processed in processAfterLoop().
495 ConfigNetworkHandler::handle_network_message(FawkesNetworkMessage *msg)
498 __inbound_queue.push_locked(msg);
503 /** Client connected.
505 * @param clid client ID
508 ConfigNetworkHandler::client_connected(unsigned int clid)
513 /** Client disconnected.
514 * If the client was a subscriber it is removed.
515 * @param clid client ID
518 ConfigNetworkHandler::client_disconnected(unsigned int clid)
520 __subscribers.lock();
521 if (find(__subscribers.begin(), __subscribers.end(), clid) != __subscribers.end()) {
522 LibLogger::log_warn("ConfigNetworkHandler",
523 "Client %u disconnected without closing the config, removing from list of subscribers",
525 __subscribers.remove(clid);
527 __subscribers.unlock();
533 * @param new_tag new tag
536 ConfigNetworkHandler::config_tag_changed(const char *new_tag)
542 ConfigNetworkHandler::config_value_changed(const char *path, bool is_default, int value)
544 __subscribers.lock();
545 for (__sit = __subscribers.begin(); __sit != __subscribers.end(); ++__sit) {
547 config_int_value_msg_t *r = prepare_msg<config_int_value_msg_t>(path, is_default);
549 __hub->send(*__sit, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_INT_VALUE,
550 r, sizeof(config_int_value_msg_t));
551 } catch (Exception &e) {
552 LibLogger::log_warn("ConfigNetworkHandler",
553 "config_value_changed[int]: Value for %s could not be sent "
554 "to client %u", path, *__sit);
555 LibLogger::log_warn("ConfigNetworkHandler", e);
558 __subscribers.unlock();
563 ConfigNetworkHandler::config_value_changed(const char *path, bool is_default, unsigned int value)
565 __subscribers.lock();
566 for (__sit = __subscribers.begin(); __sit != __subscribers.end(); ++__sit) {
568 config_uint_value_msg_t *r = prepare_msg<config_uint_value_msg_t>(path, is_default);
570 __hub->send(*__sit, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_UINT_VALUE,
571 r, sizeof(config_uint_value_msg_t));
572 } catch (Exception &e) {
573 LibLogger::log_warn("ConfigNetworkHandler",
574 "config_value_changed[uint]: Value for %s could not be sent "
575 "to client %u", path, *__sit);
576 LibLogger::log_warn("ConfigNetworkHandler", e);
579 __subscribers.unlock();
584 ConfigNetworkHandler::config_value_changed(const char *path, bool is_default, float value)
586 __subscribers.lock();
587 for (__sit = __subscribers.begin(); __sit != __subscribers.end(); ++__sit) {
589 config_float_value_msg_t *r = prepare_msg<config_float_value_msg_t>(path, is_default);
591 __hub->send(*__sit, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_FLOAT_VALUE,
592 r, sizeof(config_float_value_msg_t));
593 } catch (Exception &e) {
594 LibLogger::log_warn("ConfigNetworkHandler",
595 "config_value_changed[float]: Value for %s could not be sent "
596 "to client %u", path, *__sit);
597 LibLogger::log_warn("ConfigNetworkHandler", e);
600 __subscribers.unlock();
605 ConfigNetworkHandler::config_value_changed(const char *path, bool is_default, bool value)
607 __subscribers.lock();
608 for (__sit = __subscribers.begin(); __sit != __subscribers.end(); ++__sit) {
610 config_bool_value_msg_t *r = prepare_msg<config_bool_value_msg_t>(path, is_default);
611 r->b = (value ? 1 : 0);
612 __hub->send(*__sit, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_BOOL_VALUE,
613 r, sizeof(config_bool_value_msg_t));
614 } catch (Exception &e) {
615 LibLogger::log_warn("ConfigNetworkHandler",
616 "config_value_changed[bool]: Value for %s could not be sent "
617 "to client %u", path, *__sit);
618 LibLogger::log_warn("ConfigNetworkHandler", e);
621 __subscribers.unlock();
626 ConfigNetworkHandler::config_value_changed(const char *path, bool is_default, const char *value)
628 __subscribers.lock();
629 for (__sit = __subscribers.begin(); __sit != __subscribers.end(); ++__sit) {
631 size_t s_length = strlen(value);
632 config_string_value_msg_t *r = prepare_string_msg<config_string_value_msg_t>(path, is_default, s_length);
634 __hub->send(*__sit, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_STRING_VALUE,
635 r, sizeof(config_string_value_msg_t) + s_length);
636 } catch (Exception &e) {
637 LibLogger::log_warn("ConfigNetworkHandler",
638 "config_value_changed[string]: Value for %s could not be sent "
639 "to client %u", path, *__sit);
640 LibLogger::log_warn("ConfigNetworkHandler", e);
643 __subscribers.unlock();
648 ConfigNetworkHandler::config_comment_changed(const char *path, bool is_default, const char *comment)
650 __subscribers.lock();
651 for (__sit = __subscribers.begin(); __sit != __subscribers.end(); ++__sit) {
653 size_t s_length = strlen(comment);
654 config_comment_msg_t *r = prepare_string_msg<config_comment_msg_t>(path, is_default, s_length);
655 strcpy(r->s, comment);
657 __hub->send(*__sit, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_COMMENT_VALUE,
658 r, sizeof(config_comment_msg_t) + s_length);
659 } catch (Exception &e) {
660 LibLogger::log_warn("ConfigNetworkHandler",
661 "config_value_changed[string]: Value for %s could not be sent "
662 "to client %u", path, *__sit);
663 LibLogger::log_warn("ConfigNetworkHandler", e);
666 __subscribers.unlock();
671 ConfigNetworkHandler::config_value_erased(const char *path, bool is_default)
673 __subscribers.lock();
674 for (__sit = __subscribers.begin(); __sit != __subscribers.end(); ++__sit) {
676 config_value_erased_msg_t *r = prepare_msg<config_value_erased_msg_t>(path, is_default);
677 __hub->send(*__sit, FAWKES_CID_CONFIGMANAGER, MSG_CONFIG_VALUE_ERASED,
678 r, sizeof(config_value_erased_msg_t));
679 } catch (Exception &e) {
680 LibLogger::log_warn("ConfigNetworkHandler",
681 "configValueErased: Value for %s could not be sent "
682 "to client %u", path, *__sit);
685 __subscribers.unlock();
688 } // end namespace fawkes