diff -Nur asterisk.old/apps/app_queue.c asterisk/apps/app_queue.c --- asterisk.old/apps/app_queue.c 2005-05-09 19:16:01.000000000 +0200 +++ asterisk/apps/app_queue.c 2005-07-20 13:56:37.000000000 +0200 @@ -295,6 +295,7 @@ char sound_reporthold[80]; /* Sound file: "Hold time" (def. queue-reporthold) */ int count; /* How many entries */ + int onlyone; /* Only one agent, many devices */ int maxlen; /* Max number of entries */ int wrapuptime; /* Wrapup Time */ @@ -480,6 +481,7 @@ int res = -1; int pos = 0; int inserted = 0; + struct member *mem = NULL; ast_mutex_lock(&qlock); for (q = queues; q; q = q->next) { @@ -495,13 +497,19 @@ else if (q->maxlen && (q->count >= q->maxlen)) *reason = QUEUE_FULL; else { - /* There's space for us, put us at the right position inside - * the queue. - * Take into account the priority of the calling user */ - inserted = 0; - prev = NULL; - cur = q->head; - while(cur) { + int inuse = 0; + if (q->onlyone == 1) /* verifico se qualche membro è attivo */ + for (mem = q->members; mem; mem = mem->next) { + if (mem->status == AST_DEVICE_INUSE) { *reason = QUEUE_FULL; inuse=1; break; } + } + if (inuse==0) { + /* There's space for us, put us at the right position inside + * the queue. + * Take into account the priority of the calling user */ + inserted = 0; + prev = NULL; + cur = q->head; + while(cur) { /* We have higher priority than the current user, enter * before him, after all the other users with priority * higher or equal to our priority. */ @@ -512,16 +520,16 @@ cur->pos = ++pos; prev = cur; cur = cur->next; - } - /* No luck, join at the end of the queue */ - if (!inserted) - insert_entry(q, prev, qe, &pos); - strncpy(qe->moh, q->moh, sizeof(qe->moh) - 1); - strncpy(qe->announce, q->announce, sizeof(qe->announce) - 1); - strncpy(qe->context, q->context, sizeof(qe->context) - 1); - q->count++; - res = 0; - manager_event(EVENT_FLAG_CALL, "Join", + } + /* No luck, join at the end of the queue */ + if (!inserted) + insert_entry(q, prev, qe, &pos); + strncpy(qe->moh, q->moh, sizeof(qe->moh) - 1); + strncpy(qe->announce, q->announce, sizeof(qe->announce) - 1); + strncpy(qe->context, q->context, sizeof(qe->context) - 1); + q->count++; + res = 0; + manager_event(EVENT_FLAG_CALL, "Join", "Channel: %s\r\nCallerID: %s\r\nCallerIDName: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\n", qe->chan->name, qe->chan->cid.cid_num ? qe->chan->cid.cid_num : "unknown", @@ -530,9 +538,10 @@ #if 0 ast_log(LOG_NOTICE, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos ); #endif - } - ast_mutex_unlock(&q->lock); - break; + } + } + ast_mutex_unlock(&q->lock); + break; } } ast_mutex_unlock(&qlock); @@ -2547,6 +2556,7 @@ q->retry = DEFAULT_RETRY; q->timeout = -1; q->maxlen = 0; + q->onlyone = 0; /* default false onlyone */ q->announcefrequency = 0; q->announceholdtime = 0; q->roundingseconds = 0; /* Default - don't announce seconds */ @@ -2650,6 +2660,8 @@ q->wrapuptime = atoi(var->value); } else if (!strcasecmp(var->name, "maxlen")) { q->maxlen = atoi(var->value); + } else if (!strcasecmp(var->name, "onlyone")) { + q->onlyone = atoi(var->value); } else if (!strcasecmp(var->name, "servicelevel")) { q->servicelevel= atoi(var->value); } else if (!strcasecmp(var->name, "strategy")) { @@ -2697,6 +2709,8 @@ q->timeout = DEFAULT_TIMEOUT; if (q->maxlen < 0) q->maxlen = 0; + if (q->onlyone != 0) + q->onlyone = 1; if (!new) ast_mutex_unlock(&q->lock); if (new) { Binary files asterisk.old/apps/app_queue.o and asterisk/apps/app_queue.o differ Binary files asterisk.old/apps/app_queue.so and asterisk/apps/app_queue.so differ