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

@ -1044,14 +1044,15 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
skypiax_endpoint_interface->io_routines = &skypiax_io_routines;
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, "skypiax", "Skypiax interface commands", skypiax_function, SKYPIAX_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 */
return SWITCH_STATUS_SUCCESS;
}
else
} else
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);
}
void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj)
{
return skypiax_do_tcp_cli_thread_func(obj);
}
void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj)
{
return skypiax_do_skypeapi_thread_func(obj);
@ -1350,11 +1353,10 @@ SWITCH_STANDARD_API(sk_function)
char *mycmd = NULL, *argv[10] = { 0 };
int argc = 0;
if(globals.sk_console)
stream->write_function(stream,"sk console is: |||%s|||\n", globals.sk_console->name);
if (globals.sk_console)
stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name);
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])));
@ -1370,48 +1372,55 @@ SWITCH_STANDARD_API(sk_function)
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);
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);
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;
int found = 0;
if (argc == 2) {
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[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);
&& (strncmp(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;
}
}
if(!found)
stream->write_function(stream,"ERROR: A Skypiax interface with name='%s' was not found\n", argv[1]);
if (!found)
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");
goto end;
}
} else if (!strcasecmp(argv[0], "ciapalino")) {
} else {
if(globals.sk_console)
skypiax_signaling_write(globals.sk_console, (char *)cmd);
if (globals.sk_console)
skypiax_signaling_write(globals.sk_console, (char *) cmd);
else
stream->write_function(stream,"sk console is NOT yet assigned\n");
stream->write_function(stream, "sk console is NOT yet assigned\n");
}
end:
switch_safe_free(mycmd);
@ -1423,8 +1432,7 @@ SWITCH_STANDARD_API(skypiax_function)
{
char *mycmd = NULL, *argv[10] = { 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])));
@ -1442,29 +1450,30 @@ SWITCH_STANDARD_API(skypiax_function)
if (argv[0]) {
int i;
int found =0;
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);
&& (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]);
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 ] );
skypiax_signaling_write(tech_pvt, (char *) &cmd[strlen(argv[0]) + 1]);
}
} else {
stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_SYNTAX);
@ -1475,9 +1484,6 @@ end:
return SWITCH_STATUS_SUCCESS;
}
/* For Emacs:
* Local Variables:
* 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");
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
("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n",
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(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
("We called a Skype contact and he answered us on skype_call: %s.\n",
SKYPIAX_P_LOG, id);
@ -234,7 +236,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
skypiax_signaling_write(tech_pvt, msg_to_skype);
DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", 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);
} else {
/* we're owned, we're in a call, let's try to transfer */
/************************** TODO
@ -251,7 +254,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
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",
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,
available_skypiax_interface->skype_user);
} else {
@ -271,7 +275,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
/* we are calling out */
tech_pvt->skype_callflow = CALLFLOW_STATUS_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",
SKYPIAX_P_LOG, id);
remote_party_is_ringing(tech_pvt);
@ -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",
SKYPIAX_P_LOG, id);
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;
return CALLFLOW_INCOMING_HANGUP;
} else if (!strcasecmp(value, "REFUSED")) {
@ -338,7 +344,8 @@ int skypiax_signaling_read(private_t * tech_pvt)
DEBUGA_SKYPE
("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
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->skype_call_id[0] = '\0';
return CALLFLOW_INCOMING_HANGUP;
@ -353,19 +360,22 @@ int skypiax_signaling_read(private_t * tech_pvt)
} else if (!strcasecmp(value, "ROUTING")) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
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);
} else if (!strcasecmp(value, "UNPLACED")) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED;
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);
} else if (!strcasecmp(value, "INPROGRESS")) {
char msg_to_skype[1024];
if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_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);
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
@ -790,6 +800,7 @@ int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany)
return howmany;
}
int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany)
{
switch_size_t quantity;
@ -802,6 +813,7 @@ int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany)
return howmany;
}
int skypiax_close_socket(unsigned int fd)
{
int res;
@ -828,11 +840,13 @@ int skypiax_pipe_read(int pipe, short *buf, int howmany)
howmany = read(pipe, buf, howmany);
return howmany;
}
int skypiax_pipe_write(int pipe, short *buf, int howmany)
{
howmany = write(pipe, buf, howmany);
return howmany;
}
int skypiax_close_socket(unsigned int fd)
{
int res;
@ -995,8 +1009,8 @@ LRESULT APIENTRY skypiax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
skypiax_sleep(5000);
if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
SendMessage(HWND_BROADCAST,
tech_pvt->SkypiaxHandles.
win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
tech_pvt->
SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
(WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
0);
}
@ -1012,8 +1026,8 @@ LRESULT APIENTRY skypiax_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
skypiax_sleep(5000);
if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
SendMessage(HWND_BROADCAST,
tech_pvt->SkypiaxHandles.
win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
tech_pvt->
SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
(WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
0);
}
@ -1187,7 +1201,7 @@ int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *mess
fflush(stdout);
return 1;
}
#else// FARMING
#else // FARMING
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;
}
#endif// FARMING
#endif // FARMING
int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype)
{
struct SkypiaxHandles *SkypiaxHandles;
@ -1336,7 +1350,6 @@ void *skypiax_do_skypeapi_thread_func(void *obj)
}
SkypiaxHandles = &tech_pvt->SkypiaxHandles;
SkypiaxHandles->api_connected = 1;
char *b;
@ -1346,7 +1359,7 @@ void *skypiax_do_skypeapi_thread_func(void *obj)
char s[17000];
memset(s, '\0', 17000);
b=fgets(s, sizeof(s) - 1, stdin);
b = fgets(s, sizeof(s) - 1, stdin);
s[strlen(s) - 1] = '\0';
howmany = strlen(s) + 1;