Index: app_queue.c =================================================================== RCS file: /usr/cvsroot/asterisk/apps/app_queue.c,v retrieving revision 1.35 diff -u -r1.35 app_queue.c --- app_queue.c 10 Sep 2003 05:24:49 -0000 1.35 +++ app_queue.c 25 Sep 2003 22:20:47 -0000 @@ -160,7 +160,7 @@ int retry; /* Retry calling everyone after this amount of time */ int timeout; /* How long to wait for an answer */ - /* Queue strategy things */ + /* Queue strateqlockgy things */ int rrpos; /* Round Robin - position */ int wrapped; /* Round Robin - wrapped around? */ @@ -1384,7 +1384,7 @@ ast_cli(fd, " Callers: \n"); for (qe = q->head; qe; qe = qe->next) ast_cli(fd, " %d. %s (wait: %d:%2.2d)\n", pos++, qe->chan->name, - (now - qe->start) / 60, (now - qe->start) % 60); + (int) (now - qe->start) / 60, (int) (now - qe->start) % 60); } else ast_cli(fd, " No Callers\n"); ast_cli(fd, "\n"); @@ -1406,11 +1406,11 @@ static int manager_queues_status( struct mansession *s, struct message *m ) { time_t now; - int pos; char *id = astman_get_header(m,"ActionID"); char idText[256] = ""; struct ast_call_queue *q; struct queue_ent *qe; + struct member *mem; astman_send_ack(s, m, "Queue status will follow"); time(&now); q = queues; @@ -1424,30 +1424,90 @@ "Max: %d\r\n" "Calls: %d\r\n" "%s" - "\r\n", - q->name, q->maxlen, q->count,idText); -#if 0 + "\r\n" + , q->name, q->maxlen, q->count,idText); + + //XXX:There should be a lock when we are parsing members, but there are not any for the mo. /* Do we care about queue members? */ for (mem = q->members; mem; mem = mem->next) - ast_cli(fd, " %s/%s\n", mem->tech, mem->loc); -#endif - pos = 1; - for (qe = q->head; qe; qe = qe->next) ast_cli(s->fd, "Event: QueueMember\r\n" "Queue: %s\r\n" + "Technology: %s\r\n" + "Location: %s\r\n" + "Penalty: %d\r\n" + "Calls: %d\r\n" + "Dynamic: %d\r\n" + //"LastCall: " + , q->name, mem->tech, mem->loc, mem->penalty, mem->calls, mem->dynamic); + + for (qe = q->head; qe; qe = qe->next) + ast_cli(s->fd, "Event: QueueEntry\r\n" + "Queue: %s\r\n" "Position: %d\r\n" "Channel: %s\r\n" "CallerID: %s\r\n" "Wait: %ld\r\n" "%s" - "\r\n", - q->name, pos++, qe->chan->name, (qe->chan->callerid ? qe->chan->callerid : ""), (long)(now - qe->start), idText); + "\r\n" + , q->name, qe->pos, qe->chan->name, (qe->chan->callerid ? qe->chan->callerid : ""), (long)(now - qe->start), idText); ast_mutex_unlock(&q->lock); q = q->next; } return RESULT_SUCCESS; } +static int manager_aqm_exec( struct mansession *s, struct message *m ) +{ + char *data = astman_get_header(m, "Queue"); + char *techno = astman_get_header(m, "Technology"); + + if (!strlen(data)) { + astman_send_error(s, m, "No queue specified"); + return 0; + } + + if (!strlen(techno)) { + astman_send_error(s, m, "No technology specified"); + return 0; + } + + data = strcat(data, "|"); + data = strcat(data, techno); + + if (!aqm_exec(NULL, (void *) data)) { + ast_cli(s->fd, "Response: Success\r\n"); + return 0; + } + astman_send_error(s, m, "Execution failed"); + return 0; +} + +static int manager_rqm_exec( struct mansession *s, struct message *m ) +{ + char *data = astman_get_header(m, "Queue"); + char *techno = astman_get_header(m, "Technology"); + + if (!strlen(data)) { + astman_send_error(s, m, "No queue specified"); + return 0; + } + + if (!strlen(techno)) { + astman_send_error(s, m, "No technology specified"); + return 0; + } + + data = strcat(data, "|"); + data = strcat(data, techno); + + if (!rqm_exec(NULL, (void *) data)) { + ast_cli(s->fd, "Response: Success\r\n"); + return 0; + } + astman_send_error(s, m, "Execution failed"); + return 0; +} + static char show_queues_usage[] = "Usage: show queues\n" " Provides summary information on call queues.\n"; @@ -1462,6 +1522,8 @@ ast_cli_unregister(&cli_show_queues); ast_manager_unregister( "Queues" ); ast_manager_unregister( "QueueStatus" ); + ast_manager_unregister( app_aqm ); + ast_manager_unregister( app_rqm ); return ast_unregister_application(app); } @@ -1473,6 +1535,8 @@ ast_cli_register(&cli_show_queues); ast_manager_register( "Queues", 0, manager_queues_show, "Queues" ); ast_manager_register( "QueueStatus", 0, manager_queues_status, "Queue Status" ); + ast_manager_register( app_aqm, 0, manager_aqm_exec, "Add Queue Member" ); + ast_manager_register( app_rqm, 0, manager_rqm_exec, "Remove Queue Member" ); // [PHM 06/26/03] ast_register_application(app_aqm, aqm_exec, app_aqm_synopsis, app_aqm_descrip) ;