Example #1
0
boolean newdescwithhandle (AEDesc *desc, DescType typeCode, Handle h) {
	
	/*
	PBS 03/14/02: Create a new AEDesc with the given type and value.
	*/
	
	OSErr err = noErr;
	long len = gethandlesize (h);
	
	AEInitializeDescInline (desc);
		
	if (h == nil)
		
		err = AECreateDesc (typeCode, nil, 0, desc);
		
	else {
	
		lockhandle (h);
		
		err = AECreateDesc (typeCode, *h, len, desc);

		unlockhandle (h);
		} /*else*/
	
	return (err == noErr);		
	} /*newdescwithhandle*/
Example #2
0
// DestoryWacomContext
//
//	This function will instruct the Tablet Driver to delete a context that your
// application created. Please be nice and destroy all contexts you create
// before your application quits.
//
// parameters: UInt32 contextID - The ID returned to you when you created the
//											 context.
//
// returns: a contextID and noErr on success, else an AE error code
//////////////////////////////////////////////////////////////////////////////
OSErr	DestoryWacomContext(UInt32	contextID)
{
   AEDesc 			driverTarget,nullDesc,keyData,tObjSpecifier;
   AppleEvent		aeSend;
   OSErr				err;

   err = GetTabletDriverTarget(&driverTarget);
   if(err)
   {
      return err;
   }

   err = AECreateAppleEvent(kAECoreSuite,
                            kAEDelete,
                            &driverTarget,
                            kAutoGenerateReturnID,
                            kAnyTransactionID,
                            &aeSend);

   // Now tell the AE what to destroy
   //Create  NULL AEDesc, this will signify the end of the AEDesc Chain
   AEInitializeDesc(&nullDesc);
   err = AECreateDesc( typeNull, NULL, NULL, &nullDesc );

   AEInitializeDesc(&keyData);
   err = AECreateDesc( typeUInt32,
                       &contextID,	// This is the context ID we want to destroy
                       sizeof(contextID),
                       &keyData );

   err = CreateObjSpecifier(cContext,				// We want to destroy a context
                            &nullDesc,				// This is the last item in the chain
                            formUniqueID,			// use id to determine which context to destroy
                            &keyData,				// This is the Context ID descriptor created above
                            TRUE,					// delete the nullDesc, and KeyData descriptor for us
                            &tObjSpecifier);		// The created descriptor which says that we want to delete Context X

   err = AEPutParamDesc( &aeSend, keyDirectObject,  &tObjSpecifier);

   // Finally send the event
   err = AESend(&aeSend,	// The complete AE we created above
                NULL,		// Don't need a reply
                kAEWaitReply,
                kAEHighPriority,
                kDefaultTimeOut,
                NULL,
                NULL);
   AEDisposeDesc(&tObjSpecifier);
   AEDisposeDesc(&aeSend);
Example #3
0
OSStatus SendAppleEventToSystemProcess(AEEventID eventToSendID)
{
  AEAddressDesc targetDesc;
  static const  ProcessSerialNumber kPSNOfSystemProcess = {0, kSystemProcess };
  AppleEvent    eventReply  = {typeNull, NULL};
  AppleEvent    eventToSend = {typeNull, NULL};

  OSStatus status = AECreateDesc(typeProcessSerialNumber,
    &kPSNOfSystemProcess, sizeof(kPSNOfSystemProcess), &targetDesc);

  if (status != noErr)
    return status;

  status = AECreateAppleEvent(kCoreEventClass, eventToSendID,
    &targetDesc, kAutoGenerateReturnID, kAnyTransactionID, &eventToSend);
  AEDisposeDesc(&targetDesc);

  if (status != noErr)
    return status;

  status = AESendMessage(&eventToSend, &eventReply, kAENormalPriority, kAEDefaultTimeout);
  AEDisposeDesc(&eventToSend);

  if (status != noErr)
    return status;

  AEDisposeDesc(&eventReply);

  return status;
}
Example #4
0
static PyObject *AE_AECreateDesc(PyObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	DescType typeCode;
	char *dataPtr__in__;
	long dataPtr__len__;
	int dataPtr__in_len__;
	AEDesc result;
#ifndef AECreateDesc
	PyMac_PRECHECK(AECreateDesc);
#endif
	if (!PyArg_ParseTuple(_args, "O&s#",
	                      PyMac_GetOSType, &typeCode,
	                      &dataPtr__in__, &dataPtr__in_len__))
		return NULL;
	dataPtr__len__ = dataPtr__in_len__;
	_err = AECreateDesc(typeCode,
	                    dataPtr__in__, dataPtr__len__,
	                    &result);
	if (_err != noErr) return PyMac_Error(_err);
	_res = Py_BuildValue("O&",
	                     AEDesc_New, &result);
	return _res;
}
Example #5
0
OSErr BigSendAppleEvent(TargetID *targ,AEEventClass aeClass,AEEventID aeID,Ptr *data,short dataLen,DescType dataType,Boolean returnData,Boolean checkForHandlerErr)
{
	AEAddressDesc	targDesc={typeNull, nil};	// Desc for target
	AppleEvent		appOut={typeNull, nil},appIn={typeNull, nil};
	short			sendMode=kAENeverInteract;
	OSErr			err;
									
	if (returnData || checkForHandlerErr)
		sendMode+=kAEWaitReply;
	else
		sendMode+=kAENoReply;
									
	// Create the address desriptor
	err=AECreateDesc(typeTargetID,(Ptr)targ,sizeof(TargetID), &targDesc);
	if (err)
		return err;
		
	// now create the apple event which will be sent
	err=AECreateAppleEvent(aeClass,aeID,&targDesc,kAutoGenerateReturnID,kAnyTransactionID,&appOut);	
	if (err)
	{
		AEDisposeDesc(&targDesc);
		return err;
	}
	
	if (data && *data)
	{
		err=AEPutParamPtr(&appOut,keyDirectObject,typeChar,*data,dataLen);
		DisposePtr(*data);
		*data=0L;
		if (err)
		{
			AEDisposeDesc(&appOut);
			AEDisposeDesc(&targDesc);
		}
	}
		
	// Send the apple event	
	err=AESend(&appOut,&appIn,sendMode,kAENormalPriority,kAEDefaultTimeout,0L,0L);		
	if (err)
	{
		AEDisposeDesc(&appOut); 		// get rid of the apple events
		AEDisposeDesc(&appIn);
		AEDisposeDesc(&targDesc);	// and the address descriptor
	}
		
	if (returnData) // get info from reply event
		err=FetchParamAnySize(keyDirectObject,&appIn,data,dataType);
	
	// Get the error returned if any
	if (!err && checkForHandlerErr)
		err=FetchAEErr(&appIn);
	
	// The apple event has been sent, dispose of descriptors
	AEDisposeDesc(&appOut); 		// get rid of the apple events
	AEDisposeDesc(&appIn);
	AEDisposeDesc(&targDesc);	// and the address descriptor
	
	return err;
}
Example #6
0
Boolean IACnewsystemverb (OSType vclass, OSType vtoken, AppleEvent *event) {

	/*
	6/29/92 DW: special entry point for messages sent to system event handlers.
	
	implementation detail: this is accomplished by sending the message to ourself.
	*/
	
	AEAddressDesc adr; 
	OSErr ec;
	
	ProcessSerialNumber psn;

	psn.highLongOfPSN = 0;

	psn.lowLongOfPSN = kCurrentProcess;

	AECreateDesc (typeProcessSerialNumber, (Ptr) &psn, sizeof (psn), &adr);
	
	ec = AECreateAppleEvent (
		
		vclass, vtoken, &adr, kAutoGenerateReturnID, kAnyTransactionID, event);
	
	AEDisposeDesc (&adr);

	IACglobals.errorcode = ec;
	
	return (ec == noErr);
	} /*IACnewsystemverb*/
void StopRecorder(PRECORDER_PARM prec)
{
   OSAEvent theOSAEvent;        /* the apple event you are generating       */
   AEAddressDesc targetaddr;    /* the address descriptor for target app */
   PID           thePID;
   OSErr              rc = noErr;

   if (prec->recording)
   {
     rc = AERemoveEventHandler( kCoreEventClass,
                                kAENotifyRecording,
                                (AEEventHandlerUPP)RawEventRecordingProc,
                                FALSE );
     pmassert(prec->pmp->hab, rc == noErr );
     prec->recording = FALSE;
     rc = AEGetPID(APP_NAME, &thePID);
     rc = AECreateDesc(typePID, &thePID, sizeof(thePID), &targetaddr);
     rc = AECreateOSAEvent(kCoreEventClass,
                           kAEStopRecording,
                           &targetaddr,
                           kAutoGenerateReturnID,
                           kAnyTransactionID,
                           &theOSAEvent);
     rc = AESend(&theOSAEvent,
                 NULL,
                 kAENoReply,
                 kAENormalPriority,
                 kAEDefaultTimeout,
                 NULL,
                 NULL);
   }
}
Example #8
0
OSErr putMissingValueToReply(AppleEvent *reply)
{
	const static DescType missingValue = cMissingValue;
	OSErr err;
	AEDesc resultDesc;
	AECreateDesc(typeType, &missingValue, sizeof(missingValue), &resultDesc);
	err=AEPutParamDesc(reply, keyAEResult, &resultDesc);
	AEDisposeDesc(&resultDesc);
	return err;
}
	/* LowRunAppleScript compiles and runs an AppleScript
	provided as text in the buffer pointed to by text.  textLength
	bytes will be compiled from this buffer and run as an AppleScript
	using all of the default environment and execution settings.  resultData
        must be non-NULL, and should have been previously initialised, for example
        with _hs_initNull. The result returned by the execution
	command will be returned as typeUTF8Text in this descriptor record
	(or typeNull if there is no result information).  If the function
	returns errOSAScriptError, then resultData will be set to a
	descriptive error message describing the error (if one is
	available).  */
OSStatus LowRunAppleScript(const void* text, long textLength, AEDesc *resultData) {
	ComponentInstance theComponent;
	AEDesc scriptTextDesc;
	OSStatus err;
	OSAID scriptID, resultID;
		/* set up locals to a known state */
	theComponent = NULL;
	AECreateDesc(typeNull, NULL, 0, &scriptTextDesc);
	scriptID = kOSANullScript;
	resultID = kOSANullScript;
		/* open the scripting component */
	theComponent = OpenDefaultComponent(kOSAComponentType,
					typeAppleScript);
	if (theComponent == NULL) { err = paramErr; goto bail; }
		/* put the script text into an aedesc */
	err = AECreateDesc(typeUTF8Text, text, textLength, &scriptTextDesc);
	if (err != noErr) goto bail;
		/* compile the script */
	err = OSACompile(theComponent, &scriptTextDesc, 
					kOSAModeNull, &scriptID);
	if (err != noErr) goto bail;
		/* run the script/get the result */
	err = OSAExecute(theComponent, scriptID, kOSANullScript,
					kOSAModeNull, &resultID);
	if (resultData != NULL) {
		if (err == noErr && resultID != kOSANullScript) {
			OSADisplay(theComponent, resultID, typeUTF8Text,
						kOSAModeNull, resultData);
		}
	}
bail:
	if (err == errOSAScriptError) {
          AECreateDesc(typeNull, NULL, 0, resultData);
          OSAScriptError(theComponent, kOSAErrorMessage, typeUTF8Text, resultData);
        }

	AEDisposeDesc(&scriptTextDesc);
	if (scriptID != kOSANullScript) OSADispose(theComponent,  scriptID);
	if (resultID != kOSANullScript) OSADispose(theComponent,  resultID);
	if (theComponent != NULL) CloseComponent(theComponent);
	return err;
}
OSStatus SendOpenAE( AEDescList list )
{
    OSStatus		err;
    AEAddressDesc	theAddress;
    AppleEvent		dummyReply;
    AppleEvent		theEvent;

    theAddress.descriptorType	= typeNull;
    theAddress.dataHandle		= NULL;

    dummyReply.descriptorType	= typeNull;
    dummyReply.dataHandle		= NULL;

    theEvent.descriptorType		= typeNull;
    theEvent.dataHandle			= NULL;

    do {
        ProcessSerialNumber psn;

        err = GetCurrentProcess(&psn);
        if ( err != noErr) break;

        err =AECreateDesc(typeProcessSerialNumber, &psn, sizeof(ProcessSerialNumber), &theAddress);
        if ( err != noErr) break;

        err = AECreateAppleEvent(kCoreEventClass, kAEOpenDocuments, &theAddress, kAutoGenerateReturnID, kAnyTransactionID, &theEvent);
        if ( err != noErr) break;

        err = AEPutParamDesc(&theEvent, keyDirectObject, &list);
        if ( err != noErr) break;

        err = AESend(&theEvent, &dummyReply, kAENoReply, kAENormalPriority, kAEDefaultTimeout, NULL, NULL);
        if ( err != noErr) break;


    } while (false);

    if ( theAddress.dataHandle != NULL )
    {
        AEDisposeDesc( &theAddress );
    }

    if ( dummyReply.dataHandle != NULL )
    {
        AEDisposeDesc( &dummyReply );
    }

    if ( theEvent.dataHandle != NULL )
    {
        AEDisposeDesc( &theEvent );
    }

    return err;
}
Example #11
0
OSErr AEDescCreateUnicodeText(CFStringRef string, AEDesc* outDescPtr)
{
	OSErr err = noErr;
	DescType resultType = typeUnicodeText;
	
	UniCharCount length = CFStringGetLength(string);
	const UniChar *constBuff = CFStringGetCharactersPtr(string);
	if (constBuff == NULL) {
		UniChar *buffer;
		buffer = malloc(sizeof(UniChar)*length);
		CFStringGetCharacters(string, CFRangeMake(0, length), buffer);
		err = AECreateDesc(resultType, buffer, sizeof(UniChar)*length, outDescPtr);
		free(buffer);
	}
	else {
		err=AECreateDesc(resultType, constBuff, length*sizeof(UniChar), outDescPtr);
	}
	
	return err;
}
Example #12
0
// NOTE: AELists have 1-based indexes
OSErr AddIDToAEList(unsigned int id_num, long index, DescType object_type, AEDescList* list)
{
	AEDesc item_desc;
	AECreateDesc(typeNull, NULL, 0, &item_desc);
	OSStatus err = CreateAEDescFromID(id_num, object_type, &item_desc);
	if (noErr == err)
	{
		err = AEPutDesc(list, index, &item_desc);
		AEDisposeDesc(&item_desc);
	}
	return err;
}
Example #13
0
OSErr AEDescCreateUTF8Text(CFStringRef string, AEDesc* outDescPtr)
{
	OSErr err = noErr;
	CFStringEncoding kEncoding = kCFStringEncodingUTF8;
	DescType resultType = typeUTF8Text;
	const char *constBuff = CFStringGetCStringPtr(string, kEncoding);
	if (constBuff == NULL) {
		char *buffer;
		CFIndex charLen = CFStringGetLength(string);
		CFIndex maxLen = CFStringGetMaximumSizeForEncoding(charLen, kEncoding)+1; // +1 is for null termination.
		buffer = malloc(sizeof(char)*maxLen);
		CFStringGetCString(string, buffer, maxLen, kEncoding);
		err = AECreateDesc(resultType, buffer, strlen(buffer), outDescPtr);
		free(buffer);
	}
	else {
		err=AECreateDesc(resultType, constBuff, strlen(constBuff), outDescPtr);
	}
	
	return err;
}
Example #14
0
OSErr putAliasToReply(AliasHandle inAlias, AppleEvent *reply)
{
	OSErr err;
	AEDesc resultDesc;
	HLock((Handle)inAlias);
	err = AECreateDesc(typeAlias, (Ptr) (*inAlias),
							GetHandleSize((Handle) inAlias), &resultDesc);
	HUnlock((Handle)inAlias);
	err=AEPutParamDesc(reply, keyAEResult, &resultDesc);
	AEDisposeDesc(&resultDesc);
	return err;
}
Example #15
0
OSErr AEDescCreateWithCFURL(CFURLRef url, AEDesc* outDescPtr)
{
    OSStatus err;
    CFDataRef data = CFURLCreateData(kCFAllocatorDefault, url, kCFStringEncodingUTF8, true);
    if (data != NULL) {
        err = AECreateDesc('furl', CFDataGetBytePtr(data),
                           CFDataGetLength(data), outDescPtr);
        CFRelease(data);
    } else {
        err = kCFURLErrorUnknown;
    }
    return err;
}
Example #16
0
File: main.c Project: Deanzou/ppp
/* -----------------------------------------------------------------------------
 use launch services to launch an application
 return < 0 if the application cannot be launched
----------------------------------------------------------------------------- */
static int launch_app(char *app, char *params)
{
#ifdef HAVE_LAUNCHSERVICES

    CFURLRef 		urlref;
    LSLaunchURLSpec 	urlspec;
    OSStatus 		err;
#if 0
    OSErr		oserr;
    AEDesc		desc;
#endif

    urlref = CFURLCreateFromFileSystemRepresentation(NULL, (u_char*)app, strlen(app), FALSE);
    if (urlref == 0) 
        return -1;
    
#if 0
    oserr = AECreateDesc(typeChar, params, strlen(params), &desc);
    if (oserr != noErr) {
        CFRelease(urlref);
        return -1;
    }
#endif

    urlspec.appURL = urlref;
    urlspec.itemURLs = 0;
    urlspec.passThruParams = 0;
#if 0
    urlspec.passThruParams = &desc;
#endif 
    urlspec.launchFlags = kLSLaunchAsync + kLSLaunchDontAddToRecents 
                + kLSLaunchNewInstance + kLSLaunchNoParams;
    urlspec.asyncRefCon = 0;
        
    err = LSOpenFromURLSpec(&urlspec, NULL);
    if (err != 0) {
#if 0
        AEDisposeDesc(&desc);
#endif 
        CFRelease(urlref);
        return -2;
    }

#if 0
    AEDisposeDesc(&desc);
#endif 
    CFRelease(urlref);
	
#endif /* HAVE_LAUNCHSERVICES */
    return 0;
}
Example #17
0
OSErr GetSendersAddress(AppleEvent *event,AEAddressDesc *targ)
{
	Size		len=sizeof(long);
	DescType	actualType;
	long		sessionID;
	OSErr		err;
	
	err=AEGetAttributePtr(event, keyAddressAttr, typeSessionID, &actualType, &sessionID, len, &len);
	if (err)
		return err;
	
	// Create the address desriptor
	return AECreateDesc(typeSessionID,(Ptr)&sessionID,sizeof(long), targ);
}
Example #18
0
/********************************************************************************
	Create and return an AEDesc of type typeAlias using the provided 
	alias record.

	pAliasHdl		input:	Handle to an alias record.
	pAliasAEDesc	input:	Pointer to null AEDesc.
					output:	an AEDesc of type typeAlias.
	
	RESULT CODES
	____________
	noErr			   0	No error	
	memFullErr		-108	Not enough room in heap zone	
*/
pascal	OSErr	MoreAEOCreateAliasDesc( const AliasHandle pAliasHdl,
										AEDesc *pAliasAEDesc )
{
	OSErr	anErr = noErr;
	
	char	handleState = HGetState( (Handle)pAliasHdl );
	HLock( (Handle)pAliasHdl );
	
	anErr = AECreateDesc( typeAlias, *pAliasHdl, GetHandleSize( (Handle)pAliasHdl ), pAliasAEDesc );
	
	HSetState( (Handle)pAliasHdl, handleState );
	
	return anErr;
}//end MoreAEOCreateAliasDesc
Example #19
0
void 
Moose::launchAudioscrobbler( const std::vector<std::string>& vargs )
{
    FSRef appRef;
    LSFindApplicationForInfo( kLSUnknownCreator, CFSTR( AUDIOSCROBBLER_BUNDLEID ), NULL, &appRef, NULL );
    
    const void* arg[vargs.size()];
    
    int index(0);

    AEDescList argAEList;
    AECreateList( NULL, 0, FALSE, &argAEList );
    
    for( std::vector<std::string>::const_iterator i = vargs.begin(); i != vargs.end(); i++ ) {
        arg[index++] = CFStringCreateWithCString( NULL, i->c_str(), kCFStringEncodingUTF8 );
        AEPutPtr( &argAEList, 0, typeChar, i->c_str(), i->length());
    }
    
    LSApplicationParameters params;
    params.version = 0;
    params.flags = kLSLaunchAndHide | kLSLaunchDontSwitch | kLSLaunchAsync;;
    params.application = &appRef;
    params.asyncLaunchRefCon = NULL;
    params.environment = NULL;
    
    CFArrayRef args = CFArrayCreate( NULL, ((const void**)arg), vargs.size(), NULL);
    params.argv = args;
    
  
    AEAddressDesc target;
    AECreateDesc( typeApplicationBundleID, CFSTR( AUDIOSCROBBLER_BUNDLEID ), 16, &target);
    
    AppleEvent event;
    AECreateAppleEvent ( kCoreEventClass,
                        kAEReopenApplication ,
                        &target,
                        kAutoGenerateReturnID,
                        kAnyTransactionID,
                        &event );
    
    AEPutParamDesc( &event, keyAEPropData, &argAEList );
    
    params.initialEvent = &event;
    
    LSOpenApplication( &params, NULL );
    AEDisposeDesc( &argAEList );
    AEDisposeDesc( &target );
}
Example #20
0
OSErr putBoolToReply(Boolean aBool, AppleEvent *reply)
{
#if useLog
	printf("start putBoolToReply\n");
#endif
	OSErr err;
	DescType resultType = (aBool? typeTrue:typeFalse);
    AEDesc resultDesc;
    AECreateDesc(resultType, NULL, 0, &resultDesc);
	err=AEPutParamDesc(reply, keyAEResult, &resultDesc);
	AEDisposeDesc(&resultDesc);
#if useLog
	printf("end putBoolToReply\n");
#endif
	return err;
}
Example #21
0
OSErr putBooleanToEvent(AppleEvent *ev, AEKeyword keyword, Boolean inBool)
{
#if useLog
	fputs("start putBooleanToEvent", stderr);
#endif
	OSErr err;
	DescType resultType = (inBool? typeTrue:typeFalse);
    AEDesc resultDesc;
    AECreateDesc(resultType, NULL, 0, &resultDesc);
	err = AEPutParamDesc(ev, keyword, &resultDesc);
	AEDisposeDesc(&resultDesc);
#if useLog
	fputs("end putBooleanToEvent", stderr);
#endif
	return err;
}
Example #22
0
/********************************************************************************
	Given a property type, create an new object descriptor for that property,
	contained by containerObj.
	
	pPropertyType		input:	Property type to use for object.
	pContainerAEDesc	input:	Pointer to container object for object being created.
	propertyObjPtr	input:	Pointer to null AEDesc.
					output:	A property object.
	
	RESULT CODES
	____________
	noErr				    0	No error	
	paramErr			  -50	Error in parameter list
	memFullErr			 -108	Not enough room in heap zone	
	errAECoercionFail 	-1700	Data could not be coerced to the requested 
								Apple event data type	
	errAEWrongDataType	-1703	Wrong Apple event data type	
	errAENotAEDesc		-1704	Not a valid descriptor record	
	errAEBadListItem	-1705	Operation involving a list item failed	
*/
pascal	OSErr	MoreAEOCreatePropertyObject( const DescType pPropertyType,
											 AEDesc *pContainerAEDesc,
											 AEDesc *propertyObjPtr )
{
	OSErr	anErr = noErr;
	AEDesc	propDesc;
	
	anErr = AECreateDesc( typeType, &pPropertyType, sizeof( pPropertyType ), &propDesc );
	if ( noErr == anErr )
	{
		anErr = CreateObjSpecifier( cProperty, pContainerAEDesc, formPropertyID,
									&propDesc, false, propertyObjPtr );
		MoreAEDisposeDesc( &propDesc );
	}
	
	return anErr;
}//end MoreAEOCreatePropertyObject
Example #23
0
/********************************************************************************
	Given a ProcessSerialNumber, create an new object descriptor for the PSN,
	contained by containerObj.
	
	pPSN			input:	ProcessSerialNumber to use for object.
	pContainerAEDesc	input:	Pointer to container object for object being created.
	pPSNObjDesc		input:	Pointer to null AEDesc.
					output:	A ProcessSerialNumber object.
	
	RESULT CODES
	____________
	noErr				    0	No error	
	paramErr			  -50	Error in parameter list
	memFullErr			 -108	Not enough room in heap zone	
	errAECoercionFail 	-1700	Data could not be coerced to the requested 
								Apple event data type	
	errAEWrongDataType	-1703	Wrong Apple event data type	
	errAENotAEDesc		-1704	Not a valid descriptor record	
	errAEBadListItem	-1705	Operation involving a list item failed	
*/
pascal	OSErr	MoreAEOCreateProcessObject( const ProcessSerialNumber *pPSN,
											AEDesc *pContainerAEDesc,
											AEDesc *pPSNObjDesc )
{
	OSErr	anErr = noErr;
	AEDesc	psnDesc;
	
	anErr = AECreateDesc( typeProcessSerialNumber, pPSN, sizeof( ProcessSerialNumber ), &psnDesc );
	if ( noErr == anErr )
	{
		anErr = CreateObjSpecifier( cProperty, pContainerAEDesc, formPropertyID,
									&psnDesc, false, pPSNObjDesc );
		MoreAEDisposeDesc( &psnDesc );
	}
	
	return anErr;
}//end MoreAEOCreateProcessObject
Example #24
0
/********************************************************************************
	Given selection type, create an new object descriptor for a selection,
	contained by containerObj.
	
	pSelectionAEDesc	input:	Selection type to use for object.
	pContainerAEDesc	input:	Pointer to container object for object being created.
	pSelectionObject		input:	Pointer to null AEDesc.
						output:	A property object.
	
	RESULT CODES
	____________
	noErr				    0	No error	
	paramErr			  -50	Error in parameter list
	memFullErr			 -108	Not enough room in heap zone	
	errAECoercionFail 	-1700	Data could not be coerced to the requested 
								Apple event data type	
	errAEWrongDataType	-1703	Wrong Apple event data type	
	errAENotAEDesc		-1704	Not a valid descriptor record	
	errAEBadListItem	-1705	Operation involving a list item failed	
*/
pascal	OSErr	MoreAEOCreateSelectionObject( const DescType pSelectionAEDesc,
											  AEDesc *pContainerAEDesc,
											  AEDesc *pSelectionObject )
{
	OSErr	anErr = noErr;
	
	AEDesc	selectionDesc = {typeNull,NULL};
	
	anErr = AECreateDesc( typeAbsoluteOrdinal, &pSelectionAEDesc, sizeof( pSelectionAEDesc ), &selectionDesc );
	if ( noErr == anErr )
	{
		anErr = CreateObjSpecifier( cObject, pContainerAEDesc, formAbsolutePosition,
									&selectionDesc, false, pSelectionObject );
		MoreAEDisposeDesc( &selectionDesc );
	}			
	return anErr;
}//end MoreAEOCreateSelectionObject
Example #25
0
OSStatus SendAppleEventToSystemProcess(AEEventID EventToSend)
{
    AEAddressDesc targetDesc;
    static const ProcessSerialNumber
         kPSNOfSystemProcess = { 0, kSystemProcess };
    AppleEvent eventReply = {typeNull, NULL};
    AppleEvent appleEventToSend = {typeNull, NULL};

    OSStatus error = noErr;

    error = AECreateDesc(typeProcessSerialNumber,
        &kPSNOfSystemProcess, sizeof(kPSNOfSystemProcess),
        &targetDesc);

    if (error != noErr)
    {
        return(error);
    }

    error = AECreateAppleEvent(kCoreEventClass, EventToSend,
                     &targetDesc, kAutoGenerateReturnID,
                     kAnyTransactionID, &appleEventToSend);

    AEDisposeDesc(&targetDesc);

    if (error != noErr)
    {
        return(error);
    }

    error = AESend(&appleEventToSend, &eventReply, kAENoReply,
             kAENormalPriority, kAEDefaultTimeout,
             NULL, NULL);

    AEDisposeDesc(&appleEventToSend);

    if (error != noErr)
    {
        return(error);
    }

    AEDisposeDesc(&eventReply);

    return(error); //if this is noErr then we are successful
}
Example #26
0
static VALUE
__rbosa_insertion_loc_new (VALUE rcv, FourCharCode code)
{
    AEDesc *  self_desc;
    AEDesc    rec;
    AEDesc    pos_desc;
    AEDesc    new_desc;

    self_desc = rbosa_element_aedesc (rcv);
    AECreateList (NULL, 0, true, &rec);
    AEPutParamDesc (&rec, keyAEObject, self_desc);
    AECreateDesc (code, NULL, 0, &pos_desc);
    AEPutParamPtr (&rec, keyAEPosition, typeEnumerated, &pos_desc, 4);
    AECoerceDesc (&rec, typeInsertionLoc, &new_desc);
    AEDisposeDesc (&rec);

    return rbosa_element_make (cOSAElement, &new_desc, Qnil);
}
Example #27
0
static VALUE
rbosa_element_new (VALUE self, VALUE type, VALUE value)
{
    FourCharCode    ffc_type;
    OSErr           error;
    const char *    c_value;
    unsigned        c_value_size;
    AEDesc          desc;

    ffc_type = RVAL2FOURCHAR (type);

    if (NIL_P (value)) {
        c_value = NULL;
        c_value_size = 0;
    }
    else if (rb_obj_is_kind_of (value, rb_cInteger)) {
        FourCharCode code;

        code = NUM2INT (value);
        c_value = (const char *)&code;
        c_value_size = sizeof (FourCharCode);
    }  
    else if (ffc_type == 'alis') {
        AliasHandle     alias;

        rbobj_to_alias_handle (value, &alias);
        
        c_value = (const char *)*alias;
        c_value_size = GetHandleSize ((Handle)alias);
    }
    else {
        Check_Type (value, T_STRING);
        c_value = RSTRING (value)->ptr;
        c_value_size = RSTRING (value)->len;
    }

    error = AECreateDesc (ffc_type, c_value, c_value_size, &desc);
    if (error != noErr)     
        rb_raise (rb_eArgError, "Cannot create Apple Event descriptor from type '%s' value '%s' : %s (%d)", 
                  RVAL2CSTR (type), c_value, error_code_to_string (error), error);

    return rbosa_element_make (self, &desc, Qnil);
}
Example #28
0
  for_each(VisualPhysicsActor* actor, actors) {
    if (QFileInfo(actor->path()).exists()) {
      use_ae_desc_list = true;

      AliasHandle file_alias;
      Boolean is_directory = false;

      err = FSNewAliasFromPath(NULL, utf8(actor->path()).c_str(), 0,  &file_alias, &is_directory);

      HLock((Handle) file_alias);

      AECreateDesc(typeAlias, (Ptr) (*file_alias),
                   GetHandleSize((Handle) file_alias), &file_list_element);
      HUnlock((Handle) file_alias);

      AEPutDesc(&file_list, 0, &file_list_element);
    }

  }
Example #29
0
pascal OSStatus MoreAEOCreateObjSpecifierFromCFURLRef(const CFURLRef pCFURLRef, AEDesc *pObjSpecifier){
	OSErr anErr = paramErr;

	if (nil != pCFURLRef) {
		Boolean isDirectory = CFURLHasDirectoryPath(pCFURLRef);
		CFStringRef tCFStringRef = CFURLCopyFileSystemPath(pCFURLRef, kCFURLHFSPathStyle);
		AEDesc containerDesc = {
			typeNull, NULL
		};
		AEDesc nameDesc = {
			typeNull, NULL
		};
		UniCharPtr buf = nil;

		if (nil != tCFStringRef) {
			Size bufSize = ( CFStringGetLength(tCFStringRef) + ( isDirectory ? 1 : 0 ) ) * sizeof( UniChar );

			buf = (UniCharPtr) NewPtr(bufSize);

			if ( ( anErr = MemError() ) == noErr) {
				CFStringGetCharacters(tCFStringRef, CFRangeMake(0, bufSize / 2), buf);
				if (isDirectory) ( buf )[ ( bufSize - 1 ) / 2 ] = (UniChar) 0x003A;
			}
		} else
			anErr = coreFoundationUnknownErr;

		if (anErr == noErr)
			anErr = AECreateDesc(typeUnicodeText, buf, GetPtrSize( (Ptr) buf), &nameDesc);
		if (anErr == noErr)
			if (isDirectory) {
				anErr = CreateObjSpecifier(cFolder, &containerDesc, formName, &nameDesc, false, pObjSpecifier);
			} else {
				anErr = CreateObjSpecifier(cFile, &containerDesc, formName, &nameDesc, false, pObjSpecifier);
			}

		MoreAEDisposeDesc(&nameDesc);

		if (buf)
			DisposePtr( (Ptr) buf);
	}
	return anErr;
}
Example #30
0
void mac_opensession(void)
{

    if (mac_gestalts.navsvers > 0) {
	NavReplyRecord navr;
	NavDialogOptions navopts;
	NavTypeListHandle navtypes;
	AEDesc defaultloc = { 'null', NULL };
	AEDesc *navdefault = NULL;
	short vol;
	long dirid;
	FSSpec fss;

	if (NavGetDefaultDialogOptions(&navopts) != noErr) return;
	/* XXX should we create sessions dir? */
	if (get_session_dir(FALSE, &vol, &dirid) == noErr &&
	    FSMakeFSSpec(vol, dirid, NULL, &fss) == noErr &&
	    AECreateDesc(typeFSS, &fss, sizeof(fss), &defaultloc) == noErr)
	    navdefault = &defaultloc;
	/* Can't meaningfully preview a saved session yet */
	navopts.dialogOptionFlags &= ~kNavAllowPreviews;
	navtypes = (NavTypeListHandle)GetResource('open', open_pTTY);
	if (NavGetFile(navdefault, &navr, &navopts, NULL, NULL, NULL, navtypes,
		       NULL) == noErr && navr.validRecord)
	    mac_openlist(navr.selection);
	NavDisposeReply(&navr);
	if (navtypes != NULL)
	    ReleaseResource((Handle)navtypes);
    }
#if !TARGET_API_MAC_CARBON /* XXX Navigation Services */
    else {
	StandardFileReply sfr;
	static const OSType sftypes[] = { 'Sess', 0, 0, 0 };

	StandardGetFile(NULL, 1, sftypes, &sfr);
	if (!sfr.sfGood) return;

	mac_opensessionfrom(&sfr.sfFile);
	/* XXX handle error */
    }
#endif
}