Index: channels/chan_mobile.c =================================================================== --- channels/chan_mobile.c (revision 649) +++ channels/chan_mobile.c (working copy) @@ -568,7 +568,7 @@ struct mbl_pvt *pvt; char *dest_dev = NULL; char *dest_num = NULL; - int oldformat, group; + int oldformat, group = -1; if (!data) { ast_log(LOG_WARNING, "Channel requested with no data\n"); @@ -590,13 +590,15 @@ if (dest_num) *dest_num++ = 0x00; - /* Find requested device and make sure its connected. */ + if (((dest_dev[0] == 'g') || (dest_dev[0] == 'G')) && ((dest_dev[1] >= '0') && (dest_dev[1] <= '9'))) { + group = atoi(&dest_dev[1]); + } + + /* Find requested device and make sure it's connected. */ AST_RWLIST_RDLOCK(&devices); AST_RWLIST_TRAVERSE(&devices, pvt, entry) { - if (((dest_dev[0] == 'g') || (dest_dev[0] == 'G')) && ((dest_dev[1] >= '0') && (dest_dev[1] <= '9'))) { - group = atoi(dest_dev+1); - if (pvt->group == group) - break; + if (group > -1 && pvt->group == group && pvt->connected && !pvt->owner) { + break; } else if (!strcmp(pvt->id, dest_dev)) { break; } @@ -609,14 +611,14 @@ } if ((pvt->type == MBL_TYPE_PHONE) && !dest_num) { - ast_log(LOG_WARNING, "Cant determine destination number.\n"); + ast_log(LOG_WARNING, "Can't determine destination number.\n"); *cause = AST_CAUSE_INCOMPATIBLE_DESTINATION; return NULL; } chn = mbl_new(AST_STATE_DOWN, pvt, NULL); if (!chn) { - ast_log(LOG_WARNING, "Unable to allocate channel structure\n"); + ast_log(LOG_WARNING, "Unable to allocate channel structure.\n"); *cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL; return NULL; }