mod_skypiax: code before decl
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15765 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
302355202a
commit
dea8d99a81
|
@ -1544,8 +1544,8 @@ void *skypiax_do_skypeapi_thread_func(void *obj)
|
||||||
#else /* NOT WIN32 */
|
#else /* NOT WIN32 */
|
||||||
int X11_errors_handler(Display * dpy, XErrorEvent * err)
|
int X11_errors_handler(Display * dpy, XErrorEvent * err)
|
||||||
{
|
{
|
||||||
(void) dpy;
|
|
||||||
private_t *tech_pvt = NULL;
|
private_t *tech_pvt = NULL;
|
||||||
|
(void) dpy;
|
||||||
|
|
||||||
xerror = err->error_code;
|
xerror = err->error_code;
|
||||||
ERRORA("Received error code %d from X Server\n\n", SKYPIAX_P_LOG, xerror); ///FIXME why crash the entire skypiax? just crash the interface, instead
|
ERRORA("Received error code %d from X Server\n\n", SKYPIAX_P_LOG, xerror); ///FIXME why crash the entire skypiax? just crash the interface, instead
|
||||||
|
@ -1567,17 +1567,13 @@ static int X11_errors_untrap(void)
|
||||||
|
|
||||||
int skypiax_send_message(private_t * tech_pvt, const char *message_P)
|
int skypiax_send_message(private_t * tech_pvt, const char *message_P)
|
||||||
{
|
{
|
||||||
struct SkypiaxHandles *SkypiaxHandles;
|
struct SkypiaxHandles *SkypiaxHandles = &tech_pvt->SkypiaxHandles;
|
||||||
Window w_P;
|
Window w_P = SkypiaxHandles->skype_win;
|
||||||
Display *disp;
|
Display *disp = SkypiaxHandles->disp;
|
||||||
Window handle_P;
|
Window handle_P = SkypiaxHandles->win;
|
||||||
int ok;
|
int ok;
|
||||||
//private_t *tech_pvt = NULL;
|
//private_t *tech_pvt = NULL;
|
||||||
|
|
||||||
SkypiaxHandles = &tech_pvt->SkypiaxHandles;
|
|
||||||
w_P = SkypiaxHandles->skype_win;
|
|
||||||
disp = SkypiaxHandles->disp;
|
|
||||||
handle_P = SkypiaxHandles->win;
|
|
||||||
|
|
||||||
Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
|
Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
|
||||||
Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
|
Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
|
||||||
|
@ -1699,6 +1695,7 @@ void *skypiax_do_skypeapi_thread_func(void *obj)
|
||||||
Display *disp = NULL;
|
Display *disp = NULL;
|
||||||
Window root = -1;
|
Window root = -1;
|
||||||
Window win = -1;
|
Window win = -1;
|
||||||
|
int xfd;
|
||||||
|
|
||||||
if (!strlen(tech_pvt->X11_display))
|
if (!strlen(tech_pvt->X11_display))
|
||||||
strcpy(tech_pvt->X11_display, getenv("DISPLAY"));
|
strcpy(tech_pvt->X11_display, getenv("DISPLAY"));
|
||||||
|
@ -1723,7 +1720,6 @@ void *skypiax_do_skypeapi_thread_func(void *obj)
|
||||||
DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, tech_pvt->X11_display);
|
DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, tech_pvt->X11_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
int xfd;
|
|
||||||
xfd = XConnectionNumber(disp);
|
xfd = XConnectionNumber(disp);
|
||||||
fcntl(xfd, F_SETFD, FD_CLOEXEC);
|
fcntl(xfd, F_SETFD, FD_CLOEXEC);
|
||||||
|
|
||||||
|
@ -1733,7 +1729,7 @@ void *skypiax_do_skypeapi_thread_func(void *obj)
|
||||||
root = DefaultRootWindow(disp);
|
root = DefaultRootWindow(disp);
|
||||||
win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, DefaultScreen(disp)));
|
win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, DefaultScreen(disp)));
|
||||||
|
|
||||||
SkypiaxHandles->win = win;
|
SkypiaxHandles->win = win;
|
||||||
|
|
||||||
snprintf(buf, 512, "NAME skypiax");
|
snprintf(buf, 512, "NAME skypiax");
|
||||||
|
|
||||||
|
@ -1754,97 +1750,99 @@ void *skypiax_do_skypeapi_thread_func(void *obj)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* perform an events loop */
|
{
|
||||||
XEvent an_event;
|
/* perform an events loop */
|
||||||
char buf[21]; /* can't be longer */
|
XEvent an_event;
|
||||||
char buffer[17000];
|
char buf[21]; /* can't be longer */
|
||||||
char continuebuffer[17000];
|
char buffer[17000];
|
||||||
char *b;
|
char continuebuffer[17000];
|
||||||
int i;
|
char *b;
|
||||||
int continue_is_broken = 0;
|
int i;
|
||||||
int there_were_continues = 0;
|
int continue_is_broken = 0;
|
||||||
Atom atom_begin = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
|
int there_were_continues = 0;
|
||||||
Atom atom_continue = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
|
Atom atom_begin = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
|
||||||
|
Atom atom_continue = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
|
||||||
|
|
||||||
memset(buffer, '\0', 17000);
|
memset(buffer, '\0', 17000);
|
||||||
memset(continuebuffer, '\0', 17000);
|
memset(continuebuffer, '\0', 17000);
|
||||||
b = buffer;
|
b = buffer;
|
||||||
|
|
||||||
while (running && tech_pvt->running) {
|
while (running && tech_pvt->running) {
|
||||||
XNextEvent(disp, &an_event);
|
XNextEvent(disp, &an_event);
|
||||||
if (!(running && tech_pvt->running))
|
if (!(running && tech_pvt->running))
|
||||||
break;
|
|
||||||
switch (an_event.type) {
|
|
||||||
case ClientMessage:
|
|
||||||
|
|
||||||
if (an_event.xclient.format != 8)
|
|
||||||
break;
|
break;
|
||||||
|
switch (an_event.type) {
|
||||||
|
case ClientMessage:
|
||||||
|
|
||||||
for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
|
if (an_event.xclient.format != 8)
|
||||||
buf[i] = an_event.xclient.data.b[i];
|
break;
|
||||||
|
|
||||||
buf[i] = '\0';
|
for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
|
||||||
|
buf[i] = an_event.xclient.data.b[i];
|
||||||
|
|
||||||
//DEBUGA_SKYPE ("BUF=|||%s|||\n", SKYPIAX_P_LOG, buf);
|
buf[i] = '\0';
|
||||||
|
|
||||||
if (an_event.xclient.message_type == atom_begin) {
|
//DEBUGA_SKYPE ("BUF=|||%s|||\n", SKYPIAX_P_LOG, buf);
|
||||||
//DEBUGA_SKYPE ("BEGIN BUF=|||%s|||\n", SKYPIAX_P_LOG, buf);
|
|
||||||
|
|
||||||
if (strlen(buffer)) {
|
if (an_event.xclient.message_type == atom_begin) {
|
||||||
unsigned int howmany;
|
//DEBUGA_SKYPE ("BEGIN BUF=|||%s|||\n", SKYPIAX_P_LOG, buf);
|
||||||
howmany = strlen(b) + 1;
|
|
||||||
howmany = write(SkypiaxHandles->fdesc[1], b, howmany);
|
if (strlen(buffer)) {
|
||||||
WARNINGA("A begin atom while the previous message is not closed???? value of previous message (between vertical bars) is=|||%s|||, will be lost\n", SKYPIAX_P_LOG, buffer);
|
unsigned int howmany;
|
||||||
memset(buffer, '\0', 17000);
|
howmany = strlen(b) + 1;
|
||||||
|
howmany = write(SkypiaxHandles->fdesc[1], b, howmany);
|
||||||
|
WARNINGA("A begin atom while the previous message is not closed???? value of previous message (between vertical bars) is=|||%s|||, will be lost\n", SKYPIAX_P_LOG, buffer);
|
||||||
|
memset(buffer, '\0', 17000);
|
||||||
|
}
|
||||||
|
if(continue_is_broken){
|
||||||
|
continue_is_broken=0;
|
||||||
|
there_were_continues = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (an_event.xclient.message_type == atom_continue) {
|
||||||
|
//DEBUGA_SKYPE ("CONTINUE BUF=|||%s|||\n", SKYPIAX_P_LOG, buf);
|
||||||
|
|
||||||
|
if (!strlen(buffer)) {
|
||||||
|
DEBUGA_SKYPE
|
||||||
|
("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||, let's store it and hope next 'begin' will be the good one\n", SKYPIAX_P_LOG, buf);
|
||||||
|
strcat(continuebuffer, buf);
|
||||||
|
continue_is_broken = 1;
|
||||||
|
if (!strncmp(buf, "ognised identity", 15)) {
|
||||||
|
WARNINGA
|
||||||
|
("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n",
|
||||||
|
SKYPIAX_P_LOG, buf);
|
||||||
|
skypiax_sleep(1000000); //1 sec
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(continue_is_broken){
|
if(continue_is_broken){
|
||||||
continue_is_broken=0;
|
continue;
|
||||||
there_were_continues = 1;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (an_event.xclient.message_type == atom_continue) {
|
|
||||||
//DEBUGA_SKYPE ("CONTINUE BUF=|||%s|||\n", SKYPIAX_P_LOG, buf);
|
|
||||||
|
|
||||||
if (!strlen(buffer)) {
|
//DEBUGA_SKYPE ("i=%d, buffer=|||%s|||\n", SKYPIAX_P_LOG, i, buffer);
|
||||||
DEBUGA_SKYPE
|
strcat(buffer, buf);
|
||||||
("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||, let's store it and hope next 'begin' will be the good one\n", SKYPIAX_P_LOG, buf);
|
//DEBUGA_SKYPE ("i=%d, buffer=|||%s|||\n", SKYPIAX_P_LOG, i, buffer);
|
||||||
strcat(continuebuffer, buf);
|
strcat(buffer, continuebuffer);
|
||||||
continue_is_broken = 1;
|
//DEBUGA_SKYPE ("i=%d, buffer=|||%s|||\n", SKYPIAX_P_LOG, i, buffer);
|
||||||
if (!strncmp(buf, "ognised identity", 15)) {
|
memset(continuebuffer, '\0', 17000);
|
||||||
WARNINGA
|
|
||||||
("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n",
|
if (i < 20 || there_were_continues) { /* last fragment */
|
||||||
SKYPIAX_P_LOG, buf);
|
unsigned int howmany;
|
||||||
skypiax_sleep(1000000); //1 sec
|
|
||||||
}
|
howmany = strlen(b) + 1;
|
||||||
break;
|
|
||||||
|
howmany = write(SkypiaxHandles->fdesc[1], b, howmany);
|
||||||
|
//DEBUGA_SKYPE ("RECEIVED=|||%s|||\n", SKYPIAX_P_LOG, buffer);
|
||||||
|
memset(buffer, '\0', 17000);
|
||||||
|
XFlush(disp);
|
||||||
|
there_were_continues = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(continue_is_broken){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//DEBUGA_SKYPE ("i=%d, buffer=|||%s|||\n", SKYPIAX_P_LOG, i, buffer);
|
|
||||||
strcat(buffer, buf);
|
|
||||||
//DEBUGA_SKYPE ("i=%d, buffer=|||%s|||\n", SKYPIAX_P_LOG, i, buffer);
|
|
||||||
strcat(buffer, continuebuffer);
|
|
||||||
//DEBUGA_SKYPE ("i=%d, buffer=|||%s|||\n", SKYPIAX_P_LOG, i, buffer);
|
|
||||||
memset(continuebuffer, '\0', 17000);
|
|
||||||
|
|
||||||
if (i < 20 || there_were_continues) { /* last fragment */
|
|
||||||
unsigned int howmany;
|
|
||||||
|
|
||||||
howmany = strlen(b) + 1;
|
|
||||||
|
|
||||||
howmany = write(SkypiaxHandles->fdesc[1], b, howmany);
|
|
||||||
//DEBUGA_SKYPE ("RECEIVED=|||%s|||\n", SKYPIAX_P_LOG, buffer);
|
|
||||||
memset(buffer, '\0', 17000);
|
|
||||||
XFlush(disp);
|
|
||||||
there_were_continues = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue