qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fad...@apache.org
Subject svn commit: r1553874 [1/2] - in /qpid/proton/branches/fadams-javascript-binding: examples/messenger/py/ proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/ proton-c/bindings/java/src/main/java/org/apache/qpid/proton/messenger/jni/ p...
Date Sat, 28 Dec 2013 16:58:27 GMT
Author: fadams
Date: Sat Dec 28 16:58:25 2013
New Revision: 1553874

URL: http://svn.apache.org/r1553874
Log:
pull in latest updates from trunk to avoid diverging too much

Added:
    qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/async.py   (with props)
    qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/recv_async.py   (with props)
    qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/send_async.py   (with props)
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Errors.pm
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Tracker.pm
Removed:
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/ChangeLog
Modified:
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIDelivery.java
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNILink.java
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIReceiver.java
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/messenger/jni/JNIMessenger.java
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/MANIFEST
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Constants.pm
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid_proton.pm
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/proton.py
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/CMakeLists.txt
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/exception_handling.rb
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb
    qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/tracker_status.rb
    qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/codec.h
    qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/engine.h
    qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/error.h
    qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/messenger.h
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/codec.c
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.c
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.h
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/engine/engine-internal.h
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.c
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.h
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/store.c
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/subscription.c
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/subscription.h
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/posix/driver.c
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/sasl/sasl.c
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/transport/transport.c
    qpid/proton/branches/fadams-javascript-binding/proton-c/src/windows/driver.c
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/driver/Driver.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/engine/Delivery.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/engine/Link.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/engine/Receiver.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/messenger/Messenger.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton-api/src/main/java/org/apache/qpid/proton/messenger/Status.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton-api/src/main/resources/proton.py
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/driver/impl/DriverImpl.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/DeliveryImpl.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/engine/impl/ReceiverImpl.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/messenger/impl/MessengerImpl.java
    qpid/proton/branches/fadams-javascript-binding/proton-j/proton/src/main/java/org/apache/qpid/proton/messenger/impl/StoreEntry.java
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/engine.py
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/messenger.py
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/sasl.py
    qpid/proton/branches/fadams-javascript-binding/tests/python/proton_tests/ssl.py

Added: qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/async.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/async.py?rev=1553874&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/async.py (added)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/async.py Sat Dec 28 16:58:25 2013
@@ -0,0 +1,81 @@
+#!/usr/bin/python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import sys
+from proton import *
+
+class CallbackAdapter:
+
+    def __init__(self, messenger):
+        self.messenger = messenger
+        self.messenger.blocking = False
+        self.messenger.outgoing_window = 1024
+        self.messenger.incoming_window = 1024
+        # for application use
+        self.message = Message()
+        self._incoming_message = Message()
+        self.tracked = {}
+
+    def run(self):
+        self.running = True
+        self.messenger.start()
+        self.on_start()
+
+        while self.running:
+            self.messenger.work()
+            self._process()
+
+        self.messenger.stop()
+
+        while not self.messenger.stopped:
+            self.messenger.work()
+            self._process()
+
+        self.on_stop()
+
+    def stop(self):
+        self.running = False
+
+    def _process(self):
+        self._process_outgoing()
+        self._process_incoming()
+
+    def _process_outgoing(self):
+        for t, on_status in self.tracked.items():
+            status = self.messenger.status(t)
+            if status != PENDING:
+                on_status(status)
+                self.messenger.settle(t)
+                del self.tracked[t]
+
+    def _process_incoming(self):
+        while self.messenger.incoming:
+            t = self.messenger.get(self._incoming_message)
+            try:
+                self.on_recv(self._incoming_message)
+                self.messenger.accept(t)
+            except:
+                ex = sys.exc_info()[1]
+                print "Exception:", ex
+                self.messenger.reject(t)
+
+    def send(self, message, on_status=None):
+        t = self.messenger.put(message)
+        if on_status:
+            self.tracked[t] = on_status

Propchange: qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/async.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/async.py
------------------------------------------------------------------------------
    svn:executable = *

Added: qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/recv_async.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/recv_async.py?rev=1553874&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/recv_async.py (added)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/recv_async.py Sat Dec 28 16:58:25 2013
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import sys, optparse
+from async import *
+
+parser = optparse.OptionParser(usage="usage: %prog [options] <addr_1> ... <addr_n>",
+                               description="simple message receiver")
+
+opts, args = parser.parse_args()
+
+if not args:
+  args = ["amqp://~0.0.0.0"]
+
+class App(CallbackAdapter):
+
+    def on_start(self):
+        print "Started"
+        for a in args:
+            print "Subscribing to:", a
+            self.messenger.subscribe(a)
+        self.messenger.recv()
+
+    def on_recv(self, msg):
+        print "Received:", msg
+        if msg.body == "die":
+            self.stop()
+        if msg.reply_to:
+            self.message.clear()
+            self.message.address = msg.reply_to
+            self.message.body = "Reply for: %s" % msg.body
+            print "Replied:", self.message
+            self.send(self.message)
+
+    def on_stop(self):
+        print "Stopped"
+
+a = App(Messenger())
+a.run()

Propchange: qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/recv_async.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/recv_async.py
------------------------------------------------------------------------------
    svn:executable = *

Added: qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/send_async.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/send_async.py?rev=1553874&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/send_async.py (added)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/send_async.py Sat Dec 28 16:58:25 2013
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import sys, optparse
+from async import *
+
+parser = optparse.OptionParser(usage="usage: %prog [options] <msg_1> ... <msg_n>",
+                               description="simple message sender")
+parser.add_option("-a", "--address", default="amqp://0.0.0.0",
+                  help="address: //<domain>[/<name>] (default %default)")
+parser.add_option("-r", "--reply_to", help="reply_to: //<domain>[/<name>]")
+
+opts, args = parser.parse_args()
+if not args:
+  args = ["Hello World!"]
+
+class App(CallbackAdapter):
+
+    def on_start(self):
+        print "Started"
+        self.message.clear()
+        self.message.address = opts.address
+        self.message.reply_to = opts.reply_to
+        for a in args:
+            print "Sending:", a
+            self.message.body = a
+            self.send(self.message, self.on_status)
+
+        if opts.reply_to:
+            self.messenger.recv()
+
+    def on_status(self, status):
+        print "Status:", status
+        if not opts.reply_to or opts.reply_to[0] != "~":
+            args.pop(0)
+            if not args: self.stop()
+
+    def on_recv(self, msg):
+        print "Received:", msg
+        if opts.reply_to and opts.reply_to[0] == "~":
+            args.pop(0)
+            if not args: self.stop()
+
+    def on_stop(self):
+        print "Stopped"
+
+a = App(Messenger())
+a.run()

Propchange: qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/send_async.py
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: qpid/proton/branches/fadams-javascript-binding/examples/messenger/py/send_async.py
------------------------------------------------------------------------------
    svn:executable = *

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIDelivery.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIDelivery.java?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIDelivery.java (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIDelivery.java Sat Dec 28 16:58:25 2013
@@ -266,4 +266,9 @@ public class JNIDelivery implements Deli
         return (int) Proton.pn_delivery_pending(_impl);
     }
 
+    @ProtonCEquivalent("pn_delivery_buffered")
+    public boolean isBuffered()
+    {
+        return Proton.pn_delivery_buffered(_impl);
+    }
 }

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNILink.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNILink.java?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNILink.java (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNILink.java Sat Dec 28 16:58:25 2013
@@ -538,4 +538,17 @@ abstract class JNILink implements Link
         return Proton.pn_link_drained(getImpl());
     }
 
+    @Override
+    @ProtonCEquivalent("pn_link_remote_credit")
+    public int getRemoteCredit()
+    {
+        return Proton.pn_link_remote_credit(getImpl());
+    }
+
+    @Override
+    @ProtonCEquivalent("pn_link_get_drain")
+    public boolean getDrain()
+    {
+        return Proton.pn_link_get_drain(getImpl());
+    }
 }

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIReceiver.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIReceiver.java?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIReceiver.java (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/engine/jni/JNIReceiver.java Sat Dec 28 16:58:25 2013
@@ -62,4 +62,10 @@ public class JNIReceiver extends JNILink
         return Proton.pn_link_draining(getImpl());
     }
 
+    @Override
+    @ProtonCEquivalent("pn_link_set_drain")
+    public void setDrain(boolean drain)
+    {
+        Proton.pn_link_set_drain(getImpl(), drain);
+    }
 }

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/messenger/jni/JNIMessenger.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/messenger/jni/JNIMessenger.java?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/messenger/jni/JNIMessenger.java (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/java/src/main/java/org/apache/qpid/proton/messenger/jni/JNIMessenger.java Sat Dec 28 16:58:25 2013
@@ -113,6 +113,12 @@ class JNIMessenger implements Messenger
     }
 
     @Override
+    public int receiving()
+    {
+        return Proton.pn_messenger_receiving(_impl);
+    }
+
+    @Override
     public Message get()
     {
         SWIGTYPE_p_pn_message_t msg = Proton.pn_message();
@@ -271,6 +277,14 @@ class JNIMessenger implements Messenger
         {
             return Status.REJECTED;
         }
+        else if (status == pn_status_t.PN_STATUS_RELEASED)
+        {
+            return Status.RELEASED;
+        }
+        else if (status == pn_status_t.PN_STATUS_SETTLED)
+        {
+            return Status.SETTLED;
+        }
         else if(status == pn_status_t.PN_STATUS_UNKNOWN)
         {
             return Status.UNKNOWN;
@@ -295,7 +309,7 @@ class JNIMessenger implements Messenger
 
     private void check(int errorCode) throws ProtonException
     {
-        if(errorCode != 0 && errorCode != Proton.PN_INPROGRESS)
+        if(errorCode < 0 && errorCode != Proton.PN_INPROGRESS)
         {
             String errorMessage = Proton.pn_error_text(Proton.pn_messenger_error(_impl));
             if(errorCode == Proton.PN_TIMEOUT)

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/MANIFEST
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/MANIFEST?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/MANIFEST (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/MANIFEST Sat Dec 28 16:58:25 2013
@@ -1,4 +1,3 @@
-ChangeLog
 CMakeLists.txt
 lib/qpid/proton/Message.pm
 lib/qpid/proton/Messenger.pm

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Constants.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Constants.pm?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Constants.pm (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Constants.pm Sat Dec 28 16:58:25 2013
@@ -138,4 +138,30 @@ use constant {
         "get_map_helper"),
 };
 
+package qpid::proton::Errors;
+
+use constant {
+    NONE => 0,
+    EOS => $cproton_perl::PN_EOS,
+    ERROR => $cproton_perl::PN_ERR,
+    OVERFLOW => $cproton_perl::PN_OVERFLOW,
+    UNDERFLOW => $cproton_perl::PN_UNDERFLOW,
+    STATE => $cproton_perl::PN_STATE_ERR,
+    ARGUMENT => $cproton_perl::PN_ARG_ERR,
+    TIMEOUT => $cproton_perl::PN_TIMEOUT,
+    INTERRUPTED => $cproton_perl::PN_INTR,
+    INPROGRESS => $cproton_perl::PN_INPROGRESS,
+};
+
+package qpid::proton::Tracker;
+
+use constant {
+    ABORTED => $cproton_perl::PN_STATUS_ABORTED,
+    ACCEPTED => $cproton_perl::PN_STATUS_ACCEPTED,
+    REJECTED => $cproton_perl::PN_STATUS_REJECTED,
+    PENDING => $cproton_perl::PN_STATUS_PENDING,
+    SETTLED => $cproton_perl::PN_STATUS_SETTLED,
+    UNKNOWN => undef,
+};
+
 1;

Added: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Errors.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Errors.pm?rev=1553874&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Errors.pm (added)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Errors.pm Sat Dec 28 16:58:25 2013
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+use strict;
+use warnings;
+use cproton_perl;
+
+package qpid::proton::Errors;
+
+

Added: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm?rev=1553874&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm (added)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/ExceptionHandling.pm Sat Dec 28 16:58:25 2013
@@ -0,0 +1,36 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+use strict;
+use warnings;
+use cproton_perl;
+
+package qpid::proton;
+
+sub check_for_error {
+    my $rc = $_[0];
+
+    if($rc < 0) {
+        my $source = $_[1];
+
+        die "ERROR[$rc] " . $source->get_error();
+    }
+}
+
+1;

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Messenger.pm Sat Dec 28 16:58:25 2013
@@ -67,7 +67,7 @@ sub set_outgoing_window {
     $window = 0 if !defined($window);
     $window = int($window);
 
-    cproton_perl::pn_messenger_set_outgoing_window($self->{_impl}, $window);
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_set_outgoing_window($self->{_impl}, $window), $self);
 }
 
 sub get_outgoing_window {
@@ -75,14 +75,14 @@ sub get_outgoing_window {
     return cproton_perl::pn_messenger_get_outgoing_window($self->{_impl});
 }
 
-sub set_incoming_window {
+sub set_incoming_window{
     my ($self) = @_;
     my $window = $_[1];
 
     $window = 0 if !defined($window);
     $window = int($window);
 
-    cproton_perl::pn_messenger_set_incoming_window($self->{_impl}, $window);
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_set_incoming_window($self->{_impl}, $window), $self);
 }
 
 sub get_incoming_window {
@@ -102,12 +102,12 @@ sub get_errno {
 
 sub start {
     my ($self) = @_;
-    cproton_perl::pn_messenger_start($self->{_impl});
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_start($self->{_impl}), $self);
 }
 
 sub stop {
     my ($self) = @_;
-    cproton_perl::pn_messenger_stop($self->{_impl});
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_stop($self->{_impl}), $self);
 }
 
 sub subscribe {
@@ -138,7 +138,7 @@ sub get_private_key {
 sub set_password {
     my ($self) = @_;
 
-    cproton_perl::pn_messenger_set_password($self->{_impl}, $_[1]);
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_set_password($self->{_impl}, $_[1]), $self);
 }
 
 sub get_password {
@@ -163,16 +163,29 @@ sub put {
 
     $message->preencode();
     my $msgimpl = $message->get_impl();
-    cproton_perl::pn_messenger_put($impl, $msgimpl);
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_put($impl, $msgimpl), $self);
 
-    return cproton_perl::pn_messenger_outgoing_tracker($impl);
+    my $tracker = $self->get_outgoing_tracker();
+    return $tracker;
+}
+
+sub get_outgoing_tracker {
+    my ($self) = @_;
+    my $impl = $self->{_impl};
+
+    my $tracker = cproton_perl::pn_messenger_outgoing_tracker($impl);
+    if ($tracker != -1) {
+        return qpid::proton::Tracker->new($tracker);
+    } else {
+        return undef;
+    }
 }
 
 sub send {
     my ($self) = @_;
     my $n = $_[1];
     $n = -1 if !defined $n;
-    cproton_perl::pn_messenger_send($self->{_impl}, $n);
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_send($self->{_impl}, $n), $self);
 }
 
 sub get {
@@ -180,23 +193,36 @@ sub get {
     my $impl = $self->{_impl};
     my $message = $_[1] || new proton::Message();
 
-    cproton_perl::pn_messenger_get($impl, $message->get_impl());
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_get($impl, $message->get_impl()), $self);
     $message->postdecode();
 
-    return cproton_perl::pn_messenger_incoming_tracker($impl);
+    my $tracker = $self->get_incoming_tracker();
+    return $tracker;
+}
+
+sub get_incoming_tracker {
+    my ($self) = @_;
+    my $impl = $self->{_impl};
+
+    my $tracker = cproton_perl::pn_messenger_incoming_tracker($impl);
+    if ($tracker != -1) {
+        return qpid::proton::Tracker->new($tracker);
+    } else {
+        return undef;
+    }
 }
 
 sub receive {
     my ($self) = @_;
     my $n = $_[1];
     $n = -1 if !defined $n;
-    cproton_perl::pn_messenger_recv($self->{_impl}, $n);
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_recv($self->{_impl}, $n), $self);
 }
 
 sub interrupt {
     my ($self) = @_;
 
-    return cproton_perl::pn_messenger_interrupt($self->{_impl});
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_interrupt($self->{_impl}), $self);
 }
 
 sub outgoing {
@@ -209,6 +235,24 @@ sub incoming {
     return cproton_perl::pn_messenger_incoming($self->{_impl});
 }
 
+sub route {
+    my ($self) = @_;
+    my $impl = $self->{_impl};
+    my $pattern = $_[1];
+    my $address = $_[2];
+
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_route($impl, $pattern, $address));
+}
+
+sub rewrite {
+    my ($self) = @_;
+    my $impl = $self->{_impl};
+    my $pattern = $_[1];
+    my $address = $_[2];
+
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_rewrite($impl, $pattern, $address));
+}
+
 sub accept {
     my ($self) = @_;
     my $tracker = $_[1];
@@ -217,7 +261,7 @@ sub accept {
         $tracker = cproton_perl::pn_messenger_incoming_tracker($self->{_impl});
         $flags = $cproton_perl::PN_CUMULATIVE;
     }
-    return cproton_perl::pn_messenger_accept($self->{_impl}, $tracker, $flags);
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_accept($self->{_impl}, $tracker, $flags), $self);
 }
 
 sub reject {
@@ -228,7 +272,7 @@ sub reject {
         $tracker = cproton_perl::pn_messenger_incoming_tracker($self->{_impl});
         $flags = $cproton_perl::PN_CUMULATIVE;
     }
-    return cproton_perl::pn_messenger_reject($self->{_impl}, $tracker, $flags);
+    qpid::proton::check_for_error(cproton_perl::pn_messenger_reject($self->{_impl}, $tracker, $flags), $self);
 }
 
 sub status {

Added: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Tracker.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Tracker.pm?rev=1553874&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Tracker.pm (added)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Tracker.pm Sat Dec 28 16:58:25 2013
@@ -0,0 +1,43 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+use strict;
+use warnings;
+use cproton_perl;
+
+package qpid::proton::Tracker;
+
+sub new {
+    my ($class) = @_;
+    my ($self) = {};
+
+    $self->{_impl} = $_[1];
+
+    bless $self, $class;
+    return $self;
+}
+
+sub get_impl {
+    my ($self) = @_;
+
+
+    return $self->{_impl};
+}
+
+1;

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid_proton.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid_proton.pm?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid_proton.pm (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid_proton.pm Sat Dec 28 16:58:25 2013
@@ -21,9 +21,11 @@ use strict;
 use warnings;
 use cproton_perl;
 
+use qpid::proton::ExceptionHandling;
 use qpid::proton::Data;
 use qpid::proton::Mapping;
 use qpid::proton::Constants;
+use qpid::proton::Tracker;
 use qpid::proton::Messenger;
 use qpid::proton::Message;
 

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/proton.py
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/proton.py?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/proton.py (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/python/proton.py Sat Dec 28 16:58:25 2013
@@ -42,7 +42,7 @@ except ImportError:
     class UUID:
       def __init__(self, hex=None, bytes=None):
         if [hex, bytes].count(None) != 1:
-          raise TypeErrror("need one of hex or bytes")
+          raise TypeError("need one of hex or bytes")
         if bytes is not None:
           self.bytes = bytes
         elif hex is not None:
@@ -142,13 +142,17 @@ EXCEPTIONS = {
 PENDING = Constant("PENDING")
 ACCEPTED = Constant("ACCEPTED")
 REJECTED = Constant("REJECTED")
+RELEASED = Constant("RELEASED")
 ABORTED = Constant("ABORTED")
+SETTLED = Constant("SETTLED")
 
 STATUSES = {
   PN_STATUS_ABORTED: ABORTED,
   PN_STATUS_ACCEPTED: ACCEPTED,
   PN_STATUS_REJECTED: REJECTED,
+  PN_STATUS_RELEASED: RELEASED,
   PN_STATUS_PENDING: PENDING,
+  PN_STATUS_SETTLED: SETTLED,
   PN_STATUS_UNKNOWN: None
   }
 
@@ -443,6 +447,7 @@ first message.
     sub_impl = pn_messenger_subscribe(self._mng, source)
     if not sub_impl:
       self._check(PN_ERR)
+    return Subscription(sub_impl)
 
   def put(self, message):
     """
@@ -482,6 +487,18 @@ first message.
     disp = pn_messenger_status(self._mng, tracker);
     return STATUSES.get(disp, disp)
 
+  def buffered(self, tracker):
+    """
+    Checks if the delivery associated with the given tracker is still
+    waiting to be sent.
+
+    @type tracker: tracker
+    @param tracker: the tracker whose status is to be retrieved
+
+    @return true if delivery is still buffered
+    """
+    return pn_messenger_buffered(self._mng, tracker);
+
   def settle(self, tracker=None):
     """
     Frees a L{Messenger} from tracking the status associated with a given
@@ -1073,6 +1090,15 @@ The format of the message.
     self._check(err)
     return result
 
+class Subscription(object):
+
+  def __init__(self, impl):
+    self._impl = impl
+
+  @property
+  def address(self):
+    return pn_subscription_address(self._impl)
+
 class DataException(ProtonException):
   """
   The DataException class is the root of the Data exception hierarchy.
@@ -1271,7 +1297,7 @@ class Data:
   def _check(self, err):
     if err < 0:
       exc = EXCEPTIONS.get(err, DataException)
-      raise exc("[%s]: %s" % (err, pn_data_error(self._data)))
+      raise exc("[%s]: %s" % (err, pn_error_text(pn_data_error(self._data))))
     else:
       return err
 
@@ -1694,7 +1720,7 @@ class Data:
     """
     Checks if the current node is a null.
     """
-    self._check(pn_data_get_null(self._data))
+    return pn_data_is_null(self._data)
 
   def get_bool(self):
     """
@@ -2041,6 +2067,13 @@ class Endpoint(object):
   def remote_condition(self):
     return cond2obj(self._get_remote_cond_impl())
 
+  # the following must be provided by subclasses
+  def _get_cond_impl(self):
+      assert False, "Subclass must override this!"
+
+  def _get_remote_cond_impl(self):
+      assert False, "Subclass must override this!"
+
 class Condition:
 
   def __init__(self, name, description=None, info=None):
@@ -2177,10 +2210,6 @@ class Connection(Endpoint):
   def state(self):
     return pn_connection_state(self._conn)
 
-  @property
-  def writable(self):
-    return pn_connection_writable(self._conn)
-
   def session(self):
     return wrap_session(pn_session(self._conn))
 
@@ -2375,6 +2404,10 @@ class Link(Endpoint):
     return wrap_link(pn_link_next(self._link, mask))
 
   @property
+  def name(self):
+      return pn_link_name(self._link)
+
+  @property
   def is_sender(self):
     return pn_link_is_sender(self._link)
 
@@ -2687,11 +2720,22 @@ class Transport(object):
     else:
       self._shared_trans = True
       self._trans = _trans
+    self._sasl = None
+    self._ssl = None
 
   def __del__(self):
     if hasattr(self, "_trans"):
       if not hasattr(self, "_shared_trans"):
         pn_transport_free(self._trans)
+        if hasattr(self, "_sasl") and self._sasl:
+            # pn_transport_free deallocs the C sasl associated with the
+            # transport, so erase the reference if a SASL object was used.
+            self._sasl._sasl = None
+            self._sasl = None
+        if hasattr(self, "_ssl") and self._ssl:
+            # ditto the owned c SSL object
+            self._ssl._ssl = None
+            self._ssl = None
       del self._trans
 
   def _check(self, err):
@@ -2708,7 +2752,11 @@ class Transport(object):
     pn_transport_trace(self._trans, n)
 
   def tick(self, now):
-    return pn_transport_tick(self._trans, now)
+    """Process any timed events (like heartbeat generation).
+    now = seconds since epoch (float).
+    """
+    next = pn_transport_tick(self._trans, long(now * 1000))
+    return float(next) / 1000.0
 
   def capacity(self):
     c = pn_transport_capacity(self._trans)
@@ -2783,10 +2831,11 @@ Sets the maximum size for received frame
 
   # AMQP 1.0 idle-time-out
   def _get_idle_timeout(self):
-    return pn_transport_get_idle_timeout(self._trans)
+    msec = pn_transport_get_idle_timeout(self._trans)
+    return float(msec)/1000.0
 
-  def _set_idle_timeout(self, value):
-    pn_transport_set_idle_timeout(self._trans, value)
+  def _set_idle_timeout(self, sec):
+    pn_transport_set_idle_timeout(self._trans, long(sec * 1000))
 
   idle_timeout = property(_get_idle_timeout, _set_idle_timeout,
                           doc="""
@@ -2795,7 +2844,8 @@ The idle timeout of the connection (in m
 
   @property
   def remote_idle_timeout(self):
-    return pn_transport_get_remote_idle_timeout(self._trans)
+    msec = pn_transport_get_remote_idle_timeout(self._trans)
+    return float(msec)/1000.0
 
   @property
   def frames_output(self):
@@ -2805,6 +2855,18 @@ The idle timeout of the connection (in m
   def frames_input(self):
     return pn_transport_get_frames_input(self._trans)
 
+  def sasl(self):
+    # SASL factory (singleton for this transport)
+    if not self._sasl:
+      self._sasl = SASL(self)
+    return self._sasl
+
+  def ssl(self, domain=None, session_details=None):
+    # SSL factory (singleton for this transport)
+    if not self._ssl:
+      self._ssl = SSL(self, domain, session_details)
+    return self._ssl
+
 class SASLException(TransportException):
   pass
 
@@ -2813,8 +2875,13 @@ class SASL(object):
   OK = PN_SASL_OK
   AUTH = PN_SASL_AUTH
 
-  def __init__(self, transport):
-    self._sasl = pn_sasl(transport._trans)
+  def __new__(cls, transport):
+    """Enforce a singleton SASL object per Transport"""
+    if not transport._sasl:
+      obj = super(SASL, cls).__new__(cls)
+      obj._sasl = pn_sasl(transport._trans)
+      transport._sasl = obj
+    return transport._sasl
 
   def _check(self, err):
     if err < 0:
@@ -2923,14 +2990,29 @@ class SSL(object):
     else:
       return err
 
-  def __init__(self, transport, domain, session_details=None):
-    session_id = None
-    if session_details:
-      session_id = session_details.get_session_id()
-    self._ssl = pn_ssl( transport._trans )
-    if self._ssl is None:
-      raise SSLUnavailable()
-    pn_ssl_init( self._ssl, domain._domain, session_id )
+  def __new__(cls, transport, domain, session_details=None):
+    """Enforce a singleton SSL object per Transport"""
+    if transport._ssl:
+      # unfortunately, we've combined the allocation and the configuration in a
+      # single step.  So catch any attempt by the application to provide what
+      # may be a different configuration than the original (hack)
+      ssl = transport._ssl
+      if (domain and (ssl._domain is not domain) or
+          session_details and (ssl._session_details is not session_details)):
+        raise SSLException("Cannot re-configure existing SSL object!")
+    else:
+      obj = super(SSL, cls).__new__(cls)
+      obj._domain = domain
+      obj._session_details = session_details
+      session_id = None
+      if session_details:
+        session_id = session_details.get_session_id()
+      obj._ssl = pn_ssl( transport._trans )
+      if obj._ssl is None:
+        raise SSLUnavailable()
+      pn_ssl_init( obj._ssl, domain._domain, session_id )
+      transport._ssl = obj
+    return transport._ssl
 
   def cipher_name(self):
     rc, name = pn_ssl_get_cipher_name( self._ssl, 128 )
@@ -3070,8 +3152,12 @@ class Driver(object):
       pn_driver_free(self._driver)
       del self._driver
 
-  def wait(self, timeout):
-    return pn_driver_wait(self._driver, timeout)
+  def wait(self, timeout_sec):
+    if timeout_sec is None or timeout_sec < 0.0:
+      t = -1
+    else:
+      t = long(1000*timeout_sec)
+    return pn_driver_wait(self._driver, t)
 
   def wakeup(self):
     return pn_driver_wakeup(self._driver)
@@ -3103,6 +3189,8 @@ __all__ = [
            "PENDING",
            "MANUAL",
            "REJECTED",
+           "RELEASED",
+           "SETTLED",
            "UNDESCRIBED",
            "Array",
            "Condition",
@@ -3130,6 +3218,7 @@ __all__ = [
            "SSLDomain",
            "SSLSessionDetails",
            "SSLUnavailable",
+           "SSLException",
            "Terminus",
            "Timeout",
            "Interrupt",

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/CMakeLists.txt?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/CMakeLists.txt Sat Dec 28 16:58:25 2013
@@ -51,13 +51,13 @@ set(RUBY_ARCHLIB_DIR "${RUBY_VENDORLIB_D
 
 if (NOT RUBY_ARCHLIB_DIR)
   execute_process(COMMAND ${RUBY_EXECUTABLE}
-                  -r rbconfig -e "print RbConfig::CONFIG['vendorlibdir']"
+                  -r rbconfig -e "print RbConfig::CONFIG['vendorarchdir'] || ''"
     RESULT_VARIABLE RESULT_RUBY_ARCHLIB_DIR
     OUTPUT_VARIABLE OUTPUT_RUBY_ARCHLIB_DIR)
 
-  if(NOT RESULT_RUBY_ARCHLIB_DIR AND OUTPUT_RUBY_ARCHLIB_DIR )
+  if(OUTPUT_RUBY_ARCHLIB_DIR STREQUAL "")
     execute_process(COMMAND ${RUBY_EXECUTABLE}
-                    -r rbconfig -e "print RbConfig::CONFIG['sitearchdir']"
+                    -r rbconfig -e "print RbConfig::CONFIG['sitearchdir'] || ''"
       RESULT_VARIABLE RESULT_RUBY_ARCHLIB_DIR
       OUTPUT_VARIABLE OUTPUT_RUBY_ARCHLIB_DIR)
 

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/exception_handling.rb
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/exception_handling.rb?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/exception_handling.rb (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/exception_handling.rb Sat Dec 28 16:58:25 2013
@@ -29,8 +29,11 @@ module Qpid
       #
       # Expects the class to provide an +error+ method.
       def check_for_error(code)
+
         raise ::ArgumentError.new("Invalid error code: #{code}") if code.nil?
 
+	return code if code > 0
+
         case(code)
 
         when Qpid::Proton::Error::NONE

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/messenger.rb Sat Dec 28 16:58:25 2013
@@ -21,10 +21,39 @@ module Qpid
 
   module Proton
 
-    # A +Messenger+ provides a high-level means for sending and
-    # receiving AMQP messages.
+    # The +Messenger+ class defines a high level interface for
+    # sending and receiving Messages. Every Messenger contains
+    # a single logical queue of incoming messages and a single
+    # logical queue of outgoing messages. These messages in these
+    # queues may be destined for, or originate from, a variety of
+    # addresses.
     #
-    # ==== Examples
+    # The messenger interface is single-threaded.  All methods
+    # except one ( #interrupt ) are intended to be used from within
+    # the messenger thread.
+    #
+    # === Sending & Receiving Messages
+    #
+    # The Messenger class works in conjuction with the Message class. The
+    # Message class is a mutable holder of message content.
+    # 
+    # The put method copies its Message to the outgoing queue, and may 
+    # send queued messages if it can do so without blocking.  The send
+    # method blocks until it has sent the requested number of messages,
+    # or until a timeout interrupts the attempt.
+    # 
+    # Similarly, the recv method receives messages into the incoming
+    # queue, and may block as it attempts to receive the requested number
+    # of messages,  or until timeout is reached. It may receive fewer
+    # than the requested number.  The get method pops the
+    # eldest Message off the incoming queue and copies it into the Message
+    # object that you supply.  It will not block.
+    # 
+    # The blocking attribute allows you to turn off blocking behavior entirely,
+    # in which case send and recv will do whatever they can without
+    # blocking, and then return.  You can then look at the number
+    # of incoming and outgoing messages to see how much outstanding work
+    # still remains.
     #
     class Messenger
 
@@ -92,6 +121,12 @@ module Qpid
         Cproton.pn_messenger_get_timeout(@impl)
       end
 
+      # Blocking Attribute
+      #
+      # Enable or disable blocking behavior during message sending
+      # and receiving.  This affects every blocking call, with the
+      # exception of work().  Currently, the affected calls are
+      # send, recv, and stop.
       def blocking
         Cproton.pn_mesenger_is_blocking(@impl)
       end
@@ -118,8 +153,9 @@ module Qpid
         Cproton.pn_error_text(Cproton.pn_messenger_error(@impl))
       end
 
-      # Starts the +Messenger+, allowing it to begin sending and
-      # receiving messages.
+      # Currently a no-op placeholder.
+      # For future compatibility, do not send or recv messages
+      # before starting the +Messenger+.
       #
       def start
         check_for_error(Cproton.pn_messenger_start(@impl))
@@ -132,11 +168,22 @@ module Qpid
         check_for_error(Cproton.pn_messenger_stop(@impl))
       end
 
+      # Returns true iff a Messenger is in the stopped state.
+      # This function does not block.
+      #
       def stopped
         Cproton.pn_messenger_stopped(@impl)
       end
 
-      # Subscribes the +Messenger+ to a remote address.
+      # Subscribes the Messenger to messages originating from the
+      # specified source. The source is an address as specified in the
+      # Messenger introduction with the following addition. If the
+      # domain portion of the address begins with the '~' character, the
+      # Messenger will interpret the domain as host/port, bind to it,
+      # and listen for incoming messages. For example "~0.0.0.0",
+      # "amqp://~0.0.0.0" will all bind to any local interface and 
+      # listen for incoming messages.  Ad address of # "amqps://~0.0.0.0" 
+      # will only permit incoming SSL connections.
       #
       def subscribe(address)
         raise TypeError.new("invalid address: #{address}") if address.nil?
@@ -148,7 +195,10 @@ module Qpid
       # Path to a certificate file for the +Messenger+.
       #
       # This certificate is used when the +Messenger+ accepts or establishes
-      # SSL/TLS connections.
+      # SSL/TLS connections.  This property must be specified for the
+      # Messenger to accept incoming SSL/TLS connections and to establish
+      # client authenticated outgoing SSL/TLS connection.  Non client authenticated
+      # outgoing SSL/TLS connections do not require this property.
       #
       # ==== Options
       #
@@ -168,7 +218,8 @@ module Qpid
       #
       # The property must be specified for the +Messenger+ to accept incoming
       # SSL/TLS connections and to establish client authenticated outgoing
-      # SSL/TLS connections.
+      # SSL/TLS connections.  Non client authenticated SSL/TLS connections
+      # do not require this property.
       #
       # ==== Options
       #
@@ -202,9 +253,15 @@ module Qpid
         Cproton.pn_messenger_get_trusted_certificates(@impl)
       end
 
-      # Puts a single message into the outgoing queue.
+      # Places the content contained in the message onto the outgoing
+      # queue of the Messenger.
       #
-      # To ensure messages are sent, you should then call ::send.
+      # This method will never block, however it will send any unblocked 
+      # Messages in the outgoing queue immediately and leave any blocked
+      # Messages remaining in the outgoing queue.
+      # The send call may then be used to block until the outgoing queue 
+      # is empty.  The outgoing attribute may be used to check the depth
+      # of the outgoing queue.
       #
       # ==== Options
       #
@@ -219,14 +276,22 @@ module Qpid
         return outgoing_tracker
       end
 
-      # Sends all outgoing messages, blocking until the outgoing queue
-      # is empty.
+      # This call will block until the indicated number of messages
+      # have been sent, or until the operation times out.
+      # If n is -1 this call will block until all outgoing messages 
+      # have been sent. If n is 0 then this call will send whatever 
+      # it can without blocking.
       #
       def send(n = -1)
         check_for_error(Cproton.pn_messenger_send(@impl, n))
       end
 
-      # Gets a single message incoming message from the local queue.
+      # Moves the message from the head of the incoming message queue into
+      # the supplied message object. Any content in the supplied message
+      # will be overwritten.
+      # A tracker for the incoming Message is returned.  The tracker can
+      # later be used to communicate your acceptance or rejection of the
+      # Message.
       #
       # If no message is provided in the argument, then one is created. In
       # either case, the one returned will be the fetched message.
@@ -247,8 +312,11 @@ module Qpid
         return incoming_tracker
       end
 
-      # Receives up to the specified number of messages, blocking until at least
-      # one message is received.
+      # Receives up to limit messages into the incoming queue.  If no value
+      # for limit is supplied, this call will receive as many messages as it
+      # can buffer internally.  If the Messenger is in blocking mode, this
+      # call will block until at least one Message is available in the
+      # incoming queue.
       #
       # Options ====
       #
@@ -278,6 +346,12 @@ module Qpid
         check_for_error(Cproton.pn_messenger_interrupt(@impl))
       end
 
+      # Sends or receives any outstanding messages queued for a Messenger.
+      #
+      # This will block for the indicated timeout.  This method may also do I/O
+      # other than sending and receiving messages.  For example, closing
+      # connections after stop() has been called.
+      # 
       def work(timeout=-1)
         err = Cproton.pn_messenger_work(@impl, timeout)
         if (err == Cproton::PN_TIMEOUT) then
@@ -399,7 +473,11 @@ module Qpid
         Qpid::Proton::Tracker.new(impl)
       end
 
-      # Accepts the incoming message identified by the tracker.
+      # Signal the sender that you have acted on the Message
+      # pointed to by the tracker.  If no tracker is supplied,
+      # then all messages that have been returned by the get
+      # method are accepted, except those that have already been
+      # auto-settled by passing beyond your incoming window size.
       #
       # ==== Options
       #
@@ -417,6 +495,9 @@ module Qpid
       end
 
       # Rejects the incoming message identified by the tracker.
+      # If no tracker is supplied, all messages that have been returned
+      # by the get method are rejected, except those that have already
+      # been auto-settled by passing beyond your outgoing window size.
       #
       # ==== Options
       #
@@ -434,8 +515,10 @@ module Qpid
       end
 
       # Gets the last known remote state of the delivery associated with
-      # the given tracker. See TrackerStatus for details on the values
-      # returned.
+      # the given tracker, as long as the Message is still within your 
+      # outgoing window. (Also works on incoming messages that are still 
+      # within your incoming queue. See TrackerStatus for details on the 
+      # values returned.
       #
       # ==== Options
       #
@@ -446,7 +529,9 @@ module Qpid
         Qpid::Proton::TrackerStatus.by_value(Cproton.pn_messenger_status(@impl, tracker.impl))
       end
 
-      # Settles messages for a tracker.
+      # Frees a Messenger from tracking the status associated
+      # with a given tracker. If you don't supply a tracker, all
+      # outgoing messages up to the most recent will be settled.
       #
       # ==== Options
       #
@@ -467,9 +552,14 @@ module Qpid
 
       # Sets the incoming window.
       #
-      # If the incoming window is set to a positive value, then after each
-      # call to #accept or #reject, the object will track the status of that
-      # many deliveries.
+      # The Messenger will track the remote status of this many incoming 
+      # deliveries after they have been accepted or rejected.
+      #
+      # Messages enter this window only when you take them into your application
+      # using get().  If your incoming window size is n, and you get n+1 messages
+      # without explicitly accepting or rejecting the oldest message, then the
+      # message that passes beyond the edge of the incoming window will be 
+      # assigned the default disposition of its link.
       #
       # ==== Options
       #
@@ -486,10 +576,14 @@ module Qpid
         Cproton.pn_messenger_get_incoming_window(@impl)
       end
 
-      #Sets the outgoing window.
+      # Sets the outgoing window.
       #
-      # If the outgoing window is set to a positive value, then after each call
-      # to #send, the object will track the status of that  many deliveries.
+      # The Messenger will track the remote status of this many outgoing 
+      # deliveries after calling send.
+      # A Message enters this window when you call the put() method with the
+      # message.  If your outgoing window size is n, and you call put n+1
+      # times, status information will no longer be available for the
+      # first message.
       #
       # ==== Options
       #

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/tracker_status.rb
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/tracker_status.rb?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/tracker_status.rb (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/ruby/lib/qpid_proton/tracker_status.rb Sat Dec 28 16:58:25 2013
@@ -64,6 +64,7 @@ module Qpid
         self.add_item :PENDING,  Cproton::PN_STATUS_PENDING
         self.add_item :ACCEPTED, Cproton::PN_STATUS_ACCEPTED
         self.add_item :REJECTED, Cproton::PN_STATUS_REJECTED
+        self.add_item :SETTLED,  Cproton::PN_STATUS_SETTLED
 
     end
 

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/codec.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/codec.h?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/codec.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/codec.h Sat Dec 28 16:58:25 2013
@@ -25,6 +25,7 @@
 #include <proton/import_export.h>
 #include <proton/object.h>
 #include <proton/types.h>
+#include <proton/error.h>
 #ifndef __cplusplus
 #include <stdbool.h>
 #include <stdint.h>
@@ -98,7 +99,7 @@ typedef struct pn_data_t pn_data_t;
 PN_EXTERN pn_data_t *pn_data(size_t capacity);
 PN_EXTERN void pn_data_free(pn_data_t *data);
 PN_EXTERN int pn_data_errno(pn_data_t *data);
-PN_EXTERN const char *pn_data_error(pn_data_t *data);
+PN_EXTERN pn_error_t *pn_data_error(pn_data_t *data);
 PN_EXTERN int pn_data_vfill(pn_data_t *data, const char *fmt, va_list ap);
 PN_EXTERN int pn_data_fill(pn_data_t *data, const char *fmt, ...);
 PN_EXTERN int pn_data_vscan(pn_data_t *data, const char *fmt, va_list ap);

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/engine.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/engine.h?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/engine.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/engine.h Sat Dec 28 16:58:25 2013
@@ -120,6 +120,7 @@ typedef int pn_state_t;     /**< encodes
 #define PN_MODIFIED (0x0000000000000027)
 
 typedef int pn_trace_t;
+typedef void (pn_tracer_t)(pn_transport_t *transport, const char *message);
 
 #define PN_TRACE_OFF (0)
 #define PN_TRACE_RAW (1)
@@ -435,6 +436,12 @@ PN_EXTERN int pn_transport_close_head(pn
  */
 PN_EXTERN pn_timestamp_t pn_transport_tick(pn_transport_t *transport, pn_timestamp_t now);
 PN_EXTERN void pn_transport_trace(pn_transport_t *transport, pn_trace_t trace);
+PN_EXTERN void pn_transport_set_tracer(pn_transport_t *transport, pn_tracer_t *tracer);
+PN_EXTERN pn_tracer_t *pn_transport_get_tracer(pn_transport_t *transport);
+PN_EXTERN void pn_transport_set_context(pn_transport_t *transport, void *context);
+PN_EXTERN void *pn_transport_get_context(pn_transport_t *transport);
+PN_EXTERN void pn_transport_log(pn_transport_t *transport, const char *message);
+PN_EXTERN void pn_transport_logf(pn_transport_t *transport, const char *fmt, ...);
 // max frame of zero means "unlimited"
 PN_EXTERN uint32_t pn_transport_get_max_frame(pn_transport_t *transport);
 PN_EXTERN void pn_transport_set_max_frame(pn_transport_t *transport, uint32_t size);

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/error.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/error.h?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/error.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/error.h Sat Dec 28 16:58:25 2013
@@ -43,7 +43,7 @@ typedef struct pn_error_t pn_error_t;
 
 PN_EXTERN const char *pn_code(int code);
 
-PN_EXTERN pn_error_t *pn_error();
+PN_EXTERN pn_error_t *pn_error(void);
 PN_EXTERN void pn_error_free(pn_error_t *error);
 PN_EXTERN void pn_error_clear(pn_error_t *error);
 PN_EXTERN int pn_error_set(pn_error_t *error, int code, const char *text);

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/messenger.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/messenger.h?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/messenger.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/include/proton/messenger.h Sat Dec 28 16:58:25 2013
@@ -43,8 +43,10 @@ typedef enum {
   PN_STATUS_PENDING = 1,
   PN_STATUS_ACCEPTED = 2,
   PN_STATUS_REJECTED = 3,
-  PN_STATUS_MODIFIED = 4,
-  PN_STATUS_ABORTED = 5
+  PN_STATUS_RELEASED = 4,
+  PN_STATUS_MODIFIED = 5,
+  PN_STATUS_ABORTED = 6,
+  PN_STATUS_SETTLED = 7
 } pn_status_t;
 
 /** Construct a new Messenger with the given name. The name is global.
@@ -301,6 +303,8 @@ PN_EXTERN void *pn_subscription_get_cont
 
 PN_EXTERN void pn_subscription_set_context(pn_subscription_t *sub, void *context);
 
+PN_EXTERN const char *pn_subscription_address(pn_subscription_t *sub);
+
 /** Puts the message onto the messenger's outgoing queue.
  * The message may also be sent if transmission would not cause
  * blocking.  This call will not block.
@@ -363,7 +367,10 @@ PN_EXTERN pn_tracker_t pn_messenger_outg
  * This will block for the indicated timeout.
  *
  * @param[in] messenger the Messenger
- * @param[in] timeout the maximum time to block
+ * @param[in] timeout the maximum time to block in milliseconds, -1 ==
+ * forever, 0 == do not block
+ *
+ * @return 0 if no work to do, < 0 if error, or 1 if work was done.
  */
 PN_EXTERN int pn_messenger_work(pn_messenger_t *messenger, int timeout);
 
@@ -518,70 +525,68 @@ PN_EXTERN int pn_messenger_outgoing(pn_m
  */
 PN_EXTERN int pn_messenger_incoming(pn_messenger_t *messenger);
 
-/** Adds a routing rule to a Messenger's internal routing table.
- *
- * The route procedure may be used to influence how a messenger will
- * internally treat a given address or class of addresses. Every call
- * to the route procedure will result in messenger appending a routing
- * rule to its internal routing table.
- *
- * Whenever a message is presented to a messenger for delivery, it
- * will match the address of this message against the set of routing
- * rules in order. The first rule to match will be triggered, and
- * instead of routing based on the address presented in the message,
- * the messenger will route based on the address supplied in the rule.
- *
- * The pattern matching syntax supports two types of matches, a '%'
- * will match any character except a '/', and a '*' will match any
- * character including a '/'.
- *
- * A routing address is specified as a normal AMQP address, however it
- * may additionally use substitution variables from the pattern match
- * that triggered the rule.
- *
- * Any message sent to "foo" will be routed to "amqp://foo.com":
- *
- *   pn_messenger_route("foo", "amqp://foo.com");
- *
- * Any message sent to "foobar" will be routed to
- * "amqp://foo.com/bar":
- *
- *   pn_messenger_route("foobar", "amqp://foo.com/bar");
- *
- * Any message sent to bar/<path> will be routed to the corresponding
- * path within the amqp://bar.com domain:
- *
- *   pn_messenger_route("bar/*", "amqp://bar.com/$1");
- *
- * Route all messages over TLS:
- *
- *   pn_messenger_route("amqp:*", "amqps:$1")
- *
- * Supply credentials for foo.com:
- *
- *   pn_messenger_route("amqp://foo.com/*", "amqp://user:password@foo.com/$1");
- *
- * Supply credentials for all domains:
- *
- *   pn_messenger_route("amqp://*", "amqp://user:password@$1");
- *
- * Route all addresses through a single proxy while preserving the
- * original destination:
- *
- *   pn_messenger_route("amqp://%/*", "amqp://user:password@proxy/$1/$2");
- *
- * Route any address through a single broker:
- *
- *   pn_messenger_route("*", "amqp://user:password@broker/$1");
- *
- * @param[in] messenger the Messenger
- * @param[in] pattern a glob pattern
- * @param[in] address an address indicating alternative routing
- *
- * @return an error code or zero on success
- * @see error.h
- *
- */
+//! Adds a routing rule to a Messenger's internal routing table.
+//!
+//! The route procedure may be used to influence how a messenger will
+//! internally treat a given address or class of addresses. Every call
+//! to the route procedure will result in messenger appending a routing
+//! rule to its internal routing table.
+//!
+//! Whenever a message is presented to a messenger for delivery, it
+//! will match the address of this message against the set of routing
+//! rules in order. The first rule to match will be triggered, and
+//! instead of routing based on the address presented in the message,
+//! the messenger will route based on the address supplied in the rule.
+//!
+//! The pattern matching syntax supports two types of matches, a '%'
+//! will match any character except a '/', and a '*' will match any
+//! character including a '/'.
+//!
+//! A routing address is specified as a normal AMQP address, however it
+//! may additionally use substitution variables from the pattern match
+//! that triggered the rule.
+//!
+//! Any message sent to "foo" will be routed to "amqp://foo.com":
+//!
+//!   pn_messenger_route("foo", "amqp://foo.com");
+//!
+//! Any message sent to "foobar" will be routed to
+//! "amqp://foo.com/bar":
+//!
+//!   pn_messenger_route("foobar", "amqp://foo.com/bar");
+//!
+//! Any message sent to bar/<path> will be routed to the corresponding
+//! path within the amqp://bar.com domain:
+//!
+//!   pn_messenger_route("bar/*", "amqp://bar.com/$1");
+//!
+//! Route all messages over TLS:
+//!
+//!   pn_messenger_route("amqp:*", "amqps:$1")
+//!
+//! Supply credentials for foo.com:
+//!
+//!   pn_messenger_route("amqp://foo.com/*", "amqp://user:password@foo.com/$1");
+//!
+//! Supply credentials for all domains:
+//!
+//!   pn_messenger_route("amqp://*", "amqp://user:password@$1");
+//!
+//! Route all addresses through a single proxy while preserving the
+//! original destination:
+//!
+//!   pn_messenger_route("amqp://%/*", "amqp://user:password@proxy/$1/$2");
+//!
+//! Route any address through a single broker:
+//!
+//!   pn_messenger_route("*", "amqp://user:password@broker/$1");
+//!
+//! @param[in] messenger the Messenger
+//! @param[in] pattern a glob pattern
+//! @param[in] address an address indicating alternative routing
+//!
+//! @return an error code or zero on success
+//! @see error.h
 PN_EXTERN int pn_messenger_route(pn_messenger_t *messenger, const char *pattern,
                                  const char *address);
 

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/codec.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/codec.c?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/codec.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/codec/codec.c Sat Dec 28 16:58:25 2013
@@ -383,9 +383,9 @@ int pn_data_errno(pn_data_t *data)
   return pn_error_code(data->error);
 }
 
-const char *pn_data_error(pn_data_t *data)
+pn_error_t *pn_data_error(pn_data_t *data)
 {
-  return pn_error_text(data->error);
+  return data->error;
 }
 
 size_t pn_data_size(pn_data_t *data)

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.c?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.c Sat Dec 28 16:58:25 2013
@@ -30,12 +30,12 @@
 #include "../util.h"
 #include "../platform_fmt.h"
 
-pn_dispatcher_t *pn_dispatcher(uint8_t frame_type, void *context)
+pn_dispatcher_t *pn_dispatcher(uint8_t frame_type, pn_transport_t *transport)
 {
   pn_dispatcher_t *disp = (pn_dispatcher_t *) calloc(sizeof(pn_dispatcher_t), 1);
 
   disp->frame_type = frame_type;
-  disp->context = context;
+  disp->transport = transport;
   disp->trace = PN_TRACE_OFF;
 
   disp->input = pn_buffer(1024);
@@ -57,6 +57,8 @@ pn_dispatcher_t *pn_dispatcher(uint8_t f
   disp->halt = false;
   disp->batch = true;
 
+  disp->scratch = pn_string(NULL);
+
   return disp;
 }
 
@@ -68,6 +70,7 @@ void pn_dispatcher_free(pn_dispatcher_t 
     pn_data_free(disp->output_args);
     pn_buffer_free(disp->frame);
     free(disp->output);
+    pn_free(disp->scratch);
     free(disp);
   }
 }
@@ -84,45 +87,35 @@ static void pn_do_trace(pn_dispatcher_t 
                         pn_data_t *args, const char *payload, size_t size)
 {
   if (disp->trace & PN_TRACE_FRM) {
-    size_t n = SCRATCH;
-    pn_data_format(args, disp->scratch, &n);
-    pn_dispatcher_trace(disp, ch, "%s %s", dir == OUT ? "->" : "<-",
-                        disp->scratch);
+    pn_string_format(disp->scratch, "%u %s ", ch, dir == OUT ? "->" : "<-");
+    pn_inspect(args, disp->scratch);
+
     if (size) {
       char buf[1024];
       int e = pn_quote_data(buf, 1024, payload, size);
-      fprintf(stderr, " (%" PN_ZU ") \"%s\"%s\n", size, buf,
-              e == PN_OVERFLOW ? "... (truncated)" : "");
-    } else {
-      fprintf(stderr, "\n");
+      pn_string_addf(disp->scratch, " (%" PN_ZU ") \"%s\"%s", size, buf,
+                     e == PN_OVERFLOW ? "... (truncated)" : "");
     }
-  }
-}
 
-void pn_dispatcher_trace(pn_dispatcher_t *disp, uint16_t ch, const char *fmt, ...)
-{
-  va_list ap;
-  fprintf(stderr, "[%p:%u] ", (void *) disp, ch);
-
-  va_start(ap, fmt);
-  vfprintf(stderr, fmt, ap);
-  va_end(ap);
+    pn_transport_log(disp->transport, pn_string_get(disp->scratch));
+  }
 }
 
 int pn_dispatch_frame(pn_dispatcher_t *disp, pn_frame_t frame)
 {
   if (frame.size == 0) { // ignore null frames
     if (disp->trace & PN_TRACE_FRM)
-      pn_dispatcher_trace(disp, frame.channel, "<- (EMPTY FRAME)\n");
+      pn_transport_logf(disp->transport, "%u <- (EMPTY FRAME)\n", frame.channel);
     return 0;
   }
 
   ssize_t dsize = pn_data_decode(disp->args, frame.payload, frame.size);
   if (dsize < 0) {
-    fprintf(stderr, "Error decoding frame: %s %s\n", pn_code(dsize),
-            pn_data_error(disp->args));
-    pn_fprint_data(stderr, frame.payload, frame.size);
-    fprintf(stderr, "\n");
+    pn_string_format(disp->scratch,
+                     "Error decoding frame: %s %s\n", pn_code(dsize),
+                     pn_error_text(pn_data_error(disp->args)));
+    pn_quote(disp->scratch, frame.payload, frame.size);
+    pn_transport_log(disp->transport, pn_string_get(disp->scratch));
     return dsize;
   }
 
@@ -132,11 +125,11 @@ int pn_dispatch_frame(pn_dispatcher_t *d
   bool scanned;
   int e = pn_data_scan(disp->args, "D?L.", &scanned, &lcode);
   if (e) {
-    fprintf(stderr, "Scan error\n");
+    pn_transport_log(disp->transport, "Scan error");
     return e;
   }
   if (!scanned) {
-    fprintf(stderr, "Error dispatching frame\n");
+    pn_transport_log(disp->transport, "Error dispatching frame");
     return PN_ERR;
   }
   uint8_t code = lcode;
@@ -207,7 +200,9 @@ int pn_post_frame(pn_dispatcher_t *disp,
   int err = pn_data_vfill(disp->output_args, fmt, ap);
   va_end(ap);
   if (err) {
-    fprintf(stderr, "error posting frame: %s, %s: %s\n", fmt, pn_code(err), pn_data_error(disp->output_args));
+    pn_transport_logf(disp->transport,
+                      "error posting frame: %s, %s: %s", fmt, pn_code(err),
+                      pn_error_text(pn_data_error(disp->output_args)));
     return PN_ERR;
   }
 
@@ -224,7 +219,8 @@ int pn_post_frame(pn_dispatcher_t *disp,
       pn_buffer_ensure( disp->frame, pn_buffer_available( disp->frame ) * 2 );
       goto encode_performatives;
     }
-    fprintf(stderr, "error posting frame: %s", pn_code(wr));
+    pn_transport_logf(disp->transport,
+                      "error posting frame: %s", pn_code(wr));
     return PN_ERR;
   }
 
@@ -240,9 +236,10 @@ int pn_post_frame(pn_dispatcher_t *disp,
   }
   disp->output_frames_ct += 1;
   if (disp->trace & PN_TRACE_RAW) {
-    fprintf(stderr, "RAW: \"");
-    pn_fprint_data(stderr, disp->output + disp->available, n);
-    fprintf(stderr, "\"\n");
+    pn_string_set(disp->scratch, "RAW: \"");
+    pn_quote(disp->scratch, disp->output + disp->available, n);
+    pn_string_addf(disp->scratch, "\"");
+    pn_transport_log(disp->transport, pn_string_get(disp->scratch));
   }
   disp->available += n;
 
@@ -281,7 +278,9 @@ int pn_post_transfer_frame(pn_dispatcher
                          message_format,
                          settled, more_flag);
   if (err) {
-    fprintf(stderr, "error posting transfer frame: %s: %s\n", pn_code(err), pn_data_error(disp->output_args));
+    pn_transport_logf(disp->transport,
+                      "error posting transfer frame: %s: %s", pn_code(err),
+                      pn_error_text(pn_data_error(disp->output_args)));
     return PN_ERR;
   }
 
@@ -298,7 +297,7 @@ int pn_post_transfer_frame(pn_dispatcher
         pn_buffer_ensure( disp->frame, pn_buffer_available( disp->frame ) * 2 );
         goto encode_performatives;
       }
-      fprintf(stderr, "error posting frame: %s", pn_code(wr));
+      pn_transport_logf(disp->transport, "error posting frame: %s", pn_code(wr));
       return PN_ERR;
     }
     buf.size = wr;
@@ -346,9 +345,10 @@ int pn_post_transfer_frame(pn_dispatcher
     disp->output_frames_ct += 1;
     framecount++;
     if (disp->trace & PN_TRACE_RAW) {
-      fprintf(stderr, "RAW: \"");
-      pn_fprint_data(stderr, disp->output + disp->available, n);
-      fprintf(stderr, "\"\n");
+      pn_string_set(disp->scratch, "RAW: \"");
+      pn_quote(disp->scratch, disp->output + disp->available, n);
+      pn_string_addf(disp->scratch, "\"");
+      pn_transport_log(disp->transport, pn_string_get(disp->scratch));
     }
     disp->available += n;
   } while (disp->output_size > 0 && framecount < frame_limit);

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.h?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/dispatcher/dispatcher.h Sat Dec 28 16:58:25 2013
@@ -55,15 +55,15 @@ struct pn_dispatcher_t {
   size_t capacity;
   size_t available; /* number of raw bytes pending output */
   char *output;
-  void *context;
+  pn_transport_t *transport;
   bool halt;
   bool batch;
   uint64_t output_frames_ct;
   uint64_t input_frames_ct;
-  char scratch[SCRATCH];
+  pn_string_t *scratch;
 };
 
-pn_dispatcher_t *pn_dispatcher(uint8_t frame_type, void *context);
+pn_dispatcher_t *pn_dispatcher(uint8_t frame_type, pn_transport_t *transport);
 void pn_dispatcher_free(pn_dispatcher_t *disp);
 void pn_dispatcher_action(pn_dispatcher_t *disp, uint8_t code,
                           pn_action_t *action);
@@ -72,7 +72,6 @@ void pn_set_payload(pn_dispatcher_t *dis
 int pn_post_frame(pn_dispatcher_t *disp, uint16_t ch, const char *fmt, ...);
 ssize_t pn_dispatcher_input(pn_dispatcher_t *disp, const char *bytes, size_t available);
 ssize_t pn_dispatcher_output(pn_dispatcher_t *disp, char *bytes, size_t size);
-void pn_dispatcher_trace(pn_dispatcher_t *disp, uint16_t ch, const char *fmt, ...);
 int pn_post_transfer_frame(pn_dispatcher_t *disp,
                            uint16_t local_channel,
                            uint32_t handle,

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/engine/engine-internal.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/engine/engine-internal.h?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/engine/engine-internal.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/engine/engine-internal.h Sat Dec 28 16:58:25 2013
@@ -110,6 +110,7 @@ typedef struct pn_io_layer_t {
 } pn_io_layer_t;
 
 struct pn_transport_t {
+  pn_tracer_t *tracer;
   size_t header_count;
   pn_sasl_t *sasl;
   pn_ssl_t *ssl;
@@ -150,7 +151,7 @@ struct pn_transport_t {
   pn_error_t *error;
   pn_hash_t *local_channels;
   pn_hash_t *remote_channels;
-  char scratch[SCRATCH];
+  pn_string_t *scratch;
 
   /* statistics */
   uint64_t bytes_input;
@@ -167,6 +168,7 @@ struct pn_transport_t {
   char *input_buf;
   bool tail_closed;      // input stream closed by driver
 
+  void *context;
 };
 
 struct pn_connection_t {

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.c?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.c Sat Dec 28 16:58:25 2013
@@ -126,7 +126,7 @@ static pn_listener_ctx_t *pn_listener_ct
     pn_ssl_domain_allow_unsecured_client(ctx->domain);
   }
 
-  pn_subscription_t *sub = pn_subscription(messenger, scheme);
+  pn_subscription_t *sub = pn_subscription(messenger, scheme, host, port);
   ctx->subscription = sub;
   ctx->host = pn_strdup(host);
   ctx->port = pn_strdup(port);
@@ -743,6 +743,14 @@ void pn_messenger_endpoints(pn_messenger
   while (link) {
     if (pn_link_is_sender(link)) {
       pni_pump_out(messenger, pn_terminus_get_address(pn_link_target(link)), link);
+    } else {
+      pn_link_ctx_t *ctx = (pn_link_ctx_t *) pn_link_get_context(link);
+      if (ctx) {
+        const char *addr = pn_terminus_get_address(pn_link_remote_source(link));
+        if (ctx->subscription) {
+          pni_subscription_set_address(ctx->subscription, addr);
+        }
+      }
     }
     link = pn_link_next(link, PN_LOCAL_ACTIVE | PN_REMOTE_ACTIVE);
   }
@@ -1106,6 +1114,7 @@ pn_link_t *pn_messenger_link(pn_messenge
   char *name = NULL;
   pn_connection_t *connection = pn_messenger_resolve(messenger, address, &name);
   if (!connection) return NULL;
+  pn_connection_ctx_t *cctx = (pn_connection_ctx_t *) pn_connection_get_context(connection);
 
   pn_link_t *link = pn_link_head(connection, PN_LOCAL_ACTIVE);
   while (link) {
@@ -1129,13 +1138,22 @@ pn_link_t *pn_messenger_link(pn_messenge
     pn_link_set_rcv_settle_mode( link, PN_RCV_SECOND );
   }
   // XXX
-  pn_terminus_set_address(pn_link_target(link), name);
-  pn_terminus_set_address(pn_link_source(link), name);
+  if (pn_streq(name, "#")) {
+    if (pn_link_is_sender(link)) {
+      pn_terminus_set_dynamic(pn_link_target(link), true);
+    } else {
+      pn_terminus_set_dynamic(pn_link_source(link), true);
+    }
+  } else {
+    pn_terminus_set_address(pn_link_target(link), name);
+    pn_terminus_set_address(pn_link_source(link), name);
+  }
   link_ctx_setup( messenger, connection, link );
   if (!sender) {
     pn_link_ctx_t *ctx = (pn_link_ctx_t *)pn_link_get_context(link);
     assert( ctx );
-    ctx->subscription = pn_subscription(messenger, NULL);
+    ctx->subscription = pn_subscription(messenger, cctx->scheme, cctx->host,
+                                        cctx->port);
   }
   pn_link_open(link);
   return link;
@@ -1374,6 +1392,7 @@ int pn_messenger_put(pn_messenger_t *mes
 
 pn_tracker_t pn_messenger_outgoing_tracker(pn_messenger_t *messenger)
 {
+  assert(messenger);
   return messenger->outgoing_tracker;
 }
 
@@ -1403,7 +1422,12 @@ bool pn_messenger_buffered(pn_messenger_
   pni_entry_t *e = pni_store_entry(store, pn_tracker_sequence(tracker));
   if (e) {
     pn_delivery_t *d = pni_entry_get_delivery(e);
-    return d && pn_delivery_buffered(d);
+    if (d) {
+      bool b = pn_delivery_buffered(d);
+      return b;
+    } else {
+      return true;
+    }
   } else {
     return false;
   }
@@ -1488,7 +1512,23 @@ static bool work_pred(pn_messenger_t *me
 int pn_messenger_work(pn_messenger_t *messenger, int timeout)
 {
   messenger->worked = false;
-  return pn_messenger_tsync(messenger, work_pred, timeout);
+  int err = pn_messenger_tsync(messenger, work_pred, timeout);
+  if (err) return err;
+  return (int) (messenger->worked ? 1 : 0);
+}
+
+int pni_messenger_work(pn_messenger_t *messenger)
+{
+  if (messenger->blocking) {
+    return pn_messenger_work(messenger, messenger->timeout);
+  } else {
+    int err = pn_messenger_work(messenger, 0);
+    if (err == PN_TIMEOUT) {
+      return PN_INPROGRESS;
+    } else {
+      return err;
+    }
+  }
 }
 
 int pn_messenger_interrupt(pn_messenger_t *messenger)
@@ -1582,6 +1622,7 @@ int pn_messenger_get(pn_messenger_t *mes
 
 pn_tracker_t pn_messenger_incoming_tracker(pn_messenger_t *messenger)
 {
+  assert(messenger);
   return messenger->incoming_tracker;
 }
 

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.h
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.h?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.h (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/messenger.h Sat Dec 28 16:58:25 2013
@@ -25,5 +25,6 @@
 #include <proton/messenger.h>
 
 int pni_messenger_add_subscription(pn_messenger_t *messenger, pn_subscription_t *subscription);
+int pni_messenger_work(pn_messenger_t *messenger);
 
 #endif /* messenger.h */

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/store.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/store.c?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/store.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/store.c Sat Dec 28 16:58:25 2013
@@ -300,7 +300,7 @@ static pn_status_t disp2status(uint64_t 
   case PN_REJECTED:
     return PN_STATUS_REJECTED;
   case PN_RELEASED:
-    return PN_STATUS_PENDING;
+    return PN_STATUS_RELEASED;
   case PN_MODIFIED:
     return PN_STATUS_MODIFIED;
   default:
@@ -319,7 +319,12 @@ void pni_entry_updated(pni_entry_t *entr
     if (pn_delivery_remote_state(d)) {
       entry->status = disp2status(pn_delivery_remote_state(d));
     } else if (pn_delivery_settled(d)) {
-      entry->status = disp2status(pn_delivery_local_state(d));
+      uint64_t disp = pn_delivery_local_state(d);
+      if (disp) {
+        entry->status = disp2status(disp);
+      } else {
+        entry->status = PN_STATUS_SETTLED;
+      }
     } else {
       entry->status = PN_STATUS_PENDING;
     }

Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/subscription.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/subscription.c?rev=1553874&r1=1553873&r2=1553874&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/subscription.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/src/messenger/subscription.c Sat Dec 28 16:58:25 2013
@@ -22,12 +22,16 @@
 #include <proton/messenger.h>
 #include <proton/object.h>
 #include <assert.h>
+#include <string.h>
 
 #include "messenger.h"
 
 struct pn_subscription_t {
   pn_messenger_t *messenger;
   pn_string_t *scheme;
+  pn_string_t *host;
+  pn_string_t *port;
+  pn_string_t *address;
   void *context;
 };
 
@@ -36,6 +40,9 @@ void pn_subscription_initialize(void *ob
   pn_subscription_t *sub = (pn_subscription_t *) obj;
   sub->messenger = NULL;
   sub->scheme = pn_string(NULL);
+  sub->host = pn_string(NULL);
+  sub->port = pn_string(NULL);
+  sub->address = pn_string(NULL);
   sub->context = NULL;
 }
 
@@ -43,18 +50,26 @@ void pn_subscription_finalize(void *obj)
 {
   pn_subscription_t *sub = (pn_subscription_t *) obj;
   pn_free(sub->scheme);
+  pn_free(sub->host);
+  pn_free(sub->port);
+  pn_free(sub->address);
 }
 
 #define pn_subscription_hashcode NULL
 #define pn_subscription_compare NULL
 #define pn_subscription_inspect NULL
 
-pn_subscription_t *pn_subscription(pn_messenger_t *messenger, const char *scheme)
+pn_subscription_t *pn_subscription(pn_messenger_t *messenger,
+                                   const char *scheme,
+                                   const char *host,
+                                   const char *port)
 {
   static pn_class_t clazz = PN_CLASS(pn_subscription);
   pn_subscription_t *sub = (pn_subscription_t *) pn_new(sizeof(pn_subscription_t), &clazz);
   sub->messenger = messenger;
   pn_string_set(sub->scheme, scheme);
+  pn_string_set(sub->host, host);
+  pn_string_set(sub->port, port);
   pni_messenger_add_subscription(messenger, sub);
   pn_decref(sub);
   return sub;
@@ -77,3 +92,44 @@ void pn_subscription_set_context(pn_subs
   assert(sub);
   sub->context = context;
 }
+
+int pni_subscription_set_address(pn_subscription_t *sub, const char *address)
+{
+  assert(sub);
+
+  if (!address) return 0;
+
+  bool absolute = strncmp(address, "amqp:", 5) == 0;
+
+  if (absolute) {
+    return pn_string_set(sub->address, address);
+  } else {
+    pn_string_set(sub->address, "");
+    bool scheme = pn_string_get(sub->scheme);
+    if (scheme) {
+      int e = pn_string_addf(sub->address, "%s:", pn_string_get(sub->scheme));
+      if (e) return e;
+    }
+    if (pn_string_get(sub->host)) {
+      int e = pn_string_addf(sub->address, scheme ? "//%s" : "%s", pn_string_get(sub->host));
+      if (e) return e;
+    }
+    if (pn_string_get(sub->port)) {
+      int e = pn_string_addf(sub->address, ":%s", pn_string_get(sub->port));
+      if (e) return e;
+    }
+    return pn_string_addf(sub->address, "/%s", address);
+  }
+}
+
+const char *pn_subscription_address(pn_subscription_t *sub)
+{
+  assert(sub);
+  while (!pn_string_get(sub->address)) {
+    int err = pni_messenger_work(sub->messenger);
+    if (err < 0) {
+      return NULL;
+    }
+  }
+  return pn_string_get(sub->address);
+}



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


Mime
View raw message