+
+/* sending queue to asterisk */
+static int queue_send(void)
+{
+ int work = 0;
+ struct chan_call *call;
+ struct ast_channel *ast;
+ struct ast_frame fr;
+ char *p;
+
+ call = call_first;
+ while(call) {
+ p = call->queue_string;
+ ast = call->ast;
+ if (*p && ast) {
+ /* there is something to queue */
+ if (!ast_channel_trylock(ast)) { /* succeed */
+ while(*p) {
+ switch (*p) {
+ case 'P':
+ CDEBUG(call, ast, "Sending queued PROCEEDING to Asterisk.\n");
+ ast_queue_control(ast, AST_CONTROL_PROCEEDING);
+ break;
+ case 'R':
+ CDEBUG(call, ast, "Sending queued RINGING to Asterisk.\n");
+ ast_queue_control(ast, AST_CONTROL_RINGING);
+ break;
+ case 'A':
+ CDEBUG(call, ast, "Sending queued ANSWER to Asterisk.\n");
+ ast_queue_control(ast, AST_CONTROL_ANSWER);
+ break;
+ case 'H':
+ CDEBUG(call, ast, "Sending queued HANGUP to Asterisk.\n");
+ ast_queue_hangup(ast);
+ break;
+ case '1': case '2': case '3': case 'a':
+ case '4': case '5': case '6': case 'b':
+ case '7': case '8': case '9': case 'c':
+ case '*': case '0': case '#': case 'd':
+ CDEBUG(call, ast, "Sending queued digit '%c' to Asterisk.\n", *p);
+ /* send digit to asterisk */
+ memset(&fr, 0, sizeof(fr));
+ fr.frametype = AST_FRAME_DTMF;
+ fr.subclass = *p;
+ fr.delivery = ast_tv(0, 0);
+ fr.len = 100;
+ ast_queue_frame(ast, &fr);
+ break;
+ default:
+ CDEBUG(call, ast, "Ignoring queued digit 0x%02d.\n", *p);
+ }
+ p++;
+ }
+ call->queue_string[0] = '\0';
+ ast_channel_unlock(ast);
+ work = 1;
+ }
+ }
+ call = call->next;
+ }
+
+ return work;
+}
+
+/* signal handler */