Beispiel #1
0
static struct ast_json *channel_callerid(
	struct ast_channel_snapshot *old_snapshot,
	struct ast_channel_snapshot *new_snapshot,
	const struct timeval *tv)
{
	struct ast_json *json_channel;

	/* No NewCallerid event on first channel snapshot */
	if (!old_snapshot) {
		return NULL;
	}

	if (ast_channel_snapshot_caller_id_equal(old_snapshot, new_snapshot)) {
		return NULL;
	}

	json_channel = ast_channel_snapshot_to_json(new_snapshot, stasis_app_get_sanitizer());
	if (!json_channel) {
		return NULL;
	}

	return ast_json_pack("{s: s, s: o, s: i, s: s, s: o}",
		"type", "ChannelCallerId",
		"timestamp", ast_json_timeval(*tv, NULL),
		"caller_presentation", new_snapshot->caller->pres,
		"caller_presentation_txt", ast_describe_caller_presentation(
			new_snapshot->caller->pres),
		"channel", json_channel);
}
Beispiel #2
0
struct ast_json *ast_json_party_id(struct ast_party_id *party)
{
	RAII_VAR(struct ast_json *, json_party_id, NULL, ast_json_unref);
	int pres;

	/* Combined party presentation */
	pres = ast_party_id_presentation(party);
	json_party_id = ast_json_pack("{s: i, s: s}",
		"presentation", pres,
		"presentation_txt", ast_describe_caller_presentation(pres));
	if (!json_party_id) {
		return NULL;
	}

	/* Party number */
	if (party->number.valid && ast_json_object_set(json_party_id, "number", json_party_number(&party->number))) {
		return NULL;
	}

	/* Party name */
	if (party->name.valid && ast_json_object_set(json_party_id, "name", json_party_name(&party->name))) {
		return NULL;
	}

	/* Party subaddress */
	if (party->subaddress.valid && ast_json_object_set(json_party_id, "subaddress", json_party_subaddress(&party->subaddress))) {
		return NULL;
	}

	return ast_json_ref(json_party_id);
}
Beispiel #3
0
static struct ast_json *json_party_name(struct ast_party_name *name)
{
	if (!name->valid) {
		return NULL;
	}
	return ast_json_pack("{s: s, s: s, s: i, s: s}",
		"name", name->str,
		"character_set", ast_party_name_charset_describe(name->char_set),
		"presentation", name->presentation,
		"presentation_txt", ast_describe_caller_presentation(name->presentation));
}
Beispiel #4
0
static struct ast_json *json_party_number(struct ast_party_number *number)
{
	if (!number->valid) {
		return NULL;
	}
	return ast_json_pack("{s: s, s: i, s: i, s: s}",
		"number", number->str,
		"plan", number->plan,
		"presentation", number->presentation,
		"presentation_txt", ast_describe_caller_presentation(number->presentation));
}