private void UpdateStatus()
{
int cur_active_calls = Call.live_call_count();
bool is_call_active = (Call.active_call != null);
bool devices_ready = cur_active_calls > 0;
bool is_call_answered = (from c in Call.calls where c.state == Call.CALL_STATE.Answered || (c.state == Call.CALL_STATE.Ringing && c.is_outgoing) select true).Count() > 0;
bool is_active_call_ringing = Call.active_call != null && Call.active_call.is_outgoing == false && Call.active_call.state == Call.CALL_STATE.Ringing;
bool actually_set_active_calls = active_calls != cur_active_calls;
bool actually_set_call_active = call_active != is_call_active;
bool actually_set_CanEnd = actually_set_call_active;
bool actually_set_DevicesReady = DevicesReady != devices_ready;
bool actually_set_active_call_ringing = active_call_ringing != is_active_call_ringing;
bool actually_set_call_answered = call_answered != is_call_answered;
if (actually_set_active_calls)
{
_active_calls = cur_active_calls;
}
if (actually_set_call_active)
{
_call_active = is_call_active;
}
if (actually_set_CanEnd)
{
_CanEnd = is_call_active;
}
if (actually_set_DevicesReady)
{
_DevicesReady = devices_ready;
}
if (actually_set_active_call_ringing)
{
_active_call_ringing = is_active_call_ringing;
}
if (actually_set_call_answered)
{
_call_answered = is_call_answered;
}
if (actually_set_active_calls && active_callsChanged != null)
{
active_callsChanged(this, cur_active_calls);
}
if (actually_set_call_active && call_activeChanged != null)
{
call_activeChanged(this, is_call_active);
}
if (actually_set_CanEnd && CanEndChanged != null)
{
CanEndChanged(this, CanEnd);
}
if (actually_set_DevicesReady && DevicesReadyChanged != null)
{
DevicesReadyChanged(this, devices_ready);
}
if (actually_set_active_call_ringing && active_call_ringingChanged != null)
{
active_call_ringingChanged(this, is_active_call_ringing);
}
if (actually_set_call_answered && call_answeredChanged != null)
{
call_answeredChanged(this, is_call_answered);
}
}