[asterisk-commits] oej: branch group/testframework r46457 - in /team/group/testframework: ./ bui...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Oct 30 10:23:49 MST 2006


Author: oej
Date: Mon Oct 30 11:23:48 2006
New Revision: 46457

URL: http://svn.digium.com/view/asterisk?rev=46457&view=rev
Log:
Reset automerge on this branch

Added:
    team/group/testframework/build_tools/embed_modules.xml
      - copied unchanged from r46436, trunk/build_tools/embed_modules.xml
    team/group/testframework/build_tools/get_makeopts
      - copied unchanged from r46436, trunk/build_tools/get_makeopts
    team/group/testframework/build_tools/get_moduleinfo
      - copied unchanged from r46436, trunk/build_tools/get_moduleinfo
    team/group/testframework/build_tools/make_buildopts_h
      - copied unchanged from r46436, trunk/build_tools/make_buildopts_h
    team/group/testframework/build_tools/prep_tarball
      - copied unchanged from r46436, trunk/build_tools/prep_tarball
    team/group/testframework/build_tools/strip_nonapi
      - copied unchanged from r46436, trunk/build_tools/strip_nonapi
    team/group/testframework/channels/chan_jingle.c
      - copied unchanged from r46436, trunk/channels/chan_jingle.c
    team/group/testframework/channels/chan_vpb.cc
      - copied unchanged from r46436, trunk/channels/chan_vpb.cc
    team/group/testframework/channels/h323/Makefile.in
      - copied unchanged from r46436, trunk/channels/h323/Makefile.in
    team/group/testframework/channels/h323/ast_h323.cxx
      - copied unchanged from r46436, trunk/channels/h323/ast_h323.cxx
    team/group/testframework/channels/h323/caps_h323.cxx
      - copied unchanged from r46436, trunk/channels/h323/caps_h323.cxx
    team/group/testframework/channels/h323/caps_h323.h
      - copied unchanged from r46436, trunk/channels/h323/caps_h323.h
    team/group/testframework/channels/h323/cisco-h225.asn
      - copied unchanged from r46436, trunk/channels/h323/cisco-h225.asn
    team/group/testframework/channels/h323/cisco-h225.cxx
      - copied unchanged from r46436, trunk/channels/h323/cisco-h225.cxx
    team/group/testframework/channels/h323/cisco-h225.h
      - copied unchanged from r46436, trunk/channels/h323/cisco-h225.h
    team/group/testframework/channels/h323/compat_h323.cxx
      - copied unchanged from r46436, trunk/channels/h323/compat_h323.cxx
    team/group/testframework/channels/h323/compat_h323.h
      - copied unchanged from r46436, trunk/channels/h323/compat_h323.h
    team/group/testframework/channels/h323/noexport.map
      - copied unchanged from r46436, trunk/channels/h323/noexport.map
    team/group/testframework/pbx/ael/ael-test/ael-ntest10/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-ntest10/
    team/group/testframework/pbx/ael/ael-test/ael-ntest10/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-ntest10/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-ntest12/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-ntest12/
    team/group/testframework/pbx/ael/ael-test/ael-ntest12/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-ntest12/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-ntest9/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-ntest9/
    team/group/testframework/pbx/ael/ael-test/ael-ntest9/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-ntest9/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-test11/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-test11/
    team/group/testframework/pbx/ael/ael-test/ael-test11/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-test11/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-test14/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-test14/
    team/group/testframework/pbx/ael/ael-test/ael-test14/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-test14/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-test15/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-test15/
    team/group/testframework/pbx/ael/ael-test/ael-test15/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-test15/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-test16/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-test16/
    team/group/testframework/pbx/ael/ael-test/ael-test16/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-test16/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-test3/telemarket_torture.ael2
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-test3/telemarket_torture.ael2
    team/group/testframework/pbx/ael/ael-test/ael-test8/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-test8/
    team/group/testframework/pbx/ael/ael-test/ael-test8/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-test8/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-vtest13/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-vtest13/
    team/group/testframework/pbx/ael/ael-test/ael-vtest13/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-vtest13/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-vtest13/include1.ael2
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-vtest13/include1.ael2
    team/group/testframework/pbx/ael/ael-test/ael-vtest13/include2.ael2
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-vtest13/include2.ael2
    team/group/testframework/pbx/ael/ael-test/ael-vtest13/include3.ael2
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-vtest13/include3.ael2
    team/group/testframework/pbx/ael/ael-test/ael-vtest13/include4.ael2
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-vtest13/include4.ael2
    team/group/testframework/pbx/ael/ael-test/ael-vtest13/include5.ael2
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-vtest13/include5.ael2
    team/group/testframework/pbx/ael/ael-test/ael-vtest13/telemarket_torture.ael2
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-vtest13/telemarket_torture.ael2
    team/group/testframework/pbx/ael/ael-test/ael-vtest17/
      - copied from r46436, trunk/pbx/ael/ael-test/ael-vtest17/
    team/group/testframework/pbx/ael/ael-test/ael-vtest17/extensions.ael
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ael-vtest17/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ref.ael-ntest10
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-ntest10
    team/group/testframework/pbx/ael/ael-test/ref.ael-ntest12
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-ntest12
    team/group/testframework/pbx/ael/ael-test/ref.ael-ntest9
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-ntest9
    team/group/testframework/pbx/ael/ael-test/ref.ael-test11
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-test11
    team/group/testframework/pbx/ael/ael-test/ref.ael-test14
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-test14
    team/group/testframework/pbx/ael/ael-test/ref.ael-test15
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-test15
    team/group/testframework/pbx/ael/ael-test/ref.ael-test16
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-test16
    team/group/testframework/pbx/ael/ael-test/ref.ael-test8
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-test8
    team/group/testframework/pbx/ael/ael-test/ref.ael-vtest13
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-vtest13
    team/group/testframework/pbx/ael/ael-test/ref.ael-vtest17
      - copied unchanged from r46436, trunk/pbx/ael/ael-test/ref.ael-vtest17
    team/group/testframework/pbx/kdeconsole_main.cc
      - copied unchanged from r46436, trunk/pbx/kdeconsole_main.cc
Removed:
    team/group/testframework/acl.c
    team/group/testframework/aescrypt.c
    team/group/testframework/aeskey.c
    team/group/testframework/aesopt.h
    team/group/testframework/aestab.c
    team/group/testframework/alaw.c
    team/group/testframework/app.c
    team/group/testframework/ast_expr2.c
    team/group/testframework/ast_expr2.fl
    team/group/testframework/ast_expr2.h
    team/group/testframework/ast_expr2.y
    team/group/testframework/ast_expr2f.c
    team/group/testframework/asterisk.8
    team/group/testframework/asterisk.c
    team/group/testframework/asterisk.sgml
    team/group/testframework/astmm.c
    team/group/testframework/autoservice.c
    team/group/testframework/buildinfo.c
    team/group/testframework/callerid.c
    team/group/testframework/cdr.c
    team/group/testframework/channel.c
    team/group/testframework/channels/chan_vpb.c
    team/group/testframework/channels/h323/Makefile
    team/group/testframework/channels/h323/ast_h323.cpp
    team/group/testframework/channels/h323/h323.conf.sample
    team/group/testframework/channels/misdn/fac.c
    team/group/testframework/channels/misdn/fac.h
    team/group/testframework/chanvars.c
    team/group/testframework/cli.c
    team/group/testframework/coef_in.h
    team/group/testframework/coef_out.h
    team/group/testframework/config.c
    team/group/testframework/cryptostub.c
    team/group/testframework/cygwin/
    team/group/testframework/db.c
    team/group/testframework/db1-ast/
    team/group/testframework/devicestate.c
    team/group/testframework/dlfcn.c
    team/group/testframework/dns.c
    team/group/testframework/dnsmgr.c
    team/group/testframework/dsp.c
    team/group/testframework/ecdisa.h
    team/group/testframework/editline/
    team/group/testframework/enum.c
    team/group/testframework/file.c
    team/group/testframework/frame.c
    team/group/testframework/fskmodem.c
    team/group/testframework/http.c
    team/group/testframework/image.c
    team/group/testframework/indications.c
    team/group/testframework/io.c
    team/group/testframework/jitterbuf.c
    team/group/testframework/jitterbuf.h
    team/group/testframework/loader.c
    team/group/testframework/logger.c
    team/group/testframework/manager.c
    team/group/testframework/md5.c
    team/group/testframework/muted.c
    team/group/testframework/mxml/
    team/group/testframework/netsock.c
    team/group/testframework/pbx.c
    team/group/testframework/pbx/pbx_kdeconsole_main.cc
    team/group/testframework/plc.c
    team/group/testframework/poll.c
    team/group/testframework/privacy.c
    team/group/testframework/rtp.c
    team/group/testframework/say.c
    team/group/testframework/sched.c
    team/group/testframework/sha1.c
    team/group/testframework/slinfactory.c
    team/group/testframework/sounds.txt
    team/group/testframework/srv.c
    team/group/testframework/stdtime/
    team/group/testframework/strcompat.c
    team/group/testframework/tdd.c
    team/group/testframework/term.c
    team/group/testframework/translate.c
    team/group/testframework/udptl.c
    team/group/testframework/ulaw.c
    team/group/testframework/utils.c
Modified:
    team/group/testframework/   (props changed)
    team/group/testframework/build_tools/mkpkgconfig
    team/group/testframework/channels/chan_agent.c
    team/group/testframework/channels/chan_alsa.c
    team/group/testframework/channels/chan_features.c
    team/group/testframework/channels/chan_h323.c
    team/group/testframework/channels/chan_local.c
    team/group/testframework/channels/chan_mgcp.c
    team/group/testframework/channels/chan_misdn.c
    team/group/testframework/channels/chan_nbs.c
    team/group/testframework/channels/chan_phone.c
    team/group/testframework/channels/chan_sip.c
    team/group/testframework/channels/chan_skinny.c
    team/group/testframework/channels/chan_zap.c
    team/group/testframework/channels/h323/   (props changed)
    team/group/testframework/channels/h323/README
    team/group/testframework/channels/h323/TODO
    team/group/testframework/channels/h323/ast_h323.h
    team/group/testframework/channels/h323/chan_h323.h
    team/group/testframework/channels/iax2-parser.h
    team/group/testframework/channels/iax2-provision.c
    team/group/testframework/channels/misdn/isdn_lib.c
    team/group/testframework/channels/misdn/isdn_msg_parser.c
    team/group/testframework/channels/misdn_config.c
    team/group/testframework/configure
    team/group/testframework/pbx/   (props changed)
    team/group/testframework/pbx/Makefile
    team/group/testframework/pbx/ael/ael-test/ael-test1/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-test3/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ael-test5/extensions.ael
    team/group/testframework/pbx/ael/ael-test/ref.ael-test1
    team/group/testframework/pbx/ael/ael-test/ref.ael-test2
    team/group/testframework/pbx/ael/ael-test/ref.ael-test3
    team/group/testframework/pbx/ael/ael-test/ref.ael-test4
    team/group/testframework/pbx/ael/ael-test/ref.ael-test5
    team/group/testframework/pbx/ael/ael-test/ref.ael-test6
    team/group/testframework/pbx/ael/ael-test/ref.ael-test7
    team/group/testframework/pbx/ael/ael-test/runtests
    team/group/testframework/pbx/ael/ael.flex
    team/group/testframework/pbx/ael/ael.tab.c
    team/group/testframework/pbx/ael/ael.tab.h
    team/group/testframework/pbx/ael/ael.y
    team/group/testframework/pbx/ael/ael_lex.c
    team/group/testframework/pbx/dundi-parser.c
    team/group/testframework/pbx/pbx_ael.c
    team/group/testframework/pbx/pbx_config.c
    team/group/testframework/pbx/pbx_dundi.c
    team/group/testframework/pbx/pbx_gtkconsole.c
    team/group/testframework/pbx/pbx_kdeconsole.cc
    team/group/testframework/pbx/pbx_loopback.c
    team/group/testframework/pbx/pbx_realtime.c
    team/group/testframework/pbx/pbx_spool.c

Propchange: team/group/testframework/
------------------------------------------------------------------------------
    automerge = http://edvina.net/training/

Modified: team/group/testframework/build_tools/mkpkgconfig
URL: http://svn.digium.com/view/asterisk/team/group/testframework/build_tools/mkpkgconfig?rev=46457&r1=46456&r2=46457&view=diff
==============================================================================
--- team/group/testframework/build_tools/mkpkgconfig (original)
+++ team/group/testframework/build_tools/mkpkgconfig Mon Oct 30 11:23:48 2006
@@ -13,13 +13,20 @@
   exit
 fi
 
+#Solaris (and some others) don't have sed -r.  perl -p is equivalent
+if [[ `echo "xxx" | sed -r 's/x/y/g' 2>/dev/null | grep -c "yyy"` != 0 ]]; then
+    EXTREGEX="sed -r -e"
+else
+    EXTREGEX="perl -pe"
+fi
+
 ## Clean out CFLAGS for the spec file.
 
-LOCAL_CFLAGS=`echo $CFLAGS | sed -e 's/\s*-pipe\s*//g' | sed -e 's/-[Wmp]\S*\s*//g' | \
-  sed -r -e 's/-I(include|\.\.\/include) //g' | \
-  sed -e 's/-DINSTALL_PREFIX=\S* //g' | \
-  sed -r -e 's/-DASTERISK_VERSION=\S* //g' | \
-  sed -r -e 's/-DAST(ETCDIR|LIBDIR|VARLIBDIR|VARRUNDIR|SPOOLDIR|LOGDIR|CONFPATH|MODDIR|AGIDIR)=\S* //g'`
+LOCAL_CFLAGS=`echo $CFLAGS | ${EXTREGEX} 's/\s*-pipe\s*//g' | ${EXTREGEX} 's/-[Wmp]\S*\s*//g' | \
+  ${EXTREGEX} 's/-I(include|\.\.\/include) //g' | \
+  ${EXTREGEX} 's/-DINSTALL_PREFIX=\S* //g' | \
+  ${EXTREGEX} 's/-DASTERISK_VERSION=\S* //g' | \
+  ${EXTREGEX} 's/-DAST(ETCDIR|LIBDIR|VARLIBDIR|VARRUNDIR|SPOOLDIR|LOGDIR|CONFPATH|MODDIR|AGIDIR)=\S* //g'`
 
 
 cat <<EOF > $PPATH/asterisk.pc

Modified: team/group/testframework/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/group/testframework/channels/chan_agent.c?rev=46457&r1=46456&r2=46457&view=diff
==============================================================================
--- team/group/testframework/channels/chan_agent.c (original)
+++ team/group/testframework/channels/chan_agent.c Mon Oct 30 11:23:48 2006
@@ -31,6 +31,10 @@
  * \ingroup channel_drivers
  */
 
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
@@ -42,10 +46,6 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <sys/signal.h>
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/lock.h"
 #include "asterisk/channel.h"
@@ -77,11 +77,9 @@
 static const char config[] = "agents.conf";
 
 static const char app[] = "AgentLogin";
-static const char app2[] = "AgentCallbackLogin";
 static const char app3[] = "AgentMonitorOutgoing";
 
 static const char synopsis[] = "Call agent login";
-static const char synopsis2[] = "Call agent callback login";
 static const char synopsis3[] = "Record agent's outgoing call";
 
 static const char descrip[] =
@@ -92,14 +90,6 @@
 "the star key.\n"
 "The option string may contain zero or more of the following characters:\n"
 "      's' -- silent login - do not announce the login ok segment after agent logged in/off\n";
-
-static const char descrip2[] =
-"  AgentCallbackLogin([AgentNo][|[options][|[exten]@context]]):\n"
-"Asks the agent to login to the system with callback.\n"
-"The agent's callback extension is called (optionally with the specified\n"
-"context).\n"
-"The option string may contain zero or more of the following characters:\n"
-"      's' -- silent login - do not announce the login ok segment agent logged in/off\n";
 
 static const char descrip3[] =
 "  AgentMonitorOutgoing([options]):\n"
@@ -140,16 +130,14 @@
 
 static char moh[80] = "default";
 
-#define AST_MAX_AGENT	80		/**< Agent ID or Password max length */
+#define AST_MAX_AGENT	80                          /*!< Agent ID or Password max length */
 #define AST_MAX_BUF	256
 #define AST_MAX_FILENAME_LEN	256
 
-/** Persistent Agents astdb family */
-static const char pa_family[] = "/Agents";
-/** The maximum length of each persistent member agent database entry */
-#define PA_MAX_LEN 2048
-/** queues.conf [general] option */
-static int persistent_agents = 0;
+static const char pa_family[] = "/Agents";          /*!< Persistent Agents astdb family */
+#define PA_MAX_LEN 2048                             /*!< The maximum length of each persistent member agent database entry */
+
+static int persistent_agents = 0;                   /*!< queues.conf [general] option */
 static void dump_agents(void);
 
 static ast_group_t group;
@@ -173,25 +161,23 @@
 
 #define GETAGENTBYCALLERID	"AGENTBYCALLERID"
 
-/**
- * Structure representing an agent.
- */
+/*! \brief Structure representing an agent.  */
 struct agent_pvt {
-	ast_mutex_t lock;              /**< Channel private lock */
-	int dead;                      /**< Poised for destruction? */
-	int pending;                   /**< Not a real agent -- just pending a match */
-	int abouttograb;               /**< About to grab */
-	int autologoff;                /**< Auto timeout time */
-	int ackcall;                   /**< ackcall */
-	time_t loginstart;             /**< When agent first logged in (0 when logged off) */
-	time_t start;                  /**< When call started */
-	struct timeval lastdisc;       /**< When last disconnected */
-	int wrapuptime;                /**< Wrapup time in ms */
-	ast_group_t group;             /**< Group memberships */
-	int acknowledged;              /**< Acknowledged */
-	char moh[80];                  /**< Which music on hold */
-	char agent[AST_MAX_AGENT];     /**< Agent ID */
-	char password[AST_MAX_AGENT];  /**< Password for Agent login */
+	ast_mutex_t lock;              /*!< Channel private lock */
+	int dead;                      /*!< Poised for destruction? */
+	int pending;                   /*!< Not a real agent -- just pending a match */
+	int abouttograb;               /*!< About to grab */
+	int autologoff;                /*!< Auto timeout time */
+	int ackcall;                   /*!< ackcall */
+	time_t loginstart;             /*!< When agent first logged in (0 when logged off) */
+	time_t start;                  /*!< When call started */
+	struct timeval lastdisc;       /*!< When last disconnected */
+	int wrapuptime;                /*!< Wrapup time in ms */
+	ast_group_t group;             /*!< Group memberships */
+	int acknowledged;              /*!< Acknowledged */
+	char moh[80];                  /*!< Which music on hold */
+	char agent[AST_MAX_AGENT];     /*!< Agent ID */
+	char password[AST_MAX_AGENT];  /*!< Password for Agent login */
 	char name[AST_MAX_AGENT];
 	ast_mutex_t app_lock;          /**< Synchronization between owning applications */
 	volatile pthread_t owning_app; /**< Owning application thread id */
@@ -203,15 +189,17 @@
 	AST_LIST_ENTRY(agent_pvt) list;	/**< Next Agent in the linked list. */
 };
 
-static AST_LIST_HEAD_STATIC(agents, agent_pvt);	/**< Holds the list of agents (loaded form agents.conf). */
+static AST_LIST_HEAD_STATIC(agents, agent_pvt);	/*!< Holds the list of agents (loaded form agents.conf). */
 
 #define CHECK_FORMATS(ast, p) do { \
 	if (p->chan) {\
 		if (ast->nativeformats != p->chan->nativeformats) { \
-			ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
+			if (option_debug) \
+				ast_log(LOG_DEBUG, "Native formats changing from %d to %d\n", ast->nativeformats, p->chan->nativeformats); \
 			/* Native formats changed, reset things */ \
 			ast->nativeformats = p->chan->nativeformats; \
-			ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
+			if (option_debug) \
+				ast_log(LOG_DEBUG, "Resetting read to %d and write to %d\n", ast->readformat, ast->writeformat);\
 			ast_set_read_format(ast, ast->readformat); \
 			ast_set_write_format(ast, ast->writeformat); \
 		} \
@@ -222,7 +210,7 @@
 	} \
 } while(0)
 
-/* Cleanup moves all the relevant FD's from the 2nd to the first, but retains things
+/*! \brief Cleanup moves all the relevant FD's from the 2nd to the first, but retains things
    properly for a timingfd XXX This might need more work if agents were logged in as agents or other
    totally impractical combinations XXX */
 
@@ -237,10 +225,12 @@
 	} \
 } while(0)
 
+/*--- Forward declarations */
 static struct ast_channel *agent_request(const char *type, int format, void *data, int *cause);
 static int agent_devicestate(void *data);
 static void agent_logoff_maintenance(struct agent_pvt *p, char *loginchan, long logintime, const char *uniqueid, char *logcommand);
-static int agent_digit(struct ast_channel *ast, char digit);
+static int agent_digit_begin(struct ast_channel *ast, char digit);
+static int agent_digit_end(struct ast_channel *ast, char digit);
 static int agent_call(struct ast_channel *ast, char *dest, int timeout);
 static int agent_hangup(struct ast_channel *ast);
 static int agent_answer(struct ast_channel *ast);
@@ -253,18 +243,21 @@
 static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge);
 static void set_agentbycallerid(const char *callerid, const char *agent);
 
+/*! \brief Channel interface description for PBX integration */
 static const struct ast_channel_tech agent_tech = {
 	.type = "Agent",
 	.description = tdesc,
 	.capabilities = -1,
 	.requester = agent_request,
 	.devicestate = agent_devicestate,
-	.send_digit = agent_digit,
+	.send_digit_begin = agent_digit_begin,
+	.send_digit_end = agent_digit_end,
 	.call = agent_call,
 	.hangup = agent_hangup,
 	.answer = agent_answer,
 	.read = agent_read,
 	.write = agent_write,
+	.write_video = agent_write,
 	.send_html = agent_sendhtml,
 	.send_text = agent_sendtext,
 	.exception = agent_read,
@@ -273,13 +266,13 @@
 	.bridged_channel = agent_bridgedchannel,
 };
 
-/**
+/*!
  * Adds an agent to the global list of agents.
  *
- * @param agent A string with the username, password and real name of an agent. As defined in agents.conf. Example: "13,169,John Smith"
- * @param pending If it is pending or not.
+ * \param agent A string with the username, password and real name of an agent. As defined in agents.conf. Example: "13,169,John Smith"
+ * \param pending If it is pending or not.
  * @return The just created agent.
- * @sa agent_pvt, agents.
+ * \sa agent_pvt, agents.
  */
 static struct agent_pvt *add_agent(char *agent, int pending)
 {
@@ -365,11 +358,11 @@
 	return p;
 }
 
-/**
+/*!
  * Deletes an agent after doing some clean up.
  * Further documentation: How safe is this function ? What state should the agent be to be cleaned.
- * @param p Agent to be deleted.
- * @returns Always 0.
+ * \param p Agent to be deleted.
+ * \returns Always 0.
  */
 static int agent_cleanup(struct agent_pvt *p)
 {
@@ -451,7 +444,7 @@
 			/* Note that we don't hangup if it's not a callback because Asterisk will do it
 			   for us when the PBX instance that called login finishes */
 			if (!ast_strlen_zero(p->loginchan)) {
-				if (p->chan)
+				if (p->chan && option_debug)
 					ast_log(LOG_DEBUG, "Bridge on '%s' being cleared (2)\n", p->chan->name);
 
 				status = pbx_builtin_getvar_helper(p->chan, "CHANLOCALSTATUS");
@@ -491,7 +484,8 @@
  				}
  			}
  			break;
- 		case AST_FRAME_DTMF:
+		case AST_FRAME_DTMF_BEGIN:
+ 		case AST_FRAME_DTMF_END:
  			if (!p->acknowledged && (f->subclass == '#')) {
  				if (option_verbose > 2)
  					ast_verbose(VERBOSE_PREFIX_3 "%s acknowledged\n", p->chan->name);
@@ -505,12 +499,15 @@
  			}
  			break;
  		case AST_FRAME_VOICE:
- 			/* don't pass voice until the call is acknowledged */
+ 		case AST_FRAME_VIDEO:
+ 			/* don't pass voice or video until the call is acknowledged */
  			if (!p->acknowledged) {
  				ast_frfree(f);
  				f = &ast_null_frame;
  			}
- 			break;
+		default:
+			/* pass everything else on through */
+			break;
   		}
   	}
 
@@ -518,7 +515,7 @@
 	if (p->chan && !p->chan->_bridge) {
 		if (strcasecmp(p->chan->tech->type, "Local")) {
 			p->chan->_bridge = ast;
-			if (p->chan)
+			if (p->chan && option_debug)
 				ast_log(LOG_DEBUG, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
 		}
 	}
@@ -556,16 +553,21 @@
 	int res = -1;
 	CHECK_FORMATS(ast, p);
 	ast_mutex_lock(&p->lock);
-	if (p->chan) {
+	if (!p->chan) 
+		res = 0;
+	else {
 		if ((f->frametype != AST_FRAME_VOICE) ||
+		    (f->frametype != AST_FRAME_VIDEO) ||
 		    (f->subclass == p->chan->writeformat)) {
 			res = ast_write(p->chan, f);
 		} else {
-			ast_log(LOG_DEBUG, "Dropping one incompatible voice frame on '%s' to '%s'\n", ast->name, p->chan->name);
+			if (option_debug)
+				ast_log(LOG_DEBUG, "Dropping one incompatible %s frame on '%s' to '%s'\n", 
+					f->frametype == AST_FRAME_VOICE ? "audio" : "video",
+					ast->name, p->chan->name);
 			res = 0;
 		}
-	} else
-		res = 0;
+	}
 	CLEANUP(ast, p);
 	ast_mutex_unlock(&p->lock);
 	return res;
@@ -591,22 +593,29 @@
 	int res = -1;
 	ast_mutex_lock(&p->lock);
 	if (p->chan)
-		res = ast_indicate(p->chan, condition);
+		res = ast_indicate_data(p->chan, condition, data, datalen);
 	else
 		res = 0;
 	ast_mutex_unlock(&p->lock);
 	return res;
 }
 
-static int agent_digit(struct ast_channel *ast, char digit)
+static int agent_digit_begin(struct ast_channel *ast, char digit)
 {
 	struct agent_pvt *p = ast->tech_pvt;
 	int res = -1;
 	ast_mutex_lock(&p->lock);
-	if (p->chan)
-		res = p->chan->tech->send_digit(p->chan, digit);
-	else
-		res = 0;
+	ast_senddigit_begin(p->chan, digit);
+	ast_mutex_unlock(&p->lock);
+	return res;
+}
+
+static int agent_digit_end(struct ast_channel *ast, char digit)
+{
+	struct agent_pvt *p = ast->tech_pvt;
+	int res = -1;
+	ast_mutex_lock(&p->lock);
+	ast_senddigit_end(p->chan, digit);
 	ast_mutex_unlock(&p->lock);
 	return res;
 }
@@ -620,7 +629,8 @@
 	p->acknowledged = 0;
 	if (!p->chan) {
 		if (p->pending) {
-			ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
+			if (option_debug)
+				ast_log(LOG_DEBUG, "Pretending to dial on pending agent\n");
 			newstate = AST_STATE_DIALING;
 			res = 0;
 		} else {
@@ -636,12 +646,8 @@
 		/* Call on this agent */
 		if (option_verbose > 2)
 			ast_verbose(VERBOSE_PREFIX_3 "outgoing agentcall, to agent '%s', on '%s'\n", p->agent, p->chan->name);
-		if (p->chan->cid.cid_num)
-			free(p->chan->cid.cid_num);
-		p->chan->cid.cid_num = ast_strdup(ast->cid.cid_num);
-		if (p->chan->cid.cid_name)
-			free(p->chan->cid.cid_name);
-		p->chan->cid.cid_name = ast_strdup(ast->cid.cid_name);
+		ast_set_callerid(p->chan,
+			ast->cid.cid_num, ast->cid.cid_name, NULL);
 		ast_channel_inherit_variables(ast, p->chan);
 		res = ast_call(p->chan, p->loginchan, 0);
 		CLEANUP(ast,p);
@@ -649,16 +655,20 @@
 		return res;
 	}
 	ast_verbose( VERBOSE_PREFIX_3 "agent_call, call to agent '%s' call on '%s'\n", p->agent, p->chan->name);
-	ast_log( LOG_DEBUG, "Playing beep, lang '%s'\n", p->chan->language);
+	if (option_debug > 2)
+		ast_log(LOG_DEBUG, "Playing beep, lang '%s'\n", p->chan->language);
 	res = ast_streamfile(p->chan, beep, p->chan->language);
-	ast_log( LOG_DEBUG, "Played beep, result '%d'\n", res);
+	if (option_debug > 2)
+		ast_log(LOG_DEBUG, "Played beep, result '%d'\n", res);
 	if (!res) {
 		res = ast_waitstream(p->chan, "");
-		ast_log( LOG_DEBUG, "Waited for stream, result '%d'\n", res);
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Waited for stream, result '%d'\n", res);
 	}
 	if (!res) {
 		res = ast_set_read_format(p->chan, ast_best_codec(p->chan->nativeformats));
-		ast_log( LOG_DEBUG, "Set read format, result '%d'\n", res);
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Set read format, result '%d'\n", res);
 		if (res)
 			ast_log(LOG_WARNING, "Unable to set read format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
 	} else {
@@ -667,32 +677,32 @@
 	}
 
 	if (!res) {
-		ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
-		ast_log( LOG_DEBUG, "Set write format, result '%d'\n", res);
+		res = ast_set_write_format(p->chan, ast_best_codec(p->chan->nativeformats));
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Set write format, result '%d'\n", res);
 		if (res)
 			ast_log(LOG_WARNING, "Unable to set write format to %s\n", ast_getformatname(ast_best_codec(p->chan->nativeformats)));
 	}
-	if( !res )
-	{
+	if(!res) {
 		/* Call is immediately up, or might need ack */
 		if (p->ackcall > 1)
 			newstate = AST_STATE_RINGING;
 		else {
 			newstate = AST_STATE_UP;
 			if (recordagentcalls)
-				agent_start_monitoring(ast,0);
+				agent_start_monitoring(ast, 0);
 			p->acknowledged = 1;
 		}
 		res = 0;
 	}
-	CLEANUP(ast,p);
+	CLEANUP(ast, p);
 	ast_mutex_unlock(&p->lock);
 	if (newstate)
 		ast_setstate(ast, newstate);
 	return res;
 }
 
-/* store/clear the global variable that stores agentid based on the callerid */
+/*! \brief store/clear the global variable that stores agentid based on the callerid */
 static void set_agentbycallerid(const char *callerid, const char *agent)
 {
 	char buf[AST_MAX_BUF];
@@ -701,7 +711,7 @@
 	if (ast_strlen_zero(callerid))
 		return;
 
-	snprintf(buf, sizeof(buf), "%s_%s",GETAGENTBYCALLERID, callerid);
+	snprintf(buf, sizeof(buf), "%s_%s", GETAGENTBYCALLERID, callerid);
 	pbx_builtin_setvar_helper(NULL, buf, agent);
 }
 
@@ -723,16 +733,14 @@
 	 * as in apps/app_chanisavail.c:chanavail_exec()
 	 */
 
-	ast_atomic_fetchadd_int(&__mod_desc->usecnt, -1);
-	/* XXX do we need ast_update_use_count(); */
-
-	ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));
 	if (p->start && (ast->_state != AST_STATE_UP)) {
 		howlong = time(NULL) - p->start;
 		p->start = 0;
-	} else if (ast->_state == AST_STATE_RESERVED) {
+	} else if (ast->_state == AST_STATE_RESERVED) 
 		howlong = 0;
-	} else
+	else
 		p->start = 0; 
 	if (p->chan) {
 		p->chan->_bridge = NULL;
@@ -755,7 +763,8 @@
 				ast_hangup(p->chan);
 				p->chan = NULL;
 			}
-			ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
+			if (option_debug)
+				ast_log(LOG_DEBUG, "Hungup, howlong is %d, autologoff is %d\n", howlong, p->autologoff);
 			if (howlong  && p->autologoff && (howlong > p->autologoff)) {
 				long logintime = time(NULL) - p->loginstart;
 				p->loginstart = 0;
@@ -763,17 +772,21 @@
 				agent_logoff_maintenance(p, p->loginchan, logintime, ast->uniqueid, "Autologoff");
 			}
 		} else if (p->dead) {
-			ast_mutex_lock(&p->chan->lock);
+			ast_channel_lock(p->chan);
 			ast_softhangup(p->chan, AST_SOFTHANGUP_EXPLICIT);
-			ast_mutex_unlock(&p->chan->lock);
-		} else {
-			ast_mutex_lock(&p->chan->lock);
-			ast_moh_start(p->chan, p->moh);
-			ast_mutex_unlock(&p->chan->lock);
+			ast_channel_unlock(p->chan);
+		} else if (p->loginstart) {
+			ast_channel_lock(p->chan);
+			ast_indicate_data(p->chan, AST_CONTROL_HOLD, 
+				S_OR(p->moh, NULL),
+				!ast_strlen_zero(p->moh) ? strlen(p->moh) + 1 : 0);
+			ast_channel_unlock(p->chan);
 		}
 	}
 	ast_mutex_unlock(&p->lock);
-	ast_device_state_changed("Agent/%s", p->agent);
+	/* Only register a device state change if the agent is still logged in */
+	if (p->loginstart)
+		ast_device_state_changed("Agent/%s", p->agent);
 
 	if (p->pending) {
 		AST_LIST_LOCK(&agents);
@@ -797,7 +810,8 @@
 			ast_mutex_unlock(&p->lock);
 		}
 		/* Release ownership of the agent to other threads (presumably running the login app). */
-		ast_mutex_unlock(&p->app_lock);
+		if (ast_strlen_zero(p->loginchan))
+			ast_mutex_unlock(&p->app_lock);
 	}
 	return 0;
 }
@@ -816,14 +830,14 @@
 			res = 1;
 	}
 	ast_mutex_unlock(&p->lock);
-#if 0
-	if( !res )
-		ast_log( LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
-#endif		
+
+	if (option_debug > 4 && !res)
+		ast_log(LOG_DEBUG, "agent_cont_sleep() returning %d\n", res );
+
 	return res;
 }
 
-static int agent_ack_sleep( void *data )
+static int agent_ack_sleep(void *data)
 {
 	struct agent_pvt *p;
 	int res=0;
@@ -832,50 +846,42 @@
 
 	/* Wait a second and look for something */
 
-	p = (struct agent_pvt *)data;
-	if (p->chan) {
-		for(;;) {
-			to = ast_waitfor(p->chan, to);
-			if (to < 0) {
-				res = -1;
-				break;
-			}
-			if (!to) {
-				res = 0;
-				break;
-			}
-			f = ast_read(p->chan);
-			if (!f) {
-				res = -1;
-				break;
-			}
-			if (f->frametype == AST_FRAME_DTMF)
-				res = f->subclass;
-			else
-				res = 0;
-			ast_frfree(f);
-			ast_mutex_lock(&p->lock);
-			if (!p->app_sleep_cond) {
-				ast_mutex_unlock(&p->lock);
-				res = 0;
-				break;
-			} else if (res == '#') {
-				ast_mutex_unlock(&p->lock);
-				res = 1;
-				break;
-			}
+	p = (struct agent_pvt *) data;
+	if (!p->chan) 
+		return -1;
+
+	for(;;) {
+		to = ast_waitfor(p->chan, to);
+		if (to < 0) 
+			return -1;
+		if (!to) 
+			return 0;
+		f = ast_read(p->chan);
+		if (!f) 
+			return -1;
+		if (f->frametype == AST_FRAME_DTMF)
+			res = f->subclass;
+		else
+			res = 0;
+		ast_frfree(f);
+		ast_mutex_lock(&p->lock);
+		if (!p->app_sleep_cond) {
 			ast_mutex_unlock(&p->lock);
-			res = 0;
-		}
-	} else
-		res = -1;
+			return 0;
+		} else if (res == '#') {
+			ast_mutex_unlock(&p->lock);
+			return 1;
+		}
+		ast_mutex_unlock(&p->lock);
+		res = 0;
+	}
 	return res;
 }
 
 static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge)
 {
 	struct agent_pvt *p = bridge->tech_pvt;
-	struct ast_channel *ret=NULL;
+	struct ast_channel *ret = NULL;
 
 	if (p) {
 		if (chan == p->chan)
@@ -889,7 +895,7 @@
 	return ret;
 }
 
-/*! \brief Create new agent channel ---*/
+/*! \brief Create new agent channel */
 static struct ast_channel *agent_new(struct agent_pvt *p, int state)
 {
 	struct ast_channel *tmp;
@@ -900,89 +906,108 @@
 	}
 #endif	
 	tmp = ast_channel_alloc(0);
-	if (tmp) {
-		tmp->tech = &agent_tech;
+	if (!tmp) {
+		ast_log(LOG_WARNING, "Unable to allocate agent channel structure\n");
+		return NULL;
+	}
+
+	tmp->tech = &agent_tech;
+	if (p->chan) {
+		tmp->nativeformats = p->chan->nativeformats;
+		tmp->writeformat = p->chan->writeformat;
+		tmp->rawwriteformat = p->chan->writeformat;
+		tmp->readformat = p->chan->readformat;
+		tmp->rawreadformat = p->chan->readformat;
+		ast_string_field_set(tmp, language, p->chan->language);
+		ast_copy_string(tmp->context, p->chan->context, sizeof(tmp->context));
+		ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten));
+		/* XXX Is this really all we copy form the originating channel?? */
+	} else {
+		tmp->nativeformats = AST_FORMAT_SLINEAR;
+		tmp->writeformat = AST_FORMAT_SLINEAR;
+		tmp->rawwriteformat = AST_FORMAT_SLINEAR;
+		tmp->readformat = AST_FORMAT_SLINEAR;
+		tmp->rawreadformat = AST_FORMAT_SLINEAR;
+	}
+	if (p->pending)
+		ast_string_field_build(tmp, name, "Agent/P%s-%d", p->agent, ast_random() & 0xffff);
+	else
+		ast_string_field_build(tmp, name, "Agent/%s", p->agent);
+	/* Safe, agentlock already held */
+	ast_setstate(tmp, state);
+	tmp->tech_pvt = p;
+	p->owner = tmp;
+	/* XXX: this needs fixing */
+#if 0
+	ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
+#endif
+	ast_update_use_count();
+	tmp->priority = 1;
+	/* Wake up and wait for other applications (by definition the login app)
+	 * to release this channel). Takes ownership of the agent channel
+	 * to this thread only.
+	 * For signalling the other thread, ast_queue_frame is used until we
+	 * can safely use signals for this purpose. The pselect() needs to be
+	 * implemented in the kernel for this.
+	 */
+	p->app_sleep_cond = 0;
+	if(ast_strlen_zero(p->loginchan) && ast_mutex_trylock(&p->app_lock)) {
 		if (p->chan) {
-			tmp->nativeformats = p->chan->nativeformats;
-			tmp->writeformat = p->chan->writeformat;
-			tmp->rawwriteformat = p->chan->writeformat;
-			tmp->readformat = p->chan->readformat;
-			tmp->rawreadformat = p->chan->readformat;
-			ast_string_field_set(tmp, language, p->chan->language);
-			ast_copy_string(tmp->context, p->chan->context, sizeof(tmp->context));
-			ast_copy_string(tmp->exten, p->chan->exten, sizeof(tmp->exten));
+			ast_queue_frame(p->chan, &ast_null_frame);
+			ast_mutex_unlock(&p->lock);	/* For other thread to read the condition. */
+			ast_mutex_lock(&p->app_lock);
+			ast_mutex_lock(&p->lock);
 		} else {
-			tmp->nativeformats = AST_FORMAT_SLINEAR;
-			tmp->writeformat = AST_FORMAT_SLINEAR;
-			tmp->rawwriteformat = AST_FORMAT_SLINEAR;
-			tmp->readformat = AST_FORMAT_SLINEAR;
-			tmp->rawreadformat = AST_FORMAT_SLINEAR;
-		}
-		if (p->pending)
-			ast_string_field_build(tmp, name, "Agent/P%s-%d", p->agent, ast_random() & 0xffff);
-		else
-			ast_string_field_build(tmp, name, "Agent/%s", p->agent);
-		/* Safe, agentlock already held */
-		ast_setstate(tmp, state);
-		tmp->tech_pvt = p;
-		p->owner = tmp;
-		ast_atomic_fetchadd_int(&__mod_desc->usecnt, +1);
-		ast_update_use_count();
-		tmp->priority = 1;
-		/* Wake up and wait for other applications (by definition the login app)
-		 * to release this channel). Takes ownership of the agent channel
-		 * to this thread only.
-		 * For signalling the other thread, ast_queue_frame is used until we
-		 * can safely use signals for this purpose. The pselect() needs to be
-		 * implemented in the kernel for this.
-		 */
-		p->app_sleep_cond = 0;
-		if( ast_mutex_trylock(&p->app_lock) )
-		{
-			if (p->chan) {
-				ast_queue_frame(p->chan, &ast_null_frame);
-				ast_mutex_unlock(&p->lock);	/* For other thread to read the condition. */
-				ast_mutex_lock(&p->app_lock);
-				ast_mutex_lock(&p->lock);
-			}
-			if( !p->chan )
-			{
-				ast_log(LOG_WARNING, "Agent disconnected while we were connecting the call\n");
-				p->owner = NULL;
-				tmp->tech_pvt = NULL;
-				p->app_sleep_cond = 1;
-				ast_channel_free( tmp );
-				ast_mutex_unlock(&p->lock);	/* For other thread to read the condition. */
-				ast_mutex_unlock(&p->app_lock);
-				return NULL;
-			}
-		}
-		p->owning_app = pthread_self();
-		/* After the above step, there should not be any blockers. */
-		if (p->chan) {
-			if (ast_test_flag(p->chan, AST_FLAG_BLOCKING)) {
-				ast_log( LOG_ERROR, "A blocker exists after agent channel ownership acquired\n" );
-				CRASH;
-			}
-			ast_moh_stop(p->chan);
-		}
-	} else

[... 106281 lines stripped ...]


More information about the asterisk-commits mailing list