summaryrefslogtreecommitdiff
path: root/apps
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 /apps
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 'apps')
-rw-r--r--apps/app_agent_pool.c9
-rw-r--r--apps/app_confbridge.c16
-rw-r--r--apps/app_meetme.c17
-rw-r--r--apps/app_queue.c33
-rw-r--r--apps/app_voicemail.c18
5 files changed, 46 insertions, 47 deletions
diff --git a/apps/app_agent_pool.c b/apps/app_agent_pool.c
index ad1745d8d..a36c77143 100644
--- a/apps/app_agent_pool.c
+++ b/apps/app_agent_pool.c
@@ -2525,13 +2525,14 @@ static int action_agents(struct mansession *s, const struct message *m)
struct ao2_iterator iter;
struct agent_pvt *agent;
struct ast_str *out = ast_str_alloca(4096);
+ int num_agents = 0;
if (!ast_strlen_zero(id)) {
snprintf(id_text, sizeof(id_text), "ActionID: %s\r\n", id);
} else {
id_text[0] = '\0';
}
- astman_send_ack(s, m, "Agents will follow");
+ astman_send_listack(s, m, "Agents will follow", "start");
iter = ao2_iterator_init(agents, 0);
for (; (agent = ao2_iterator_next(&iter)); ao2_ref(agent, -1)) {
@@ -2586,12 +2587,12 @@ static int action_agents(struct mansession *s, const struct message *m)
astman_append(s, "Event: Agents\r\n"
"%s%s\r\n",
ast_str_buffer(out), id_text);
+ ++num_agents;
}
ao2_iterator_destroy(&iter);
- astman_append(s, "Event: AgentsComplete\r\n"
- "%s"
- "\r\n", id_text);
+ astman_send_list_complete_start(s, m, "AgentsComplete", num_agents);
+ astman_send_list_complete_end(s);
return 0;
}
diff --git a/apps/app_confbridge.c b/apps/app_confbridge.c
index 8bffb2958..b5d48452d 100644
--- a/apps/app_confbridge.c
+++ b/apps/app_confbridge.c
@@ -2897,12 +2897,8 @@ static int action_confbridgelist(struct mansession *s, const struct message *m)
ao2_unlock(conference);
ao2_ref(conference, -1);
- astman_append(s,
- "Event: ConfbridgeListComplete\r\n"
- "EventList: Complete\r\n"
- "ListItems: %d\r\n"
- "%s"
- "\r\n", total, id_text);
+ astman_send_list_complete_start(s, m, "ConfbridgeListComplete", total);
+ astman_send_list_complete_end(s);
return 0;
}
@@ -2952,12 +2948,8 @@ static int action_confbridgelistrooms(struct mansession *s, const struct message
ao2_iterator_destroy(&iter);
/* Send final confirmation */
- astman_append(s,
- "Event: ConfbridgeListRoomsComplete\r\n"
- "EventList: Complete\r\n"
- "ListItems: %d\r\n"
- "%s"
- "\r\n", totalitems, id_text);
+ astman_send_list_complete_start(s, m, "ConfbridgeListRoomsComplete", totalitems);
+ astman_send_list_complete_end(s);
return 0;
}
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index bc30f29be..907770e22 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -5577,13 +5577,10 @@ static int action_meetmelist(struct mansession *s, const struct message *m)
ao2_iterator_destroy(&user_iter);
}
AST_LIST_UNLOCK(&confs);
+
/* Send final confirmation */
- astman_append(s,
- "Event: MeetmeListComplete\r\n"
- "EventList: Complete\r\n"
- "ListItems: %d\r\n"
- "%s"
- "\r\n", total, idText);
+ astman_send_list_complete_start(s, m, "MeetmeListComplete", total);
+ astman_send_list_complete_end(s);
return 0;
}
@@ -5645,12 +5642,8 @@ static int action_meetmelistrooms(struct mansession *s, const struct message *m)
AST_LIST_UNLOCK(&confs);
/* Send final confirmation */
- astman_append(s,
- "Event: MeetmeListRoomsComplete\r\n"
- "EventList: Complete\r\n"
- "ListItems: %d\r\n"
- "%s"
- "\r\n", totalitems, idText);
+ astman_send_list_complete_start(s, m, "MeetmeListRoomsComplete", totalitems);
+ astman_send_list_complete_end(s);
return 0;
}
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 1cf1f6ad3..d41641c62 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -9462,19 +9462,21 @@ static int manager_queues_summary(struct mansession *s, const struct message *m)
int qmemavail = 0;
int qchancount = 0;
int qlongestholdtime = 0;
+ int qsummaries = 0;
const char *id = astman_get_header(m, "ActionID");
const char *queuefilter = astman_get_header(m, "Queue");
- char idText[256] = "";
+ char idText[256];
struct call_queue *q;
struct queue_ent *qe;
struct member *mem;
struct ao2_iterator queue_iter;
struct ao2_iterator mem_iter;
- astman_send_ack(s, m, "Queue summary will follow");
+ astman_send_listack(s, m, "Queue summary will follow", "start");
time(&now);
+ idText[0] = '\0';
if (!ast_strlen_zero(id)) {
- snprintf(idText, 256, "ActionID: %s\r\n", id);
+ snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
}
queue_iter = ao2_iterator_init(queues, 0);
while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) {
@@ -9517,15 +9519,15 @@ static int manager_queues_summary(struct mansession *s, const struct message *m)
"%s"
"\r\n",
q->name, qmemcount, qmemavail, qchancount, q->holdtime, q->talktime, qlongestholdtime, idText);
+ ++qsummaries;
}
ao2_unlock(q);
queue_t_unref(q, "Done with iterator");
}
ao2_iterator_destroy(&queue_iter);
- astman_append(s,
- "Event: QueueSummaryComplete\r\n"
- "%s"
- "\r\n", idText);
+
+ astman_send_list_complete_start(s, m, "QueueSummaryComplete", qsummaries);
+ astman_send_list_complete_end(s);
return RESULT_SUCCESS;
}
@@ -9535,10 +9537,11 @@ static int manager_queues_status(struct mansession *s, const struct message *m)
{
time_t now;
int pos;
+ int q_items = 0;
const char *id = astman_get_header(m,"ActionID");
const char *queuefilter = astman_get_header(m,"Queue");
const char *memberfilter = astman_get_header(m,"Member");
- char idText[256] = "";
+ char idText[256];
struct call_queue *q;
struct queue_ent *qe;
float sl = 0;
@@ -9546,8 +9549,9 @@ static int manager_queues_status(struct mansession *s, const struct message *m)
struct ao2_iterator queue_iter;
struct ao2_iterator mem_iter;
- astman_send_ack(s, m, "Queue status will follow");
+ astman_send_listack(s, m, "Queue status will follow", "start");
time(&now);
+ idText[0] = '\0';
if (!ast_strlen_zero(id)) {
snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
}
@@ -9575,6 +9579,8 @@ static int manager_queues_status(struct mansession *s, const struct message *m)
"\r\n",
q->name, q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted,
q->callsabandoned, q->servicelevel, sl, q->weight, idText);
+ ++q_items;
+
/* List Queue Members */
mem_iter = ao2_iterator_init(q->members, 0);
while ((mem = ao2_iterator_next(&mem_iter))) {
@@ -9594,10 +9600,12 @@ static int manager_queues_status(struct mansession *s, const struct message *m)
"\r\n",
q->name, mem->membername, mem->interface, mem->state_interface, mem->dynamic ? "dynamic" : "static",
mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, idText);
+ ++q_items;
}
ao2_ref(mem, -1);
}
ao2_iterator_destroy(&mem_iter);
+
/* List Queue Entries */
pos = 1;
for (qe = q->head; qe; qe = qe->next) {
@@ -9619,6 +9627,7 @@ static int manager_queues_status(struct mansession *s, const struct message *m)
S_COR(ast_channel_connected(qe->chan)->id.number.valid, ast_channel_connected(qe->chan)->id.number.str, "unknown"),
S_COR(ast_channel_connected(qe->chan)->id.name.valid, ast_channel_connected(qe->chan)->id.name.str, "unknown"),
(long) (now - qe->start), idText);
+ ++q_items;
}
}
ao2_unlock(q);
@@ -9626,10 +9635,8 @@ static int manager_queues_status(struct mansession *s, const struct message *m)
}
ao2_iterator_destroy(&queue_iter);
- astman_append(s,
- "Event: QueueStatusComplete\r\n"
- "%s"
- "\r\n",idText);
+ astman_send_list_complete_start(s, m, "QueueStatusComplete", q_items);
+ astman_send_list_complete_end(s);
return RESULT_SUCCESS;
}
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 8cc7b60d4..6311263a4 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -13049,10 +13049,13 @@ static int manager_list_voicemail_users(struct mansession *s, const struct messa
{
struct ast_vm_user *vmu = NULL;
const char *id = astman_get_header(m, "ActionID");
- char actionid[128] = "";
+ char actionid[128];
+ int num_users = 0;
- if (!ast_strlen_zero(id))
+ actionid[0] = '\0';
+ if (!ast_strlen_zero(id)) {
snprintf(actionid, sizeof(actionid), "ActionID: %s\r\n", id);
+ }
AST_LIST_LOCK(&users);
@@ -13062,20 +13065,20 @@ static int manager_list_voicemail_users(struct mansession *s, const struct messa
return RESULT_SUCCESS;
}
- astman_send_ack(s, m, "Voicemail user list will follow");
+ astman_send_listack(s, m, "Voicemail user list will follow", "start");
AST_LIST_TRAVERSE(&users, vmu, list) {
char dirname[256];
-
#ifdef IMAP_STORAGE
int new, old;
+
inboxcount(vmu->mailbox, &new, &old);
#endif
make_dir(dirname, sizeof(dirname), vmu->context, vmu->mailbox, "INBOX");
astman_append(s,
- "%s"
"Event: VoicemailUserEntry\r\n"
+ "%s"
"VMContext: %s\r\n"
"VoiceMailbox: %s\r\n"
"Fullname: %s\r\n"
@@ -13144,8 +13147,11 @@ static int manager_list_voicemail_users(struct mansession *s, const struct messa
count_messages(vmu, dirname)
#endif
);
+ ++num_users;
}
- astman_append(s, "Event: VoicemailUserEntryComplete\r\n%s\r\n", actionid);
+
+ astman_send_list_complete_start(s, m, "VoicemailUserEntryComplete", num_users);
+ astman_send_list_complete_end(s);
AST_LIST_UNLOCK(&users);