Allow getting a call from an existing "sub" channel.

Cancel ringing if endpoint hangs up before answering.

Fixes were backported from trunk (there was apparently a bit of confusion during merge of a previous patch).
(closes issue #10241)


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@76178 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Jason Parker
2007-07-20 21:03:57 +00:00
parent 24f0e6a947
commit d0baa5500e

View File

@@ -3315,15 +3315,14 @@ static int handle_offhook_message(struct skinny_req *req, struct skinnysession *
l = sub->parent; l = sub->parent;
} }
transmit_ringer_mode(s, SKINNY_RING_OFF);
l->hookstate = SKINNY_OFFHOOK;
if (sub && sub->onhold) { if (sub && sub->onhold) {
transmit_ringer_mode(s, SKINNY_RING_OFF);
l->hookstate = SKINNY_OFFHOOK;
return 1; return 1;
} }
transmit_ringer_mode(s, SKINNY_RING_OFF);
transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON); transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON);
l->hookstate = SKINNY_OFFHOOK;
if (sub && sub->outgoing) { if (sub && sub->outgoing) {
/* We're answering a ringing call */ /* We're answering a ringing call */
@@ -3379,17 +3378,17 @@ static int handle_onhook_message(struct skinny_req *req, struct skinnysession *s
} }
l = sub->parent; l = sub->parent;
if (sub->onhold) {
l->hookstate = SKINNY_ONHOOK;
return 0;
}
if (l->hookstate == SKINNY_ONHOOK) { if (l->hookstate == SKINNY_ONHOOK) {
/* Something else already put us back on hook */ /* Something else already put us back on hook */
return 0; return 0;
} }
sub->cxmode = SKINNY_CX_RECVONLY;
l->hookstate = SKINNY_ONHOOK; l->hookstate = SKINNY_ONHOOK;
if (sub->onhold) {
return 0;
}
sub->cxmode = SKINNY_CX_RECVONLY;
transmit_callstate(s, l->instance, l->hookstate, sub->callid); transmit_callstate(s, l->instance, l->hookstate, sub->callid);
if (skinnydebug) if (skinnydebug)
ast_verbose("Skinny %s@%s went on hook\n", l->name, d->name); ast_verbose("Skinny %s@%s went on hook\n", l->name, d->name);
@@ -3900,37 +3899,37 @@ static int handle_soft_key_event_message(struct skinny_req *req, struct skinnyse
} }
#endif #endif
break; break;
case SOFTKEY_NEWCALL: case SOFTKEY_NEWCALL: /* Actually the DIAL softkey */
/* XXX Untested */
if (skinnydebug) if (skinnydebug)
ast_verbose("Received Softkey Event: New Call(%d)\n", instance); ast_verbose("Received Softkey Event: New Call(%d)\n", instance);
transmit_ringer_mode(s,SKINNY_RING_OFF); if (!sub || !sub->owner) {
transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON); c = skinny_new(l, AST_STATE_DOWN);
transmit_speaker_mode(s, SKINNY_SPEAKERON); } else {
c = sub->owner;
l->hookstate = SKINNY_OFFHOOK;
if (sub) {
ast_verbose("Uhoh, got NewCall with sub != 0\n");
break;
} }
c = skinny_new(l, AST_STATE_DOWN); if (!c) {
ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
if(c) { } else {
sub = c->tech_pvt; sub = c->tech_pvt;
transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); if (l->hookstate == SKINNY_ONHOOK) {
l->hookstate = SKINNY_OFFHOOK;
transmit_speaker_mode(s, SKINNY_SPEAKERON);
transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid);
}
if (skinnydebug)
ast_verbose("Attempting to Clear display on Skinny %s@%s\n", l->name, d->name);
transmit_displaymessage(s, NULL); /* clear display */ transmit_displaymessage(s, NULL); /* clear display */
transmit_tone(s, SKINNY_DIALTONE); transmit_tone(s, SKINNY_DIALTONE);
transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK); transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK);
/* start the switch thread */ /* start the switch thread */
if (ast_pthread_create(&t, NULL, skinny_ss, c)) { if (ast_pthread_create(&t, NULL, skinny_ss, c)) {
ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno)); ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno));
ast_hangup(c); ast_hangup(c);
} }
} else {
ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name);
} }
break; break;
case SOFTKEY_HOLD: case SOFTKEY_HOLD: