Linux + iPhone Continuity / iMessage / SMS
cleaner interface
Zack Bartela5041e47a9c3
diff --git a/src/cli/main.cpp b/src/cli/main.cppindex dac1f83..59af096 100644--- a/src/cli/main.cpp+++ b/src/cli/main.cpp@@ -20,10 +20,8 @@ void run_native_messaging_host(tether::Client& client) {std::thread reader_thread([&]() {std::string buffer;char buf[8192];- int daemon_sock = client.get_socket();-while (running) {- ssize_t n = read(daemon_sock, buf, sizeof(buf));+ ssize_t n = client.read(buf, sizeof(buf));if (n <= 0) {running = false;break;diff --git a/src/core/include/tether/client.hpp b/src/core/include/tether/client.hppindex af2ee5d..c4ede86 100644--- a/src/core/include/tether/client.hpp+++ b/src/core/include/tether/client.hpp@@ -22,7 +22,7 @@ namespace tether {bool send_file(const std::string& path, std::string& err_out);std::string get_peer_fingerprint() const;- int get_socket() const;+ ssize_t read(char* buf, size_t count);// High Level Featuresstd::string get_clipboard(std::string& err_out);diff --git a/src/core/src/client.cpp b/src/core/src/client.cppindex 97fdf9d..f596844 100644--- a/src/core/src/client.cpp+++ b/src/core/src/client.cpp@@ -143,7 +143,7 @@ namespace tether {if (write(sock_, payload.c_str(), payload.size()) < 0) {debug::log(ERR, "client write error\n");}- ssize_t n = read(sock_, buf, sizeof(buf) - 1);+ ssize_t n = ::read(sock_, buf, sizeof(buf) - 1);if (n > 0) {buf[n] = '\0';return std::string(buf);@@ -161,7 +161,13 @@ namespace tether {}}- int Client::get_socket() const { return sock_; }+ ssize_t Client::read(char* buf, size_t count) {+ if (ssl_) {+ return SSL_read(ssl_, buf, count);+ } else {+ return ::read(sock_, buf, count);+ }+ }std::string Client::get_clipboard(std::string& err_out) {nlohmann::json j;