conf_state_empty.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 2012, Terry Wilson
  5. *
  6. * Terry Wilson <twilson@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. *
  18. * Please follow coding guidelines
  19. * http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES
  20. */
  21. /*! \file
  22. *
  23. * \brief Confbridge state handling for the EMPTY state
  24. *
  25. * \author\verbatim Terry Wilson <twilson@digium.com> \endverbatim
  26. *
  27. * \ingroup applications
  28. */
  29. /*** MODULEINFO
  30. <support_level>core</support_level>
  31. ***/
  32. #include "asterisk.h"
  33. #include "asterisk/devicestate.h"
  34. #include "include/confbridge.h"
  35. #include "include/conf_state.h"
  36. static void join_unmarked(struct confbridge_user *user);
  37. static void join_waitmarked(struct confbridge_user *user);
  38. static void join_marked(struct confbridge_user *user);
  39. static void transition_to_empty(struct confbridge_user *user);
  40. struct confbridge_state STATE_EMPTY = {
  41. .name = "EMPTY",
  42. .join_unmarked = join_unmarked,
  43. .join_waitmarked = join_waitmarked,
  44. .join_marked = join_marked,
  45. .entry = transition_to_empty,
  46. };
  47. struct confbridge_state *CONF_STATE_EMPTY = &STATE_EMPTY;
  48. static void join_unmarked(struct confbridge_user *user)
  49. {
  50. conf_add_user_active(user->conference, user);
  51. conf_handle_first_join(user->conference);
  52. conf_add_post_join_action(user, conf_handle_only_person);
  53. conf_change_state(user, CONF_STATE_SINGLE);
  54. }
  55. static void join_waitmarked(struct confbridge_user *user)
  56. {
  57. conf_default_join_waitmarked(user);
  58. conf_handle_first_join(user->conference);
  59. conf_change_state(user, CONF_STATE_INACTIVE);
  60. }
  61. static void join_marked(struct confbridge_user *user)
  62. {
  63. conf_add_user_marked(user->conference, user);
  64. conf_handle_first_join(user->conference);
  65. conf_add_post_join_action(user, conf_handle_only_person);
  66. conf_change_state(user, CONF_STATE_SINGLE_MARKED);
  67. }
  68. static void transition_to_empty(struct confbridge_user *user)
  69. {
  70. /* Set device state to "not in use" */
  71. ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", user->conference->name);
  72. conf_ended(user->conference);
  73. }