Merged revisions 285373 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 7 Sep 2010 21:14:54 +0000 (21:14 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 7 Sep 2010 21:14:54 +0000 (21:14 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r285373 | tilghman | 2010-09-07 16:14:03 -0500 (Tue, 07 Sep 2010) | 7 lines

  Add CHANNEL(checkhangup) to check whether a channel is in the process of being hanged up.

  (closes issue #17652)
   Reported by: kobaz
   Patches:
         func_channel.patch uploaded by kobaz (license 834)
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@285374 65c4cc65-6c06-0410-ace0-fbb531ad65f3

funcs/func_channel.c

index 729bdf4..1416efc 100644 (file)
@@ -88,6 +88,9 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
                                        <enum name="channeltype">
                                                <para>R/O technology used for channel.</para>
                                        </enum>
+                                       <enum name="checkhangup">
+                                               <para>1/0 whether the channel is hanging up</para>
+                                       </enum>
                                        <enum name="language">
                                                <para>R/W language for sounds played.</para>
                                        </enum>
@@ -298,7 +301,11 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
                locked_copy_string(chan, buf, chan->tech->type, len);
        else if (!strcasecmp(data, "accountcode"))
                locked_copy_string(chan, buf, chan->accountcode, len);
-       else if (!strcasecmp(data, "peeraccount"))
+       else if (!strcasecmp(data, "checkhangup")) {
+               ast_channel_lock(chan);
+               ast_copy_string(buf, ast_check_hangup(chan) ? "1" : "0", len);
+               ast_channel_unlock(chan);
+       } else if (!strcasecmp(data, "peeraccount"))
                locked_copy_string(chan, buf, chan->peeraccount, len);
        else if (!strcasecmp(data, "hangupsource"))
                locked_copy_string(chan, buf, chan->hangupsource, len);