summaryrefslogtreecommitdiff
path: root/res/res_features.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-08-10 16:24:11 +0000
committerRussell Bryant <russell@russellbryant.com>2007-08-10 16:24:11 +0000
commite113d36aa4052a9f102fbac687f16bf9bf6096de (patch)
treefc67d9e42c9d0e43f71e39bb24d4b2edc06ac7a0 /res/res_features.c
parentfef7773d0b802f4330999923bcd0a353a6f7ee31 (diff)
Merge a set of device state improvements from team/russell/events.
The way a device state change propagates is kind of silly, in my opinion. A device state provider calls a function that indicates that the state of a device has changed. Then, another thread goes back and calls a callback for the device state provider to find out what the new state is before it can go send it off to whoever cares. I have changed it so that you can include the state that the device has changed to in the first function call from the device state provider. This removes the need to have to call the callback, which locks up critical containers to go find out what the state changed to. This change set changes the "simple" device state providers to use the new method. This includes parking, meetme, and SLA. I have also mostly converted chan_agent in my branch, but still have some more things to think through before presenting the plan for converting channel drivers to ensure all of the right events get generated ... git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@79027 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_features.c')
-rw-r--r--res/res_features.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/res/res_features.c b/res/res_features.c
index 1083948a5..af5ee4865 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -349,13 +349,12 @@ static int adsi_announce_park(struct ast_channel *chan, char *parkingexten)
}
/*! \brief Notify metermaids that we've changed an extension */
-static void notify_metermaids(const char *exten, char *context)
+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", exten, context);
+ ast_debug(4, "Notification of state change to metermaids %s@%s\n to state '%s'",
+ exten, context, devstate2str(state));
- /* Send notification to devicestate subsystem */
- ast_device_state_changed("park:%s@%s", exten, context);
- return;
+ ast_devstate_changed(state, "park:%s@%s", exten, context);
}
/*! \brief metermaids callback from devicestate.c */
@@ -493,7 +492,7 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
ast_say_digits(peer, pu->parkingnum, "", peer->language);
if (con) {
if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, ast_strdup(pu->parkingexten), ast_free, registrar))
- notify_metermaids(pu->parkingexten, parking_con);
+ notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_INUSE);
}
if (pu->notquiteyet) {
/* Wake up parking thread if we're really done */
@@ -2097,7 +2096,7 @@ static void *do_parking_thread(void *ignore)
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
else
- notify_metermaids(pu->parkingexten, parking_con);
+ notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_NOT_INUSE);
} else
ast_log(LOG_WARNING, "Whoa, no parking context?\n");
ast_free(pu);
@@ -2131,7 +2130,7 @@ static void *do_parking_thread(void *ignore)
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
else
- notify_metermaids(pu->parkingexten, parking_con);
+ notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_NOT_INUSE);
} else
ast_log(LOG_WARNING, "Whoa, no parking context?\n");
ast_free(pu);
@@ -2246,7 +2245,7 @@ static int park_exec(struct ast_channel *chan, void *data)
if (ast_context_remove_extension2(con, pu->parkingexten, 1, NULL))
ast_log(LOG_WARNING, "Whoa, failed to remove the extension!\n");
else
- notify_metermaids(pu->parkingexten, parking_con);
+ notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_NOT_INUSE);
} else
ast_log(LOG_WARNING, "Whoa, no parking context?\n");
@@ -3030,7 +3029,7 @@ static int load_config(void)
/* Remove the old parking extension */
if (!ast_strlen_zero(old_parking_con) && (con = ast_context_find(old_parking_con))) {
if(ast_context_remove_extension2(con, old_parking_ext, 1, registrar))
- notify_metermaids(old_parking_ext, old_parking_con);
+ notify_metermaids(old_parking_ext, old_parking_con, AST_DEVICE_NOT_INUSE);
ast_debug(1, "Removed old parking extension %s@%s\n", old_parking_ext, old_parking_con);
}
@@ -3042,7 +3041,7 @@ static int load_config(void)
if (parkaddhints)
park_add_hints(parking_con, parking_start, parking_stop);
if (!res)
- notify_metermaids(ast_parking_ext(), parking_con);
+ notify_metermaids(ast_parking_ext(), parking_con, AST_DEVICE_INUSE);
return res;
}