Index: channels/chan_skinny.c =================================================================== --- channels/chan_skinny.c (revision 62093) +++ channels/chan_skinny.c (working copy) @@ -98,6 +98,7 @@ #define SKINNY_MAX_PACKET 1000 static int keep_alive = 120; +static char vmaccess[32]; /* Voicemail pilot number */ static char date_format[6] = "D-M-Y"; static char version_id[16] = "P002F202"; @@ -2285,8 +2286,11 @@ if (res < 0) { if (skinnydebug) ast_verbose("Skinny(%s@%s): waitfordigit returned < 0\n", l->name, d->name); - ast_indicate(c, -1); - ast_hangup(c); + if(sub->owner){ + //sub->alreadygone = 1; + ast_indicate(c, -1); + ast_hangup(c); + } return NULL; } else if (res) { exten[len++]=res; @@ -2328,7 +2332,8 @@ } else if (res == 0) { ast_log(LOG_DEBUG, "Not enough digits (and no ambiguous match)...\n"); transmit_tone(s, SKINNY_REORDER); - ast_hangup(c); + if (c) + ast_hangup(c); return NULL; } else if (!ast_canmatch_extension(c, c->context, exten, 1, c->cid.cid_num) && ((exten[0] != '*') || (!ast_strlen_zero(exten) > 2))) { @@ -2345,7 +2350,9 @@ ast_indicate(c, -1); } } - ast_hangup(c); + if(c) + ast_hangup(c); + return NULL; } @@ -3026,13 +3033,16 @@ if (skinnydebug) ast_verbose("Received Stimulus: Redial(%d)\n", instance); -#if 0 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); } else { sub = c->tech_pvt; - transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); + l = sub->parent; + if (l->hookstate == SKINNY_ONHOOK){ + l->hookstate = SKINNY_OFFHOOK; + 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 */ @@ -3051,42 +3061,52 @@ ast_hangup(c); } } -#endif break; case STIMULUS_SPEEDDIAL: if (skinnydebug) ast_verbose("Received Stimulus: SpeedDial(%d)\n", instance); -#if 0 + struct skinny_speeddial *sd; if (!(sd = find_speeddial_by_instance(d, instance))) { return 0; } - c = skinny_new(l, AST_STATE_DOWN); - if(c) { + if (!sub || !sub->owner) { + c = skinny_new(l, AST_STATE_DOWN); + } else { + c = sub->owner; + } + + if(!c) { + ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); + } else { sub = c->tech_pvt; l = sub->parent; - 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_tone(s, SKINNY_DIALTONE); - if (!ast_ignore_pattern(c->context, sd->exten)) { transmit_tone(s, SKINNY_SILENCE); } if (ast_exists_extension(c, c->context, sd->exten, 1, l->cid_num)) { - if (!ast_matchmore_extension(c, c->context, sd->exten, 1, l->cid_num)) { + //if (!ast_matchmore_extension(c, c->context, sd->exten, 1, l->cid_num)) { ast_copy_string(c->exten, sd->exten, sizeof(c->exten)); ast_copy_string(l->lastnumberdialed, sd->exten, sizeof(l->lastnumberdialed)); - skinny_newcall(c); + + if (ast_pthread_create(&t, NULL, skinny_newcall, c)) { + ast_log(LOG_WARNING, "Unable to create new call thread: %s\n", strerror(errno)); + ast_hangup(c); + } break; - } + //} } - } else { - ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); } -#endif break; case STIMULUS_HOLD: if (skinnydebug) @@ -3116,7 +3136,41 @@ case STIMULUS_VOICEMAIL: if (skinnydebug) ast_verbose("Received Stimulus: Voicemail(%d)\n", instance); - /* XXX Find and dial voicemail extension */ + + if (!sub || !sub->owner) { + c = skinny_new(l, AST_STATE_DOWN); + } else { + c = sub->owner; + } + if(!c) { + ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); + } else { + sub = c->tech_pvt; + l = sub->parent; + 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_tone(s, SKINNY_DIALTONE); + if (!ast_ignore_pattern(c->context, vmaccess)) { + transmit_tone(s, SKINNY_SILENCE); + } + if (ast_exists_extension(c, c->context, vmaccess, 1, l->cid_num)) { + //if (!ast_matchmore_extension(c, c->context, sd->exten, 1, l->cid_num)) { + ast_copy_string(c->exten, vmaccess, sizeof(c->exten)); + ast_copy_string(l->lastnumberdialed, vmaccess, sizeof(l->lastnumberdialed)); + if (ast_pthread_create(&t, NULL, skinny_newcall, c)) { + ast_log(LOG_WARNING, "Unable to create new call thread: %s\n", strerror(errno)); + ast_hangup(c); + } + break; + //} + } + } break; case STIMULUS_CALLPARK: if (skinnydebug) @@ -3745,7 +3799,6 @@ if (skinnydebug) ast_verbose("Received Softkey Event: Redial(%d)\n", instance); -#if 0 if (!sub || !sub->owner) { c = skinny_new(l, AST_STATE_DOWN); } else { @@ -3756,7 +3809,11 @@ ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); } else { 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 */ @@ -3775,34 +3832,43 @@ ast_hangup(c); } } -#endif break; - case SOFTKEY_NEWCALL: + case SOFTKEY_NEWCALL: /* Actually the DIAL softkey */ /* XXX Untested */ if (skinnydebug) ast_verbose("Received Softkey Event: New Call(%d)\n", instance); - transmit_ringer_mode(s,SKINNY_RING_OFF); - transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON); + if (!sub || !sub->owner) { + c = skinny_new(l, AST_STATE_DOWN); + } else { + c = sub->owner; + } - l->hookstate = SKINNY_OFFHOOK; + /* transmit_ringer_mode(s,SKINNY_RING_OFF); + transmit_lamp_indication(s, STIMULUS_LINE, l->instance, SKINNY_LAMP_ON); */ - if (sub) { - transmit_callstate(s, l->instance, SKINNY_OFFHOOK, sub->callid); + /* l->hookstate = SKINNY_OFFHOOK; */ + + if (!c) { + ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); + } else { + sub = c->tech_pvt; + 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_tone(s, SKINNY_DIALTONE); transmit_selectsoftkeys(s, l->instance, sub->callid, KEYDEF_OFFHOOK); - c = skinny_new(l, AST_STATE_DOWN); - if(c) { - /* start the switch thread */ - if (ast_pthread_create(&t, NULL, skinny_ss, c)) { - ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno)); - ast_hangup(c); - } - } else { - ast_log(LOG_WARNING, "Unable to create channel for %s@%s\n", l->name, d->name); + + /* start the switch thread */ + if (ast_pthread_create(&t, NULL, skinny_ss, c)) { + ast_log(LOG_WARNING, "Unable to create switch thread: %s\n", strerror(errno)); + ast_hangup(c); } } break; @@ -4461,6 +4527,8 @@ } } else if (!strcasecmp(v->name, "keepalive")) { keep_alive = atoi(v->value); + } else if (!strcasecmp(v->name, "vmaccess")) { + ast_copy_string(vmaccess, v->value, sizeof(vmaccess)); } else if (!strcasecmp(v->name, "dateformat")) { ast_copy_string(date_format, v->value, sizeof(date_format)); } else if (!strcasecmp(v->name, "allow")) { Index: configs/skinny.conf.sample =================================================================== --- configs/skinny.conf.sample (revision 62093) +++ configs/skinny.conf.sample (working copy) @@ -7,6 +7,10 @@ dateformat=M-D-Y ; M,D,Y in any order (5 chars max) keepalive=120 +;vmaccess=8500 ; Systemwide voicemailmain pilot number + ; It must be in the same context as the calling + ; device/line + ;allow=all ; see doc/rtp-packetization for framing options ;disallow=