diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/app.c | 11 | ||||
-rw-r--r-- | main/features.c | 19 | ||||
-rw-r--r-- | main/global_datastores.c | 38 |
3 files changed, 62 insertions, 6 deletions
diff --git a/main/app.c b/main/app.c index 99eaec3f6..6e09059e5 100644 --- a/main/app.c +++ b/main/app.c @@ -1670,6 +1670,17 @@ int ast_app_parse_options64(const struct ast_app_option *options, struct ast_fla return res; } +void ast_app_options2str64(const struct ast_app_option *options, struct ast_flags64 *flags, char *buf, size_t len) +{ + unsigned int i, found = 0; + for (i = 32; i < 128 && found < len; i++) { + if (ast_test_flag64(flags, options[i].flag)) { + buf[found++] = i; + } + } + buf[found] = '\0'; +} + int ast_get_encoded_char(const char *stream, char *result, size_t *consumed) { int i; diff --git a/main/features.c b/main/features.c index 7779c0679..69aae8ca6 100644 --- a/main/features.c +++ b/main/features.c @@ -53,6 +53,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/devicestate.h" #include "asterisk/monitor.h" #include "asterisk/audiohook.h" +#include "asterisk/global_datastores.h" #define DEFAULT_PARK_TIME 45000 #define DEFAULT_TRANSFER_DIGIT_TIMEOUT 3000 @@ -2232,10 +2233,24 @@ static void *do_parking_thread(void *ignore) } if (con) { char returnexten[AST_MAX_EXTENSION]; - snprintf(returnexten, sizeof(returnexten), "%s,,t", peername); + struct ast_datastore *features_datastore; + struct ast_dial_features *dialfeatures = NULL; + + ast_channel_lock(chan); + + if ((features_datastore = ast_channel_datastore_find(chan, &dial_features_info, NULL))) + dialfeatures = features_datastore->data; + + ast_channel_unlock(chan); + + if (dialfeatures) + snprintf(returnexten, sizeof(returnexten), "%s,,%s", peername, dialfeatures->options); + else /* Existing default */ + snprintf(returnexten, sizeof(returnexten), "%s,,t", peername); + ast_add_extension2(con, 1, peername_flat, 1, NULL, NULL, "Dial", ast_strdup(returnexten), ast_free_ptr, registrar); } - if (comebacktoorigin) { + if (comebacktoorigin) { set_c_e_p(chan, parking_con_dial, peername_flat, 1); } else { ast_log(LOG_WARNING, "now going to parkedcallstimeout,s,1 | ps is %d\n",pu->parkingnum); diff --git a/main/global_datastores.c b/main/global_datastores.c index 9b87b2cb4..ca04a0fe9 100644 --- a/main/global_datastores.c +++ b/main/global_datastores.c @@ -35,8 +35,9 @@ static void dialed_interface_destroy(void *data) struct ast_dialed_interface *di = NULL; AST_LIST_HEAD(, ast_dialed_interface) *dialed_interface_list = data; - if (!dialed_interface_list) + if (!dialed_interface_list) { return; + } AST_LIST_LOCK(dialed_interface_list); while ((di = AST_LIST_REMOVE_HEAD(dialed_interface_list, list))) @@ -53,11 +54,13 @@ static void *dialed_interface_duplicate(void *data) AST_LIST_HEAD(, ast_dialed_interface) *old_list; AST_LIST_HEAD(, ast_dialed_interface) *new_list = NULL; - if(!(old_list = data)) + if(!(old_list = data)) { return NULL; + } - if(!(new_list = ast_calloc(1, sizeof(*new_list)))) + if(!(new_list = ast_calloc(1, sizeof(*new_list)))) { return NULL; + } AST_LIST_HEAD_INIT(new_list); AST_LIST_LOCK(old_list); @@ -76,8 +79,35 @@ static void *dialed_interface_duplicate(void *data) return new_list; } + +static void *dial_features_duplicate(void *data) +{ + struct ast_dial_features *df = data, *df_copy; + + if (!(df_copy = ast_calloc(1, sizeof(*df)))) { + return NULL; + } + + memcpy(df_copy, df, sizeof(*df)); + + return df_copy; +} + +static void dial_features_destroy(void *data) { + struct ast_dial_features *df = data; + if (df) { + ast_free(df); + } +} + const struct ast_datastore_info dialed_interface_info = { - .type ="dialed-interface", + .type = "dialed-interface", .destroy = dialed_interface_destroy, .duplicate = dialed_interface_duplicate, }; + +const struct ast_datastore_info dial_features_info = { + .type = "dial-features", + .destroy = dial_features_destroy, + .duplicate = dial_features_duplicate, +}; |