Revision
14475
Author
seven
Date
2009-08-09 19:38:45 -0500 (Sun, 09 Aug 2009)

Log Message

Oops.. there files should be there

Added Paths

Diff

Added: freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/AutoreleasePool.h (0 => 14475)


--- freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/AutoreleasePool.h	                        (rev 0)
+++ freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/AutoreleasePool.h	2009-08-10 00:38:45 UTC (rev 14475)
@@ -0,0 +1,10 @@
+// static pool
+
+void InitAutoreleasePool();
+void ReleaseAutoreleasePool();  
+                                       
+// can we do this?
+// #import <Foundation/NSAutoreleasePool.h> 
+// 
+// NSAutoreleasePool * NewAutoreleasePool();
+// void DestroyAutoreleasePool(NSAutoreleasePool *the_pool);

Added: freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/AutoreleasePool.m (0 => 14475)


--- freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/AutoreleasePool.m	                        (rev 0)
+++ freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/AutoreleasePool.m	2009-08-10 00:38:45 UTC (rev 14475)
@@ -0,0 +1,27 @@
+#include <Foundation/Foundation.h>
+#include "AutoreleasePool.h" 
+
+static NSAutoreleasePool *pool = NULL;
+
+void InitAutoreleasePool()
+{
+  pool = [[NSAutoreleasePool alloc] init];
+}
+
+void ReleaseAutoreleasePool()
+{
+  [pool release];
+}
+
+NSAutoreleasePool * NewAutoreleasePool()
+{
+  return [[NSAutoreleasePool alloc] init];
+}
+
+void DestroyAutoreleasePool(NSAutoreleasePool *the_pool)
+{
+  [the_pool release];
+}
+
+
+

Added: freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/mac_client.c (0 => 14475)


--- freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/mac_client.c	                        (rev 0)
+++ freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/mac_client.c	2009-08-10 00:38:45 UTC (rev 14475)
@@ -0,0 +1,116 @@
+#include <stdio.h>
+#include <stdlib.h>  
+#include <pthread.h>
+#import <Skype/Skype.h>                  
+// #import <CoreFoundation/CoreFoundation.h>
+// #import <Cocoa/Cocoa.h>  
+// #include <Foundation/NSAutoreleasePool.h>
+#include "AutoreleasePool.h"
+	
+// #include <glibc.h>
+typedef struct SkypeDelegate SkypeDelegate;
+                                    
+int r = 0;
+void SkypeNotificationReceived(CFStringRef aNotificationString){
+	CFStringRef input = aNotificationString;
+	char *output = NULL;
+	
+	int strlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(input), kCFStringEncodingUTF8);
+	
+	output = (char *)CFStringGetCStringPtr(input, kCFStringEncodingUTF8);
+	if (!output)
+	{
+		output = NewPtr(strlen+1);
+		CFStringGetCString(input, output, strlen+1, kCFStringEncodingUTF8);
+	}
+	printf("Message received  %s\n", output);
+	
+}
+void SkypeAttachResponse(unsigned int aAttachResponseCode){
+	r = aAttachResponseCode;
+	printf("Got %d\n", r);
+}
+void SkypeBecameAvailable(CFPropertyListRef aNotification){}
+void SkypeBecameUnavailable(CFPropertyListRef aNotification){}
+
+void
+RunThread()
+{
+    RunApplicationEventLoop(); 
+}
+int main(int arcg, char **argv)
+{
+	SkypeDelegate skype_delegate;
+	skype_delegate.clientApplicationName = CFSTR("skypiax");
+	skype_delegate.SkypeNotificationReceived = SkypeNotificationReceived;
+   	skype_delegate.SkypeAttachResponse = SkypeAttachResponse;
+	skype_delegate.SkypeBecameAvailable = SkypeBecameAvailable;
+	skype_delegate.SkypeBecameUnavailable = SkypeBecameUnavailable; 
+	
+	pthread_t tid;
+    CFStringRef cmd, resp;
+    char c;    
+	char *tmp = (char *)malloc(sizeof(char) * 1024);
+
+
+    tmp[0] = '\0';
+    
+	                                
+	
+	// NSAutoreleasePool * pool = 
+	InitAutoreleasePool();
+    
+	// NSAutoreleasePool* pool	= [[NSAutoreleasePool alloc] init];
+
+	SetSkypeDelegate(&skype_delegate); 
+	
+	printf("is: %d\n", IsSkypeRunning());
+	RunCurrentEventLoop(1);
+
+	ConnectToSkype();
+	
+	
+	
+	while(r == 0) {
+		printf("sleep 1\n");
+		RunCurrentEventLoop(1);
+	}       	
+	
+	// SendSkypeCommand(CFSTR("CALL echo123"));
+	
+	pthread_create(&tid, NULL, (void *) RunThread, NULL);
+    while(c != EOF) {
+        c = getchar();
+        switch(c) {
+            case '\n': /* parse and execute. */
+                if (tmp[0] != '\0') {
+                    //cmd = CFStringCreateWithCString(kCFAllocatorDefault, tmp, kCFStringEncodingMacRoman);
+                    cmd = CFStringCreateWithCString(kCFAllocatorDefault, tmp, kCFStringEncodingASCII);
+					if (!strcmp("exit", tmp)) {
+						goto end;
+					}
+                    fprintf(stdout, "=>%s\n", CFStringGetCStringPtr(cmd, 0));
+                    resp = SendSkypeCommand(cmd);
+                    CFRelease(cmd);
+                    if (resp != NULL) {
+                        fprintf(stdout, "%s\n", CFStringGetCStringPtr(resp, 0));
+                    }
+                    bzero(tmp, sizeof(tmp));
+                }
+                break;
+            default: strncat(tmp, &c, 1);
+                break;
+        }
+    }
+                           
+	
+end:	                               
+	RunCurrentEventLoop(1);
+	DisconnectFromSkype();     
+	RemoveSkypeDelegate();
+	// release_pool();
+	
+	ReleaseAutoreleasePool();
+	// [pool release];
+	return 0;
+}
\ No newline at end of file

Added: freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/mac_client2.c (0 => 14475)


--- freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/mac_client2.c	                        (rev 0)
+++ freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/mac_client2.c	2009-08-10 00:38:45 UTC (rev 14475)
@@ -0,0 +1,124 @@
+#include <stdio.h>
+#include <stdlib.h>  
+#include <pthread.h>
+#import <Skype/Skype.h>                  
+// #import <CoreFoundation/CoreFoundation.h>
+// #import <Foundation/NSAutoreleasePool.h>
+#include "AutoreleasePool.h"
+	
+// #include <glibc.h>
+typedef struct SkypeDelegate SkypeDelegate;
+                                    
+int r = 0;
+void SkypeNotificationReceived(CFStringRef aNotificationString){
+	CFStringRef input = aNotificationString;
+	char *output = NULL;
+	
+	int strlen = CFStringGetMaximumSizeForEncoding(CFStringGetLength(input), kCFStringEncodingUTF8);
+	
+	output = (char *)CFStringGetCStringPtr(input, kCFStringEncodingUTF8);
+	if (!output)
+	{
+		output = NewPtr(strlen+1);
+		CFStringGetCString(input, output, strlen+1, kCFStringEncodingUTF8);
+	}
+	printf("Message received  %s\n", output);
+
+}
+void SkypeAttachResponse(unsigned int aAttachResponseCode){
+	r = aAttachResponseCode;
+	printf("Got %d\n", r);
+}
+void SkypeBecameAvailable(CFPropertyListRef aNotification){}
+void SkypeBecameUnavailable(CFPropertyListRef aNotification){}
+
+void RunThread()
+{
+    RunApplicationEventLoop(); 
+}
+
+void skype_thread()
+{
+	SkypeDelegate skype_delegate;
+	skype_delegate.clientApplicationName = CFSTR("skypiax");
+	skype_delegate.SkypeNotificationReceived = SkypeNotificationReceived;
+   	skype_delegate.SkypeAttachResponse = SkypeAttachResponse;
+	skype_delegate.SkypeBecameAvailable = SkypeBecameAvailable;
+	skype_delegate.SkypeBecameUnavailable = SkypeBecameUnavailable; 
+	    
+	OSStatus status;
+	// NSAutoreleasePool * pool = 
+	InitAutoreleasePool();
+    
+	// NSAutoreleasePool* pool	= [[NSAutoreleasePool alloc] init];
+
+	SetSkypeDelegate(&skype_delegate); 
+	
+	printf("IsSkypeRunning: %d\n", IsSkypeRunning());
+	RunCurrentEventLoop(1);
+
+	ConnectToSkype();
+	
+	
+	while(r == 0) {
+		printf("sleep 1\n");
+		status = RunCurrentEventLoop(1);
+		printf("Event loop status: %d\n", (int)status);
+		sleep(1);
+	}       	
+	
+	// SendSkypeCommand(CFSTR("CALL echo123"));
+	                
+	while(r) {
+		RunCurrentEventLoop(1);
+	}
+	
+	RunCurrentEventLoop(1);
+	DisconnectFromSkype();     
+	RemoveSkypeDelegate();
+	// release_pool();
+	
+	ReleaseAutoreleasePool();
+	// [pool release];
+	
+}
+int main(int arcg, char **argv)
+{
+	pthread_t tid;                               
+	// pthread_t tid2;
+    CFStringRef cmd, resp;
+    char c;    
+	char *tmp = (char *)malloc(sizeof(char) * 1024);
+
+
+    tmp[0] = '\0';
+    
+	                	
+	pthread_create(&tid, NULL, (void *) skype_thread, NULL);
+	// pthread_create(&tid2, NULL, (void *) RunThread, NULL);
+
+    while(c != EOF) {
+        c = getchar();
+        switch(c) {
+            case '\n': /* parse and execute. */
+                if (tmp[0] != '\0') {
+                    //cmd = CFStringCreateWithCString(kCFAllocatorDefault, tmp, kCFStringEncodingMacRoman);
+                    cmd = CFStringCreateWithCString(kCFAllocatorDefault, tmp, kCFStringEncodingASCII);
+					if (!strcmp("exit", tmp)) {
+						exit(0);
+					}
+                    fprintf(stdout, "=>%s\n", CFStringGetCStringPtr(cmd, 0));
+                    resp = SendSkypeCommand(cmd);
+                    CFRelease(cmd);
+                    if (resp != NULL) {
+                        fprintf(stdout, "%s\n", CFStringGetCStringPtr(resp, 0));
+                    }
+                    bzero(tmp, sizeof(tmp));
+                }
+                break;
+            default: strncat(tmp, &c, 1);
+                break;
+        }
+    }
+	return 0;                       	
+}
\ No newline at end of file

Added: freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/mfile (0 => 14475)


--- freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/mfile	                        (rev 0)
+++ freeswitch/branches/seven/src/mod/endpoints/mod_skypiax/mfile	2009-08-10 00:38:45 UTC (rev 14475)
@@ -0,0 +1,11 @@
+#make -f mfile
+all: libs
+	gcc -g -fPIC -Wall -o mac_client -ObjC -framework Skype mac_client.c  -framework Carbon -framework Foundation -lpthread AutoreleasePool.o
+	gcc -g -fPIC -Wall -o mac_client2 -ObjC -framework Skype mac_client2.c  -framework Carbon -framework Foundation -lpthread AutoreleasePool.o
+	gcc  -g -fPIC -Wall -c -o skypiax_protocol.o -I. -I../../../include  -I../../../../libs/libteletone/src/ skypiax_protocol.c 
+
+libs:
+	gcc -c -o AutoreleasePool.o AutoreleasePool.m 
+	
+clean:
+	rm -f *.o
\ No newline at end of file