[Freeswitch-svn] [commit] r11444 - in freeswitch/branches/ctrix/mod_airpe: . osx_framework

FreeSWITCH SVN ctrix at freeswitch.org
Thu Jan 22 16:08:52 PST 2009


Author: ctrix
Date: Thu Jan 22 18:08:52 2009
New Revision: 11444

Log:
Initial (not working) Carbon stuff

Added:
   freeswitch/branches/ctrix/mod_airpe/osx_framework/
   freeswitch/branches/ctrix/mod_airpe/osx_framework/LICENSE
   freeswitch/branches/ctrix/mod_airpe/osx_framework/Skype.h
   freeswitch/branches/ctrix/mod_airpe/osx_framework/SkypeAPI-Carbon.h
   freeswitch/branches/ctrix/mod_airpe/osx_framework/SkypeAPI.h
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

Modified: freeswitch/branches/ctrix/mod_airpe/Makefile
==============================================================================
--- freeswitch/branches/ctrix/mod_airpe/Makefile	(original)
+++ freeswitch/branches/ctrix/mod_airpe/Makefile	Thu Jan 22 18:08:52 2009
@@ -3,7 +3,7 @@
 MODNAME=mod_airpe
 
 LOCAL_CFLAGS=
-LOCAL_LDFLAGS=-lX11
+#LOCAL_LDFLAGS=-lX11
 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
 

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	Thu Jan 22 18:08:52 2009
@@ -1,9 +1,103 @@
 
 #include "mod_airpe.h"
 
-#if defined (MACOSX) || defined(DARWIN)
+//#if defined (MACOSX) 
+//#if  defined(DARWIN)
+#if 1
 
-#error OSX Not yet supported
+
+#include "osx_framework/SkypeAPI-Carbon.h"
+
+struct skype_window_handler_s {
+    struct SkypeDelegate	delegate;
+
+    uint8_t			api_connected;
+    int				watchdog;
+};
+
+
+
+switch_status_t airpe_skype_watchdog_reset(skype_window_handler_t *window) {
+    window->watchdog = 0;
+    return SWITCH_STATUS_SUCCESS;
+}
+
+switch_status_t airpe_skype_watchdog_increment(skype_window_handler_t *window) {
+    window->watchdog++;
+
+    if ( window->watchdog >= 5 ) {
+    }
+
+    return SWITCH_STATUS_SUCCESS;
+}
+
+skype_window_handler_t *skype_window_alloc( switch_memory_pool_t *pool) {
+    return (skype_window_handler_t *) switch_core_alloc( pool, sizeof(skype_window_handler_t));
+}
+
+switch_status_t skype_restart( skype_window_handler_t *window, const char *params ) {
+    /* TODO */
+    return SWITCH_STATUS_SUCCESS;
+}
+
+switch_status_t airpe_skype_send_message(skype_window_handler_t *window, const char *message_P) {
+    CFStringRef string;
+
+    string = CFStringCreateWithCString(NULL, message_P, kCFStringEncodingUTF8 );
+    SendSkypeCommand(string);
+    CFRelease(string);
+
+    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;
+    }
+}
+
+
+
+/*****************************************************************************
+    THREADS
+ *****************************************************************************/
+void IncomingMessage(CFStringRef aNotificationString) {
+    char *string;
+
+    ADEBUG("Incoming message");
+
+    airpe_manage_skype_msg( airpe, string);
+
+}
+
+void *SWITCH_THREAD_FUNC airpe_skype_thread(switch_thread_t * thread, void *obj) {
+    airpe_interface_t *airpe = NULL;
+    struct SkypeDelegate *del;
+
+    assert(obj);
+
+    airpe = obj;
+
+    del = &airpe->skype_window->delegate;
+
+    del->clientApplicationName="airpe";
+    del->SkypeNotificationReceived=IncomingMessage;
+    SetSkypeDelegate(del);
+    ConnectToSkype();
+
+    while ( airpe->running ) {
+	switch_sleep(100000);
+    }
+
+    DisconnectFromSkype();
+    RemoveSkypeDelegate();
+
+    return NULL;
+}
 
 #endif
 

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	Thu Jan 22 18:08:52 2009
@@ -28,10 +28,10 @@
  *
  */
 
-#if defined (__GNUC__) && !(defined (MACOSX) || defined(DARWIN) ) 
-    
 #include "mod_airpe.h"
 
+#if defined (__GNUC__) && !(defined (MACOSX) || defined(DARWIN) ) 
+    
 #include <X11/Xlib.h>
 #include <X11/Xlibint.h>
 #include <X11/Xatom.h>
@@ -39,12 +39,12 @@
 #define X11_MSG_LEN	20
 
 struct skype_window_handler_s {
+    uint8_t	api_connected;
+    int		watchdog;
     Display 	*disp;
     Window 	win;
-    uint8_t	api_connected;
     int 	fdesc[2];
     Window 	skype_win;
-    int		watchdog;
 };
 
 

Added: freeswitch/branches/ctrix/mod_airpe/osx_framework/LICENSE
==============================================================================
--- (empty file)
+++ freeswitch/branches/ctrix/mod_airpe/osx_framework/LICENSE	Thu Jan 22 18:08:52 2009
@@ -0,0 +1,30 @@
+Copyright (c) 2004-2006, Skype Limited.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above
+    copyright notice, this list of conditions and the following
+    disclaimer in the documentation and/or other materials provided
+    with the distribution.
+  * Neither the name of the Skype Limited nor the names of its
+    contributors may be used to endorse or promote products derived
+    from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+

Added: freeswitch/branches/ctrix/mod_airpe/osx_framework/Skype.h
==============================================================================
--- (empty file)
+++ freeswitch/branches/ctrix/mod_airpe/osx_framework/Skype.h	Thu Jan 22 18:08:52 2009
@@ -0,0 +1,16 @@
+// $Id: Skype.h,v 1.2 2005/06/15 11:13:05 teelem Exp $
+/*
+ *  Skype.h
+ *  SkypeMac
+ *
+ *  Created by Janno Teelem on 12/04/2005.
+ *  Copyright (c) 2005 Skype Technologies S.A. All rights reserved.
+ *
+ */
+
+#include "SkypeAPI-Carbon.h"
+
+#ifdef __OBJC__
+	#include "SkypeAPI.h"
+#endif
+

Added: freeswitch/branches/ctrix/mod_airpe/osx_framework/SkypeAPI-Carbon.h
==============================================================================
--- (empty file)
+++ freeswitch/branches/ctrix/mod_airpe/osx_framework/SkypeAPI-Carbon.h	Thu Jan 22 18:08:52 2009
@@ -0,0 +1,45 @@
+// $Id: SkypeAPI-Carbon.h,v 1.4 2005/11/28 19:00:28 teelem Exp $
+/*
+ *  SkypeAPI-Carbon.h
+ *  SkypeMac
+ *
+ *  Created by Janno Teelem on 14/06/2005.
+ *  Copyright 2005 Skype Technologies S.A.. All rights reserved.
+ *
+ */
+
+#include <sys/cdefs.h>
+#include <Carbon/Carbon.h>
+
+__BEGIN_DECLS
+
+// In order to use Skype API, you must create a single instance of SkypeDelegate.
+// Set callback functions for the members of this struct and Skype will call these
+// functions to notify your application when something happens.
+struct SkypeDelegate
+{
+	// Required member
+	CFStringRef clientApplicationName;
+	
+	// Optional members, can be NULL
+	void (*SkypeNotificationReceived)(CFStringRef aNotificationString);
+	void (*SkypeAttachResponse)(unsigned int aAttachResponseCode);			// 0 - failed, 1 - success
+	void (*SkypeBecameAvailable)(CFPropertyListRef aNotification);
+	void (*SkypeBecameUnavailable)(CFPropertyListRef aNotification);
+};
+
+Boolean IsSkypeRunning(void);
+Boolean IsSkypeAvailable(void);
+
+// You must call this function, before calling ConnectToSkype() and SendSkypeCommand()
+void SetSkypeDelegate(struct SkypeDelegate* aDelegate);
+
+struct SkypeDelegate* GetSkypeDelegate(void);
+void RemoveSkypeDelegate(void);
+
+void ConnectToSkype(void);
+void DisconnectFromSkype(void);
+
+CFStringRef SendSkypeCommand(CFStringRef aCommandString);
+
+__END_DECLS
\ No newline at end of file

Added: freeswitch/branches/ctrix/mod_airpe/osx_framework/SkypeAPI.h
==============================================================================
--- (empty file)
+++ freeswitch/branches/ctrix/mod_airpe/osx_framework/SkypeAPI.h	Thu Jan 22 18:08:52 2009
@@ -0,0 +1,46 @@
+// $Id: SkypeAPI.h,v 1.5 2005/11/28 19:00:28 teelem Exp $
+//
+//  SkypeAPI.h
+//  SkypeMac
+//
+//  Created by Janno Teelem on 12/04/2005.
+//  Copyright (c) 2005 Skype Technologies S.A. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+ at protocol SkypeAPIDelegate;
+
+ at interface SkypeAPI : NSObject 
+{
+
+}
+
++ (BOOL)isSkypeRunning;				
++ (BOOL)isSkypeAvailable;	// You can only connect and send commands when this method returns YES.
+				// For example, when Skype is running, but user is logged out, then it returns NO.
+								
++ (void)setSkypeDelegate:(NSObject<SkypeAPIDelegate>*)aDelegate;
++ (NSObject<SkypeAPIDelegate>*)skypeDelegate;
++ (void)removeSkypeDelegate;
+
++ (void)connect;
++ (void)disconnect;
+
++ (NSString*)sendSkypeCommand:(NSString*)aCommandString;
+ at end
+
+
+// delegate protocol
+ at protocol SkypeAPIDelegate
+- (NSString*)clientApplicationName;
+ at end
+
+// delegate informal protocol
+ at interface NSObject (SkypeAPIDelegateInformalProtocol)
+- (void)skypeNotificationReceived:(NSString*)aNotificationString;
+- (void)skypeAttachResponse:(unsigned)aAttachResponseCode;				// 0 - failed, 1 - success
+- (void)skypeBecameAvailable:(NSNotification*)aNotification;
+- (void)skypeBecameUnavailable:(NSNotification*)aNotification;
+ at end
+



More information about the Freeswitch-svn mailing list