qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r1343864 - /qpid/proton/trunk/proton-j/jproton.py
Date Tue, 29 May 2012 17:29:47 GMT
Author: rhs
Date: Tue May 29 17:29:47 2012
New Revision: 1343864

URL: http://svn.apache.org/viewvc?rev=1343864&view=rev
Log:
filled in more shim

Modified:
    qpid/proton/trunk/proton-j/jproton.py

Modified: qpid/proton/trunk/proton-j/jproton.py
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/jproton.py?rev=1343864&r1=1343863&r2=1343864&view=diff
==============================================================================
--- qpid/proton/trunk/proton-j/jproton.py (original)
+++ qpid/proton/trunk/proton-j/jproton.py Tue May 29 17:29:47 2012
@@ -19,18 +19,80 @@
 
 from org.apache.qpid.proton.engine import *
 from jarray import zeros
+from java.util import EnumSet
 
 PN_EOS = Transport.END_OF_STREAM
 
+PN_LOCAL_UNINIT = 1
+PN_LOCAL_ACTIVE = 2
+PN_LOCAL_CLOSED = 4
+PN_REMOTE_UNINIT = 8
+PN_REMOTE_ACTIVE = 16
+PN_REMOTE_CLOSED = 32
+
+def enums(mask):
+  local = []
+  if (PN_LOCAL_UNINIT | mask):
+    local.append(EndpointState.UNINITIALIZED)
+  if (PN_LOCAL_ACTIVE | mask):
+    local.append(EndpointState.ACTIVE)
+  if (PN_LOCAL_CLOSED | mask):
+    local.append(EndpointState.CLOSED)
+
+  remote = []
+  if (PN_REMOTE_UNINIT | mask):
+    remote.append(EndpointState.UNINITIALIZED)
+  if (PN_REMOTE_ACTIVE | mask):
+    remote.append(EndpointState.ACTIVE)
+  if (PN_REMOTE_CLOSED | mask):
+    remote.append(EndpointState.CLOSED)
+
+  return EnumSet.of(*local), EnumSet.of(*remote)
+
+def state(endpoint):
+  local = endpoint.getLocalState()
+  remote = endpoint.getRemoteState()
+
+  result = 0
+
+  if (local == EndpointState.UNINITIALIZED):
+    result = result | PN_LOCAL_UNINIT
+  elif (local == EndpointState.ACTIVE):
+    result = result | PN_LOCAL_ACTIVE
+  elif (local == EndpointState.CLOSED):
+    result = result | PN_LOCAL_CLOSED
+
+  if (remote == EndpointState.UNINITIALIZED):
+    result = result | PN_REMOTE_UNINIT
+  elif (remote == EndpointState.ACTIVE):
+    result = result | PN_REMOTE_ACTIVE
+  elif (remote == EndpointState.CLOSED):
+    result = result | PN_REMOTE_CLOSED
+
+  return result
+
+
 def pn_connection():
   return impl.ConnectionImpl()
 
+def pn_connection_state(c):
+  return state(c)
+
 def pn_connection_open(c):
   return c.open()
 
+def pn_connection_close(c):
+  return c.close()
+
+def pn_connection_destroy(c):
+  pass
+
 def pn_session(c):
   return c.session()
 
+def pn_session_state(s):
+  return state(s)
+
 def pn_session_open(s):
   return s.open()
 
@@ -47,3 +109,7 @@ def pn_output(t, size):
 
 def pn_input(t, inp):
   return t.input(inp, 0, len(inp))
+
+def pn_session_head(c, mask):
+  local, remote = enums(mask)
+  return c.sessionHead(local, remote)



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


Mime
View raw message