diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-08-10 16:24:11 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-08-10 16:24:11 +0000 |
commit | 58d5edca86dbec98b948cfece8a995e5fb2a7366 (patch) | |
tree | fc67d9e42c9d0e43f71e39bb24d4b2edc06ac7a0 /res | |
parent | 09a83ce0a8102c40c0f9ef44d310032bf30a28c1 (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: http://svn.digium.com/svn/asterisk/trunk@79027 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rw-r--r-- | res/res_features.c | 21 |
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; } |