コード例 #1
0
ファイル: manager_mwi.c プロジェクト: asterisk/asterisk
static void mwi_update_cb(void *data, struct stasis_subscription *sub,
				    struct stasis_message *message)
{
	struct ast_mwi_state *mwi_state;
	RAII_VAR(struct ast_str *, channel_event_string, NULL, ast_free);

	if (ast_mwi_state_type() != stasis_message_type(message)) {
		return;
	}

	mwi_state = stasis_message_data(message);
	if (!mwi_state) {
		return;
	}

	if (mwi_state->snapshot) {
		channel_event_string = ast_manager_build_channel_state_string(mwi_state->snapshot);
	}

	/*** DOCUMENTATION
		<managerEventInstance>
			<synopsis>Raised when the state of messages in a voicemail mailbox
			has changed or when a channel has finished interacting with a
			mailbox.</synopsis>
			<syntax>
				<channel_snapshot/>
				<parameter name="Mailbox">
					<para>The mailbox with the new message, specified as <literal>mailbox</literal>@<literal>context</literal></para>
				</parameter>
				<parameter name="Waiting">
					<para>Whether or not the mailbox has messages waiting for it.</para>
				</parameter>
				<parameter name="New">
					<para>The number of new messages.</para>
				</parameter>
				<parameter name="Old">
					<para>The number of old messages.</para>
				</parameter>
			</syntax>
			<description>
				<note><para>The Channel related parameters are only present if a
				channel was involved in the manipulation of a mailbox. If no
				channel is involved, the parameters are not included with the
				event.</para>
				</note>
			</description>
		</managerEventInstance>
	***/
	manager_event(EVENT_FLAG_CALL, "MessageWaiting",
			"%s"
			"Mailbox: %s\r\n"
			"Waiting: %d\r\n"
			"New: %d\r\n"
			"Old: %d\r\n",
			AS_OR(channel_event_string, ""),
			mwi_state->uniqueid,
			ast_app_has_voicemail(mwi_state->uniqueid, NULL),
			mwi_state->new_msgs,
			mwi_state->old_msgs);
}
コード例 #2
0
ファイル: app_disa.c プロジェクト: axiatp/asterisk
static void play_dialtone(struct ast_channel *chan, char *mailbox)
{
	const struct tone_zone_sound *ts = NULL;
	if(ast_app_has_voicemail(mailbox, NULL))
		ts = ast_get_indication_tone(chan->zone, "dialrecall");
	else
		ts = ast_get_indication_tone(chan->zone, "dial");
	if (ts)
		ast_playtones_start(chan, 0, ts->data, 0);
	else
		ast_tonepair_start(chan, 350, 440, 0, 0);
}
コード例 #3
0
ファイル: app_disa.c プロジェクト: piyawad/test1
static void play_dialtone(struct ast_channel *chan, char *mailbox)
{
	struct ast_tone_zone_sound *ts = NULL;

	if (ast_app_has_voicemail(mailbox, NULL)) {
		ts = ast_get_indication_tone(ast_channel_zone(chan), "dialrecall");
	} else {
		ts = ast_get_indication_tone(ast_channel_zone(chan), "dial");
	}

	if (ts) {
		ast_playtones_start(chan, 0, ts->data, 0);
		ts = ast_tone_zone_sound_unref(ts);
	} else {
		ast_tonepair_start(chan, 350, 440, 0, 0);
	}
}
コード例 #4
0
int ast_app_has_voicemail(const char *mailbox)
{
    DIR *dir;
    struct dirent *de;
    char fn[256];
    char tmp[256]="";
    char *mb, *cur;
    char *context;
    int ret;
    /* If no mailbox, return immediately */
    if (ast_strlen_zero(mailbox))
        return 0;
    if (strchr(mailbox, ',')) {
        strncpy(tmp, mailbox, sizeof(tmp) - 1);
        mb = tmp;
        ret = 0;
        while((cur = strsep(&mb, ","))) {
            if (!ast_strlen_zero(cur)) {
                if (ast_app_has_voicemail(cur))
                    return 1;
            }
        }
        return 0;
    }
    strncpy(tmp, mailbox, sizeof(tmp) - 1);
    context = strchr(tmp, '@');
    if (context) {
        *context = '\0';
        context++;
    } else
        context = "default";
    snprintf(fn, sizeof(fn), "%s/voicemail/%s/%s/INBOX", (char *)ast_config_AST_SPOOL_DIR, context, tmp);
    dir = opendir(fn);
    if (!dir)
        return 0;
    while ((de = readdir(dir))) {
        if (!strncasecmp(de->d_name, "msg", 3))
            break;
    }
    closedir(dir);
    if (de)
        return 1;
    return 0;
}