Added a new AE method that handles custom timeouts.
[ITMac.git] / ITAppleEventTools.m
index 0fe0b76..a61f5a4 100644 (file)
@@ -45,6 +45,10 @@ NSAppleEventDescriptor *ITSendAEWithKey(FourCharCode reqKey, FourCharCode evClas
 }
 
 NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode evClass, FourCharCode evID, const ProcessSerialNumber *psn) {
+       ITSendAEWithStringAndTimeout(sendString, evClass, evID, psn, 60);
+}
+
+NSAppleEventDescriptor *ITSendAEWithStringAndTimeout(NSString *sendString, FourCharCode evClass, FourCharCode evID, const ProcessSerialNumber *psn, long timeout) {
        pid_t pid;
        AppleEvent sendEvent, replyEvent;
        AEDesc resultDesc;
@@ -66,7 +70,7 @@ NSAppleEventDescriptor *ITSendAEWithString(NSString *sendString, FourCharCode ev
                return nil;
        }
        
-       err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/60, NULL, NULL);
+       err = AESend(&sendEvent, &replyEvent, kAEWaitReply, kAENormalPriority, /*kAEDefaultTimeout*/timeout, NULL, NULL);
        AEDisposeDesc(&sendEvent);
        
        if (err) {