Hello,

I deleted default profile from conference.conf.xml and from that time I could 
not connect second outgoing channel to conference.

I located problem in searching for conference with 'switch_core_hash_find' 
function. Only name of conference is stored in hash so
looking for something like 'n...@profile' did not find any. In my opinion it 
always used second attempt to dial when conference
was not found, and it successes only if default profile is available.

There is also bgdial problem which do not allow to call to not existing 
conference, but in function conf_api_sub_bgdial it looks
like it was meant to work. I have to know freeswitch code better to fix it.

I created patch to solve first problem. This is my first patch so please give 
me comments so next time I do it better. I choose
this way to learn how freeswitch modules are made. I would also like if someone 
could review my patch and tell me if this is a way
mod_conference should work. I assumed that looking for conference is for 
connecting members to existing conference, and that it's
should work like that. Previously it did not find conference if profile was 
given in command.

Szymon Olko
--- _mod_conference.c	2009-03-25 10:18:14.000000000 +0100
+++ mod_conference.c	2009-03-25 11:52:32.000000000 +0100
@@ -3583,7 +3583,7 @@
 	if (conference) {
 		conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3]);
 	} else {
-		conference_outcall_bg(NULL, argv[1], NULL, argv[2], 60, NULL, argv[4], argv[3]);
+		conference_outcall_bg(NULL, argv[0], NULL, argv[2], 60, NULL, argv[4], argv[3]);
 	}
 	stream->write_function(stream, "OK\n");
 
@@ -3974,6 +3974,7 @@
 	char *http = NULL, *type = NULL;
 	int argc;
 	char *argv[25] = { 0 };
+	char conf_name[512] = "", *p;
 
 	if (!cmd) {
 		cmd = "help";
@@ -4000,8 +4001,13 @@
 	/* try to find a command to execute */
 	if (argc && argv[0]) {
 		conference_obj_t *conference = NULL;
-
-		if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, argv[0]))) {
+		
+		if ((p = strchr(argv[0], '@'))) {
+		    switch_copy_string(conf_name, argv[0], ++p - argv[0]);
+    		} else {
+		    switch_copy_string(conf_name, argv[0], sizeof(conf_name));
+    		}
+		if ((conference = (conference_obj_t *) switch_core_hash_find(globals.conference_hash, conf_name))) {
 			if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
 				goto done;
@@ -4026,7 +4032,7 @@
 					/* command returned error, so show syntax usage */
 					stream->write_function(stream, conf_api_sub_commands[CONF_API_COMMAND_DIAL].psyntax);
 				}
-			} else if (strcasecmp(argv[0], "bgdial") == 0) {
+			} else if (strcasecmp(argv[1], "bgdial") == 0) {
 				if (conf_api_sub_bgdial(NULL, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
 					/* command returned error, so show syntax usage */
 					stream->write_function(stream, conf_api_sub_commands[CONF_API_COMMAND_BGDIAL].psyntax);
@@ -4058,11 +4064,13 @@
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 	switch_channel_t *caller_channel = NULL;
 	char appdata[512];
+	char full_conference_name[512];
 	int rdlock = 0;
 
 	*cause = SWITCH_CAUSE_NORMAL_CLEARING;
 
 	if (conference == NULL) {
+		switch_copy_string(full_conference_name, conference_name, sizeof(full_conference_name));
 		char *dialstr = switch_mprintf("{ignore_early_media=true}%s", bridgeto);
 		status = switch_ivr_originate(NULL, &peer_session, cause, dialstr, 60, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE);
 		switch_safe_free(dialstr);
@@ -4076,7 +4084,7 @@
 		goto callup;
 	}
 
-	conference_name = conference->name;
+	switch_snprintf(full_conference_name,sizeof(full_conference_name),"%...@%s",conference->name, conference->profile_name);
 
 	if (switch_thread_rwlock_tryrdlock(conference->rwlock) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
@@ -4130,17 +4138,17 @@
 		switch_caller_extension_t *extension = NULL;
 
 		/* build an extension name object */
-		if ((extension = switch_caller_extension_new(peer_session, conference_name, conference_name)) == 0) {
+		if ((extension = switch_caller_extension_new(peer_session, full_conference_name, full_conference_name)) == 0) {
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
 			status = SWITCH_STATUS_MEMERR;
 			goto done;
 		}
 		/* add them to the conference */
 		if (flags && strcasecmp(flags, "none")) {
-			switch_snprintf(appdata, sizeof(appdata), "%s+flags{%s}", conference_name, flags);
+			switch_snprintf(appdata, sizeof(appdata), "%s+flags{%s}", full_conference_name, flags);
 			switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, appdata);
 		} else {
-			switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, conference_name);
+			switch_caller_extension_add_application(peer_session, extension, (char *) global_app_name, full_conference_name);
 		}
 
 		switch_channel_set_caller_extension(peer_channel, extension);
_______________________________________________
Freeswitch-dev mailing list
Freeswitch-dev@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
http://www.freeswitch.org

Reply via email to