source: trunk/Cocoa/F-Script Anywhere/Source/FSABundle.mm@ 626

Last change on this file since 626 was 153, checked in by Nicholas Riley, 21 years ago

Integrates SCPatch and mach_inject; unfinished, buggy.

File size: 2.6 KB
RevLine 
[153]1//
2// FSABundle.mm
3// F-Script Anywhere
4//
5// Created by Nicholas Riley on Fri Feb 01 2002.
6// Copyright (c) 2002 Nicholas Riley. All rights reserved.
7//
8
9/*
10
11 F-Script Anywhere is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 F-Script Anywhere is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with F-Script Anywhere; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
25*/
26
27#include <Carbon/Carbon.h>
28#include "SCPatchClient.h"
29#include "SCPatchPrivate.h"
30#include <stdio.h>
31#import "FSAnywhere.h"
32#import "FSAController.h"
33
34class FSAPatchClient : public SCPatchClient
35{
36public:
37 virtual OSErr Initialize(CFStringRef /* clientBundleID */,
38 CFStringRef /* controllerBundleID */,
39 pid_t /* pid */);
40 virtual void ReceiveMessage(const AppleEvent * /* theAE */);
41};
42
43OSErr FSAPatchClient::Initialize(CFStringRef clientBundleID,
44 CFStringRef controllerBundleID,
45 pid_t pid)
46{
47 FSALog(@"client = %@", (NSString *)clientBundleID);
48 FSALog(@"controller = %@", (NSString *)controllerBundleID);
49 [FSAController installMenu];
50 return noErr;
51}
52
53void FSAPatchClient::ReceiveMessage(const AppleEvent *theAE)
54{
55 OSErr err = noErr;
56 Size actualSize;
57 DescType actualType;
58 OSType eventClass, eventID;
59
60 // XXX is this implementation even necessary?
61 if ( (err = AEGetAttributePtr(theAE, keyEventIDAttr, typeType, &actualType, &eventID,
62 sizeof(OSType), &actualSize)) != noErr)
63 return;
64
65 if ( (err = AEGetAttributePtr(theAE, keyEventClassAttr, typeType, &actualType,
66 &eventClass, sizeof(OSType), &actualSize)) != noErr)
67 return;
68
69 if (eventClass == kSCMessageClass && eventID == kSCPing) {
70 fprintf(stderr, "client received ping: sending reply...\n");
71 SendMessage(mControllerBundleID, NULL, kSCMessageClass, kSCPing, "");
72 fprintf(stderr, "reply sent\n");
73 }
74}
75
76FSAPatchClient FSAPatchClientInstance;
77SCPatchClient *SCPatchClient::sGlobalPatchClientInstance = &FSAPatchClientInstance;
Note: See TracBrowser for help on using the repository browser.