Merge pull request #2412 from PurpleI2P/revert-2411-openssl

Revert "Haiku OS gui"
This commit is contained in:
orignal
2026-06-17 13:47:58 -04:00
committed by GitHub
+5 -86
View File
@@ -18,8 +18,6 @@
#include <Window.h>
#include <Application.h>
#include <Alert.h>
#include<sstream>
//#include<Roster.h>
#include "version.h"
#include "Log.h"
@@ -36,9 +34,7 @@ enum
M_RUN_PEER_TEST,
M_DUMMY_COMMAND,
C_GRACEFUL_SHUTDOWN_UPDATE,
C_MAIN_VIEW_UPDATE,
M_SHOW_TUNNEL,
C_OPENHTTP
C_MAIN_VIEW_UPDATE
};
constexpr bigtime_t GRACEFUL_SHUTDOWN_UPDATE_INTERVAL = 1000*1100; // in microseconds, ~ 1 sec
constexpr int GRACEFUL_SHUTDOWN_UPDATE_COUNT = 600; // 10 minutes
@@ -52,10 +48,9 @@ class MainWindow: public BWindow
private:
void MessageReceived (BMessage * msg) override;
bool QuitRequested () override;
void GetInfoAboutTunnel(BMessage * msg);
void UpdateMainView ();
void OpenHTTPInterface(void);
template <class T> void DrawTunnel(T tun);
private:
BMessenger m_Messenger;
BStringView * m_MainView;
@@ -79,7 +74,6 @@ MainWindow::MainWindow ():
auto menuBar = new BMenuBar (r, "menubar");
AddChild (menuBar);
auto runMenu = new BMenu ("Run");
runMenu->AddItem (new BMenuItem ("Open web interface", new BMessage(C_OPENHTTP)));
runMenu->AddItem (new BMenuItem ("Graceful shutdown", new BMessage (M_GRACEFUL_SHUTDOWN), 'G'));
runMenu->AddItem (new BMenuItem ("Quit", new BMessage (B_QUIT_REQUESTED), 'Q'));
menuBar->AddItem (runMenu);
@@ -88,19 +82,9 @@ MainWindow::MainWindow ():
menuBar->AddItem (commandsMenu);
auto tunnelsMenu = new BMenu ("Tunnels");
for (auto& it: i2p::client::context.GetClientTunnels ())
{
auto msg = new BMessage{M_SHOW_TUNNEL};
msg->AddString("tunnel_name", BString(it.second->GetName()));
msg->AddBool("is_client_tunnel", true);
tunnelsMenu->AddItem (new BMenuItem (it.second->GetName (), msg));
}
tunnelsMenu->AddItem (new BMenuItem (it.second->GetName (), new BMessage (M_DUMMY_COMMAND)));
for (auto& it: i2p::client::context.GetServerTunnels ())
{
auto msg = new BMessage{M_SHOW_TUNNEL};
msg->AddString("tunnel_name", BString(it.second->GetName()));
msg->AddBool("is_client_tunnel", false);
tunnelsMenu->AddItem (new BMenuItem (it.second->GetName (), msg));
}
tunnelsMenu->AddItem (new BMenuItem (it.second->GetName (), new BMessage (M_DUMMY_COMMAND)));
menuBar->AddItem (tunnelsMenu);
m_MainView = new BStringView (BRect (20, 21, 300, 250), nullptr, "Starting...", B_FOLLOW_ALL, B_WILL_DRAW);
m_MainView->SetViewColor (255, 255, 255);
@@ -120,79 +104,14 @@ void MainWindow::UpdateMainView ()
m_MainView->SetText (s.str ().c_str ());
}
template <class T>
void MainWindow :: DrawTunnel(T tun) // idk about type, so todo: change to normal type
{
m_MainView->SetText( i2p::client::context.GetAddressBook().ToAddress(tun).c_str() );
}
void MainWindow :: GetInfoAboutTunnel(BMessage * msg)
{
if(!msg) return;
bool isClient = false;
BString name{};
msg->FindString("tunnel_name", &name);
msg->FindBool("is_client_tunnel", &isClient);
if (isClient)
{
for(auto it :i2p::client::context.GetClientTunnels () )
{
if( BString(it.second->GetName()) == name )
{
auto & ident = it.second->GetLocalDestination()->GetIdentHash();
return DrawTunnel(ident);
//TODO:
}
}
}else {
for(auto it: i2p::client::context.GetServerTunnels())
{
if( BString(it.second->GetName()) == name)
{
auto & ident = it.second->GetLocalDestination()->GetIdentHash();
return DrawTunnel(ident);
//TODO:
}
}
}// if not client tunnel
}
void MainWindow :: OpenHTTPInterface()
{
bool enabled; i2p::config::GetOption("http.enabled", enabled);
uint16_t port; i2p::config::GetOption("http.port", port);
std::string address; i2p::config::GetOption("http.address", address);
if(!enabled)
{
return m_MainView->SetText("Not enabled http server");
}
// int pid;
std::ostringstream com;
com << "WebPositive http://" << address << ":" << port;
//char * argv[] = {(char*)url.str().c_str() , NULL, NULL};
//BRoster{}.Launch( "application/x-vnd.Haiku-WebPositive", 2, argv);
std::string url_s{url.str()};
std::thread ([url_s]() {
system(url_s.c_str());
}).detach();
}
void MainWindow::MessageReceived (BMessage * msg)
{
if (!msg) return;
switch (msg->what)
{
case C_MAIN_VIEW_UPDATE:
UpdateMainView ();
break;
case C_OPENHTTP:
OpenHTTPInterface();
break;
case M_SHOW_TUNNEL:
GetInfoAboutTunnel(msg);
break;
case M_GRACEFUL_SHUTDOWN:
if (!m_GracefulShutdownTimer)
{