forked from jkcoxson/idevice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprovider.cpp
More file actions
58 lines (45 loc) · 1.79 KB
/
Copy pathprovider.cpp
File metadata and controls
58 lines (45 loc) · 1.79 KB
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
// Jackson Coxson
#include <idevice++/bindings.hpp>
#include <idevice++/ffi.hpp>
#include <idevice++/provider.hpp>
namespace IdeviceFFI {
Result<Provider, FfiError>
Provider::tcp_new(const idevice_sockaddr* ip, PairingFile&& pairing, const std::string& label) {
IdeviceProviderHandle* out = nullptr;
FfiError e(idevice_tcp_provider_new(
ip, static_cast<IdevicePairingFile*>(pairing.raw()), label.c_str(), &out));
if (e) {
return Err(e);
}
// Success: Rust consumed the pairing file -> abandon our ownership
pairing.release();
return Ok(Provider::adopt(out));
}
Result<Provider, FfiError> Provider::usbmuxd_new(UsbmuxdAddr&& addr,
uint32_t tag,
const std::string& udid,
uint32_t device_id,
const std::string& label) {
IdeviceProviderHandle* out = nullptr;
FfiError e(usbmuxd_provider_new(static_cast<UsbmuxdAddrHandle*>(addr.raw()),
tag,
udid.c_str(),
device_id,
label.c_str(),
&out));
if (e) {
return Err(e);
}
// Success: Rust consumed the addr -> abandon our ownership
addr.release();
return Ok(Provider::adopt(out));
}
Result<PairingFile, FfiError> Provider::get_pairing_file() {
IdevicePairingFile* out = nullptr;
FfiError e(idevice_provider_get_pairing_file(handle_.get(), &out));
if (e) {
return Err(e);
}
return Ok(PairingFile(out));
}
} // namespace IdeviceFFI