low level toxsync stuff all wired up, now only the highlevel sync logic is missing
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#include <solanaceae/plugin/solana_plugin_v1.h>
|
||||
|
||||
#include <solanaceae/crdtnotes/crdtnotes.hpp>
|
||||
#include <solanaceae/crdtnotes/crdtnotes_sync.hpp>
|
||||
//#include <solanaceae/util/config_model.hpp>
|
||||
|
||||
#include <memory>
|
||||
@ -10,6 +11,7 @@
|
||||
#define PROVIDE_INSTANCE(x, p, v) solana_api->provideInstance(#x, p, static_cast<x*>(v))
|
||||
|
||||
static std::unique_ptr<CRDTNotes> g_crdtn = nullptr;
|
||||
static std::unique_ptr<CRDTNotesSync> g_crdtns = nullptr;
|
||||
|
||||
extern "C" {
|
||||
|
||||
@ -42,10 +44,14 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
g_crdtn = std::make_unique<CRDTNotes>(/**conf*/);
|
||||
g_crdtns = std::make_unique<CRDTNotesSync>(/**conf*/);
|
||||
|
||||
// register types
|
||||
PROVIDE_INSTANCE(CRDTNotes, "CRDTNotes", g_crdtn.get());
|
||||
|
||||
PROVIDE_INSTANCE(CRDTNotesSync, "CRDTNotes", g_crdtns.get());
|
||||
PROVIDE_INSTANCE(CRDTNotesEventI, "CRDTNotes", g_crdtns.get());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
#include <solanaceae/plugin/solana_plugin_v1.h>
|
||||
|
||||
#include <solanaceae/crdtnotes/crdtnotes.hpp>
|
||||
#include <solanaceae/crdtnotes/crdtnotes_sync.hpp>
|
||||
#include <solanaceae/crdtnotes_toxsync/crdtnotes_toxsync.hpp>
|
||||
//#include <solanaceae/util/config_model.hpp>
|
||||
#include <solanaceae/contact/contact_model3.hpp>
|
||||
#include <solanaceae/toxcore/tox_interface.hpp>
|
||||
#include <solanaceae/toxcore/tox_event_interface.hpp>
|
||||
#include <solanaceae/tox_contacts/tox_contact_model2.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
@ -34,16 +36,20 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
|
||||
//ConfigModelI* conf = nullptr;
|
||||
CRDTNotes* notes = nullptr;
|
||||
CRDTNotesEventI* notes_sync = nullptr;
|
||||
Contact3Registry* cr = nullptr;
|
||||
ToxI* t = nullptr;
|
||||
ToxEventProviderI* tep = nullptr;
|
||||
ToxContactModel2* tcm = nullptr;
|
||||
|
||||
{ // make sure required types are loaded
|
||||
//conf = RESOLVE_INSTANCE(ConfigModelI);
|
||||
notes = RESOLVE_INSTANCE(CRDTNotes);
|
||||
notes_sync = RESOLVE_INSTANCE(CRDTNotesEventI);
|
||||
cr = RESOLVE_INSTANCE(Contact3Registry);
|
||||
t = RESOLVE_INSTANCE(ToxI);
|
||||
tep = RESOLVE_INSTANCE(ToxEventProviderI);
|
||||
tcm = RESOLVE_INSTANCE(ToxContactModel2);
|
||||
|
||||
//if (conf == nullptr) {
|
||||
//std::cerr << "PLUGIN CRDTN missing ConfigModelI\n";
|
||||
@ -55,6 +61,11 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (notes_sync == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNTS missing CRDTNotesEventI\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (cr == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNTS missing Contact3Registry\n";
|
||||
return 2;
|
||||
@ -69,11 +80,16 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
||||
std::cerr << "PLUGIN CRDTNTS missing ToxEventProviderI\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (tcm == nullptr) {
|
||||
std::cerr << "PLUGIN CRDTNTS missing ToxContactModel2\n";
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
// static store, could be anywhere tho
|
||||
// construct with fetched dependencies
|
||||
g_crdtn_ts = std::make_unique<CRDTNotesToxSync>(*notes, *cr, *t, *tep);
|
||||
g_crdtn_ts = std::make_unique<CRDTNotesToxSync>(*notes, *notes_sync, *cr, *t, *tep, *tcm);
|
||||
|
||||
// register types
|
||||
PROVIDE_INSTANCE(CRDTNotesToxSync, "CRDTNotesToxSync", g_crdtn_ts.get());
|
||||
|
Reference in New Issue
Block a user