Freeswitch-branches
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
February 2009
- 5 participants
- 71 discussions
Author: gmaruzz
Date: Mon Feb 9 12:26:31 2009
New Revision: 11715
Log:
skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 12:26:31 2009
@@ -352,8 +352,7 @@
DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
- if (!strcasecmp(message, "ERROR 68")) { /* not yet protocol specified,
- just authorized */
+ if (!strcasecmp(message, "ERROR 68")) {
DEBUGA_SKYPE
("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
SKYPIAX_P_LOG);
@@ -386,25 +385,6 @@
if (!where) {
WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message);
}
-
- if (!strcasecmp(message, "#333")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[11]); */
- memset(tech_pvt->skype_friends, 0, 4096);
- strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
- }
- if (!strcasecmp(message, "#222")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[10]); */
- memset(tech_pvt->skype_fullname, 0, 512);
- strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
- }
- if (!strcasecmp(message, "#765")) {
- /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
- * message_2, &message_2[10]); */
- memset(tech_pvt->skype_displayname, 0, 512);
- strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
- }
if (!strcasecmp(message, "ERROR")) {
ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
@@ -716,6 +696,26 @@
} //CALL
+ /* the "numbered" messages that follows are used by the directory application, not yet ported */
+ if (!strcasecmp(message, "#333")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[11]); */
+ memset(tech_pvt->skype_friends, 0, 4096);
+ strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
+ }
+ if (!strcasecmp(message, "#222")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
+ memset(tech_pvt->skype_fullname, 0, 512);
+ strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
+ }
+ if (!strcasecmp(message, "#765")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
+ memset(tech_pvt->skype_displayname, 0, 512);
+ strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
+ }
+
a = 0;
} //message end
} //read_from_pipe
1
0
Author: gmaruzz
Date: Mon Feb 9 12:10:52 2009
New Revision: 11714
Log:
skypiax: cleaning skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 12:10:52 2009
@@ -327,53 +327,32 @@
{
char read_from_pipe[4096];
- char messaggio[4096];
- char messaggio_2[4096];
+ char message[4096];
+ char message_2[4096];
char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
char **stringp = NULL;
- int rt;
int a;
unsigned int howmany;
unsigned int i;
-#ifndef WIN32
- int fdselect;
- fd_set fs;
- struct timeval to;
-#endif /* WIN32 */
memset(read_from_pipe, 0, 4096);
- memset(messaggio, 0, 4096);
- memset(messaggio_2, 0, 4096);
+ memset(message, 0, 4096);
+ memset(message_2, 0, 4096);
-#ifdef WIN32
- rt = 1;
-#else /* WIN32 */
- fdselect = tech_pvt->SkypiaxHandles.fdesc[0];
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //500 msec
- to.tv_sec = 0;
- rt = select(fdselect + 1, &fs, NULL, NULL, &to);
-#endif /* WIN32 */
-
- if (rt > 0) {
- if (tech_pvt->SkypiaxHandles.fdesc[0]) {
- howmany = sizeof(read_from_pipe);
howmany =
skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe,
- howmany);
+ sizeof(read_from_pipe));
a = 0;
for (i = 0; i < howmany; i++) {
- messaggio[a] = read_from_pipe[i];
+ message[a] = read_from_pipe[i];
a++;
if (read_from_pipe[i] == '\0') {
- //DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio);
- DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, messaggio);
+ DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, message);
- if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
+ if (!strcasecmp(message, "ERROR 68")) { /* not yet protocol specified,
just authorized */
DEBUGA_SKYPE
("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
@@ -384,9 +363,9 @@
return 0;
}
- if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
+ if (!strncasecmp(message, "ERROR 92 CALL", 12)) {
ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
- SKYPIAX_P_LOG, messaggio);
+ SKYPIAX_P_LOG, message);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
@@ -399,35 +378,35 @@
}
}
- strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1);
+ strncpy(message_2, message, sizeof(message) - 1);
- buf = messaggio;
+ buf = message;
stringp = &buf;
where = strsep(stringp, " ");
if (!where) {
- WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio);
+ WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, message);
}
- if (!strcasecmp(messaggio, "#333")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[11]); */
+ if (!strcasecmp(message, "#333")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[11]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[11]); */
memset(tech_pvt->skype_friends, 0, 4096);
- strncpy(tech_pvt->skype_friends, &messaggio_2[11], 4095);
+ strncpy(tech_pvt->skype_friends, &message_2[11], 4095);
}
- if (!strcasecmp(messaggio, "#222")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[10]); */
+ if (!strcasecmp(message, "#222")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
memset(tech_pvt->skype_fullname, 0, 512);
- strncpy(tech_pvt->skype_fullname, &messaggio_2[10], 511);
+ strncpy(tech_pvt->skype_fullname, &message_2[10], 511);
}
- if (!strcasecmp(messaggio, "#765")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[10]); */
+ if (!strcasecmp(message, "#765")) {
+ /* DEBUGA_SKYPE("Skype MSG: message_2: %s, message2[10]: %s\n", SKYPIAX_P_LOG,
+ * message_2, &message_2[10]); */
memset(tech_pvt->skype_displayname, 0, 512);
- strncpy(tech_pvt->skype_displayname, &messaggio_2[10], 511);
+ strncpy(tech_pvt->skype_displayname, &message_2[10], 511);
}
- if (!strcasecmp(messaggio, "ERROR")) {
- ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
+ if (!strcasecmp(message, "ERROR")) {
+ ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, message);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
@@ -439,7 +418,7 @@
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
}
}
- if (!strcasecmp(messaggio, "CURRENTUSERHANDLE")) {
+ if (!strcasecmp(message, "CURRENTUSERHANDLE")) {
strncpy(obj, where, sizeof(obj) - 1);
where = strsep(stringp, " ");
@@ -449,12 +428,12 @@
if (!strcasecmp(id, tech_pvt->skype_user)) {
tech_pvt->SkypiaxHandles.api_connected = 1;
DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user);
+ ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user);
}
}
- if (!strcasecmp(messaggio, "USER")) {
+ if (!strcasecmp(message, "USER")) {
strncpy(obj, where, sizeof(obj) - 1);
where = strsep(stringp, " ");
@@ -467,8 +446,8 @@
if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
char msg_to_skype[256];
- DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop);
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop);
//FIXME: TODO: allow authorization based on config param
sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
@@ -476,7 +455,7 @@
}
}
- if (!strcasecmp(messaggio, "MESSAGE")) {
+ if (!strcasecmp(message, "MESSAGE")) {
strncpy(obj, where, sizeof(obj) - 1);
where = strsep(stringp, " ");
@@ -496,8 +475,8 @@
if (!strcasecmp(value, "RECEIVED")) {
char msg_to_skype[256];
DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s value: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop, value);
+ ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop, value);
//FIXME: TODO: allow authorization based on config param
sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
@@ -506,8 +485,8 @@
} else if (!strcasecmp(prop, "BODY")) {
char msg_to_skype[256];
- DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop);
+ DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop);
//FIXME: TODO: on config param ???
sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
@@ -516,7 +495,7 @@
}
- if (!strcasecmp(messaggio, "CALL")) {
+ if (!strcasecmp(message, "CALL")) {
strncpy(obj, where, sizeof(obj) - 1);
@@ -535,8 +514,8 @@
where = strsep(stringp, " ");
DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
+ ("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
+ SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : "NULL");
if (!strcasecmp(prop, "PARTNER_HANDLE")) {
strncpy(tech_pvt->callid_number, value,
@@ -741,8 +720,6 @@
} //message end
} //read_from_pipe
- }
- }
return 0;
}
1
0
Author: gmaruzz
Date: Mon Feb 9 11:35:00 2009
New Revision: 11712
Log:
skypiax: skypiax_protocol.c indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 11:35:00 2009
@@ -230,13 +230,13 @@
if (!running)
break;
- fdselect = fd;
+ fdselect = fd;
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
to.tv_usec = 2000000; //2000 msec
to.tv_sec = 0;
- rt = select(fdselect + 1, NULL, &fs, NULL, &to);
+ rt = select(fdselect + 1, NULL, &fs, NULL, &to);
if (rt > 0) {
@@ -246,7 +246,7 @@
SAMPLES_PER_FRAME * sizeof(short));
if (got != SAMPLES_PER_FRAME * sizeof(short)) {
WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
- SAMPLES_PER_FRAME * sizeof(short));
+ SAMPLES_PER_FRAME * sizeof(short));
}
if (got == SAMPLES_PER_FRAME * sizeof(short)) {
@@ -284,7 +284,7 @@
} else {
WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
- SAMPLES_PER_FRAME * sizeof(short));
+ SAMPLES_PER_FRAME * sizeof(short));
}
} else {
if (rt)
@@ -307,17 +307,19 @@
{
unsigned int samples;
- samples =
- skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short));
-
- if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
- if (samples)
- WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short));
- return 0;
- } else {
- /* A real frame */
- tech_pvt->read_frame.datalen = samples;
- }
+ samples =
+ skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data,
+ SAMPLES_PER_FRAME * sizeof(short));
+
+ if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
+ if (samples)
+ WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples,
+ SAMPLES_PER_FRAME * sizeof(short));
+ return 0;
+ } else {
+ /* A real frame */
+ tech_pvt->read_frame.datalen = samples;
+ }
return 1;
}
@@ -339,7 +341,6 @@
struct timeval to;
#endif /* WIN32 */
-
memset(read_from_pipe, 0, 4096);
memset(messaggio, 0, 4096);
memset(messaggio_2, 0, 4096);
@@ -387,7 +388,7 @@
ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
SKYPIAX_P_LOG, messaggio);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
@@ -428,7 +429,7 @@
if (!strcasecmp(messaggio, "ERROR")) {
ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
@@ -533,9 +534,9 @@
where = strsep(stringp, " ");
- DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
+ DEBUGA_SKYPE
+ ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
if (!strcasecmp(prop, "PARTNER_HANDLE")) {
strncpy(tech_pvt->callid_number, value,
@@ -579,9 +580,9 @@
if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
if (strcasecmp(id, tech_pvt->skype_call_id)) {
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);
+ DEBUGA_SKYPE
+ ("We called a Skype contact and he answered us on skype_call: %s.\n",
+ SKYPIAX_P_LOG, id);
}
}
@@ -609,8 +610,8 @@
skypiax_sleep(10000);
sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
skypiax_skype_write(tech_pvt, msg_to_skype);
- DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
- SKYPIAX_P_LOG, id);
+ DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
+ SKYPIAX_P_LOG, id);
strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
} else {
@@ -644,7 +645,7 @@
} else if (!strcasecmp(value, "FINISHED")) {
//tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
+ DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
tech_pvt->skype_call_id[0] = '\0';
if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
@@ -656,9 +657,9 @@
} else if (!strcasecmp(value, "CANCELLED")) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
- SKYPIAX_P_LOG, id);
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
+ SKYPIAX_P_LOG, id);
tech_pvt->skype_call_id[0] = '\0';
if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
@@ -669,9 +670,9 @@
}
} else if (!strcasecmp(value, "FAILED")) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
- SKYPIAX_P_LOG, id);
+ DEBUGA_SKYPE
+ ("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';
strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
@@ -680,9 +681,9 @@
if (!strcasecmp(id, tech_pvt->skype_call_id)) {
/* this is the id of the call we are in, probably we generated it */
tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
- SKYPIAX_P_LOG, id);
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
+ SKYPIAX_P_LOG, id);
strncpy(tech_pvt->skype_call_id, id,
sizeof(tech_pvt->skype_call_id) - 1);
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
@@ -708,7 +709,7 @@
tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
tech_pvt->interface_state = SKYPIAX_STATE_UP;
- 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);
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
tech_pvt->tcp_cli_port);
skypiax_skype_write(tech_pvt, msg_to_skype);
@@ -815,6 +816,7 @@
return res;
}
+
int skypiax_skypeaudio_init(private_t * tech_pvt)
{
switch_status_t rv;
@@ -845,6 +847,7 @@
return res;
}
+
int skypiax_skypeaudio_init(private_t * tech_pvt)
{
if (pipe(tech_pvt->audiopipe)) {
@@ -863,7 +866,6 @@
}
#endif /* WIN32 */
-
#ifdef WIN32
enum {
@@ -917,7 +919,7 @@
DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
sprintf(acInputRow, "%s", msg_to_skype);
- DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow);
+ DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow);
/* send command to skype */
oCopyData.dwData = 0;
oCopyData.lpData = acInputRow;
@@ -1105,7 +1107,6 @@
tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
}
-
void *skypiax_do_skypeapi_thread_func(void *obj)
{
private_t *tech_pvt = obj;
@@ -1250,7 +1251,6 @@
}
-
int skypiax_skype_present(struct SkypiaxHandles *SkypiaxHandles)
{
Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True);
@@ -1316,7 +1316,6 @@
Window root = -1;
Window win = -1;
-
if (!strlen(tech_pvt->X11_display))
strcpy(tech_pvt->X11_display, getenv("DISPLAY"));
@@ -1428,5 +1427,3 @@
}
#endif // WIN32
-
-
1
0
Author: gmaruzz
Date: Mon Feb 9 11:34:30 2009
New Revision: 11711
Log:
skypiax: cleaning skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 11:34:30 2009
@@ -303,34 +303,6 @@
return NULL;
}
-int skypiax_skypeaudio_init(private_t * tech_pvt)
-{
-
-#if defined(WIN32) && !defined(__CYGWIN__)
- switch_status_t rv;
- rv =
- switch_file_pipe_create(&tech_pvt->audiopipe[0], &tech_pvt->audiopipe[1],
- skypiax_module_pool);
- rv =
- switch_file_pipe_create(&tech_pvt->audioskypepipe[0], &tech_pvt->audioskypepipe[1],
- skypiax_module_pool);
-#else /* WIN32 */
- if (pipe(tech_pvt->audiopipe)) {
- fcntl(tech_pvt->audiopipe[0], F_SETFL, O_NONBLOCK);
- fcntl(tech_pvt->audiopipe[1], F_SETFL, O_NONBLOCK);
- }
- if (pipe(tech_pvt->audioskypepipe)) {
- fcntl(tech_pvt->audioskypepipe[0], F_SETFL, O_NONBLOCK);
- fcntl(tech_pvt->audioskypepipe[1], F_SETFL, O_NONBLOCK);
- }
-#endif /* WIN32 */
-
-/* this pipe is the audio fd for asterisk to poll on during a call. FS do not use it */
- tech_pvt->skypiax_sound_capt_fd = tech_pvt->audiopipe[0];
-
- return 0;
-}
-
int skypiax_skypeaudio_read(private_t * tech_pvt)
{
unsigned int samples;
@@ -843,7 +815,17 @@
return res;
}
-
+int skypiax_skypeaudio_init(private_t * tech_pvt)
+{
+ switch_status_t rv;
+ rv =
+ switch_file_pipe_create(&tech_pvt->audiopipe[0], &tech_pvt->audiopipe[1],
+ skypiax_module_pool);
+ rv =
+ switch_file_pipe_create(&tech_pvt->audioskypepipe[0], &tech_pvt->audioskypepipe[1],
+ skypiax_module_pool);
+ return 0;
+}
#else /* WIN32 */
int skypiax_pipe_read(int pipe, short *buf, int howmany)
{
@@ -863,6 +845,22 @@
return res;
}
+int skypiax_skypeaudio_init(private_t * tech_pvt)
+{
+ if (pipe(tech_pvt->audiopipe)) {
+ fcntl(tech_pvt->audiopipe[0], F_SETFL, O_NONBLOCK);
+ fcntl(tech_pvt->audiopipe[1], F_SETFL, O_NONBLOCK);
+ }
+ if (pipe(tech_pvt->audioskypepipe)) {
+ fcntl(tech_pvt->audioskypepipe[0], F_SETFL, O_NONBLOCK);
+ fcntl(tech_pvt->audioskypepipe[1], F_SETFL, O_NONBLOCK);
+ }
+
+/* this pipe is the audio fd for asterisk to poll on during a call. FS do not use it */
+ tech_pvt->skypiax_sound_capt_fd = tech_pvt->audiopipe[0];
+
+ return 0;
+}
#endif /* WIN32 */
1
0
Author: gmaruzz
Date: Mon Feb 9 11:25:07 2009
New Revision: 11710
Log:
skypiax: cleaning on Visual C
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Mon Feb 9 11:25:07 2009
@@ -948,8 +948,6 @@
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
{
- private_t *tech_pvt = NULL; //for logging
-
skypiax_module_pool = pool;
memset(&globals, '\0', sizeof(globals));
1
0
Author: gmaruzz
Date: Mon Feb 9 11:23:01 2009
New Revision: 11709
Log:
skypiax: cleaning skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c Mon Feb 9 11:23:01 2009
@@ -25,7 +25,6 @@
switch_mutex_t *mutex;
} globals;
-int option_debug = 100;
switch_endpoint_interface_t *skypiax_endpoint_interface;
switch_memory_pool_t *skypiax_module_pool = NULL;
int running = 0;
@@ -95,7 +94,6 @@
void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session)
{
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
tech_pvt->read_frame.data = tech_pvt->databuf;
tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED,
@@ -111,7 +109,6 @@
DEBUGA_SKYPE("skypiax_codec SUCCESS\n", SKYPIAX_P_LOG);
}
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
/*
@@ -585,7 +582,6 @@
int res;
int forever = 1;
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
DEBUGA_SKYPE("In skypiax_signaling_thread_func: started, p=%p\n", SKYPIAX_P_LOG,
(void *) tech_pvt);
@@ -623,7 +619,6 @@
memset(tech_pvt->session_uuid_str, '\0', sizeof(tech_pvt->session_uuid_str));
}
}
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
@@ -971,7 +966,6 @@
skypiax_endpoint_interface->io_routines = &skypiax_io_routines;
skypiax_endpoint_interface->state_handler = &skypiax_state_handlers;
- DEBUGA_SKYPE("EXITING FUNC!\n", SKYPIAX_P_LOG);
if(running)
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 11:23:01 2009
@@ -11,10 +11,10 @@
extern switch_endpoint_interface_t *skypiax_endpoint_interface;
#endif /* ASTERISK */
-extern int option_debug;
extern int running;
/*************************************/
+/* suspicious globals FIXME */
#ifdef WIN32
DWORD win32_dwThreadId;
#else
@@ -45,9 +45,6 @@
short kill_cli_buff[SAMPLES_PER_FRAME];
short totalbuf[SAMPLES_PER_FRAME];
- if (option_debug > 100) {
- DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
@@ -55,17 +52,11 @@
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ERRORA("socket Error\n", SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
ERRORA("bind Error\n", SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
@@ -183,9 +174,6 @@
DEBUGA_SKYPE("incoming audio server (I am it) GONE\n", SKYPIAX_P_LOG);
skypiax_close_socket(s);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
@@ -208,9 +196,6 @@
unsigned int sin_size;
#endif /* WIN32 */
- if (option_debug > 100) {
- DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
@@ -218,17 +203,11 @@
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ERRORA("socket Error\n", SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
ERRORA("bind Error\n", SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
skypiax_close_socket(s);
return NULL;
}
@@ -321,9 +300,6 @@
DEBUGA_SKYPE("outbound audio server (I am it) GONE\n", SKYPIAX_P_LOG);
skypiax_close_socket(s);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
@@ -391,9 +367,6 @@
struct timeval to;
#endif /* WIN32 */
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
memset(read_from_pipe, 0, 4096);
memset(messaggio, 0, 4096);
@@ -442,14 +415,10 @@
ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
SKYPIAX_P_LOG, messaggio);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
return CALLFLOW_INCOMING_HANGUP;
} else {
@@ -487,14 +456,10 @@
if (!strcasecmp(messaggio, "ERROR")) {
ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
tech_pvt->skype_call_id[0] = '\0';
if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
return CALLFLOW_INCOMING_HANGUP;
} else {
@@ -596,7 +561,6 @@
where = strsep(stringp, " ");
- if (option_debug > 101)
DEBUGA_SKYPE
("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
@@ -643,7 +607,6 @@
if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
if (strcasecmp(id, tech_pvt->skype_call_id)) {
strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- if (option_debug > 1)
DEBUGA_SKYPE
("We called a Skype contact and he answered us on skype_call: %s.\n",
SKYPIAX_P_LOG, id);
@@ -674,7 +637,6 @@
skypiax_sleep(10000);
sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
skypiax_skype_write(tech_pvt, msg_to_skype);
- if (option_debug)
DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
SKYPIAX_P_LOG, id);
strncpy(tech_pvt->skype_call_id, id,
@@ -710,14 +672,10 @@
} else if (!strcasecmp(value, "FINISHED")) {
//tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
tech_pvt->skype_call_id[0] = '\0';
if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
//tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
return CALLFLOW_INCOMING_HANGUP;
} else {
@@ -726,16 +684,12 @@
} else if (!strcasecmp(value, "CANCELLED")) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
- if (option_debug)
DEBUGA_SKYPE
("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
SKYPIAX_P_LOG, id);
tech_pvt->skype_call_id[0] = '\0';
if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
return CALLFLOW_INCOMING_HANGUP;
} else {
@@ -743,22 +697,17 @@
}
} else if (!strcasecmp(value, "FAILED")) {
tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
- if (option_debug)
DEBUGA_SKYPE
("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';
strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return CALLFLOW_INCOMING_HANGUP;
} else if (!strcasecmp(value, "REFUSED")) {
if (!strcasecmp(id, tech_pvt->skype_call_id)) {
/* this is the id of the call we are in, probably we generated it */
tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
- if (option_debug)
DEBUGA_SKYPE
("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
SKYPIAX_P_LOG, id);
@@ -766,9 +715,6 @@
sizeof(tech_pvt->skype_call_id) - 1);
tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
tech_pvt->skype_call_id[0] = '\0';
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return CALLFLOW_INCOMING_HANGUP;
} else {
/* we're here because were us that refused an incoming call */
@@ -825,19 +771,12 @@
}
}
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return 0;
}
int skypiax_skype_senddigit(private_t * tech_pvt, char digit)
{
char msg_to_skype[1024];
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
DEBUGA_SKYPE("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
@@ -845,9 +784,6 @@
skypiax_skype_write(tech_pvt, msg_to_skype);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -855,9 +791,6 @@
{
char msg_to_skype[1024];
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
skypiax_sleep(5000);
DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
skypiax_skype_write(tech_pvt, "SET AGC OFF");
@@ -869,9 +802,6 @@
if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) {
ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
return 0;
@@ -988,11 +918,7 @@
DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
sprintf(acInputRow, "%s", msg_to_skype);
- if (option_debug > 100)
DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow);
/* send command to skype */
oCopyData.dwData = 0;
@@ -1006,16 +932,10 @@
ERRORA
("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then launch Skypiax and try again.\n",
SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
}
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -1319,24 +1239,15 @@
DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
SkypiaxHandles = &tech_pvt->SkypiaxHandles;
if (!skypiax_skype_send_message(SkypiaxHandles, msg_to_skype)) {
ERRORA
("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then restart Skype, then launch Skypiax and try again.\n",
SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -1407,7 +1318,6 @@
Window root = -1;
Window win = -1;
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
if (!strlen(tech_pvt->X11_display))
strcpy(tech_pvt->X11_display, getenv("DISPLAY"));
@@ -1455,7 +1365,6 @@
ERRORA
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
SKYPIAX_P_LOG);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
running = 0;
return NULL;
}
@@ -1465,7 +1374,6 @@
ERRORA
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
SKYPIAX_P_LOG);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
running = 0;
return NULL;
}
@@ -1517,7 +1425,6 @@
running = 0;
return NULL;
}
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
running = 0;
return NULL;
1
0
09 Feb '09
Author: gmaruzz
Date: Mon Feb 9 11:22:53 2009
New Revision: 11708
Log:
skypiax: cleaning skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Mon Feb 9 11:22:53 2009
@@ -180,16 +180,10 @@
{
struct skypiax_pvt *p = c->tech_pvt;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
/* queue the frame */
if (p)
p->control_to_send = control;
else {
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
DEBUGA_PBX("Queued CONTROL FRAME %d\n", SKYPIAX_P_LOG, control);
@@ -198,9 +192,6 @@
while (p->control_to_send)
usleep(1);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -210,14 +201,8 @@
char *name = data;
int res = AST_DEVICE_INVALID;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (!data) {
ERRORA("Devicestate requested with no data\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return res;
}
@@ -253,9 +238,6 @@
ERRORA("Checking device state for interface [%s] returning AST_DEVICE_INVALID\n",
SKYPIAX_P_LOG, name);
}
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return res;
}
@@ -268,9 +250,6 @@
struct skypiax_pvt *p = c->tech_pvt;
int res = 0;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
NOTICA("Let's INDICATE %d\n", SKYPIAX_P_LOG, cond);
switch (cond) {
@@ -296,9 +275,6 @@
res = -1;
}
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return res;
}
@@ -310,18 +286,12 @@
struct ast_channel *tmp = NULL;
char *name = data;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n",
SKYPIAX_P_LOG, type, name, *cause, format);
if (!data) {
ERRORA("Channel requested with no data\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
@@ -372,9 +342,6 @@
WARNINGA("Unable to create new Skypiax channel %s\n", SKYPIAX_P_LOG, name);
}
/* return the newly created channel */
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return tmp;
}
@@ -390,15 +357,9 @@
/* if there is not skypiax pvt why we are here ? */
if (!p) {
ERRORA("Asked to hangup channel not connected\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (p->skype && p->interface_state != SKYPIAX_STATE_DOWN) {
char msg_to_skype[1024];
p->interface_state = SKYPIAX_STATE_HANGUP_REQUESTED;
@@ -457,26 +418,15 @@
/* set the channel state to DOWN, eg. available, not in active use */
if (ast_setstate(c, SKYPIAX_STATE_DOWN)) {
ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
- if (option_debug)
- DEBUGA_PBX("Hanged Up\n", SKYPIAX_P_LOG);
/* restart the monitor thread, so it can recheck which interfaces it have to watch during its loop (the interfaces that are not owned by channels) */
if (skypiax_restart_monitor()) {
ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -487,9 +437,6 @@
struct skypiax_pvt *p = c->tech_pvt;
int res;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
/* whle ringing, we just wait, the skype thread will answer */
while (p->interface_state == SKYPIAX_STATE_RING) {
usleep(10000); //10msec
@@ -498,13 +445,9 @@
ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n", SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state);
res = -1;
} else {
- if (option_debug)
DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG);
res = 0;
}
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return res;
}
@@ -512,15 +455,9 @@
int skypiax_senddigit_begin(struct ast_channel *c, char digit)
{
struct skypiax_pvt *p = c->tech_pvt;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
DEBUGA_PBX("DIGIT BEGIN received: %c\n", SKYPIAX_P_LOG, digit);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -528,9 +465,6 @@
{
struct skypiax_pvt *p = c->tech_pvt;
char msg_to_skype[1024];
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
NOTICA("DIGIT END received: %c %d\n", SKYPIAX_P_LOG, digit, duration);
@@ -538,9 +472,6 @@
skypiax_skype_write(p, msg_to_skype);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
#else /* ASTERISK_VERSION_1_4 */
@@ -549,18 +480,12 @@
struct skypiax_pvt *p = c->tech_pvt;
char msg_to_skype[1024];
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
NOTICA("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit);
skypiax_skype_write(p, msg_to_skype);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -576,9 +501,6 @@
short *buf;
int samples;
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
/* if there are control frames queued to be sent by skypiax_queue_control, send it the first */
//TODO maybe better a real queue?
@@ -605,9 +527,6 @@
/* if the call is not active (ie: answered), do not send audio frames, they would pile up in a lag queue */
if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return &f;
}
@@ -632,10 +551,6 @@
skypiax_sound_boost(&f, p->capture_boost);
}
- if (option_debug > 100) {
- DEBUGA_SOUND("samples=%d\n", SKYPIAX_P_LOG, samples);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return &f;
}
@@ -650,20 +565,13 @@
char *stringp = NULL;
int status;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if ((c->_state != SKYPIAX_STATE_DOWN)
&& (c->_state != SKYPIAX_STATE_RESERVED)) {
ERRORA("skypiax_call called on %s, neither down nor reserved\n", SKYPIAX_P_LOG,
c->name);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
- if (option_debug > 1)
DEBUGA_PBX("skypiax_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG, idest,
timeout);
@@ -674,14 +582,10 @@
if (!where) {
ERRORA("Destination %s requires an actual destination (Skypiax/device/destination)\n",
SKYPIAX_P_LOG, idest);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
strncpy(dstr, where + p->stripmsd, sizeof(dstr) - 1);
- if (option_debug > 1)
DEBUGA_PBX("skypiax_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG,
idest, timeout, dstr);
@@ -689,20 +593,13 @@
status = skypiax_skype_call(p, dstr, timeout);
if (status) {
WARNINGA("skypiax_call dialing failed: %d!\n", SKYPIAX_P_LOG, status);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
- if (option_debug > 1)
DEBUGA_PBX("skypiax_call dialed idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG,
idest, timeout, dstr);
ast_setstate(p->owner, SKYPIAX_STATE_DIALING);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -731,13 +628,7 @@
struct skypiax_pvt *p = c->tech_pvt;
int sent;
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
if (p->playback_boost)
@@ -746,10 +637,6 @@
sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen);
//skypiax_sound_write(p, f);
- if (option_debug > 100) {
- DEBUGA_SOUND("sent=%d\n", SKYPIAX_P_LOG, sent);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -759,29 +646,17 @@
{
struct skypiax_pvt *p = newchan->tech_pvt;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (!p) {
ERRORA("No pvt after masquerade. Strange things may happen\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
if (p->owner != oldchan) {
ERRORA("old channel wasn't %p but was %p\n", SKYPIAX_P_LOG, oldchan, p->owner);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
p->owner = newchan;
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -789,9 +664,6 @@
{
struct ast_channel *tmp;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
/* alloc a generic channel struct */
#ifndef ASTERISK_VERSION_1_4
tmp = ast_channel_alloc(1);
@@ -858,9 +730,6 @@
ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG);
//ast_dsp_free(p->dsp);
ast_channel_free(tmp);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
/* if the requested state is different from DOWN, let the pbx manage this interface (now part of the newly created channel) */
@@ -869,9 +738,6 @@
if (ast_pbx_start(tmp)) {
ERRORA("Unable to start PBX on %s\n", SKYPIAX_P_LOG, tmp->name);
ast_channel_free(tmp);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
}
@@ -893,15 +759,9 @@
ast_update_use_count();
/* return the newly created channel */
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return tmp;
}
ERRORA("failed memory allocation for Skypiax channel\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
@@ -927,10 +787,6 @@
struct ast_flags config_flags = { 0 };
#endif /* ASTERISK_VERSION_1_6 */
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- ast_log(LOG_DEBUG, "ENTERING FUNC\n");
- }
#if defined(WANT_SKYPE_X11) || defined(__CYGWIN__)
#ifndef __CYGWIN__
if (!XInitThreads())
@@ -949,9 +805,6 @@
i = ast_channel_register(&skypiax_tech);
if (i < 0) {
ERRORA("Unable to register channel type '%s'\n", SKYPIAX_P_LOG, skypiax_type);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
/* load skypiax.conf config file */
@@ -984,9 +837,6 @@
/* if error, unload config from memory and return */
ast_config_destroy(cfg);
ast_channel_unregister(&skypiax_tech);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
/* do it for each category described in config */
@@ -997,9 +847,6 @@
} else {
ERRORA("Unable to load skypiax_config skypiax.conf\n", SKYPIAX_P_LOG);
ast_channel_unregister(&skypiax_tech);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
#ifndef ASTERISK_VERSION_1_6
@@ -1008,14 +855,8 @@
/* start to monitor the interfaces (skypiax_iflist) for the first time */
if (skypiax_restart_monitor()) {
ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -1034,9 +875,6 @@
struct skypiax_pvt *p = NULL, *p2 = NULL;
int res;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
/* unregister our channel type with Asterisk */
ast_channel_unregister(&skypiax_tech);
@@ -1060,9 +898,6 @@
&& (skypiax_monitor_thread != AST_PTHREADT_STOP)) {
if (pthread_cancel(skypiax_monitor_thread)) {
ERRORA("pthread_cancel failed, BAD\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
if (pthread_kill(skypiax_monitor_thread, SIGURG)) {
@@ -1071,9 +906,6 @@
#ifndef __CYGWIN__ /* under cygwin, this seems to be not reliable, get stuck at times */
if (pthread_join(skypiax_monitor_thread, NULL)) {
ERRORA("pthread_join failed, BAD\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
#endif /* __CYGWIN__ */
@@ -1128,9 +960,6 @@
sleep(5); /* without this pause, for some unknown (to me) reason it crashes on cygwin */
#endif /* __CYGWIN__ */
NOTICA("Unloaded Skypiax Module\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -1143,9 +972,6 @@
{
int res;
static struct skypiax_pvt *p = &skypiax_log_struct;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
/* lock the skypiax_usecnt lock */
LOKKA(&skypiax_usecnt_lock);
/* retrieve the skypiax_usecnt */
@@ -1153,9 +979,6 @@
/* unlock the skypiax_usecnt lock */
UNLOCKA(&skypiax_usecnt_lock);
/* return the skypiax_usecnt */
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return res;
}
@@ -1166,13 +989,6 @@
*/
char *description()
{
- static struct skypiax_pvt *p = &skypiax_log_struct;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return (char *) skypiax_desc;
}
@@ -1184,16 +1000,9 @@
char *key()
{
struct skypiax_pvt *p = NULL;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
- if (option_debug)
NOTICA("Returning Key\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return ASTERISK_GPL_KEY;
}
@@ -1228,10 +1037,6 @@
/* alloc memory for PVT */
tmp = malloc(sizeof(struct skypiax_pvt));
if (tmp == NULL) { /* fail */
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- ast_log(LOG_DEBUG, "EXITING FUNC\n");
- }
return NULL;
}
/* clear memory for PVT */
@@ -1399,9 +1204,6 @@
if (res == -1) {
ERRORA("Failed initializing sound device\n", SKYPIAX_TMP_LOG);
/* we failed, free the PVT */
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- }
free(tmp);
return NULL;
}
@@ -1421,7 +1223,6 @@
tmp->skype_thread = AST_PTHREADT_NULL;
if (tmp->skype) {
- if (option_debug > 1)
ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n",
(unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
(unsigned long) AST_PTHREADT_NULL);
@@ -1429,21 +1230,14 @@
if (ast_pthread_create
(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- }
free(tmp);
return NULL;
}
#else /* __CYGWIN__ */
#ifdef WANT_SKYPE_X11
- if (option_debug > 1)
ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]);
if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- }
free(tmp);
return NULL;
}
@@ -1452,13 +1246,9 @@
usleep(100000); //0.1 sec
if( tmp->skype_thread == AST_PTHREADT_NULL){
ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- }
free(tmp);
return NULL;
}
- if (option_debug > 1)
ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n",
(unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
(unsigned long) AST_PTHREADT_NULL);
@@ -1516,9 +1306,6 @@
/* return the newly created skypiax_pvt */
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- }
return tmp;
}
@@ -1527,14 +1314,8 @@
{
static struct skypiax_pvt *p = &skypiax_log_struct;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
/* If we're supposed to be stopped -- stay stopped */
if (skypiax_monitor_thread == AST_PTHREADT_STOP) {
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
LOKKA(&skypiax_monlock);
@@ -1542,9 +1323,6 @@
if (skypiax_monitor_thread == pthread_self()) {
UNLOCKA(&skypiax_monlock);
ERRORA("Cannot kill myself\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
/* if the monitor thread exists */
@@ -1556,16 +1334,10 @@
if (ast_pthread_create(&skypiax_monitor_thread, NULL, skypiax_do_monitor, NULL) < 0) {
UNLOCKA(&skypiax_monlock);
ERRORA("Unable to start monitor thread.\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
}
UNLOCKA(&skypiax_monlock);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
@@ -1582,14 +1354,8 @@
struct timeval to;
time_t now_timestamp;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
@@ -1657,9 +1423,6 @@
continue;
else {
ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, res, strerror(errno));
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
}
@@ -1694,9 +1457,6 @@
pthread_testcancel();
}
/* Never reached */
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
@@ -1712,12 +1472,6 @@
int skypiax_sound_init(struct skypiax_pvt *p)
{
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return skypiax_skypeaudio_init(p);
}
@@ -1733,14 +1487,8 @@
int skypiax_sound_shutdown(struct skypiax_pvt *p)
{
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
//return skypiax_portaudio_shutdown(p);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
}
@@ -1750,14 +1498,8 @@
struct ast_frame *f = NULL;
int res;
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
res = skypiax_skypeaudio_read(p);
f = &p->read_frame;
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return f;
}
@@ -1766,13 +1508,7 @@
{
int ret = -1;
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
ret = skypiax_skypeaudio_write(p, f);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return ret;
}
@@ -1785,16 +1521,10 @@
struct skypiax_pvt *p = data;
int res;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
DEBUGA_SERIAL("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, p);
if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
@@ -1804,7 +1534,6 @@
if (p->skype) {
res = skypiax_skype_read(p);
if (res == CALLFLOW_INCOMING_HANGUP) {
- if (option_debug)
DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
if (p->owner) {
pthread_testcancel();
@@ -1814,9 +1543,6 @@
}
}
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return NULL;
}
@@ -1835,14 +1561,8 @@
{
struct skypiax_pvt *p = NULL;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (sscanf(s, "%lf", boost) != 1) {
ERRORA("invalid boost <%s>\n", SKYPIAX_P_LOG, s);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return;
}
if (*boost < -BOOST_MAX) {
@@ -1853,7 +1573,6 @@
*boost = BOOST_MAX;
}
*boost = exp(log(10) * *boost / 20) * BOOST_SCALE;
- if (option_debug > 1)
DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost);
}
@@ -1863,38 +1582,23 @@
struct skypiax_pvt *skypiax_console_find_desc(char *dev)
{
struct skypiax_pvt *p = NULL;
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
for (p = skypiax_iflist; p && strcmp(p->name, dev) != 0; p = p->next);
if (p == NULL)
WARNINGA("could not find <%s>\n", SKYPIAX_P_LOG, dev);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return p;
}
int skypiax_console_playback_boost(int fd, int argc, char *argv[])
{
struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (argc > 2) {
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SHOWUSAGE;
}
if (!p) {
ast_cli(fd,
"No \"current\" skypiax_console for playback_boost, please enter 'help skypiax_console'\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
@@ -1911,30 +1615,18 @@
20 * log10(((double) p->playback_boost / (double) BOOST_SCALE)));
}
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
int skypiax_console_capture_boost(int fd, int argc, char *argv[])
{
struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (argc > 2) {
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SHOWUSAGE;
}
if (!p) {
ast_cli(fd,
"No \"current\" skypiax_console for capture_boost, please enter 'help skypiax_console'\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
@@ -1951,9 +1643,6 @@
20 * log10(((double) p->capture_boost / (double) BOOST_SCALE)));
}
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
@@ -1961,36 +1650,21 @@
{
struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (argc != 1) {
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SHOWUSAGE;
}
if (!p) {
ast_cli(fd,
"No \"current\" skypiax_console for hanging up, please enter 'help skypiax_console'\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
if (!p->owner) {
ast_cli(fd, "No call to hangup on the active skypiax_console, that is [%s]\n",
skypiax_console_active);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_FAILURE;
}
if (p->owner)
ast_queue_hangup(p->owner);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
@@ -1999,21 +1673,12 @@
char *s = NULL;
struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (argc != 2) {
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SHOWUSAGE;
}
if (!p) {
ast_cli(fd,
"No \"current\" skypiax_console for dialing, please enter 'help skypiax_console'\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
@@ -2027,9 +1692,6 @@
f.subclass = s[i];
ast_queue_frame(p->owner, &f);
}
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
} else
ast_cli(fd,
@@ -2037,9 +1699,6 @@
skypiax_console_active);
if (s)
free(s);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
int skypiax_console_set_active(int fd, int argc, char *argv[])
@@ -2093,9 +1752,6 @@
if (ast_pthread_create
(&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) {
ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
} else {
DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
@@ -2105,9 +1761,6 @@
if (ast_pthread_create
(&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return -1;
} else {
DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
@@ -2230,14 +1883,8 @@
{
int sent;
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return 0;
}
int skypiax_console_skype(int fd, int argc, char *argv[])
@@ -2254,17 +1901,8 @@
"No \"current\" console for skypiax_skype, please enter 'help console'\n");
return RESULT_SUCCESS;
}
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
if (!p->skype) {
ast_cli(fd, "The \"current\" console is not connected to a Skype client'\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
@@ -2285,9 +1923,6 @@
break;
}
skypiax_skype_write(p, skype_msg);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
return RESULT_SUCCESS;
}
@@ -2370,7 +2005,6 @@
} else {
snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
}
- if (option_debug)
NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn);
time(&t);
ast_copy_string(date, ctime(&t), sizeof(date));
@@ -2382,14 +2016,12 @@
if (p->phonebook_writing_fp) {
if (add_to_skypiax_dir_conf) {
- if (option_debug)
NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn);
fprintf(p->phonebook_writing_fp, ";!\n");
fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date);
fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__);
fprintf(p->phonebook_writing_fp, ";!\n");
} else {
- if (option_debug)
NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn);
fprintf(p->phonebook_writing_fp, ";!\n");
fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n");
1
0
[commit] r11707 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk
by FreeSWITCH SVN 09 Feb '09
by FreeSWITCH SVN 09 Feb '09
09 Feb '09
Author: gmaruzz
Date: Mon Feb 9 10:56:44 2009
New Revision: 11707
Log:
skypiax: cleaning skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h
freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h Mon Feb 9 10:56:44 2009
@@ -405,6 +405,16 @@
int outbound_channel_answered(private_t *tech_pvt);
int skypiax_skype_senddigit(struct skypiax_pvt *p, char digit);
int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype);
+#if defined(WIN32) && !defined(__CYGWIN__)
+int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany);
+int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany);
+/* Visual C do not have strsep ? */
+char *strsep(char **stringp, const char *delim);
+#else
+int skypiax_pipe_read(int pipe, short *buf, int howmany);
+int skypiax_pipe_write(int pipe, short *buf, int howmany);
+#endif /* WIN32 */
+int skypiax_close_socket(unsigned int fd);
#define SKYPIAX_STATE_DOWN AST_STATE_DOWN
#define SKYPIAX_STATE_RING AST_STATE_RING
#define SKYPIAX_STATE_DIALING AST_STATE_DIALING
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Mon Feb 9 10:56:44 2009
@@ -259,5 +259,13 @@
int new_inbound_channel(private_t *tech_pvt);
int outbound_channel_answered(private_t *tech_pvt);
int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype);
+#if defined(WIN32) && !defined(__CYGWIN__)
+int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany);
+int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany);
/* Visual C do not have strsep ? */
char *strsep(char **stringp, const char *delim);
+#else
+int skypiax_pipe_read(int pipe, short *buf, int howmany);
+int skypiax_pipe_write(int pipe, short *buf, int howmany);
+#endif /* WIN32 */
+int skypiax_close_socket(unsigned int fd);
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 10:56:44 2009
@@ -7,8 +7,6 @@
extern char *skypiax_console_active;
#else /* FREESWITCH */
#define skypiax_sleep switch_sleep
-//#define skypiax_pipe_write switch_file_write
-//#define skypiax_pipe_read switch_file_read
extern switch_memory_pool_t *skypiax_module_pool;
extern switch_endpoint_interface_t *skypiax_endpoint_interface;
#endif /* ASTERISK */
@@ -17,76 +15,14 @@
extern int running;
/*************************************/
-#ifndef WIN32
+#ifdef WIN32
+DWORD win32_dwThreadId;
+#else
XErrorHandler old_handler = 0;
int xerror = 0;
-#else
-DWORD win32_dwThreadId;
#endif /* WIN32 */
/*************************************/
-#if defined(WIN32) && !defined(__CYGWIN__)
-int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany)
-{
- switch_size_t quantity;
-
- quantity = howmany;
-
- switch_file_read(pipe, buf, &quantity);
-
- howmany = quantity;
-
- return howmany;
-}
-#else /* WIN32 */
-int skypiax_pipe_read(int pipe, short *buf, int howmany)
-{
- howmany = read(pipe, buf, howmany);
- return howmany;
-}
-#endif /* WIN32 */
-
-#if defined(WIN32) && !defined(__CYGWIN__)
-int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany)
-{
- switch_size_t quantity;
-
- quantity = howmany;
-
- switch_file_write(pipe, buf, &quantity);
-
- howmany = quantity;
-
- return howmany;
-}
-#else /* WIN32 */
-int skypiax_pipe_write(int pipe, short *buf, int howmany)
-{
- howmany = write(pipe, buf, howmany);
- return howmany;
-}
-#endif /* WIN32 */
-
-#if defined(WIN32) && !defined(__CYGWIN__)
-int skypiax_close_socket(unsigned int fd)
-{
- int res;
-
- res = closesocket(fd);
-
- return res;
-}
-#else /* WIN32 */
-int skypiax_close_socket(unsigned int fd)
-{
- int res;
-
- res = close(fd);
-
- return res;
-}
-#endif /* WIN32 */
-
void *skypiax_do_tcp_srv_thread_func(void *obj)
{
private_t *tech_pvt = obj;
@@ -941,6 +877,63 @@
return 0;
}
+/***************************/
+/* PLATFORM SPECIFIC */
+/***************************/
+#if defined(WIN32) && !defined(__CYGWIN__)
+int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany)
+{
+ switch_size_t quantity;
+
+ quantity = howmany;
+
+ switch_file_read(pipe, buf, &quantity);
+
+ howmany = quantity;
+
+ return howmany;
+}
+int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany)
+{
+ switch_size_t quantity;
+
+ quantity = howmany;
+
+ switch_file_write(pipe, buf, &quantity);
+
+ howmany = quantity;
+
+ return howmany;
+}
+int skypiax_close_socket(unsigned int fd)
+{
+ int res;
+
+ res = closesocket(fd);
+
+ return res;
+}
+
+#else /* WIN32 */
+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;
+
+ res = close(fd);
+
+ return res;
+}
+#endif /* WIN32 */
#ifdef WIN32
1
0
Author: gmaruzz
Date: Mon Feb 9 10:34:49 2009
New Revision: 11705
Log:
skypiax: cleaning added strsep() to skypiax.h, Visual C lack it
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Mon Feb 9 10:34:49 2009
@@ -259,3 +259,5 @@
int new_inbound_channel(private_t *tech_pvt);
int outbound_channel_answered(private_t *tech_pvt);
int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype);
+/* Visual C do not have strsep ? */
+char *strsep(char **stringp, const char *delim);
1
0
[commit] r11703 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk
by FreeSWITCH SVN 09 Feb '09
by FreeSWITCH SVN 09 Feb '09
09 Feb '09
Author: gmaruzz
Date: Mon Feb 9 10:10:52 2009
New Revision: 11703
Log:
skypiax: cleaning skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h
freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h Mon Feb 9 10:10:52 2009
@@ -404,6 +404,7 @@
int new_inbound_channel(private_t *tech_pvt);
int outbound_channel_answered(private_t *tech_pvt);
int skypiax_skype_senddigit(struct skypiax_pvt *p, char digit);
+int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype);
#define SKYPIAX_STATE_DOWN AST_STATE_DOWN
#define SKYPIAX_STATE_RING AST_STATE_RING
#define SKYPIAX_STATE_DIALING AST_STATE_DIALING
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h Mon Feb 9 10:10:52 2009
@@ -258,3 +258,4 @@
int start_audio_threads(private_t *tech_pvt);
int new_inbound_channel(private_t *tech_pvt);
int outbound_channel_answered(private_t *tech_pvt);
+int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype);
Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c Mon Feb 9 10:10:52 2009
@@ -20,6 +20,8 @@
#ifndef WIN32
XErrorHandler old_handler = 0;
int xerror = 0;
+#else
+DWORD win32_dwThreadId;
#endif /* WIN32 */
/*************************************/
@@ -421,7 +423,6 @@
{
unsigned int samples;
- //samples = SAMPLES_PER_FRAME * sizeof(short);
samples =
skypiax_pipe_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short));
@@ -436,557 +437,564 @@
return 1;
}
-#ifdef WIN32
-
-enum {
- SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully
- attached and API window handle can be found
- in wParam parameter */
- SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged
- connection request and is waiting
- for confirmation from the user. */
- /* The client is not yet attached
- * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */
- SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly
- denied access to client */
- SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /* API is not available
- at the moment.
- For example, this happens when no user
- is currently logged in. */
- /* Client should wait for
- * SKYPECONTROLAPI_ATTACH_API_AVAILABLE
- * broadcast before making any further */
- /* connection attempts. */
- SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
-};
-
-char
- *strsep(char **stringp, const char *delim)
+int skypiax_skype_read(private_t * tech_pvt)
{
- char *res;
-
- if (!stringp || !*stringp || !**stringp)
- return (char *) 0;
- res = *stringp;
- while (**stringp && !strchr(delim, **stringp))
- ++(*stringp);
+ char read_from_pipe[4096];
+ char messaggio[4096];
+ char messaggio_2[4096];
+ char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
+ char **stringp = NULL;
+ int rt;
+ int a;
+ unsigned int howmany;
+ unsigned int i;
+#ifndef WIN32
+ int fdselect;
+ fd_set fs;
+ struct timeval to;
+#endif /* WIN32 */
- if (**stringp) {
- **stringp = '\0';
- ++(*stringp);
+ if (option_debug > 100) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
- return res;
-}
-
-LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
- LPARAM ulParam)
-{
- LRESULT lReturnCode;
- int fIssueDefProc;
- private_t *tech_pvt = NULL;
-
- lReturnCode = 0;
- fIssueDefProc = 0;
- tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA);
- switch (uiMessage) {
- case WM_CREATE:
- tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams;
- SetWindowLong(hWindow, GWL_USERDATA, (LONG) tech_pvt);
- DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG);
- break;
- case WM_DESTROY:
- NOTICA("got DESTROY\n", SKYPIAX_P_LOG);
- tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
- PostQuitMessage(0);
- break;
- case WM_COPYDATA:
- if (tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
- unsigned int howmany;
- char msg_from_skype[2048];
-
- PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
+ memset(read_from_pipe, 0, 4096);
+ memset(messaggio, 0, 4096);
+ memset(messaggio_2, 0, 4096);
- memset(msg_from_skype, '\0', sizeof(msg_from_skype));
- strncpy(msg_from_skype, (const char *) poCopyData->lpData,
- sizeof(msg_from_skype) - 2);
+#ifdef WIN32
+ rt = 1;
+#else /* WIN32 */
+ fdselect = tech_pvt->SkypiaxHandles.fdesc[0];
+ FD_ZERO(&fs);
+ FD_SET(fdselect, &fs);
+ to.tv_usec = 2000000; //500 msec
+ to.tv_sec = 0;
+ rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+#endif /* WIN32 */
- howmany = strlen(msg_from_skype) + 1;
-//#if defined(WIN32) && !defined(__CYGWIN__)
+ if (rt > 0) {
+ if (tech_pvt->SkypiaxHandles.fdesc[0]) {
+ howmany = sizeof(read_from_pipe);
howmany =
- skypiax_pipe_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype,
- howmany);
- //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype);
-//#else
- //howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, howmany);
- //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype);
-//#endif
- lReturnCode = 1;
- }
- break;
- default:
- if (tech_pvt && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
- if (uiMessage ==
- tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
- switch (ulParam) {
- case SKYPECONTROLAPI_ATTACH_SUCCESS:
- if (!tech_pvt->SkypiaxHandles.api_connected) {
- DEBUGA_SKYPE("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
- tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
- tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle =
- tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle;
- }
- break;
- case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
- DEBUGA_SKYPE
- ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n",
- SKYPIAX_P_LOG);
- skypiax_sleep(5000);
- if (!tech_pvt->SkypiaxHandles.api_connected) {
- SendMessage(HWND_BROADCAST,
- tech_pvt->SkypiaxHandles.
- win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
- (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
- 0);
- }
- break;
- case SKYPECONTROLAPI_ATTACH_REFUSED:
- ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG);
- break;
- case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
- ERRORA("Skype API not (yet?) available\n", SKYPIAX_P_LOG);
- break;
- case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
- DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
- skypiax_sleep(5000);
- if (!tech_pvt->SkypiaxHandles.api_connected) {
- SendMessage(HWND_BROADCAST,
- tech_pvt->SkypiaxHandles.
- win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
- (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
- 0);
- }
- break;
- default:
- WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG);
- }
- lReturnCode = 1;
- break;
- }
- }
- fIssueDefProc = 1;
- break;
- }
- if (fIssueDefProc)
- lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam);
- return (lReturnCode);
-}
+ skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe,
+ howmany);
-int win32_Initialize_CreateWindowClass(private_t * tech_pvt)
-{
- unsigned char *paucUUIDString;
- RPC_STATUS lUUIDResult;
- int fReturnStatus;
- UUID oUUID;
+ a = 0;
+ for (i = 0; i < howmany; i++) {
+ messaggio[a] = read_from_pipe[i];
+ a++;
- fReturnStatus = 0;
- lUUIDResult = UuidCreate(&oUUID);
- tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle =
- (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
- if (tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle != NULL
- && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) {
- if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) {
- WNDCLASS oWindowClass;
+ if (read_from_pipe[i] == '\0') {
- strcpy(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "Skype-API-Skypiax-");
- strcat(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName,
- (char *) paucUUIDString);
+ //DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio);
+ DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, messaggio);
- oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
- oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present;
- oWindowClass.cbClsExtra = 0;
- oWindowClass.cbWndExtra = 0;
- oWindowClass.hInstance = tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle;
- oWindowClass.hIcon = NULL;
- oWindowClass.hCursor = NULL;
- oWindowClass.hbrBackground = NULL;
- oWindowClass.lpszMenuName = NULL;
- oWindowClass.lpszClassName = tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName;
+ if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
+ just authorized */
+ DEBUGA_SKYPE
+ ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
+ SKYPIAX_P_LOG);
+ skypiax_sleep(1000000);
+ skypiax_skype_write(tech_pvt, "PROTOCOL 6");
+ skypiax_sleep(10000);
+ return 0;
+ }
- if (RegisterClass(&oWindowClass) != 0)
- fReturnStatus = 1;
+ if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
+ ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
+ SKYPIAX_P_LOG, messaggio);
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ tech_pvt->skype_call_id[0] = '\0';
- RpcStringFree(&paucUUIDString);
- }
- }
- if (fReturnStatus == 0)
- CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle),
- tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
- return (fReturnStatus);
-}
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
+ }
-void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt)
-{
- UnregisterClass(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName,
- tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle);
- CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle),
- tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
-}
+ strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1);
-int win32_Initialize_CreateMainWindow(private_t * tech_pvt)
-{
- tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle =
- CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
- tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "",
- WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
- 128, 128, NULL, 0, tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle,
- tech_pvt);
- return (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0);
-}
+ buf = messaggio;
+ stringp = &buf;
+ where = strsep(stringp, " ");
+ if (!where) {
+ WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio);
+ }
-void win32_DeInitialize_DestroyMainWindow(private_t * tech_pvt)
-{
- if (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL)
- DestroyWindow(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle),
- tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
-}
+ if (!strcasecmp(messaggio, "#333")) {
+ /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG,
+ * messaggio_2, &messaggio_2[11]); */
+ memset(tech_pvt->skype_friends, 0, 4096);
+ strncpy(tech_pvt->skype_friends, &messaggio_2[11], 4095);
+ }
+ if (!strcasecmp(messaggio, "#222")) {
+ /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
+ * messaggio_2, &messaggio_2[10]); */
+ memset(tech_pvt->skype_fullname, 0, 512);
+ strncpy(tech_pvt->skype_fullname, &messaggio_2[10], 511);
+ }
+ if (!strcasecmp(messaggio, "#765")) {
+ /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
+ * messaggio_2, &messaggio_2[10]); */
+ memset(tech_pvt->skype_displayname, 0, 512);
+ strncpy(tech_pvt->skype_displayname, &messaggio_2[10], 511);
+ }
+ if (!strcasecmp(messaggio, "ERROR")) {
+ ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ tech_pvt->skype_call_id[0] = '\0';
-DWORD win32_dwThreadId;
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
+ }
+ if (!strcasecmp(messaggio, "CURRENTUSERHANDLE")) {
+ strncpy(obj, where, sizeof(obj) - 1);
-void *skypiax_do_skypeapi_thread_func(void *obj)
-{
- /* create window class */
- /* create dummy/hidden window for processing messages */
- /* run message loop thread */
- /* do application control until exit */
- /* exit: send QUIT message to our own window */
- /* wait until thred terminates */
- /* destroy main window */
- /* destroy window class */
+ where = strsep(stringp, " ");
- private_t *tech_pvt = obj;
-#if defined(WIN32) && !defined(__CYGWIN__)
- switch_status_t rv;
+ strncpy(id, where, sizeof(id) - 1);
- switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0],
- &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool);
- rv =
- switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0],
- &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool);
-#else /* WIN32 */
- if (pipe(tech_pvt->SkypiaxHandles.fdesc)) {
- fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
- fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
- }
-#endif /* WIN32 */
+ if (!strcasecmp(id, tech_pvt->skype_user)) {
+ tech_pvt->SkypiaxHandles.api_connected = 1;
+ DEBUGA_SKYPE
+ ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user);
+ }
+ }
- tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach =
- RegisterWindowMessage("SkypeControlAPIAttach");
- tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
- RegisterWindowMessage("SkypeControlAPIDiscover");
+ if (!strcasecmp(messaggio, "USER")) {
+ strncpy(obj, where, sizeof(obj) - 1);
- skypiax_sleep(2000000);
+ where = strsep(stringp, " ");
- if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
- && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
- if (win32_Initialize_CreateWindowClass(tech_pvt)) {
- if (win32_Initialize_CreateMainWindow(tech_pvt)) {
- if (SendMessage
- (HWND_BROADCAST,
- tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
- (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) {
- tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle =
- tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle;
- while (1) {
- MSG oMessage;
- if (!running)
- break;
- while (GetMessage(&oMessage, 0, 0, 0)) {
- TranslateMessage(&oMessage);
- DispatchMessage(&oMessage);
- }
- }
- }
- win32_DeInitialize_DestroyMainWindow(tech_pvt);
- }
- win32_DeInitialize_DestroyWindowClass(tech_pvt);
- }
- }
+ strncpy(id, where, sizeof(id) - 1);
- return NULL;
-}
+ where = strsep(stringp, " ");
-#else /* NOT WIN32 */
+ strncpy(prop, where, sizeof(prop) - 1);
-int X11_errors_handler(Display * dpy, XErrorEvent * err)
-{
- (void) dpy;
- private_t *tech_pvt = NULL;
+ if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
+ char msg_to_skype[256];
+ DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop);
- xerror = err->error_code;
- ERRORA("Received error code %d from X Server\n\n", SKYPIAX_P_LOG, xerror);
- return 0; /* ignore the error */
-}
+ //FIXME: TODO: allow authorization based on config param
+ sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ }
+ }
-static void X11_errors_trap(void)
-{
- xerror = 0;
- old_handler = XSetErrorHandler(X11_errors_handler);
-}
+ if (!strcasecmp(messaggio, "MESSAGE")) {
+ strncpy(obj, where, sizeof(obj) - 1);
-static int X11_errors_untrap(void)
-{
- XSetErrorHandler(old_handler);
- return (xerror != BadValue) && (xerror != BadWindow);
-}
+ where = strsep(stringp, " ");
-int skypiax_skype_send_message(struct SkypiaxHandles *SkypiaxHandles,
- const char *message_P)
-{
+ strncpy(id, where, sizeof(id) - 1);
- Window w_P;
- Display *disp;
- Window handle_P;
- int ok;
- private_t *tech_pvt = NULL;
+ where = strsep(stringp, " ");
- w_P = SkypiaxHandles->skype_win;
- disp = SkypiaxHandles->disp;
- handle_P = SkypiaxHandles->win;
+ strncpy(prop, where, sizeof(prop) - 1);
- Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
- Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
- unsigned int pos = 0;
- unsigned int len = strlen(message_P);
- XEvent e;
+ if (!strcasecmp(prop, "STATUS")) {
- memset(&e, 0, sizeof(e));
- e.xclient.type = ClientMessage;
- e.xclient.message_type = atom1; /* leading message */
- e.xclient.display = disp;
- e.xclient.window = handle_P;
- e.xclient.format = 8;
+ where = strsep(stringp, " ");
- X11_errors_trap();
- //XLockDisplay(disp);
- do {
- unsigned int i;
- for (i = 0; i < 20 && i + pos <= len; ++i)
- e.xclient.data.b[i] = message_P[i + pos];
- XSendEvent(disp, w_P, False, 0, &e);
+ strncpy(value, where, sizeof(value) - 1);
- e.xclient.message_type = atom2; /* following messages */
- pos += i;
- } while (pos <= len);
+ if (!strcasecmp(value, "RECEIVED")) {
+ char msg_to_skype[256];
+ DEBUGA_SKYPE
+ ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s value: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop, value);
- XSync(disp, False);
- ok = X11_errors_untrap();
+ //FIXME: TODO: allow authorization based on config param
+ sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ }
+ } else if (!strcasecmp(prop, "BODY")) {
+ char msg_to_skype[256];
- if (!ok)
- ERRORA("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror);
- //XUnlockDisplay(disp);
+ DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop);
- return 1;
-}
+ //FIXME: TODO: on config param ???
+ sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ }
-int skypiax_skype_present(struct SkypiaxHandles *SkypiaxHandles)
-{
- Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True);
+ }
- Atom type_ret;
- int format_ret;
- unsigned long nitems_ret;
- unsigned long bytes_after_ret;
- unsigned char *prop;
- int status;
- private_t *tech_pvt = NULL;
+ if (!strcasecmp(messaggio, "CALL")) {
- X11_errors_trap();
- //XLockDisplay(disp);
- status =
- XGetWindowProperty(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->disp),
- skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret,
- &nitems_ret, &bytes_after_ret, &prop);
- //XUnlockDisplay(disp);
- X11_errors_untrap();
+ strncpy(obj, where, sizeof(obj) - 1);
- /* sanity check */
- if (status != Success || format_ret != 32 || nitems_ret != 1) {
- SkypiaxHandles->skype_win = (Window) - 1;
- DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG);
- return 0;
- }
+ where = strsep(stringp, " ");
- SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff;
- DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG,
- (unsigned int) SkypiaxHandles->skype_win);
- return 1;
-}
+ strncpy(id, where, sizeof(id) - 1);
-void skypiax_skype_clean_disp(void *data)
-{
+ where = strsep(stringp, " ");
- int *dispptr;
- int disp;
- private_t *tech_pvt = NULL;
+ strncpy(prop, where, sizeof(prop) - 1);
- dispptr = data;
- disp = *dispptr;
+ where = strsep(stringp, " ");
- if (disp) {
- DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPIAX_P_LOG, disp);
- close(disp);
- DEBUGA_SKYPE("destroyed disp\n", SKYPIAX_P_LOG);
- } else {
- DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG);
- }
- DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG);
- skypiax_sleep(1000);
-}
-
-void *skypiax_do_skypeapi_thread_func(void *obj)
-{
-
- private_t *tech_pvt = obj;
- struct SkypiaxHandles *SkypiaxHandles;
- char buf[512];
- Display *disp = NULL;
- Window root = -1;
- Window win = -1;
-
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-
- if (!strlen(tech_pvt->X11_display))
- strcpy(tech_pvt->X11_display, getenv("DISPLAY"));
-
- if (!tech_pvt->tcp_srv_port)
- tech_pvt->tcp_srv_port = 10160;
-
- if (!tech_pvt->tcp_cli_port)
- tech_pvt->tcp_cli_port = 10161;
+ strncpy(value, where, sizeof(value) - 1);
- if (pipe(tech_pvt->SkypiaxHandles.fdesc)) {
- fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
- fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
- }
- SkypiaxHandles = &tech_pvt->SkypiaxHandles;
- disp = XOpenDisplay(tech_pvt->X11_display);
- if (!disp) {
- ERRORA("Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG,
- tech_pvt->X11_display);
- running = 0;
- return NULL;
- } else {
- DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, tech_pvt->X11_display);
- }
+ where = strsep(stringp, " ");
- int xfd;
- xfd = XConnectionNumber(disp);
- fcntl(xfd, F_SETFD, FD_CLOEXEC);
+ if (option_debug > 101)
+ DEBUGA_SKYPE
+ ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
- //FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd);
+ if (!strcasecmp(prop, "PARTNER_HANDLE")) {
+ 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);
+ return CALLFLOW_INCOMING_RING;
+ }
+ if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
+ snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s",
+ value, where ? " " : "", where ? where : "");
+ DEBUGA_SKYPE
+ ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
+ SKYPIAX_P_LOG, id, tech_pvt->callid_name);
+ }
+ if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
+ DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG,
+ id);
+ if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
+ tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
+ }
+ if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
+ DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
+ if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
+ tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
+ }
- SkypiaxHandles->disp = disp;
+ if (!strcasecmp(prop, "DTMF")) {
- if (skypiax_skype_present(SkypiaxHandles)) {
- root = DefaultRootWindow(disp);
- win =
- XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0,
- BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp,
- DefaultScreen
- (disp)));
+ DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
- SkypiaxHandles->win = win;
+ dtmf_received(tech_pvt, value);
+ }
- snprintf(buf, 512, "NAME skypiax");
+ if (!strcasecmp(prop, "FAILUREREASON")) {
+ DEBUGA_SKYPE
+ ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n",
+ SKYPIAX_P_LOG, id);
+ }
+ if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
+ if (strcasecmp(id, tech_pvt->skype_call_id)) {
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ if (option_debug > 1)
+ DEBUGA_SKYPE
+ ("We called a Skype contact and he answered us on skype_call: %s.\n",
+ SKYPIAX_P_LOG, id);
+ }
+ }
- if (!skypiax_skype_send_message(SkypiaxHandles, buf)) {
- ERRORA
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
- SKYPIAX_P_LOG);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- running = 0;
- return NULL;
- }
+ if (!strcasecmp(prop, "STATUS")) {
- snprintf(buf, 512, "PROTOCOL 6");
- if (!skypiax_skype_send_message(SkypiaxHandles, buf)) {
- ERRORA
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
- SKYPIAX_P_LOG);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- running = 0;
- return NULL;
- }
+ if (!strcasecmp(value, "RINGING")) {
+ char msg_to_skype[1024];
+ if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) {
+ /* we are not calling out */
- /* perform an events loop */
- XEvent an_event;
- char buf[21]; /* can't be longer */
- char buffer[17000];
- char *b;
- int i;
+ if (!strlen(tech_pvt->skype_call_id)) { //FIXME
+ /* we are not inside an active call */
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
+ tech_pvt->interface_state = SKYPIAX_STATE_RING;
+ /* no owner, no active call, let's answer */
+ skypiax_skype_write(tech_pvt, "SET AGC OFF");
+ skypiax_sleep(10000);
+ skypiax_skype_write(tech_pvt, "SET AEC OFF");
+ skypiax_sleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
+ sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ if (option_debug)
+ DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
+ SKYPIAX_P_LOG, id);
+ 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 refuse */
+ sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ skypiax_sleep(10000);
+ DEBUGA_SKYPE
+ ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
+ SKYPIAX_P_LOG, id);
- b = buffer;
+ }
+ } else {
+ /* we are calling out */
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
+ tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
+ //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
+ 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);
+ }
+ } else if (!strcasecmp(value, "EARLYMEDIA")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
+ tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
+ //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
+ DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
+ SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "MISSED")) {
+ DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
- while (1) {
- XNextEvent(disp, &an_event);
- if (!running)
- break;
- switch (an_event.type) {
- case ClientMessage:
+ } else if (!strcasecmp(value, "FINISHED")) {
+ //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
+ tech_pvt->skype_call_id[0] = '\0';
- if (an_event.xclient.format != 8)
- break;
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
- for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
- buf[i] = an_event.xclient.data.b[i];
+ } else if (!strcasecmp(value, "CANCELLED")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
+ if (option_debug)
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
+ SKYPIAX_P_LOG, id);
+ tech_pvt->skype_call_id[0] = '\0';
- buf[i] = '\0';
+ if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ }
+ } else if (!strcasecmp(value, "FAILED")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
+ if (option_debug)
+ DEBUGA_SKYPE
+ ("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';
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return CALLFLOW_INCOMING_HANGUP;
+ } else if (!strcasecmp(value, "REFUSED")) {
+ if (!strcasecmp(id, tech_pvt->skype_call_id)) {
+ /* this is the id of the call we are in, probably we generated it */
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
+ if (option_debug)
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
+ SKYPIAX_P_LOG, id);
+ 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';
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ /* we're here because were us that refused an incoming call */
+ DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
- strcat(buffer, buf);
+ }
+ } else if (!strcasecmp(value, "ROUTING")) {
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
+ tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
+ 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;
+ 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];
+ tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
+ strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+ tech_pvt->interface_state = SKYPIAX_STATE_UP;
+ DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
+ tech_pvt->tcp_cli_port);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+ start_audio_threads(tech_pvt);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
+ tech_pvt->tcp_srv_port);
+ skypiax_skype_write(tech_pvt, msg_to_skype);
- if (i < 20) { /* last fragment */
- unsigned int howmany;
+ tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
- howmany = strlen(b) + 1;
+ if (!strlen(tech_pvt->session_uuid_str)) {
+ DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
+ new_inbound_channel(tech_pvt);
+ } else {
+ DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
+ outbound_channel_answered(tech_pvt);
+ }
- howmany = write(SkypiaxHandles->fdesc[1], b, howmany);
- memset(buffer, '\0', 17000);
- }
+ } else {
+ WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG,
+ id, value);
+
+ }
+ } //STATUS
+
+ } //CALL
+
+ a = 0;
+ } //message end
+ } //read_from_pipe
- break;
- default:
- break;
- }
}
- } else {
- ERRORA
- ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n",
- SKYPIAX_P_LOG);
- running = 0;
- return NULL;
}
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- running = 0;
- return NULL;
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ return 0;
}
-#endif // WIN32
-int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype)
+int skypiax_skype_senddigit(private_t * tech_pvt, char digit)
+{
+ char msg_to_skype[1024];
+ if (option_debug > 10) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ }
+
+ DEBUGA_SKYPE("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
+
+ sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit);
+
+ skypiax_skype_write(tech_pvt, msg_to_skype);
+
+ if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return 0;
+}
+
+int skypiax_skype_call(private_t * tech_pvt, char *rdest, int timeout)
{
+ char msg_to_skype[1024];
+
+ if (option_debug > 10) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ }
+ skypiax_sleep(5000);
+ DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
+ skypiax_skype_write(tech_pvt, "SET AGC OFF");
+ skypiax_sleep(10000);
+ skypiax_skype_write(tech_pvt, "SET AEC OFF");
+ skypiax_sleep(10000);
+
+ sprintf(msg_to_skype, "CALL %s", rdest);
+ if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) {
+
+ ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG);
+ if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return -1;
+ }
+ return 0;
+}
+
+
+
#ifdef WIN32
+
+enum {
+ SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully
+ attached and API window handle can be found
+ in wParam parameter */
+ SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged
+ connection request and is waiting
+ for confirmation from the user. */
+ /* The client is not yet attached
+ * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */
+ SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly
+ denied access to client */
+ SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /* API is not available
+ at the moment.
+ For example, this happens when no user
+ is currently logged in. */
+ /* Client should wait for
+ * SKYPECONTROLAPI_ATTACH_API_AVAILABLE
+ * broadcast before making any further */
+ /* connection attempts. */
+ SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
+};
+
+/* Visual C do not have strsep? */
+char
+ *strsep(char **stringp, const char *delim)
+{
+ char *res;
+
+ if (!stringp || !*stringp || !**stringp)
+ return (char *) 0;
+
+ res = *stringp;
+ while (**stringp && !strchr(delim, **stringp))
+ ++(*stringp);
+
+ if (**stringp) {
+ **stringp = '\0';
+ ++(*stringp);
+ }
+
+ return res;
+}
+
+int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype)
+{
static char acInputRow[1024];
COPYDATASTRUCT oCopyData;
-#else /* WIN32 */
- struct SkypiaxHandles *SkypiaxHandles;
-#endif /* WIN32 */
DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
-#ifdef WIN32
-
if (option_debug > 100) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
@@ -1003,7 +1011,7 @@
(WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
(LPARAM) & oCopyData) == FALSE) {
ERRORA
- ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n",
+ ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then launch Skypiax and try again.\n",
SKYPIAX_P_LOG);
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
@@ -1011,23 +1019,6 @@
return -1;
}
}
-#else /* WIN32 */
-
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
- SkypiaxHandles = &tech_pvt->SkypiaxHandles;
-
- if (!skypiax_skype_send_message(SkypiaxHandles, msg_to_skype)) {
- ERRORA
- ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n",
- SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- }
-#endif /* WIN32 */
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
@@ -1036,507 +1027,508 @@
}
-int skypiax_skype_read(private_t * tech_pvt)
+LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
+ LPARAM ulParam)
{
+ LRESULT lReturnCode;
+ int fIssueDefProc;
+ private_t *tech_pvt = NULL;
- char read_from_pipe[4096];
- char messaggio[4096];
- char messaggio_2[4096];
- char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
- char **stringp = NULL;
- int rt;
- int a;
- unsigned int howmany;
- unsigned int i;
-#ifndef WIN32
- int fdselect;
- fd_set fs;
- struct timeval to;
-#endif /* WIN32 */
-
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
+ lReturnCode = 0;
+ fIssueDefProc = 0;
+ tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA);
+ switch (uiMessage) {
+ case WM_CREATE:
+ tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams;
+ SetWindowLong(hWindow, GWL_USERDATA, (LONG) tech_pvt);
+ DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG);
+ break;
+ case WM_DESTROY:
+ NOTICA("got DESTROY\n", SKYPIAX_P_LOG);
+ tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
+ PostQuitMessage(0);
+ break;
+ case WM_COPYDATA:
+ if (tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
+ unsigned int howmany;
+ char msg_from_skype[2048];
- memset(read_from_pipe, 0, 4096);
- memset(messaggio, 0, 4096);
- memset(messaggio_2, 0, 4096);
+ PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
-#ifdef WIN32
- rt = 1;
-#else /* WIN32 */
- fdselect = tech_pvt->SkypiaxHandles.fdesc[0];
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //500 msec
- to.tv_sec = 0;
- rt = select(fdselect + 1, &fs, NULL, NULL, &to);
-#endif /* WIN32 */
+ memset(msg_from_skype, '\0', sizeof(msg_from_skype));
+ strncpy(msg_from_skype, (const char *) poCopyData->lpData,
+ sizeof(msg_from_skype) - 2);
- if (rt > 0) {
- if (tech_pvt->SkypiaxHandles.fdesc[0]) {
- howmany = sizeof(read_from_pipe);
+ howmany = strlen(msg_from_skype) + 1;
howmany =
- skypiax_pipe_read(tech_pvt->SkypiaxHandles.fdesc[0], (short *) read_from_pipe,
- howmany);
-
- a = 0;
- for (i = 0; i < howmany; i++) {
- messaggio[a] = read_from_pipe[i];
- a++;
-
- if (read_from_pipe[i] == '\0') {
-
- //DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio);
- DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, messaggio);
-
- if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
- just authorized */
- DEBUGA_SKYPE
- ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
- SKYPIAX_P_LOG);
- skypiax_sleep(1000000);
- skypiax_skype_write(tech_pvt, "PROTOCOL 6");
- skypiax_sleep(10000);
- return 0;
- }
-
- if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
- ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
- SKYPIAX_P_LOG, messaggio);
- tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
- tech_pvt->skype_call_id[0] = '\0';
-
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
- }
-
- strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1);
-
- buf = messaggio;
- stringp = &buf;
- where = strsep(stringp, " ");
- if (!where) {
- WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio);
- }
-
- if (!strcasecmp(messaggio, "#333")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[11]); */
- memset(tech_pvt->skype_friends, 0, 4096);
- strncpy(tech_pvt->skype_friends, &messaggio_2[11], 4095);
- }
- if (!strcasecmp(messaggio, "#222")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[10]); */
- memset(tech_pvt->skype_fullname, 0, 512);
- strncpy(tech_pvt->skype_fullname, &messaggio_2[10], 511);
- }
- if (!strcasecmp(messaggio, "#765")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[10]); */
- memset(tech_pvt->skype_displayname, 0, 512);
- strncpy(tech_pvt->skype_displayname, &messaggio_2[10], 511);
+ skypiax_pipe_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype,
+ howmany);
+ //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype);
+ lReturnCode = 1;
+ }
+ break;
+ default:
+ if (tech_pvt && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+ if (uiMessage ==
+ tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+ switch (ulParam) {
+ case SKYPECONTROLAPI_ATTACH_SUCCESS:
+ if (!tech_pvt->SkypiaxHandles.api_connected) {
+ DEBUGA_SKYPE("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
+ tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
+ tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle =
+ tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle;
}
- if (!strcasecmp(messaggio, "ERROR")) {
- ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
- tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
- tech_pvt->skype_call_id[0] = '\0';
-
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
+ break;
+ case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
+ DEBUGA_SKYPE
+ ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n",
+ SKYPIAX_P_LOG);
+ skypiax_sleep(5000);
+ if (!tech_pvt->SkypiaxHandles.api_connected) {
+ SendMessage(HWND_BROADCAST,
+ tech_pvt->SkypiaxHandles.
+ win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+ (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
+ 0);
}
- if (!strcasecmp(messaggio, "CURRENTUSERHANDLE")) {
- strncpy(obj, where, sizeof(obj) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(id, where, sizeof(id) - 1);
-
- if (!strcasecmp(id, tech_pvt->skype_user)) {
- tech_pvt->SkypiaxHandles.api_connected = 1;
- DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user);
- }
+ break;
+ case SKYPECONTROLAPI_ATTACH_REFUSED:
+ ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG);
+ break;
+ case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
+ ERRORA("Skype API not (yet?) available\n", SKYPIAX_P_LOG);
+ break;
+ case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
+ DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
+ skypiax_sleep(5000);
+ if (!tech_pvt->SkypiaxHandles.api_connected) {
+ SendMessage(HWND_BROADCAST,
+ tech_pvt->SkypiaxHandles.
+ win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+ (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
+ 0);
}
+ break;
+ default:
+ WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG);
+ }
+ lReturnCode = 1;
+ break;
+ }
+ }
+ fIssueDefProc = 1;
+ break;
+ }
+ if (fIssueDefProc)
+ lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam);
+ return (lReturnCode);
+}
- if (!strcasecmp(messaggio, "USER")) {
- strncpy(obj, where, sizeof(obj) - 1);
-
- where = strsep(stringp, " ");
+int win32_Initialize_CreateWindowClass(private_t * tech_pvt)
+{
+ unsigned char *paucUUIDString;
+ RPC_STATUS lUUIDResult;
+ int fReturnStatus;
+ UUID oUUID;
- strncpy(id, where, sizeof(id) - 1);
+ fReturnStatus = 0;
+ lUUIDResult = UuidCreate(&oUUID);
+ tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle =
+ (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
+ if (tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle != NULL
+ && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) {
+ if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) {
+ WNDCLASS oWindowClass;
- where = strsep(stringp, " ");
+ strcpy(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "Skype-API-Skypiax-");
+ strcat(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName,
+ (char *) paucUUIDString);
- strncpy(prop, where, sizeof(prop) - 1);
+ oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
+ oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present;
+ oWindowClass.cbClsExtra = 0;
+ oWindowClass.cbWndExtra = 0;
+ oWindowClass.hInstance = tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle;
+ oWindowClass.hIcon = NULL;
+ oWindowClass.hCursor = NULL;
+ oWindowClass.hbrBackground = NULL;
+ oWindowClass.lpszMenuName = NULL;
+ oWindowClass.lpszClassName = tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName;
- if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
- char msg_to_skype[256];
- DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop);
+ if (RegisterClass(&oWindowClass) != 0)
+ fReturnStatus = 1;
- //FIXME: TODO: allow authorization based on config param
- sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- }
- }
+ RpcStringFree(&paucUUIDString);
+ }
+ }
+ if (fReturnStatus == 0)
+ CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle),
+ tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
+ return (fReturnStatus);
+}
- if (!strcasecmp(messaggio, "MESSAGE")) {
- strncpy(obj, where, sizeof(obj) - 1);
+void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt)
+{
+ UnregisterClass(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName,
+ tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle);
+ CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle),
+ tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
+}
- where = strsep(stringp, " ");
+int win32_Initialize_CreateMainWindow(private_t * tech_pvt)
+{
+ tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle =
+ CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
+ tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "",
+ WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
+ 128, 128, NULL, 0, tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle,
+ tech_pvt);
+ return (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0);
+}
- strncpy(id, where, sizeof(id) - 1);
+void win32_DeInitialize_DestroyMainWindow(private_t * tech_pvt)
+{
+ if (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL)
+ DestroyWindow(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle),
+ tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
+}
- where = strsep(stringp, " ");
- strncpy(prop, where, sizeof(prop) - 1);
+void *skypiax_do_skypeapi_thread_func(void *obj)
+{
+ private_t *tech_pvt = obj;
+#if defined(WIN32) && !defined(__CYGWIN__)
+ switch_status_t rv;
- if (!strcasecmp(prop, "STATUS")) {
+ switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0],
+ &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool);
+ rv =
+ switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0],
+ &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool);
+#else /* WIN32 */
+ if (pipe(tech_pvt->SkypiaxHandles.fdesc)) {
+ fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
+ fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
+ }
+#endif /* WIN32 */
- where = strsep(stringp, " ");
+ tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach =
+ RegisterWindowMessage("SkypeControlAPIAttach");
+ tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
+ RegisterWindowMessage("SkypeControlAPIDiscover");
- strncpy(value, where, sizeof(value) - 1);
+ skypiax_sleep(2000000);
- if (!strcasecmp(value, "RECEIVED")) {
- char msg_to_skype[256];
- DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s value: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop, value);
-
- //FIXME: TODO: allow authorization based on config param
- sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- }
- } else if (!strcasecmp(prop, "BODY")) {
- char msg_to_skype[256];
-
- DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop);
-
- //FIXME: TODO: on config param ???
- sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
+ if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
+ && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
+ if (win32_Initialize_CreateWindowClass(tech_pvt)) {
+ if (win32_Initialize_CreateMainWindow(tech_pvt)) {
+ if (SendMessage
+ (HWND_BROADCAST,
+ tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+ (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) {
+ tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle =
+ tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle;
+ while (1) {
+ MSG oMessage;
+ if (!running)
+ break;
+ while (GetMessage(&oMessage, 0, 0, 0)) {
+ TranslateMessage(&oMessage);
+ DispatchMessage(&oMessage);
}
-
}
+ }
+ win32_DeInitialize_DestroyMainWindow(tech_pvt);
+ }
+ win32_DeInitialize_DestroyWindowClass(tech_pvt);
+ }
+ }
- if (!strcasecmp(messaggio, "CALL")) {
-
- strncpy(obj, where, sizeof(obj) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(id, where, sizeof(id) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(prop, where, sizeof(prop) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(value, where, sizeof(value) - 1);
-
- where = strsep(stringp, " ");
-
- if (option_debug > 101)
- DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
-
- if (!strcasecmp(prop, "PARTNER_HANDLE")) {
- 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);
- return CALLFLOW_INCOMING_RING;
- }
- if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
- snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s",
- value, where ? " " : "", where ? where : "");
- DEBUGA_SKYPE
- ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
- SKYPIAX_P_LOG, id, tech_pvt->callid_name);
- }
- if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
- DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG,
- id);
- if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
- tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
- }
- if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
- DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
- if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
- tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
- }
-
- if (!strcasecmp(prop, "DTMF")) {
-
- DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
-
- dtmf_received(tech_pvt, value);
- }
-
- if (!strcasecmp(prop, "FAILUREREASON")) {
- DEBUGA_SKYPE
- ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n",
- SKYPIAX_P_LOG, id);
- }
- if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
- if (strcasecmp(id, tech_pvt->skype_call_id)) {
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- if (option_debug > 1)
- DEBUGA_SKYPE
- ("We called a Skype contact and he answered us on skype_call: %s.\n",
- SKYPIAX_P_LOG, id);
- }
- }
-
- if (!strcasecmp(prop, "STATUS")) {
-
- if (!strcasecmp(value, "RINGING")) {
- char msg_to_skype[1024];
- if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) {
- /* we are not calling out */
+ return NULL;
+}
- if (!strlen(tech_pvt->skype_call_id)) { //FIXME
- /* we are not inside an active call */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
- tech_pvt->interface_state = SKYPIAX_STATE_RING;
- /* no owner, no active call, let's answer */
- skypiax_skype_write(tech_pvt, "SET AGC OFF");
- skypiax_sleep(10000);
- skypiax_skype_write(tech_pvt, "SET AEC OFF");
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- if (option_debug)
- DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
- SKYPIAX_P_LOG, id);
- 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 refuse */
- sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- skypiax_sleep(10000);
- DEBUGA_SKYPE
- ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
- SKYPIAX_P_LOG, id);
+#else /* NOT WIN32 */
+int X11_errors_handler(Display * dpy, XErrorEvent * err)
+{
+ (void) dpy;
+ private_t *tech_pvt = NULL;
- }
- } else {
- /* we are calling out */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
- tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
- //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
- 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);
- }
- } else if (!strcasecmp(value, "EARLYMEDIA")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
- tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
- //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
- DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
- SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "MISSED")) {
- DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
+ xerror = err->error_code;
+ ERRORA("Received error code %d from X Server\n\n", SKYPIAX_P_LOG, xerror);
+ return 0; /* ignore the error */
+}
- } else if (!strcasecmp(value, "FINISHED")) {
- //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
- DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
- tech_pvt->skype_call_id[0] = '\0';
+static void X11_errors_trap(void)
+{
+ xerror = 0;
+ old_handler = XSetErrorHandler(X11_errors_handler);
+}
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
+static int X11_errors_untrap(void)
+{
+ XSetErrorHandler(old_handler);
+ return (xerror != BadValue) && (xerror != BadWindow);
+}
- } else if (!strcasecmp(value, "CANCELLED")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
- if (option_debug)
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
- SKYPIAX_P_LOG, id);
- tech_pvt->skype_call_id[0] = '\0';
+int skypiax_skype_send_message(struct SkypiaxHandles *SkypiaxHandles,
+ const char *message_P)
+{
- if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- }
- } else if (!strcasecmp(value, "FAILED")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
- if (option_debug)
- DEBUGA_SKYPE
- ("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';
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return CALLFLOW_INCOMING_HANGUP;
- } else if (!strcasecmp(value, "REFUSED")) {
- if (!strcasecmp(id, tech_pvt->skype_call_id)) {
- /* this is the id of the call we are in, probably we generated it */
- tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
- if (option_debug)
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
- SKYPIAX_P_LOG, id);
- 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';
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- /* we're here because were us that refused an incoming call */
- DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
+ Window w_P;
+ Display *disp;
+ Window handle_P;
+ int ok;
+ private_t *tech_pvt = NULL;
- }
- } else if (!strcasecmp(value, "ROUTING")) {
- tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
- tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
- 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;
- 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];
- tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
- strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
- tech_pvt->interface_state = SKYPIAX_STATE_UP;
- DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
- sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
- tech_pvt->tcp_cli_port);
- skypiax_skype_write(tech_pvt, msg_to_skype);
- start_audio_threads(tech_pvt);
- sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
- tech_pvt->tcp_srv_port);
- skypiax_skype_write(tech_pvt, msg_to_skype);
+ w_P = SkypiaxHandles->skype_win;
+ disp = SkypiaxHandles->disp;
+ handle_P = SkypiaxHandles->win;
- tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
+ Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
+ Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
+ unsigned int pos = 0;
+ unsigned int len = strlen(message_P);
+ XEvent e;
- if (!strlen(tech_pvt->session_uuid_str)) {
- DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
- new_inbound_channel(tech_pvt);
- } else {
- DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
- outbound_channel_answered(tech_pvt);
- }
+ memset(&e, 0, sizeof(e));
+ e.xclient.type = ClientMessage;
+ e.xclient.message_type = atom1; /* leading message */
+ e.xclient.display = disp;
+ e.xclient.window = handle_P;
+ e.xclient.format = 8;
- } else {
- WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG,
- id, value);
+ X11_errors_trap();
+ //XLockDisplay(disp);
+ do {
+ unsigned int i;
+ for (i = 0; i < 20 && i + pos <= len; ++i)
+ e.xclient.data.b[i] = message_P[i + pos];
+ XSendEvent(disp, w_P, False, 0, &e);
- }
- } //STATUS
+ e.xclient.message_type = atom2; /* following messages */
+ pos += i;
+ } while (pos <= len);
- } //CALL
+ XSync(disp, False);
+ ok = X11_errors_untrap();
- a = 0;
- } //message end
- } //read_from_pipe
+ if (!ok)
+ ERRORA("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror);
+ //XUnlockDisplay(disp);
+
+ return 1;
+}
+int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype)
+{
+ struct SkypiaxHandles *SkypiaxHandles;
+
+ DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ }
+ SkypiaxHandles = &tech_pvt->SkypiaxHandles;
+ if (!skypiax_skype_send_message(SkypiaxHandles, msg_to_skype)) {
+ ERRORA
+ ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax, then restart Skype, then launch Skypiax and try again.\n",
+ SKYPIAX_P_LOG);
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
+ return -1;
}
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return 0;
+
}
-int skypiax_skype_senddigit(private_t * tech_pvt, char digit)
+
+int skypiax_skype_present(struct SkypiaxHandles *SkypiaxHandles)
{
- char msg_to_skype[1024];
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True);
+
+ Atom type_ret;
+ int format_ret;
+ unsigned long nitems_ret;
+ unsigned long bytes_after_ret;
+ unsigned char *prop;
+ int status;
+ private_t *tech_pvt = NULL;
+
+ X11_errors_trap();
+ //XLockDisplay(disp);
+ status =
+ XGetWindowProperty(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->disp),
+ skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret,
+ &nitems_ret, &bytes_after_ret, &prop);
+ //XUnlockDisplay(disp);
+ X11_errors_untrap();
+
+ /* sanity check */
+ if (status != Success || format_ret != 32 || nitems_ret != 1) {
+ SkypiaxHandles->skype_win = (Window) - 1;
+ DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG);
+ return 0;
}
- DEBUGA_SKYPE("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
+ SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff;
+ DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG,
+ (unsigned int) SkypiaxHandles->skype_win);
+ return 1;
+}
- sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit);
+void skypiax_skype_clean_disp(void *data)
+{
- skypiax_skype_write(tech_pvt, msg_to_skype);
+ int *dispptr;
+ int disp;
+ private_t *tech_pvt = NULL;
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ dispptr = data;
+ disp = *dispptr;
+
+ if (disp) {
+ DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPIAX_P_LOG, disp);
+ close(disp);
+ DEBUGA_SKYPE("destroyed disp\n", SKYPIAX_P_LOG);
+ } else {
+ DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG);
}
- return 0;
+ DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG);
+ skypiax_sleep(1000);
}
-int skypiax_skype_call(private_t * tech_pvt, char *rdest, int timeout)
+void *skypiax_do_skypeapi_thread_func(void *obj)
{
- char msg_to_skype[1024];
- if (option_debug > 10) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ private_t *tech_pvt = obj;
+ struct SkypiaxHandles *SkypiaxHandles;
+ char buf[512];
+ Display *disp = NULL;
+ Window root = -1;
+ Window win = -1;
+
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+
+ if (!strlen(tech_pvt->X11_display))
+ strcpy(tech_pvt->X11_display, getenv("DISPLAY"));
+
+ if (!tech_pvt->tcp_srv_port)
+ tech_pvt->tcp_srv_port = 10160;
+
+ if (!tech_pvt->tcp_cli_port)
+ tech_pvt->tcp_cli_port = 10161;
+
+ if (pipe(tech_pvt->SkypiaxHandles.fdesc)) {
+ fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
+ fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
+ }
+ SkypiaxHandles = &tech_pvt->SkypiaxHandles;
+ disp = XOpenDisplay(tech_pvt->X11_display);
+ if (!disp) {
+ ERRORA("Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG,
+ tech_pvt->X11_display);
+ running = 0;
+ return NULL;
+ } else {
+ DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, tech_pvt->X11_display);
}
- skypiax_sleep(5000);
- DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
- skypiax_skype_write(tech_pvt, "SET AGC OFF");
- skypiax_sleep(10000);
- skypiax_skype_write(tech_pvt, "SET AEC OFF");
- skypiax_sleep(10000);
- sprintf(msg_to_skype, "CALL %s", rdest);
- if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) {
+ int xfd;
+ xfd = XConnectionNumber(disp);
+ fcntl(xfd, F_SETFD, FD_CLOEXEC);
- ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
+ SkypiaxHandles->disp = disp;
+
+ if (skypiax_skype_present(SkypiaxHandles)) {
+ root = DefaultRootWindow(disp);
+ win =
+ XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0,
+ BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp,
+ DefaultScreen
+ (disp)));
+
+ SkypiaxHandles->win = win;
+
+ snprintf(buf, 512, "NAME skypiax");
+
+ if (!skypiax_skype_send_message(SkypiaxHandles, buf)) {
+ ERRORA
+ ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
+ SKYPIAX_P_LOG);
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ running = 0;
+ return NULL;
}
- return -1;
+
+ snprintf(buf, 512, "PROTOCOL 6");
+ if (!skypiax_skype_send_message(SkypiaxHandles, buf)) {
+ ERRORA
+ ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
+ SKYPIAX_P_LOG);
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ running = 0;
+ return NULL;
+ }
+
+ /* perform an events loop */
+ XEvent an_event;
+ char buf[21]; /* can't be longer */
+ char buffer[17000];
+ char *b;
+ int i;
+
+ b = buffer;
+
+ while (1) {
+ XNextEvent(disp, &an_event);
+ if (!running)
+ break;
+ switch (an_event.type) {
+ case ClientMessage:
+
+ if (an_event.xclient.format != 8)
+ break;
+
+ for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
+ buf[i] = an_event.xclient.data.b[i];
+
+ buf[i] = '\0';
+
+ strcat(buffer, buf);
+
+ if (i < 20) { /* last fragment */
+ unsigned int howmany;
+
+ howmany = strlen(b) + 1;
+
+ howmany = write(SkypiaxHandles->fdesc[1], b, howmany);
+ memset(buffer, '\0', 17000);
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+ } else {
+ ERRORA
+ ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n",
+ SKYPIAX_P_LOG);
+ running = 0;
+ return NULL;
}
- //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
- return 0;
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ running = 0;
+ return NULL;
+
}
+#endif // WIN32
+
+
1
0