-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlisten.h
63 lines (54 loc) · 2.32 KB
/
listen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* listen.h
* iusbcomm
*
* Created by John Heaton on 5/16/10.
* Copyright 2010 Gojohnnyboi. All rights reserved.
*
*/
#ifndef IUSBCOMM_LISTEN_H
#define IUSBCOMM_LISTEN_H
#include "recovery.h"
typedef struct __iUSBListener *iUSBListenerRef;
/*!
@enum iUSBListenerType
@field kUSBListenerTypeNormal - Devices in normal mode
@field kUSBListenerTypeRecovery - Devices in recovery/dfu mode
*/
typedef enum {
kUSBListenerTypeNormal = 0x2,
kUSBListenerTypeRecovery = 0x4
} iUSBListenerType;
/*!
@function iUSBListenerCreate
Create a new listener object that will deliver notifications of device connections to the specified callbacks,
for the specified modes.
@param listenModes - kUSBListenerType value(s). ex: (kUSBListenerTypeNormal | kUSBListenerTypeRecovery)
@param recoveryCallback - The callback for recovery device connections
Note: Do *NOT* release a iUSBRecoveryDeviceRef object until you receive a detach notification. It will cause issues.
@result A new listener object which the caller is responsible for releasing
*/
iUSBListenerRef iUSBListenerCreate(iUSBListenerType listenModes, iUSBRecoveryDeviceConnectionChangeCallback recoveryCallback);
/*!
@function iUSBListenerStartListeningOnRunLoop
Setup for listening and/or add the notification port to your run loop in the specified mode.
@param listener - The listener object to add to your run loop
@param runLoop - The run loop to add the notifications to. If NULL, CFRunLoopGetCurrent() will be assumed.
@param runLoopMode - The mode of your run loop to add to. If NULL, kCFRunLoopDefaultMode will be assumed.
*/
Boolean iUSBListenerStartListeningOnRunLoop(iUSBListenerRef listener, CFRunLoopRef runLoop, CFStringRef runLoopMode);
/*!
@function iUSBListenerStopListeningOnRunLoop
Remove the listener from a run loop in the specified mode
@param listener - The listener to remove from the run loop.
@param runLoop - The run loop to remove the listener from.
@param runLoopMode - The mode of the run loop to remove the listener from.
*/
void iUSBListenerStopListeningOnRunLoop(iUSBListenerRef listener, CFRunLoopRef runLoop, CFStringRef runLoopMode);
/*!
@function iUSBListenerRelease
Safely clean up and deallocate a listener object
@param listenr - The listener to deallocate
*/
void iUSBListenerRelease(iUSBListenerRef listener);
#endif /* IUSBCOMM_LISTEN_H */