forked from jkcoxson/idevice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathidevice.cpp
More file actions
64 lines (55 loc) · 1.59 KB
/
Copy pathidevice.cpp
File metadata and controls
64 lines (55 loc) · 1.59 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
59
60
61
62
63
64
// Jackson Coxson
#include <idevice++/idevice.hpp>
namespace IdeviceFFI {
Result<Idevice, FfiError> Idevice::create(IdeviceSocketHandle* socket, const std::string& label) {
IdeviceHandle* h = nullptr;
FfiError e(idevice_new(socket, label.c_str(), &h));
if (e) {
return Err(e);
}
return Ok(Idevice(h));
}
#if defined(__unix__) || defined(__APPLE__)
Result<Idevice, FfiError> Idevice::from_fd(int fd, const std::string& label) {
IdeviceHandle* h = nullptr;
FfiError e(idevice_from_fd(fd, label.c_str(), &h));
if (e) {
return Err(e);
}
return Ok(Idevice(h));
}
#endif
Result<Idevice, FfiError>
Idevice::create_tcp(const sockaddr* addr, socklen_t addr_len, const std::string& label) {
IdeviceHandle* h = nullptr;
FfiError e(idevice_new_tcp_socket(addr, addr_len, label.c_str(), &h));
if (e) {
return Err(e);
}
return Ok(Idevice(h));
}
Result<std::string, FfiError> Idevice::get_type() const {
char* cstr = nullptr;
FfiError e(idevice_get_type(handle_.get(), &cstr));
if (e) {
return Err(e);
}
std::string out(cstr);
idevice_string_free(cstr);
return Ok(out);
}
Result<void, FfiError> Idevice::rsd_checkin() {
FfiError e(idevice_rsd_checkin(handle_.get()));
if (e) {
return Err(e);
}
return Ok();
}
Result<void, FfiError> Idevice::start_session(const PairingFile& pairing_file, bool legacy) {
FfiError e(idevice_start_session(handle_.get(), pairing_file.raw(), legacy));
if (e) {
return Err(e);
}
return Ok();
}
} // namespace IdeviceFFI