[Freeswitch-svn] [commit] r10765 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Mon Dec 15 02:05:51 PST 2008
Author: gmaruzz
Date: Mon Dec 15 05:05:50 2008
New Revision: 10765
Log:
skypiax: multiline on linux
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Mon Dec 15 05:05:50 2008
@@ -595,6 +595,7 @@
{
char *cf = "skypiax.conf";
switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
+ skypiax_interface_t *p = NULL;
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool);
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
@@ -672,6 +673,8 @@
char *fail_dial_regex = NULL;
char *enable_callerid = "true";
char *X11_display = NULL;
+ char *tcp_cli_port = NULL;
+ char *tcp_srv_port = NULL;
uint32_t interface_id = 0, to = 0, max = 0;
@@ -695,6 +698,10 @@
fail_dial_regex = val;
} else if (!strcasecmp(var, "hold-music")) {
hold_music = val;
+ } else if (!strcasecmp(var, "tcp_cli_port")) {
+ tcp_cli_port = val;
+ } else if (!strcasecmp(var, "tcp_srv_port")) {
+ tcp_srv_port = val;
} else if (!strcasecmp(var, "X11-display") || !strcasecmp(var, "X11_display")) {
X11_display = val;
} else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) {
@@ -710,7 +717,17 @@
"interface missing REQUIRED param 'X11_display'\n");
continue;
}
+ if (!tcp_cli_port) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "interface missing REQUIRED param 'tcp_cli_port'\n");
+ continue;
+ }
+ if (!tcp_srv_port) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+ "interface missing REQUIRED param 'tcp_srv_port'\n");
+ continue;
+ }
if (!id) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
"interface missing REQUIRED param 'id'\n");
@@ -771,13 +788,25 @@
} else {
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, "N/A");
}
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = atoi(tcp_cli_port);
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = atoi(tcp_srv_port);
+ //switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port, tcp_cli_port);
+ //switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port, tcp_srv_port);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].X11_display, X11_display);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
+
+
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].X11_display=%s\n",
interface_id, globals.SKYPIAX_INTERFACES[interface_id].X11_display);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port=%d\n",
+ interface_id, globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+ "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port=%d\n",
+ interface_id, globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n",
interface_id, globals.SKYPIAX_INTERFACES[interface_id].name);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Mon Dec 15 05:05:50 2008
@@ -148,6 +148,8 @@
char hold_music[256];
char type[256];
char X11_display[256];
+ int tcp_cli_port;
+ int tcp_srv_port;
struct AsteriskHandles AsteriskHandlesAst;
int interface_state; /*!< \brief 'state' of the interface (channel) */
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Mon Dec 15 05:05:50 2008
@@ -27,9 +27,9 @@
HANDLE volatile win32_hGlobal_PromptConsoleHandle = NULL;
#else /* NOT WIN32 */
#define SKYPE_X11_BUF_SIZE 512
-Window skype_win = (Window) - 1;
-static XErrorHandler old_handler = 0;
-static int xerror = 0;
+//Window skype_win = (Window) - 1;
+//static XErrorHandler old_handler = 0;
+//static int xerror = 0;
#endif /* WIN32 */
@@ -72,7 +72,7 @@
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
- my_addr.sin_port = htons(5556); //FIXME configurable!
+ my_addr.sin_port = htons(p->tcp_srv_port); //FIXME configurable!
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ERRORA("socket Error\n", SKYPIAX_P_LOG);
@@ -235,7 +235,7 @@
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
- my_addr.sin_port = htons(5558); //FIXME configurable!
+ my_addr.sin_port = htons(p->tcp_cli_port); //FIXME configurable!
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ERRORA("socket Error\n", SKYPIAX_P_LOG);
@@ -635,6 +635,7 @@
}
#else /* NOT WIN32 */
+#if 0
int X11_errors_handler(Display * dpy, XErrorEvent * err)
{
(void) dpy;
@@ -656,6 +657,7 @@
XSetErrorHandler(old_handler);
return (xerror != BadValue) && (xerror != BadWindow);
}
+#endif
int skypiax_skype_send_message(struct AsteriskHandles *AsteriskHandlesAst,
const char *message_P)
@@ -664,7 +666,7 @@
Window w_P;
Display *disp;
Window handle_P;
- struct skypiax_interface *p = NULL;
+ //struct skypiax_interface *p = NULL;
w_P = AsteriskHandlesAst->skype_win;
disp = AsteriskHandlesAst->disp;
@@ -675,7 +677,7 @@
unsigned int pos = 0;
unsigned int len = strlen(message_P);
XEvent e;
- int ok;
+ //int ok;
memset(&e, 0, sizeof(e));
e.xclient.type = ClientMessage;
@@ -684,7 +686,7 @@
e.xclient.window = handle_P;
e.xclient.format = 8;
- X11_errors_trap();
+ //X11_errors_trap();
//XLockDisplay(disp);
do {
unsigned int i;
@@ -698,17 +700,17 @@
XSync(disp, False);
//XUnlockDisplay(disp);
- ok = X11_errors_untrap();
+ //ok = X11_errors_untrap();
- if (!ok)
- DEBUGA_SKYPE("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror);
+ //if (!ok) DEBUGA_SKYPE("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror);
- return ok;
+ //return ok;
+ return 1;
}
-int skypiax_skype_present(Display * disp)
+int skypiax_skype_present(struct AsteriskHandles *AsteriskHandlesAst)
{
- Atom skype_inst = XInternAtom(disp, "_SKYPE_INSTANCE", True);
+ Atom skype_inst = XInternAtom(AsteriskHandlesAst->disp, "_SKYPE_INSTANCE", True);
Atom type_ret;
int format_ret;
@@ -718,25 +720,25 @@
int status;
struct skypiax_interface *p = NULL;
- X11_errors_trap();
+ //X11_errors_trap();
//XLockDisplay(disp);
status =
- XGetWindowProperty(disp, DefaultRootWindow(disp), skype_inst, 0, 1, False, XA_WINDOW,
+ XGetWindowProperty(AsteriskHandlesAst->disp, DefaultRootWindow(AsteriskHandlesAst->disp), skype_inst, 0, 1, False, XA_WINDOW,
&type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop);
//XUnlockDisplay(disp);
- X11_errors_untrap();
+ //X11_errors_untrap();
/* sanity check */
if (status != Success || format_ret != 32 || nitems_ret != 1) {
- skype_win = (Window) - 1;
+ AsteriskHandlesAst->skype_win = (Window) - 1;
DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG);
return 0;
}
- skype_win = *(const unsigned long *) prop & 0xffffffff;
+ AsteriskHandlesAst->skype_win = *(const unsigned long *) prop & 0xffffffff;
//DEBUGA_SKYPE("Skype instance found with id #%x\n", SKYPIAX_P_LOG,
DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG,
- (unsigned int) skype_win);
+ (unsigned int) AsteriskHandlesAst->skype_win);
return 1;
}
@@ -798,7 +800,9 @@
//FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd);
DEBUGA_SKYPE("PUSH disp %d\n", SKYPIAX_P_LOG, xfd);
- if (skypiax_skype_present(disp)) {
+ AsteriskHandlesAst->disp = disp;
+
+ if (skypiax_skype_present(AsteriskHandlesAst)) {
root = DefaultRootWindow(disp);
win =
XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0,
@@ -806,11 +810,10 @@
DefaultScreen
(disp)));
- DEBUGA_SKYPE("skype_win=%d win=%d\n", SKYPIAX_P_LOG, (unsigned int) skype_win,
- (unsigned int) win);
+ //DEBUGA_SKYPE("skype_win=%d win=%d\n", SKYPIAX_P_LOG, (unsigned int) skype_win, (unsigned int) win);
- AsteriskHandlesAst->skype_win = skype_win;
- AsteriskHandlesAst->disp = disp;
+ //AsteriskHandlesAst->skype_win = skype_win;
+ //AsteriskHandlesAst->disp = disp;
AsteriskHandlesAst->win = win;
snprintf(buf, SKYPE_X11_BUF_SIZE, "NAME skypiax");
@@ -1309,10 +1312,10 @@
DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
}
switch_sleep(100000);
- sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, p->tcp_srv_port);
skypiax_skype_write(p, msg_to_skype);
switch_sleep(100000);
- sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, p->tcp_cli_port);
skypiax_skype_write(p, msg_to_skype);
switch_sleep(100000);
}
More information about the Freeswitch-svn
mailing list