[Freeswitch-svn] [commit] r5398 - in freeswitch/trunk/src: include mod/applications/mod_conference

Freeswitch SVN mikej at freeswitch.org
Wed Jun 20 00:17:26 EDT 2007


Author: mikej
Date: Wed Jun 20 00:17:26 2007
New Revision: 5398

Modified:
   freeswitch/trunk/src/include/switch_loadable_module.h
   freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c

Log:
move mod_conference to use new module loader interfaces.

Modified: freeswitch/trunk/src/include/switch_loadable_module.h
==============================================================================
--- freeswitch/trunk/src/include/switch_loadable_module.h	(original)
+++ freeswitch/trunk/src/include/switch_loadable_module.h	Wed Jun 20 00:17:26 2007
@@ -275,6 +275,26 @@
 	break; \
 	}
 
+#define SWITCH_ADD_CHAT(chat_int, int_name, funcptr) \
+	for (;;) { \
+	chat_int = switch_loadable_module_create_interface(*module_interface, SWITCH_CHAT_INTERFACE); \
+	chat_int->chat_send = funcptr; \
+	chat_int->interface_name = int_name; \
+	break; \
+	}
+
+#define SWITCH_ADD_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) \
+	for (;;) { \
+	app_int = switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE); \
+	app_int->interface_name = int_name; \
+	app_int->application_function = funcptr; \
+	app_int->short_desc = short_descript; \
+	app_int->long_desc = long_descript; \
+	app_int->syntax = syntax_string; \
+	app_interface->flags = app_flags; \
+	break; \
+	}
+
 ///\}
 
 SWITCH_END_EXTERN_C

Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c	Wed Jun 20 00:17:26 2007
@@ -39,7 +39,7 @@
 
 static const char global_app_name[] = "conference";
 static char *global_cf_name = "conference.conf";
-static switch_api_interface_t conf_api_interface;
+static char *api_syntax;
 
 /* Size to allocate for audio buffers */
 #define CONF_BUFFER_SIZE 1024 * 128
@@ -3523,7 +3523,7 @@
 			if (strcasecmp(argv[0], "list") == 0) {
 				conf_api_sub_list(NULL, stream, argc, argv);
 			} else if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
-				stream->write_function(stream, "%s\n", conf_api_interface.syntax);
+				stream->write_function(stream, "%s\n", api_syntax);
 			} else if (argv[1] && strcasecmp(argv[1], "dial") == 0) {
 				if (conf_api_sub_dial(NULL, stream, argc, argv) != SWITCH_STATUS_SUCCESS) {
 					/* command returned error, so show syntax usage */
@@ -4338,30 +4338,6 @@
 	switch_thread_create(&thread, thd_attr, conference_record_thread_run, rec, rec->pool);
 }
 
-static switch_application_interface_t conference_autocall_application_interface = {
-	/*.interface_name */ "conference_set_auto_outcall",
-	/*.application_function */ conference_auto_function,
-	NULL, NULL, NULL,
-	/* flags */ SAF_NONE,
-	/*.next */
-};
-
-static switch_application_interface_t conference_application_interface = {
-	/*.interface_name */ global_app_name,
-	/*.application_function */ conference_function,
-	NULL, NULL, NULL,
-	/* flags */ SAF_NONE,
-	/*.next */ &conference_autocall_application_interface
-};
-
-static switch_api_interface_t conf_api_interface = {
-	/*.interface_name */ "conference",
-	/*.desc */ "Conference module commands",
-	/*.function */ conf_api_main,
-	/*.syntax *//* see switch_module_load, this is built on the fly */
-	/*.next */
-};
-
 static switch_status_t chat_send(char *proto, char *from, char *to, char *subject, char *body, char *hint)
 {
 	char name[512] = "", *p, *lbuf = NULL;
@@ -4412,7 +4388,7 @@
 #if 0
 			else {
 				if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) {
-					stream.write_function(&stream, "%s\n", conf_api_interface.syntax);
+					stream.write_function(&stream, "%s\n", api_syntax);
 					/* find a normal command */
 				} else {
 					conf_api_dispatch(conference, &stream, argc, argv, (const char *) body, 0);
@@ -4431,26 +4407,6 @@
 	return SWITCH_STATUS_SUCCESS;
 }
 
-static switch_chat_interface_t conference_chat_interface = {
-	/*.name */ CONF_CHAT_PROTO,
-	/*.chat_send */ chat_send,
-
-};
-
-static switch_loadable_module_interface_t conference_module_interface = {
-	/*.module_name */ modname,
-	/*.endpoint_interface */ NULL,
-	/*.timer_interface */ NULL,
-	/*.dialplan_interface */ NULL,
-	/*.codec_interface */ NULL,
-	/*.application_interface */ &conference_application_interface,
-	/*.api_interface */ &conf_api_interface,
-	/*.file_interface */ NULL,
-	/*.speech_interface */ NULL,
-	/*.directory_interface */ NULL,
-	/*.chat_interface */ &conference_chat_interface
-};
-
 static switch_status_t conf_default_controls(conference_obj_t * conference)
 {
 	switch_status_t status = SWITCH_STATUS_FALSE;
@@ -4941,10 +4897,16 @@
 	uint32_t i;
 	size_t nl, ol = 0;
 	char *p = NULL;
+	switch_chat_interface_t *chat_interface;
+	switch_api_interface_t *api_interface;
+	switch_application_interface_t *app_interface;
 	switch_status_t status = SWITCH_STATUS_SUCCESS;
 
 	memset(&globals, 0, sizeof(globals));
 
+	/* Connect my internal structure to the blank pointer passed to me */
+	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
+
 	/* build api interface help ".syntax" field string */
 	p = strdup("");
 	for (i = 0; i < CONFFUNCAPISIZE; i++) {
@@ -4962,13 +4924,12 @@
 		}
 
 	}
-	/* install api interface help ".syntax" field string */
-	if (p != NULL) {
-		conf_api_interface.syntax = p;
-	}
+	api_syntax = p;
 
-	/* Connect my internal structure to the blank pointer passed to me */
-	*module_interface = &conference_module_interface;
+	SWITCH_ADD_API(api_interface, "conference", "Conference module commands", conf_api_main, p);
+	SWITCH_ADD_APP(app_interface, global_app_name, global_app_name, NULL, conference_function, NULL, SAF_NONE);
+	SWITCH_ADD_APP(app_interface, "conference_set_auto_outcall", "conference_set_auto_outcall", NULL, conference_auto_function, NULL, SAF_NONE);
+	SWITCH_ADD_CHAT(chat_interface, CONF_CHAT_PROTO, chat_send);
 
 	/* create/register custom event message type */
 	if (switch_event_reserve_subclass(CONF_EVENT_MAINT) != SWITCH_STATUS_SUCCESS) {
@@ -4977,10 +4938,7 @@
 	}
 
 	/* Setup the pool */
-	if (switch_core_new_memory_pool(&globals.conference_pool) != SWITCH_STATUS_SUCCESS) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no conference pool\n");
-		return SWITCH_STATUS_TERM;
-	}
+	globals.conference_pool = pool;
 
 	/* Setup a hash to store conferences by name */
 	switch_core_hash_init(&globals.conference_hash, globals.conference_pool);
@@ -5015,9 +4973,7 @@
 		}
 
 		/* free api interface help ".syntax" field string */
-		if (conf_api_interface.syntax != NULL) {
-			free((char *) conf_api_interface.syntax);
-		}
+		switch_safe_free(api_syntax);
 	}
 
 	return SWITCH_STATUS_SUCCESS;



More information about the Freeswitch-svn mailing list