+ -- Merge voicemail enhancements (app_voicemail2)
+ -- Add multiple queueing strategies
-- Merge support for 'T'
-- Allow pending agent calling (Agent/:1)
-- Add groupings to agents.conf
char numsubst[256];
char tech[40];
int stillgoing;
- int penalty;
int metric;
int allowredirect_in;
int allowredirect_out;
int musiconhold;
int dataquality;
int allowdisconnect;
+ struct member *member;
struct localuser *next;
};
char tech[80]; /* Technology */
char loc[256]; /* Location */
int penalty; /* Are we a last resort? */
- struct timeval lastcall; /* When last successful call was hungup */
+ int calls;
+ time_t lastcall; /* When last successful call was hungup */
struct member *next; /* Next member */
};
#define MAX 256
-static struct ast_channel *wait_for_answer(struct queue_ent *qe, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect, char *digit)
+static struct localuser *wait_for_answer(struct queue_ent *qe, struct localuser *outgoing, int *to, int *allowredir_in, int *allowredir_out, int *allowdisconnect, char *digit)
{
char *queue = qe->parent->name;
struct localuser *o;
int numbusies = 0;
int orig = *to;
struct ast_frame *f;
- struct ast_channel *peer = NULL;
+ struct localuser *peer = NULL;
struct ast_channel *watchers[MAX];
int pos;
struct ast_channel *winner;
if (!peer) {
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
- peer = o->chan;
+ peer = o;
*allowredir_in = o->allowredirect_in;
*allowredir_out = o->allowredirect_out;
*allowdisconnect = o->allowdisconnect;
if (!peer) {
if (option_verbose > 2)
ast_verbose( VERBOSE_PREFIX_3 "%s answered %s\n", o->chan->name, in->name);
- peer = o->chan;
+ peer = o;
*allowredir_in = o->allowredirect_in;
*allowredir_out = o->allowredirect_out;
*allowdisconnect = o->allowdisconnect;
return res;
}
-static int calc_metric(struct ast_call_queue *q, int pos, struct queue_ent *qe, struct localuser *tmp)
+static int update_queue(struct ast_call_queue *q, struct localuser *user)
+{
+ struct member *cur;
+ /* Since a reload could have taken place, we have to traverse the list to
+ be sure it's still valid */
+ ast_pthread_mutex_lock(&q->lock);
+ cur = q->members;
+ while(cur) {
+ if (user->member == cur) {
+ time(&cur->lastcall);
+ cur->calls++;
+ break;
+ }
+ cur = cur->next;
+ }
+ ast_pthread_mutex_unlock(&q->lock);
+ return 0;
+}
+
+static int calc_metric(struct ast_call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct localuser *tmp)
{
switch (q->strategy) {
case QUEUE_STRATEGY_RINGALL:
q->wrapped = 1;
tmp->metric = pos;
}
- tmp->metric += tmp->penalty * 1000000;
+ tmp->metric += mem->penalty * 1000000;
break;
case QUEUE_STRATEGY_RANDOM:
tmp->metric = rand() % 1000;
- tmp->metric += tmp->penalty * 1000000;
+ tmp->metric += mem->penalty * 1000000;
+ break;
+ case QUEUE_STRATEGY_FEWESTCALLS:
+ tmp->metric = mem->calls;
+ tmp->metric += mem->penalty * 1000000;
+ break;
+ case QUEUE_STRATEGY_LEASTRECENT:
+ if (!mem->lastcall)
+ tmp->metric = 0;
+ else
+ tmp->metric = 1000000 - (time(NULL) - mem->lastcall);
+ tmp->metric += mem->penalty * 1000000;
break;
default:
ast_log(LOG_WARNING, "Can't calculate metric for unknown strategy %d\n", q->strategy);
char restofit[AST_MAX_EXTENSION];
char *newnum;
struct ast_channel *peer;
+ struct localuser *lpeer;
int res = 0, bridge = 0;
int zapx = 2;
int x=0;
} else
ast_log(LOG_DEBUG, "Simple queue (no URL)\n");
+ tmp->member = cur; /* Never directly dereference! Could change on reload */
strncpy(tmp->tech, cur->tech, sizeof(tmp->tech)-1);
strncpy(tmp->numsubst, cur->loc, sizeof(tmp->numsubst)-1);
- tmp->penalty = cur->penalty;
/* If we're dialing by extension, look at the extension to know what to dial */
if ((newnum = strstr(tmp->numsubst, "BYEXTENSION"))) {
strncpy(restofit, newnum + strlen("BYEXTENSION"), sizeof(restofit)-1);
if (!qe->parent->strategy)
ring_entry(qe, tmp);
else
- calc_metric(qe->parent, x++, qe, tmp);
+ calc_metric(qe->parent, cur, x++, qe, tmp);
/* Put them in the list of outgoing thingies... We're ready now.
XXX If we're forcibly removed, these outgoing calls won't get
hung up XXX */
if (qe->parent->strategy)
ring_one(qe, outgoing);
ast_pthread_mutex_unlock(&qe->parent->lock);
- peer = wait_for_answer(qe, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect, &digit);
+ lpeer = wait_for_answer(qe, outgoing, &to, &allowredir_in, &allowredir_out, &allowdisconnect, &digit);
+ if (lpeer)
+ peer = lpeer->chan;
+ else
+ peer = NULL;
if (!peer) {
if (to) {
/* Musta gotten hung up */
if (tmp->dataquality) zapx = 0;
ast_channel_setoption(peer,AST_OPTION_TONE_VERIFY,&zapx,sizeof(char),0);
}
+ /* Update parameters for the queue */
+ update_queue(qe->parent, lpeer);
hanguptree(outgoing, peer);
/* Stop music on hold */
ast_moh_stop(qe->chan);
int pos;
time_t now;
char max[80];
+ char calls[80];
time(&now);
if (argc != 2)
snprintf(max, sizeof(max), " with penalty %d", mem->penalty);
else
strcpy(max, "");
- ast_cli(fd, " %s/%s%s\n", mem->tech, mem->loc, max);
+ if (mem->calls) {
+ snprintf(calls, sizeof(calls), " has taken %d calls (last was %ld secs ago)",
+ mem->calls, time(NULL) - mem->lastcall);
+ } else
+ strcpy(calls, " has taken no calls yet");
+ ast_cli(fd, " %s/%s%s%s\n", mem->tech, mem->loc, max, calls);
}
} else
ast_cli(fd, " No Members\n");
bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 0, "Listen", "Listen", "1", 1);
bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 1, "Folder", "Folder", "2", 1);
bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 2, "Advanced", "Advnced", "3", 1);
- bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Options", "Options", "4", 1);
+ bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 3, "Options", "Options", "0", 1);
bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 4, "Help", "Help", "*", 1);
bytes += adsi_load_soft_key(buf + bytes, ADSI_KEY_APPS + 5, "Exit", "Exit", "#", 1);
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DOWNLOAD);
bytes += adsi_input_format(buf + bytes, 1, ADSI_DIR_FROM_LEFT, 0, "Password: ******", "");
bytes += adsi_input_control(buf + bytes, ADSI_COMM_PAGE, 4, 0, 1, ADSI_JUST_LEFT);
bytes += adsi_set_keys(buf + bytes, keys);
+ bytes += adsi_voice_mode(buf + bytes, 0);
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
}
bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 2, ADSI_JUST_CENT, 0, " ", "");
bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
bytes += adsi_set_keys(buf + bytes, keys);
+ bytes += adsi_voice_mode(buf + bytes, 0);
+
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
}
bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_LEFT, 0, datetime, "");
bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
bytes += adsi_set_keys(buf + bytes, keys);
+ bytes += adsi_voice_mode(buf + bytes, 0);
+
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
}
/* Except "Exit" */
keys[5] = ADSI_KEY_SKT | (ADSI_KEY_APPS + 5);
bytes += adsi_set_keys(buf + bytes, keys);
+ bytes += adsi_voice_mode(buf + bytes, 0);
+
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
}
keys[0] = 1;
bytes += adsi_set_keys(buf + bytes, keys);
+ bytes += adsi_voice_mode(buf + bytes, 0);
+
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
}
bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
bytes += adsi_set_keys(buf + bytes, keys);
+ bytes += adsi_voice_mode(buf + bytes, 0);
+
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
}
if (!adsi_available(chan))
return;
bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
+ bytes += adsi_voice_mode(buf + bytes, 0);
+
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
}
bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_LEFT, 0, " ", "");
bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Goodbye", "");
bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
+ bytes += adsi_voice_mode(buf + bytes, 0);
+
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
}
char newpassword[80] = "";
char newpassword2[80] = "";
char prefile[256]="";
+ char buf[256];
+ int bytes=0;
+
+ if (adsi_available(chan))
+ {
+ bytes += adsi_logo(buf + bytes);
+ bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 3, ADSI_JUST_CENT, 0, "Options Menu", "");
+ bytes += adsi_display(buf + bytes, ADSI_COMM_PAGE, 4, ADSI_JUST_CENT, 0, "Not Done", "");
+ bytes += adsi_set_line(buf + bytes, ADSI_COMM_PAGE, 1);
+ bytes += adsi_voice_mode(buf + bytes, 0);
+ adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
+ }
while((cmd >= 0) && (cmd != 't')) {
if (cmd)
retries = 0;
break;
case '0':
cmd = vm_options(chan, vmu, &vms, vmfmts);
+ if (useadsi)
+ adsi_status(chan, vms.newmessages, vms.oldmessages, vms.lastmsg);
break;
default: /* Nothing */
cmd = vm_instructions(chan, &vms);
;
; ringall - ring all available channels until one answers (default)
; roundrobin - take turns ringing each available interface
-; leastrecent - ring interface which least recently had a call
-; fewestcalls - ring interface which has had fewest completed calls
+; leastrecent - ring interface which was least recently called by this queue
+; fewestcalls - ring the one with fewest completed calls from this queue
; random - ring random interface
;
;strategy = ringall