You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2018/06/08 13:51:33 UTC
[2/2] qpid-proton git commit: PROTON-1857: [cpp] no access to AMQP
connection offered/desired capabilities
PROTON-1857: [cpp] no access to AMQP connection offered/desired capabilities
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/763a0798
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/763a0798
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/763a0798
Branch: refs/heads/master
Commit: 763a0798db95d967f441b52a2009851111c541ce
Parents: ba92861
Author: Alan Conway <ac...@redhat.com>
Authored: Thu Jun 7 17:34:03 2018 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu Jun 7 17:48:34 2018 -0400
----------------------------------------------------------------------
cpp/include/proton/connection.hpp | 7 +++++++
cpp/include/proton/connection_options.hpp | 7 +++++++
cpp/src/connection.cpp | 11 +++++++++++
cpp/src/connection_options.cpp | 11 +++++++++++
cpp/src/container_test.cpp | 22 ++++++++++++++++++++++
5 files changed, 58 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/763a0798/cpp/include/proton/connection.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/connection.hpp b/cpp/include/proton/connection.hpp
index 603d5dd..298a4be 100644
--- a/cpp/include/proton/connection.hpp
+++ b/cpp/include/proton/connection.hpp
@@ -27,6 +27,7 @@
#include "./internal/object.hpp"
#include "./endpoint.hpp"
#include "./session.hpp"
+#include "./symbol.hpp"
#include <proton/type_compat.h>
@@ -138,6 +139,12 @@ PN_CPP_CLASS_EXTERN connection : public internal::object<pn_connection_t>, publi
/// @see @ref connection_options::max_sessions
PN_CPP_EXTERN uint16_t max_sessions() const;
+ /// **Unsettled API** - Extension capabilities offered by the remote peer.
+ PN_CPP_EXTERN std::vector<symbol> offered_capabilities() const;
+
+ /// **Unsettled API** - Extension capabilities desired by the remote peer.
+ PN_CPP_EXTERN std::vector<symbol> desired_capabilities() const;
+
/// Get the idle timeout set by the remote peer.
///
/// @see @ref connection_options::idle_timeout
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/763a0798/cpp/include/proton/connection_options.hpp
----------------------------------------------------------------------
diff --git a/cpp/include/proton/connection_options.hpp b/cpp/include/proton/connection_options.hpp
index 2583a16..3a51446 100644
--- a/cpp/include/proton/connection_options.hpp
+++ b/cpp/include/proton/connection_options.hpp
@@ -27,6 +27,7 @@
#include "./internal/config.hpp"
#include "./internal/export.hpp"
#include "./internal/pn_unique_ptr.hpp"
+#include "./symbol.hpp"
#include "./types_fwd.hpp"
#include <proton/type_compat.h>
@@ -145,6 +146,12 @@ class connection_options {
/// Specify the allowed mechanisms for use on the connection.
PN_CPP_EXTERN connection_options& sasl_allowed_mechs(const std::string&);
+ /// **Unsettled API** - Extension capabilities offered to the remote peer.
+ PN_CPP_EXTERN connection_options& offered_capabilities(const std::vector<symbol>&);
+
+ /// **Unsettled API** - Extension capabilities desired from the remote peer.
+ PN_CPP_EXTERN connection_options& desired_capabilities(const std::vector<symbol>&);
+
/// **Unsettled API** - Set the SASL configuration name.
PN_CPP_EXTERN connection_options& sasl_config_name(const std::string&);
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/763a0798/cpp/src/connection.cpp
----------------------------------------------------------------------
diff --git a/cpp/src/connection.cpp b/cpp/src/connection.cpp
index 1d66c41..8060059 100644
--- a/cpp/src/connection.cpp
+++ b/cpp/src/connection.cpp
@@ -21,6 +21,7 @@
#include "proton_bits.hpp"
+#include "proton/codec/vector.hpp"
#include "proton/connection.hpp"
#include "proton/connection_options.hpp"
#include "proton/container.hpp"
@@ -179,4 +180,14 @@ void connection::wake() const {
pn_connection_wake(pn_object());
}
+std::vector<symbol> connection::offered_capabilities() const {
+ value caps(pn_connection_offered_capabilities(pn_object()));
+ return caps.empty() ? std::vector<symbol>() : caps.get<std::vector<symbol> >();
+}
+
+std::vector<symbol> connection::desired_capabilities() const {
+ value caps(pn_connection_desired_capabilities(pn_object()));
+ return caps.empty() ? std::vector<symbol>() : caps.get<std::vector<symbol> >();
+}
+
}
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/763a0798/cpp/src/connection_options.cpp
----------------------------------------------------------------------
diff --git a/cpp/src/connection_options.cpp b/cpp/src/connection_options.cpp
index 362d1cf..1903536 100644
--- a/cpp/src/connection_options.cpp
+++ b/cpp/src/connection_options.cpp
@@ -21,6 +21,7 @@
#include "proton/connection_options.hpp"
#include "proton/connection.hpp"
+#include "proton/codec/vector.hpp"
#include "proton/fwd.hpp"
#include "proton/messaging_handler.hpp"
#include "proton/reconnect_options.hpp"
@@ -58,6 +59,8 @@ class connection_options::impl {
option<std::string> virtual_host;
option<std::string> user;
option<std::string> password;
+ option<std::vector<symbol> > offered_capabilities;
+ option<std::vector<symbol> > desired_capabilities;
option<reconnect_options> reconnect;
option<class ssl_client_options> ssl_client_options;
option<class ssl_server_options> ssl_server_options;
@@ -91,6 +94,10 @@ class connection_options::impl {
pn_connection_set_user(pnc, user.value.c_str());
if (password.set)
pn_connection_set_password(pnc, password.value.c_str());
+ if (offered_capabilities.set)
+ value(pn_connection_offered_capabilities(pnc)) = offered_capabilities.value;
+ if (desired_capabilities.set)
+ value(pn_connection_desired_capabilities(pnc)) = desired_capabilities.value;
}
void apply_transport(pn_transport_t* pnt) {
@@ -152,6 +159,8 @@ class connection_options::impl {
virtual_host.update(x.virtual_host);
user.update(x.user);
password.update(x.password);
+ offered_capabilities.update(x.offered_capabilities);
+ desired_capabilities.update(x.desired_capabilities);
reconnect.update(x.reconnect);
ssl_client_options.update(x.ssl_client_options);
ssl_server_options.update(x.ssl_server_options);
@@ -192,6 +201,8 @@ connection_options& connection_options::container_id(const std::string &id) { im
connection_options& connection_options::virtual_host(const std::string &id) { impl_->virtual_host = id; return *this; }
connection_options& connection_options::user(const std::string &user) { impl_->user = user; return *this; }
connection_options& connection_options::password(const std::string &password) { impl_->password = password; return *this; }
+connection_options& connection_options::offered_capabilities(const std::vector<symbol> &caps) { impl_->offered_capabilities = caps; return *this; }
+connection_options& connection_options::desired_capabilities(const std::vector<symbol> &caps) { impl_->desired_capabilities = caps; return *this; }
connection_options& connection_options::reconnect(const reconnect_options &r) { impl_->reconnect = r; return *this; }
connection_options& connection_options::ssl_client_options(const class ssl_client_options &c) { impl_->ssl_client_options = c; return *this; }
connection_options& connection_options::ssl_server_options(const class ssl_server_options &c) { impl_->ssl_server_options = c; return *this; }
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/763a0798/cpp/src/container_test.cpp
----------------------------------------------------------------------
diff --git a/cpp/src/container_test.cpp b/cpp/src/container_test.cpp
index 5bfaa28..f73f95b 100644
--- a/cpp/src/container_test.cpp
+++ b/cpp/src/container_test.cpp
@@ -88,6 +88,8 @@ class test_handler : public proton::messaging_handler {
std::string peer_vhost;
std::string peer_container_id;
+ std::vector<proton::symbol> peer_offered_capabilities;
+ std::vector<proton::symbol> peer_desired_capabilities;
proton::listener listener;
test_listen_handler listen_handler;
@@ -107,6 +109,8 @@ class test_handler : public proton::messaging_handler {
peer_vhost = c.virtual_host();
if (peer_container_id.empty() && !c.container_id().empty())
peer_container_id = c.container_id();
+ peer_offered_capabilities = c.offered_capabilities();
+ peer_desired_capabilities = c.desired_capabilities();
if (!closing) c.close();
closing = true;
}
@@ -157,6 +161,23 @@ int test_container_no_vhost() {
return 0;
}
+std::vector<proton::symbol> make_caps(const std::string& s) {
+ std::vector<proton::symbol> caps;
+ caps.push_back(s);
+ return caps;
+}
+
+int test_container_capabilities() {
+ proton::connection_options opts;
+ opts.offered_capabilities(make_caps("offered"));
+ opts.desired_capabilities(make_caps("desired"));
+ test_handler th("", opts);
+ proton::container(th).run();
+ ASSERT_EQUAL(th.peer_offered_capabilities[0], proton::symbol("offered"));
+ ASSERT_EQUAL(th.peer_desired_capabilities[0], proton::symbol("desired"));
+ return 0;
+}
+
int test_container_bad_address() {
// Listen on a bad address, check for leaks
// Regression test for https://issues.apache.org/jira/browse/PROTON-1217
@@ -372,6 +393,7 @@ int main(int argc, char** argv) {
int failed = 0;
RUN_ARGV_TEST(failed, test_container_default_container_id());
RUN_ARGV_TEST(failed, test_container_vhost());
+ RUN_ARGV_TEST(failed, test_container_capabilities());
RUN_ARGV_TEST(failed, test_container_default_vhost());
RUN_ARGV_TEST(failed, test_container_no_vhost());
RUN_ARGV_TEST(failed, test_container_bad_address());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org