skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12833 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Giovanni Maruzzelli 2009-03-29 09:21:07 +00:00
parent 3c206cfa22
commit ba1a8ec241
2 changed files with 183 additions and 164 deletions

View File

@ -40,9 +40,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown); 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); SWITCH_STANDARD_API(skypiax_function);
#define SKYPIAX_SYNTAX "interface_name skype_API_msg" #define SKYPIAX_SYNTAX "interface_name skype_API_msg"
static struct { static struct {
int debug; int debug;
@ -664,10 +664,10 @@ static void *SWITCH_THREAD_FUNC skypiax_signaling_thread_func(switch_thread_t *
} }
tech_pvt->interface_state = SKYPIAX_STATE_DOWN; tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str)); memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str));
} else { } else {
ERRORA("no tech_pvt?\n", SKYPIAX_P_LOG); ERRORA("no tech_pvt?\n", SKYPIAX_P_LOG);
} }
} }
} }
return NULL; return NULL;
} }
@ -1026,7 +1026,7 @@ static switch_status_t load_config(void)
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load) SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
{ {
skypiax_module_pool = pool; skypiax_module_pool = pool;
switch_api_interface_t *commands_api_interface; switch_api_interface_t *commands_api_interface;
memset(&globals, '\0', sizeof(globals)); memset(&globals, '\0', sizeof(globals));
@ -1044,14 +1044,15 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
skypiax_endpoint_interface->io_routines = &skypiax_io_routines; skypiax_endpoint_interface->io_routines = &skypiax_io_routines;
skypiax_endpoint_interface->state_handler = &skypiax_state_handlers; skypiax_endpoint_interface->state_handler = &skypiax_state_handlers;
if (running){ if (running) {
SWITCH_ADD_API(commands_api_interface, "sk", "Skypiax console commands", sk_function, SK_SYNTAX); SWITCH_ADD_API(commands_api_interface, "sk", "Skypiax console commands", sk_function,
SWITCH_ADD_API(commands_api_interface, "skypiax", "Skypiax interface commands", skypiax_function, SKYPIAX_SYNTAX); 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;
} } else
else
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
} }
@ -1129,10 +1130,12 @@ void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, voi
{ {
return skypiax_do_tcp_srv_thread_func(obj); return skypiax_do_tcp_srv_thread_func(obj);
} }
void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj) void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj)
{ {
return skypiax_do_tcp_cli_thread_func(obj); return skypiax_do_tcp_cli_thread_func(obj);
} }
void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj) void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj)
{ {
return skypiax_do_skypeapi_thread_func(obj); return skypiax_do_skypeapi_thread_func(obj);
@ -1231,20 +1234,20 @@ int remote_party_is_ringing(private_t * tech_pvt)
session = switch_core_session_locate(tech_pvt->session_uuid_str); session = switch_core_session_locate(tech_pvt->session_uuid_str);
} else { } else {
ERRORA("No session???\n", SKYPIAX_P_LOG); ERRORA("No session???\n", SKYPIAX_P_LOG);
goto done; goto done;
} }
if (session) { if (session) {
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
} else { } else {
ERRORA("No session???\n", SKYPIAX_P_LOG); ERRORA("No session???\n", SKYPIAX_P_LOG);
goto done; goto done;
} }
if (channel) { if (channel) {
switch_channel_mark_ring_ready(channel); switch_channel_mark_ring_ready(channel);
DEBUGA_SKYPE("skype_call: REMOTE PARTY RINGING\n", SKYPIAX_P_LOG); DEBUGA_SKYPE("skype_call: REMOTE PARTY RINGING\n", SKYPIAX_P_LOG);
} else { } else {
ERRORA("No channel???\n", SKYPIAX_P_LOG); ERRORA("No channel???\n", SKYPIAX_P_LOG);
goto done; goto done;
} }
switch_core_session_rwunlock(session); switch_core_session_rwunlock(session);
@ -1262,21 +1265,21 @@ int remote_party_is_early_media(private_t * tech_pvt)
session = switch_core_session_locate(tech_pvt->session_uuid_str); session = switch_core_session_locate(tech_pvt->session_uuid_str);
} else { } else {
ERRORA("No session???\n", SKYPIAX_P_LOG); ERRORA("No session???\n", SKYPIAX_P_LOG);
goto done; goto done;
} }
if (session) { if (session) {
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
switch_core_session_add_stream(session, NULL); switch_core_session_add_stream(session, NULL);
} else { } else {
ERRORA("No session???\n", SKYPIAX_P_LOG); ERRORA("No session???\n", SKYPIAX_P_LOG);
goto done; goto done;
} }
if (channel) { if (channel) {
switch_channel_mark_pre_answered(channel); switch_channel_mark_pre_answered(channel);
NOTICA("skype_call: REMOTE PARTY EARLY MEDIA\n", SKYPIAX_P_LOG); NOTICA("skype_call: REMOTE PARTY EARLY MEDIA\n", SKYPIAX_P_LOG);
} else { } else {
ERRORA("No channel???\n", SKYPIAX_P_LOG); ERRORA("No channel???\n", SKYPIAX_P_LOG);
goto done; goto done;
} }
switch_core_session_rwunlock(session); switch_core_session_rwunlock(session);
@ -1294,20 +1297,20 @@ int outbound_channel_answered(private_t * tech_pvt)
session = switch_core_session_locate(tech_pvt->session_uuid_str); session = switch_core_session_locate(tech_pvt->session_uuid_str);
} else { } else {
ERRORA("No session???\n", SKYPIAX_P_LOG); ERRORA("No session???\n", SKYPIAX_P_LOG);
goto done; goto done;
} }
if (session) { if (session) {
channel = switch_core_session_get_channel(session); channel = switch_core_session_get_channel(session);
} else { } else {
ERRORA("No session???\n", SKYPIAX_P_LOG); ERRORA("No session???\n", SKYPIAX_P_LOG);
goto done; goto done;
} }
if (channel) { if (channel) {
switch_channel_mark_answered(channel); switch_channel_mark_answered(channel);
//DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id); //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
} else { } else {
ERRORA("No channel???\n", SKYPIAX_P_LOG); ERRORA("No channel???\n", SKYPIAX_P_LOG);
goto done; goto done;
} }
switch_core_session_rwunlock(session); switch_core_session_rwunlock(session);
@ -1347,137 +1350,140 @@ private_t *find_available_skypiax_interface(void)
SWITCH_STANDARD_API(sk_function) SWITCH_STANDARD_API(sk_function)
{ {
char *mycmd = NULL, *argv[10] = { 0 }; char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0; int argc = 0;
if(globals.sk_console) if (globals.sk_console)
stream->write_function(stream,"sk console is: |||%s|||\n", globals.sk_console->name); stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name);
else else
stream->write_function(stream,"sk console is NOT yet assigned\n"); stream->write_function(stream, "sk console is NOT yet assigned\n");
if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
}
if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { if (!argc) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); stream->write_function(stream, "%s", SK_SYNTAX);
} goto end;
}
if (!argc) { if (!strcasecmp(argv[0], "list")) {
stream->write_function(stream, "%s", SK_SYNTAX); int i;
goto end; for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
} if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) {
stream->write_function(stream,
"globals.SKYPIAX_INTERFACES[%d].name=\t|||%s||| is \tBUSY, session_uuid_str=|||%s|||\n",
i, globals.SKYPIAX_INTERFACES[i].name,
globals.SKYPIAX_INTERFACES[i].session_uuid_str);
} else {
stream->write_function(stream,
"globals.SKYPIAX_INTERFACES[%d].name=\t|||%s||| is \tIDLE\n",
i, globals.SKYPIAX_INTERFACES[i].name);
}
}
}
} else if (!strcasecmp(argv[0], "console")) {
int i;
int found = 0;
if (!strcasecmp(argv[0], "list")) { if (argc == 2) {
int i; for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
for (i = 0; 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)) { if (strlen(globals.SKYPIAX_INTERFACES[i].name)
if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) { && (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[1], strlen(argv[1])) ==
stream->write_function(stream,"globals.SKYPIAX_INTERFACES[%d].name=\t|||%s||| is \tBUSY, session_uuid_str=|||%s|||\n", i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str); 0)) {
} else { globals.sk_console = &globals.SKYPIAX_INTERFACES[i];
stream->write_function(stream,"globals.SKYPIAX_INTERFACES[%d].name=\t|||%s||| is \tIDLE\n", i, globals.SKYPIAX_INTERFACES[i].name); stream->write_function(stream,
} "sk console is now: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n",
} i, globals.SKYPIAX_INTERFACES[i].name);
} stream->write_function(stream, "sk console is: |||%s|||\n",
} else if (!strcasecmp(argv[0], "console")) { globals.sk_console->name);
int i; found = 1;
int found =0; break;
}
if (argc == 2) { }
for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) { if (!found)
/* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ stream->write_function(stream,
if (strlen(globals.SKYPIAX_INTERFACES[i].name) "ERROR: A Skypiax interface with name='%s' was not found\n",
&& argv[1]);
(strncmp } else {
(globals.SKYPIAX_INTERFACES[i].name, argv[1],
strlen(argv[1])) == 0)) {
globals.sk_console=&globals.SKYPIAX_INTERFACES[i];
stream->write_function(stream,"sk console is now: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPIAX_INTERFACES[i].name);
stream->write_function(stream,"sk console is: |||%s|||\n", globals.sk_console->name);
found = 1;
break;
}
} stream->write_function(stream, "-ERR Usage: sk console interface_name\n");
if(!found) goto end;
stream->write_function(stream,"ERROR: A Skypiax interface with name='%s' was not found\n", argv[1]); }
} else {
stream->write_function(stream, "-ERR Usage: sk console interface_name\n"); } else if (!strcasecmp(argv[0], "ciapalino")) {
goto end;
}
} else {
} else if (!strcasecmp(argv[0], "ciapalino")) { if (globals.sk_console)
skypiax_signaling_write(globals.sk_console, (char *) cmd);
} else { else
if(globals.sk_console) stream->write_function(stream, "sk console is NOT yet assigned\n");
skypiax_signaling_write(globals.sk_console, (char *)cmd); }
else
stream->write_function(stream,"sk console is NOT yet assigned\n");
}
end: end:
switch_safe_free(mycmd); switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
SWITCH_STANDARD_API(skypiax_function) SWITCH_STANDARD_API(skypiax_function)
{ {
char *mycmd = NULL, *argv[10] = { 0 }; char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0; int argc = 0;
private_t *tech_pvt=NULL; 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 (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) { if (!argc) {
argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX);
} goto end;
}
if (!argc) { if (argc < 2) {
stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX); stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX);
goto end; goto end;
} }
if (argc < 2) { if (argv[0]) {
stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX); int i;
goto end; int found = 0;
}
if (argv[0]) { for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
int i; /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */
int found =0; 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;
}
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 (!found) {
if (strlen(globals.SKYPIAX_INTERFACES[i].name) stream->write_function(stream,
&& "ERROR: A Skypiax interface with name='%s' was not found\n",
(strncmp argv[0]);
(globals.SKYPIAX_INTERFACES[i].name, argv[0], switch_safe_free(mycmd);
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;
}
} return SWITCH_STATUS_SUCCESS;
if(!found){ } else {
stream->write_function(stream,"ERROR: A Skypiax interface with name='%s' was not found\n", argv[0]); skypiax_signaling_write(tech_pvt, (char *) &cmd[strlen(argv[0]) + 1]);
switch_safe_free(mycmd); }
} else {
return SWITCH_STATUS_SUCCESS; stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX);
} else { }
skypiax_signaling_write(tech_pvt, (char *)&cmd[ strlen(argv[0]) + 1 ] );
}
} else {
stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX);
}
end: end:
switch_safe_free(mycmd); switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
/* For Emacs: /* For Emacs:
* Local Variables: * Local Variables:
* mode:c * mode:c

View File

@ -167,7 +167,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL"); SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL");
if (!strcasecmp(prop, "PARTNER_HANDLE")) { if (!strcasecmp(prop, "PARTNER_HANDLE")) {
skypiax_strncpy(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1); skypiax_strncpy(tech_pvt->callid_number, value,
sizeof(tech_pvt->callid_number) - 1);
DEBUGA_SKYPE DEBUGA_SKYPE
("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n", ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n",
SKYPIAX_P_LOG, id, tech_pvt->callid_number); SKYPIAX_P_LOG, id, tech_pvt->callid_number);
@ -201,7 +202,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
} }
if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) { if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
if (strcasecmp(id, tech_pvt->skype_call_id)) { if (strcasecmp(id, tech_pvt->skype_call_id)) {
skypiax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); skypiax_strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
DEBUGA_SKYPE DEBUGA_SKYPE
("We called a Skype contact and he answered us on skype_call: %s.\n", ("We called a Skype contact and he answered us on skype_call: %s.\n",
SKYPIAX_P_LOG, id); SKYPIAX_P_LOG, id);
@ -234,7 +236,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
skypiax_signaling_write(tech_pvt, msg_to_skype); skypiax_signaling_write(tech_pvt, msg_to_skype);
DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG, DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
id); id);
skypiax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); skypiax_strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
} else { } else {
/* we're owned, we're in a call, let's try to transfer */ /* we're owned, we're in a call, let's try to transfer */
/************************** TODO /************************** TODO
@ -251,7 +254,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
DEBUGA_SKYPE DEBUGA_SKYPE
("Let's transfer the skype_call %s to %s interface (with skype_user: %s), because we are already in a skypiax call(%s)\n", ("Let's transfer the skype_call %s to %s interface (with skype_user: %s), because we are already in a skypiax call(%s)\n",
SKYPIAX_P_LOG, tech_pvt->skype_call_id, SKYPIAX_P_LOG, tech_pvt->skype_call_id,
available_skypiax_interface->name, available_skypiax_interface->skype_user, id); available_skypiax_interface->name,
available_skypiax_interface->skype_user, id);
sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id, sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id,
available_skypiax_interface->skype_user); available_skypiax_interface->skype_user);
} else { } else {
@ -271,7 +275,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
/* we are calling out */ /* we are calling out */
tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
tech_pvt->interface_state = SKYPIAX_STATE_RINGING; tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
skypiax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); skypiax_strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n", DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
SKYPIAX_P_LOG, id); SKYPIAX_P_LOG, id);
remote_party_is_ringing(tech_pvt); remote_party_is_ringing(tech_pvt);
@ -282,12 +287,12 @@ int skypiax_signaling_read(private_t * tech_pvt)
tech_pvt->interface_state = SKYPIAX_STATE_DIALING; tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG, NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG,
id); id);
start_audio_threads(tech_pvt); start_audio_threads(tech_pvt);
skypiax_sleep(1000); skypiax_sleep(1000);
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
tech_pvt->tcp_cli_port); tech_pvt->tcp_cli_port);
skypiax_signaling_write(tech_pvt, msg_to_skype); skypiax_signaling_write(tech_pvt, msg_to_skype);
sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
tech_pvt->tcp_srv_port); tech_pvt->tcp_srv_port);
skypiax_signaling_write(tech_pvt, msg_to_skype); skypiax_signaling_write(tech_pvt, msg_to_skype);
@ -328,7 +333,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
("we tried to call Skype on skype_call %s and Skype has now FAILED\n", ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
SKYPIAX_P_LOG, id); SKYPIAX_P_LOG, id);
tech_pvt->skype_call_id[0] = '\0'; tech_pvt->skype_call_id[0] = '\0';
skypiax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); skypiax_strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
tech_pvt->interface_state = SKYPIAX_STATE_DOWN; tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
return CALLFLOW_INCOMING_HANGUP; return CALLFLOW_INCOMING_HANGUP;
} else if (!strcasecmp(value, "REFUSED")) { } else if (!strcasecmp(value, "REFUSED")) {
@ -338,7 +344,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
DEBUGA_SKYPE DEBUGA_SKYPE
("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
SKYPIAX_P_LOG, id); SKYPIAX_P_LOG, id);
skypiax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); skypiax_strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
tech_pvt->interface_state = SKYPIAX_STATE_DOWN; tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
tech_pvt->skype_call_id[0] = '\0'; tech_pvt->skype_call_id[0] = '\0';
return CALLFLOW_INCOMING_HANGUP; return CALLFLOW_INCOMING_HANGUP;
@ -347,31 +354,34 @@ int skypiax_signaling_read(private_t * tech_pvt)
DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id); DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
} }
} else if (!strcasecmp(value, "TRANSFERRING")) { } else if (!strcasecmp(value, "TRANSFERRING")) {
DEBUGA_SKYPE("skype_call %s is transferring\n", SKYPIAX_P_LOG, id); DEBUGA_SKYPE("skype_call %s is transferring\n", SKYPIAX_P_LOG, id);
} else if (!strcasecmp(value, "TRANSFERRED")) { } else if (!strcasecmp(value, "TRANSFERRED")) {
DEBUGA_SKYPE("skype_call %s has been transferred\n", SKYPIAX_P_LOG, id); DEBUGA_SKYPE("skype_call %s has been transferred\n", SKYPIAX_P_LOG, id);
} else if (!strcasecmp(value, "ROUTING")) { } else if (!strcasecmp(value, "ROUTING")) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING; tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
tech_pvt->interface_state = SKYPIAX_STATE_DIALING; tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
skypiax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); skypiax_strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id); DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id);
} else if (!strcasecmp(value, "UNPLACED")) { } else if (!strcasecmp(value, "UNPLACED")) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED; tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED;
tech_pvt->interface_state = SKYPIAX_STATE_DIALING; tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
skypiax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); skypiax_strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
} else if (!strcasecmp(value, "INPROGRESS")) { } else if (!strcasecmp(value, "INPROGRESS")) {
char msg_to_skype[1024]; char msg_to_skype[1024];
if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id) if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id)
|| !strcasecmp(tech_pvt->skype_call_id, id)) { || !strcasecmp(tech_pvt->skype_call_id, id)) {
skypiax_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); skypiax_strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) { if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
tech_pvt->interface_state = SKYPIAX_STATE_UP; tech_pvt->interface_state = SKYPIAX_STATE_UP;
start_audio_threads(tech_pvt); start_audio_threads(tech_pvt);
skypiax_sleep(1000); skypiax_sleep(1000);
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
tech_pvt->tcp_cli_port); tech_pvt->tcp_cli_port);
skypiax_signaling_write(tech_pvt, msg_to_skype); skypiax_signaling_write(tech_pvt, msg_to_skype);
@ -495,7 +505,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
if (rt > 0) { if (rt > 0) {
#ifdef FARMING #ifdef FARMING
switch_sleep(500); //seems that reconnecting through a proxy leads to half the packet size, bizarrely, 158-162, never 160 :-) switch_sleep(500); //seems that reconnecting through a proxy leads to half the packet size, bizarrely, 158-162, never 160 :-)
#endif // FARMING #endif // FARMING
len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
@ -790,6 +800,7 @@ int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany)
return howmany; return howmany;
} }
int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany) int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany)
{ {
switch_size_t quantity; switch_size_t quantity;
@ -802,6 +813,7 @@ int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany)
return howmany; return howmany;
} }
int skypiax_close_socket(unsigned int fd) int skypiax_close_socket(unsigned int fd)
{ {
int res; int res;
@ -828,11 +840,13 @@ int skypiax_pipe_read(int pipe, short *buf, int howmany)
howmany = read(pipe, buf, howmany); howmany = read(pipe, buf, howmany);
return howmany; return howmany;
} }
int skypiax_pipe_write(int pipe, short *buf, int howmany) int skypiax_pipe_write(int pipe, short *buf, int howmany)
{ {
howmany = write(pipe, buf, howmany); howmany = write(pipe, buf, howmany);
return howmany; return howmany;
} }
int skypiax_close_socket(unsigned int fd) int skypiax_close_socket(unsigned int fd)
{ {
int res; int res;
@ -966,7 +980,7 @@ LRESULT APIENTRY skypiax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
memset(msg_from_skype, '\0', sizeof(msg_from_skype)); memset(msg_from_skype, '\0', sizeof(msg_from_skype));
skypiax_strncpy(msg_from_skype, (const char *) poCopyData->lpData, skypiax_strncpy(msg_from_skype, (const char *) poCopyData->lpData,
sizeof(msg_from_skype) - 2); sizeof(msg_from_skype) - 2);
howmany = strlen(msg_from_skype) + 1; howmany = strlen(msg_from_skype) + 1;
howmany = howmany =
@ -995,8 +1009,8 @@ LRESULT APIENTRY skypiax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
skypiax_sleep(5000); skypiax_sleep(5000);
if (!tech_pvt->SkypiaxHandles.currentuserhandle) { if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
SendMessage(HWND_BROADCAST, SendMessage(HWND_BROADCAST,
tech_pvt->SkypiaxHandles. tech_pvt->
win32_uiGlobal_MsgID_SkypeControlAPIDiscover, SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
(WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
0); 0);
} }
@ -1012,8 +1026,8 @@ LRESULT APIENTRY skypiax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
skypiax_sleep(5000); skypiax_sleep(5000);
if (!tech_pvt->SkypiaxHandles.currentuserhandle) { if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
SendMessage(HWND_BROADCAST, SendMessage(HWND_BROADCAST,
tech_pvt->SkypiaxHandles. tech_pvt->
win32_uiGlobal_MsgID_SkypeControlAPIDiscover, SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
(WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
0); 0);
} }
@ -1072,7 +1086,7 @@ int win32_Initialize_CreateWindowClass(private_t * tech_pvt)
} }
if (fReturnStatus == 0) if (fReturnStatus == 0)
CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle); CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle);
tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL; tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
return (fReturnStatus); return (fReturnStatus);
} }
@ -1081,7 +1095,7 @@ void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt)
UnregisterClass(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, UnregisterClass(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName,
tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle); tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle);
CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle); CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle);
tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL; tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
} }
int win32_Initialize_CreateMainWindow(private_t * tech_pvt) int win32_Initialize_CreateMainWindow(private_t * tech_pvt)
@ -1183,11 +1197,11 @@ static int X11_errors_untrap(void)
#ifdef FARMING #ifdef FARMING
int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P) int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
{ {
printf("%s\n", message_P); printf("%s\n", message_P);
fflush(stdout); fflush(stdout);
return 1; return 1;
} }
#else// FARMING #else // FARMING
int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P) int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
{ {
@ -1236,7 +1250,7 @@ int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *mess
return 1; return 1;
} }
#endif// FARMING #endif // FARMING
int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype) int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype)
{ {
struct SkypiaxHandles *SkypiaxHandles; struct SkypiaxHandles *SkypiaxHandles;
@ -1336,23 +1350,22 @@ void *skypiax_do_skypeapi_thread_func(void *obj)
} }
SkypiaxHandles = &tech_pvt->SkypiaxHandles; SkypiaxHandles = &tech_pvt->SkypiaxHandles;
SkypiaxHandles->api_connected = 1; SkypiaxHandles->api_connected = 1;
char *b; char *b;
unsigned int howmany; unsigned int howmany;
while (1) { while (1) {
char s[17000]; char s[17000];
memset(s, '\0', 17000); memset(s, '\0', 17000);
b=fgets(s, sizeof(s) - 1, stdin); b = fgets(s, sizeof(s) - 1, stdin);
s[strlen(s) - 1] = '\0'; s[strlen(s) - 1] = '\0';
howmany = strlen(s) + 1; howmany = strlen(s) + 1;
howmany = write(SkypiaxHandles->fdesc[1], &s, howmany); howmany = write(SkypiaxHandles->fdesc[1], &s, howmany);
} }
} }
#else //FARMING #else //FARMING