summaryrefslogtreecommitdiff
path: root/res/parking
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2015-01-09 18:16:54 +0000
committerRichard Mudgett <rmudgett@digium.com>2015-01-09 18:16:54 +0000
commit52a7cdb1011ee4930c1cd5efaf31588f570b88cf (patch)
tree38d65f57442763ca60d1439b747f5ca99863e0a5 /res/parking
parent77ee23210d40dbbdbb9be6836be6f716af88a54c (diff)
AMI: Make AMI actions that generate event lists consistent.
* Made the following AMI actions use list API calls for consistency: Agents BridgeInfo BridgeList BridgeTechnologyList ConfbridgeLIst ConfbridgeLIstRooms CoreShowChannels DAHDIShowChannels DBGet DeviceStateList ExtensionStateList FAXSessions Hangup IAXpeerlist IAXpeers IAXregistry MeetmeList MeetmeListRooms MWIGet ParkedCalls Parkinglots PJSIPShowEndpoint PJSIPShowEndpoints PJSIPShowRegistrationsInbound PJSIPShowRegistrationsOutbound PJSIPShowResourceLists PJSIPShowSubscriptionsInbound PJSIPShowSubscriptionsOutbound PresenceStateList PRIShowSpans QueueStatus QueueSummary ShowDialPlan SIPpeers SIPpeerstatus SIPshowregistry SKINNYdevices SKINNYlines Status VoicemailUsersList * Incremented the AMI version to 2.7.0. * Changed astman_send_listack() to not use the listflag parameter and always set the value to "Start" so the start capitalization is consistent. i.e., The FAXSessions used "Start" while the rest of the system used "start". The corresponding complete event always used "Complete". * Fixed ami_show_resource_lists() "PJSIPShowResourceLists" to output the AMI ActionID for all of its list events. * Fixed off-nominal AMI protocol error in manager_bridge_info(), manager_parking_status_single_lot(), and manager_parking_status_all_lots(). Use of astman_send_error() after responding to the original AMI action request violates the action response pattern by sending two responses. * Fixed minor protocol error in action_getconfig() when no requested categories are found. Each line needs to be formatted as "Header: text". * Fixed off-nominal memory leak in manager_build_parked_call_string(). * Eliminated unnecessary use of RAII_VAR() in ami_subscription_detail(). ASTERISK-24049 #close Reported by: Jonathan Rose Review: https://reviewboard.asterisk.org/r/4315/ ........ Merged revisions 430434 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@430435 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/parking')
-rw-r--r--res/parking/parking_manager.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/res/parking/parking_manager.c b/res/parking/parking_manager.c
index 73b5ff495..74b455928 100644
--- a/res/parking/parking_manager.c
+++ b/res/parking/parking_manager.c
@@ -210,11 +210,16 @@ static struct ast_str *manager_build_parked_call_string(const struct ast_parked_
parkee_string = ast_manager_build_channel_state_string_prefix(payload->parkee, "Parkee");
if (!parkee_string) {
+ ast_free(out);
return NULL;
}
if (payload->retriever) {
retriever_string = ast_manager_build_channel_state_string_prefix(payload->retriever, "Retriever");
+ if (!retriever_string) {
+ ast_free(out);
+ return NULL;
+ }
}
ast_str_set(&out, 0,
@@ -250,7 +255,7 @@ static void manager_parking_status_single_lot(struct mansession *s, const struct
return;
}
- astman_send_ack(s, m, "Parked calls will follow");
+ astman_send_listack(s, m, "Parked calls will follow", "start");
iter_users = ao2_iterator_init(curlot->parked_users, 0);
while ((curuser = ao2_iterator_next(&iter_users))) {
@@ -260,17 +265,13 @@ static void manager_parking_status_single_lot(struct mansession *s, const struct
payload = parked_call_payload_from_parked_user(curuser, PARKED_CALL);
if (!payload) {
ao2_ref(curuser, -1);
- ao2_iterator_destroy(&iter_users);
- astman_send_error(s, m, "Failed to retrieve parking data about a parked user.");
- return;
+ break;
}
parked_call_string = manager_build_parked_call_string(payload);
if (!parked_call_string) {
ao2_ref(curuser, -1);
- ao2_iterator_destroy(&iter_users);
- astman_send_error(s, m, "Failed to retrieve parking data about a parked user.");
- return;
+ break;
}
total++;
@@ -286,12 +287,9 @@ static void manager_parking_status_single_lot(struct mansession *s, const struct
}
ao2_iterator_destroy(&iter_users);
- astman_append(s,
- "Event: ParkedCallsComplete\r\n"
- "Total: %d\r\n"
- "%s"
- "\r\n",
- total, id_text);
+ astman_send_list_complete_start(s, m, "ParkedCallsComplete", total);
+ astman_append(s, "Total: %d\r\n", total);
+ astman_send_list_complete_end(s);
}
static void manager_parking_status_all_lots(struct mansession *s, const struct message *m, const char *id_text)
@@ -310,7 +308,7 @@ static void manager_parking_status_all_lots(struct mansession *s, const struct m
return;
}
- astman_send_ack(s, m, "Parked calls will follow");
+ astman_send_listack(s, m, "Parked calls will follow", "start");
iter_lots = ao2_iterator_init(lot_container, 0);
while ((curlot = ao2_iterator_next(&iter_lots))) {
@@ -324,8 +322,7 @@ static void manager_parking_status_all_lots(struct mansession *s, const struct m
ao2_ref(curuser, -1);
ao2_iterator_destroy(&iter_users);
ao2_ref(curlot, -1);
- ao2_iterator_destroy(&iter_lots);
- return;
+ goto abort_list;
}
parked_call_string = manager_build_parked_call_string(payload);
@@ -333,8 +330,7 @@ static void manager_parking_status_all_lots(struct mansession *s, const struct m
ao2_ref(curuser, -1);
ao2_iterator_destroy(&iter_users);
ao2_ref(curlot, -1);
- ao2_iterator_destroy(&iter_lots);
- return;
+ goto abort_list;
}
total++;
@@ -351,22 +347,21 @@ static void manager_parking_status_all_lots(struct mansession *s, const struct m
ao2_iterator_destroy(&iter_users);
ao2_ref(curlot, -1);
}
+abort_list:
ao2_iterator_destroy(&iter_lots);
- astman_append(s,
- "Event: ParkedCallsComplete\r\n"
- "Total: %d\r\n"
- "%s"
- "\r\n",
- total, id_text);
+ astman_send_list_complete_start(s, m, "ParkedCallsComplete", total);
+ astman_append(s, "Total: %d\r\n", total);
+ astman_send_list_complete_end(s);
}
static int manager_parking_status(struct mansession *s, const struct message *m)
{
const char *id = astman_get_header(m, "ActionID");
const char *lot_name = astman_get_header(m, "ParkingLot");
- char id_text[256] = "";
+ char id_text[256];
+ id_text[0] = '\0';
if (!ast_strlen_zero(id)) {
snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", id);
}
@@ -380,24 +375,30 @@ static int manager_parking_status(struct mansession *s, const struct message *m)
return 0;
}
+struct park_list_data {
+ const char *id_text;
+ int count;
+};
+
static int manager_append_event_parking_lot_data_cb(void *obj, void *arg, void *data, int flags)
{
struct parking_lot *curlot = obj;
struct mansession *s = arg;
- char *id_text = data;
+ struct park_list_data *list_data = data;
astman_append(s, "Event: Parkinglot\r\n"
+ "%s" /* The Action ID */
"Name: %s\r\n"
"StartSpace: %d\r\n"
"StopSpace: %d\r\n"
"Timeout: %u\r\n"
- "%s" /* The Action ID */
"\r\n",
+ list_data->id_text,
curlot->name,
curlot->cfg->parking_start,
curlot->cfg->parking_stop,
- curlot->cfg->parkingtime,
- id_text);
+ curlot->cfg->parkingtime);
+ ++list_data->count;
return 0;
}
@@ -405,9 +406,11 @@ static int manager_append_event_parking_lot_data_cb(void *obj, void *arg, void *
static int manager_parking_lot_list(struct mansession *s, const struct message *m)
{
const char *id = astman_get_header(m, "ActionID");
- char id_text[256] = "";
struct ao2_container *lot_container;
+ char id_text[256];
+ struct park_list_data list_data;
+ id_text[0] = '\0';
if (!ast_strlen_zero(id)) {
snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", id);
}
@@ -419,14 +422,15 @@ static int manager_parking_lot_list(struct mansession *s, const struct message *
return 0;
}
- astman_send_ack(s, m, "Parking lots will follow");
+ astman_send_listack(s, m, "Parking lots will follow", "start");
- ao2_callback_data(lot_container, OBJ_MULTIPLE | OBJ_NODATA, manager_append_event_parking_lot_data_cb, s, id_text);
+ list_data.id_text = id_text;
+ list_data.count = 0;
+ ao2_callback_data(lot_container, OBJ_MULTIPLE | OBJ_NODATA,
+ manager_append_event_parking_lot_data_cb, s, &list_data);
- astman_append(s,
- "Event: ParkinglotsComplete\r\n"
- "%s"
- "\r\n",id_text);
+ astman_send_list_complete_start(s, m, "ParkinglotsComplete", list_data.count);
+ astman_send_list_complete_end(s);
return 0;
}