Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Functions | Variables
parking_manager.c File Reference

Call Parking Manager Actions and Events. More...

#include "asterisk.h"
#include "res_parking.h"
#include "asterisk/config.h"
#include "asterisk/config_options.h"
#include "asterisk/utils.h"
#include "asterisk/module.h"
#include "asterisk/cli.h"
#include "asterisk/astobj2.h"
#include "asterisk/features.h"
#include "asterisk/manager.h"
#include "asterisk/bridge.h"

Go to the source code of this file.

Data Structures

struct  park_list_data
 

Functions

int load_parking_manager (void)
 Register manager actions and setup subscriptions for stasis events. More...
 
static int manager_append_event_parking_lot_data_cb (void *obj, void *arg, void *data, int flags)
 
static struct ast_strmanager_build_parked_call_string (const struct ast_parked_call_payload *payload)
 Builds a manager string based on the contents of a parked call payload.
 
static int manager_park (struct mansession *s, const struct message *m)
 
static void manager_park_bridged (struct mansession *s, const struct message *m, struct ast_channel *chan, struct ast_channel *parker_chan, const char *parkinglot, int timeout_override)
 
static void manager_park_unbridged (struct mansession *s, const struct message *m, struct ast_channel *chan, const char *parkinglot, int timeout_override)
 
static int manager_parking_lot_list (struct mansession *s, const struct message *m)
 
static int manager_parking_status (struct mansession *s, const struct message *m)
 
static void manager_parking_status_all_lots (struct mansession *s, const struct message *m, const char *id_text)
 
static void manager_parking_status_single_lot (struct mansession *s, const struct message *m, const char *id_text, const char *lot_name)
 
static void parked_call_message_response (struct ast_parked_call_payload *parked_call)
 
static struct ast_parked_call_payloadparked_call_payload_from_failure (struct ast_channel *chan)
 
static struct ast_parked_call_payloadparked_call_payload_from_parked_user (struct parked_user *pu, enum ast_parked_call_event_type event_type)
 
static void parking_event_cb (void *data, struct stasis_subscription *sub, struct stasis_message *message)
 
static void parking_manager_disable_stasis (void)
 
static void parking_manager_enable_stasis (void)
 
void publish_parked_call (struct parked_user *pu, enum ast_parked_call_event_type event_type)
 Publish a stasis parked call message for a given parked user. More...
 
void publish_parked_call_failure (struct ast_channel *parkee)
 Publish a stasis parked call message for the channel indicating failure to park. More...
 
void unload_parking_manager (void)
 Unregister manager actions and remove subscriptions for stasis events. More...
 

Variables

static struct stasis_subscriptionparking_sub
 subscription to the parking lot topic
 

Detailed Description

Call Parking Manager Actions and Events.

Author
Jonathan Rose jrose.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file parking_manager.c.

Function Documentation

int load_parking_manager ( void  )

Register manager actions and setup subscriptions for stasis events.

Since
12.0.0

Definition at line 704 of file parking_manager.c.

References ast_manager_register_xml.

705 {
706  int res;
707 
708  res = ast_manager_register_xml("Parkinglots", EVENT_FLAG_CALL, manager_parking_lot_list);
709  res |= ast_manager_register_xml("ParkedCalls", EVENT_FLAG_CALL, manager_parking_status);
710  res |= ast_manager_register_xml("Park", EVENT_FLAG_CALL, manager_park);
711  parking_manager_enable_stasis();
712  return res ? -1 : 0;
713 }
#define ast_manager_register_xml(action, authority, func)
Register a manager callback using XML documentation to describe the manager.
Definition: manager.h:191
void publish_parked_call ( struct parked_user pu,
enum ast_parked_call_event_type  event_type 
)

Publish a stasis parked call message for a given parked user.

Since
12.0.0
Parameters
pupointer to a parked_user that we are generating the message for
event_typeWhat parked call event type is provoking this message

Definition at line 627 of file parking_manager.c.

References ast_parked_call_type(), ast_parking_topic(), RAII_VAR, stasis_message_create(), and stasis_publish().

628 {
629  RAII_VAR(struct ast_parked_call_payload *, payload, NULL, ao2_cleanup);
630  RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
631 
632  if (!ast_parked_call_type()) {
633  return;
634  }
635 
636  payload = parked_call_payload_from_parked_user(pu, event_type);
637  if (!payload) {
638  return;
639  }
640 
642  if (!msg) {
643  return;
644  }
645 
647 }
struct stasis_message_type * ast_parked_call_type(void)
accessor for the parked call stasis message type
A parked call message payload.
Definition: parking.h:59
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
struct stasis_topic * ast_parking_topic(void)
accessor for the parking stasis topic
Definition: parking.c:67
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941
void publish_parked_call_failure ( struct ast_channel parkee)

Publish a stasis parked call message for the channel indicating failure to park.

Since
12.0.0
Parameters
parkeechannel belonging to the failed parkee

Definition at line 605 of file parking_manager.c.

References ast_parked_call_type(), ast_parking_topic(), RAII_VAR, stasis_message_create(), and stasis_publish().

606 {
607  RAII_VAR(struct ast_parked_call_payload *, payload, NULL, ao2_cleanup);
608  RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
609 
610  if (!ast_parked_call_type()) {
611  return;
612  }
613 
614  payload = parked_call_payload_from_failure(parkee);
615  if (!payload) {
616  return;
617  }
618 
620  if (!msg) {
621  return;
622  }
623 
625 }
struct stasis_message_type * ast_parked_call_type(void)
accessor for the parked call stasis message type
A parked call message payload.
Definition: parking.h:59
struct stasis_message * stasis_message_create(struct stasis_message_type *type, void *data)
Create a new message.
void stasis_publish(struct stasis_topic *topic, struct stasis_message *message)
Publish a message to a topic's subscribers.
Definition: stasis.c:1511
struct stasis_topic * ast_parking_topic(void)
accessor for the parking stasis topic
Definition: parking.c:67
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941
void unload_parking_manager ( void  )

Unregister manager actions and remove subscriptions for stasis events.

Since
12.0.0

Definition at line 720 of file parking_manager.c.

References ast_manager_unregister().

721 {
722  ast_manager_unregister("Parkinglots");
723  ast_manager_unregister("ParkedCalls");
724  ast_manager_unregister("Park");
725  parking_manager_disable_stasis();
726 }
int ast_manager_unregister(const char *action)
Unregister a registered manager command.
Definition: manager.c:8057