skypiax: added another SWITCH_API_COMMANDS to send skype_api command to the named client: skypiax interface_name skype_API_msg

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12799 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Giovanni Maruzzelli 2009-03-26 22:02:32 +00:00
parent fe9d1ca3fb
commit f0bc6d07e1
1 changed files with 60 additions and 1 deletions

View File

@ -41,6 +41,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown);
SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL);
SWITCH_STANDARD_API(sk_function); SWITCH_STANDARD_API(sk_function);
#define SK_SYNTAX "list || console || skype_API_msg" #define SK_SYNTAX "list || console || skype_API_msg"
SWITCH_STANDARD_API(skypiax_function);
#define SKYPIAX_SYNTAX "interface_name skype_API_msg"
static struct { static struct {
int debug; int debug;
@ -1044,7 +1046,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
if (running){ if (running){
SWITCH_ADD_API(commands_api_interface, "sk", "Skypiax commands", sk_function, SK_SYNTAX); SWITCH_ADD_API(commands_api_interface, "sk", "Skypiax console commands", sk_function, SK_SYNTAX);
SWITCH_ADD_API(commands_api_interface, "skypiax", "Skypiax interface commands", skypiax_function, SKYPIAX_SYNTAX);
/* indicate that the module should continue to be loaded */ /* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
@ -1416,6 +1419,62 @@ end:
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_STANDARD_API(skypiax_function)
{
char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0;
private_t *tech_pvt=NULL;
if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (!argc) {
stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX);
goto end;
}
if (argc < 2) {
stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX);
goto end;
}
if (argv[0]) {
int i;
int found =0;
for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
/* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */
if (strlen(globals.SKYPIAX_INTERFACES[i].name)
&&
(strncmp
(globals.SKYPIAX_INTERFACES[i].name, argv[0],
strlen(argv[0])) == 0)) {
tech_pvt=&globals.SKYPIAX_INTERFACES[i];
stream->write_function(stream,"Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPIAX_INTERFACES[i].name);
found = 1;
break;
}
}
if(!found){
stream->write_function(stream,"ERROR: A Skypiax interface with name='%s' was not found\n", argv[0]);
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS;
} else {
skypiax_signaling_write(tech_pvt, (char *)&cmd[ strlen(argv[0]) + 1 ] );
}
} else {
stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX);
}
end:
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS;
}