SWITCH_STANDARD_API(skypiax_function);
#define SKYPIAX_SYNTAX "interface_name skype_API_msg"
+SWITCH_STANDARD_API(skypiax_chat_function);
+#define SKYPIAX_CHAT_SYNTAX "interface_name remote_skypename TEXT"
/* BEGIN: Changes here */
#define FULL_RELOAD 0
#define SOFT_RELOAD 1
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, "skypiax_chat", "Skypiax_chat interface remote_skypename TEXT", skypiax_chat_function, SKYPIAX_CHAT_SYNTAX);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
return SWITCH_STATUS_SUCCESS;
}
+SWITCH_STANDARD_API(skypiax_chat_function)
+{
+ char *mycmd = NULL, *argv[10] = { 0 };
+ int argc = 0;
+ private_t *tech_pvt = NULL;
+ int tried =0;
+ int i;
+ int found = 0;
+ char skype_msg[1024];
+
+ 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_CHAT_SYNTAX);
+ goto end;
+ }
+
+ if (argc < 3) {
+ stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_CHAT_SYNTAX);
+ goto end;
+ }
+
+ if (argv[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]);
+ goto end;
+ } else {
+ char skype_msg[256];
+ //NOTICA("TEXT is: %s\n", SKYPIAX_P_LOG, (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1] );
+ snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", argv[1]);
+ skypiax_signaling_write(tech_pvt, skype_msg);
+ usleep(100);
+ }
+ } else {
+ stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_CHAT_SYNTAX);
+ }
+
+
+ found=0;
+
+ while(!found){
+ for(i=0; i<MAX_CHATS; i++){
+ if(!strcmp(tech_pvt->chats[i].dialog_partner, argv[1]) ){
+ snprintf(skype_msg, sizeof(skype_msg), "CHATMESSAGE %s %s", tech_pvt->chats[i].chatname, (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]);
+ skypiax_signaling_write(tech_pvt, skype_msg);
+ found=1;
+ break;
+ }
+ }
+ if(found){
+ break;
+ }
+ if(tried > 1000){
+ stream->write_function(stream, "ERROR: no chat with dialog_partner='%s' was not found\n", argv[1]);
+ break;
+ }
+ usleep(1000);
+ }
+
+end:
+ switch_safe_free(mycmd);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
SWITCH_STANDARD_API(skypiax_function)
{
skypiax_signaling_write(tech_pvt, msg_to_skype);
}
}
- if (!strcasecmp(message, "CHATMESSAGE")) {
+ if (!strcasecmp(message, "CHAT")) {
char msg_to_skype[256];
int i;
int found;
skypiax_strncpy(id, where, sizeof(id) - 1);
where = strsep(stringp, " ");
skypiax_strncpy(prop, where, sizeof(prop) - 1);
- //where = strsep(stringp, " ");
skypiax_strncpy(value, *stringp, sizeof(value) - 1);
- //where = strsep(stringp, " ");
- //ERRORA ("Skype MSG, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", SKYPIAX_P_LOG, obj, id, prop, value, where ? where : "NULL");
+ if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "DIALOG")) {
+ DEBUGA_SKYPE("CHAT %s is DIALOG\n", SKYPIAX_P_LOG, id);
+ sprintf(msg_to_skype, "GET CHAT %s DIALOG_PARTNER", id);
+ skypiax_signaling_write(tech_pvt, msg_to_skype);
+ }
+
+ if (!strcasecmp(prop, "DIALOG_PARTNER")) {
+ DEBUGA_SKYPE("CHAT %s has DIALOG_PARTNER %s\n", SKYPIAX_P_LOG, id, value);
+ found=0;
+ for(i=0; i<MAX_CHATS; i++){
+ if(strlen(tech_pvt->chats[i].chatname) == 0 || !strcmp(tech_pvt->chats[i].chatname, id) ){
+ strncpy(tech_pvt->chats[i].chatname, id, sizeof(tech_pvt->chats[i].chatname));
+ strncpy(tech_pvt->chats[i].dialog_partner, value, sizeof(tech_pvt->chats[i].dialog_partner));
+ found=1;
+ break;
+ }
+ }
+ if(!found){
+ ERRORA("why we do not have a chats slot free? we have more than %d chats in parallel?\n", SKYPIAX_P_LOG, MAX_CHATS);
+ }
+
+ DEBUGA_SKYPE("CHAT %s is in position %d in the chats array, chatname=%s, dialog_partner=%s\n", SKYPIAX_P_LOG, id, i, tech_pvt->chats[i].chatname, tech_pvt->chats[i].dialog_partner);
+ }
+
+ }
+
+
+ if (!strcasecmp(message, "CHATMESSAGE")) {
+ char msg_to_skype[256];
+ int i;
+ int found;
+
+ skypiax_strncpy(obj, where, sizeof(obj) - 1);
+ where = strsep(stringp, " ");
+ skypiax_strncpy(id, where, sizeof(id) - 1);
+ where = strsep(stringp, " ");
+ skypiax_strncpy(prop, where, sizeof(prop) - 1);
+ skypiax_strncpy(value, *stringp, sizeof(value) - 1);
if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) {
- NOTICA("RECEIVED CHATMESSAGE %s, let's see which type it is\n", SKYPIAX_P_LOG, id);
+ DEBUGA_SKYPE("RECEIVED CHATMESSAGE %s, let's see which type it is\n", SKYPIAX_P_LOG, id);
sprintf(msg_to_skype, "GET CHATMESSAGE %s TYPE", id);
skypiax_signaling_write(tech_pvt, msg_to_skype);
}
if (!strcasecmp(prop, "TYPE") && !strcasecmp(value, "SAID")) {
- NOTICA("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPIAX_P_LOG, id);
+ DEBUGA_SKYPE("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPIAX_P_LOG, id);
found=0;
for(i=0; i<MAX_CHATMESSAGES; i++){
if(strlen(tech_pvt->chatmessages[i].id) == 0){
if(!found){
ERRORA("why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n", SKYPIAX_P_LOG, MAX_CHATMESSAGES);
} else {
- NOTICA("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPIAX_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id);
+ DEBUGA_SKYPE("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPIAX_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id);
sprintf(msg_to_skype, "GET CHATMESSAGE %s CHATNAME", id);
skypiax_signaling_write(tech_pvt, msg_to_skype);
skypiax_sleep(100);
}
if (!strcasecmp(prop, "CHATNAME")) {
- NOTICA("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPIAX_P_LOG, id, value);
+ DEBUGA_SKYPE("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPIAX_P_LOG, id, value);
found=0;
for(i=0; i<MAX_CHATMESSAGES; i++){
if(!strcmp(tech_pvt->chatmessages[i].id, id)){
}
}
if (!strcasecmp(prop, "FROM_HANDLE")) {
- NOTICA("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPIAX_P_LOG, id, value);
+ DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPIAX_P_LOG, id, value);
found=0;
for(i=0; i<MAX_CHATMESSAGES; i++){
if(!strcmp(tech_pvt->chatmessages[i].id, id)){
}
if (!strcasecmp(prop, "FROM_DISPNAME")) {
- NOTICA("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPIAX_P_LOG, id, value);
+ DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPIAX_P_LOG, id, value);
found=0;
for(i=0; i<MAX_CHATMESSAGES; i++){
if(!strcmp(tech_pvt->chatmessages[i].id, id)){
}
if (!strcasecmp(prop, "BODY")) {
- NOTICA("CHATMESSAGE %s has BODY %s\n", SKYPIAX_P_LOG, id, value);
+ DEBUGA_SKYPE("CHATMESSAGE %s has BODY %s\n", SKYPIAX_P_LOG, id, value);
found=0;
for(i=0; i<MAX_CHATMESSAGES; i++){
if(!strcmp(tech_pvt->chatmessages[i].id, id)){