85a86 > char adv[80]; /* Dir of advertisements */ 87a89,90 > int announcetimeout; /* How often to announce their position */ > int advert_timeout; /* How often to play an advertisement */ 89a93,94 > time_t last_pos; /* When we last played position */ > time_t last_adv; /* When we last played an advertisement */ 103a109 > char adv[80]; /* Dir of advertisements */ 106a113 > int advert_timeout; /* How often to play an advertisement */ 122a130,168 > static int playback(struct ast_channel *chan, char *type, void *data) > { > int res = 0; > struct localuser *u; > char tmp[256]; > char *options; > int option_skip=0; > int option_noanswer = 0; > char *stringp; > if (strcmp(type, "pos")) { // if no match, play position > // Get a random file from advertisements > printf("else print == %s\n", type); > } > if (!data || !strlen((char *)data)) { > ast_log(LOG_WARNING, "Playback requires an argument (filename)\n"); > return -1; > } > strncpy(tmp, (char *)data, sizeof(tmp)-1); > stringp=tmp; > strsep(&stringp, "|"); > options = strsep(&stringp, "|"); > if (options && !strcasecmp(options, "skip")) > option_skip = 1; > if (options && !strcasecmp(options, "noanswer")) > option_noanswer = 1; > if (!res) { > ast_stopstream(chan); > res = ast_streamfile(chan, tmp, chan->language); > if (!res) > res = ast_waitstream(chan, ""); > else { > ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", chan->name, (char *)data); > res = 0; > } > ast_stopstream(chan); > } > return res; > } > 153a200 > strncpy(qe->adv, q->adv, sizeof(qe->adv)); 154a202,203 > qe->announcetimeout = q->announcetimeout; > qe->advert_timeout = q->advert_timeout; 393a443 > time_t now; 398a449,457 > time(&now); > if ( (qe->announcetimeout > 0) && ((now - qe->last_pos) >= qe->announcetimeout) ) { > qe->last_pos = now; > ast_moh_stop(qe->chan); > playback(qe->chan, "pos", "Youare1"); > ast_say_number(qe->chan, qe->pos, AST_DIGIT_ANY, qe->chan->language); > ast_moh_start(qe->chan, qe->moh); > } > 648c707 < --- > time_t now; 651a711 > 684a745,746 > qe.last_pos = qe.start; > qe.last_adv = qe.start; 689a752,754 > qe.start = time(NULL); > qe.last_pos = qe.start; > qe.last_adv = qe.start; 707a773,781 > time(&now); > if ( (qe.announcetimeout > 0) && ((now - qe.last_pos) >= qe.announcetimeout) ) { > qe.last_pos = now; > ast_log(LOG_WARNING, "timeout, play message?\n"); > ast_moh_stop(chan); > playback(chan, "pos", "Youare1"); > ast_say_number(chan, 1, AST_DIGIT_ANY, chan->language); > ast_moh_start(chan, qe.moh); > } 781a856,858 > q->announcetimeout = 0; > q->advert_timeout = 0; > q->retry = 0; 785a863 > strcpy(q->adv, ""); 811a890,891 > } else if (!strcasecmp(var->name, "advert_dir")) { > strncpy(q->adv, var->value, sizeof(q->adv) - 1); 817a898,901 > } else if (!strcasecmp(var->name, "announcetimeout")) { > q->announcetimeout = atoi(var->value); > } else if (!strcasecmp(var->name, "advert_timeout")) { > q->advert_timeout = atoi(var->value); 965a1050,1051 > >