2022-01-21 15:39:53 -08:00
|
|
|
#include "ipfs-daemon.h"
|
2022-05-29 08:03:58 -07:00
|
|
|
#include "main-window.h"
|
2021-04-02 18:13:39 -07:00
|
|
|
#include "option-group.h"
|
2022-01-21 15:39:53 -08:00
|
|
|
#include "project_config.h"
|
2021-04-02 18:13:39 -07:00
|
|
|
|
2020-11-28 14:47:34 -08:00
|
|
|
#include <gtkmm/application.h>
|
2021-04-02 18:13:39 -07:00
|
|
|
#include <iomanip>
|
|
|
|
#include <iostream>
|
2022-01-21 15:39:53 -08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
2020-11-12 16:54:34 -08:00
|
|
|
|
2021-04-02 18:13:39 -07:00
|
|
|
/**
|
|
|
|
* \brief Entry point of the app
|
|
|
|
*/
|
2022-01-21 15:39:53 -08:00
|
|
|
int main(int argc, char* argv[])
|
2020-11-12 16:54:34 -08:00
|
|
|
{
|
2022-01-21 15:39:53 -08:00
|
|
|
// Set the command-line parameters option settings
|
|
|
|
Glib::OptionContext context("LibreWeb Browser - Decentralized Web Browser");
|
|
|
|
OptionGroup group;
|
2022-05-25 14:22:16 -07:00
|
|
|
Glib::ustring default_timeout = group.timeout;
|
2022-01-21 15:39:53 -08:00
|
|
|
context.set_main_group(group);
|
2021-04-02 18:13:39 -07:00
|
|
|
|
2022-01-21 15:39:53 -08:00
|
|
|
// Create the GTK application
|
|
|
|
auto app = Gtk::Application::create();
|
|
|
|
app->set_flags(Gio::ApplicationFlags::APPLICATION_NON_UNIQUE);
|
2021-02-27 15:25:25 -08:00
|
|
|
|
2022-01-21 15:39:53 -08:00
|
|
|
// Parse the context
|
|
|
|
try
|
|
|
|
{
|
|
|
|
context.parse(argc, argv);
|
|
|
|
if (group.version)
|
2021-02-12 12:46:41 -08:00
|
|
|
{
|
2022-01-21 15:39:53 -08:00
|
|
|
std::cout << "LibreWeb Browser " << PROJECT_VER << std::endl;
|
|
|
|
exit(EXIT_SUCCESS);
|
2021-02-12 12:46:41 -08:00
|
|
|
}
|
2022-01-21 15:39:53 -08:00
|
|
|
}
|
|
|
|
catch (const Glib::Error& error)
|
|
|
|
{
|
|
|
|
std::cerr << "ERROR: Parse failure: " << error.what() << std::endl;
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
2021-04-03 14:31:44 -07:00
|
|
|
|
2022-01-21 15:39:53 -08:00
|
|
|
// The default is to start the IPFS Daemon
|
2022-05-25 14:22:16 -07:00
|
|
|
if (group.disable_ipfs_daemon)
|
2022-01-21 15:39:53 -08:00
|
|
|
{
|
|
|
|
std::cout << "WARN: You disabled the IPFS Daemon from starting-up "
|
|
|
|
"(you are using: -d/--disable-ipfs-daemon)."
|
|
|
|
<< std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-25 14:22:16 -07:00
|
|
|
IPFSDaemon ipfs_daemon;
|
|
|
|
ipfs_daemon.spawn();
|
2022-01-21 15:39:53 -08:00
|
|
|
}
|
|
|
|
|
2022-05-25 14:22:16 -07:00
|
|
|
if (group.timeout.compare(default_timeout) != 0)
|
2022-01-21 15:39:53 -08:00
|
|
|
{
|
|
|
|
std::cout << "WARN: You changed the time-out value. Please, be sure you know what you're doing." << std::endl;
|
|
|
|
}
|
|
|
|
|
2022-05-25 14:22:16 -07:00
|
|
|
// Run the GTK main window in the main thread
|
|
|
|
MainWindow main_window(group.timeout);
|
|
|
|
return app->run(main_window);
|
2020-11-12 16:54:34 -08:00
|
|
|
}
|