[asterisk-commits] dvossel: branch dvossel/hd_confbridge r314411 - in /team/dvossel/hd_confbridg...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 20 11:08:06 CDT 2011
Author: dvossel
Date: Wed Apr 20 11:08:03 2011
New Revision: 314411
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=314411
Log:
addresses more reviewboard comments
Modified:
team/dvossel/hd_confbridge/apps/app_confbridge.c
team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
Modified: team/dvossel/hd_confbridge/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/app_confbridge.c?view=diff&rev=314411&r1=314410&r2=314411
==============================================================================
--- team/dvossel/hd_confbridge/apps/app_confbridge.c (original)
+++ team/dvossel/hd_confbridge/apps/app_confbridge.c Wed Apr 20 11:08:03 2011
@@ -1078,11 +1078,11 @@
static int conf_get_pin(struct ast_channel *chan, struct conference_bridge_user *conference_bridge_user)
{
- char pin_guess[MAX_PIN] = { 0, };
+ char pin_guess[MAX_PIN+1] = { 0, };
const char *pin = conference_bridge_user->u_profile.pin;
char *tmp = pin_guess;
int i, res;
- unsigned int len = MAX_PIN - 1;
+ unsigned int len = MAX_PIN ;
/* give them three tries to get the pin right */
for (i = 0; i < 3; i++) {
@@ -1103,11 +1103,11 @@
pin_guess[0] = res;
pin_guess[1] = '\0';
tmp = pin_guess + 1;
- len = MAX_PIN - 2;
+ len = MAX_PIN - 1;
} else {
/* reset pin buf as empty buffer. */
tmp = pin_guess;
- len = MAX_PIN - 1;
+ len = MAX_PIN;
}
}
return -1;
@@ -1460,6 +1460,38 @@
return 0;
}
+static int action_kick_last(struct conference_bridge *conference_bridge,
+ struct ast_bridge_channel *bridge_channel,
+ struct conference_bridge_user *conference_bridge_user)
+{
+ struct conference_bridge_user *last_participant = NULL;
+ int isadmin = ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ADMIN);
+
+ if (!isadmin) {
+ ast_stream_and_wait(bridge_channel->chan,
+ conf_get_sound(CONF_SOUND_ERROR_MENU, conference_bridge_user->b_profile.sounds),
+ "");
+ ast_log(LOG_WARNING, "Only admin users can use the kick_last menu action. Channel %s of conf %s is not an admin.\n",
+ bridge_channel->chan->name,
+ conference_bridge->name);
+ return -1;
+ }
+
+ ao2_lock(conference_bridge);
+ if (((last_participant = AST_LIST_LAST(&conference_bridge->users_list)) == conference_bridge_user)
+ || (ast_test_flag(&last_participant->u_profile, USER_OPT_ADMIN))) {
+ ao2_unlock(conference_bridge);
+ ast_stream_and_wait(bridge_channel->chan,
+ conf_get_sound(CONF_SOUND_ERROR_MENU, conference_bridge_user->b_profile.sounds),
+ "");
+ } else if (last_participant) {
+ last_participant->kicked = 1;
+ ast_bridge_remove(conference_bridge->bridge, last_participant->chan);
+ ao2_unlock(conference_bridge);
+ }
+ return 0;
+}
+
static int action_dialplan_exec(struct ast_bridge_channel *bridge_channel, struct conf_menu_action *menu_action)
{
struct ast_pbx_args args;
@@ -1511,7 +1543,6 @@
struct conf_menu *menu)
{
struct conf_menu_action *menu_action;
- struct conference_bridge_user *last_participant = NULL;
int isadmin = ast_test_flag(&conference_bridge_user->u_profile, USER_OPT_ADMIN);
int stop_prompts = 0;
int res = 0;
@@ -1577,22 +1608,7 @@
break;
case MENU_ACTION_ADMIN_KICK_LAST:
- if (!isadmin) {
- break;
- }
- ao2_lock(conference_bridge);
- if (((last_participant = AST_LIST_LAST(&conference_bridge->users_list)) == conference_bridge_user)
- || (ast_test_flag(&last_participant->u_profile, USER_OPT_ADMIN))) {
- ao2_unlock(conference_bridge);
- res = ast_stream_and_wait(bridge_channel->chan,
- conf_get_sound(CONF_SOUND_ERROR_MENU, conference_bridge_user->b_profile.sounds),
- "");
-
- } else if (last_participant) {
- last_participant->kicked = 1;
- ast_bridge_remove(conference_bridge->bridge, last_participant->chan);
- ao2_unlock(conference_bridge);
- }
+ res |= action_kick_last(conference_bridge, bridge_channel, conference_bridge_user);
break;
case MENU_ACTION_LEAVE:
ao2_lock(conference_bridge);
Modified: team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c?view=diff&rev=314411&r1=314410&r2=314411
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/conf_config_parser.c Wed Apr 20 11:08:03 2011
@@ -148,25 +148,15 @@
static int set_user_option(const char *name, const char *value, struct user_profile *u_profile)
{
if (!strcasecmp(name, "admin")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_ADMIN :
- u_profile->flags & ~USER_OPT_ADMIN;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_ADMIN);
} else if (!strcasecmp(name, "marked")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_MARKEDUSER :
- u_profile->flags & ~USER_OPT_MARKEDUSER;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_MARKEDUSER);
} else if (!strcasecmp(name, "startmuted")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_STARTMUTED :
- u_profile->flags & ~USER_OPT_STARTMUTED;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_STARTMUTED);
} else if (!strcasecmp(name, "music_on_hold_when_empty")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_MUSICONHOLD :
- u_profile->flags & ~USER_OPT_MUSICONHOLD;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_MUSICONHOLD);
} else if (!strcasecmp(name, "quiet")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_QUIET :
- u_profile->flags & ~USER_OPT_QUIET;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_QUIET);
} else if (!strcasecmp(name, "announce_user_count_all")) {
if (ast_true(value)) {
u_profile->flags = u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNTALL;
@@ -178,41 +168,27 @@
return -1;
}
} else if (!strcasecmp(name, "announce_user_count")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_ANNOUNCEUSERCOUNT :
- u_profile->flags & ~USER_OPT_ANNOUNCEUSERCOUNT;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_ANNOUNCEUSERCOUNT);
} else if (!strcasecmp(name, "announce_only_user")) {
u_profile->flags = ast_true(value) ?
u_profile->flags & ~USER_OPT_NOONLYPERSON :
u_profile->flags | USER_OPT_NOONLYPERSON;
} else if (!strcasecmp(name, "wait_marked")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_WAITMARKED :
- u_profile->flags & ~USER_OPT_WAITMARKED;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_WAITMARKED);
} else if (!strcasecmp(name, "end_marked")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_ENDMARKED :
- u_profile->flags & ~USER_OPT_ENDMARKED;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_ENDMARKED);
} else if (!strcasecmp(name, "talk_detection_events")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_TALKER_DETECT :
- u_profile->flags & ~USER_OPT_TALKER_DETECT;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_TALKER_DETECT);
} else if (!strcasecmp(name, "dtmf_passthrough")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_DTMF_PASS:
- u_profile->flags & ~USER_OPT_DTMF_PASS;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_DTMF_PASS);
} else if (!strcasecmp(name, "announce_join_leave")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_ANNOUNCE_JOIN_LEAVE :
- u_profile->flags & ~USER_OPT_ANNOUNCE_JOIN_LEAVE;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_ANNOUNCE_JOIN_LEAVE);
} else if (!strcasecmp(name, "pin")) {
ast_copy_string(u_profile->pin, value, sizeof(u_profile->pin));
} else if (!strcasecmp(name, "music_on_hold_class")) {
ast_copy_string(u_profile->moh_class, value, sizeof(u_profile->moh_class));
} else if (!strcasecmp(name, "denoise")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_DENOISE :
- u_profile->flags & ~USER_OPT_DENOISE;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_DENOISE);
} else if (!strcasecmp(name, "dsp_talking_threshold")) {
if (sscanf(value, "%30u", &u_profile->talking_threshold) != 1) {
return -1;
@@ -222,9 +198,7 @@
return -1;
}
} else if (!strcasecmp(name, "dsp_drop_silence")) {
- u_profile->flags = ast_true(value) ?
- u_profile->flags | USER_OPT_DROP_SILENCE :
- u_profile->flags & ~USER_OPT_DROP_SILENCE;
+ ast_set2_flag(u_profile, ast_true(value), USER_OPT_DROP_SILENCE);
} else if (!strcasecmp(name, "template")) {
if (!(conf_find_user_profile(NULL, value, u_profile))) {
return -1;
@@ -303,9 +277,7 @@
return -1;
}
} else if (!strcasecmp(name, "record_conference")) {
- b_profile->flags = ast_true(value) ?
- b_profile->flags | BRIDGE_OPT_RECORD_CONFERENCE :
- b_profile->flags & ~BRIDGE_OPT_RECORD_CONFERENCE;
+ ast_set2_flag(b_profile, ast_true(value), BRIDGE_OPT_RECORD_CONFERENCE);
} else if (!strcasecmp(name, "max_members")) {
if (sscanf(value, "%30u", &b_profile->max_members) != 1) {
return -1;
@@ -604,14 +576,15 @@
static int add_menu_entry(struct conf_menu *menu, const char *dtmf, const char *action_names)
{
- struct conf_menu_entry *menu_entry = ast_calloc(1, sizeof(*menu_entry));
+ struct conf_menu_entry *menu_entry = NULL;
int res = 0;
char *tmp_action_names = ast_strdupa(action_names);
char *action = NULL;
char *action_args;
char *tmp;
-
- if (!(menu_entry)) {
+ char buf[PATH_MAX];
+
+ if (!(menu_entry = ast_calloc(1, sizeof(*menu_entry)))) {
return -1;
}
@@ -641,21 +614,24 @@
} else if (!strcasecmp(action, "leave_conference")) {
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_LEAVE, NULL);
} else if (!strncasecmp(action, "dialplan_exec", 13)) {
- action_args = ast_strdupa(action);
+ ast_copy_string(buf, action, sizeof(buf));
+ action_args = buf;
if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
*tmp = '\0';
action_args++;
}
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_DIALPLAN_EXEC, action_args);
} else if (action_len >= 21 && !strncasecmp(action, "playback_and_continue", 21)) {
- action_args = ast_strdupa(action);
+ ast_copy_string(buf, action, sizeof(buf));
+ action_args = buf;
if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
*tmp = '\0';
action_args++;
}
res |= add_action_to_menu_entry(menu_entry, MENU_ACTION_PLAYBACK_AND_CONTINUE, action_args);
} else if (action_len >= 8 && !strncasecmp(action, "playback", 8)) {
- action_args = ast_strdupa(action);
+ ast_copy_string(buf, action, sizeof(buf));
+ action_args = buf;
if ((action_args = strchr(action, '(')) && (tmp = strrchr(action_args, ')'))) {
*tmp = '\0';
action_args++;
@@ -905,7 +881,7 @@
case CLI_INIT:
e->command = "confbridge show profile bridge";
e->usage =
- "Usage confbridge show profile bridge [<profile name>]\n";
+ "Usage confbridge show profile bridge <profile name>\n";
return NULL;
case CLI_GENERATE:
if (a->pos == 4) {
@@ -929,7 +905,7 @@
if (b_profile.internal_sample_rate) {
snprintf(tmp, sizeof(tmp), "%d", b_profile.internal_sample_rate);
} else {
- snprintf(tmp, sizeof(tmp), "auto");
+ ast_copy_string(tmp, "auto", sizeof(tmp));
}
ast_cli(a->fd,"Internal Sample Rate: %s\n", tmp);
@@ -1196,7 +1172,7 @@
conf_parse_init();
}
- if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
+ if (!cfg || cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
return 0;
}
@@ -1204,6 +1180,7 @@
while ((cat = ast_category_browse(cfg, cat))) {
if (!(type = (ast_variable_retrieve(cfg, cat, "type")))) {
+ ast_log(LOG_WARNING, "Section '%s' lacks type\n", cat);
continue;
}
if (!strcasecmp(type, "bridge")) {
@@ -1222,6 +1199,11 @@
return 0;
}
+static void conf_user_profile_copy(struct user_profile *dst, struct user_profile *src)
+{
+ memcpy(dst, src, sizeof(*dst));
+}
+
const struct user_profile *conf_find_user_profile(struct ast_channel *chan, const char *user_profile_name, struct user_profile *result)
{
struct user_profile tmp;
@@ -1236,7 +1218,7 @@
ast_channel_unlock(chan);
b_data = datastore->data;
if (b_data->u_usable) {
- memcpy(result, &b_data->u_profile, sizeof(*result));
+ conf_user_profile_copy(result, &b_data->u_profile);
return result;
}
}
@@ -1250,7 +1232,7 @@
return NULL;
}
ao2_lock(tmp2);
- memcpy(result, tmp2, sizeof(*result));
+ conf_user_profile_copy(result, tmp2);
ao2_unlock(tmp2);
ao2_ref(tmp2, -1);
@@ -1279,7 +1261,6 @@
struct bridge_profile *tmp2;
struct ast_datastore *datastore = NULL;
struct func_confbridge_data *b_data = NULL;
- ast_copy_string(tmp.name, bridge_profile_name, sizeof(tmp.name));
if (chan) {
ast_channel_lock(chan);
@@ -1296,6 +1277,7 @@
if (ast_strlen_zero(bridge_profile_name)) {
bridge_profile_name = DEFAULT_BRIDGE_PROFILE;
}
+ ast_copy_string(tmp.name, bridge_profile_name, sizeof(tmp.name));
if (!(tmp2 = ao2_find(bridge_profiles, &tmp, OBJ_POINTER))) {
return NULL;
}
Modified: team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h?view=diff&rev=314411&r1=314410&r2=314411
==============================================================================
--- team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h (original)
+++ team/dvossel/hd_confbridge/apps/confbridge/include/confbridge.h Wed Apr 20 11:08:03 2011
@@ -86,7 +86,7 @@
struct conf_menu_action {
enum conf_menu_action_id id;
union {
- char playback_file[512];
+ char playback_file[PATH_MAX];
struct {
char context[AST_MAX_CONTEXT];
char exten[AST_MAX_EXTENSION];
@@ -175,7 +175,7 @@
struct bridge_profile {
char name[64];
- char rec_file[512];
+ char rec_file[PATH_MAX];
unsigned int flags;
unsigned int max_members; /*!< The maximum number of participants allowed in the conference */
unsigned int internal_sample_rate; /*!< The internal sample rate of the bridge. 0 when set to auto adjust mode. */
More information about the asterisk-commits
mailing list