qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r1397215 - in /qpid/proton/trunk: proton-c/bindings/python/proton.py proton-c/include/proton/engine.h proton-c/src/engine/engine-internal.h proton-c/src/engine/engine.c proton-j/src/main/scripts/proton.py tests/proton_tests/engine.py
Date Thu, 11 Oct 2012 18:14:14 GMT
Author: rhs
Date: Thu Oct 11 18:14:14 2012
New Revision: 1397215

URL: http://svn.apache.org/viewvc?rev=1397215&view=rev
Log:
added support for connection capabilities

Modified:
    qpid/proton/trunk/proton-c/bindings/python/proton.py
    qpid/proton/trunk/proton-c/include/proton/engine.h
    qpid/proton/trunk/proton-c/src/engine/engine-internal.h
    qpid/proton/trunk/proton-c/src/engine/engine.c
    qpid/proton/trunk/proton-j/src/main/scripts/proton.py
    qpid/proton/trunk/tests/proton_tests/engine.py

Modified: qpid/proton/trunk/proton-c/bindings/python/proton.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/proton.py?rev=1397215&r1=1397214&r2=1397215&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/bindings/python/proton.py (original)
+++ qpid/proton/trunk/proton-c/bindings/python/proton.py Thu Oct 11 18:14:14 2012
@@ -1344,6 +1344,22 @@ class Connection(Endpoint):
   def remote_hostname(self):
     return pn_connection_remote_hostname(self._conn)
 
+  @property
+  def offered_capabilities(self):
+    return Data(_data=pn_connection_offered_capabilities(self._conn))
+
+  @property
+  def desired_capabilities(self):
+    return Data(_data=pn_connection_desired_capabilities(self._conn))
+
+  @property
+  def remote_offered_capabilities(self):
+    return Data(_data=pn_connection_remote_offered_capabilities(self._conn))
+
+  @property
+  def remote_desired_capabilities(self):
+    return Data(_data=pn_connection_remote_desired_capabilities(self._conn))
+
   def open(self):
     pn_connection_open(self._conn)
 

Modified: qpid/proton/trunk/proton-c/include/proton/engine.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/engine.h?rev=1397215&r1=1397214&r2=1397215&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/include/proton/engine.h (original)
+++ qpid/proton/trunk/proton-c/include/proton/engine.h Thu Oct 11 18:14:14 2012
@@ -129,6 +129,11 @@ const char *pn_connection_get_hostname(p
 void pn_connection_set_hostname(pn_connection_t *connection, const char *hostname);
 const char *pn_connection_remote_container(pn_connection_t *connection);
 const char *pn_connection_remote_hostname(pn_connection_t *connection);
+pn_data_t *pn_connection_offered_capabilities(pn_connection_t *connection);
+pn_data_t *pn_connection_desired_capabilities(pn_connection_t *connection);
+pn_data_t *pn_connection_remote_offered_capabilities(pn_connection_t *connection);
+pn_data_t *pn_connection_remote_desired_capabilities(pn_connection_t *connection);
+
 
 /** Extracts the first delivery on the connection that has pending
  *  operations.

Modified: qpid/proton/trunk/proton-c/src/engine/engine-internal.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine-internal.h?rev=1397215&r1=1397214&r2=1397215&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/engine/engine-internal.h (original)
+++ qpid/proton/trunk/proton-c/src/engine/engine-internal.h Thu Oct 11 18:14:14 2012
@@ -103,6 +103,8 @@ struct pn_transport_t {
   bool close_rcvd;
   char *remote_container;
   char *remote_hostname;
+  pn_data_t *remote_offered_capabilities;
+  pn_data_t *remote_desired_capabilities;
   pn_error_t *error;
   pn_session_state_t *sessions;
   size_t session_capacity;
@@ -128,6 +130,8 @@ struct pn_connection_t {
   pn_delivery_t *tpwork_tail;
   char *container;
   char *hostname;
+  pn_data_t *offered_capabilities;
+  pn_data_t *desired_capabilities;
   void *context;
 };
 

Modified: qpid/proton/trunk/proton-c/src/engine/engine.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1397215&r1=1397214&r2=1397215&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/engine/engine.c (original)
+++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Oct 11 18:14:14 2012
@@ -201,6 +201,8 @@ void pn_connection_free(pn_connection_t 
   free(connection->sessions);
   free(connection->container);
   free(connection->hostname);
+  pn_data_free(connection->offered_capabilities);
+  pn_data_free(connection->desired_capabilities);
   pn_endpoint_tini(&connection->endpoint);
   free(connection);
 }
@@ -241,6 +243,8 @@ void pn_transport_free(pn_transport_t *t
   }
   free(transport->remote_container);
   free(transport->remote_hostname);
+  pn_data_free(transport->remote_offered_capabilities);
+  pn_data_free(transport->remote_desired_capabilities);
   pn_error_free(transport->error);
   free(transport->sessions);
   free(transport->channels);
@@ -434,6 +438,8 @@ pn_connection_t *pn_connection()
   conn->tpwork_tail = NULL;
   conn->container = NULL;
   conn->hostname = NULL;
+  conn->offered_capabilities = pn_data(16);
+  conn->desired_capabilities = pn_data(16);
 
   return conn;
 }
@@ -472,6 +478,28 @@ void pn_connection_set_hostname(pn_conne
   connection->hostname = pn_strdup(hostname);
 }
 
+pn_data_t *pn_connection_offered_capabilities(pn_connection_t *connection)
+{
+  return connection->offered_capabilities;
+}
+
+pn_data_t *pn_connection_desired_capabilities(pn_connection_t *connection)
+{
+  return connection->desired_capabilities;
+}
+
+pn_data_t *pn_connection_remote_offered_capabilities(pn_connection_t *connection)
+{
+  if (!connection) return NULL;
+  return connection->transport ? connection->transport->remote_offered_capabilities
: NULL;
+}
+
+pn_data_t *pn_connection_remote_desired_capabilities(pn_connection_t *connection)
+{
+  if (!connection) return NULL;
+  return connection->transport ? connection->transport->remote_desired_capabilities
: NULL;
+}
+
 const char *pn_connection_remote_container(pn_connection_t *connection)
 {
   if (!connection) return NULL;
@@ -752,6 +780,8 @@ void pn_transport_init(pn_transport_t *t
   transport->close_rcvd = false;
   transport->remote_container = NULL;
   transport->remote_hostname = NULL;
+  transport->remote_offered_capabilities = pn_data(16);
+  transport->remote_desired_capabilities = pn_data(16);
   transport->error = pn_error();
 
   transport->sessions = NULL;
@@ -1308,8 +1338,12 @@ int pn_do_open(pn_dispatcher_t *disp)
   pn_connection_t *conn = transport->connection;
   bool container_q, hostname_q;
   pn_bytes_t remote_container, remote_hostname;
-  int err = pn_scan_args(disp, "D.[?S?S]", &container_q, &remote_container,
-                         &hostname_q, &remote_hostname);
+  pn_data_clear(transport->remote_offered_capabilities);
+  pn_data_clear(transport->remote_desired_capabilities);
+  int err = pn_scan_args(disp, "D.[?S?S.....CC]", &container_q,
+                         &remote_container, &hostname_q, &remote_hostname,
+                         transport->remote_offered_capabilities,
+                         transport->remote_desired_capabilities);
   if (err) return err;
   if (container_q) {
     transport->remote_container = pn_bytes_strdup(remote_container);
@@ -1823,7 +1857,11 @@ int pn_process_conn_setup(pn_transport_t
     if (!(endpoint->state & PN_LOCAL_UNINIT) && !transport->open_sent)
     {
       pn_connection_t *connection = (pn_connection_t *) endpoint;
-      int err = pn_post_frame(transport->disp, 0, "DL[SS]", OPEN, connection->container,
connection->hostname);
+      int err = pn_post_frame(transport->disp, 0, "DL[SSnnnnnCC]", OPEN,
+                              connection->container,
+                              connection->hostname,
+                              connection->offered_capabilities,
+                              connection->desired_capabilities);
       if (err) return err;
       transport->open_sent = true;
     }

Modified: qpid/proton/trunk/proton-j/src/main/scripts/proton.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/scripts/proton.py?rev=1397215&r1=1397214&r2=1397215&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/src/main/scripts/proton.py (original)
+++ qpid/proton/trunk/proton-j/src/main/scripts/proton.py Thu Oct 11 18:14:14 2012
@@ -139,6 +139,9 @@ class Connection(Endpoint):
       self.impl.setRemoteHostname(hostname)
   remote_hostname = property(_get_remote_hostname, _set_remote_hostname)
 
+  @property
+  def offered_capabilities(self):
+    return DataDummy()
 
 
 def wrap_session(impl):

Modified: qpid/proton/trunk/tests/proton_tests/engine.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/tests/proton_tests/engine.py?rev=1397215&r1=1397214&r2=1397215&view=diff
==============================================================================
--- qpid/proton/trunk/tests/proton_tests/engine.py (original)
+++ qpid/proton/trunk/tests/proton_tests/engine.py Thu Oct 11 18:14:14 2012
@@ -142,6 +142,31 @@ class ConnectionTest(Test):
     assert self.c1.state == Endpoint.LOCAL_CLOSED | Endpoint.REMOTE_CLOSED
     assert self.c2.state == Endpoint.LOCAL_CLOSED | Endpoint.REMOTE_CLOSED
 
+  def test_capabilities(self):
+    self.c1.offered_capabilities.put_array(False, Data.SYMBOL)
+    self.c1.offered_capabilities.enter()
+    self.c1.offered_capabilities.put_symbol("O_one")
+    self.c1.offered_capabilities.put_symbol("O_two")
+    self.c1.offered_capabilities.put_symbol("O_three")
+    self.c1.offered_capabilities.exit()
+
+    self.c1.desired_capabilities.put_array(False, Data.SYMBOL)
+    self.c1.desired_capabilities.enter()
+    self.c1.desired_capabilities.put_symbol("D_one")
+    self.c1.desired_capabilities.put_symbol("D_two")
+    self.c1.desired_capabilities.put_symbol("D_three")
+    self.c1.desired_capabilities.exit()
+
+    self.c1.open()
+
+    assert self.c2.remote_offered_capabilities.format() == ""
+    assert self.c2.remote_desired_capabilities.format() == ""
+
+    self.pump()
+
+    assert self.c2.remote_offered_capabilities.format() == self.c1.offered_capabilities.format()
+    assert self.c2.remote_desired_capabilities.format() == self.c1.desired_capabilities.format()
+
 class SessionTest(Test):
 
   def setup(self):



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message