|
|
|
@ -59,12 +59,14 @@ CoreExt::CoreExt(ExtensionPtr<ToxExt> toxExt_)
@@ -59,12 +59,14 @@ CoreExt::CoreExt(ExtensionPtr<ToxExt> toxExt_)
|
|
|
|
|
|
|
|
|
|
void CoreExt::process() |
|
|
|
|
{ |
|
|
|
|
std::lock_guard<std::mutex> lock(toxext_mutex); |
|
|
|
|
toxext_iterate(toxExt.get()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void CoreExt::onLosslessPacket(uint32_t friendId, const uint8_t* data, size_t length) |
|
|
|
|
{ |
|
|
|
|
if (is_toxext_packet(data, length)) { |
|
|
|
|
std::lock_guard<std::mutex> lock(toxext_mutex); |
|
|
|
|
toxext_handle_lossless_custom_packet(toxExt.get(), friendId, data, length); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -73,11 +75,15 @@ CoreExt::Packet::Packet(
@@ -73,11 +75,15 @@ CoreExt::Packet::Packet(
|
|
|
|
|
ToxExtPacketList* packetList, |
|
|
|
|
ToxExtensionMessages* toxExtMessages, |
|
|
|
|
uint32_t friendId, |
|
|
|
|
std::mutex* toxext_mutex, |
|
|
|
|
PacketPassKey) |
|
|
|
|
: toxExtMessages(toxExtMessages) |
|
|
|
|
: toxext_mutex(toxext_mutex) |
|
|
|
|
, toxExtMessages(toxExtMessages) |
|
|
|
|
, packetList(packetList) |
|
|
|
|
, friendId(friendId) |
|
|
|
|
{} |
|
|
|
|
{ |
|
|
|
|
assert(toxext_mutex != nullptr); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::unique_ptr<ICoreExtPacket> CoreExt::getPacket(uint32_t friendId) |
|
|
|
|
{ |
|
|
|
@ -85,6 +91,7 @@ std::unique_ptr<ICoreExtPacket> CoreExt::getPacket(uint32_t friendId)
@@ -85,6 +91,7 @@ std::unique_ptr<ICoreExtPacket> CoreExt::getPacket(uint32_t friendId)
|
|
|
|
|
toxext_packet_list_create(toxExt.get(), friendId), |
|
|
|
|
toxExtMessages.get(), |
|
|
|
|
friendId, |
|
|
|
|
&toxext_mutex, |
|
|
|
|
PacketPassKey{})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -130,6 +137,8 @@ uint64_t CoreExt::Packet::addExtendedMessage(QString message)
@@ -130,6 +137,8 @@ uint64_t CoreExt::Packet::addExtendedMessage(QString message)
|
|
|
|
|
|
|
|
|
|
bool CoreExt::Packet::send() |
|
|
|
|
{ |
|
|
|
|
std::lock_guard<std::mutex> lock(*toxext_mutex); |
|
|
|
|
|
|
|
|
|
auto ret = toxext_send(packetList); |
|
|
|
|
if (ret != TOXEXT_SUCCESS) { |
|
|
|
|
qWarning() << "Failed to send packet"; |
|
|
|
|