pEp macOS Desktop adapter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

2 years ago
  1. //
  2. // pEpMacOSAdapterProtocol.h
  3. // pEpMacOSAdapter
  4. //
  5. // Created by Volker Birk on 20.04.20.
  6. // Copyleft © 2020 p≡p foundation.
  7. // This file is under GNU General Public License 3.0
  8. //
  9. #import <Foundation/Foundation.h>
  10. // The protocol that this service will vend as its API. This header file will also need to be visible to the process hosting the service.
  11. @protocol pEpMacOSAdapterProtocol
  12. // Replace the API of this protocol with an API appropriate to the service you are vending.
  13. - (void)upperCaseString:(NSString *)aString withReply:(void (^)(NSString *))reply;
  14. @end
  15. /*
  16. To use the service from an application or other process, use NSXPCConnection to establish a connection to the service by doing something like this:
  17. _connectionToService = [[NSXPCConnection alloc] initWithServiceName:@"pEp.foundation.pEpMacOSAdapter"];
  18. _connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(pEpMacOSAdapterProtocol)];
  19. [_connectionToService resume];
  20. Once you have a connection to the service, you can use it like this:
  21. [[_connectionToService remoteObjectProxy] upperCaseString:@"hello" withReply:^(NSString *aString) {
  22. // We have received a response. Update our text field, but do it on the main thread.
  23. NSLog(@"Result string was: %@", aString);
  24. }];
  25. And, when you are finished with the service, clean up the connection like this:
  26. [_connectionToService invalidate];
  27. */