[svn-commits] mjordan: trunk r396060 - in /trunk: ./ apps/ channels/ include/asterisk/ main...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Aug 1 21:32:47 CDT 2013


Author: mjordan
Date: Thu Aug  1 21:32:44 2013
New Revision: 396060

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396060
Log:
Remove dead code from features.c; refactor pickup code into pickup.c

This patch does the following:
 * It moves the pickup code out of features.c and into pickup.c
 * It removes the vast majority of dead code out of features.c. In particular,
   this includes the parking code.

(issue ASTERISK-22134)


Added:
    trunk/include/asterisk/pickup.h   (with props)
    trunk/main/pickup.c   (with props)
Modified:
    trunk/CHANGES
    trunk/UPGRADE.txt
    trunk/apps/app_directed_pickup.c
    trunk/channels/chan_gtalk.c
    trunk/channels/chan_sip.c
    trunk/channels/chan_skinny.c
    trunk/channels/chan_unistim.c
    trunk/include/asterisk/_private.h
    trunk/include/asterisk/features.h
    trunk/include/asterisk/parking.h
    trunk/main/asterisk.c
    trunk/main/bridge.c
    trunk/main/cdr.c
    trunk/main/cel.c
    trunk/main/features.c
    trunk/main/pbx.c
    trunk/res/parking/parking_applications.c
    trunk/res/parking/parking_manager.c
    trunk/res/res_parking.c
    trunk/res/stasis/control.c
    trunk/tests/test_cdr.c
    trunk/tests/test_cel.c

Modified: trunk/CHANGES
URL: http://svnview.digium.com/svn/asterisk/trunk/CHANGES?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Aug  1 21:32:44 2013
@@ -310,6 +310,15 @@
  * The option 'allowmultiplelogin' can now be set or overriden in a particular
    account. When set in the general context, it will act as the default
    setting for defined accounts.
+
+ * The 'BridgeAction' event was removed. It technically added no value, as the
+   Bridge Action already receives confirmation of the bridge through a
+   successful completion Event.
+
+ * The 'BridgeExec' events were removed. These events duplicated the events that
+   occur in the Briding API, and are conveyed now through BridgeCreate,
+   BridgeEnter, and BridgeLeave events.
+
 
 AGI (Asterisk Gateway Interface)
 ------------------

Modified: trunk/UPGRADE.txt
URL: http://svnview.digium.com/svn/asterisk/trunk/UPGRADE.txt?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/UPGRADE.txt (original)
+++ trunk/UPGRADE.txt Thu Aug  1 21:32:44 2013
@@ -185,6 +185,10 @@
  - Executing a dynamic feature on the bridge peer in a multi-party bridge will
    execute it on all peers of the activating channel.
 
+ - There is no longer an explicit 'features reload' CLI command. Features can still be
+   reloaded using 'module reload features'.
+
+
 Parking:
  - The arguments for the Park, ParkedCall, and ParkAndAnnounce applications have
    been modified significantly. See the application documents for specific details.

Modified: trunk/apps/app_directed_pickup.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_directed_pickup.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/apps/app_directed_pickup.c (original)
+++ trunk/apps/app_directed_pickup.c Thu Aug  1 21:32:44 2013
@@ -43,7 +43,7 @@
 #include "asterisk/module.h"
 #include "asterisk/lock.h"
 #include "asterisk/app.h"
-#include "asterisk/features.h"
+#include "asterisk/pickup.h"
 #include "asterisk/manager.h"
 #include "asterisk/callerid.h"
 
@@ -305,7 +305,7 @@
 	return 0;
 }
 
-/* Find channel for pick up specified by partial channel name */ 
+/* Find channel for pick up specified by partial channel name */
 static int find_by_part(void *obj, void *arg, void *data, int flags)
 {
 	struct ast_channel *target = obj;/*!< Potential pickup target */
@@ -323,7 +323,7 @@
 	return 0;
 }
 
-/* Attempt to pick up specified by partial channel name */ 
+/* Attempt to pick up specified by partial channel name */
 static int pickup_by_part(struct ast_channel *chan, const char *part)
 {
 	struct ast_channel *target;/*!< Potential pickup target */

Modified: trunk/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_gtalk.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/channels/chan_gtalk.c (original)
+++ trunk/channels/chan_gtalk.c Thu Aug  1 21:32:44 2013
@@ -85,7 +85,7 @@
 #include "asterisk/abstract_jb.h"
 #include "asterisk/jabber.h"
 #include "asterisk/jingle.h"
-#include "asterisk/features.h"
+#include "asterisk/parking.h"
 #include "asterisk/stasis_channels.h"
 
 #define GOOGLE_CONFIG		"gtalk.conf"
@@ -2319,8 +2319,8 @@
  * Module loading including tests for configuration or dependencies.
  * This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE,
  * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails
- * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the 
- * configuration file or other non-critical problem return 
+ * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the
+ * configuration file or other non-critical problem return
  * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.
  */
 static int load_module(void)

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Thu Aug  1 21:32:44 2013
@@ -259,7 +259,8 @@
 #include "asterisk/cli.h"
 #include "asterisk/musiconhold.h"
 #include "asterisk/dsp.h"
-#include "asterisk/features.h"
+#include "asterisk/pickup.h"
+#include "asterisk/parking.h"
 #include "asterisk/srv.h"
 #include "asterisk/astdb.h"
 #include "asterisk/causes.h"

Modified: trunk/channels/chan_skinny.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_skinny.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/channels/chan_skinny.c (original)
+++ trunk/channels/chan_skinny.c Thu Aug  1 21:32:44 2013
@@ -68,7 +68,7 @@
 #include "asterisk/manager.h"
 #include "asterisk/say.h"
 #include "asterisk/astdb.h"
-#include "asterisk/features.h"
+#include "asterisk/pickup.h"
 #include "asterisk/app.h"
 #include "asterisk/musiconhold.h"
 #include "asterisk/utils.h"

Modified: trunk/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_unistim.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/channels/chan_unistim.c (original)
+++ trunk/channels/chan_unistim.c Thu Aug  1 21:32:44 2013
@@ -73,7 +73,7 @@
 #include "asterisk/musiconhold.h"
 #include "asterisk/causes.h"
 #include "asterisk/indications.h"
-#include "asterisk/features.h"
+#include "asterisk/pickup.h"
 #include "asterisk/astobj2.h"
 #include "asterisk/astdb.h"
 #include "asterisk/features_config.h"

Modified: trunk/include/asterisk/_private.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/_private.h?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/include/asterisk/_private.h (original)
+++ trunk/include/asterisk/_private.h Thu Aug  1 21:32:44 2013
@@ -8,7 +8,7 @@
  *
  * \brief
  * Prototypes for public functions only of internal interest,
- * 
+ *
  */
 
 
@@ -25,7 +25,7 @@
 void ast_channels_init(void);		/*!< Provided by channel.c */
 void ast_builtins_init(void);		/*!< Provided by cli.c */
 int ast_cli_perms_init(int reload);	/*!< Provided by cli.c */
-int dnsmgr_init(void);			/*!< Provided by dnsmgr.c */ 
+int dnsmgr_init(void);			/*!< Provided by dnsmgr.c */
 void dnsmgr_start_refresh(void);	/*!< Provided by dnsmgr.c */
 int dnsmgr_reload(void);		/*!< Provided by dnsmgr.c */
 void threadstorage_init(void);		/*!< Provided by threadstorage.c */
@@ -109,9 +109,9 @@
  */
 void ast_process_pending_reloads(void);
 
-/*! \brief Load XML documentation. Provided by xmldoc.c 
+/*! \brief Load XML documentation. Provided by xmldoc.c
  *  \retval 1 on error.
- *  \retval 0 on success. 
+ *  \retval 0 on success.
  */
 int ast_xmldoc_load_documentation(void);
 

Modified: trunk/include/asterisk/features.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/features.h?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/include/asterisk/features.h (original)
+++ trunk/include/asterisk/features.h Thu Aug  1 21:32:44 2013
@@ -27,30 +27,6 @@
 #include "asterisk/pbx.h"
 #include "asterisk/linkedlists.h"
 #include "asterisk/bridge.h"
-
-#define FEATURE_MAX_LEN		11
-#define FEATURE_APP_LEN		64
-#define FEATURE_APP_ARGS_LEN	256
-#define FEATURE_SNAME_LEN	32
-#define FEATURE_EXTEN_LEN	32
-#define FEATURE_MOH_LEN		80  /* same as MAX_MUSICCLASS from channel.h */
-
-#define DEFAULT_PARKINGLOT "default"	/*!< Default parking lot */
-
-#define AST_FEATURE_RETURN_HANGUP           -1
-#define AST_FEATURE_RETURN_SUCCESSBREAK     0
-#define AST_FEATURE_RETURN_PBX_KEEPALIVE    AST_PBX_KEEPALIVE
-#define AST_FEATURE_RETURN_NO_HANGUP_PEER   AST_PBX_NO_HANGUP_PEER
-#define AST_FEATURE_RETURN_PASSDIGITS       21
-#define AST_FEATURE_RETURN_STOREDIGITS      22
-#define AST_FEATURE_RETURN_SUCCESS          23
-#define AST_FEATURE_RETURN_KEEPTRYING       24
-#define AST_FEATURE_RETURN_PARKFAILED       25
-
-#define FEATURE_SENSE_CHAN	(1 << 0)
-#define FEATURE_SENSE_PEER	(1 << 1)
-
-typedef int (*ast_feature_operation)(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, const char *code, int sense, void *data);
 
 /*! \brief main call feature structure */
 
@@ -93,54 +69,7 @@
 int ast_bridge_add_channel(struct ast_bridge *bridge, struct ast_channel *chan,
 		struct ast_bridge_features *features, int play_tone, const char *xfersound);
 
-/*!
- * \brief Test if a channel can be picked up.
- *
- * \param chan Channel to test if can be picked up.
- *
- * \note This function assumes that chan is locked.
- *
- * \return TRUE if channel can be picked up.
- */
-int ast_can_pickup(struct ast_channel *chan);
 
-/*!
- * \brief Find a pickup channel target by group.
- *
- * \param chan channel that initiated pickup.
- *
- * \retval target on success.  The returned channel is locked and reffed.
- * \retval NULL on error.
- */
-struct ast_channel *ast_pickup_find_by_group(struct ast_channel *chan);
-
-/*! \brief Pickup a call */
-int ast_pickup_call(struct ast_channel *chan);
-
-/*!
- * \brief Pickup a call target.
- *
- * \param chan channel that initiated pickup.
- * \param target channel to be picked up.
- *
- * \note This function assumes that target is locked.
- *
- * \retval 0 on success.
- * \retval -1 on failure.
- */
-int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target);
-
-/*!
- * \brief accessor for call pickup message type
- * \since 12.0.0
- *
- * \retval pointer to the stasis message type
- * \retval NULL if not initialized
- */
-struct stasis_message_type *ast_call_pickup_type(void);
-
-/*! \brief Reload call features from features.conf */
-int ast_features_reload(void);
 
 /*!
  * \brief parse L option and read associated channel variables to set warning, warning frequency, and timelimit

Modified: trunk/include/asterisk/parking.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/parking.h?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/include/asterisk/parking.h (original)
+++ trunk/include/asterisk/parking.h Thu Aug  1 21:32:44 2013
@@ -29,6 +29,11 @@
  * \brief The default parking application that Asterisk expects.
  */
 #define PARK_APPLICATION "Park"
+
+/*!
+ * \brief The default parking lot
+ */
+#define DEFAULT_PARKINGLOT "default"
 
 /*!
  * \brief Defines the type of parked call message being published

Added: trunk/include/asterisk/pickup.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/pickup.h?view=auto&rev=396060
==============================================================================
--- trunk/include/asterisk/pickup.h (added)
+++ trunk/include/asterisk/pickup.h Thu Aug  1 21:32:44 2013
@@ -1,0 +1,91 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2013, Digium, Inc.
+ *
+ * Matt Jordan <mjordan at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief Call Pickup API
+ *
+ * Includes code and algorithms from the Zapata library.
+ *
+ */
+
+#ifndef _AST_FEATURES_H
+#define _AST_FEATURES_H
+
+/*!
+ * \brief Test if a channel can be picked up.
+ *
+ * \param chan Channel to test if can be picked up.
+ *
+ * \note This function assumes that chan is locked.
+ *
+ * \return TRUE if channel can be picked up.
+ */
+int ast_can_pickup(struct ast_channel *chan);
+
+/*!
+ * \brief Find a pickup channel target by group.
+ *
+ * \param chan channel that initiated pickup.
+ *
+ * \retval target on success.  The returned channel is locked and reffed.
+ * \retval NULL on error.
+ */
+struct ast_channel *ast_pickup_find_by_group(struct ast_channel *chan);
+
+/*!
+ * \brief Pickup a call
+ *
+ * \param chan The channel that initiated the pickup
+ *
+ * \retval 0 on success
+ * \retval -1 on failure
+ */
+int ast_pickup_call(struct ast_channel *chan);
+
+/*!
+ * \brief Pickup a call target.
+ *
+ * \param chan channel that initiated pickup.
+ * \param target channel to be picked up.
+ *
+ * \note This function assumes that target is locked.
+ *
+ * \retval 0 on success.
+ * \retval -1 on failure.
+ */
+int ast_do_pickup(struct ast_channel *chan, struct ast_channel *target);
+
+/*!
+ * \brief accessor for call pickup message type
+ * \since 12.0.0
+ *
+ * \retval pointer to the stasis message type
+ * \retval NULL if not initialized
+ */
+struct stasis_message_type *ast_call_pickup_type(void);
+
+/*!
+ * \brief Initialize pickup
+ *
+ * \retval 0 on success
+ * \retval non-zero on failure
+ */
+int ast_pickup_init(void);
+
+#endif /* _AST_FEATURES_H */

Propchange: trunk/include/asterisk/pickup.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: trunk/include/asterisk/pickup.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: trunk/include/asterisk/pickup.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Thu Aug  1 21:32:44 2013
@@ -202,6 +202,7 @@
 #include "asterisk/cli.h"
 #include "asterisk/channel.h"
 #include "asterisk/translate.h"
+#include "asterisk/pickup.h"
 #include "asterisk/features.h"
 #include "asterisk/acl.h"
 #include "asterisk/ulaw.h"
@@ -4298,6 +4299,11 @@
 		exit(1);
 	}
 
+	if (ast_pickup_init()) {
+		printf("%s", term_quit());
+		exit(1);
+	}
+
 	if (ast_bridging_init()) {
 		printf("%s", term_quit());
 		exit(1);

Modified: trunk/main/bridge.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/bridge.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/main/bridge.c (original)
+++ trunk/main/bridge.c Thu Aug  1 21:32:44 2013
@@ -40,6 +40,7 @@
 #include "asterisk/bridge.h"
 #include "asterisk/bridge_internal.h"
 #include "asterisk/bridge_channel_internal.h"
+#include "asterisk/bridge_features.h"
 #include "asterisk/bridge_basic.h"
 #include "asterisk/bridge_technology.h"
 #include "asterisk/bridge_channel.h"

Modified: trunk/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cdr.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Thu Aug  1 21:32:44 2013
@@ -916,17 +916,14 @@
 		return 0;
 	}
 
-	if (strcmp(new_snapshot->context, old_snapshot->context)
-		|| strcmp(new_snapshot->exten, old_snapshot->exten)
-		|| new_snapshot->priority != old_snapshot->priority) {
-		return 1;
-	}
-
 	/* When Party A is originated to an application and the application exits, the stack
 	 * will attempt to clear the application and restore the dummy originate application
 	 * of "AppDialX". Ignore application changes to AppDialX as a result.
 	 */
-	if (strcmp(new_snapshot->appl, old_snapshot->appl) && strncasecmp(new_snapshot->appl, "appdial", 7)) {
+	if (strcmp(new_snapshot->appl, old_snapshot->appl) && strncasecmp(new_snapshot->appl, "appdial", 7)
+		&& (strcmp(new_snapshot->context, old_snapshot->context)
+		|| strcmp(new_snapshot->exten, old_snapshot->exten)
+		|| new_snapshot->priority != old_snapshot->priority)) {
 		return 1;
 	}
 

Modified: trunk/main/cel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/cel.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/main/cel.c (original)
+++ trunk/main/cel.c Thu Aug  1 21:32:44 2013
@@ -61,7 +61,7 @@
 #include "asterisk/stasis_bridges.h"
 #include "asterisk/bridge.h"
 #include "asterisk/parking.h"
-#include "asterisk/features.h"
+#include "asterisk/pickup.h"
 #include "asterisk/core_local.h"
 
 /*** DOCUMENTATION

Modified: trunk/main/features.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/features.c?view=diff&rev=396060&r1=396059&r2=396060
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Thu Aug  1 21:32:44 2013
@@ -72,6 +72,7 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/test.h"
 #include "asterisk/bridge.h"
+#include "asterisk/bridge_features.h"
 #include "asterisk/bridge_basic.h"
 #include "asterisk/bridge_after.h"
 #include "asterisk/stasis.h"
@@ -282,25 +283,7 @@
 			<para>Bridge together two channels already in the PBX.</para>
 		</description>
 	</manager>
-	<managerEvent language="en_US" name="Pickup">
-		<managerEventInstance class="EVENT_FLAG_CALL">
-			<synopsis>Raised when a call pickup occurs.</synopsis>
-			<syntax>
-				<channel_snapshot/>
-				<channel_snapshot prefix="Target"/>
-			</syntax>
-		</managerEventInstance>
-	</managerEvent>
  ***/
-
-#define DEFAULT_PARK_TIME							45000	/*!< ms */
-#define DEFAULT_PARK_EXTENSION						"700"
-#define DEFAULT_COMEBACK_CONTEXT					"parkedcallstimeout"
-#define DEFAULT_COMEBACK_TO_ORIGIN					1
-#define DEFAULT_COMEBACK_DIAL_TIME					30
-
-#define AST_MAX_WATCHERS 256
-#define MAX_DIAL_FEATURE_OPTIONS 30
 
 /* TODO Scrape all of the parking stuff out of features.c */
 
@@ -310,286 +293,12 @@
 	FEATURE_INTERPRET_CHECK,  /* Used by feature_check */
 } feature_interpret_op;
 
-/*! Parking lot access ramp dialplan usage entry. */
-struct parking_dp_ramp {
-	/*! Next node in the parking lot spaces dialplan list. */
-	AST_LIST_ENTRY(parking_dp_ramp) node;
-	/*! TRUE if the parking lot access extension is exclusive. */
-	unsigned int exclusive:1;
-	/*! Parking lot access extension */
-	char exten[1];
-};
-
-/*! Parking lot dialplan access ramp map */
-AST_LIST_HEAD_NOLOCK(parking_dp_ramp_map, parking_dp_ramp);
-
-/*! Parking lot spaces dialplan usage entry. */
-struct parking_dp_spaces {
-	/*! Next node in the parking lot spaces dialplan list. */
-	AST_LIST_ENTRY(parking_dp_spaces) node;
-	/*! First parking space */
-	int start;
-	/*! Last parking space */
-	int stop;
-};
-
-/*! Parking lot dialplan context space map */
-AST_LIST_HEAD_NOLOCK(parking_dp_space_map, parking_dp_spaces);
-
-/*! Parking lot context dialplan usage entry. */
-struct parking_dp_context {
-	/*! Next node in the parking lot contexts dialplan list. */
-	AST_LIST_ENTRY(parking_dp_context) node;
-	/*! Parking access extensions defined in this context. */
-	struct parking_dp_ramp_map access_extens;
-	/*! Parking spaces defined in this context. */
-	struct parking_dp_space_map spaces;
-	/*! Parking hints defined in this context. */
-	struct parking_dp_space_map hints;
-	/*! Parking lot context name */
-	char context[1];
-};
-
-/*! Parking lot dialplan usage map. */
-AST_LIST_HEAD_NOLOCK(parking_dp_map, parking_dp_context);
-
-/*!
- * \brief Description of one parked call, added to a list while active, then removed.
- * The list belongs to a parkinglot.
- */
-struct parkeduser {
-	struct ast_channel *chan;                   /*!< Parked channel */
-	struct timeval start;                       /*!< Time the park started */
-	int parkingnum;                             /*!< Parking lot space used */
-	char parkingexten[AST_MAX_EXTENSION];       /*!< If set beforehand, parking extension used for this call */
-	char context[AST_MAX_CONTEXT];              /*!< Where to go if our parking time expires */
-	char exten[AST_MAX_EXTENSION];
-	int priority;
-	unsigned int parkingtime;                   /*!< Maximum length in parking lot before return */
-	/*! Method to entertain the caller when parked: AST_CONTROL_RINGING, AST_CONTROL_HOLD, or 0(none) */
-	enum ast_control_frame_type hold_method;
-	unsigned int notquiteyet:1;
-	unsigned int options_specified:1;
-	char peername[AST_CHANNEL_NAME];
-	unsigned char moh_trys;
-	/*! Parking lot this entry belongs to.  Holds a parking lot reference. */
-	struct ast_parkinglot *parkinglot;
-	AST_LIST_ENTRY(parkeduser) list;
-};
-
-/*! Parking lot configuration options. */
-struct parkinglot_cfg {
-	/*! Music class used for parking */
-	char mohclass[MAX_MUSICCLASS];
-	/*! Extension to park calls in this parking lot. */
-	char parkext[AST_MAX_EXTENSION];
-	/*! Context for which parking is made accessible */
-	char parking_con[AST_MAX_CONTEXT];
-	/*! Context that timed-out parked calls are called back on when comebacktoorigin=no */
-	char comebackcontext[AST_MAX_CONTEXT];
-	/*! First available extension for parking */
-	int parking_start;
-	/*! Last available extension for parking */
-	int parking_stop;
-	/*! Default parking time in ms. */
-	unsigned int parkingtime;
-	/*!
-	 * \brief Enable DTMF based transfers on bridge when picking up parked calls.
-	 *
-	 * \details
-	 * none(0)
-	 * AST_FEATURE_FLAG_BYCALLEE
-	 * AST_FEATURE_FLAG_BYCALLER
-	 * AST_FEATURE_FLAG_BYBOTH
-	 */
-	int parkedcalltransfers;
-	/*!
-	 * \brief Enable DTMF based parking on bridge when picking up parked calls.
-	 *
-	 * \details
-	 * none(0)
-	 * AST_FEATURE_FLAG_BYCALLEE
-	 * AST_FEATURE_FLAG_BYCALLER
-	 * AST_FEATURE_FLAG_BYBOTH
-	 */
-	int parkedcallreparking;
-	/*!
-	 * \brief Enable DTMF based hangup on a bridge when pickup up parked calls.
-	 *
-	 * \details
-	 * none(0)
-	 * AST_FEATURE_FLAG_BYCALLEE
-	 * AST_FEATURE_FLAG_BYCALLER
-	 * AST_FEATURE_FLAG_BYBOTH
-	 */
-	int parkedcallhangup;
-	/*!
-	 * \brief Enable DTMF based recording on a bridge when picking up parked calls.
-	 *
-	 * \details
-	 * none(0)
-	 * AST_FEATURE_FLAG_BYCALLEE
-	 * AST_FEATURE_FLAG_BYCALLER
-	 * AST_FEATURE_FLAG_BYBOTH
-	 */
-	int parkedcallrecording;
-
-	/*! Time in seconds to dial the device that parked a timedout parked call */
-	unsigned int comebackdialtime;
-	/*! TRUE if findslot is set to next */
-	unsigned int parkfindnext:1;
-	/*! TRUE if the parking lot is exclusively accessed by parkext */
-	unsigned int parkext_exclusive:1;
-	/*! Add parking hints automatically */
-	unsigned int parkaddhints:1;
-	/*! TRUE if configuration is invalid and the parking lot should not be used. */
-	unsigned int is_invalid:1;
-	/*! TRUE if a timed out parked call goes back to the parker */
-	unsigned int comebacktoorigin:1;
-};
-
-/*! \brief Structure for parking lots which are put in a container. */
-struct ast_parkinglot {
-	/*! Name of the parking lot. */
-	char name[AST_MAX_CONTEXT];
-	/*! Parking lot user configuration. */
-	struct parkinglot_cfg cfg;
-
-	/*! Parking space to start next park search. */
-	int next_parking_space;
-
-	/*! That which bears the_mark shall be deleted if parking lot empty! (Used during reloads.) */
-	unsigned int the_mark:1;
-	/*! TRUE if the parking lot is disabled. */
-	unsigned int disabled:1;
-
-	/*! List of active parkings in this parkinglot */
-	AST_LIST_HEAD(parkinglot_parklist, parkeduser) parkings;
-};
-
-/*! \brief The configured parking lots container. Always at least one  - the default parking lot */
-static struct ao2_container *parkinglots;
-
-/*! Force a config reload to reload regardless of config file timestamp. */
-#ifdef TEST_FRAMEWORK
-static int force_reload_load;
-#endif
-
-/*!
- * \brief Context for parking dialback to parker.
- * \note The need for the context is a KLUDGE.
- *
- * \todo Might be able to eliminate the parking_con_dial context
- * kludge by running app_dial directly in its own thread to
- * simulate a PBX.
- */
-static char parking_con_dial[] = "park-dial";
-
-/*! Ensure that features.conf reloads on one thread at a time. */
-AST_MUTEX_DEFINE_STATIC(features_reload_lock);
-
-static char *registrar = "features";		   /*!< Registrar for operations */
-
-/*! PARK_APP_NAME application arguments */
-AST_DEFINE_APP_ARGS_TYPE(park_app_args,
-	AST_APP_ARG(timeout);		/*!< Time in ms to remain in the parking lot. */
-	AST_APP_ARG(return_con);	/*!< Context to return parked call if timeout. */
-	AST_APP_ARG(return_ext);	/*!< Exten to return parked call if timeout. */
-	AST_APP_ARG(return_pri);	/*!< Priority to return parked call if timeout. */
-	AST_APP_ARG(options);		/*!< Parking option flags. */
-	AST_APP_ARG(pl_name);		/*!< Parking lot name to use if present. */
-	AST_APP_ARG(dummy);			/*!< Place to put any remaining args string. */
-	);
-
-static pthread_t parking_thread;
 struct ast_dial_features {
 	/*! Channel's feature flags. */
 	struct ast_flags my_features;
 	/*! Bridge peer's feature flags. */
 	struct ast_flags peer_features;
 };
-
-static struct ast_manager_event_blob *call_pickup_to_ami(struct stasis_message *message);
-
-STASIS_MESSAGE_TYPE_DEFN(
-	ast_call_pickup_type,
-	.to_ami = call_pickup_to_ami);
-
-
-#if defined(ATXFER_NULL_TECH)
-/*!
- * \internal
- * \brief Set the channel technology to the kill technology.
- *
- * \param chan Channel to change technology.
- *
- * \return Nothing
- */
-static void set_kill_chan_tech(struct ast_channel *chan)
-{
-	int idx;
-
-	ast_channel_lock(chan);
-
-	/* Hangup the channel's physical side */
-	if (ast_channel_tech(chan)->hangup) {
-		ast_channel_tech(chan)->hangup(chan);
-	}
-	if (ast_channel_tech_pvt(chan)) {
-		ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n",
-			ast_channel_name(chan));
-		ast_free(ast_channel_tech_pvt(chan));
-		ast_channel_tech_pvt_set(chan, NULL);
-	}
-
-	/* Install the kill technology and wake up anyone waiting on it. */
-	ast_channel_tech_set(chan, &ast_kill_tech);
-	for (idx = 0; idx < AST_MAX_FDS; ++idx) {
-		switch (idx) {
-		case AST_ALERT_FD:
-		case AST_TIMING_FD:
-		case AST_GENERATOR_FD:
-			/* Don't clear these fd's. */
-			break;
-		default:
-			ast_channel_set_fd(chan, idx, -1);
-			break;
-		}
-	}
-	ast_queue_frame(chan, &ast_null_frame);
-
-	ast_channel_unlock(chan);
-}
-#endif	/* defined(ATXFER_NULL_TECH) */
-
-#if defined(ATXFER_NULL_TECH)
-/*!
- * \internal
- * \brief Set the channel name to something unique.
- *
- * \param chan Channel to change name.
- *
- * \return Nothing
- */
-static void set_new_chan_name(struct ast_channel *chan)
-{
-	static int seq_num_last;
-	int seq_num;
-	int len;
-	char *chan_name;
-	char dummy[1];
-
-	/* Create the new channel name string. */
-	ast_channel_lock(chan);
-	seq_num = ast_atomic_fetchadd_int(&seq_num_last, +1);
-	len = snprintf(dummy, sizeof(dummy), "%s<XFER_%x>", ast_channel_name(chan), seq_num) + 1;
-	chan_name = ast_alloca(len);
-	snprintf(chan_name, len, "%s<XFER_%x>", ast_channel_name(chan), seq_num);
-	ast_channel_unlock(chan);
-
-	ast_change_name(chan, chan_name);
-}
-#endif	/* defined(ATXFER_NULL_TECH) */
 
 static void *dial_features_duplicate(void *data)
 {
@@ -655,9 +364,6 @@
 	return 0;
 }
 
-/* Forward declarations */
-static void parkinglot_unref(struct ast_parkinglot *parkinglot);
-
 struct ast_bridge_thread_obj
 {
 	struct ast_bridge_config bconfig;
@@ -667,98 +373,12 @@
 	unsigned int return_to_pbx:1;
 };
 
-static int parkinglot_hash_cb(const void *obj, const int flags)
-{
-	const struct ast_parkinglot *parkinglot = obj;
-
-	return ast_str_case_hash(parkinglot->name);
-}
-
-static int parkinglot_cmp_cb(void *obj, void *arg, int flags)
-{
-	struct ast_parkinglot *parkinglot = obj;
-	struct ast_parkinglot *parkinglot2 = arg;
-
-	return !strcasecmp(parkinglot->name, parkinglot2->name) ? CMP_MATCH | CMP_STOP : 0;
-}
-
-/*!
- * \brief store context, extension and priority
- * \param chan, context, ext, pri
- */
-static void set_c_e_p(struct ast_channel *chan, const char *context, const char *ext, int pri)
-{
-	ast_channel_context_set(chan, context);
-	ast_channel_exten_set(chan, ext);
-	ast_channel_priority_set(chan, pri);
-}
-
 static const struct ast_datastore_info channel_app_data_datastore = {
 	.type = "Channel appdata datastore",
 	.destroy = ast_free_ptr,
 };
 
-/*! \brief Notify metermaids that we've changed an extension */
-static void notify_metermaids(const char *exten, char *context, enum ast_device_state state)
-{
-	ast_debug(4, "Notification of state change to metermaids %s@%s\n to state '%s'",
-		exten, context, ast_devstate2str(state));
-
-	ast_devstate_changed(state, AST_DEVSTATE_CACHABLE, "park:%s@%s", exten, context);
-}
-
-/*! \brief metermaids callback from devicestate.c */
-static enum ast_device_state metermaidstate(const char *data)
-{
-	char *context;
-	char *exten;
-
-	context = ast_strdupa(data);
-
-	exten = strsep(&context, "@");
-	if (!context)
-		return AST_DEVICE_INVALID;
-
-	ast_debug(4, "Checking state of exten %s in context %s\n", exten, context);
-
-	if (!ast_exists_extension(NULL, context, exten, 1, NULL))
-		return AST_DEVICE_NOT_INUSE;
-
-	return AST_DEVICE_INUSE;
-}
-
-/*! Options to pass to park_call_full */
-enum ast_park_call_options {
-	/*! Provide ringing to the parked caller instead of music on hold */
-	AST_PARK_OPT_RINGING =   (1 << 0),
-	/*! Randomly choose a parking spot for the caller instead of choosing
-	 *  the first one that is available. */
-	AST_PARK_OPT_RANDOMIZE = (1 << 1),
-	/*! Do not announce the parking number */
-	AST_PARK_OPT_SILENCE = (1 << 2),
-};
-
-/*! Optional additional parking options when parking a call. */
-struct ast_park_call_args {
-	/*! How long to wait in the parking lot before the call gets sent back
-	 *  to the specified return extension (or a best guess at where it came
-	 *  from if not explicitly specified). */
-	int timeout;
-	/*! An output parameter to store the parking space where the parked caller
-	 *  was placed. */
-	int *extout;
-	const char *orig_chan_name;
-	const char *return_con;
-	const char *return_ext;
-	int return_pri;
-	uint32_t flags;
-	/*! Parked user that has already obtained a parking space */
-	struct parkeduser *pu;
-	/*! \brief Parkinglot to be parked in */
-	struct ast_parkinglot *parkinglot;
-};
-
-/*!
+/*
  * \internal
  * \brief Get the extension for a given builtin feature
  *
@@ -1462,472 +1082,6 @@
 	return res;
 }
 
-/*! \brief Output parking event to manager */
-static void post_manager_event(const char *s, struct parkeduser *pu)
-{
-	manager_event(EVENT_FLAG_CALL, s,
-		"Exten: %s\r\n"
-		"Channel: %s\r\n"
-		"Parkinglot: %s\r\n"
-		"CallerIDNum: %s\r\n"
-		"CallerIDName: %s\r\n"
-		"ConnectedLineNum: %s\r\n"
-		"ConnectedLineName: %s\r\n"
-		"UniqueID: %s\r\n",
-		pu->parkingexten,
-		ast_channel_name(pu->chan),
-		pu->parkinglot->name,
-		S_COR(ast_channel_caller(pu->chan)->id.number.valid, ast_channel_caller(pu->chan)->id.number.str, "<unknown>"),
-		S_COR(ast_channel_caller(pu->chan)->id.name.valid, ast_channel_caller(pu->chan)->id.name.str, "<unknown>"),
-		S_COR(ast_channel_connected(pu->chan)->id.number.valid, ast_channel_connected(pu->chan)->id.number.str, "<unknown>"),
-		S_COR(ast_channel_connected(pu->chan)->id.name.valid, ast_channel_connected(pu->chan)->id.name.str, "<unknown>"),
-		ast_channel_uniqueid(pu->chan)
-		);
-}
-
-static char *callback_dialoptions(struct ast_flags *features_callee, struct ast_flags *features_caller, char *options, size_t len)
-{
-	int i = 0;
-	enum {
-		OPT_CALLEE_REDIRECT   = 't',
-		OPT_CALLER_REDIRECT   = 'T',
-		OPT_CALLEE_AUTOMON    = 'w',
-		OPT_CALLER_AUTOMON    = 'W',
-		OPT_CALLEE_DISCONNECT = 'h',
-		OPT_CALLER_DISCONNECT = 'H',
-		OPT_CALLEE_PARKCALL   = 'k',
-		OPT_CALLER_PARKCALL   = 'K',
-	};
-
-	memset(options, 0, len);
-	if (ast_test_flag(features_caller, AST_FEATURE_REDIRECT) && i < len) {
-		options[i++] = OPT_CALLER_REDIRECT;
-	}
-	if (ast_test_flag(features_caller, AST_FEATURE_AUTOMON) && i < len) {
-		options[i++] = OPT_CALLER_AUTOMON;
-	}
-	if (ast_test_flag(features_caller, AST_FEATURE_DISCONNECT) && i < len) {
-		options[i++] = OPT_CALLER_DISCONNECT;
-	}
-	if (ast_test_flag(features_caller, AST_FEATURE_PARKCALL) && i < len) {
-		options[i++] = OPT_CALLER_PARKCALL;
-	}
-
-	if (ast_test_flag(features_callee, AST_FEATURE_REDIRECT) && i < len) {
-		options[i++] = OPT_CALLEE_REDIRECT;
-	}
-	if (ast_test_flag(features_callee, AST_FEATURE_AUTOMON) && i < len) {
-		options[i++] = OPT_CALLEE_AUTOMON;
-	}
-	if (ast_test_flag(features_callee, AST_FEATURE_DISCONNECT) && i < len) {
-		options[i++] = OPT_CALLEE_DISCONNECT;
-	}
-	if (ast_test_flag(features_callee, AST_FEATURE_PARKCALL) && i < len) {
-		options[i++] = OPT_CALLEE_PARKCALL;
-	}
-
-	return options;
-}
-
-/*!
- * \internal
- * \brief Run management on a parked call.
- *
- * \note The parkinglot parkings list is locked on entry.
- *
- * \retval TRUE if the parking completed.
- */
-static int manage_parked_call(struct parkeduser *pu, const struct pollfd *pfds, int nfds, struct pollfd **new_pfds, int *new_nfds, int *ms)
-{
-	struct ast_channel *chan = pu->chan;	/* shorthand */
-	int tms;        /* timeout for this item */
-	int x;          /* fd index in channel */
-
-	tms = ast_tvdiff_ms(ast_tvnow(), pu->start);
-	if (tms > pu->parkingtime) {
-		/*
-		 * Call has been parked too long.
-		 * Stop entertaining the caller.
-		 */
-		switch (pu->hold_method) {
-		case AST_CONTROL_HOLD:
-			ast_indicate(pu->chan, AST_CONTROL_UNHOLD);
-			break;
-		case AST_CONTROL_RINGING:
-			ast_indicate(pu->chan, -1);
-			break;
-		default:
-			break;
-		}
-		pu->hold_method = 0;
-
-		/* Get chan, exten from derived kludge */
-		if (pu->peername[0]) {
-			char *peername;
-			char *dash;
-			char *peername_flat; /* using something like DAHDI/52 for an extension name is NOT a good idea */
-			char parkingslot[AST_MAX_EXTENSION]; /* buffer for parkinglot slot number */
-			int i;
-
-			peername = ast_strdupa(pu->peername);
-			dash = strrchr(peername, '-');
-			if (dash) {
-				*dash = '\0';
-			}
-
-			peername_flat = ast_strdupa(peername);
-			for (i = 0; peername_flat[i]; i++) {
-				if (peername_flat[i] == '/') {
-					peername_flat[i] = '_';
-				}
-			}
-
-			if (!ast_context_find_or_create(NULL, NULL, parking_con_dial, registrar)) {
-				ast_log(LOG_ERROR,
-					"Parking dial context '%s' does not exist and unable to create\n",
-					parking_con_dial);
-			} else {
-				char returnexten[AST_MAX_EXTENSION];
-				char comebackdialtime[AST_MAX_EXTENSION];
-				struct ast_datastore *features_datastore;
-				struct ast_dial_features *dialfeatures;
-
-				if (!strncmp(peername, "Parked/", 7)) {
-					peername += 7;
-				}
-
-				ast_channel_lock(chan);
-				features_datastore = ast_channel_datastore_find(chan, &dial_features_info,
-					NULL);
-				if (features_datastore && (dialfeatures = features_datastore->data)) {
-					char buf[MAX_DIAL_FEATURE_OPTIONS] = {0,};
-
-					snprintf(returnexten, sizeof(returnexten), "%s,%u,%s", peername,
-						pu->parkinglot->cfg.comebackdialtime,
-						callback_dialoptions(&dialfeatures->peer_features,
-							&dialfeatures->my_features, buf, sizeof(buf)));
-				} else { /* Existing default */
-					ast_log(LOG_NOTICE, "Dial features not found on %s, using default!\n",
-						ast_channel_name(chan));
-					snprintf(returnexten, sizeof(returnexten), "%s,%u,t", peername,
-						pu->parkinglot->cfg.comebackdialtime);
-				}
-				ast_channel_unlock(chan);
-
-				snprintf(comebackdialtime, sizeof(comebackdialtime), "%u",
-						pu->parkinglot->cfg.comebackdialtime);
-				pbx_builtin_setvar_helper(chan, "COMEBACKDIALTIME", comebackdialtime);
-
-				pbx_builtin_setvar_helper(chan, "PARKER", peername);
-
-			}
-
-			snprintf(parkingslot, sizeof(parkingslot), "%d", pu->parkingnum);
-			pbx_builtin_setvar_helper(chan, "PARKINGSLOT", parkingslot);
-			pbx_builtin_setvar_helper(chan, "PARKEDLOT", pu->parkinglot->name);
-
-			if (pu->options_specified) {
-				/*
-				 * Park() was called with overriding return arguments, respect
-				 * those arguments.
-				 */
-				set_c_e_p(chan, pu->context, pu->exten, pu->priority);
-			} else if (pu->parkinglot->cfg.comebacktoorigin) {
-				set_c_e_p(chan, parking_con_dial, peername_flat, 1);
-			} else {
-				/* Handle fallback when extensions don't exist here since that logic was removed from pbx */
-				if (ast_exists_extension(chan, pu->parkinglot->cfg.comebackcontext, peername_flat, 1, NULL)) {
-					set_c_e_p(chan, pu->parkinglot->cfg.comebackcontext, peername_flat, 1);
-				} else if (ast_exists_extension(chan, pu->parkinglot->cfg.comebackcontext, "s", 1, NULL)) {
-					ast_verb(2, "Can not start %s at %s,%s,1. Using 's@%s' instead.\n", ast_channel_name(chan),
-						pu->parkinglot->cfg.comebackcontext, peername_flat, pu->parkinglot->cfg.comebackcontext);
-					set_c_e_p(chan, pu->parkinglot->cfg.comebackcontext, "s", 1);
-				} else {
-					ast_verb(2, "Can not start %s at %s,%s,1 and exten 's@%s' does not exist. Using 's at default'\n",
-						ast_channel_name(chan),
-						pu->parkinglot->cfg.comebackcontext, peername_flat,
-						pu->parkinglot->cfg.comebackcontext);
-					set_c_e_p(chan, "default", "s", 1);
-				}
-			}
-		} else {
-			/*
-			 * They've been waiting too long, send them back to where they
-			 * came.  Theoretically they should have their original
-			 * extensions and such, but we copy to be on the safe side.
-			 */
-			set_c_e_p(chan, pu->context, pu->exten, pu->priority);
-		}
-		post_manager_event("ParkedCallTimeOut", pu);
-
-		ast_verb(2, "Timeout for %s parked on %d (%s). Returning to %s,%s,%d\n",
-			ast_channel_name(pu->chan), pu->parkingnum, pu->parkinglot->name, ast_channel_context(pu->chan),
-			ast_channel_exten(pu->chan), ast_channel_priority(pu->chan));
-
-		/* Start up the PBX, or hang them up */
-		if (ast_pbx_start(chan))  {
-			ast_log(LOG_WARNING,
-				"Unable to restart the PBX for user on '%s', hanging them up...\n",
-				ast_channel_name(pu->chan));
-			ast_hangup(chan);
-		}
-
-		/* And take them out of the parking lot */
-		return 1;
-	}
-
-	/* still within parking time, process descriptors */
-	if (pfds) {
-		for (x = 0; x < AST_MAX_FDS; x++) {
-			struct ast_frame *f;
-			int y;
-
-			if (!ast_channel_fd_isset(chan, x)) {
-				continue;	/* nothing on this descriptor */
-			}
-
-			for (y = 0; y < nfds; y++) {
-				if (pfds[y].fd == ast_channel_fd(chan, x)) {

[... 1336 lines stripped ...]



More information about the svn-commits mailing list