Compare commits
7 Commits
70bc3a47f2
...
tray_test1
Author | SHA1 | Date | |
---|---|---|---|
a6df1ecf8e | |||
e82a99c312 | |||
6a9e02e241 | |||
54409b01f5 | |||
8ba8b6322f | |||
bc0f21175b | |||
f7471ca4cb |
@ -33,6 +33,7 @@
|
|||||||
android:required="false" />
|
android:required="false" />
|
||||||
|
|
||||||
<!-- Audio recording support -->
|
<!-- Audio recording support -->
|
||||||
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.microphone"
|
android:name="android.hardware.microphone"
|
||||||
android:required="false" />
|
android:required="false" />
|
||||||
@ -56,9 +57,6 @@
|
|||||||
<!-- Allow access to the vibrator -->
|
<!-- Allow access to the vibrator -->
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
|
|
||||||
<!-- if you want to capture audio, uncomment this. -->
|
|
||||||
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
|
|
||||||
|
|
||||||
<!-- Create a Java class extending SDLActivity and place it in a
|
<!-- Create a Java class extending SDLActivity and place it in a
|
||||||
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
directory under app/src/main/java matching the package, e.g. app/src/main/java/com/gamemaker/game/MyGame.java
|
||||||
|
|
||||||
|
6
external/sdl/CMakeLists.txt
vendored
6
external/sdl/CMakeLists.txt
vendored
@ -9,7 +9,8 @@ if (NOT TARGET SDL3::SDL3)
|
|||||||
set(SDL_DISABLE_ANDROID_JAR OFF CACHE INTERNAL "")
|
set(SDL_DISABLE_ANDROID_JAR OFF CACHE INTERNAL "")
|
||||||
|
|
||||||
FetchContent_Declare(SDL3
|
FetchContent_Declare(SDL3
|
||||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
#GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
||||||
|
GIT_REPOSITORY https://github.com/Semphriss/SDL
|
||||||
#GIT_TAG 0429f5d6a36fc35b551bcc2acd4a40c2db6dab82 # tip when looking
|
#GIT_TAG 0429f5d6a36fc35b551bcc2acd4a40c2db6dab82 # tip when looking
|
||||||
#GIT_TAG 14f584a94bfd49cf1524db75bf3c419fdf9436cd # tip 26-04-2024
|
#GIT_TAG 14f584a94bfd49cf1524db75bf3c419fdf9436cd # tip 26-04-2024
|
||||||
#GIT_TAG 06d6f2cb2518622593570985589700910cf4399f # 13-05-2024 - before
|
#GIT_TAG 06d6f2cb2518622593570985589700910cf4399f # 13-05-2024 - before
|
||||||
@ -25,7 +26,8 @@ if (NOT TARGET SDL3::SDL3)
|
|||||||
#GIT_TAG 6e885d96193a4b0096fe7fed6d4e6c3e5f247283 # tip 09-09-2024
|
#GIT_TAG 6e885d96193a4b0096fe7fed6d4e6c3e5f247283 # tip 09-09-2024
|
||||||
#GIT_TAG 9dd8859240703d886941733ad32c1dc6f50d64f0 # tip 19-09-2024
|
#GIT_TAG 9dd8859240703d886941733ad32c1dc6f50d64f0 # tip 19-09-2024
|
||||||
#GIT_TAG afdf325fb4090e93a124519d1a3bc1fbe0ba9025 # bad
|
#GIT_TAG afdf325fb4090e93a124519d1a3bc1fbe0ba9025 # bad
|
||||||
GIT_TAG e292d1f5ace469f718d7b6b4dec8c28e37dcaa0e # tip 05-10-2024 (3.1.3)
|
#GIT_TAG e292d1f5ace469f718d7b6b4dec8c28e37dcaa0e # tip 05-10-2024 (3.1.3)
|
||||||
|
GIT_TAG c523f0bcfeb5700ee233b7fae3c2b036822b8627
|
||||||
|
|
||||||
FIND_PACKAGE_ARGS # for the future
|
FIND_PACKAGE_ARGS # for the future
|
||||||
)
|
)
|
||||||
|
2
external/solanaceae_message3
vendored
2
external/solanaceae_message3
vendored
Submodule external/solanaceae_message3 updated: 9728f71c98...3e6c857c8a
2
external/solanaceae_tox
vendored
2
external/solanaceae_tox
vendored
Submodule external/solanaceae_tox updated: 1a3d9dd187...a0c3336f37
@ -66,6 +66,9 @@ target_sources(tomato PUBLIC
|
|||||||
./sdl_clipboard_utils.hpp
|
./sdl_clipboard_utils.hpp
|
||||||
./sdl_clipboard_utils.cpp
|
./sdl_clipboard_utils.cpp
|
||||||
|
|
||||||
|
./sys_tray.hpp
|
||||||
|
./sys_tray.cpp
|
||||||
|
|
||||||
./chat_gui/theme.hpp
|
./chat_gui/theme.hpp
|
||||||
./chat_gui/theme.cpp
|
./chat_gui/theme.cpp
|
||||||
./chat_gui/icons/direct.hpp
|
./chat_gui/icons/direct.hpp
|
||||||
|
@ -198,7 +198,7 @@ void FileSelector::render(void) {
|
|||||||
const auto ctime = std::chrono::system_clock::to_time_t(file_time_converted);
|
const auto ctime = std::chrono::system_clock::to_time_t(file_time_converted);
|
||||||
|
|
||||||
const auto ltime = std::localtime(&ctime);
|
const auto ltime = std::localtime(&ctime);
|
||||||
ImGui::TextDisabled("%2d.%2d.%2d - %2d:%2d", ltime->tm_mday, ltime->tm_mon, ltime->tm_year + 1900, ltime->tm_hour, ltime->tm_min);
|
ImGui::TextDisabled("%2d.%2d.%2d - %2d:%2d", ltime->tm_mday, ltime->tm_mon + 1, ltime->tm_year + 1900, ltime->tm_hour, ltime->tm_min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ void ChatGui4::setClipboardData(std::vector<std::string> mime_types, std::shared
|
|||||||
ChatGui4::ChatGui4(
|
ChatGui4::ChatGui4(
|
||||||
ConfigModelI& conf,
|
ConfigModelI& conf,
|
||||||
ObjectStore2& os,
|
ObjectStore2& os,
|
||||||
RegistryMessageModel& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
Contact3Registry& cr,
|
Contact3Registry& cr,
|
||||||
TextureUploaderI& tu,
|
TextureUploaderI& tu,
|
||||||
ContactTextureCache& contact_tc,
|
ContactTextureCache& contact_tc,
|
||||||
@ -1118,38 +1118,38 @@ void ChatGui4::renderMessageBodyFile(Message3Registry& reg, const Message3 e) {
|
|||||||
// hacky
|
// hacky
|
||||||
const auto* fts = o.try_get<ObjComp::Ephemeral::File::TransferStats>();
|
const auto* fts = o.try_get<ObjComp::Ephemeral::File::TransferStats>();
|
||||||
if (fts != nullptr && o.any_of<ObjComp::F::SingleInfo, ObjComp::F::CollectionInfo>()) {
|
if (fts != nullptr && o.any_of<ObjComp::F::SingleInfo, ObjComp::F::CollectionInfo>()) {
|
||||||
const auto total_size =
|
const int64_t total_size =
|
||||||
o.all_of<ObjComp::F::SingleInfo>() ?
|
o.all_of<ObjComp::F::SingleInfo>() ?
|
||||||
o.get<ObjComp::F::SingleInfo>().file_size :
|
o.get<ObjComp::F::SingleInfo>().file_size :
|
||||||
o.get<ObjComp::F::CollectionInfo>().total_size
|
o.get<ObjComp::F::CollectionInfo>().total_size
|
||||||
;
|
;
|
||||||
|
|
||||||
uint64_t total {0u};
|
int64_t transfer_total {0u};
|
||||||
float rate {0.f};
|
float transfer_rate {0.f};
|
||||||
if (o.all_of<ObjComp::F::TagLocalHaveAll>() && fts->total_down <= 0) {
|
if (o.all_of<ObjComp::F::TagLocalHaveAll>() && fts->total_down <= 0) {
|
||||||
// if have all AND no dl -> show upload progress
|
// if have all AND no dl -> show upload progress
|
||||||
ImGui::TextUnformatted(" up");
|
ImGui::TextUnformatted(" up");
|
||||||
total = fts->total_up;
|
transfer_total = fts->total_up;
|
||||||
rate = fts->rate_up;
|
transfer_rate = fts->rate_up;
|
||||||
} else {
|
} else {
|
||||||
// else show download progress
|
// else show download progress
|
||||||
ImGui::TextUnformatted("down");
|
ImGui::TextUnformatted("down");
|
||||||
total = fts->total_down;
|
transfer_total = fts->total_down;
|
||||||
rate = fts->rate_down;
|
transfer_rate = fts->rate_down;
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
float fraction = float(total) / total_size;
|
float fraction = float(transfer_total) / total_size;
|
||||||
|
|
||||||
char overlay_buf[64];
|
char overlay_buf[64];
|
||||||
if (rate > 0.000001f) {
|
if (transfer_rate > 0.000001f) {
|
||||||
const char* byte_suffix = "???";
|
const char* byte_suffix = "???";
|
||||||
int64_t byte_divider = sizeToHumanReadable(rate, byte_suffix);
|
int64_t byte_divider = sizeToHumanReadable(transfer_rate, byte_suffix);
|
||||||
int64_t seconds_remaining = (total_size - total) / rate;
|
int64_t seconds_remaining = (total_size - transfer_total) / transfer_rate;
|
||||||
if (seconds_remaining > 0) {
|
if (seconds_remaining > 0) {
|
||||||
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s %lds ", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix, seconds_remaining);
|
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s %lds ", fraction * 100 + 0.01f, transfer_rate/byte_divider, byte_suffix, seconds_remaining);
|
||||||
} else {
|
} else {
|
||||||
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s", fraction * 100 + 0.01f, rate/byte_divider, byte_suffix);
|
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%% @ %.1f%s/s", fraction * 100 + 0.01f, transfer_rate/byte_divider, byte_suffix);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f);
|
std::snprintf(overlay_buf, sizeof(overlay_buf), "%.1f%%", fraction * 100 + 0.01f);
|
||||||
|
@ -27,7 +27,7 @@ using MessageTextureCache = TextureCache<void*, Message3Handle, MessageImageLoad
|
|||||||
class ChatGui4 {
|
class ChatGui4 {
|
||||||
ConfigModelI& _conf;
|
ConfigModelI& _conf;
|
||||||
ObjectStore2& _os;
|
ObjectStore2& _os;
|
||||||
RegistryMessageModel& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
Contact3Registry& _cr;
|
Contact3Registry& _cr;
|
||||||
|
|
||||||
ContactTextureCache& _contact_tc;
|
ContactTextureCache& _contact_tc;
|
||||||
@ -60,7 +60,7 @@ class ChatGui4 {
|
|||||||
ChatGui4(
|
ChatGui4(
|
||||||
ConfigModelI& conf,
|
ConfigModelI& conf,
|
||||||
ObjectStore2& os,
|
ObjectStore2& os,
|
||||||
RegistryMessageModel& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
Contact3Registry& cr,
|
Contact3Registry& cr,
|
||||||
TextureUploaderI& tu,
|
TextureUploaderI& tu,
|
||||||
ContactTextureCache& contact_tc,
|
ContactTextureCache& contact_tc,
|
||||||
|
@ -7,34 +7,21 @@
|
|||||||
SDLVideo2InputDevice::SDLVideo2InputDevice(void) {
|
SDLVideo2InputDevice::SDLVideo2InputDevice(void) {
|
||||||
int devcount {0};
|
int devcount {0};
|
||||||
SDL_CameraID *devices = SDL_GetCameras(&devcount);
|
SDL_CameraID *devices = SDL_GetCameras(&devcount);
|
||||||
std::cout << "SDLVID: SDL Camera Driver: " << SDL_GetCurrentCameraDriver() << "\n";
|
|
||||||
|
|
||||||
if (devices == nullptr || devcount < 1) {
|
if (devices == nullptr || devcount < 1) {
|
||||||
throw int(2); // TODO: proper error code
|
throw int(2); // TODO: proper error code
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "SDLVID: found cameras:\n";
|
// pick the last (usually the newest device)
|
||||||
for (int i = 0; i < devcount; i++) {
|
_dev = devices[devcount-1];
|
||||||
const SDL_CameraID device = devices[i];
|
|
||||||
|
|
||||||
const char *name = SDL_GetCameraName(device);
|
|
||||||
std::cout << " - Camera #" << i << ": " << name << "\n";
|
|
||||||
|
|
||||||
int speccount {0};
|
|
||||||
SDL_CameraSpec** specs = SDL_GetCameraSupportedFormats(device, &speccount);
|
|
||||||
if (specs == nullptr) {
|
|
||||||
std::cout << " - no supported spec\n";
|
|
||||||
} else {
|
|
||||||
for (int spec_i = 0; spec_i < speccount; spec_i++) {
|
|
||||||
std::cout << " - " << specs[spec_i]->width << "x" << specs[spec_i]->height << "@" << float(specs[spec_i]->framerate_numerator)/specs[spec_i]->framerate_denominator << "fps " << SDL_GetPixelFormatName(specs[spec_i]->format) << "\n";
|
|
||||||
|
|
||||||
}
|
|
||||||
SDL_free(specs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SDL_free(devices);
|
SDL_free(devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDLVideo2InputDevice::SDLVideo2InputDevice(const SDL_CameraID dev) : _dev(dev) {
|
||||||
|
// nothing else?
|
||||||
|
}
|
||||||
|
|
||||||
SDLVideo2InputDevice::~SDLVideo2InputDevice(void) {
|
SDLVideo2InputDevice::~SDLVideo2InputDevice(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,19 +31,6 @@ std::shared_ptr<FrameStream2I<SDLVideoFrame>> SDLVideo2InputDevice::subscribe(vo
|
|||||||
// there was previously no stream, we assume no thread
|
// there was previously no stream, we assume no thread
|
||||||
// open device here? or on the thread?
|
// open device here? or on the thread?
|
||||||
|
|
||||||
int devcount {0};
|
|
||||||
SDL_CameraID *devices = SDL_GetCameras(&devcount);
|
|
||||||
|
|
||||||
if (devices == nullptr || devcount < 1) {
|
|
||||||
_ref--;
|
|
||||||
// error/no devices, should we do this in the constructor?
|
|
||||||
SDL_free(devices);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//auto device = devices[0];
|
|
||||||
auto device = devices[devcount-1];
|
|
||||||
|
|
||||||
SDL_CameraSpec spec {
|
SDL_CameraSpec spec {
|
||||||
// FORCE a different pixel format
|
// FORCE a different pixel format
|
||||||
SDL_PIXELFORMAT_UNKNOWN,
|
SDL_PIXELFORMAT_UNKNOWN,
|
||||||
@ -71,9 +45,9 @@ std::shared_ptr<FrameStream2I<SDLVideoFrame>> SDLVideo2InputDevice::subscribe(vo
|
|||||||
|
|
||||||
// choose a good spec, large res but <= 1080p
|
// choose a good spec, large res but <= 1080p
|
||||||
int speccount {0};
|
int speccount {0};
|
||||||
SDL_CameraSpec** specs = SDL_GetCameraSupportedFormats(device, &speccount);
|
SDL_CameraSpec** specs = SDL_GetCameraSupportedFormats(_dev, &speccount);
|
||||||
if (specs != nullptr) {
|
if (specs != nullptr) {
|
||||||
spec = *specs[0];
|
spec = *specs[speccount-1]; // start with last, as its usually the smallest
|
||||||
for (int spec_i = 1; spec_i < speccount; spec_i++) {
|
for (int spec_i = 1; spec_i < speccount; spec_i++) {
|
||||||
if (specs[spec_i]->height > 1080) {
|
if (specs[spec_i]->height > 1080) {
|
||||||
continue;
|
continue;
|
||||||
@ -104,10 +78,9 @@ std::shared_ptr<FrameStream2I<SDLVideoFrame>> SDLVideo2InputDevice::subscribe(vo
|
|||||||
|
|
||||||
camera = {
|
camera = {
|
||||||
//SDL_OpenCamera(device, nullptr),
|
//SDL_OpenCamera(device, nullptr),
|
||||||
SDL_OpenCamera(device, &spec),
|
SDL_OpenCamera(_dev, &spec),
|
||||||
&SDL_CloseCamera
|
&SDL_CloseCamera
|
||||||
};
|
};
|
||||||
SDL_free(devices);
|
|
||||||
|
|
||||||
if (!camera) {
|
if (!camera) {
|
||||||
std::cerr << "SDLVID error: failed opening camera device\n";
|
std::cerr << "SDLVID error: failed opening camera device\n";
|
||||||
|
@ -15,11 +15,13 @@
|
|||||||
// while a stream is subscribed, have the camera device open
|
// while a stream is subscribed, have the camera device open
|
||||||
// and aquire and push frames from a thread
|
// and aquire and push frames from a thread
|
||||||
struct SDLVideo2InputDevice : public FrameStream2MultiSource<SDLVideoFrame> {
|
struct SDLVideo2InputDevice : public FrameStream2MultiSource<SDLVideoFrame> {
|
||||||
|
SDL_CameraID _dev {0};
|
||||||
|
|
||||||
std::atomic_uint _ref {0};
|
std::atomic_uint _ref {0};
|
||||||
std::thread _thread;
|
std::thread _thread;
|
||||||
|
|
||||||
// TODO: device id
|
|
||||||
SDLVideo2InputDevice(void);
|
SDLVideo2InputDevice(void);
|
||||||
|
SDLVideo2InputDevice(const SDL_CameraID dev);
|
||||||
virtual ~SDLVideo2InputDevice(void);
|
virtual ~SDLVideo2InputDevice(void);
|
||||||
|
|
||||||
// we hook int multi source
|
// we hook int multi source
|
||||||
|
@ -75,7 +75,7 @@ MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme
|
|||||||
|
|
||||||
g_provideInstance<ConfigModelI>("ConfigModelI", "host", &conf);
|
g_provideInstance<ConfigModelI>("ConfigModelI", "host", &conf);
|
||||||
g_provideInstance<Contact3Registry>("Contact3Registry", "1", "host", &cr);
|
g_provideInstance<Contact3Registry>("Contact3Registry", "1", "host", &cr);
|
||||||
g_provideInstance<RegistryMessageModel>("RegistryMessageModel", "host", &rmm);
|
g_provideInstance<RegistryMessageModelI>("RegistryMessageModelI", "host", &rmm);
|
||||||
g_provideInstance<MessageSerializerNJ>("MessageSerializerNJ", "host", &msnj);
|
g_provideInstance<MessageSerializerNJ>("MessageSerializerNJ", "host", &msnj);
|
||||||
|
|
||||||
g_provideInstance<ToxI>("ToxI", "host", &tc);
|
g_provideInstance<ToxI>("ToxI", "host", &tc);
|
||||||
@ -181,21 +181,57 @@ MainScreen::MainScreen(SimpleConfigModel&& conf_, SDL_Renderer* renderer_, Theme
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_InitSubSystem(SDL_INIT_CAMERA)) {
|
if (SDL_InitSubSystem(SDL_INIT_CAMERA)) {
|
||||||
{ // video in
|
std::cout << "MS: SDL Camera Driver: " << SDL_GetCurrentCameraDriver() << "\n";
|
||||||
ObjectHandle vsrc {os.registry(), os.registry().create()};
|
|
||||||
try {
|
|
||||||
vsrc.emplace<Components::FrameStream2Source<SDLVideoFrame>>(
|
|
||||||
std::make_unique<SDLVideo2InputDevice>()
|
|
||||||
);
|
|
||||||
|
|
||||||
vsrc.emplace<Components::StreamSource>(Components::StreamSource::create<SDLVideoFrame>("SDL Video Default Recording Device"));
|
int devcount {0};
|
||||||
vsrc.emplace<Components::TagDefaultTarget>();
|
SDL_CameraID *devices = SDL_GetCameras(&devcount);
|
||||||
|
|
||||||
os.throwEventConstruct(vsrc);
|
std::cout << "MS: found cameras:\n";
|
||||||
} catch (...) {
|
if (devices != nullptr) {
|
||||||
std::cerr << "MS error: failed constructing default video input source\n";
|
ObjectHandle last_src{};
|
||||||
os.registry().destroy(vsrc);
|
for (int i = 0; i < devcount; i++) {
|
||||||
|
const SDL_CameraID device = devices[i];
|
||||||
|
|
||||||
|
const char *name = SDL_GetCameraName(device);
|
||||||
|
std::cout << " - Camera #" << i << ": " << name << "\n";
|
||||||
|
|
||||||
|
int speccount {0};
|
||||||
|
SDL_CameraSpec** specs = SDL_GetCameraSupportedFormats(device, &speccount);
|
||||||
|
if (specs == nullptr) {
|
||||||
|
std::cout << " - no supported spec\n";
|
||||||
|
} else {
|
||||||
|
for (int spec_i = 0; spec_i < speccount; spec_i++) {
|
||||||
|
std::cout << " - " << specs[spec_i]->width << "x" << specs[spec_i]->height << "@" << float(specs[spec_i]->framerate_numerator)/specs[spec_i]->framerate_denominator << "fps " << SDL_GetPixelFormatName(specs[spec_i]->format) << "\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
SDL_free(specs);
|
||||||
|
|
||||||
|
// create sink for device
|
||||||
|
ObjectHandle vsrc {os.registry(), os.registry().create()};
|
||||||
|
try {
|
||||||
|
vsrc.emplace<Components::FrameStream2Source<SDLVideoFrame>>(
|
||||||
|
std::make_unique<SDLVideo2InputDevice>(device)
|
||||||
|
);
|
||||||
|
|
||||||
|
vsrc.emplace<Components::StreamSource>(Components::StreamSource::create<SDLVideoFrame>("SDL Video '" + std::string(name) + "'"));
|
||||||
|
//vsrc.emplace<Components::TagDefaultTarget>();
|
||||||
|
|
||||||
|
os.throwEventConstruct(vsrc);
|
||||||
|
last_src = vsrc;
|
||||||
|
} catch (...) {
|
||||||
|
std::cerr << "MS error: failed constructing video input source\n";
|
||||||
|
os.registry().destroy(vsrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (static_cast<bool>(last_src)) {
|
||||||
|
// last_src.emplace<Components::TagDefaultTarget>();
|
||||||
|
//}
|
||||||
|
|
||||||
|
SDL_free(devices);
|
||||||
|
} else {
|
||||||
|
std::cout << " none\n";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "MS warning: no sdl camera: " << SDL_GetError() << "\n";
|
std::cerr << "MS warning: no sdl camera: " << SDL_GetError() << "\n";
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <solanaceae/util/simple_config_model.hpp>
|
#include <solanaceae/util/simple_config_model.hpp>
|
||||||
#include <solanaceae/contact/contact_model3.hpp>
|
#include <solanaceae/contact/contact_model3.hpp>
|
||||||
#include <solanaceae/message3/registry_message_model.hpp>
|
#include <solanaceae/message3/registry_message_model.hpp>
|
||||||
|
#include <solanaceae/message3/registry_message_model_impl.hpp>
|
||||||
#include <solanaceae/message3/message_time_sort.hpp>
|
#include <solanaceae/message3/message_time_sort.hpp>
|
||||||
#include <solanaceae/message3/message_serializer.hpp>
|
#include <solanaceae/message3/message_serializer.hpp>
|
||||||
#include <solanaceae/plugin/plugin_manager.hpp>
|
#include <solanaceae/plugin/plugin_manager.hpp>
|
||||||
@ -28,6 +29,8 @@
|
|||||||
#include "./tox_avatar_loader.hpp"
|
#include "./tox_avatar_loader.hpp"
|
||||||
#include "./message_image_loader.hpp"
|
#include "./message_image_loader.hpp"
|
||||||
|
|
||||||
|
#include "./sys_tray.hpp"
|
||||||
|
|
||||||
#include "./chat_gui4.hpp"
|
#include "./chat_gui4.hpp"
|
||||||
#include "./chat_gui/settings_window.hpp"
|
#include "./chat_gui/settings_window.hpp"
|
||||||
#include "./object_store_ui.hpp"
|
#include "./object_store_ui.hpp"
|
||||||
@ -58,7 +61,7 @@ struct MainScreen final : public Screen {
|
|||||||
|
|
||||||
SimpleConfigModel conf;
|
SimpleConfigModel conf;
|
||||||
Contact3Registry cr;
|
Contact3Registry cr;
|
||||||
RegistryMessageModel rmm;
|
RegistryMessageModelImpl rmm;
|
||||||
MessageSerializerNJ msnj;
|
MessageSerializerNJ msnj;
|
||||||
MessageTimeSort mts;
|
MessageTimeSort mts;
|
||||||
|
|
||||||
@ -90,6 +93,8 @@ struct MainScreen final : public Screen {
|
|||||||
MessageImageLoader mil;
|
MessageImageLoader mil;
|
||||||
TextureCache<void*, Message3Handle, MessageImageLoader> msg_tc;
|
TextureCache<void*, Message3Handle, MessageImageLoader> msg_tc;
|
||||||
|
|
||||||
|
SystemTray st;
|
||||||
|
|
||||||
ChatGui4 cg;
|
ChatGui4 cg;
|
||||||
SettingsWindow sw;
|
SettingsWindow sw;
|
||||||
ObjectStoreUI osui;
|
ObjectStoreUI osui;
|
||||||
|
@ -120,7 +120,7 @@ void MediaMetaInfoLoader::handleMessage(const Message3Handle& m) {
|
|||||||
_rmm.throwEventUpdate(m);
|
_rmm.throwEventUpdate(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaMetaInfoLoader::MediaMetaInfoLoader(RegistryMessageModel& rmm) : _rmm(rmm) {
|
MediaMetaInfoLoader::MediaMetaInfoLoader(RegistryMessageModelI& rmm) : _rmm(rmm) {
|
||||||
// HACK: make them be added externally?
|
// HACK: make them be added externally?
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderWebP>());
|
||||||
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
_image_loaders.push_back(std::make_unique<ImageLoaderSDLBMP>());
|
||||||
|
@ -13,14 +13,14 @@ namespace Message::Components {
|
|||||||
// adds metadata to file messages
|
// adds metadata to file messages
|
||||||
class MediaMetaInfoLoader : public RegistryMessageModelEventI {
|
class MediaMetaInfoLoader : public RegistryMessageModelEventI {
|
||||||
protected:
|
protected:
|
||||||
RegistryMessageModel& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
|
|
||||||
std::vector<std::unique_ptr<ImageLoaderI>> _image_loaders;
|
std::vector<std::unique_ptr<ImageLoaderI>> _image_loaders;
|
||||||
|
|
||||||
void handleMessage(const Message3Handle& m);
|
void handleMessage(const Message3Handle& m);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MediaMetaInfoLoader(RegistryMessageModel& rmm);
|
MediaMetaInfoLoader(RegistryMessageModelI& rmm);
|
||||||
virtual ~MediaMetaInfoLoader(void);
|
virtual ~MediaMetaInfoLoader(void);
|
||||||
|
|
||||||
protected: // rmm
|
protected: // rmm
|
||||||
|
52
src/sys_tray.cpp
Normal file
52
src/sys_tray.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#include "./sys_tray.hpp"
|
||||||
|
|
||||||
|
#include "./image_loader_sdl_image.hpp"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <fstream>
|
||||||
|
#include <ios>
|
||||||
|
#include <memory>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
SystemTray::SystemTray(void) {
|
||||||
|
std::cout << "adding sys tray\n";
|
||||||
|
|
||||||
|
std::ifstream file("../res/icon/tomato_v1_256.png");
|
||||||
|
file.seekg(0, std::ios::end);
|
||||||
|
size_t file_size = file.tellg();
|
||||||
|
file.seekg(0, std::ios::beg);
|
||||||
|
std::vector<uint8_t> data(file_size);
|
||||||
|
file.read(reinterpret_cast<char*>(data.data()), file_size);
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
std::cout << "tray icon file size: " << file_size << "\n";
|
||||||
|
|
||||||
|
ImageLoaderSDLImage il;
|
||||||
|
auto image = il.loadFromMemoryRGBA(data.data(), data.size());
|
||||||
|
std::unique_ptr<SDL_Surface, decltype(&SDL_DestroySurface)> surf = {
|
||||||
|
SDL_CreateSurfaceFrom(
|
||||||
|
image.width, image.height,
|
||||||
|
SDL_PIXELFORMAT_RGBA32,
|
||||||
|
(void*)image.frames.at(0).data.data(),
|
||||||
|
4*image.width
|
||||||
|
),
|
||||||
|
&SDL_DestroySurface
|
||||||
|
};
|
||||||
|
|
||||||
|
std::cout << "tray dims " << image.width << "x" << image.height << "\n";
|
||||||
|
|
||||||
|
|
||||||
|
// different icons?
|
||||||
|
_tray = SDL_CreateTray(surf.get(), "tomato");
|
||||||
|
if (_tray == nullptr) {
|
||||||
|
std::cerr << "failed to create SystemTray!!\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SystemTray::~SystemTray(void) {
|
||||||
|
if (_tray != nullptr) {
|
||||||
|
SDL_DestroyTray(_tray);
|
||||||
|
_tray = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
12
src/sys_tray.hpp
Normal file
12
src/sys_tray.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
class SystemTray {
|
||||||
|
SDL_Tray* _tray {nullptr};
|
||||||
|
|
||||||
|
public:
|
||||||
|
SystemTray(void);
|
||||||
|
~SystemTray(void);
|
||||||
|
};
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Contact::Components {
|
|||||||
|
|
||||||
ToxFriendFauxOfflineMessaging::ToxFriendFauxOfflineMessaging(
|
ToxFriendFauxOfflineMessaging::ToxFriendFauxOfflineMessaging(
|
||||||
Contact3Registry& cr,
|
Contact3Registry& cr,
|
||||||
RegistryMessageModel& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
ToxContactModel2& tcm,
|
ToxContactModel2& tcm,
|
||||||
ToxI& t,
|
ToxI& t,
|
||||||
ToxEventProviderI& tep
|
ToxEventProviderI& tep
|
||||||
@ -54,7 +54,7 @@ float ToxFriendFauxOfflineMessaging::tick(float time_delta) {
|
|||||||
// cleanup
|
// cleanup
|
||||||
if (_cr.all_of<Contact::Components::NextSendAttempt>(c)) {
|
if (_cr.all_of<Contact::Components::NextSendAttempt>(c)) {
|
||||||
_cr.remove<Contact::Components::NextSendAttempt>(c);
|
_cr.remove<Contact::Components::NextSendAttempt>(c);
|
||||||
auto* mr = static_cast<const RegistryMessageModel&>(_rmm).get(c);
|
auto* mr = static_cast<const RegistryMessageModelI&>(_rmm).get(c);
|
||||||
if (mr != nullptr) {
|
if (mr != nullptr) {
|
||||||
mr->storage<Message::Components::LastSendAttempt>().clear();
|
mr->storage<Message::Components::LastSendAttempt>().clear();
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ ToxFriendFauxOfflineMessaging::dfmc_Ret ToxFriendFauxOfflineMessaging::doFriendM
|
|||||||
// unacked message
|
// unacked message
|
||||||
// timeouts for exising unacked messages expired (send)
|
// timeouts for exising unacked messages expired (send)
|
||||||
|
|
||||||
auto* mr = static_cast<const RegistryMessageModel&>(_rmm).get(c);
|
auto* mr = static_cast<const RegistryMessageModelI&>(_rmm).get(c);
|
||||||
if (mr == nullptr) {
|
if (mr == nullptr) {
|
||||||
// no messages
|
// no messages
|
||||||
return dfmc_Ret::NO_MSG;
|
return dfmc_Ret::NO_MSG;
|
||||||
|
@ -15,7 +15,7 @@ namespace Contact::Components {
|
|||||||
// timers get reset on connection changes, and send order is preserved.
|
// timers get reset on connection changes, and send order is preserved.
|
||||||
class ToxFriendFauxOfflineMessaging : public ToxEventI {
|
class ToxFriendFauxOfflineMessaging : public ToxEventI {
|
||||||
Contact3Registry& _cr;
|
Contact3Registry& _cr;
|
||||||
RegistryMessageModel& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
ToxContactModel2& _tcm;
|
ToxContactModel2& _tcm;
|
||||||
ToxI& _t;
|
ToxI& _t;
|
||||||
ToxEventProviderI& _tep;
|
ToxEventProviderI& _tep;
|
||||||
@ -30,7 +30,7 @@ class ToxFriendFauxOfflineMessaging : public ToxEventI {
|
|||||||
public:
|
public:
|
||||||
ToxFriendFauxOfflineMessaging(
|
ToxFriendFauxOfflineMessaging(
|
||||||
Contact3Registry& cr,
|
Contact3Registry& cr,
|
||||||
RegistryMessageModel& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
ToxContactModel2& tcm,
|
ToxContactModel2& tcm,
|
||||||
ToxI& t,
|
ToxI& t,
|
||||||
ToxEventProviderI& tep
|
ToxEventProviderI& tep
|
||||||
|
Reference in New Issue
Block a user