diff options
author | Mark Michelson <mmichelson@digium.com> | 2013-06-06 21:40:35 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2013-06-06 21:40:35 +0000 |
commit | 2dc8a060064f359a17f5ebcd515d85fe5203c019 (patch) | |
tree | fca012b9378a2a005fea30278f7d2a6129251b1f /channels/chan_unistim.c | |
parent | 5f740572d081330fb43462eba5b0f495d8e56df1 (diff) |
Refactor the features configuration scheme.
Features configuration is handled in its own API in
features_config.h and features_config.c. This way, features
configuration is accessible to anything that needs it.
In addition, features configuration has been altered to
be more channel-oriented. Most callers of features API
code will be supplying a channel so that the individual
channel's settings will be acquired rather than the global
setting.
Missing from this commit is XML documentation for the
features configuration. That will be handled in a separate
commit.
Review: https://reviewboard.asterisk.org/r/2578/
(issue ASTERISK-21542)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@390751 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels/chan_unistim.c')
-rw-r--r-- | channels/chan_unistim.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c index 426e6ab10..28d332f62 100644 --- a/channels/chan_unistim.c +++ b/channels/chan_unistim.c @@ -76,6 +76,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/features.h" #include "asterisk/astobj2.h" #include "asterisk/astdb.h" +#include "asterisk/features_config.h" #define DEFAULTCONTEXT "default" @@ -3086,11 +3087,25 @@ static void handle_call_outgoing(struct unistimsession *s) send_favorite_short(sub->softkey, FAV_ICON_OFFHOOK_BLACK, s); s->device->selected = -1; if (!sub->owner) { /* A call is already in progress ? */ + RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, NULL, ao2_cleanup); + const char *pickupexten; + c = unistim_new(sub, AST_STATE_DOWN, NULL); /* No, starting a new one */ if (!sub->rtp) { /* Need to start RTP before calling ast_pbx_run */ start_rtp(sub); } - if (c && !strcmp(s->device->phone_number, ast_pickup_ext())) { + if (c) { + ast_channel_lock(c); + pickup_cfg = ast_get_chan_features_pickup_config(c); + if (!pickup_cfg) { + ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n"); + pickupexten = ""; + } else { + pickupexten = ast_strdupa(pickup_cfg->pickupexten); + } + ast_channel_unlock(c); + } + if (c && !strcmp(s->device->phone_number, pickupexten)) { if (unistimdebug) { ast_verb(0, "Try to pickup in unistim_new\n"); } @@ -4099,8 +4114,17 @@ static void key_main_page(struct unistimsession *pte, char keycode) ast_mutex_unlock(&devicelock); show_extension_page(pte); } else { /* Pickup function */ + /* XXX Is there a way to get a specific channel here? */ + RAII_VAR(struct ast_features_pickup_config *, pickup_cfg, + ast_get_chan_features_pickup_config(NULL), ao2_cleanup); + + if (!pickup_cfg) { + ast_log(LOG_ERROR, "Unable to retrieve pickup configuration options. Unable to detect call pickup extension\n"); + break; + } + pte->device->selected = -1; - ast_copy_string(pte->device->phone_number, ast_pickup_ext(), + ast_copy_string(pte->device->phone_number, pickup_cfg->pickupexten, sizeof(pte->device->phone_number)); handle_call_outgoing(pte); } |