[Freeswitch-svn] [commit] r11547 - freeswitch/branches/ctrix/mod_airpe

FreeSWITCH SVN ctrix at freeswitch.org
Wed Jan 28 16:48:54 PST 2009


Author: ctrix
Date: Wed Jan 28 18:48:53 2009
New Revision: 11547

Log:
Some steps to OSX integration (still far away)

Modified:
   freeswitch/branches/ctrix/mod_airpe/Makefile
   freeswitch/branches/ctrix/mod_airpe/airpe_if_osx.c
   freeswitch/branches/ctrix/mod_airpe/airpe_if_x11.c
   freeswitch/branches/ctrix/mod_airpe/mod_airpe.c
   freeswitch/branches/ctrix/mod_airpe/mod_airpe.h

Modified: freeswitch/branches/ctrix/mod_airpe/Makefile
==============================================================================
--- freeswitch/branches/ctrix/mod_airpe/Makefile	(original)
+++ freeswitch/branches/ctrix/mod_airpe/Makefile	Wed Jan 28 18:48:53 2009
@@ -2,12 +2,12 @@
 
 MODNAME=mod_airpe
 
-LOCAL_CFLAGS=
+LOCAL_CFLAGS=-w
 LOCAL_OBJS=airpe_if_common.o airpe_api.o airpe_apps.o airpe_if_x11.o airpe_if_osx.o airpe_if_win32.o
 LOCAL_SOURCES=airpe_if_common.c airpe_api.c airpe_apps.c airpe_if_x11.c airpe_if_osx.c airpe_if_win32.c
 
 LOCAL_INSERT_LDFLAGS=\
-    if test $$osarch = "Darwin" ; then echo "-framework Skype -framework CoreFoundation" ; \
+    if test $$osarch = "Darwin" ; then echo "-framework Carbon -framework Skype" ; \
     else echo "-lX11" ; \
     fi;
 

Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_osx.c
==============================================================================
--- freeswitch/branches/ctrix/mod_airpe/airpe_if_osx.c	(original)
+++ freeswitch/branches/ctrix/mod_airpe/airpe_if_osx.c	Wed Jan 28 18:48:53 2009
@@ -13,7 +13,16 @@
     int				watchdog;
 };
 
+static switch_memory_pool_t *tech_pool;
 
+/*****************************************************************************
+    EXPORTED FUNCTIONS    
+ *****************************************************************************/
+
+void airpe_tech_set_pool(switch_memory_pool_t *pool) {
+    if ( !tech_pool )
+	tech_pool = pool;
+}
 
 switch_status_t airpe_skype_watchdog_reset(skype_window_handler_t *window) {
     window->watchdog = 0;
@@ -41,42 +50,60 @@
 switch_status_t airpe_skype_send_message(skype_window_handler_t *window, const char *message_P) {
     CFStringRef string;
 
+ADEBUG("Sending %s \n", message_P);
     string = CFStringCreateWithCString(NULL, message_P, kCFStringEncodingUTF8 );
     SendSkypeCommand(string);
-    CFRelease(string);
-    RunCurrentEventLoop(0.01);
+//    CFRelease(string);
+ADEBUG("Sent \n");
 
     return SWITCH_STATUS_SUCCESS;
 }
 
 switch_status_t airpe_skype_avalaible(skype_window_handler_t *window)
 {
-/*
     if ( IsSkypeAvailable() ) {
 	return SWITCH_STATUS_SUCCESS;
     }
     else {
 	return SWITCH_STATUS_FALSE;
     }
-*/
-	return SWITCH_STATUS_FALSE;
 }
 
-
-
 /*****************************************************************************
     THREADS
  *****************************************************************************/
 static int attached = -1;
 
+static char *ToCString(CFStringRef cstr) {
+    int strlen;
+    char *output;
+
+    if ( !cstr )
+	return NULL;
+    
+    strlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(cstr), kCFStringEncodingUTF8);
+    output = NewPtr(strlen+1);
+
+    CFStringGetCString(cstr, output, strlen+1, kCFStringEncodingUTF8);
+
+    return output;
+}
+
+
 static void IncomingMessage(CFStringRef aNotificationString) {
-    ADEBUG("Incoming message");
+    char *in;
+
+    in = ToCString(aNotificationString);
+    if ( in ) {
+	ADEBUG("Incoming message %s\n", in);
+    }
 }
 
 static void AttachResponse(unsigned int aAttachResponseCode) {
     ADEBUG("Attach: %d\n", aAttachResponseCode);
     attached = aAttachResponseCode;
 }
+
 void *SWITCH_THREAD_FUNC airpe_skype_thread(switch_thread_t * thread, void *obj) {
     airpe_interface_t *airpe = NULL;
     struct SkypeDelegate *del;
@@ -89,35 +116,39 @@
 	goto done;
     }
     RunCurrentEventLoop(0.1);
-/*
+
     if ( !IsSkypeRunning() ) {
 	ADEBUG("Sorry, not running\n");
 	goto done;
     }
     RunCurrentEventLoop(0.1);
-*/
-    airpe->running = 1;
 
+    airpe->running = 1;
     del = &airpe->skype_window->delegate;
     del->clientApplicationName=CFSTR("airpe");
     del->SkypeNotificationReceived=IncomingMessage;
     del->SkypeAttachResponse=AttachResponse;
 
+
+ADEBUG("\n");
     SetSkypeDelegate(del);
     RunCurrentEventLoop(0.1);
     ConnectToSkype();
     RunCurrentEventLoop(0.1);
 
+ADEBUG("\n");
     while ( airpe->running && attached !=1  ) {
-//	ADEBUG("Sorry, not attached\n");
+	ADEBUG("Sorry, not yet attached\n");
 	RunCurrentEventLoop(0.01);
     }
 
+ADEBUG("\n");
     if ( !attached && airpe->running ) {
-	ADEBUG("Sorry, not attached\n");
+	ADEBUG("Sorry, not attached. exiting\n");
 	goto done;
     }
 
+ADEBUG("\n");
     if ( airpe_on_connect_messages( airpe, 6 ) != SWITCH_STATUS_SUCCESS ) {
 	switch_log_printf(	SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, 
 				"airpe client %s. Failed to send handshake messages\n", 
@@ -126,9 +157,11 @@
     }
 
 
+ADEBUG("UUUUUUUUUUUUUUUUUU\n");
     while ( airpe->running ) {
 	RunCurrentEventLoop(0.01);
     }
+ADEBUG("AAAAAAAAAAAAAAAaaa\n");
 
     DisconnectFromSkype();
     RemoveSkypeDelegate();

Modified: freeswitch/branches/ctrix/mod_airpe/airpe_if_x11.c
==============================================================================
--- freeswitch/branches/ctrix/mod_airpe/airpe_if_x11.c	(original)
+++ freeswitch/branches/ctrix/mod_airpe/airpe_if_x11.c	Wed Jan 28 18:48:53 2009
@@ -47,7 +47,7 @@
     Window 	skype_win;
 };
 
-
+static switch_memory_pool_t *tech_pool;
 
 
 static XErrorHandler old_handler = 0;
@@ -72,6 +72,11 @@
     return (xerror != BadValue) && (xerror != BadWindow);
 }
 
+void airpe_tech_set_pool(switch_memory_pool_t *pool) {
+    if ( !tech_pool )
+	tech_pool = pool;
+}
+
 switch_status_t airpe_skype_watchdog_reset(skype_window_handler_t *window) {
     window->watchdog = 0;
     return SWITCH_STATUS_SUCCESS;

Modified: freeswitch/branches/ctrix/mod_airpe/mod_airpe.c
==============================================================================
--- freeswitch/branches/ctrix/mod_airpe/mod_airpe.c	(original)
+++ freeswitch/branches/ctrix/mod_airpe/mod_airpe.c	Wed Jan 28 18:48:53 2009
@@ -200,6 +200,7 @@
     airpe_audio_sockets_create(airpe);
 
     switch_threadattr_create(&attr_skype, airpe_module_pool);
+    switch_threadattr_detach_set(&attr_skype, 0);
     switch_threadattr_stacksize_set(attr_skype, SWITCH_THREAD_STACKSIZE);
 
     return switch_thread_create(&airpe->airpe_thread_skype, 
@@ -244,7 +245,7 @@
     /* I prefer not to expose airpe_endpoint_interface out of this file. */
     return switch_core_session_request(airpe_endpoint_interface, pool);
 }
-
+	
 
 /*****************************************************************************
     CHANNEL STATE HANDLERS
@@ -652,6 +653,7 @@
     pool = airpe_module_pool;
     
     if (!(xml = switch_xml_open_cfg("airpe.conf", &cfg, NULL))) {
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "airpe.conf not found\n");
 	return SWITCH_STATUS_TERM;
     }
 
@@ -873,13 +875,19 @@
 SWITCH_MODULE_LOAD_FUNCTION(mod_airpe_load)
 {
     airpe_module_pool = pool;
+    switch_status_t ret;
 
     memset(&globals, 0, sizeof(globals));
 
     switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, pool);
     switch_core_hash_init(&globals.interfaces_hash, pool);
 
-    load_config(0);
+    airpe_tech_set_pool(pool);
+
+    if ( (ret=load_config(0))!=SWITCH_STATUS_SUCCESS ) {
+	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading configuration!\n");
+	return ret;
+    }
 
     *module_interface = switch_loadable_module_create_module_interface(pool, modname);
 

Modified: freeswitch/branches/ctrix/mod_airpe/mod_airpe.h
==============================================================================
--- freeswitch/branches/ctrix/mod_airpe/mod_airpe.h	(original)
+++ freeswitch/branches/ctrix/mod_airpe/mod_airpe.h	Wed Jan 28 18:48:53 2009
@@ -225,6 +225,7 @@
 switch_status_t airpe_on_connect_messages( airpe_interface_t *airpe, int protocol );
 
 /* INTERFACE - PLATFORM DEPENDANT FUNCTIONS */
+void airpe_tech_set_pool(switch_memory_pool_t *pool);
 switch_status_t airpe_skype_watchdog_reset(skype_window_handler_t *window);
 switch_status_t airpe_skype_watchdog_increment(skype_window_handler_t *window);
 skype_window_handler_t *skype_window_alloc( switch_memory_pool_t *pool);



More information about the Freeswitch-svn mailing list