--- asterisk/channels/chan_sip.c 2004-12-13 08:26:26.000000000 -0700 +++ asterisk-20041213/channels/chan_sip.c 2004-12-21 13:22:25.000000000 -0700 @@ -368,6 +368,7 @@ struct sip_history *history; /* History of this SIP dialog */ struct ast_variable *vars; struct sip_pvt *next; /* Next call in chain */ + int onhold; /* call on hold */ } *iflist = NULL; #define FLAG_RESPONSE (1 << 0) @@ -587,6 +588,7 @@ static void prune_peers(void); static int sip_do_reload(void); +static int holdevents = 0; /*--- sip_debug_test_addr: See if we pass debug IP filter */ static inline int sip_debug_test_addr(struct sockaddr_in *addr) @@ -2775,8 +2777,23 @@ /* Turn on/off music on hold if we are holding/unholding */ if (sin.sin_addr.s_addr && !sendonly) { ast_moh_stop(ast_bridged_channel(p->owner)); + if (holdevents && p->onhold) { + manager_event(EVENT_FLAG_CALL, "Unhold", + "Channel: %s\r\n" + "Uniqueid: %s\r\n", + p->owner->name, + p->owner->uniqueid); + } } else { ast_moh_start(ast_bridged_channel(p->owner), NULL); + if (holdevents) { + manager_event(EVENT_FLAG_CALL, "Hold", + "Channel: %s\r\n" + "Uniqueid: %s\r\n", + p->owner->name, + p->owner->uniqueid); + p->onhold = 1; + } } } } @@ -8947,6 +8964,8 @@ } else { ast_log(LOG_WARNING, "Invalid port number '%s' at line %d of %s\n", v->value, v->lineno, config); } + } else if (!strcasecmp(v->name, "holdevents")) { + holdevents = ast_true(v->value); } /* else if (strcasecmp(v->name,"type")) * ast_log(LOG_WARNING, "Ignoring %s\n", v->name); --- asterisk/configs/sip.conf.sample 2004-12-11 20:44:17.000000000 -0700 +++ asterisk-20041213/configs/sip.conf.sample 2004-12-21 13:28:11.000000000 -0700 @@ -122,6 +122,7 @@ ; (instead of type=friend) if you have calls in both directions ;registertimeout=20 ; retry registration calls every 20 seconds (default) +;holdevents=no ; generate manager events when sip ua places call on hold ;externip = 200.201.202.203 ; Address that we're going to put in outbound SIP messages ; if we're behind a NAT