mirror of https://github.com/bqv/weechat-xmpp
restore lost code
parent
5377445423
commit
e0a3aace3a
@ -0,0 +1,33 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// 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 "strophe.hh"
|
||||
|
||||
xmpp_log_t* logger = nullptr;
|
||||
|
||||
namespace xmpp {
|
||||
context::context()
|
||||
: context(xmpp_ctx_new(nullptr, logger)) {
|
||||
}
|
||||
|
||||
context::context(xmpp_ctx_ptr ptr)
|
||||
: xmpp_ctx_ptr(std::move(ptr)) {
|
||||
}
|
||||
|
||||
context::context(xmpp_ctx_t *ptr)
|
||||
: context(std::move(xmpp_ctx_ptr(
|
||||
ptr, [this] (xmpp_ctx_t *ctx) {
|
||||
xmpp_ctx_free(ctx);
|
||||
}
|
||||
))) {
|
||||
}
|
||||
|
||||
context::~context() {
|
||||
this->reset(nullptr);
|
||||
}
|
||||
|
||||
void shutdown() {
|
||||
xmpp_shutdown();
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// 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/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
extern "C" {
|
||||
#include <strophe.h>
|
||||
}
|
||||
|
||||
namespace xmpp {
|
||||
typedef std::unique_ptr<
|
||||
xmpp_ctx_t,
|
||||
std::function<void(xmpp_ctx_t*)>> xmpp_ctx_ptr;
|
||||
|
||||
class context : public xmpp_ctx_ptr {
|
||||
public:
|
||||
context();
|
||||
context(xmpp_ctx_ptr ptr);
|
||||
context(xmpp_ctx_t *ptr);
|
||||
~context();
|
||||
};
|
||||
|
||||
void shutdown();
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
#include <iostream>
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
#include "../strophe.hh"
|
||||
|
||||
TEST_CASE("create context")
|
||||
{
|
||||
xmpp::context ctx;
|
||||
|
||||
CHECK(ctx.get());
|
||||
}
|
Loading…
Reference in New Issue