switch to lmdb++

master
Tony Olagbaiye 3 years ago
parent 2482fd4691
commit 5011ae9fa2
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -6,7 +6,7 @@ endif
RM=rm -f
FIND=find
INCLUDES=-Ilibstrophe -Ideps \
INCLUDES=-Ilibstrophe -Ideps -Ideps/fmt/include \
$(shell xml2-config --cflags) \
$(shell pkg-config --cflags librnp-0) \
$(shell pkg-config --cflags libomemo-c)
@ -88,14 +88,11 @@ xmpp.so: $(OBJS) $(DEPS) $(HDRS)
patchelf --set-rpath $(LIBRARY_PATH):$(shell realpath $(shell dirname $(shell gcc --print-libgcc-file-name))/../../../) xmpp.so && \
patchelf --shrink-rpath xmpp.so || true
.%.o: %.cpp
@$(CXX) $(CPPFLAGS) -c $< -o $@
.%.o: %.c
@$(CC) $(CFLAGS) -c $< -o $@
xmpp/.%.o: xmpp/%.c
@$(CC) $(CFLAGS) -c $< -o $@
.%.o: %.cpp
@$(CXX) $(CPPFLAGS) -c $< -o $@
xmpp/.%.o: xmpp/%.cpp
@$(CXX) $(CPPFLAGS) -c $< -o $@

@ -2,6 +2,7 @@
// License, version 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <fmt/core.h>
#include <memory>
#include <stdlib.h>
#include <stdint.h>
@ -17,7 +18,7 @@
#include <session_pre_key.h>
#include <protocol.h>
#include <curve.h>
#include <lmdb.h>
#include <lmdb++.h>
#include <strophe.h>
#include <weechat/weechat-plugin.h>
@ -2107,28 +2108,21 @@ void omemo__init(struct t_gui_buffer *buffer, struct t_omemo **omemo,
return;
}
MDB_txn *parentTransaction = NULL;
MDB_txn *transaction = NULL;
if (mdb_txn_begin(new_omemo->db->env, parentTransaction, 0, &transaction)) {
weechat_printf(NULL, "%sxmpp: failed to open lmdb transaction",
weechat_prefix("error"));
return;
}
try {
MDB_txn *parentTransaction = NULL;
lmdb::txn transaction = lmdb::txn::begin(new_omemo->db->env, parentTransaction);
size_t db_name_len = strlen("omemo_") + strlen(account_name);
char *db_name = (char *)malloc(sizeof(char) * (db_name_len + 1));
snprintf(db_name, db_name_len+1, "omemo_%s", account_name);
if (mdb_dbi_open(transaction, db_name, MDB_CREATE, &new_omemo->db->dbi_omemo)) {
weechat_printf(NULL, "%sxmpp: failed to open lmdb database",
weechat_prefix("error"));
return;
}
size_t db_name_len = strlen("omemo_") + strlen(account_name);
char *db_name = (char *)malloc(sizeof(char) * (db_name_len + 1));
snprintf(db_name, db_name_len+1, "omemo_%s", account_name);
new_omemo->db->dbi_omemo = lmdb::dbi::open(transaction, db_name, MDB_CREATE);
if (mdb_txn_commit(transaction)) {
weechat_printf(NULL, "%sxmpp: failed to close lmdb transaction",
weechat_prefix("error"));
transaction.commit();
} catch (const std::exception& ex) {
auto format = fmt::format("%sxmpp: lmdb failure {}", ex.what());
weechat_printf(NULL, format.data(), weechat_prefix("error"));
return;
};
}
struct signal_crypto_provider crypto_provider = {
.random_func = &cp_random_generator,

Loading…
Cancel
Save