Working IPFS network test!

master
Melroy van den Berg 2020-12-04 23:37:01 +01:00
parent f777bf2eac
commit d43289901f
7 changed files with 59 additions and 4 deletions

View File

@ -67,6 +67,12 @@
"bit": "cpp",
"cstring": "cpp",
"set": "cpp",
"valarray": "cpp"
"valarray": "cpp",
"bitset": "cpp",
"csignal": "cpp",
"forward_list": "cpp",
"unordered_set": "cpp",
"regex": "cpp",
"shared_mutex": "cpp"
}
}

View File

@ -39,6 +39,8 @@ set(SOURCES
menu.h
md-parser.cc
md-parser.h
network.cc
network.h
render-area.cc
render-area.h
)
@ -63,13 +65,11 @@ get_property(CMAKE_BINARY_DIR GLOBAL PROPERTY COMMONMARKER_BINARY_DIR)
get_property(CMAKE_EXTENSIONS_BINARY_DIR GLOBAL PROPERTY COMMONMARKER_EXTENSIONS_BINARY_DIR)
target_include_directories(${PROJECT_TARGET} PRIVATE
${PROJECT_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}
${CMAKE_EXTENSIONS_BINARY_DIR}
${GTKMM_INCLUDE_DIRS}
${CAIRO_INCLUDE_DIRS}
lib/commonmarker/src
lib/ipfs-http-client/include
${PROJECT_SOURCE_DIR}/lib/ipfs-http-client/include
)
target_link_directories(${PROJECT_TARGET} PRIVATE

View File

@ -28,6 +28,10 @@ MainWindow::MainWindow() : m_vbox(Gtk::ORIENTATION_VERTICAL, 0)
add(m_vbox);
show_all_children();
// Just an IPFS test! Fetch a resource from the IPFS network
// Assuming you already running a IPFS deamon
network.FetchReadme();
// Setup parser
setupParser();
}

View File

@ -7,6 +7,7 @@
#include <gtkmm/scrolledwindow.h>
#include "render-area.h"
#include "menu.h"
#include "network.h"
class Parser;
@ -28,6 +29,7 @@ protected:
RenderArea m_renderArea;
private:
Parser *parser;
Network network;
void setupParser();
};

View File

@ -1,3 +1,6 @@
#ifndef MENU_H
#define MENU_H
#include <signal.h>
#include <gtkmm/menubar.h>
#include <gtkmm/menu.h>
@ -32,3 +35,4 @@ protected:
private:
Gtk::MenuItem* createMenuItem(const Glib::ustring& label_text);
};
#endif

View File

@ -0,0 +1,19 @@
#include "network.h"
#include <iostream>
#include <sstream>
Network::Network()
: client("localhost", 5001)
{
}
Network::~Network() {
}
void Network::FetchReadme() {
// Demo ...
std::stringstream contents;
client.FilesGet("/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme", &contents);
std::cout << contents.str() << std::endl;
}

View File

@ -0,0 +1,20 @@
#ifndef NETWORK_H
#define NETWORK_H
#include <ipfs/client.h>
/**
* \class Network
* \brief IPFS Network
*/
class Network
{
public:
Network();
virtual ~Network();
void FetchReadme();
private:
ipfs::Client client;
};
#endif