Skip to content

Linux + iPhone Continuity / iMessage / SMS

fix: clang format

Zack Bartel8750d415a0d6
diff --git a/src/core/include/tether/otp.hpp b/src/core/include/tether/otp.hpp
index 8caab57..ddae2a0 100644
--- a/src/core/include/tether/otp.hpp
+++ b/src/core/include/tether/otp.hpp
@@ -10,7 +10,7 @@ namespace tether {
struct Otp {
std::string code;
std::string sender_domain; // registrable domain of the source; "" when unknown
- uint64_t id = 0; // 0 == no code
+ uint64_t id = 0; // 0 == no code
explicit operator bool() const { return id != 0 && !code.empty(); }
};
diff --git a/src/core/src/net.cpp b/src/core/src/net.cpp
index 6f955ce..bc57587 100644
--- a/src/core/src/net.cpp
+++ b/src/core/src/net.cpp
@@ -1011,9 +1011,7 @@ namespace tether {
continue;
}
} else if (j.contains("command") && j["command"] == "new_otp" && j.contains("otp")) {
- otp_publish(otp_from_json(j["otp"]),
- j.value("sender_domain", std::string{}),
- client_fd);
+ otp_publish(otp_from_json(j["otp"]), j.value("sender_domain", std::string{}), client_fd);
std::string payload = "{\"status\":\"ok\"}\n";
write_plain_packet(client_fd, payload);
continue;
@@ -1348,7 +1346,7 @@ namespace tether {
reason = "peer closed connection during handshake";
} else if (err == SSL_ERROR_SYSCALL) {
reason = (ssl_err != 0) ? std::string("syscall error: ") + std::strerror(ssl_err)
- : "ssl syscall failed";
+ : "ssl syscall failed";
} else {
reason = "ssl error " + std::to_string(err);
}
@@ -1478,8 +1476,7 @@ namespace tether {
}
} else if (j.contains("command") && j["command"] == "new_otp" && j.contains("otp")) {
// OTP sent from a mobile client (iPhone Share Extension) over mTLS.
- otp_publish(otp_from_json(j["otp"]),
- j.value("sender_domain", std::string{}));
+ otp_publish(otp_from_json(j["otp"]), j.value("sender_domain", std::string{}));
std::string payload = "{\"status\":\"ok\"}\n";
robust_ssl_write(ssl, payload.c_str(), payload.size());
continue;
diff --git a/src/core/src/psl_data.hpp b/src/core/src/psl_data.hpp
index cd54154..bd9891c 100644
--- a/src/core/src/psl_data.hpp
+++ b/src/core/src/psl_data.hpp
@@ -7,7 +7,7 @@
#include <string_view>
namespace tether {
-inline constexpr std::string_view kPslData = R"PSL(
+ inline constexpr std::string_view kPslData = R"PSL(
ac
com.ac
edu.ac
diff --git a/src/core/src/wayland.cpp b/src/core/src/wayland.cpp
index 43250fb..6ee3159 100644
--- a/src/core/src/wayland.cpp
+++ b/src/core/src/wayland.cpp
@@ -1,6 +1,6 @@
#include "tether/wayland.hpp"
-#include "wayland_protocols/wayland.hpp"
#include "wayland_protocols/ext-data-control-v1.hpp"
+#include "wayland_protocols/wayland.hpp"
#include "wayland_protocols/wlr-data-control-unstable-v1.hpp"
#include <cstring>
diff --git a/src/core/src/wayland_protocols/ext-data-control-v1.cpp b/src/core/src/wayland_protocols/ext-data-control-v1.cpp
index 7979ad1..37b781b 100644
--- a/src/core/src/wayland_protocols/ext-data-control-v1.cpp
+++ b/src/core/src/wayland_protocols/ext-data-control-v1.cpp
@@ -29,7 +29,7 @@
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
-
+
*/
#define private public
@@ -38,7 +38,7 @@
#undef private
#define F std::function
-static const wl_interface* extDataControlV1_dummyTypes[] = { nullptr };
+static const wl_interface* extDataControlV1_dummyTypes[] = {nullptr};
// Reference all other interfaces.
// The reason why this is in snake is to
@@ -58,7 +58,8 @@ wl_proxy* CCExtDataControlManagerV1::sendCreateDataSource() {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, &ext_data_control_source_v1_interface, wl_proxy_get_version(pResource), 0, nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 0, &ext_data_control_source_v1_interface, wl_proxy_get_version(pResource), 0, nullptr);
return proxy;
}
@@ -67,7 +68,8 @@ wl_proxy* CCExtDataControlManagerV1::sendGetDataDevice(wl_proxy* seat) {
if (!pResource)
return nullptr;
- auto proxy = wl_proxy_marshal_flags(pResource, 1, &ext_data_control_device_v1_interface, wl_proxy_get_version(pResource), 0, nullptr, seat);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 1, &ext_data_control_device_v1_interface, wl_proxy_get_version(pResource), 0, nullptr, seat);
return proxy;
}
@@ -89,15 +91,18 @@ static const wl_interface* _CExtDataControlManagerV1GetDataDeviceTypes[] = {
};
static const wl_message _CExtDataControlManagerV1Requests[] = {
- { .name = "create_data_source", .signature = "n", .types = _CExtDataControlManagerV1CreateDataSourceTypes + 0},
- { .name = "get_data_device", .signature = "no", .types = _CExtDataControlManagerV1GetDataDeviceTypes + 0},
- { .name = "destroy", .signature = "", .types = extDataControlV1_dummyTypes + 0},
+ {.name = "create_data_source", .signature = "n", .types = _CExtDataControlManagerV1CreateDataSourceTypes + 0},
+ {.name = "get_data_device", .signature = "no", .types = _CExtDataControlManagerV1GetDataDeviceTypes + 0},
+ {.name = "destroy", .signature = "", .types = extDataControlV1_dummyTypes + 0},
};
const wl_interface ext_data_control_manager_v1_interface = {
- .name = "ext_data_control_manager_v1", .version = 1,
- .method_count = 3, .methods = _CExtDataControlManagerV1Requests,
- .event_count = 0, .events = nullptr,
+ .name = "ext_data_control_manager_v1",
+ .version = 1,
+ .method_count = 3,
+ .methods = _CExtDataControlManagerV1Requests,
+ .event_count = 0,
+ .events = nullptr,
};
CCExtDataControlManagerV1::CCExtDataControlManagerV1(wl_proxy* resource) : pResource(resource) {
@@ -148,7 +153,8 @@ void CCExtDataControlDeviceV1::sendSetSelection(CCExtDataControlSourceV1* source
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 0, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 0, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr);
proxy;
}
@@ -165,7 +171,8 @@ void CCExtDataControlDeviceV1::sendSetPrimarySelection(CCExtDataControlSourceV1*
if (!pResource)
return;
- auto proxy = wl_proxy_marshal_flags(pResource, 2, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr);
+ auto proxy = wl_proxy_marshal_flags(
+ pResource, 2, nullptr, wl_proxy_get_version(pResource), 0, source ? source->pResource : nullptr);
proxy;
}
static const wl_interface* _CExtDataControlDeviceV1SetSelectionTypes[] = {
@@ -185,22 +192,25 @@ static const wl_interface* _CExtDataControlDeviceV1PrimarySelectionTypes[] = {
};
static const wl_message _CExtDataControlDeviceV1Requests[] = {
- { .name = "set_selection", .signature = "?o", .types = _CExtDataControlDeviceV1SetSelectionTypes + 0},
- { .name = "destroy", .signature = "", .types = extDataControlV1_dummyTypes + 0},
- { .name = "set_primary_selection", .signature = "?o", .types = _CExtDataControlDeviceV1SetPrimarySelectionTypes + 0},
+ {.name = "set_selection", .signature = "?o", .types = _CExtDataControlDeviceV1SetSelectionTypes + 0},
+ {.name = "destroy", .signature = "", .types = extDataControlV1_dummyTypes + 0},
+ {.name = "set_primary_selection", .signature = "?o", .types = _CExtDataControlDeviceV1SetPrimarySelectionTypes + 0},
};
static const wl_message _CExtDataControlDeviceV1Events[] = {
- { .name = "data_offer", .signature = "n", .types = _CExtDataControlDeviceV1DataOfferTypes + 0},
- { .name = "selection", .signature = "?o", .types = _CExtDataControlDeviceV1SelectionTypes + 0},
- { .name = "finished", .signature = "", .types = extDataControlV1_dummyTypes + 0},
- { .name = "primary_selection", .signature = "?o", .types = _CExtDataControlDeviceV1PrimarySelectionTypes + 0},
+ {.name = "data_offer", .signature = "n", .types = _CExtDataControlDeviceV1DataOfferTypes + 0},
+ {.name = "selection", .signature = "?o", .types = _CExtDataControlDeviceV1SelectionTypes + 0},
+ {.name = "finished", .signature = "", .types = extDataControlV1_dummyTypes + 0},
+ {.name = "primary_selection", .signature = "?o", .types = _CExtDataControlDeviceV1PrimarySelectionTypes + 0},
};
const wl_interface ext_data_control_device_v1_interface = {
- .name = "ext_data_control_device_v1", .version = 1,
- .method_count = 3, .methods = _CExtDataControlDeviceV1Requests,
- .event_count = 4, .events = _CExtDataControlDeviceV1Events,
+ .name = "ext_data_control_device_v1",
+ .version = 1,
+ .method_count = 3,
+ .methods = _CExtDataControlDeviceV1Requests,
+ .event_count = 4,
+ .events = _CExtDataControlDeviceV1Events,
};
CCExtDataControlDeviceV1::CCExtDataControlDeviceV1(wl_proxy* resource) : pResource(resource) {
@@ -216,19 +226,19 @@ CCExtDataControlDeviceV1::~CCExtDataControlDeviceV1() {
sendDestroy();
}
-void CCExtDataControlDeviceV1::setDataOffer(F<void(CCExtDataControlDeviceV1*, wl_proxy*)> &&handler) {
+void CCExtDataControlDeviceV1::setDataOffer(F<void(CCExtDataControlDeviceV1*, wl_proxy*)>&& handler) {
requests.dataOffer = std::move(handler);
}
-void CCExtDataControlDeviceV1::setSelection(F<void(CCExtDataControlDeviceV1*, wl_proxy*)> &&handler) {
+void CCExtDataControlDeviceV1::setSelection(F<void(CCExtDataControlDeviceV1*, wl_proxy*)>&& handler) {
requests.selection = std::move(handler);
}
-void CCExtDataControlDeviceV1::setFinished(F<void(CCExtDataControlDeviceV1*)> &&handler) {
+void CCExtDataControlDeviceV1::setFinished(F<void(CCExtDataControlDeviceV1*)>&& handler) {
requests.finished = std::move(handler);
}
-void CCExtDataControlDeviceV1::setPrimarySelection(F<void(CCExtDataControlDeviceV1*, wl_proxy*)> &&handler) {
+void CCExtDataControlDeviceV1::setPrimarySelection(F<void(CCExtDataControlDeviceV1*, wl_proxy*)>&& handler) {
requests.primarySelection = std::move(handler);
}
@@ -274,19 +284,22 @@ static const wl_interface* _CExtDataControlSourceV1SendTypes[] = {
};
static const wl_message _CExtDataControlSourceV1Requests[] = {
- { .name = "offer", .signature = "s", .types = _CExtDataControlSourceV1OfferTypes + 0},
- { .name = "destroy", .signature = "", .types = extDataControlV1_dummyTypes + 0},
+ {.name = "offer", .signature = "s", .types = _CExtDataControlSourceV1OfferTypes + 0},
+ {.name = "destroy", .signature = "", .types = extDataControlV1_dummyTypes + 0},
};
static const wl_message _CExtDataControlSourceV1Events[] = {
- { .name = "send", .signature = "sh", .types = _CExtDataControlSourceV1SendTypes + 0},
- { .name = "cancelled", .signature = "", .types = extDataControlV1_dummyTypes + 0},
+ {.name = "send", .signature = "sh", .types = _CExtDataControlSourceV1SendTypes + 0},
+ {.name = "cancelled", .signature = "", .types = extDataControlV1_dummyTypes + 0},
};
const wl_interface ext_data_control_source_v1_interface = {
- .name = "ext_data_control_source_v1", .version = 1,
- .method_count = 2, .methods = _CExtDataControlSourceV1Requests,
- .event_count = 2, .events = _CExtDataControlSourceV1Events,
+ .name = "ext_data_control_source_v1",
+ .version = 1,
+ .method_count = 2,
+ .methods = _CExtDataControlSourceV1Requests,
+ .event_count = 2,
+ .events = _CExtDataControlSourceV1Events,
};
CCExtDataControlSourceV1::CCExtDataControlSourceV1(wl_proxy* resource) : pResource(resource) {
@@ -302,11 +315,11 @@ CCExtDataControlSourceV1::~CCExtDataControlSourceV1() {
sendDestroy();
}
-void CCExtDataControlSourceV1::setSend(F<void(CCExtDataControlSourceV1*, const char*, int32_t)> &&handler) {
+void CCExtDataControlSourceV1::setSend(F<void(CCExtDataControlSourceV1*, const char*, int32_t)>&& handler) {
requests.send = std::move(handler);
}
-void CCExtDataControlSourceV1::setCancelled(F<void(CCExtDataControlSourceV1*)> &&handler) {
+void CCExtDataControlSourceV1::setCancelled(F<void(CCExtDataControlSourceV1*)>&& handler) {
requests.cancelled = std::move(handler);
}
@@ -345,18 +358,21 @@ static const wl_interface* _CExtDataControlOfferV1OfferTypes[] = {
};
static const wl_message _CExtDataControlOfferV1Requests[] = {
- { .name = "receive", .signature = "sh", .types = _CExtDataControlOfferV1ReceiveTypes + 0},
- { .name = "destroy", .signature = "", .types = extDataControlV1_dummyTypes + 0},
+ {.name = "receive", .signature = "sh", .types = _CExtDataControlOfferV1ReceiveTypes + 0},
+ {.name = "destroy", .signature = "", .types = extDataControlV1_dummyTypes + 0},
};
static const wl_message _CExtDataControlOfferV1Events[] = {
- { .name = "offer", .signature = "s", .types = _CExtDataControlOfferV1OfferTypes + 0},
+ {.name = "offer", .signature = "s", .types = _CExtDataControlOfferV1OfferTypes + 0},
};
const wl_interface ext_data_control_offer_v1_interface = {
- .name = "ext_data_control_offer_v1", .version = 1,
- .method_count = 2, .methods = _CExtDataControlOfferV1Requests,
- .event_count = 1, .events = _CExtDataControlOfferV1Events,
+ .name = "ext_data_control_offer_v1",
+ .version = 1,
+ .method_count = 2,
+ .methods = _CExtDataControlOfferV1Requests,
+ .event_count = 1,
+ .events = _CExtDataControlOfferV1Events,
};
CCExtDataControlOfferV1::CCExtDataControlOfferV1(wl_proxy* resource) : pResource(resource) {
@@ -372,7 +388,7 @@ CCExtDataControlOfferV1::~CCExtDataControlOfferV1() {
sendDestroy();
}
-void CCExtDataControlOfferV1::setOffer(F<void(CCExtDataControlOfferV1*, const char*)> &&handler) {
+void CCExtDataControlOfferV1::setOffer(F<void(CCExtDataControlOfferV1*, const char*)>&& handler) {
requests.offer = std::move(handler);
}
diff --git a/src/core/src/wayland_protocols/ext-data-control-v1.hpp b/src/core/src/wayland_protocols/ext-data-control-v1.hpp
index 8f74cca..d5da0c6 100644
--- a/src/core/src/wayland_protocols/ext-data-control-v1.hpp
+++ b/src/core/src/wayland_protocols/ext-data-control-v1.hpp
@@ -29,13 +29,13 @@
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
-
+
*/
#pragma once
-#include <functional>
#include <cstdint>
+#include <functional>
#include <string>
#include <wayland-client.h>
@@ -51,7 +51,6 @@ enum extDataControlSourceV1Error : uint32_t {
EXT_DATA_CONTROL_SOURCE_V1_ERROR_INVALID_OFFER = 1,
};
-
class CCExtDataControlManagerV1;
class CCExtDataControlSourceV1;
class CCExtDataControlDeviceV1;
@@ -73,40 +72,47 @@ extern const wl_interface ext_data_control_offer_v1_interface;
#endif
-
class CCExtDataControlManagerV1 {
- public:
+public:
CCExtDataControlManagerV1(wl_proxy*);
~CCExtDataControlManagerV1();
-
// set the data for this resource
- void setData(void* data) {{
- pData = data;
- }}
+ void setData(void* data) {
+ {
+ pData = data;
+ }
+ }
// get the data for this resource
- void* data() {{
- return pData;
- }}
+ void* data() {
+ {
+ return pData;
+ }
+ }
// get the raw wl_resource (wl_proxy) ptr
- wl_proxy* resource() {{
- return pResource;
- }}
+ wl_proxy* resource() {
+ {
+ return pResource;
+ }
+ }
// get the raw wl_proxy ptr
- wl_proxy* proxy() {{
- return pResource;
- }}
+ wl_proxy* proxy() {
+ {
+ return pResource;
+ }
+ }
// get the resource version
- int version() {{
- return wl_proxy_get_version(pResource);
- }}
-
- // --------------- Requests --------------- //
+ int version() {
+ {
+ return wl_proxy_get_version(pResource);
+ }
+ }
+ // --------------- Requests --------------- //
// --------------- Events --------------- //
@@ -114,7 +120,7 @@ class CCExtDataControlManagerV1 {
wl_proxy* sendGetDataDevice(wl_proxy*);
void sendDestroy();
- private:
+private:
struct {
} requests;
@@ -125,45 +131,52 @@ class CCExtDataControlManagerV1 {
void* pData = nullptr;
};
-
-
class CCExtDataControlDeviceV1 {
- public:
+public:
CCExtDataControlDeviceV1(wl_proxy*);
~CCExtDataControlDeviceV1();
-
// set the data for this resource
- void setData(void* data) {{
- pData = data;
- }}
+ void setData(void* data) {
+ {
+ pData = data;
+ }
+ }
// get the data for this resource
- void* data() {{
- return pData;
- }}
+ void* data() {
+ {
+ return pData;
+ }
+ }
// get the raw wl_resource (wl_proxy) ptr
- wl_proxy* resource() {{
- return pResource;
- }}
+ wl_proxy* resource() {
+ {
+ return pResource;
+ }
+ }
// get the raw wl_proxy ptr
- wl_proxy* proxy() {{
- return pResource;
- }}
+ wl_proxy* proxy() {
+ {
+ return pResource;
+ }
+ }
// get the resource version
- int version() {{
- return wl_proxy_get_version(pResource);
- }}
-
+ int version() {
+ {
+ return wl_proxy_get_version(pResource);
+ }
+ }
+
// --------------- Requests --------------- //
- void setDataOffer(F<void(CCExtDataControlDeviceV1*, wl_proxy*)> &&handler);
- void setSelection(F<void(CCExtDataControlDeviceV1*, wl_proxy*)> &&handler);
- void setFinished(F<void(CCExtDataControlDeviceV1*)> &&handler);
- void setPrimarySelection(F<void(CCExtDataControlDeviceV1*, wl_proxy*)> &&handler);
+ void setDataOffer(F<void(CCExtDataControlDeviceV1*, wl_proxy*)>&& handler);
+ void setSelection(F<void(CCExtDataControlDeviceV1*, wl_proxy*)>&& handler);
+ void setFinished(F<void(CCExtDataControlDeviceV1*)>&& handler);
+ void setPrimarySelection(F<void(CCExtDataControlDeviceV1*, wl_proxy*)>&& handler);
// --------------- Events --------------- //
@@ -171,7 +184,7 @@ class CCExtDataControlDeviceV1 {
void sendDestroy();
void sendSetPrimarySelection(CCExtDataControlSourceV1*);
- private:
+private:
struct {
F<void(CCExtDataControlDeviceV1*, wl_proxy*)> dataOffer;
F<void(CCExtDataControlDeviceV1*, wl_proxy*)> selection;
@@ -186,50 +199,57 @@ class CCExtDataControlDeviceV1 {
void* pData = nullptr;
};
-
-
class CCExtDataControlSourceV1 {
- public:
+public:
CCExtDataControlSourceV1(wl_proxy*);
~CCExtDataControlSourceV1();
-
// set the data for this resource
- void setData(void* data) {{
- pData = data;
- }}
+ void setData(void* data) {
+ {
+ pData = data;
+ }
+ }
// get the data for this resource
- void* data() {{
- return pData;
- }}
+ void* data() {
+ {
+ return pData;
+ }
+ }
// get the raw wl_resource (wl_proxy) ptr
- wl_proxy* resource() {{
- return pResource;
- }}
+ wl_proxy* resource() {
+ {
+ return pResource;
+ }
+ }
// get the raw wl_proxy ptr
- wl_proxy* proxy() {{
- return pResource;
- }}
+ wl_proxy* proxy() {
+ {
+ return pResource;
+ }
+ }
// get the resource version
- int version() {{
- return wl_proxy_get_version(pResource);
- }}
-
+ int version() {
+ {
+ return wl_proxy_get_version(pResource);
+ }
+ }
+
// --------------- Requests --------------- //
- void setSend(F<void(CCExtDataControlSourceV1*, const char*, int32_t)> &&handler);
- void setCancelled(F<void(CCExtDataControlSourceV1*)> &&handler);
+ void setSend(F<void(CCExtDataControlSourceV1*, const char*, int32_t)>&& handler);
+ void setCancelled(F<void(CCExtDataControlSourceV1*)>&& handler);
// --------------- Events --------------- //
void sendOffer(const char*);
void sendDestroy();
- private:
+private:
struct {
F<void(CCExtDataControlSourceV1*, const char*, int32_t)> send;
F<void(CCExtDataControlSourceV1*)> cancelled;
@@ -242,49 +262,56 @@ class CCExtDataControlSourceV1 {
void* pData = nullptr;
};
-
-
class CCExtDataControlOfferV1 {
- public:
+public:
CCExtDataControlOfferV1(wl_proxy*);
~CCExtDataControlOfferV1();
-
// set the data for this resource
- void setData(void* data) {{
- pData = data;
- }}
+ void setData(void* data) {
+ {
+ pData = data;
+ }
+ }
// get the data for this resource
- void* data() {{
- return pData;
- }}
+ void* data() {
+ {
+ return pData;
+ }
+ }
// get the raw wl_resource (wl_proxy) ptr
- wl_proxy* resource() {{
- return pResource;
- }}
+ wl_proxy* resource() {
+ {
+ return pResource;
+ }
+ }
// get the raw wl_proxy ptr
- wl_proxy* proxy() {{
- return pResource;
- }}
+ wl_proxy* proxy() {
+ {
+ return pResource;
+ }
+ }
// get the resource version
- int version() {{
- return wl_proxy_get_version(pResource);
- }}
-
+ int version() {
+ {
+ return wl_proxy_get_version(pResource);
+ }
+ }
+
// --------------- Requests --------------- //
- void setOffer(F<void(CCExtDataControlOfferV1*, const char*)> &&handler);
+ void setOffer(F<void(CCExtDataControlOfferV1*, const char*)>&& handler);
// --------------- Events --------------- //
void sendReceive(const char*, int32_t);
void sendDestroy();
- private:
+private:
struct {
F<void(CCExtDataControlOfferV1*, const char*)> offer;
} requests;
@@ -296,6 +323,4 @@ class CCExtDataControlOfferV1 {
void* pData = nullptr;
};
-
-
#undef F