diff options
author | Damien Wedhorn <voip@facts.com.au> | 2012-06-07 21:44:15 +0000 |
---|---|---|
committer | Damien Wedhorn <voip@facts.com.au> | 2012-06-07 21:44:15 +0000 |
commit | d979399071f314f002f82556c7998a9e58c1ef3d (patch) | |
tree | 34989f96cc17d40ea466ba10a6037ab1e5dd28c4 /channels/chan_skinny.c | |
parent | 0271734f2e7864aefebfd1f1b11b0d1aa0ad9109 (diff) |
Skinny cleanup (mwi_event_cb).
Original was testing for d->session, setting and testing again (all nested).
Removed duplicate testing and restructured function to test/return and then
the main code.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368681 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_skinny.c')
-rw-r--r-- | channels/chan_skinny.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 5f5c61156..1c89674b9 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -3179,38 +3179,36 @@ static void mwi_event_cb(const struct ast_event *event, void *userdata) { struct skinny_line *l = userdata; struct skinny_device *d = l->device; - if (d && d->session) { - struct skinnysession *s = d->session; - struct skinny_line *l2; - int new_msgs = 0; - int dev_msgs = 0; - - if (s) { - if (event) { - l->newmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS); - } + struct skinny_line *l2; + int dev_msgs = 0; + + if (!d || !d->session) { + return; + } - if (l->newmsgs) { - transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, l->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON); - } else { - transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, SKINNY_LAMP_OFF); - } + if (event) { + l->newmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS); + } - /* find out wether the device lamp should be on or off */ - AST_LIST_TRAVERSE(&d->lines, l2, list) { - if (l2->newmsgs) { - dev_msgs++; - } - } + if (l->newmsgs) { + transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, l->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON); + } else { + transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, SKINNY_LAMP_OFF); + } - if (dev_msgs) { - transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, d->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON); - } else { - transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, SKINNY_LAMP_OFF); - } - ast_verb(3, "Skinny mwi_event_cb found %d new messages\n", new_msgs); + /* find out wether the device lamp should be on or off */ + AST_LIST_TRAVERSE(&d->lines, l2, list) { + if (l2->newmsgs) { + dev_msgs++; } } + + if (dev_msgs) { + transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, d->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON); + } else { + transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, SKINNY_LAMP_OFF); + } + ast_verb(3, "Skinny mwi_event_cb found %d new messages\n", l->newmsgs); } /* I do not believe skinny can deal with video. |