[futurebasic] C API Conversion

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2005 : Group Archive : Group : All Groups

From: <russp@...>
Date: Sun, 27 Nov 2005 23:46:37 -0600
The saga continues...

This is like those teenage serial horror movies where the monster gets killed
and keeps coming back in the sequels.

In desperation after Robert suggested maybe the Skype framework would only
work in Tiger, I thought "what the heck" and ran the software update on my
10.3.9 machine.  My thinking was "maybe my panther's just sick rather than
obsolete".  Well dang if it didn't fix that problem!  Maybe my panther just
needed soothing.

So now I can connect to the Skype API.  The neat little assembler routines
from Robert P. work great and I was able to propogate them to do the other
commands in the API.

Here's my next question:
Skype responds back to another app by communication with the SkypeDelegate
structure which looks like this.

struct SkypeDelegate
{
    // Required member
    CFStringRef clientApplicationName;

    // Optional members, can be NULL
    void (*SkypeNotificationReceived)(CFStringRef aNotificationString);
    void (*SkypeAttachResponse)(unsigned int aAttachResponseCode);
    void (*SkypeBecameAvailable)(CFPropertyListRef aNotification);
    void (*SkypeBecameUnavailable)(CFPropertyListRef aNotification);
};

I just figured out tonight that except for clientApplicationName (which
Robert already figured out how to send), the other ones mean I should send a
pointer to a routine in my own App for Skype to call when something changes. 
Just in case anyone is interested this is explained here:
<http://share.skype.com/developer_zone/documentation/skype_api_for_osx/>

Me thinks, well, I'll just have some of these:

long if 0
"SkypeNotificationReceived" 
ENTERPROC fn SkypeNotificationReceived (aNotification as pointer)
EXITPROC

"SkypeAttachResponse" 
ENTERPROC fn SkypeAttachResponse (aAttachResponseCode% as short)
EXITPROC
end if

and then put the pointers in the delgate structure that Robert provided like
this:  All but one are turned off.

delegate.clientApplicationName= fn CFSTR( "TestProg" )
delegate.SkypeNotificationReceivedUPP=0
delegate.SkypeAttachResponseUPP=PROC "SkypeAttachResponse"     
delegate.SkypeBecameAvailableUPP=0
delegate.SkypeBecameUnavailableUPP=0

The problem:  When Skype tries to use these callbacks (like when I connect)
it crashes my App.

I have my program printing out the location of PROC "SkypeAttachResponse" so
I know where the routine sits in memory.  

The crash log looks like this:

Exception:  EXC_BAD_INSTRUCTION (0x0002)
Code[0]:    0x00000002
Code[1]:    0x000efc9c


Thread 0 Crashed:
0                            	0x000efc9c 0xb6040 + 0x39c5c
1   com.skype.skypeframework 	0xd00026fc +[SkypeAPI connect] + 0x1dc
(SkypeAPI.m:256)
2   com.skype.skypeframework 	0xd0003544 -[VirtualSkypeController connect] +
0x4c (SkypeAPI-Carbon.mm:131)
3   com.skype.skypeframework 	0xd000384c ConnectToSkype + 0x48
(SkypeAPI-Carbon.mm:194)
4                            	0x000ef488 ConnectToSkype + 0x24

The address on line 0 where is hosed is (0x000efc9c) is consistently 4 bytes
more than the location of the enterproc (0x000efc98).

Even with all the code from inside the PROC removed it crashes.  I guess I'm
doing something wrong with the setup but I'm lost again.  I assume its the
executable in the framework attached to my app that initiates the crash
rather than the Skype App since Skype does NOT have to be running to do any
of this.

I searched help and the board until I read a comment by Robert about the
first 8 bytes to an enterproc being in registers... and realized I needed to
bother you all again.  

ENTERPROC works on Pascal structures?  But this needs a C structure?  The
stack does what on entry?  Arghhh...

Once again I appreciate all the help and I hope I'm not being to needy (or
windy)

Thanks

russp







___________________________________________________________
Fidelity Communications Webmail - http://webmail.fidnet.com