Reject phone busy calls before any incoming UI when policy is enabled
This commit is contained in:
1 parent
ce68b9a291
commit
dbd5db235b
3 files changed
+25
-9
No files matched your search
+14
-4
@@ -231,12 +231,15 @@ static void call_publish_phone_status(struct UTUN_INSTANCE* inst) {
|
||||
}
|
||||
}
|
||||
|
||||
void call_set_phone_state(struct UTUN_INSTANCE* inst, int state, int publish, int notify) {
|
||||
void call_set_phone_state(struct UTUN_INSTANCE* inst, int state, int publish, int notify, int reject) {
|
||||
if (!inst || state < 0 || state > 2) { DEBUG_ERROR(DEBUG_CATEGORY_CALL, "invalid phone state=%d", state); return; }
|
||||
if (inst->phone_state == state && inst->phone_status_hidden == !publish && inst->phone_notify_enabled == !!notify) return;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "phone state old=%u new=%d publish=%d notify=%d", inst->phone_state, state, !!publish, !!notify);
|
||||
if (inst->phone_state == state && inst->phone_status_hidden == !publish && inst->phone_notify_enabled == !!notify &&
|
||||
inst->phone_reject_enabled == !!reject) return;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "phone state old=%u new=%d publish=%d notify=%d reject=%d",
|
||||
inst->phone_state, state, !!publish, !!notify, !!reject);
|
||||
inst->phone_state = (uint8_t)state;
|
||||
inst->phone_status_hidden = !publish; inst->phone_notify_enabled = !!notify;
|
||||
inst->phone_reject_enabled = !!reject;
|
||||
call_publish_phone_status(inst);
|
||||
}
|
||||
|
||||
@@ -577,6 +580,9 @@ static void call_handle_invite(struct call_ctx* ctx, uint64_t from, uint64_t gro
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CALL, "call invite tuple/role mismatch id=%016llx", (unsigned long long)call_id); return;
|
||||
}
|
||||
if (s->state == CALL_ST_RINGING || s->state == CALL_ST_WAIT_DECISION) {
|
||||
if (s->state == CALL_ST_WAIT_DECISION && ctx->inst->phone_state == 2 && ctx->inst->phone_reject_enabled) {
|
||||
call_end(ctx, s, CALL_REASON_PHONE_BUSY, CALL_SUBCMD_DECLINE); return;
|
||||
}
|
||||
if (get_time_tb() - s->started_tb >= CALL_RING_TIMEOUT_TB) {
|
||||
call_end(ctx, s, CALL_REASON_RING_TIMEOUT, CALL_SUBCMD_CANCEL); return;
|
||||
}
|
||||
@@ -634,6 +640,10 @@ static void call_handle_invite(struct call_ctx* ctx, uint64_t from, uint64_t gro
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CALL, "%s: session alloc failed id=%016llx", CALL_ID, (unsigned long long)call_id);
|
||||
return;
|
||||
}
|
||||
if (ctx->inst->phone_state == 2 && ctx->inst->phone_reject_enabled) {
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "phone busy; incoming call rejected id=%016llx", (unsigned long long)call_id);
|
||||
call_end(ctx, s, CALL_REASON_PHONE_BUSY, CALL_SUBCMD_DECLINE); return;
|
||||
}
|
||||
s->state = ctx->inst->phone_notify_enabled && ctx->inst->phone_state == 2 ? CALL_ST_WAIT_DECISION : CALL_ST_RINGING;
|
||||
call_publish_phone_status(ctx->inst);
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "%s: INVITE id=%016llx from=0x%016llx group=0x%016llx (declared group=0x%016llx)",
|
||||
@@ -701,7 +711,7 @@ static void call_handle_decline(struct call_ctx* ctx, uint64_t from, const uint8
|
||||
if (!s || s->state == CALL_ST_ENDED) return;
|
||||
DEBUG_INFO(DEBUG_CATEGORY_CALL, "%s: DECLINE id=%016llx reason=%d", CALL_ID, (unsigned long long)call_id, reason);
|
||||
call_event_id(ctx, CHAT_EVT_CALL_DECLINED, call_id, reason);
|
||||
call_end(ctx, s, CALL_REASON_DECLINE, 0);
|
||||
call_end(ctx, s, reason == CALL_REASON_PHONE_BUSY ? CALL_REASON_PHONE_BUSY : CALL_REASON_DECLINE, 0);
|
||||
(void)from;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user